@codingfactory/mediables-vue 2.4.14 → 2.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- "use strict";var Fd=Object.defineProperty;var Id=(a,n,t)=>n in a?Fd(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var L=(a,n,t)=>Id(a,typeof n!="symbol"?n+"":n,t);const wa=require("pinia"),e=require("vue"),ze=require("pixi.js"),ct=require("./editor-DJk8cX17.cjs"),I=require("@ionic/vue"),Rd=require("pixi-filters");function $d(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Ye=$d(ze),Ei=1,Dd=new Set(["free","square","circle"]);function Ud(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function Ad(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Hi(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==Ei)return null;const t=n.crop,o=t&&Ad(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Dd.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,c=[];if(Array.isArray(s))for(const l of s){if(!l||typeof l!="object")continue;const d=l;if(typeof d.id!="string")continue;const u={},m=d.values;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[f,p]of Object.entries(m))Ud(p)&&(u[f]=p);c.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:Ei,crop:{rect:o,aspectRatio:r,shape:i},filters:c}}function Ks(a){const n=Hi(a);return n?JSON.stringify(n):null}function Od(a){try{const n=JSON.parse(a);return Hi(n)}catch{return null}}function Ld(){return{version:Ei,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Vt={apiBaseUrl:"/api/v1",isAdmin:!1};function Rn(a){Vt={...Vt,...a}}function qs(){return{...Vt}}function Qs(a){Vt={...a}}function el(a){const n=qs();return Rn(a),()=>{Qs(n)}}const zd=async(a,n={})=>{var c;const t=(c=document.querySelector('meta[name="csrf-token"]'))==null?void 0:c.getAttribute("content"),o={Accept:"application/json",...n.headers};t&&(o["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:n.method||"GET",headers:o,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(a,r);if(!s.ok){const l=await s.json().catch(()=>({message:"Request failed"}));throw new Error(l.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},xt=wa.defineStore("media",()=>{const a=e.ref([]),n=e.ref([]),t=e.ref(!1),o=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),c=e.ref({type:null,uuid:null}),l=e.ref([]),d=e.ref(!1),u=e.ref(null),m=e.ref(new Map),f=e.ref(new Map),p=e.ref(new Set),v=e.ref(new Map),g=e.ref({}),E=5*60*1e3,T=e.computed(()=>{if(Vt.apiScope)return Vt.apiScope;if(Vt.isAdmin)return"admin"}),N=e.computed(()=>T.value==="admin");function w(){return Vt.httpClient||zd}function h(ce){const se=Vt.apiBaseUrl||"/api/v1",ke=T.value?`/${T.value}`:"";return`${se}${ke}${ce}`}function x(ce,se){return`${T.value??"default"}-${ce}-${JSON.stringify(se)}`}function D(ce){return Date.now()-ce<E}function C(){v.value.clear(),g.value={}}function y(ce){if(!ce||!ce.data)return;const se={};ce.data.forEach(ke=>{const oe=`${ke.file_name}-${ke.collection_name||"default"}`,le=se[oe];(!le||Object.keys(ke.generated_conversions||{}).length>Object.keys(le.generated_conversions||{}).length)&&(se[oe]=ke)}),a.value=Object.values(se),ce.meta&&(i.value=ce.meta.current_page,r.value=Math.ceil(ce.meta.total/ce.meta.per_page))}async function S(ce=1,se={}){const ke=x(ce,se),oe=v.value.get(ke);if(oe&&D(oe.timestamp)){const le=oe.data;return y(le),le}t.value=!0,o.value=null;try{const le=new URLSearchParams;le.append("page",ce.toString()),le.append("per_page",s.value.toString()),N.value&&le.append("linked","1");for(const rt in se)if(Object.prototype.hasOwnProperty.call(se,rt)){const He=se[rt];He!=null&&He!==""&&le.append(rt,String(He))}const Se=await w()(h(`/media?${le}`));return v.value.set(ke,{data:Se,timestamp:Date.now()}),y(Se),Se}catch(le){throw o.value=le instanceof Error?le.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function A(ce,se){t.value=!0,o.value=null;const ke=`${ce.name}-${Date.now()}`,oe={file:ce,progress:0,status:"uploading"};m.value.set(ke,oe);try{const le=new FormData;le.append("file",ce),le.append("collection",se.collection),se.ownerUuid&&(le.append("owner_uuid",se.ownerUuid),le.append("owner_type",se.ownerType||"")),se.usageUuid&&(le.append("usage_uuid",se.usageUuid),le.append("usage_type",se.usageType||""),le.append("usage_purpose",se.usagePurpose||"")),se.customProperties&&le.append("custom_properties",JSON.stringify(se.customProperties));const Se=await w()(h("/media"),{method:"POST",body:le});return oe.status="completed",oe.progress=100,oe.media=Se==null?void 0:Se.data,i.value===1&&(Se!=null&&Se.data)&&(a.value=[Se.data,...a.value]),C(),(Se==null?void 0:Se.data)||null}catch(le){throw oe.status="error",oe.error=le instanceof Error?le.message:"Upload failed",o.value=oe.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(ke)},5e3)}}async function k(ce){t.value=!0,o.value=null;const se=a.value.findIndex(oe=>oe.uuid===ce);let ke;se!==-1&&(ke=a.value.splice(se,1)[0]);try{return await w()(h(`/media/${ce}`),{method:"DELETE"}),p.value.delete(ce),C(),!0}catch(oe){throw ke&&se!==-1&&a.value.splice(se,0,ke),o.value=oe instanceof Error?oe.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function B(ce,se){t.value=!0,o.value=null;try{const oe=await w()(h(`/media/${ce}`),{method:"PATCH",body:se,data:se});if(oe!=null&&oe.data){const le=a.value.findIndex(Ee=>Ee.uuid===ce);return le!==-1&&(a.value[le]={...a.value[le],...oe.data}),C(),oe.data}return null}catch(ke){throw o.value=ke instanceof Error?ke.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function R(){t.value=!0,o.value=null;try{const se=await w()(h("/media/collections"));return n.value=(se==null?void 0:se.data)||[],n.value}catch(ce){throw o.value=ce instanceof Error?ce.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function U(ce,se,ke="images",oe){d.value=!0,u.value=null;try{const le=new URLSearchParams;le.append("collection",ke),oe&&le.append("search",oe);const Se=await w()(h(`/media/model/${ce}/${se}?${le}`));return Se!=null&&Se.data?(l.value=Se.data,Se.data):[]}catch(le){throw u.value=le instanceof Error?le.message:"Failed to fetch model media",l.value=[],new Error(u.value)}finally{d.value=!1}}async function _(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value];try{const Se=await w()(h(`/media/model/${ce}/${se}/attach`),{method:"POST",body:{media_uuids:ke,collection:oe}});return await U(ce,se,oe),(Se==null?void 0:Se.data)||[]}catch(Ee){throw l.value=le,u.value=Ee instanceof Error?Ee.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function z(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value];l.value=l.value.filter(Ee=>Ee.uuid!==ke);try{return await w()(h(`/media/model/${ce}/${se}/detach`),{method:"POST",body:{media_uuid:ke,collection:oe}}),!0}catch(Ee){throw l.value=le,u.value=Ee instanceof Error?Ee.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function H(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value],Ee=new Map(l.value.map(Se=>[Se.uuid,Se]));l.value=ke.map(Se=>Ee.get(Se)).filter(Se=>Se!==void 0);try{return await w()(h(`/media/model/${ce}/${se}/reorder`),{method:"POST",body:{media_uuids:ke,collection:oe}}),!0}catch(Se){throw l.value=le,u.value=Se instanceof Error?Se.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function M(ce,se,ke={}){const oe=w(),le=Vt.apiBaseUrl||"/api/v1",Ee=new FormData,Se=se.imageData,rt=Se.match(/^data:(image\/\w+);base64,/),He=rt?rt[1]:"image/png",pt=Se.replace(/^data:image\/\w+;base64,/,""),K=atob(pt),de=new Uint8Array(K.length);for(let J=0;J<K.length;J++)de[J]=K.charCodeAt(J);const ie=new Blob([de],{type:He});Ee.append("image_file",ie,`edited.${He==="image/jpeg"?"jpg":"png"}`);const he=Ks(se.state);he&&Ee.append("editor_state",he),se.metadata&&(Ee.append("filters",JSON.stringify(se.metadata.filters)),se.metadata.cropRect&&Ee.append("crop_data",JSON.stringify(se.metadata.cropRect))),Ee.append("save_as_new","true"),ke.asVariant&&Ee.append("as_variant","true"),ke.name!==void 0&&Ee.append("name",ke.name);const _e=await oe(`${le}/editor/${ce}/save`,{method:"POST",body:Ee});if("media"in _e&&_e.media)return _e.media;if("status_url"in _e&&_e.status_url)return $(oe,_e.status_url,ke.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function $(ce,se,ke){const oe=Date.now(),le=2e3;for(;Date.now()-oe<ke;){await new Promise(Se=>setTimeout(Se,le));const Ee=await ce(se);if(Ee.status==="completed"&&Ee.media)return Ee.media;if(Ee.status==="failed")throw new Error(Ee.error??"Image processing failed")}throw new Error("Image processing timed out")}function X(ce,se,ke){c.value=ke!==void 0?{type:ce,uuid:se,collection:ke}:{type:ce,uuid:se},g.value[`${ce}-${se}`]={timestamp:Date.now()}}function j(){c.value={type:null,uuid:null},l.value=[],u.value=null}async function te(){if(!c.value.type||!c.value.uuid)return;const ce=await U(c.value.type,c.value.uuid,c.value.collection||"images");l.value=ce||[]}function ge(){a.value.forEach(ce=>p.value.add(ce.uuid))}function Ne(){p.value.clear()}function ee(ce){p.value.has(ce)?p.value.delete(ce):p.value.add(ce)}function F(ce){return p.value.has(ce)}function P(){return Array.from(m.value.values()).some(ce=>ce.status==="uploading")}function fe(ce){return m.value.get(ce)||f.value.get(ce)}function ne(){return[...Array.from(m.value.values()),...Array.from(f.value.values())]}async function Y(){const ce=Array.from(p.value);let se=0;for(const ke of ce)try{await k(ke),se++}catch{}return Ne(),se}function Me(ce,se){var ke;return se&&((ke=ce.conversion_urls)!=null&&ke[se])?ce.conversion_urls[se]||"":ce.original_url||ce.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:N,modelContext:c,modelMedia:l,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:f,cachedResponses:g,fetchMedia:S,uploadFile:A,deleteMedia:k,updateMedia:B,clearCache:C,fetchCollections:R,fetchModelMedia:U,attachMedia:_,detachMedia:z,reorderMedia:H,saveEditedImage:M,setModelContext:X,clearModelContext:j,refreshModelMedia:te,selectAllItems:ge,clearSelection:Ne,toggleSelection:ee,isSelected:F,deleteSelectedItems:Y,getHttpClient:w,getApiUrl:h,hasActiveUploads:P,getUploadProgress:fe,getAllUploadProgress:ne,getMediaUrl:Me}}),tl=()=>((Vt.apiScope!=="admin"||Vt.isAdmin!==!0)&&Rn({...Vt,apiScope:"admin",isAdmin:!0}),xt());function Pd(a,n){try{let t=ct.getFilter(a);if(t||(ct.registerCorePixiFilters(),t=ct.getFilter(a)),!t){try{const r=ct.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const jd=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function c(){var E;if(!r){o("error",new Error("Editor not initialized"));return}const u=r.exportImage("png",.92);if(!u){o("error",new Error("Failed to export image — the image could not be processed"));return}const m=r.getSerializableState(),f=r._renderer,p=((E=f.getExportDimensions)==null?void 0:E.call(f))??{width:0,height:0},v={width:Math.round(p.width),height:Math.round(p.height)};o("save",{imageData:u,dimensions:v,state:m})}function l(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Ye,ct.initializeFilterRegistry();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"),r=new ct.VanillaImageEditor(i.value,u),r.setFilterRegistry({getAllFilters:ct.getAllFilters,getFilter:ct.getFilter,getFiltersByCategory:ct.getFiltersByCategory}),r.save=function(){c()},r.on("cancel",l),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}return e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const m=u[0];m&&m.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))}),e.watch(()=>t.initialImage,u=>{r&&u&&r.loadImage(u,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.watch(()=>t.sessionKey,()=>{r&&t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(u,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Be=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},nl=Be(jd,[["__scopeId","data-v-d6416384"]]),Wd={class:"editor-modal-panel"},Zd={class:"editor-fill"},Xd=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{default:null},sessionKey:{default:0},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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),c=e.ref(null),l=g=>{o("error",g)},d=()=>{e.nextTick(()=>{if(i.value){const g=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");g&&g.focus()}})};e.watch(()=>t.modelValue,g=>{r.value=g,g&&(c.value=document.activeElement,d())},{immediate:!0});const u=async g=>{try{s.value=!0,t.onSave&&await t.onSave(g),o("save",g)}catch(E){l(E)}finally{s.value=!1}},m=()=>{o("cancel"),p()},f=()=>{s.value||p()},p=()=>{r.value=!1,o("update:modelValue",!1),c.value&&c.value instanceof HTMLElement&&(c.value.focus(),c.value=null)},v=g=>{if(g.key==="Escape"&&r.value&&!s.value){p();return}if(g.key==="Tab"&&r.value&&i.value){const E=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(E.length===0)return;const T=E[0],N=E[E.length-1];g.shiftKey&&document.activeElement===T?(g.preventDefault(),N.focus()):!g.shiftKey&&document.activeElement===N&&(g.preventDefault(),T.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(g,E)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(f,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:f}),e.createElementVNode("div",Wd,[e.createElementVNode("div",Zd,[e.createVNode(nl,{"initial-image":g.initialImage,"initial-state":g.initialState,"session-key":g.sessionKey,theme:g.theme,"crop-shape":g.cropShape,preset:g.preset,"primary-color":g.primaryColor,"secondary-color":g.secondaryColor,"save-button-color":g.saveButtonColor,"download-button-color":g.downloadButtonColor,onSave:u,onCancel:m,onError:l},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),ol=Be(Xd,[["__scopeId","data-v-9ca8dea8"]]),Hd={class:"media-workspace"},Gd={class:"media-workspace-toolbar"},Jd={class:"media-workspace-label"},Yd=["value"],Kd={class:"media-workspace-grid"},qd=["onClick"],Qd=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var m;const t=a,o=n,i=xt(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),s=e.computed(()=>t.subScopes),c=e.computed(()=>s.value.find(f=>f.id===r.value));let l=null;function d(){l&&(l(),l=null),t.apiScope&&(l=el({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const f={};(p=c.value)!=null&&p.collection&&(f.collection=c.value.collection),await i.fetchMedia(1,f),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,f=>{f&&f!==r.value&&(r.value=f)}),e.watch(()=>t.subScopes,f=>{if(f.length===0){r.value="";return}f.some(p=>p.id===r.value)||(r.value=f[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,f=>{f&&(o("scope-change",f),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{l&&(l(),l=null)}),(f,p)=>(e.openBlock(),e.createElementBlock("div",Hd,[e.createElementVNode("div",Gd,[e.createElementVNode("label",Jd,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=v=>r.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,Yd))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=v=>o("upload"))}," Upload ")]),e.createElementVNode("div",Kd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:g=>o("preview",v)},e.toDisplayString(v.file_name),9,qd))),128))])]))}}),eu=Be(Qd,[["__scopeId","data-v-895f26fe"]]),tu={class:"managed-media-gallery"},nu={class:"gallery-grid"},ou=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(a){return(n,t)=>(e.openBlock(),e.createElementBlock("div",tu,[e.createElementVNode("div",nu,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),au=Be(ou,[["__scopeId","data-v-a60fdcd7"]]),iu="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>",Gi="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>",ru="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>",Ji="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>",su="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>",lu="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>",no="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>",cu="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>",il="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>",es="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>",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' stroke-width='48' d='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",uu="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>",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' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",$n="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>",ns="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>",mu="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>",rn="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>",pu="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>",Yn="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>",fu="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>",hu="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>",os="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>",rl="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>",ho="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>",vu="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>",gu="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>",yu="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>",oo="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>",as="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>",ri="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>",wu="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>",bu="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>",si="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>",ku="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>",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' 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>",Eu="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>",Vu="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>",ll="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>",Su="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>",Cu="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>",Nu="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>",_u="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>",cl="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>",Tu="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>",Mu="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>",dl="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>",Bu="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>",Fu="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>",On="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>",Iu="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>",Ru="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>",is="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>",Yi="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>",$u="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>",li="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>",an="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>",Kn="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>",rs="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>",Du="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>",ul="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>",Uu="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>",ml="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>",Au="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>",Ou="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>",Lu="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>",zu="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>",Pu="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>",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-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>",Wu="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>",Ao="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 ss=()=>{};function Zu(a,n){function t(...o){return new Promise((i,r)=>{Promise.resolve(a(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})).then(i).catch(r)})}return t}function Xu(a,n={}){let t,o,i=ss;const r=l=>{clearTimeout(l),i(),i=ss};let s;return l=>{const d=e.toValue(a),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(l())):new Promise((m,f)=>{i=n.rejectOnCancel?f:m,s=l,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,m(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,m(l())},d)})}}function Hu(a,n=200,t={}){return Zu(Xu(n,t),a)}const qn=new Map;function Gu(a){const n=e.getCurrentScope();function t(c){var l;const d=qn.get(a)||new Set;d.add(c),qn.set(a,d);const u=()=>i(c);return(l=n==null?void 0:n.cleanups)==null||l.push(u),u}function o(c){function l(...d){i(l),c(...d)}return t(l)}function i(c){const l=qn.get(a);l&&(l.delete(c),l.size||r())}function r(){qn.delete(a)}function s(c,l){var d;(d=qn.get(a))==null||d.forEach(u=>u(c,l))}return{on:t,once:o,off:i,emit:s,reset:r}}function Ju(){var r,s;const a=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function Yu(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=Gu("media-selection"),r=Ju(),s=e.computed(()=>a.value.filter(x=>n.value.has(x.uuid))),c=e.computed(()=>n.value.size);e.watch(n,x=>{i.emit({type:"selection:changed",count:x.size,selectedIds:Array.from(x)})},{deep:!0});const l=e.computed(()=>a.value.length>0&&a.value.every(x=>n.value.has(x.uuid))),d=e.computed(()=>a.value.some(x=>n.value.has(x.uuid)));function u(x){return n.value.has(x)}function m(x){n.value.has(x)?(n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)):(n.value.add(x),t.value=x,o.value=a.value.findIndex(D=>D.uuid===x),n.value.size===1&&r.selection())}function f(x){n.value.add(x),t.value=x,o.value=a.value.findIndex(D=>D.uuid===x)}function p(x){n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)}function v(){a.value.forEach(x=>n.value.add(x.uuid))}function g(){n.value.clear(),t.value=null,o.value=-1}function E(){l.value?g():v()}function T(x,D){const C=a.value.findIndex(y=>y.uuid===x);if(C!==-1)if(D!=null&&D.shiftKey&&o.value!==-1){const y=Math.min(o.value,C),S=Math.max(o.value,C);for(let A=y;A<=S;A++)n.value.add(a.value[A].uuid)}else m(x)}function N(){if(a.value.length===0)return;let x=o.value+1;x>=a.value.length&&(x=0),g(),f(a.value[x].uuid)}function w(){if(a.value.length===0)return;let x=o.value-1;x<0&&(x=a.value.length-1),g(),f(a.value[x].uuid)}function h(x){switch(x.key){case"ArrowDown":x.preventDefault(),N();break;case"ArrowUp":x.preventDefault(),w();break;case"a":(x.ctrlKey||x.metaKey)&&(x.preventDefault(),v());break;case"Escape":x.preventDefault(),g();break;case" ":t.value&&(x.preventDefault(),m(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:c,isAllSelected:l,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:m,select:f,deselect:p,selectAll:v,clear:g,toggleAll:E,rangeSelect:T,selectNext:N,selectPrevious:w,handleKeydown:h,selectionBus:i}}const Ku={class:"flex items-center justify-between w-full px-4"},qu={class:"p-4"},Qu={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},em={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},tm=["value"],nm={class:"flex gap-2 mt-4"},om={class:"flex justify-end mb-4"},am={key:1,class:"flex justify-center items-center h-64"},im={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},rm={class:"text-sm text-theme-secondary"},sm={key:0},lm={class:"mb-4"},cm={class:"mb-4"},dm={class:"flex gap-2"},um={class:"flex items-center justify-between px-4 py-2"},mm={class:"text-sm text-theme-secondary"},pm={key:0},fm={key:0},hm={key:1},vm={class:"flex gap-2"},gm=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),c=e.ref(!1),l=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),m=e.ref(!1),f=e.ref({}),p=e.ref(["images","documents","videos"]),v=e.ref(1),g=e.ref(!0),E=e.ref(!1),T=tl(),N=Yu(l);function w(F){var se;const P=F.conversion_urls||{},fe=F.proxy_url||F.original_url||F.url||"",ne=P.thumb||P.preview||F.preview_url||F.thumbnail_url||fe,Y=F.custom_properties||{},Me=Y.width,ce=Y.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:fe,url:fe,thumbnail_url:ne,conversions:F.conversions||{},conversion_urls:P,generated_conversions:F.generated_conversions||{},custom_properties:Y,caption:F.caption||null,alt_text:F.alt_text||null,created_at:F.created_at,updated_at:F.updated_at,is_image:((se=F.mime_type)==null?void 0:se.startsWith("image/"))||!1,...typeof Me=="number"?{width:Me}:{},...typeof ce=="number"?{height:ce}:{},...F.formatted_size!==void 0?{formatted_size:F.formatted_size}:{}}}e.watch(()=>t.selectedItems,F=>{u.value=new Set(F),N.clear(),F.forEach(P=>N.select(P))});const h=e.computed(()=>{var P;let F=l.value;return(P=f.value.types)!=null&&P.length&&(F=F.filter(fe=>{var Y,Me;const ne=(Y=fe.mime_type)==null?void 0:Y.split("/")[0];return(Me=f.value.types)==null?void 0:Me.includes(ne)})),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&(F=F.filter(fe=>{const ne=fe.size/1048576;return!(f.value.sizeMin!==void 0&&ne<f.value.sizeMin||f.value.sizeMax!==void 0&&ne>f.value.sizeMax)})),F}),x=e.computed(()=>{var P;let F=0;return f.value.search&&F++,f.value.collection&&F++,(f.value.dateFrom||f.value.dateTo)&&F++,(P=f.value.types)!=null&&P.length&&(F+=f.value.types.length),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&F++,F}),D=e.computed(()=>{const F=N.selectedCount.value;return F===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${F} ${F===1?"Item":"Items"}`:"Item"}`}),C=e.computed(()=>{const F=N.selectedCount.value;return!!(F===0||t.selectionMode==="single"&&F>1||t.maxSelection&&F>t.maxSelection)}),y=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function S(F=!0){F?(c.value=!0,l.value=[],v.value=1,g.value=!0):E.value=!0;try{const P={collection:f.value.collection||t.collection,per_page:24};switch((s.value||f.value.search)&&(P.search=s.value||f.value.search||""),f.value.dateFrom&&(P.from_date=f.value.dateFrom),f.value.dateTo&&(P.to_date=f.value.dateTo),i.value){case"recent":await T.fetchMedia(v.value,P),F?l.value=T.items.map(fe=>w(fe)):l.value=[...l.value,...T.items.map(fe=>w(fe))],g.value=T.currentPage<T.totalPages;break;case"model":if(t.modelType&&t.modelId){const fe=await T.fetchModelMedia(t.modelType,t.modelId,P.collection,P.search);l.value=fe?fe.map(ne=>w(ne)):[],g.value=!1}break;case"library":await T.fetchMedia(v.value,P),F?l.value=T.items.map(fe=>w(fe)):l.value=[...l.value,...T.items.map(fe=>w(fe))],g.value=T.currentPage<T.totalPages;break}}catch{}finally{c.value=!1,E.value=!1}}async function A(F){if(!g.value||E.value){F!=null&&F.target&&F.target.complete();return}v.value++,await S(!1),F!=null&&F.target&&(F.target.complete(),g.value||(F.target.disabled=!0))}function k(F){return F==="recent"||F==="model"||F==="library"}function B(F){i.value=F,S()}function R(F){typeof F=="string"&&k(F)&&B(F)}async function U(F){t.selectionMode==="single"?(N.clear(),N.select(F.uuid)):(N.toggle(F.uuid),t.maxSelection&&N.selectedCount.value>t.maxSelection&&(N.deselect(F.uuid),await(await I.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function _(){o("confirm",N.selectedItems.value)}function z(){o("close")}function H(F){}const M=e.ref(null),$=e.ref(!1);function X(F){M.value=F,$.value=!0}function j(F){const P=l.value.findIndex(ne=>ne.uuid===F.uuid);P!==-1&&(l.value[P]=F);const fe={};F.alt_text!==void 0&&(fe.alt_text=F.alt_text),F.caption!==void 0&&(fe.caption=F.caption),F.custom_properties!==void 0&&(fe.custom_properties=F.custom_properties),T.updateMedia(F.uuid,fe)}function te(){S()}function ge(){f.value={},s.value="",S()}const Ne=Hu(()=>{S(!0)},300);e.watch(s,()=>{t.isOpen&&Ne()});async function ee(F){try{await(await I.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await T.deleteMedia(F),await S()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,F=>{F&&S()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(F=>N.select(F))}),(F,P)=>{const fe=e.resolveComponent("AdminMediaGrid"),ne=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":F.isOpen,onDidDismiss:z,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:z},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Ku,[e.createVNode(e.unref(I.IonSegment),{value:i.value,onIonChange:P[0]||(P[0]=Y=>R(Y.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[15]||(P[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(I.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[16]||(P[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[17]||(P[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(I.IonButton),{fill:"clear",size:"small",onClick:P[1]||(P[1]=Y=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[x.value>0?(e.openBlock(),e.createBlock(e.unref(I.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",qu,[m.value?(e.openBlock(),e.createElementBlock("div",Qu,[e.createElementVNode("div",em,[e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[18]||(P[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":P[2]||(P[2]=Y=>f.value.collection=Y),class:"w-full p-2 border rounded"},[P[19]||(P[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,Y=>(e.openBlock(),e.createElementBlock("option",{key:Y,value:Y},e.toDisplayString(Y),9,tm))),128))],512),[[e.vModelSelect,f.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[20]||(P[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[3]||(P[3]=Y=>f.value.dateFrom=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[21]||(P[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[4]||(P[4]=Y=>f.value.dateTo=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateTo]])])]),e.createElementVNode("div",nm,[e.createVNode(e.unref(I.IonButton),{size:"small",onClick:te},{default:e.withCtx(()=>[...P[22]||(P[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{size:"small",fill:"clear",onClick:ge},{default:e.withCtx(()=>[...P[23]||(P[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":P[5]||(P[5]=Y=>s.value=Y),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",om,[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:P[6]||(P[6]=Y=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(I.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:P[7]||(P[7]=Y=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),c.value?(e.openBlock(),e.createElementBlock("div",am,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):h.value.length===0?(e.openBlock(),e.createElementBlock("div",im,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),P[24]||(P[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",rm,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(fe,{key:3,"media-items":h.value,"selected-items":e.unref(N).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:U,onPreview:H,onEdit:X,onDelete:ee},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(I.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(Y,Me)=>(e.openBlock(),e.createBlock(ne,{key:Y.uuid,media:Y,selected:e.unref(N).isSelected(Y.uuid),"selection-mode":!0,index:Me,onToggleSelect:U,onPreview:H,onEdit:X,onDelete:ee},null,8,["media","selected","index"]))),128))]),_:1})),!c.value&&h.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(I.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:P[8]||(P[8]=Y=>A(Y))},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(I.IonModal),{"is-open":$.value,onDidDismiss:P[14]||(P[14]=Y=>$.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:P[9]||(P[9]=Y=>$.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[...P[25]||(P[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"p-4"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",sm,[e.createElementVNode("div",lm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[26]||(P[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[10]||(P[10]=Y=>M.value.caption=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,M.value.caption]])]),e.createElementVNode("div",cm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[27]||(P[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[11]||(P[11]=Y=>M.value.alt_text=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,M.value.alt_text]])]),e.createElementVNode("div",dm,[e.createVNode(e.unref(I.IonButton),{onClick:P[12]||(P[12]=Y=>j(M.value))},{default:e.withCtx(()=>[...P[28]||(P[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:P[13]||(P[13]=Y=>$.value=!1)},{default:e.withCtx(()=>[...P[29]||(P[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",um,[e.createElementVNode("div",mm,[e.unref(N).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",pm,[e.createTextVNode(e.toDisplayString(e.unref(N).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",fm," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",hm," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",vm,[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:z},{default:e.withCtx(()=>[...P[30]||(P[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{disabled:C.value,onClick:_},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),ym=Be(gm,[["__scopeId","data-v-9a8c0954"]]),wm={key:1,class:"flex flex-col items-center justify-center py-16"},bm=["draggable","onDragstart","onDragover","onDrop"],km={key:0,class:"absolute top-2 left-2 z-20"},xm=["checked","onChange"],Em={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Vm=["data-media-id"],Sm={key:0,class:"w-full h-full flex items-center justify-center"},Cm=["src","alt","onError","onLoad"],Nm={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},_m={class:"text-center"},Tm={class:"text-4xl text-gray-400 mb-2"},Mm={class:"text-sm font-medium text-gray-500"},Bm={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Fm=["onClick"],Im=["onClick"],Rm=["onClick"],$m={class:"p-3"},Dm={class:"text-sm font-medium truncate mb-1"},Um={class:"text-xs text-gray-600 dark:text-gray-400"},Am={key:0},Om={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Lm=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),c=e.ref(null),l=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,S){t.reorderable&&(i.value=y,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/html","")))}function m(C,y){t.reorderable&&(C.preventDefault(),r.value=y)}function f(){r.value=null}function p(C,y){if(!t.reorderable||!i.value)return;C.preventDefault();const S=[...t.mediaItems],A=S.findIndex(k=>{var B;return k.uuid===((B=i.value)==null?void 0:B.uuid)});if(A!==-1&&A!==y&&i.value){const[k]=S.splice(A,1);S.splice(y,0,k),o("reorder",S)}i.value=null,r.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 g(C){var S;return C.thumbnail_url||((S=C.conversion_urls)==null?void 0:S.thumb)||C.original_url||C.url||""}function E(C){var A,k,B;const y=((A=C.mime_type)==null?void 0:A.startsWith("image/"))||!1,S=!!(C.thumbnail_url||(k=C.conversion_urls)!=null&&k.thumb||(B=C.conversion_urls)!=null&&B.preview||C.original_url||C.url);return y&&S}function T(C){var y;return((y=C.split(".").pop())==null?void 0:y.toUpperCase())||""}function N(C){var S;const y=((S=C.mime_type)==null?void 0:S.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&&(c.value=new IntersectionObserver(C=>{C.forEach(y=>{var S;if(y.isIntersecting){const A=y.target.getAttribute("data-media-id");A&&(s.value.add(A),(S=c.value)==null||S.unobserve(y.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{c.value&&c.value.disconnect()});function w(C){return!0}function h(){c.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(y=>{var A;const S=y.getAttribute("data-media-id");S&&!s.value.has(S)&&((A=c.value)==null||A.observe(y))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),h()},{immediate:!0,deep:!0});function x(C,y){const S=C.target;delete S.dataset.fallbackIndex}function D(C,y){const S=C.target,A=S.closest("[data-media-id]"),k=[y.original_url,y.url,y.thumbnail_url,"preview_url"in y?y.preview_url:void 0].filter(B=>B&&B.trim()!==""&&B!==S.src);if(k.length>0&&S.dataset.fallbackIndex){const B=parseInt(S.dataset.fallbackIndex);if(B<k.length){S.dataset.fallbackIndex=(B+1).toString(),S.src=k[B]||"";return}}else if(k.length>0){S.dataset.fallbackIndex="1",S.src=k[0]||"";return}if(S.style.display="none",A&&!A.querySelector(".media-fallback-icon")){const R=document.createElement("div");R.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",R.innerHTML=`
1
+ "use strict";var Dd=Object.defineProperty;var Ud=(a,n,t)=>n in a?Dd(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var L=(a,n,t)=>Ud(a,typeof n!="symbol"?n+"":n,t);const ba=require("pinia"),e=require("vue"),ze=require("pixi.js"),ct=require("./editor-2YMaYryX.cjs"),I=require("@ionic/vue"),Ad=require("pixi-filters");function Od(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Ye=Od(ze),Ni=1,Ld=new Set(["free","square","circle"]);function zd(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function Pd(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Ki(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==Ni)return null;const t=n.crop,o=t&&Pd(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Ld.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,c=[];if(Array.isArray(s))for(const l of s){if(!l||typeof l!="object")continue;const d=l;if(typeof d.id!="string")continue;const u={},m=d.values;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[f,p]of Object.entries(m))zd(p)&&(u[f]=p);c.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:Ni,crop:{rect:o,aspectRatio:r,shape:i},filters:c}}function tl(a){const n=Ki(a);return n?JSON.stringify(n):null}function jd(a){try{const n=JSON.parse(a);return Ki(n)}catch{return null}}function Wd(){return{version:Ni,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Vt={apiBaseUrl:"/api/v1",isAdmin:!1};function $n(a){Vt={...Vt,...a}}function nl(){return{...Vt}}function ol(a){Vt={...a}}function al(a){const n=nl();return $n(a),()=>{ol(n)}}const Zd=async(a,n={})=>{var c;const t=(c=document.querySelector('meta[name="csrf-token"]'))==null?void 0:c.getAttribute("content"),o={Accept:"application/json",...n.headers};t&&(o["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:n.method||"GET",headers:o,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(a,r);if(!s.ok){const l=await s.json().catch(()=>({message:"Request failed"}));throw new Error(l.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},xt=ba.defineStore("media",()=>{const a=e.ref([]),n=e.ref([]),t=e.ref(!1),o=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),c=e.ref({type:null,uuid:null}),l=e.ref([]),d=e.ref(!1),u=e.ref(null),m=e.ref(new Map),f=e.ref(new Map),p=e.ref(new Set),v=e.ref(new Map),g=e.ref({}),E=5*60*1e3,T=e.computed(()=>{if(Vt.apiScope)return Vt.apiScope;if(Vt.isAdmin)return"admin"}),N=e.computed(()=>T.value==="admin");function w(){return Vt.httpClient||Zd}function h(ce){const se=Vt.apiBaseUrl||"/api/v1",ke=T.value?`/${T.value}`:"";return`${se}${ke}${ce}`}function x(ce,se){return`${T.value??"default"}-${ce}-${JSON.stringify(se)}`}function D(ce){return Date.now()-ce<E}function C(){v.value.clear(),g.value={}}function y(ce){if(!ce||!ce.data)return;const se={};ce.data.forEach(ke=>{const oe=`${ke.file_name}-${ke.collection_name||"default"}`,le=se[oe];(!le||Object.keys(ke.generated_conversions||{}).length>Object.keys(le.generated_conversions||{}).length)&&(se[oe]=ke)}),a.value=Object.values(se),ce.meta&&(i.value=ce.meta.current_page,r.value=Math.ceil(ce.meta.total/ce.meta.per_page))}async function S(ce=1,se={}){const ke=x(ce,se),oe=v.value.get(ke);if(oe&&D(oe.timestamp)){const le=oe.data;return y(le),le}t.value=!0,o.value=null;try{const le=new URLSearchParams;le.append("page",ce.toString()),le.append("per_page",s.value.toString()),N.value&&le.append("linked","1");for(const rt in se)if(Object.prototype.hasOwnProperty.call(se,rt)){const He=se[rt];He!=null&&He!==""&&le.append(rt,String(He))}const Se=await w()(h(`/media?${le}`));return v.value.set(ke,{data:Se,timestamp:Date.now()}),y(Se),Se}catch(le){throw o.value=le instanceof Error?le.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function A(ce,se){t.value=!0,o.value=null;const ke=`${ce.name}-${Date.now()}`,oe={file:ce,progress:0,status:"uploading"};m.value.set(ke,oe);try{const le=new FormData;le.append("file",ce),le.append("collection",se.collection),se.ownerUuid&&(le.append("owner_uuid",se.ownerUuid),le.append("owner_type",se.ownerType||"")),se.usageUuid&&(le.append("usage_uuid",se.usageUuid),le.append("usage_type",se.usageType||""),le.append("usage_purpose",se.usagePurpose||"")),se.customProperties&&le.append("custom_properties",JSON.stringify(se.customProperties));const Se=await w()(h("/media"),{method:"POST",body:le});return oe.status="completed",oe.progress=100,oe.media=Se==null?void 0:Se.data,i.value===1&&(Se!=null&&Se.data)&&(a.value=[Se.data,...a.value]),C(),(Se==null?void 0:Se.data)||null}catch(le){throw oe.status="error",oe.error=le instanceof Error?le.message:"Upload failed",o.value=oe.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(ke)},5e3)}}async function k(ce){t.value=!0,o.value=null;const se=a.value.findIndex(oe=>oe.uuid===ce);let ke;se!==-1&&(ke=a.value.splice(se,1)[0]);try{return await w()(h(`/media/${ce}`),{method:"DELETE"}),p.value.delete(ce),C(),!0}catch(oe){throw ke&&se!==-1&&a.value.splice(se,0,ke),o.value=oe instanceof Error?oe.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function B(ce,se){t.value=!0,o.value=null;try{const oe=await w()(h(`/media/${ce}`),{method:"PATCH",body:se,data:se});if(oe!=null&&oe.data){const le=a.value.findIndex(Ee=>Ee.uuid===ce);return le!==-1&&(a.value[le]={...a.value[le],...oe.data}),C(),oe.data}return null}catch(ke){throw o.value=ke instanceof Error?ke.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function R(){t.value=!0,o.value=null;try{const se=await w()(h("/media/collections"));return n.value=(se==null?void 0:se.data)||[],n.value}catch(ce){throw o.value=ce instanceof Error?ce.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function U(ce,se,ke="images",oe){d.value=!0,u.value=null;try{const le=new URLSearchParams;le.append("collection",ke),oe&&le.append("search",oe);const Se=await w()(h(`/media/model/${ce}/${se}?${le}`));return Se!=null&&Se.data?(l.value=Se.data,Se.data):[]}catch(le){throw u.value=le instanceof Error?le.message:"Failed to fetch model media",l.value=[],new Error(u.value)}finally{d.value=!1}}async function _(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value];try{const Se=await w()(h(`/media/model/${ce}/${se}/attach`),{method:"POST",body:{media_uuids:ke,collection:oe}});return await U(ce,se,oe),(Se==null?void 0:Se.data)||[]}catch(Ee){throw l.value=le,u.value=Ee instanceof Error?Ee.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function z(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value];l.value=l.value.filter(Ee=>Ee.uuid!==ke);try{return await w()(h(`/media/model/${ce}/${se}/detach`),{method:"POST",body:{media_uuid:ke,collection:oe}}),!0}catch(Ee){throw l.value=le,u.value=Ee instanceof Error?Ee.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function H(ce,se,ke,oe="images"){d.value=!0,u.value=null;const le=[...l.value],Ee=new Map(l.value.map(Se=>[Se.uuid,Se]));l.value=ke.map(Se=>Ee.get(Se)).filter(Se=>Se!==void 0);try{return await w()(h(`/media/model/${ce}/${se}/reorder`),{method:"POST",body:{media_uuids:ke,collection:oe}}),!0}catch(Se){throw l.value=le,u.value=Se instanceof Error?Se.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function M(ce,se,ke={}){const oe=w(),le=Vt.apiBaseUrl||"/api/v1",Ee=new FormData,Se=se.imageData,rt=Se.match(/^data:(image\/\w+);base64,/),He=rt?rt[1]:"image/png",pt=Se.replace(/^data:image\/\w+;base64,/,""),K=atob(pt),de=new Uint8Array(K.length);for(let J=0;J<K.length;J++)de[J]=K.charCodeAt(J);const ie=new Blob([de],{type:He});Ee.append("image_file",ie,`edited.${He==="image/jpeg"?"jpg":"png"}`);const he=tl(se.state);he&&Ee.append("editor_state",he),se.metadata&&(Ee.append("filters",JSON.stringify(se.metadata.filters)),se.metadata.cropRect&&Ee.append("crop_data",JSON.stringify(se.metadata.cropRect))),Ee.append("save_as_new","true"),ke.asVariant&&Ee.append("as_variant","true"),ke.name!==void 0&&Ee.append("name",ke.name);const _e=await oe(`${le}/editor/${ce}/save`,{method:"POST",body:Ee});if("media"in _e&&_e.media)return _e.media;if("status_url"in _e&&_e.status_url)return $(oe,_e.status_url,ke.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function $(ce,se,ke){const oe=Date.now(),le=2e3;for(;Date.now()-oe<ke;){await new Promise(Se=>setTimeout(Se,le));const Ee=await ce(se);if(Ee.status==="completed"&&Ee.media)return Ee.media;if(Ee.status==="failed")throw new Error(Ee.error??"Image processing failed")}throw new Error("Image processing timed out")}function X(ce,se,ke){c.value=ke!==void 0?{type:ce,uuid:se,collection:ke}:{type:ce,uuid:se},g.value[`${ce}-${se}`]={timestamp:Date.now()}}function W(){c.value={type:null,uuid:null},l.value=[],u.value=null}async function te(){if(!c.value.type||!c.value.uuid)return;const ce=await U(c.value.type,c.value.uuid,c.value.collection||"images");l.value=ce||[]}function ge(){a.value.forEach(ce=>p.value.add(ce.uuid))}function Ne(){p.value.clear()}function ee(ce){p.value.has(ce)?p.value.delete(ce):p.value.add(ce)}function F(ce){return p.value.has(ce)}function P(){return Array.from(m.value.values()).some(ce=>ce.status==="uploading")}function pe(ce){return m.value.get(ce)||f.value.get(ce)}function ne(){return[...Array.from(m.value.values()),...Array.from(f.value.values())]}async function Y(){const ce=Array.from(p.value);let se=0;for(const ke of ce)try{await k(ke),se++}catch{}return Ne(),se}function Me(ce,se){var ke;return se&&((ke=ce.conversion_urls)!=null&&ke[se])?ce.conversion_urls[se]||"":ce.original_url||ce.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:N,modelContext:c,modelMedia:l,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:f,cachedResponses:g,fetchMedia:S,uploadFile:A,deleteMedia:k,updateMedia:B,clearCache:C,fetchCollections:R,fetchModelMedia:U,attachMedia:_,detachMedia:z,reorderMedia:H,saveEditedImage:M,setModelContext:X,clearModelContext:W,refreshModelMedia:te,selectAllItems:ge,clearSelection:Ne,toggleSelection:ee,isSelected:F,deleteSelectedItems:Y,getHttpClient:w,getApiUrl:h,hasActiveUploads:P,getUploadProgress:pe,getAllUploadProgress:ne,getMediaUrl:Me}}),il=()=>((Vt.apiScope!=="admin"||Vt.isAdmin!==!0)&&$n({...Vt,apiScope:"admin",isAdmin:!0}),xt());function Xd(a,n){try{let t=ct.getFilter(a);if(t||(ct.registerCorePixiFilters(),t=ct.getFilter(a)),!t){try{const r=ct.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const Hd=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function c(){var E;if(!r){o("error",new Error("Editor not initialized"));return}const u=r.exportImage("png",.92);if(!u){o("error",new Error("Failed to export image — the image could not be processed"));return}const m=r.getSerializableState(),f=r._renderer,p=((E=f.getExportDimensions)==null?void 0:E.call(f))??{width:0,height:0},v={width:Math.round(p.width),height:Math.round(p.height)};o("save",{imageData:u,dimensions:v,state:m})}function l(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Ye,ct.initializeFilterRegistry();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"),r=new ct.VanillaImageEditor(i.value,u),r.setFilterRegistry({getAllFilters:ct.getAllFilters,getFilter:ct.getFilter,getFiltersByCategory:ct.getFiltersByCategory}),r.save=function(){c()},r.on("cancel",l),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}return e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const m=u[0];m&&m.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))}),e.watch(()=>t.initialImage,u=>{r&&u&&r.loadImage(u,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.watch(()=>t.sessionKey,()=>{r&&t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(u,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Be=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},rl=Be(Hd,[["__scopeId","data-v-d6416384"]]),Gd={class:"editor-modal-panel"},Jd={class:"editor-fill"},Yd=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{default:null},sessionKey:{default:0},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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),c=e.ref(null),l=g=>{o("error",g)},d=()=>{e.nextTick(()=>{if(i.value){const g=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");g&&g.focus()}})};e.watch(()=>t.modelValue,g=>{r.value=g,g&&(c.value=document.activeElement,d())},{immediate:!0});const u=async g=>{try{s.value=!0,t.onSave&&await t.onSave(g),o("save",g)}catch(E){l(E)}finally{s.value=!1}},m=()=>{o("cancel"),p()},f=()=>{s.value||p()},p=()=>{r.value=!1,o("update:modelValue",!1),c.value&&c.value instanceof HTMLElement&&(c.value.focus(),c.value=null)},v=g=>{if(g.key==="Escape"&&r.value&&!s.value){p();return}if(g.key==="Tab"&&r.value&&i.value){const E=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(E.length===0)return;const T=E[0],N=E[E.length-1];g.shiftKey&&document.activeElement===T?(g.preventDefault(),N.focus()):!g.shiftKey&&document.activeElement===N&&(g.preventDefault(),T.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(g,E)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(f,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:f}),e.createElementVNode("div",Gd,[e.createElementVNode("div",Jd,[e.createVNode(rl,{"initial-image":g.initialImage,"initial-state":g.initialState,"session-key":g.sessionKey,theme:g.theme,"crop-shape":g.cropShape,preset:g.preset,"primary-color":g.primaryColor,"secondary-color":g.secondaryColor,"save-button-color":g.saveButtonColor,"download-button-color":g.downloadButtonColor,onSave:u,onCancel:m,onError:l},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),sl=Be(Yd,[["__scopeId","data-v-9ca8dea8"]]),Kd={class:"media-workspace"},qd={class:"media-workspace-toolbar"},Qd={class:"media-workspace-label"},eu=["value"],tu={class:"media-workspace-grid"},nu=["onClick"],ou=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var m;const t=a,o=n,i=xt(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),s=e.computed(()=>t.subScopes),c=e.computed(()=>s.value.find(f=>f.id===r.value));let l=null;function d(){l&&(l(),l=null),t.apiScope&&(l=al({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const f={};(p=c.value)!=null&&p.collection&&(f.collection=c.value.collection),await i.fetchMedia(1,f),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,f=>{f&&f!==r.value&&(r.value=f)}),e.watch(()=>t.subScopes,f=>{if(f.length===0){r.value="";return}f.some(p=>p.id===r.value)||(r.value=f[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,f=>{f&&(o("scope-change",f),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{l&&(l(),l=null)}),(f,p)=>(e.openBlock(),e.createElementBlock("div",Kd,[e.createElementVNode("div",qd,[e.createElementVNode("label",Qd,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=v=>r.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,eu))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=v=>o("upload"))}," Upload ")]),e.createElementVNode("div",tu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:g=>o("preview",v)},e.toDisplayString(v.file_name),9,nu))),128))])]))}}),au=Be(ou,[["__scopeId","data-v-895f26fe"]]),iu={class:"managed-media-gallery"},ru={class:"gallery-grid"},su=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(a){return(n,t)=>(e.openBlock(),e.createElementBlock("div",iu,[e.createElementVNode("div",ru,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),lu=Be(su,[["__scopeId","data-v-a60fdcd7"]]),cu="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>",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' d='M256 112v288M400 256H112' 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 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>",Qi="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>",uu="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>",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' stroke-width='48' d='M268 112l144 144-144 144M392 256H100' class='ionicon-fill-none'/></svg>",oo="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>",pu="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>",ll="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>",cl="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>",as="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>",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' stroke-width='48' d='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",hu="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>",is="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>",Dn="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>",rs="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>",sn="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>",gu="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>",Kn="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>",yu="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>",wu="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>",ss="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>",dl="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>",vo="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>",bu="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>",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' 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>",xu="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>",ao="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>",ls="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>",di="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>",Eu="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>",Vu="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>",ui="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>",Su="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>",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' 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>",Nu="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>",_u="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>",ul="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>",ml="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>",Tu="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>",Mu="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>",Bu="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>",Fu="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>",pl="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>",Iu="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>",Ru="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>",fl="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>",$u="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>",Du="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>",Ln="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>",Uu="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>",Au="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>",cs="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>",er="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>",Ou="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>",mi="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>",rn="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>",qn="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>",ds="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>",Lu="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>",hl="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>",zu="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>",vl="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>",Pu="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>",ju="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>",Wu="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>",Zu="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>",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-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>",Hu="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>",Gu="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>",Oo="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 us=()=>{};function Ju(a,n){function t(...o){return new Promise((i,r)=>{Promise.resolve(a(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})).then(i).catch(r)})}return t}function Yu(a,n={}){let t,o,i=us;const r=l=>{clearTimeout(l),i(),i=us};let s;return l=>{const d=e.toValue(a),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(l())):new Promise((m,f)=>{i=n.rejectOnCancel?f:m,s=l,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,m(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,m(l())},d)})}}function Ku(a,n=200,t={}){return Ju(Yu(n,t),a)}const Qn=new Map;function qu(a){const n=e.getCurrentScope();function t(c){var l;const d=Qn.get(a)||new Set;d.add(c),Qn.set(a,d);const u=()=>i(c);return(l=n==null?void 0:n.cleanups)==null||l.push(u),u}function o(c){function l(...d){i(l),c(...d)}return t(l)}function i(c){const l=Qn.get(a);l&&(l.delete(c),l.size||r())}function r(){Qn.delete(a)}function s(c,l){var d;(d=Qn.get(a))==null||d.forEach(u=>u(c,l))}return{on:t,once:o,off:i,emit:s,reset:r}}function Qu(){var r,s;const a=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var c,l;if(a)try{const d=(l=(c=window.Capacitor)==null?void 0:c.Plugins)==null?void 0:l.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function em(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=qu("media-selection"),r=Qu(),s=e.computed(()=>a.value.filter(x=>n.value.has(x.uuid))),c=e.computed(()=>n.value.size);e.watch(n,x=>{i.emit({type:"selection:changed",count:x.size,selectedIds:Array.from(x)})},{deep:!0});const l=e.computed(()=>a.value.length>0&&a.value.every(x=>n.value.has(x.uuid))),d=e.computed(()=>a.value.some(x=>n.value.has(x.uuid)));function u(x){return n.value.has(x)}function m(x){n.value.has(x)?(n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)):(n.value.add(x),t.value=x,o.value=a.value.findIndex(D=>D.uuid===x),n.value.size===1&&r.selection())}function f(x){n.value.add(x),t.value=x,o.value=a.value.findIndex(D=>D.uuid===x)}function p(x){n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)}function v(){a.value.forEach(x=>n.value.add(x.uuid))}function g(){n.value.clear(),t.value=null,o.value=-1}function E(){l.value?g():v()}function T(x,D){const C=a.value.findIndex(y=>y.uuid===x);if(C!==-1)if(D!=null&&D.shiftKey&&o.value!==-1){const y=Math.min(o.value,C),S=Math.max(o.value,C);for(let A=y;A<=S;A++)n.value.add(a.value[A].uuid)}else m(x)}function N(){if(a.value.length===0)return;let x=o.value+1;x>=a.value.length&&(x=0),g(),f(a.value[x].uuid)}function w(){if(a.value.length===0)return;let x=o.value-1;x<0&&(x=a.value.length-1),g(),f(a.value[x].uuid)}function h(x){switch(x.key){case"ArrowDown":x.preventDefault(),N();break;case"ArrowUp":x.preventDefault(),w();break;case"a":(x.ctrlKey||x.metaKey)&&(x.preventDefault(),v());break;case"Escape":x.preventDefault(),g();break;case" ":t.value&&(x.preventDefault(),m(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:c,isAllSelected:l,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:m,select:f,deselect:p,selectAll:v,clear:g,toggleAll:E,rangeSelect:T,selectNext:N,selectPrevious:w,handleKeydown:h,selectionBus:i}}const tm={class:"flex items-center justify-between w-full px-4"},nm={class:"p-4"},om={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},am={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},im=["value"],rm={class:"flex gap-2 mt-4"},sm={class:"flex justify-end mb-4"},lm={key:1,class:"flex justify-center items-center h-64"},cm={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},dm={class:"text-sm text-theme-secondary"},um={key:0},mm={class:"mb-4"},pm={class:"mb-4"},fm={class:"flex gap-2"},hm={class:"flex items-center justify-between px-4 py-2"},vm={class:"text-sm text-theme-secondary"},gm={key:0},ym={key:0},wm={key:1},bm={class:"flex gap-2"},km=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),c=e.ref(!1),l=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),m=e.ref(!1),f=e.ref({}),p=e.ref(["images","documents","videos"]),v=e.ref(1),g=e.ref(!0),E=e.ref(!1),T=il(),N=em(l);function w(F){var se;const P=F.conversion_urls||{},pe=F.proxy_url||F.original_url||F.url||"",ne=P.thumb||P.preview||F.preview_url||F.thumbnail_url||pe,Y=F.custom_properties||{},Me=Y.width,ce=Y.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:pe,url:pe,thumbnail_url:ne,conversions:F.conversions||{},conversion_urls:P,generated_conversions:F.generated_conversions||{},custom_properties:Y,caption:F.caption||null,alt_text:F.alt_text||null,created_at:F.created_at,updated_at:F.updated_at,is_image:((se=F.mime_type)==null?void 0:se.startsWith("image/"))||!1,...typeof Me=="number"?{width:Me}:{},...typeof ce=="number"?{height:ce}:{},...F.formatted_size!==void 0?{formatted_size:F.formatted_size}:{}}}e.watch(()=>t.selectedItems,F=>{u.value=new Set(F),N.clear(),F.forEach(P=>N.select(P))});const h=e.computed(()=>{var P;let F=l.value;return(P=f.value.types)!=null&&P.length&&(F=F.filter(pe=>{var Y,Me;const ne=(Y=pe.mime_type)==null?void 0:Y.split("/")[0];return(Me=f.value.types)==null?void 0:Me.includes(ne)})),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&(F=F.filter(pe=>{const ne=pe.size/1048576;return!(f.value.sizeMin!==void 0&&ne<f.value.sizeMin||f.value.sizeMax!==void 0&&ne>f.value.sizeMax)})),F}),x=e.computed(()=>{var P;let F=0;return f.value.search&&F++,f.value.collection&&F++,(f.value.dateFrom||f.value.dateTo)&&F++,(P=f.value.types)!=null&&P.length&&(F+=f.value.types.length),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&F++,F}),D=e.computed(()=>{const F=N.selectedCount.value;return F===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${F} ${F===1?"Item":"Items"}`:"Item"}`}),C=e.computed(()=>{const F=N.selectedCount.value;return!!(F===0||t.selectionMode==="single"&&F>1||t.maxSelection&&F>t.maxSelection)}),y=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function S(F=!0){F?(c.value=!0,l.value=[],v.value=1,g.value=!0):E.value=!0;try{const P={collection:f.value.collection||t.collection,per_page:24};switch((s.value||f.value.search)&&(P.search=s.value||f.value.search||""),f.value.dateFrom&&(P.from_date=f.value.dateFrom),f.value.dateTo&&(P.to_date=f.value.dateTo),i.value){case"recent":await T.fetchMedia(v.value,P),F?l.value=T.items.map(pe=>w(pe)):l.value=[...l.value,...T.items.map(pe=>w(pe))],g.value=T.currentPage<T.totalPages;break;case"model":if(t.modelType&&t.modelId){const pe=await T.fetchModelMedia(t.modelType,t.modelId,P.collection,P.search);l.value=pe?pe.map(ne=>w(ne)):[],g.value=!1}break;case"library":await T.fetchMedia(v.value,P),F?l.value=T.items.map(pe=>w(pe)):l.value=[...l.value,...T.items.map(pe=>w(pe))],g.value=T.currentPage<T.totalPages;break}}catch{}finally{c.value=!1,E.value=!1}}async function A(F){if(!g.value||E.value){F!=null&&F.target&&F.target.complete();return}v.value++,await S(!1),F!=null&&F.target&&(F.target.complete(),g.value||(F.target.disabled=!0))}function k(F){return F==="recent"||F==="model"||F==="library"}function B(F){i.value=F,S()}function R(F){typeof F=="string"&&k(F)&&B(F)}async function U(F){t.selectionMode==="single"?(N.clear(),N.select(F.uuid)):(N.toggle(F.uuid),t.maxSelection&&N.selectedCount.value>t.maxSelection&&(N.deselect(F.uuid),await(await I.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function _(){o("confirm",N.selectedItems.value)}function z(){o("close")}function H(F){}const M=e.ref(null),$=e.ref(!1);function X(F){M.value=F,$.value=!0}function W(F){const P=l.value.findIndex(ne=>ne.uuid===F.uuid);P!==-1&&(l.value[P]=F);const pe={};F.alt_text!==void 0&&(pe.alt_text=F.alt_text),F.caption!==void 0&&(pe.caption=F.caption),F.custom_properties!==void 0&&(pe.custom_properties=F.custom_properties),T.updateMedia(F.uuid,pe)}function te(){S()}function ge(){f.value={},s.value="",S()}const Ne=Ku(()=>{S(!0)},300);e.watch(s,()=>{t.isOpen&&Ne()});async function ee(F){try{await(await I.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await T.deleteMedia(F),await S()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,F=>{F&&S()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(F=>N.select(F))}),(F,P)=>{const pe=e.resolveComponent("AdminMediaGrid"),ne=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":F.isOpen,onDidDismiss:z,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:z},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",tm,[e.createVNode(e.unref(I.IonSegment),{value:i.value,onIonChange:P[0]||(P[0]=Y=>R(Y.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[15]||(P[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(I.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[16]||(P[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[17]||(P[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(I.IonButton),{fill:"clear",size:"small",onClick:P[1]||(P[1]=Y=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[x.value>0?(e.openBlock(),e.createBlock(e.unref(I.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",nm,[m.value?(e.openBlock(),e.createElementBlock("div",om,[e.createElementVNode("div",am,[e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[18]||(P[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":P[2]||(P[2]=Y=>f.value.collection=Y),class:"w-full p-2 border rounded"},[P[19]||(P[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,Y=>(e.openBlock(),e.createElementBlock("option",{key:Y,value:Y},e.toDisplayString(Y),9,im))),128))],512),[[e.vModelSelect,f.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[20]||(P[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[3]||(P[3]=Y=>f.value.dateFrom=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[21]||(P[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[4]||(P[4]=Y=>f.value.dateTo=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateTo]])])]),e.createElementVNode("div",rm,[e.createVNode(e.unref(I.IonButton),{size:"small",onClick:te},{default:e.withCtx(()=>[...P[22]||(P[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{size:"small",fill:"clear",onClick:ge},{default:e.withCtx(()=>[...P[23]||(P[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":P[5]||(P[5]=Y=>s.value=Y),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",sm,[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:P[6]||(P[6]=Y=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(I.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:P[7]||(P[7]=Y=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),c.value?(e.openBlock(),e.createElementBlock("div",lm,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):h.value.length===0?(e.openBlock(),e.createElementBlock("div",cm,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),P[24]||(P[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",dm,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(pe,{key:3,"media-items":h.value,"selected-items":e.unref(N).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:U,onPreview:H,onEdit:X,onDelete:ee},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(I.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(Y,Me)=>(e.openBlock(),e.createBlock(ne,{key:Y.uuid,media:Y,selected:e.unref(N).isSelected(Y.uuid),"selection-mode":!0,index:Me,onToggleSelect:U,onPreview:H,onEdit:X,onDelete:ee},null,8,["media","selected","index"]))),128))]),_:1})),!c.value&&h.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(I.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:P[8]||(P[8]=Y=>A(Y))},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(I.IonModal),{"is-open":$.value,onDidDismiss:P[14]||(P[14]=Y=>$.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:P[9]||(P[9]=Y=>$.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[...P[25]||(P[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"p-4"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",um,[e.createElementVNode("div",mm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[26]||(P[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[10]||(P[10]=Y=>M.value.caption=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,M.value.caption]])]),e.createElementVNode("div",pm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...P[27]||(P[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[11]||(P[11]=Y=>M.value.alt_text=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,M.value.alt_text]])]),e.createElementVNode("div",fm,[e.createVNode(e.unref(I.IonButton),{onClick:P[12]||(P[12]=Y=>W(M.value))},{default:e.withCtx(()=>[...P[28]||(P[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:P[13]||(P[13]=Y=>$.value=!1)},{default:e.withCtx(()=>[...P[29]||(P[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",hm,[e.createElementVNode("div",vm,[e.unref(N).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",gm,[e.createTextVNode(e.toDisplayString(e.unref(N).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",ym," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",wm," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",bm,[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:z},{default:e.withCtx(()=>[...P[30]||(P[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{disabled:C.value,onClick:_},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),xm=Be(km,[["__scopeId","data-v-9a8c0954"]]),Em={key:1,class:"flex flex-col items-center justify-center py-16"},Vm=["draggable","onDragstart","onDragover","onDrop"],Sm={key:0,class:"absolute top-2 left-2 z-20"},Cm=["checked","onChange"],Nm={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},_m=["data-media-id"],Tm={key:0,class:"w-full h-full flex items-center justify-center"},Mm=["src","alt","onError","onLoad"],Bm={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},Fm={class:"text-center"},Im={class:"text-4xl text-gray-400 mb-2"},Rm={class:"text-sm font-medium text-gray-500"},$m={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Dm=["onClick"],Um=["onClick"],Am=["onClick"],Om={class:"p-3"},Lm={class:"text-sm font-medium truncate mb-1"},zm={class:"text-xs text-gray-600 dark:text-gray-400"},Pm={key:0},jm={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Wm=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),c=e.ref(null),l=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,S){t.reorderable&&(i.value=y,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/html","")))}function m(C,y){t.reorderable&&(C.preventDefault(),r.value=y)}function f(){r.value=null}function p(C,y){if(!t.reorderable||!i.value)return;C.preventDefault();const S=[...t.mediaItems],A=S.findIndex(k=>{var B;return k.uuid===((B=i.value)==null?void 0:B.uuid)});if(A!==-1&&A!==y&&i.value){const[k]=S.splice(A,1);S.splice(y,0,k),o("reorder",S)}i.value=null,r.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 g(C){var S;return C.thumbnail_url||((S=C.conversion_urls)==null?void 0:S.thumb)||C.original_url||C.url||""}function E(C){var A,k,B;const y=((A=C.mime_type)==null?void 0:A.startsWith("image/"))||!1,S=!!(C.thumbnail_url||(k=C.conversion_urls)!=null&&k.thumb||(B=C.conversion_urls)!=null&&B.preview||C.original_url||C.url);return y&&S}function T(C){var y;return((y=C.split(".").pop())==null?void 0:y.toUpperCase())||""}function N(C){var S;const y=((S=C.mime_type)==null?void 0:S.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&&(c.value=new IntersectionObserver(C=>{C.forEach(y=>{var S;if(y.isIntersecting){const A=y.target.getAttribute("data-media-id");A&&(s.value.add(A),(S=c.value)==null||S.unobserve(y.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{c.value&&c.value.disconnect()});function w(C){return!0}function h(){c.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(y=>{var A;const S=y.getAttribute("data-media-id");S&&!s.value.has(S)&&((A=c.value)==null||A.observe(y))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),h()},{immediate:!0,deep:!0});function x(C,y){const S=C.target;delete S.dataset.fallbackIndex}function D(C,y){const S=C.target,A=S.closest("[data-media-id]"),k=[y.original_url,y.url,y.thumbnail_url,"preview_url"in y?y.preview_url:void 0].filter(B=>B&&B.trim()!==""&&B!==S.src);if(k.length>0&&S.dataset.fallbackIndex){const B=parseInt(S.dataset.fallbackIndex);if(B<k.length){S.dataset.fallbackIndex=(B+1).toString(),S.src=k[B]||"";return}}else if(k.length>0){S.dataset.fallbackIndex="1",S.src=k[0]||"";return}if(S.style.display="none",A&&!A.querySelector(".media-fallback-icon")){const R=document.createElement("div");R.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",R.innerHTML=`
2
2
  <div class="text-center">
3
3
  <div class="text-4xl text-gray-400 mb-2">${N(y)}</div>
4
4
  <p class="text-sm font-medium text-gray-500">${T(y.file_name)}</p>
5
5
  </div>
6
- `,A.appendChild(R)}}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,S=>e.createElementVNode("div",{key:`skeleton-${S}`,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",wm,[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]=S=>o("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,(S,A)=>(e.openBlock(),e.createElementBlock("div",{key:S.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===A}]),draggable:C.reorderable,onDragstart:k=>u(k,S),onDragover:k=>m(k,A),onDragleave:f,onDrop:k=>p(k,A)},[C.selectionMode?(e.openBlock(),e.createElementBlock("div",km,[e.createElementVNode("input",{type:"checkbox",checked:l(S),onChange:k=>o("toggleSelect",S),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,xm)])):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:S,index:A},void 0,!0)],2)):e.createCommentVNode("",!0),C.reorderable?(e.openBlock(),e.createElementBlock("div",Em,[...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":l(S)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":S.uuid},[E(S)&&!w(S.uuid)?(e.openBlock(),e.createElementBlock("div",Sm,[...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),E(S)&&w(S.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(S),alt:S.alt_text||S.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:k=>D(k,S),onLoad:k=>x(k)},null,40,Cm)):(e.openBlock(),e.createElementBlock("div",Nm,[e.createElementVNode("div",_m,[e.createElementVNode("div",Tm,e.toDisplayString(N(S)),1),e.createElementVNode("p",Mm,e.toDisplayString(T(S.file_name)),1)])])),e.createElementVNode("div",Bm,[e.createElementVNode("button",{onClick:k=>o("preview",S),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,Fm),C.showEditButton&&E(S)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:k=>o("edit",S),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,Im)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:k=>o("delete",S.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,Rm)])],8,Vm),e.createElementVNode("div",$m,[e.createElementVNode("h4",Dm,e.toDisplayString(S.file_name),1),e.createElementVNode("p",Um,[e.createTextVNode(e.toDisplayString(v(S.size))+" ",1),S.width&&S.height?(e.openBlock(),e.createElementBlock("span",Am," • "+e.toDisplayString(S.width)+"x"+e.toDisplayString(S.height),1)):e.createCommentVNode("",!0)]),S.caption?(e.openBlock(),e.createElementBlock("p",Om,e.toDisplayString(S.caption),1)):e.createCommentVNode("",!0)])],2)],42,bm))),128))],2))}}),zm=Be(Lm,[["__scopeId","data-v-f0c343b7"]]),Pm={class:"model-media-manager"},jm=["accept","multiple"],Wm={class:"flex items-center justify-between mb-4"},Zm={key:0,class:"text-lg font-medium"},Xm={class:"flex gap-2"},Hm={key:0,class:"flex items-center justify-center py-8"},Gm={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"},Jm={class:"text-gray-600 dark:text-gray-400"},Ym={class:"flex gap-2 mt-4"},Km={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},qm=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(a,{emit:n}){const t=a,o=n,i=xt(),r=e.ref(!1),s=e.ref(!1),c=e.ref(!1),l=e.ref(!1),d=e.ref(null),u=e.ref(0),m=e.ref(null),f=e.ref(void 0),p=e.ref(null),v=e.ref(null),g=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),E=e.computed(()=>i.modelMedia.map($=>$.uuid)),T=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function N(){Rn({isAdmin:t.mode==="admin"})}async function w($){await(await I.toastController.create({message:$,duration:3e3,color:"danger",position:"bottom"})).present()}async function h(){if(!s.value)if(s.value=!0,N(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],o("update:media",i.modelMedia);else{r.value=!0,o("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),o("update:media",i.modelMedia)}catch($){const X=$ instanceof Error?$.message:"Failed to fetch media";o("error",{operation:"fetch",message:X,details:$})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,$=>{s.value&&o("update:media",$)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,h()}),e.watch(()=>t.mode,()=>{N()}),e.onMounted(()=>{h()}),e.onUnmounted(()=>{i.clearModelContext()});function x(){return i.modelMedia.length>0}function D(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function C($){var j,te,ge;if(!((j=$.mime_type)!=null&&j.startsWith("image/")))return null;const X=$.original_url||$.url||((te=$.conversion_urls)==null?void 0:te.preview)||((ge=$.conversion_urls)==null?void 0:ge.thumb)||$.thumbnail_url;return X&&X.trim()!==""?X:null}function y(){c.value=!0}function S(){var $;($=v.value)==null||$.click()}function A(){c.value=!1}async function k($){if(!t.allowEdit)return;const X=C($);if(X){d.value=$,u.value++;try{const j=i.getHttpClient(),te=i.getApiUrl(""),ge=await j(`${te.replace(/\/$/,"")}/editor/${$.uuid}/edit`);f.value=ge.editable_source_url||X,m.value=ge.editor_state??null}catch{f.value=X,m.value=null}l.value=!0}}function B(){l.value=!1,d.value=null,f.value=void 0,m.value=null}async function R($){if(!d.value)throw new Error("No media selected for editing");const X=d.value,j=t.editMode==="variant";try{p.value=null;const te=await i.saveEditedImage(X.uuid,$,{asVariant:j,name:X.file_name});j||await i.detachMedia(t.mediableType,t.mediableId,X.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[te.uuid],t.collection),o("edit-complete",{originalMedia:X,editedMedia:te,mode:t.editMode}),l.value=!1,d.value=null}catch(te){const ge=te instanceof Error?te.message:"Failed to save edited image";throw p.value=ge,await w(ge),te}}function U($){if(p.value===$.message){p.value=null;return}w($.message)}async function _($){const X=$.target,j=X.files;if(!(!j||j.length===0)){for(let te=0;te<j.length;te++){const ge=j[te];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ge.type)){o("error",{operation:"upload",message:`File type ${ge.type} is not accepted`,details:{file:ge.name}});continue}if(t.maxFileSize!==void 0&&ge.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ge.name,size:ge.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:ge});try{const Ne=await i.uploadFile(ge,{collection:t.collection});Ne!=null&&Ne.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[Ne.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:ge}),o("attach",[Ne]))}catch(Ne){const ee=Ne instanceof Error?Ne.message:"Upload failed";o("error",{operation:"upload",message:ee,details:Ne}),o("upload-progress",{status:"error",progress:0,file:ge,error:ee})}}X.value=""}}async function z($){const X=$.map(j=>j.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,X,t.collection),o("reorder",i.modelMedia)}catch(j){const te=j instanceof Error?j.message:"Failed to reorder media";o("error",{operation:"reorder",message:te,details:j}),await w(te)}}async function H($){const X=i.modelMedia.find(j=>j.uuid===$);try{await i.detachMedia(t.mediableType,t.mediableId,$,t.collection),X&&o("detach",X)}catch(j){const te=j instanceof Error?j.message:"Failed to detach media";o("error",{operation:"detach",message:te,details:j}),await w(te)}}async function M($){c.value=!1;const X=$.map(ge=>ge.uuid),j=new Set(E.value);let te=Array.from(new Set(X)).filter(ge=>!j.has(ge));if(g.value!==void 0&&te.length>g.value&&(te=te.slice(0,g.value)),te.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,te,t.collection);const ge=i.modelMedia.filter(Ne=>te.includes(Ne.uuid));o("attach",ge)}catch(ge){const Ne=ge instanceof Error?ge.message:"Failed to attach media";o("error",{operation:"attach",message:Ne,details:ge})}}return($,X)=>(e.openBlock(),e.createElementBlock("div",Pm,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:T.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:_},null,40,jm),e.createElementVNode("div",Wm,[$.title?(e.openBlock(),e.createElementBlock("h3",Zm,e.toDisplayString($.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Xm,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small",disabled:D(),"data-testid":"browse-button",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(si)},null,8,["icon"]),X[1]||(X[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small",disabled:D(),"data-testid":"upload-button",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(ns)},null,8,["icon"]),X[2]||(X[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Hm,[e.createVNode(e.unref(I.IonSpinner),{"data-testid":"spinner"})])):x()?(e.openBlock(),e.createBlock(zm,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!$.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!$.allowEdit,"selection-mode":!1,onReorder:z,onDelete:H,onEdit:k},e.createSlots({_:2},[$.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:j})=>[j===0?(e.openBlock(),e.createElementBlock("div",Km," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Gm,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(si),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Jm,e.toDisplayString($.emptyText),1),e.createElementVNode("div",Ym,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(si)},null,8,["icon"]),X[3]||(X[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(ns)},null,8,["icon"]),X[4]||(X[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(ym,e.mergeProps({"is-open":c.value,"selected-items":E.value,collection:$.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:M,onClose:A}),null,16,["is-open","selected-items","collection"]),e.createVNode(ol,{modelValue:l.value,"onUpdate:modelValue":X[0]||(X[0]=j=>l.value=j),"initial-image":f.value,"initial-state":m.value,"session-key":u.value,"on-save":R,onCancel:B,onError:U},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),Qm=Be(qm,[["__scopeId","data-v-6677bbfe"]]);function Oo(a,n,t,o){if(t<=0||o<=0)return!1;try{return n.drawImage(a,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function ep(a,n){return a?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:n,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:n,opacity:"1",pointerEvents:"auto"}}const tp=["src"],np={class:"preview-controls"},op=["aria-label"],ap={class:"time-display"},ip={class:"current-time"},rp={class:"total-time"},sp={key:0,class:"fps-display"},lp={key:0,class:"loading-overlay"},cp={key:1,class:"error-overlay"},dp=.1,up=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},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(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Ye,r=a,s=t,c=e.ref(),l=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),f=e.ref(0),p=e.ref(0),v=e.ref(!1);let g,E,T=null,N=null,w=null,h=[],x="",D=null,C=0,y=0,S=0,A=0,k=!1,B=0,R=0,U,_=null,z=!1,H=!1,M=0;const $=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),X=e.computed(()=>ep(v.value,r.fitMode));function j(J){return typeof J=="number"&&Number.isFinite(J)&&J>=0?J:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function te(J){const ue=j(J.duration);return ue<=0?!1:J.currentTime>=Math.max(0,ue-dp)}async function ge(){var J,ue;if(!H&&l.value&&!g&&!(!d.value||d.value.readyState<3)){H=!0;try{m.value=void 0;let ve=((J=c.value)==null?void 0:J.clientWidth)||800,Z=((ue=c.value)==null?void 0:ue.clientHeight)||450;if((ve<=0||Z<=0)&&(ve=d.value.videoWidth||800,Z=d.value.videoHeight||450),g=new Ye.Application,await g.init({width:ve,height:Z,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),l.value.appendChild(g.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!g&&ge()},100),g&&(g.destroy(!0),g=null);return}if(C=d.value.videoWidth,y=d.value.videoHeight,N=document.createElement("canvas"),N.width=C,N.height=y,w=N.getContext("2d"),!w)throw new Error("Unable to create 2D canvas context for video preview");const Q=Oo(d.value,w,C,y),ae=Ye.Texture.from(N);T=ae.source,E=new Ye.Sprite(ae),E.visible=!0,E.alpha=1,de(),g.stage.addChild(E),g.renderer&&!g.renderer.destroyed&&g.render()}P(),r.targetFps<60?Ne():g.ticker.add(ee),v.value=!0,"ResizeObserver"in window&&(D=new ResizeObserver(Q=>{k||(k=!0,requestAnimationFrame(()=>{k=!1;const ae=Q[Q.length-1],{width:xe,height:De}=ae.contentRect;if(xe<=0||De<=0)return;const Qe=Math.round(xe),We=Math.round(De);Qe===S&&We===A||(S=Qe,A=We,de())}))}),D.observe(c.value)),r.filters&&r.filters.length>0&&P(),r.showFps&&Se(),M=0}catch{if(pt(),!z&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&M<2){M+=1,window.setTimeout(()=>{z||ge()},M*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{H=!1}}}function Ne(){const J=1e3/r.targetFps;let ue=performance.now();function ve(){if(z||!g)return;const Z=performance.now(),Q=Z-ue;Q>=J&&(ee(),ue=Z-Q%J),_=requestAnimationFrame(ve)}_=requestAnimationFrame(ve)}function ee(){if(!(!g||!E||z)&&r.active)try{w&&N&&T&&d.value&&(d.value.readyState>=2&&Oo(d.value,w,N.width,N.height)&&T.update(),d.value.paused||s("frame-update",Y())),r.showFps&&R++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{z=!0}}function F(){for(const J of h)try{J.destroy()}catch{}h=[]}function P(){if(E){if(!r.filters||r.filters.length===0){E.filters=null,F();return}F(),r.filters.forEach(J=>{const ue=fe(J);ue&&h.push(ue)}),E.filters=h.length>0?h:null,x=JSON.stringify(r.filters),g&&g.render()}}function fe(J){const ue=J.filterId,ve=J.params||{},Z=ct.getFilter(ue);if(Z&&!ct.isFilterCompatibleWithMedia(ue,"video"))return null;if(Z&&Z.createFilter)try{return Z.createFilter(ve)}catch{}const Q=(ae,xe,De)=>Math.min(De,Math.max(xe,ae));switch(ue){case"brightness":{const ae=new o,xe=Q(typeof ve.brightness=="number"?ve.brightness:typeof ve.value=="number"?ve.value:1,0,5);return ae.brightness(xe,!0),ae}case"contrast":{const ae=new o,xe=Q(typeof ve.contrast=="number"?ve.contrast:typeof ve.value=="number"?ve.value:1,0,5);return ae.contrast(xe,!0),ae}case"saturation":{const ae=new o,xe=Q(typeof ve.saturation=="number"?ve.saturation:typeof ve.value=="number"?ve.value:1,0,5);return ae.saturate(xe,!0),ae}case"hue":{const ae=new o,xe=Q(typeof ve.value=="number"?ve.value:0,-180,180);return ae.hue(xe,!0),ae}case"gaussian-blur":case"blur":{const ae=Q(typeof ve.blur=="number"?ve.blur:typeof ve.value=="number"?ve.value:2,0,10);return new i(ae)}case"grayscale":{const ae=new o;return ae.desaturate(),ae}case"sepia":case"color-matrix":{const ae=new o;return ae.sepia(!0),ae}case"vignette":{const ae=typeof ve.value=="number"?ve.value:.3;return ne(Q(ae,0,1))}default:return null}}function ne(J){const ue=`
6
+ `,A.appendChild(R)}}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,S=>e.createElementVNode("div",{key:`skeleton-${S}`,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",Em,[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]=S=>o("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,(S,A)=>(e.openBlock(),e.createElementBlock("div",{key:S.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===A}]),draggable:C.reorderable,onDragstart:k=>u(k,S),onDragover:k=>m(k,A),onDragleave:f,onDrop:k=>p(k,A)},[C.selectionMode?(e.openBlock(),e.createElementBlock("div",Sm,[e.createElementVNode("input",{type:"checkbox",checked:l(S),onChange:k=>o("toggleSelect",S),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,Cm)])):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:S,index:A},void 0,!0)],2)):e.createCommentVNode("",!0),C.reorderable?(e.openBlock(),e.createElementBlock("div",Nm,[...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":l(S)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":S.uuid},[E(S)&&!w(S.uuid)?(e.openBlock(),e.createElementBlock("div",Tm,[...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),E(S)&&w(S.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(S),alt:S.alt_text||S.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:k=>D(k,S),onLoad:k=>x(k)},null,40,Mm)):(e.openBlock(),e.createElementBlock("div",Bm,[e.createElementVNode("div",Fm,[e.createElementVNode("div",Im,e.toDisplayString(N(S)),1),e.createElementVNode("p",Rm,e.toDisplayString(T(S.file_name)),1)])])),e.createElementVNode("div",$m,[e.createElementVNode("button",{onClick:k=>o("preview",S),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,Dm),C.showEditButton&&E(S)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:k=>o("edit",S),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,Um)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:k=>o("delete",S.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,Am)])],8,_m),e.createElementVNode("div",Om,[e.createElementVNode("h4",Lm,e.toDisplayString(S.file_name),1),e.createElementVNode("p",zm,[e.createTextVNode(e.toDisplayString(v(S.size))+" ",1),S.width&&S.height?(e.openBlock(),e.createElementBlock("span",Pm," • "+e.toDisplayString(S.width)+"x"+e.toDisplayString(S.height),1)):e.createCommentVNode("",!0)]),S.caption?(e.openBlock(),e.createElementBlock("p",jm,e.toDisplayString(S.caption),1)):e.createCommentVNode("",!0)])],2)],42,Vm))),128))],2))}}),Zm=Be(Wm,[["__scopeId","data-v-f0c343b7"]]),Xm={class:"model-media-manager"},Hm=["accept","multiple"],Gm={class:"flex items-center justify-between mb-4"},Jm={key:0,class:"text-lg font-medium"},Ym={class:"flex gap-2"},Km={key:0,class:"flex items-center justify-center py-8"},qm={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"},Qm={class:"text-gray-600 dark:text-gray-400"},ep={class:"flex gap-2 mt-4"},tp={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},np=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(a,{emit:n}){const t=a,o=n,i=xt(),r=e.ref(!1),s=e.ref(!1),c=e.ref(!1),l=e.ref(!1),d=e.ref(null),u=e.ref(0),m=e.ref(null),f=e.ref(void 0),p=e.ref(null),v=e.ref(null),g=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),E=e.computed(()=>i.modelMedia.map($=>$.uuid)),T=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function N(){$n({isAdmin:t.mode==="admin"})}async function w($){await(await I.toastController.create({message:$,duration:3e3,color:"danger",position:"bottom"})).present()}async function h(){if(!s.value)if(s.value=!0,N(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],o("update:media",i.modelMedia);else{r.value=!0,o("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),o("update:media",i.modelMedia)}catch($){const X=$ instanceof Error?$.message:"Failed to fetch media";o("error",{operation:"fetch",message:X,details:$})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,$=>{s.value&&o("update:media",$)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,h()}),e.watch(()=>t.mode,()=>{N()}),e.onMounted(()=>{h()}),e.onUnmounted(()=>{i.clearModelContext()});function x(){return i.modelMedia.length>0}function D(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function C($){var W,te,ge;if(!((W=$.mime_type)!=null&&W.startsWith("image/")))return null;const X=$.original_url||$.url||((te=$.conversion_urls)==null?void 0:te.preview)||((ge=$.conversion_urls)==null?void 0:ge.thumb)||$.thumbnail_url;return X&&X.trim()!==""?X:null}function y(){c.value=!0}function S(){var $;($=v.value)==null||$.click()}function A(){c.value=!1}async function k($){if(!t.allowEdit)return;const X=C($);if(X){d.value=$,u.value++;try{const W=i.getHttpClient(),te=i.getApiUrl(""),ge=await W(`${te.replace(/\/$/,"")}/editor/${$.uuid}/edit`);f.value=ge.editable_source_url||X,m.value=ge.editor_state??null}catch{f.value=X,m.value=null}l.value=!0}}function B(){l.value=!1,d.value=null,f.value=void 0,m.value=null}async function R($){if(!d.value)throw new Error("No media selected for editing");const X=d.value,W=t.editMode==="variant";try{p.value=null;const te=await i.saveEditedImage(X.uuid,$,{asVariant:W,name:X.file_name});W||await i.detachMedia(t.mediableType,t.mediableId,X.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[te.uuid],t.collection),o("edit-complete",{originalMedia:X,editedMedia:te,mode:t.editMode}),l.value=!1,d.value=null}catch(te){const ge=te instanceof Error?te.message:"Failed to save edited image";throw p.value=ge,await w(ge),te}}function U($){if(p.value===$.message){p.value=null;return}w($.message)}async function _($){const X=$.target,W=X.files;if(!(!W||W.length===0)){for(let te=0;te<W.length;te++){const ge=W[te];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ge.type)){o("error",{operation:"upload",message:`File type ${ge.type} is not accepted`,details:{file:ge.name}});continue}if(t.maxFileSize!==void 0&&ge.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ge.name,size:ge.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:ge});try{const Ne=await i.uploadFile(ge,{collection:t.collection});Ne!=null&&Ne.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[Ne.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:ge}),o("attach",[Ne]))}catch(Ne){const ee=Ne instanceof Error?Ne.message:"Upload failed";o("error",{operation:"upload",message:ee,details:Ne}),o("upload-progress",{status:"error",progress:0,file:ge,error:ee})}}X.value=""}}async function z($){const X=$.map(W=>W.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,X,t.collection),o("reorder",i.modelMedia)}catch(W){const te=W instanceof Error?W.message:"Failed to reorder media";o("error",{operation:"reorder",message:te,details:W}),await w(te)}}async function H($){const X=i.modelMedia.find(W=>W.uuid===$);try{await i.detachMedia(t.mediableType,t.mediableId,$,t.collection),X&&o("detach",X)}catch(W){const te=W instanceof Error?W.message:"Failed to detach media";o("error",{operation:"detach",message:te,details:W}),await w(te)}}async function M($){c.value=!1;const X=$.map(ge=>ge.uuid),W=new Set(E.value);let te=Array.from(new Set(X)).filter(ge=>!W.has(ge));if(g.value!==void 0&&te.length>g.value&&(te=te.slice(0,g.value)),te.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,te,t.collection);const ge=i.modelMedia.filter(Ne=>te.includes(Ne.uuid));o("attach",ge)}catch(ge){const Ne=ge instanceof Error?ge.message:"Failed to attach media";o("error",{operation:"attach",message:Ne,details:ge})}}return($,X)=>(e.openBlock(),e.createElementBlock("div",Xm,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:T.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:_},null,40,Hm),e.createElementVNode("div",Gm,[$.title?(e.openBlock(),e.createElementBlock("h3",Jm,e.toDisplayString($.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ym,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small",disabled:D(),"data-testid":"browse-button",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(ui)},null,8,["icon"]),X[1]||(X[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small",disabled:D(),"data-testid":"upload-button",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(rs)},null,8,["icon"]),X[2]||(X[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Km,[e.createVNode(e.unref(I.IonSpinner),{"data-testid":"spinner"})])):x()?(e.openBlock(),e.createBlock(Zm,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!$.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!$.allowEdit,"selection-mode":!1,onReorder:z,onDelete:H,onEdit:k},e.createSlots({_:2},[$.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:W})=>[W===0?(e.openBlock(),e.createElementBlock("div",tp," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",qm,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ui),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Qm,e.toDisplayString($.emptyText),1),e.createElementVNode("div",ep,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(ui)},null,8,["icon"]),X[3]||(X[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(rs)},null,8,["icon"]),X[4]||(X[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(xm,e.mergeProps({"is-open":c.value,"selected-items":E.value,collection:$.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:M,onClose:A}),null,16,["is-open","selected-items","collection"]),e.createVNode(sl,{modelValue:l.value,"onUpdate:modelValue":X[0]||(X[0]=W=>l.value=W),"initial-image":f.value,"initial-state":m.value,"session-key":u.value,"on-save":R,onCancel:B,onError:U},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),op=Be(np,[["__scopeId","data-v-6677bbfe"]]);function Lo(a,n,t,o){if(t<=0||o<=0)return!1;try{return n.drawImage(a,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function ap(a,n){return a?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:n,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:n,opacity:"1",pointerEvents:"auto"}}const ip=["src"],rp={class:"preview-controls"},sp=["aria-label"],lp={class:"time-display"},cp={class:"current-time"},dp={class:"total-time"},up={key:0,class:"fps-display"},mp={key:0,class:"loading-overlay"},pp={key:1,class:"error-overlay"},fp=.1,hp=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},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(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Ye,r=a,s=t,c=e.ref(),l=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),f=e.ref(0),p=e.ref(0),v=e.ref(!1);let g,E,T=null,N=null,w=null,h=[],x="",D=null,C=0,y=0,S=0,A=0,k=!1,B=0,R=0,U,_=null,z=!1,H=!1,M=0;const $=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),X=e.computed(()=>ap(v.value,r.fitMode));function W(J){return typeof J=="number"&&Number.isFinite(J)&&J>=0?J:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function te(J){const ue=W(J.duration);return ue<=0?!1:J.currentTime>=Math.max(0,ue-fp)}async function ge(){var J,ue;if(!H&&l.value&&!g&&!(!d.value||d.value.readyState<3)){H=!0;try{m.value=void 0;let ve=((J=c.value)==null?void 0:J.clientWidth)||800,Z=((ue=c.value)==null?void 0:ue.clientHeight)||450;if((ve<=0||Z<=0)&&(ve=d.value.videoWidth||800,Z=d.value.videoHeight||450),g=new Ye.Application,await g.init({width:ve,height:Z,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),l.value.appendChild(g.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!g&&ge()},100),g&&(g.destroy(!0),g=null);return}if(C=d.value.videoWidth,y=d.value.videoHeight,N=document.createElement("canvas"),N.width=C,N.height=y,w=N.getContext("2d"),!w)throw new Error("Unable to create 2D canvas context for video preview");const Q=Lo(d.value,w,C,y),ae=Ye.Texture.from(N);T=ae.source,E=new Ye.Sprite(ae),E.visible=!0,E.alpha=1,de(),g.stage.addChild(E),g.renderer&&!g.renderer.destroyed&&g.render()}P(),r.targetFps<60?Ne():g.ticker.add(ee),v.value=!0,"ResizeObserver"in window&&(D=new ResizeObserver(Q=>{k||(k=!0,requestAnimationFrame(()=>{k=!1;const ae=Q[Q.length-1],{width:xe,height:De}=ae.contentRect;if(xe<=0||De<=0)return;const Qe=Math.round(xe),We=Math.round(De);Qe===S&&We===A||(S=Qe,A=We,de())}))}),D.observe(c.value)),r.filters&&r.filters.length>0&&P(),r.showFps&&Se(),M=0}catch{if(pt(),!z&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&M<2){M+=1,window.setTimeout(()=>{z||ge()},M*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{H=!1}}}function Ne(){const J=1e3/r.targetFps;let ue=performance.now();function ve(){if(z||!g)return;const Z=performance.now(),Q=Z-ue;Q>=J&&(ee(),ue=Z-Q%J),_=requestAnimationFrame(ve)}_=requestAnimationFrame(ve)}function ee(){if(!(!g||!E||z)&&r.active)try{w&&N&&T&&d.value&&(d.value.readyState>=2&&Lo(d.value,w,N.width,N.height)&&T.update(),d.value.paused||s("frame-update",Y())),r.showFps&&R++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{z=!0}}function F(){for(const J of h)try{J.destroy()}catch{}h=[]}function P(){if(E){if(!r.filters||r.filters.length===0){E.filters=null,F();return}F(),r.filters.forEach(J=>{const ue=pe(J);ue&&h.push(ue)}),E.filters=h.length>0?h:null,x=JSON.stringify(r.filters),g&&g.render()}}function pe(J){const ue=J.filterId,ve=J.params||{},Z=ct.getFilter(ue);if(Z&&!ct.isFilterCompatibleWithMedia(ue,"video"))return null;if(Z&&Z.createFilter)try{return Z.createFilter(ve)}catch{}const Q=(ae,xe,De)=>Math.min(De,Math.max(xe,ae));switch(ue){case"brightness":{const ae=new o,xe=Q(typeof ve.brightness=="number"?ve.brightness:typeof ve.value=="number"?ve.value:1,0,5);return ae.brightness(xe,!0),ae}case"contrast":{const ae=new o,xe=Q(typeof ve.contrast=="number"?ve.contrast:typeof ve.value=="number"?ve.value:1,0,5);return ae.contrast(xe,!0),ae}case"saturation":{const ae=new o,xe=Q(typeof ve.saturation=="number"?ve.saturation:typeof ve.value=="number"?ve.value:1,0,5);return ae.saturate(xe,!0),ae}case"hue":{const ae=new o,xe=Q(typeof ve.value=="number"?ve.value:0,-180,180);return ae.hue(xe,!0),ae}case"gaussian-blur":case"blur":{const ae=Q(typeof ve.blur=="number"?ve.blur:typeof ve.value=="number"?ve.value:2,0,10);return new i(ae)}case"grayscale":{const ae=new o;return ae.desaturate(),ae}case"sepia":case"color-matrix":{const ae=new o;return ae.sepia(!0),ae}case"vignette":{const ae=typeof ve.value=="number"?ve.value:.3;return ne(Q(ae,0,1))}default:return null}}function ne(J){const ue=`
7
7
  precision mediump float;
8
8
  varying vec2 vTextureCoord;
9
9
  uniform sampler2D uSampler;
@@ -15,22 +15,22 @@
15
15
  vec4 color = texture2D(uSampler, vTextureCoord);
16
16
  gl_FragColor = vec4(color.rgb * (1.0 - vignette), color.a);
17
17
  }
18
- `;return new Ye.Filter(void 0,ue,{strength:J})}function Y(){var ue;return!g||!E?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((ue=d.value)==null?void 0:ue.currentTime)||0,width:C||0,height:y||0}}function Me(){var J;f.value=j((J=d.value)==null?void 0:J.duration),s("duration-change",f.value)}function ce(){u.value=!1,m.value=void 0}function se(){u.value&&(u.value=!1),!v.value&&r.active?ge():v.value}function ke(){var ue,ve,Z;const J=((ue=d.value)==null?void 0:ue.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:J,width:((ve=d.value)==null?void 0:ve.videoWidth)||0,height:((Z=d.value)==null?void 0:Z.videoHeight)||0})}function oe(){d.value&&(d.value.currentTime=0),s("play-pause")}function le(J){var ve;const ue=J.target;if(ue!=null&&ue.error)switch(ue.error.code){case ue.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case ue.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case ue.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case ue.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(ve=ue.src)==null?void 0:ve.substring(0,100)}`;break;default:m.value="Failed to load video"}else m.value="Failed to load video";s("error",m.value),u.value=!1}function Ee(J){d.value&&(d.value.currentTime=Math.max(0,Math.min(J,f.value)))}function Se(){U=window.setInterval(()=>{const J=performance.now(),ue=J-B;p.value=Math.round(R*1e3/ue),R=0,B=J},1e3)}function rt(J){if(!Number.isFinite(J)||J<0)return"00:00";const ue=Math.floor(J/60),ve=Math.floor(J%60);return`${ue.toString().padStart(2,"0")}:${ve.toString().padStart(2,"0")}`}function He(){m.value=void 0,u.value=!0,M=0,pt(),d.value&&d.value.load()}function pt(){if(D&&(D.disconnect(),D=null),_&&(cancelAnimationFrame(_),_=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(ee)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}l.value&&(l.value.innerHTML=""),F(),g=null,E=null,T=null,N=null,w=null,v.value=!1,k=!1,x=""}function K(){g&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,de()})))}function de(){if(!g||!E||!C||!y||!c.value)return;const J=Math.round(c.value.clientWidth),ue=Math.round(c.value.clientHeight);if(J<=0||ue<=0)return;g.renderer.resize(J,ue);const ve=g.screen.width/C,Z=g.screen.height/y;let Q=1;switch(r.fitMode){case"cover":Q=Math.max(ve,Z);break;case"none":Q=1;break;case"contain":default:Q=Math.min(ve,Z);break}E.scale.set(Q),E.anchor.set(.5),E.position.set(g.screen.width/2,g.screen.height/2),E.visible=!0,E.alpha=1,g.renderer&&!g.renderer.destroyed&&g.render()}e.watch(()=>r.filters,()=>{v.value&&P()},{deep:!0}),e.watch(()=>r.active,async J=>{if(J&&!g&&d.value&&d.value.readyState>=2){await ge();return}g&&(J&&(await e.nextTick(),c.value&&c.value.getBoundingClientRect(),E&&w&&N&&T&&(d.value&&d.value.readyState>=2&&Oo(d.value,w,N.width,N.height)&&T.update(),de(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(J?g.ticker.start():g.ticker.stop()))}),e.watch($,J=>{J?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function ie(){if(d.value){m.value=void 0,te(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}m.value="Unable to start preview playback",s("error",m.value)}}e.watch(()=>r.isPlaying,J=>{d.value&&(J?ie():d.value.pause())}),e.watch(()=>r.playhead,J=>{d.value&&Math.abs(d.value.currentTime-J)>.5&&Ee(J)}),e.watch(()=>r.fitMode,()=>{de()}),e.onMounted(()=>{z=!1,e.nextTick(()=>{c.value&&c.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",K),B=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value&&ge()})}),e.onUnmounted(()=>{if(z=!0,_&&(cancelAnimationFrame(_),_=null),window.removeEventListener("resize",K),D&&(D.disconnect(),D=null),U&&clearInterval(U),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(ee)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}h.forEach(J=>{try{J.destroy()}catch{}}),h=[],E=null,T=null,N=null,w=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function he(J){if(!await _e()||!d.value||!w||!N||!T)return null;const ve=d.value,Z=Number.isFinite(f.value)&&f.value>0?f.value:Number.isFinite(ve.duration)&&ve.duration>0?ve.duration:0,Q=Math.max(0,Math.min(J,Z));return await new Promise(xe=>{let De=!1,Qe=0;const We=()=>{De||(De=!0,ve.removeEventListener("seeked",ft),window.clearTimeout(Qe),xe())},ft=()=>{We()},Ze=Number.isFinite(ve.currentTime)?ve.currentTime:0;if(Math.abs(Ze-Q)<.016){requestAnimationFrame(()=>We());return}ve.addEventListener("seeked",ft),Qe=window.setTimeout(()=>We(),700),ve.currentTime=Q}),Oo(ve,w,N.width,N.height)?(T.update(),g.render(),g.canvas):null}async function _e(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await ge()}if(!g||!E||!w||!N||!T)return!1;if(r.filters&&r.filters.length>0){const J=E.filters,ue=Array.isArray(J)?J.length:0,Z=JSON.stringify(r.filters)!==x;(ue===0||ue!==r.filters.length||Z)&&P()}return await e.nextTick(),await new Promise(J=>{requestAnimationFrame(()=>J())}),!0}return n({captureFrameAt:he,ensureReadyForCapture:_e,duration:f,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(J,ue)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:c},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:l},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:$.value,onLoadedmetadata:Me,onLoadeddata:ce,onCanplay:se,onTimeupdate:ke,onEnded:oe,onError:le,style:e.normalizeStyle(X.value),crossorigin:"anonymous",playsinline:"",controls:""},null,44,tp),e.createElementVNode("div",np,[e.createElementVNode("button",{class:"play-button",onClick:ue[0]||(ue[0]=ve=>J.$emit("play-pause")),"aria-label":J.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:J.isPlaying?e.unref(sl):e.unref(cl)},null,8,["icon"])],8,op),e.createElementVNode("div",ap,[e.createElementVNode("span",ip,e.toDisplayString(rt(J.playhead)),1),ue[1]||(ue[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",rp,e.toDisplayString(rt(f.value)),1)]),J.showFps?(e.openBlock(),e.createElementBlock("div",sp,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",lp,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),ue[2]||(ue[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",cp,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ji)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:He},"Retry")])):e.createCommentVNode("",!0)],512))}}),ls=Be(up,[["__scopeId","data-v-192ec332"]]);var Ki=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},O=(a,n,t)=>(Ki(a,n,"read from private field"),t?t.call(a):n.get(a)),Ie=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},it=(a,n,t,o)=>(Ki(a,n,"write to private field"),n.set(a,t),t),mp=(a,n,t,o)=>({set _(i){it(a,n,i)},get _(){return O(a,n,o)}}),Re=(a,n,t)=>(Ki(a,n,"access private method"),t),$e=new Uint8Array(8),Wt=new DataView($e.buffer),tt=a=>[(a%256+256)%256],Le=a=>(Wt.setUint16(0,a,!1),[$e[0],$e[1]]),pp=a=>(Wt.setInt16(0,a,!1),[$e[0],$e[1]]),pl=a=>(Wt.setUint32(0,a,!1),[$e[1],$e[2],$e[3]]),be=a=>(Wt.setUint32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),fp=a=>(Wt.setInt32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),bn=a=>(Wt.setUint32(0,Math.floor(a/2**32),!1),Wt.setUint32(4,a,!1),[$e[0],$e[1],$e[2],$e[3],$e[4],$e[5],$e[6],$e[7]]),qi=a=>(Wt.setInt16(0,2**8*a,!1),[$e[0],$e[1]]),zt=a=>(Wt.setInt32(0,2**16*a,!1),[$e[0],$e[1],$e[2],$e[3]]),ci=a=>(Wt.setInt32(0,2**30*a,!1),[$e[0],$e[1],$e[2],$e[3]]),Nt=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},sa=a=>a&&a[a.length-1],Qi=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},jt=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},fl=a=>{let n=a*(Math.PI/180),t=Math.cos(n),o=Math.sin(n);return[t,o,0,-o,t,0,0,0,1]},hl=fl(0),vl=a=>[zt(a[0]),zt(a[1]),ci(a[2]),zt(a[3]),zt(a[4]),ci(a[5]),zt(a[6]),zt(a[7]),ci(a[8])],lo=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(lo):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,lo(t)])),Dn=a=>a>=0&&a<2**32,qe=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),Pe=(a,n,t,o,i)=>qe(a,[tt(n),pl(t),o??[]],i),hp=a=>{let n=512;return a.fragmented?qe("ftyp",[Nt("iso5"),be(n),Nt("iso5"),Nt("iso6"),Nt("mp41")]):qe("ftyp",[Nt("isom"),be(n),Nt("isom"),a.holdsAvc?Nt("avc1"):[],Nt("mp41")])},Vi=a=>({type:"mdat",largeSize:a}),vp=a=>({type:"free",size:a}),Jo=(a,n,t=!1)=>qe("moov",null,[gp(n,a),...a.map(o=>yp(o,n)),t?Jp(a):null]),gp=(a,n)=>{let t=jt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const c=Qi(s.samples);return c.presentationTimestamp+c.duration})),Ni),o=Math.max(...n.map(s=>s.id))+1,i=!Dn(a)||!Dn(t),r=i?bn:be;return Pe("mvhd",+i,0,[r(a),r(a),be(Ni),r(t),zt(1),qi(1),Array(10).fill(0),vl(hl),Array(24).fill(0),be(o)])},yp=(a,n)=>qe("trak",null,[wp(a,n),bp(a,n)]),wp=(a,n)=>{let t=Qi(a.samples),o=jt(t?t.presentationTimestamp+t.duration:0,Ni),i=!Dn(n)||!Dn(o),r=i?bn:be,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?fl(a.info.rotation):a.info.rotation:s=hl,Pe("tkhd",+i,3,[r(n),r(n),be(a.id),be(0),r(o),Array(8).fill(0),Le(0),Le(0),qi(a.info.type==="audio"?1:0),Le(0),vl(s),zt(a.info.type==="video"?a.info.width:0),zt(a.info.type==="video"?a.info.height:0)])},bp=(a,n)=>qe("mdia",null,[kp(a,n),xp(a.info.type==="video"?"vide":"soun"),Ep(a)]),kp=(a,n)=>{let t=Qi(a.samples),o=jt(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Dn(n)||!Dn(o),r=i?bn:be;return Pe("mdhd",+i,0,[r(n),r(n),be(a.timescale),r(o),Le(21956),Le(0)])},xp=a=>Pe("hdlr",0,0,[Nt("mhlr"),Nt(a),be(0),be(0),be(0),Nt("mp4-muxer-hdlr",!0)]),Ep=a=>qe("minf",null,[a.info.type==="video"?Vp():Sp(),Cp(),Tp(a)]),Vp=()=>Pe("vmhd",0,1,[Le(0),Le(0),Le(0),Le(0)]),Sp=()=>Pe("smhd",0,0,[Le(0),Le(0)]),Cp=()=>qe("dinf",null,[Np()]),Np=()=>Pe("dref",0,0,[be(1)],[_p()]),_p=()=>Pe("url ",0,1),Tp=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return qe("stbl",null,[Mp(a),jp(a),Wp(a),Zp(a),Xp(a),Hp(a),n?Gp(a):null])},Mp=a=>Pe("stsd",0,0,[be(1)],[a.info.type==="video"?Bp(rf[a.info.codec],a):Lp(lf[a.info.codec],a)]),Bp=(a,n)=>qe(a,[Array(6).fill(0),Le(1),Le(0),Le(0),Array(12).fill(0),Le(n.info.width),Le(n.info.height),be(4718592),be(4718592),be(0),Le(1),Array(32).fill(0),Le(24),pp(65535)],[sf[n.info.codec](n),n.info.decoderConfig.colorSpace?$p(n):null]),Fp={bt709:1,bt470bg:5,smpte170m:6},Ip={bt709:1,smpte170m:6,"iec61966-2-1":13},Rp={rgb:0,bt709:1,bt470bg:5,smpte170m:6},$p=a=>qe("colr",[Nt("nclx"),Le(Fp[a.info.decoderConfig.colorSpace.primaries]),Le(Ip[a.info.decoderConfig.colorSpace.transfer]),Le(Rp[a.info.decoderConfig.colorSpace.matrix]),tt((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Dp=a=>a.info.decoderConfig&&qe("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),Up=a=>a.info.decoderConfig&&qe("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),Ap=a=>{if(!a.info.decoderConfig)return null;let n=a.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),o=Number(t[1]),i=Number(t[2]),c=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return Pe("vpcC",1,0,[tt(o),tt(i),tt(c),tt(2),tt(2),tt(2),Le(0)])},Op=()=>{let t=(1<<7)+1;return qe("av1C",[t,0,0,0])},Lp=(a,n)=>qe(a,[Array(6).fill(0),Le(1),Le(0),Le(0),be(0),Le(n.info.numberOfChannels),Le(16),Le(0),Le(0),zt(n.info.sampleRate)],[cf[n.info.codec](n)]),zp=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return Pe("esds",0,0,[be(58753152),tt(32+n.byteLength),Le(1),tt(0),be(75530368),tt(18+n.byteLength),tt(64),tt(21),pl(0),be(130071),be(130071),be(92307584),tt(n.byteLength),...n,be(109084800),tt(1),tt(2)])},Pp=a=>{var i;let n=3840,t=0;const o=(i=a.info.decoderConfig)==null?void 0:i.description;if(o){if(o.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(o)?new DataView(o.buffer,o.byteOffset,o.byteLength):new DataView(o);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return qe("dOps",[tt(0),tt(a.info.numberOfChannels),Le(n),be(a.info.sampleRate),qi(t),tt(0)])},jp=a=>Pe("stts",0,0,[be(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[be(n.sampleCount),be(n.sampleDelta)])]),Wp=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return Pe("stss",0,0,[be(n.length),n.map(([t])=>be(t+1))])},Zp=a=>Pe("stsc",0,0,[be(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[be(n.firstChunk),be(n.samplesPerChunk),be(1)])]),Xp=a=>Pe("stsz",0,0,[be(0),be(a.samples.length),a.samples.map(n=>be(n.size))]),Hp=a=>a.finalizedChunks.length>0&&sa(a.finalizedChunks).offset>=2**32?Pe("co64",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>bn(n.offset))]):Pe("stco",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>be(n.offset))]),Gp=a=>Pe("ctts",0,0,[be(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[be(n.sampleCount),be(n.sampleCompositionTimeOffset)])]),Jp=a=>qe("mvex",null,a.map(Yp)),Yp=a=>Pe("trex",0,0,[be(a.id),be(1),be(0),be(0),be(0)]),cs=(a,n)=>qe("moof",null,[Kp(a),...n.map(qp)]),Kp=a=>Pe("mfhd",0,0,[be(a)]),gl=a=>{let n=0,t=0,o=0,i=0,r=a.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|o<<8|i},qp=a=>qe("traf",null,[Qp(a),ef(a),tf(a)]),Qp=a=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=a.currentChunk.samples[1]??a.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:gl(t)};return Pe("tfhd",0,n,[be(a.id),be(o.duration),be(o.size),be(o.flags)])},ef=a=>Pe("tfdt",1,0,[bn(jt(a.currentChunk.startTimestamp,a.timescale))]),tf=a=>{let n=a.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(g=>g.size),o=a.currentChunk.samples.map(gl),i=a.currentChunk.samples.map(g=>jt(g.presentationTimestamp-g.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),c=new Set(o),l=new Set(i),d=c.size===2&&o[0]!==o[1],u=r.size>1,m=s.size>1,f=!d&&c.size>1,p=l.size>1||[...l].some(g=>g!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+f,v|=2048*+p,Pe("trun",1,v,[be(a.currentChunk.samples.length),be(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?be(o[0]):[],a.currentChunk.samples.map((g,E)=>[u?be(n[E]):[],m?be(t[E]):[],f?be(o[E]):[],p?fp(i[E]):[]])])},nf=a=>qe("mfra",null,[...a.map(of),af()]),of=(a,n)=>Pe("tfra",1,0,[be(a.id),be(63),be(a.finalizedChunks.length),a.finalizedChunks.map(o=>[bn(jt(o.startTimestamp,a.timescale)),bn(o.moofOffset),be(n+1),be(1),be(1)])]),af=()=>Pe("mfro",0,0,[be(0)]),rf={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},sf={avc:Dp,hevc:Up,vp9:Ap,av1:Op},lf={aac:"mp4a",opus:"Opus"},cf={aac:zp,opus:Pp},ba=class{},er=class extends ba{constructor(){super(...arguments),this.buffer=null}},yl=class extends ba{constructor(a){if(super(),this.options=a,typeof a!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(a.onData){if(typeof a.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(a.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(a.chunked!==void 0&&typeof a.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},df=class extends ba{constructor(a,n){if(super(),this.stream=a,this.options=n,!(a instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(n!==void 0&&typeof n!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(n&&n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},dn,Mn,wl=class{constructor(){this.pos=0,Ie(this,dn,new Uint8Array(8)),Ie(this,Mn,new DataView(O(this,dn).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){O(this,Mn).setUint32(0,a,!1),this.write(O(this,dn).subarray(0,4))}writeU64(a){O(this,Mn).setUint32(0,Math.floor(a/2**32),!1),O(this,Mn).setUint32(4,a,!1),this.write(O(this,dn).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)O(this,Mn).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(O(this,dn));a.length%8!==0&&this.write(O(this,dn).subarray(0,a.length%8))}writeBox(a){if(this.offsets.set(a,this.pos),a.contents&&!a.children)this.writeBoxHeader(a,a.size??a.contents.byteLength+8),this.write(a.contents);else{let n=this.pos;if(this.writeBoxHeader(a,0),a.contents&&this.write(a.contents),a.children)for(let i of a.children)i&&this.writeBox(i);let t=this.pos,o=a.size??t-n;this.seek(n),this.writeBoxHeader(a,o),this.seek(t)}}writeBoxHeader(a,n){this.writeU32(a.largeSize?1:n),this.writeAscii(a.type),a.largeSize&&this.writeU64(n)}measureBoxHeader(a){return 8+(a.largeSize?8:0)}patchBox(a){let n=this.pos;this.seek(this.offsets.get(a)),this.writeBox(a),this.seek(n)}measureBox(a){if(a.contents&&!a.children)return this.measureBoxHeader(a)+a.contents.byteLength;{let n=this.measureBoxHeader(a);if(a.contents&&(n+=a.contents.byteLength),a.children)for(let t of a.children)t&&(n+=this.measureBox(t));return n}}};dn=new WeakMap;Mn=new WeakMap;var Yo,yn,vo,ao,Ko,Si,uf=class extends wl{constructor(a){super(),Ie(this,Ko),Ie(this,Yo,void 0),Ie(this,yn,new ArrayBuffer(2**16)),Ie(this,vo,new Uint8Array(O(this,yn))),Ie(this,ao,0),it(this,Yo,a)}write(a){Re(this,Ko,Si).call(this,this.pos+a.byteLength),O(this,vo).set(a,this.pos),this.pos+=a.byteLength,it(this,ao,Math.max(O(this,ao),this.pos))}finalize(){Re(this,Ko,Si).call(this,this.pos),O(this,Yo).buffer=O(this,yn).slice(0,Math.max(O(this,ao),this.pos))}};Yo=new WeakMap;yn=new WeakMap;vo=new WeakMap;ao=new WeakMap;Ko=new WeakSet;Si=function(a){let n=O(this,yn).byteLength;for(;n<a;)n*=2;if(n===O(this,yn).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(O(this,vo),0),it(this,yn,t),it(this,vo,o)};var mf=2**24,pf=2,co,un,io,Kt,St,la,Ci,tr,bl,nr,kl,uo,ca,or=class extends wl{constructor(a){var n,t;super(),Ie(this,la),Ie(this,tr),Ie(this,nr),Ie(this,uo),Ie(this,co,void 0),Ie(this,un,[]),Ie(this,io,void 0),Ie(this,Kt,void 0),Ie(this,St,[]),it(this,co,a),it(this,io,((n=a.options)==null?void 0:n.chunked)??!1),it(this,Kt,((t=a.options)==null?void 0:t.chunkSize)??mf)}write(a){O(this,un).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(O(this,un).length===0)return;let a=[],n=[...O(this,un)].sort((i,r)=>i.start-r.start);a.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=a[a.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):a.push({start:s.start,size:s.data.byteLength})}for(let i of a){i.data=new Uint8Array(i.size);for(let r of O(this,un))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);O(this,io)?(Re(this,la,Ci).call(this,i.data,i.start),Re(this,uo,ca).call(this)):(o=(t=O(this,co).options).onData)==null||o.call(t,i.data,i.start)}O(this,un).length=0}finalize(){O(this,io)&&Re(this,uo,ca).call(this,!0)}};co=new WeakMap;un=new WeakMap;io=new WeakMap;Kt=new WeakMap;St=new WeakMap;la=new WeakSet;Ci=function(a,n){let t=O(this,St).findIndex(c=>c.start<=n&&n<c.start+O(this,Kt));t===-1&&(t=Re(this,nr,kl).call(this,n));let o=O(this,St)[t],i=n-o.start,r=a.subarray(0,Math.min(O(this,Kt)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Re(this,tr,bl).call(this,o,s),o.written[0].start===0&&o.written[0].end===O(this,Kt)&&(o.shouldFlush=!0),O(this,St).length>pf){for(let c=0;c<O(this,St).length-1;c++)O(this,St)[c].shouldFlush=!0;Re(this,uo,ca).call(this)}r.byteLength<a.byteLength&&Re(this,la,Ci).call(this,a.subarray(r.byteLength),n+r.byteLength)};tr=new WeakSet;bl=function(a,n){let t=0,o=a.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);a.written[r].start<=n.start?(t=r+1,i=r):o=r-1}for(a.written.splice(i+1,0,n),(i===-1||a.written[i].end<n.start)&&i++;i<a.written.length-1&&a.written[i].end>=a.written[i+1].start;)a.written[i].end=Math.max(a.written[i].end,a.written[i+1].end),a.written.splice(i+1,1)};nr=new WeakSet;kl=function(a){let t={start:Math.floor(a/O(this,Kt))*O(this,Kt),data:new Uint8Array(O(this,Kt)),written:[],shouldFlush:!1};return O(this,St).push(t),O(this,St).sort((o,i)=>o.start-i.start),O(this,St).indexOf(t)};uo=new WeakSet;ca=function(a=!1){var n,t;for(let o=0;o<O(this,St).length;o++){let i=O(this,St)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=O(this,co).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);O(this,St).splice(o--,1)}}};var ff=class extends or{constructor(a){var n;super(new yl({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},Ni=1e3,hf=["avc","hevc","vp9","av1"],vf=["aac","opus"],gf=2082844800,yf=["strict","offset","cross-track-offset"],Ce,Te,da,Et,lt,at,Bn,Fn,ar,mn,pn,mo,_i,xl,Ti,El,ir,Vl,Mi,Sl,rr,Cl,qo,Bi,Lt,Yt,sr,Nl,po,ua,ma,lr,Un,wo,Qo,Fi,_l=class{constructor(a){if(Ie(this,_i),Ie(this,Ti),Ie(this,ir),Ie(this,Mi),Ie(this,rr),Ie(this,qo),Ie(this,Lt),Ie(this,sr),Ie(this,po),Ie(this,ma),Ie(this,Un),Ie(this,Qo),Ie(this,Ce,void 0),Ie(this,Te,void 0),Ie(this,da,void 0),Ie(this,Et,void 0),Ie(this,lt,null),Ie(this,at,null),Ie(this,Bn,Math.floor(Date.now()/1e3)+gf),Ie(this,Fn,[]),Ie(this,ar,1),Ie(this,mn,[]),Ie(this,pn,[]),Ie(this,mo,!1),Re(this,_i,xl).call(this,a),a.video=lo(a.video),a.audio=lo(a.audio),a.fastStart=lo(a.fastStart),this.target=a.target,it(this,Ce,{firstTimestampBehavior:"strict",...a}),a.target instanceof er)it(this,Te,new uf(a.target));else if(a.target instanceof yl)it(this,Te,new or(a.target));else if(a.target instanceof df)it(this,Te,new ff(a.target));else throw new Error(`Invalid target: ${a.target}`);Re(this,Mi,Sl).call(this),Re(this,Ti,El).call(this)}addVideoChunk(a,n,t,o){if(!(a instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(n&&typeof n!="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(o!==void 0&&!Number.isFinite(o))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(a.byteLength);a.copyTo(i),this.addVideoChunkRaw(i,a.type,t??a.timestamp,a.duration,n,o)}addVideoChunkRaw(a,n,t,o,i,r){if(!(a instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(r!==void 0&&!Number.isFinite(r))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Re(this,Qo,Fi).call(this),!O(this,Ce).video)throw new Error("No video track declared.");if(typeof O(this,Ce).fastStart=="object"&&O(this,lt).samples.length===O(this,Ce).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${O(this,Ce).fastStart.expectedVideoChunks}).`);let s=Re(this,qo,Bi).call(this,O(this,lt),a,n,t,o,i,r);if(O(this,Ce).fastStart==="fragmented"&&O(this,at)){for(;O(this,pn).length>0&&O(this,pn)[0].decodeTimestamp<=s.decodeTimestamp;){let c=O(this,pn).shift();Re(this,Lt,Yt).call(this,O(this,at),c)}s.decodeTimestamp<=O(this,at).lastDecodeTimestamp?Re(this,Lt,Yt).call(this,O(this,lt),s):O(this,mn).push(s)}else Re(this,Lt,Yt).call(this,O(this,lt),s)}addAudioChunk(a,n,t){if(!(a instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(n&&typeof n!="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 o=new Uint8Array(a.byteLength);a.copyTo(o),this.addAudioChunkRaw(o,a.type,t??a.timestamp,a.duration,n)}addAudioChunkRaw(a,n,t,o,i){if(!(a instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Re(this,Qo,Fi).call(this),!O(this,Ce).audio)throw new Error("No audio track declared.");if(typeof O(this,Ce).fastStart=="object"&&O(this,at).samples.length===O(this,Ce).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${O(this,Ce).fastStart.expectedAudioChunks}).`);let r=Re(this,qo,Bi).call(this,O(this,at),a,n,t,o,i);if(O(this,Ce).fastStart==="fragmented"&&O(this,lt)){for(;O(this,mn).length>0&&O(this,mn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=O(this,mn).shift();Re(this,Lt,Yt).call(this,O(this,lt),s)}r.decodeTimestamp<=O(this,lt).lastDecodeTimestamp?Re(this,Lt,Yt).call(this,O(this,at),r):O(this,pn).push(r)}else Re(this,Lt,Yt).call(this,O(this,at),r)}finalize(){if(O(this,mo))throw new Error("Cannot finalize a muxer more than once.");if(O(this,Ce).fastStart==="fragmented"){for(let n of O(this,mn))Re(this,Lt,Yt).call(this,O(this,lt),n);for(let n of O(this,pn))Re(this,Lt,Yt).call(this,O(this,at),n);Re(this,ma,lr).call(this,!1)}else O(this,lt)&&Re(this,po,ua).call(this,O(this,lt)),O(this,at)&&Re(this,po,ua).call(this,O(this,at));let a=[O(this,lt),O(this,at)].filter(Boolean);if(O(this,Ce).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=Jo(a,O(this,Bn)),r=O(this,Te).measureBox(i);n=O(this,Te).measureBox(O(this,Et));let s=O(this,Te).pos+r+n;for(let c of O(this,Fn)){c.offset=s;for(let{data:l}of c.samples)s+=l.byteLength,n+=l.byteLength}if(s<2**32)break;n>=2**32&&(O(this,Et).largeSize=!0)}let t=Jo(a,O(this,Bn));O(this,Te).writeBox(t),O(this,Et).size=n,O(this,Te).writeBox(O(this,Et));for(let o of O(this,Fn))for(let i of o.samples)O(this,Te).write(i.data),i.data=null}else if(O(this,Ce).fastStart==="fragmented"){let n=O(this,Te).pos,t=nf(a);O(this,Te).writeBox(t);let o=O(this,Te).pos-n;O(this,Te).seek(O(this,Te).pos-4),O(this,Te).writeU32(o)}else{let n=O(this,Te).offsets.get(O(this,Et)),t=O(this,Te).pos-n;O(this,Et).size=t,O(this,Et).largeSize=t>=2**32,O(this,Te).patchBox(O(this,Et));let o=Jo(a,O(this,Bn));if(typeof O(this,Ce).fastStart=="object"){O(this,Te).seek(O(this,da)),O(this,Te).writeBox(o);let i=n-O(this,Te).pos;O(this,Te).writeBox(vp(i))}else O(this,Te).writeBox(o)}Re(this,Un,wo).call(this),O(this,Te).finalize(),it(this,mo,!0)}};Ce=new WeakMap;Te=new WeakMap;da=new WeakMap;Et=new WeakMap;lt=new WeakMap;at=new WeakMap;Bn=new WeakMap;Fn=new WeakMap;ar=new WeakMap;mn=new WeakMap;pn=new WeakMap;mo=new WeakMap;_i=new WeakSet;xl=function(a){if(typeof a!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(a.target instanceof ba))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!hf.includes(a.video.codec))throw new TypeError(`Unsupported video codec: ${a.video.codec}`);if(!Number.isInteger(a.video.width)||a.video.width<=0)throw new TypeError(`Invalid video width: ${a.video.width}. Must be a positive integer.`);if(!Number.isInteger(a.video.height)||a.video.height<=0)throw new TypeError(`Invalid video height: ${a.video.height}. Must be a positive integer.`);const n=a.video.rotation;if(typeof n=="number"&&![0,90,180,270].includes(n))throw new TypeError(`Invalid video rotation: ${n}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(n)&&(n.length!==9||n.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${n.join()}`);if(a.video.frameRate!==void 0&&(!Number.isInteger(a.video.frameRate)||a.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${a.video.frameRate}. Must be a positive integer.`)}if(a.audio){if(!vf.includes(a.audio.codec))throw new TypeError(`Unsupported audio codec: ${a.audio.codec}`);if(!Number.isInteger(a.audio.numberOfChannels)||a.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${a.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(a.audio.sampleRate)||a.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${a.audio.sampleRate}. Must be a positive integer.`)}if(a.firstTimestampBehavior&&!yf.includes(a.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${a.firstTimestampBehavior}`);if(typeof a.fastStart=="object"){if(a.video){if(a.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(a.fastStart.expectedVideoChunks)||a.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(a.audio){if(a.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(a.fastStart.expectedAudioChunks)||a.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(a.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(a.minFragmentDuration!==void 0&&(!Number.isFinite(a.minFragmentDuration)||a.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Ti=new WeakSet;El=function(){var a;if(O(this,Te).writeBox(hp({holdsAvc:((a=O(this,Ce).video)==null?void 0:a.codec)==="avc",fragmented:O(this,Ce).fastStart==="fragmented"})),it(this,da,O(this,Te).pos),O(this,Ce).fastStart==="in-memory")it(this,Et,Vi(!1));else if(O(this,Ce).fastStart!=="fragmented"){if(typeof O(this,Ce).fastStart=="object"){let n=Re(this,ir,Vl).call(this);O(this,Te).seek(O(this,Te).pos+n)}it(this,Et,Vi(!0)),O(this,Te).writeBox(O(this,Et))}Re(this,Un,wo).call(this)};ir=new WeakSet;Vl=function(){if(typeof O(this,Ce).fastStart!="object")return;let a=0,n=[O(this,Ce).fastStart.expectedVideoChunks,O(this,Ce).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};Mi=new WeakSet;Sl=function(){if(O(this,Ce).video&&it(this,lt,{id:1,info:{type:"video",codec:O(this,Ce).video.codec,width:O(this,Ce).video.width,height:O(this,Ce).video.height,rotation:O(this,Ce).video.rotation??0,decoderConfig:null},timescale:O(this,Ce).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),O(this,Ce).audio&&(it(this,at,{id:O(this,Ce).video?2:1,info:{type:"audio",codec:O(this,Ce).audio.codec,numberOfChannels:O(this,Ce).audio.numberOfChannels,sampleRate:O(this,Ce).audio.sampleRate,decoderConfig:null},timescale:O(this,Ce).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),O(this,Ce).audio.codec==="aac")){let a=Re(this,rr,Cl).call(this,2,O(this,Ce).audio.sampleRate,O(this,Ce).audio.numberOfChannels);O(this,at).info.decoderConfig={codec:O(this,Ce).audio.codec,description:a,numberOfChannels:O(this,Ce).audio.numberOfChannels,sampleRate:O(this,Ce).audio.sampleRate}}};rr=new WeakSet;Cl=function(a,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=a.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=n.toString(2).padStart(24,"0")),s+=r.toString(2).padStart(4,"0");let c=Math.ceil(s.length/8)*8;s=s.padEnd(c,"0");let l=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)l[d/8]=parseInt(s.slice(d,d+8),2);return l};qo=new WeakSet;Bi=function(a,n,t,o,i,r,s){let c=o/1e6,l=(o-(s??0))/1e6,d=i/1e6,u=Re(this,sr,Nl).call(this,c,l,a);return c=u.presentationTimestamp,l=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:c,decodeTimestamp:l,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:jt(d,a.timescale)}};Lt=new WeakSet;Yt=function(a,n){O(this,Ce).fastStart!=="fragmented"&&a.samples.push(n);const t=jt(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=jt(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,O(this,Ce).fastStart!=="fragmented"){let s=sa(a.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,a.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const c=sa(a.compositionTimeOffsetTable);c.sampleCompositionTimeOffset===t?c.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,O(this,Ce).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:jt(n.duration,a.timescale)}),a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));a.lastSample=n;let o=!1;if(!a.currentChunk)o=!0;else{let i=n.presentationTimestamp-a.currentChunk.startTimestamp;if(O(this,Ce).fastStart==="fragmented"){let r=O(this,lt)??O(this,at);const s=O(this,Ce).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,Re(this,ma,lr).call(this))}else o=i>=.5}o&&(a.currentChunk&&Re(this,po,ua).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};sr=new WeakSet;Nl=function(a,n,t){var s,c;const o=O(this,Ce).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).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.
18
+ `;return new Ye.Filter(void 0,ue,{strength:J})}function Y(){var ue;return!g||!E?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((ue=d.value)==null?void 0:ue.currentTime)||0,width:C||0,height:y||0}}function Me(){var J;f.value=W((J=d.value)==null?void 0:J.duration),s("duration-change",f.value)}function ce(){u.value=!1,m.value=void 0}function se(){u.value&&(u.value=!1),!v.value&&r.active?ge():v.value}function ke(){var ue,ve,Z;const J=((ue=d.value)==null?void 0:ue.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:J,width:((ve=d.value)==null?void 0:ve.videoWidth)||0,height:((Z=d.value)==null?void 0:Z.videoHeight)||0})}function oe(){d.value&&(d.value.currentTime=0),s("play-pause")}function le(J){var ve;const ue=J.target;if(ue!=null&&ue.error)switch(ue.error.code){case ue.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case ue.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case ue.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case ue.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(ve=ue.src)==null?void 0:ve.substring(0,100)}`;break;default:m.value="Failed to load video"}else m.value="Failed to load video";s("error",m.value),u.value=!1}function Ee(J){d.value&&(d.value.currentTime=Math.max(0,Math.min(J,f.value)))}function Se(){U=window.setInterval(()=>{const J=performance.now(),ue=J-B;p.value=Math.round(R*1e3/ue),R=0,B=J},1e3)}function rt(J){if(!Number.isFinite(J)||J<0)return"00:00";const ue=Math.floor(J/60),ve=Math.floor(J%60);return`${ue.toString().padStart(2,"0")}:${ve.toString().padStart(2,"0")}`}function He(){m.value=void 0,u.value=!0,M=0,pt(),d.value&&d.value.load()}function pt(){if(D&&(D.disconnect(),D=null),_&&(cancelAnimationFrame(_),_=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(ee)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}l.value&&(l.value.innerHTML=""),F(),g=null,E=null,T=null,N=null,w=null,v.value=!1,k=!1,x=""}function K(){g&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,de()})))}function de(){if(!g||!E||!C||!y||!c.value)return;const J=Math.round(c.value.clientWidth),ue=Math.round(c.value.clientHeight);if(J<=0||ue<=0)return;g.renderer.resize(J,ue);const ve=g.screen.width/C,Z=g.screen.height/y;let Q=1;switch(r.fitMode){case"cover":Q=Math.max(ve,Z);break;case"none":Q=1;break;case"contain":default:Q=Math.min(ve,Z);break}E.scale.set(Q),E.anchor.set(.5),E.position.set(g.screen.width/2,g.screen.height/2),E.visible=!0,E.alpha=1,g.renderer&&!g.renderer.destroyed&&g.render()}e.watch(()=>r.filters,()=>{v.value&&P()},{deep:!0}),e.watch(()=>r.active,async J=>{if(J&&!g&&d.value&&d.value.readyState>=2){await ge();return}g&&(J&&(await e.nextTick(),c.value&&c.value.getBoundingClientRect(),E&&w&&N&&T&&(d.value&&d.value.readyState>=2&&Lo(d.value,w,N.width,N.height)&&T.update(),de(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(J?g.ticker.start():g.ticker.stop()))}),e.watch($,J=>{J?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function ie(){if(d.value){m.value=void 0,te(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}m.value="Unable to start preview playback",s("error",m.value)}}e.watch(()=>r.isPlaying,J=>{d.value&&(J?ie():d.value.pause())}),e.watch(()=>r.playhead,J=>{d.value&&Math.abs(d.value.currentTime-J)>.5&&Ee(J)}),e.watch(()=>r.fitMode,()=>{de()}),e.onMounted(()=>{z=!1,e.nextTick(()=>{c.value&&c.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",K),B=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value&&ge()})}),e.onUnmounted(()=>{if(z=!0,_&&(cancelAnimationFrame(_),_=null),window.removeEventListener("resize",K),D&&(D.disconnect(),D=null),U&&clearInterval(U),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(ee)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}h.forEach(J=>{try{J.destroy()}catch{}}),h=[],E=null,T=null,N=null,w=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function he(J){if(!await _e()||!d.value||!w||!N||!T)return null;const ve=d.value,Z=Number.isFinite(f.value)&&f.value>0?f.value:Number.isFinite(ve.duration)&&ve.duration>0?ve.duration:0,Q=Math.max(0,Math.min(J,Z));return await new Promise(xe=>{let De=!1,Qe=0;const We=()=>{De||(De=!0,ve.removeEventListener("seeked",ft),window.clearTimeout(Qe),xe())},ft=()=>{We()},Ze=Number.isFinite(ve.currentTime)?ve.currentTime:0;if(Math.abs(Ze-Q)<.016){requestAnimationFrame(()=>We());return}ve.addEventListener("seeked",ft),Qe=window.setTimeout(()=>We(),700),ve.currentTime=Q}),Lo(ve,w,N.width,N.height)?(T.update(),g.render(),g.canvas):null}async function _e(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await ge()}if(!g||!E||!w||!N||!T)return!1;if(r.filters&&r.filters.length>0){const J=E.filters,ue=Array.isArray(J)?J.length:0,Z=JSON.stringify(r.filters)!==x;(ue===0||ue!==r.filters.length||Z)&&P()}return await e.nextTick(),await new Promise(J=>{requestAnimationFrame(()=>J())}),!0}return n({captureFrameAt:he,ensureReadyForCapture:_e,duration:f,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(J,ue)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:c},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:l},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:$.value,onLoadedmetadata:Me,onLoadeddata:ce,onCanplay:se,onTimeupdate:ke,onEnded:oe,onError:le,style:e.normalizeStyle(X.value),crossorigin:"anonymous",playsinline:"",controls:""},null,44,ip),e.createElementVNode("div",rp,[e.createElementVNode("button",{class:"play-button",onClick:ue[0]||(ue[0]=ve=>J.$emit("play-pause")),"aria-label":J.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:J.isPlaying?e.unref(ul):e.unref(pl)},null,8,["icon"])],8,sp),e.createElementVNode("div",lp,[e.createElementVNode("span",cp,e.toDisplayString(rt(J.playhead)),1),ue[1]||(ue[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",dp,e.toDisplayString(rt(f.value)),1)]),J.showFps?(e.openBlock(),e.createElementBlock("div",up,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",mp,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),ue[2]||(ue[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",pp,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:He},"Retry")])):e.createCommentVNode("",!0)],512))}}),ms=Be(hp,[["__scopeId","data-v-192ec332"]]);var tr=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},O=(a,n,t)=>(tr(a,n,"read from private field"),t?t.call(a):n.get(a)),Ie=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},it=(a,n,t,o)=>(tr(a,n,"write to private field"),n.set(a,t),t),vp=(a,n,t,o)=>({set _(i){it(a,n,i)},get _(){return O(a,n,o)}}),Re=(a,n,t)=>(tr(a,n,"access private method"),t),$e=new Uint8Array(8),Zt=new DataView($e.buffer),tt=a=>[(a%256+256)%256],Le=a=>(Zt.setUint16(0,a,!1),[$e[0],$e[1]]),gp=a=>(Zt.setInt16(0,a,!1),[$e[0],$e[1]]),gl=a=>(Zt.setUint32(0,a,!1),[$e[1],$e[2],$e[3]]),be=a=>(Zt.setUint32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),yp=a=>(Zt.setInt32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),kn=a=>(Zt.setUint32(0,Math.floor(a/2**32),!1),Zt.setUint32(4,a,!1),[$e[0],$e[1],$e[2],$e[3],$e[4],$e[5],$e[6],$e[7]]),nr=a=>(Zt.setInt16(0,2**8*a,!1),[$e[0],$e[1]]),Pt=a=>(Zt.setInt32(0,2**16*a,!1),[$e[0],$e[1],$e[2],$e[3]]),pi=a=>(Zt.setInt32(0,2**30*a,!1),[$e[0],$e[1],$e[2],$e[3]]),Nt=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},la=a=>a&&a[a.length-1],or=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Wt=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},yl=a=>{let n=a*(Math.PI/180),t=Math.cos(n),o=Math.sin(n);return[t,o,0,-o,t,0,0,0,1]},wl=yl(0),bl=a=>[Pt(a[0]),Pt(a[1]),pi(a[2]),Pt(a[3]),Pt(a[4]),pi(a[5]),Pt(a[6]),Pt(a[7]),pi(a[8])],co=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(co):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,co(t)])),Un=a=>a>=0&&a<2**32,qe=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),Pe=(a,n,t,o,i)=>qe(a,[tt(n),gl(t),o??[]],i),wp=a=>{let n=512;return a.fragmented?qe("ftyp",[Nt("iso5"),be(n),Nt("iso5"),Nt("iso6"),Nt("mp41")]):qe("ftyp",[Nt("isom"),be(n),Nt("isom"),a.holdsAvc?Nt("avc1"):[],Nt("mp41")])},_i=a=>({type:"mdat",largeSize:a}),bp=a=>({type:"free",size:a}),Yo=(a,n,t=!1)=>qe("moov",null,[kp(n,a),...a.map(o=>xp(o,n)),t?Qp(a):null]),kp=(a,n)=>{let t=Wt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const c=or(s.samples);return c.presentationTimestamp+c.duration})),Bi),o=Math.max(...n.map(s=>s.id))+1,i=!Un(a)||!Un(t),r=i?kn:be;return Pe("mvhd",+i,0,[r(a),r(a),be(Bi),r(t),Pt(1),nr(1),Array(10).fill(0),bl(wl),Array(24).fill(0),be(o)])},xp=(a,n)=>qe("trak",null,[Ep(a,n),Vp(a,n)]),Ep=(a,n)=>{let t=or(a.samples),o=Wt(t?t.presentationTimestamp+t.duration:0,Bi),i=!Un(n)||!Un(o),r=i?kn:be,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?yl(a.info.rotation):a.info.rotation:s=wl,Pe("tkhd",+i,3,[r(n),r(n),be(a.id),be(0),r(o),Array(8).fill(0),Le(0),Le(0),nr(a.info.type==="audio"?1:0),Le(0),bl(s),Pt(a.info.type==="video"?a.info.width:0),Pt(a.info.type==="video"?a.info.height:0)])},Vp=(a,n)=>qe("mdia",null,[Sp(a,n),Cp(a.info.type==="video"?"vide":"soun"),Np(a)]),Sp=(a,n)=>{let t=or(a.samples),o=Wt(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Un(n)||!Un(o),r=i?kn:be;return Pe("mdhd",+i,0,[r(n),r(n),be(a.timescale),r(o),Le(21956),Le(0)])},Cp=a=>Pe("hdlr",0,0,[Nt("mhlr"),Nt(a),be(0),be(0),be(0),Nt("mp4-muxer-hdlr",!0)]),Np=a=>qe("minf",null,[a.info.type==="video"?_p():Tp(),Mp(),Ip(a)]),_p=()=>Pe("vmhd",0,1,[Le(0),Le(0),Le(0),Le(0)]),Tp=()=>Pe("smhd",0,0,[Le(0),Le(0)]),Mp=()=>qe("dinf",null,[Bp()]),Bp=()=>Pe("dref",0,0,[be(1)],[Fp()]),Fp=()=>Pe("url ",0,1),Ip=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return qe("stbl",null,[Rp(a),Hp(a),Gp(a),Jp(a),Yp(a),Kp(a),n?qp(a):null])},Rp=a=>Pe("stsd",0,0,[be(1)],[a.info.type==="video"?$p(df[a.info.codec],a):Wp(mf[a.info.codec],a)]),$p=(a,n)=>qe(a,[Array(6).fill(0),Le(1),Le(0),Le(0),Array(12).fill(0),Le(n.info.width),Le(n.info.height),be(4718592),be(4718592),be(0),Le(1),Array(32).fill(0),Le(24),gp(65535)],[uf[n.info.codec](n),n.info.decoderConfig.colorSpace?Op(n):null]),Dp={bt709:1,bt470bg:5,smpte170m:6},Up={bt709:1,smpte170m:6,"iec61966-2-1":13},Ap={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Op=a=>qe("colr",[Nt("nclx"),Le(Dp[a.info.decoderConfig.colorSpace.primaries]),Le(Up[a.info.decoderConfig.colorSpace.transfer]),Le(Ap[a.info.decoderConfig.colorSpace.matrix]),tt((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Lp=a=>a.info.decoderConfig&&qe("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),zp=a=>a.info.decoderConfig&&qe("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),Pp=a=>{if(!a.info.decoderConfig)return null;let n=a.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),o=Number(t[1]),i=Number(t[2]),c=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return Pe("vpcC",1,0,[tt(o),tt(i),tt(c),tt(2),tt(2),tt(2),Le(0)])},jp=()=>{let t=(1<<7)+1;return qe("av1C",[t,0,0,0])},Wp=(a,n)=>qe(a,[Array(6).fill(0),Le(1),Le(0),Le(0),be(0),Le(n.info.numberOfChannels),Le(16),Le(0),Le(0),Pt(n.info.sampleRate)],[pf[n.info.codec](n)]),Zp=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return Pe("esds",0,0,[be(58753152),tt(32+n.byteLength),Le(1),tt(0),be(75530368),tt(18+n.byteLength),tt(64),tt(21),gl(0),be(130071),be(130071),be(92307584),tt(n.byteLength),...n,be(109084800),tt(1),tt(2)])},Xp=a=>{var i;let n=3840,t=0;const o=(i=a.info.decoderConfig)==null?void 0:i.description;if(o){if(o.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(o)?new DataView(o.buffer,o.byteOffset,o.byteLength):new DataView(o);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return qe("dOps",[tt(0),tt(a.info.numberOfChannels),Le(n),be(a.info.sampleRate),nr(t),tt(0)])},Hp=a=>Pe("stts",0,0,[be(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[be(n.sampleCount),be(n.sampleDelta)])]),Gp=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return Pe("stss",0,0,[be(n.length),n.map(([t])=>be(t+1))])},Jp=a=>Pe("stsc",0,0,[be(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[be(n.firstChunk),be(n.samplesPerChunk),be(1)])]),Yp=a=>Pe("stsz",0,0,[be(0),be(a.samples.length),a.samples.map(n=>be(n.size))]),Kp=a=>a.finalizedChunks.length>0&&la(a.finalizedChunks).offset>=2**32?Pe("co64",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>kn(n.offset))]):Pe("stco",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>be(n.offset))]),qp=a=>Pe("ctts",0,0,[be(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[be(n.sampleCount),be(n.sampleCompositionTimeOffset)])]),Qp=a=>qe("mvex",null,a.map(ef)),ef=a=>Pe("trex",0,0,[be(a.id),be(1),be(0),be(0),be(0)]),ps=(a,n)=>qe("moof",null,[tf(a),...n.map(nf)]),tf=a=>Pe("mfhd",0,0,[be(a)]),kl=a=>{let n=0,t=0,o=0,i=0,r=a.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|o<<8|i},nf=a=>qe("traf",null,[of(a),af(a),rf(a)]),of=a=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=a.currentChunk.samples[1]??a.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:kl(t)};return Pe("tfhd",0,n,[be(a.id),be(o.duration),be(o.size),be(o.flags)])},af=a=>Pe("tfdt",1,0,[kn(Wt(a.currentChunk.startTimestamp,a.timescale))]),rf=a=>{let n=a.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(g=>g.size),o=a.currentChunk.samples.map(kl),i=a.currentChunk.samples.map(g=>Wt(g.presentationTimestamp-g.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),c=new Set(o),l=new Set(i),d=c.size===2&&o[0]!==o[1],u=r.size>1,m=s.size>1,f=!d&&c.size>1,p=l.size>1||[...l].some(g=>g!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+f,v|=2048*+p,Pe("trun",1,v,[be(a.currentChunk.samples.length),be(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?be(o[0]):[],a.currentChunk.samples.map((g,E)=>[u?be(n[E]):[],m?be(t[E]):[],f?be(o[E]):[],p?yp(i[E]):[]])])},sf=a=>qe("mfra",null,[...a.map(lf),cf()]),lf=(a,n)=>Pe("tfra",1,0,[be(a.id),be(63),be(a.finalizedChunks.length),a.finalizedChunks.map(o=>[kn(Wt(o.startTimestamp,a.timescale)),kn(o.moofOffset),be(n+1),be(1),be(1)])]),cf=()=>Pe("mfro",0,0,[be(0)]),df={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},uf={avc:Lp,hevc:zp,vp9:Pp,av1:jp},mf={aac:"mp4a",opus:"Opus"},pf={aac:Zp,opus:Xp},ka=class{},ar=class extends ka{constructor(){super(...arguments),this.buffer=null}},xl=class extends ka{constructor(a){if(super(),this.options=a,typeof a!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(a.onData){if(typeof a.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(a.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(a.chunked!==void 0&&typeof a.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},ff=class extends ka{constructor(a,n){if(super(),this.stream=a,this.options=n,!(a instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(n!==void 0&&typeof n!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(n&&n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},un,Bn,El=class{constructor(){this.pos=0,Ie(this,un,new Uint8Array(8)),Ie(this,Bn,new DataView(O(this,un).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){O(this,Bn).setUint32(0,a,!1),this.write(O(this,un).subarray(0,4))}writeU64(a){O(this,Bn).setUint32(0,Math.floor(a/2**32),!1),O(this,Bn).setUint32(4,a,!1),this.write(O(this,un).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)O(this,Bn).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(O(this,un));a.length%8!==0&&this.write(O(this,un).subarray(0,a.length%8))}writeBox(a){if(this.offsets.set(a,this.pos),a.contents&&!a.children)this.writeBoxHeader(a,a.size??a.contents.byteLength+8),this.write(a.contents);else{let n=this.pos;if(this.writeBoxHeader(a,0),a.contents&&this.write(a.contents),a.children)for(let i of a.children)i&&this.writeBox(i);let t=this.pos,o=a.size??t-n;this.seek(n),this.writeBoxHeader(a,o),this.seek(t)}}writeBoxHeader(a,n){this.writeU32(a.largeSize?1:n),this.writeAscii(a.type),a.largeSize&&this.writeU64(n)}measureBoxHeader(a){return 8+(a.largeSize?8:0)}patchBox(a){let n=this.pos;this.seek(this.offsets.get(a)),this.writeBox(a),this.seek(n)}measureBox(a){if(a.contents&&!a.children)return this.measureBoxHeader(a)+a.contents.byteLength;{let n=this.measureBoxHeader(a);if(a.contents&&(n+=a.contents.byteLength),a.children)for(let t of a.children)t&&(n+=this.measureBox(t));return n}}};un=new WeakMap;Bn=new WeakMap;var Ko,wn,go,io,qo,Ti,hf=class extends El{constructor(a){super(),Ie(this,qo),Ie(this,Ko,void 0),Ie(this,wn,new ArrayBuffer(2**16)),Ie(this,go,new Uint8Array(O(this,wn))),Ie(this,io,0),it(this,Ko,a)}write(a){Re(this,qo,Ti).call(this,this.pos+a.byteLength),O(this,go).set(a,this.pos),this.pos+=a.byteLength,it(this,io,Math.max(O(this,io),this.pos))}finalize(){Re(this,qo,Ti).call(this,this.pos),O(this,Ko).buffer=O(this,wn).slice(0,Math.max(O(this,io),this.pos))}};Ko=new WeakMap;wn=new WeakMap;go=new WeakMap;io=new WeakMap;qo=new WeakSet;Ti=function(a){let n=O(this,wn).byteLength;for(;n<a;)n*=2;if(n===O(this,wn).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(O(this,go),0),it(this,wn,t),it(this,go,o)};var vf=2**24,gf=2,uo,mn,ro,qt,St,ca,Mi,ir,Vl,rr,Sl,mo,da,sr=class extends El{constructor(a){var n,t;super(),Ie(this,ca),Ie(this,ir),Ie(this,rr),Ie(this,mo),Ie(this,uo,void 0),Ie(this,mn,[]),Ie(this,ro,void 0),Ie(this,qt,void 0),Ie(this,St,[]),it(this,uo,a),it(this,ro,((n=a.options)==null?void 0:n.chunked)??!1),it(this,qt,((t=a.options)==null?void 0:t.chunkSize)??vf)}write(a){O(this,mn).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(O(this,mn).length===0)return;let a=[],n=[...O(this,mn)].sort((i,r)=>i.start-r.start);a.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=a[a.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):a.push({start:s.start,size:s.data.byteLength})}for(let i of a){i.data=new Uint8Array(i.size);for(let r of O(this,mn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);O(this,ro)?(Re(this,ca,Mi).call(this,i.data,i.start),Re(this,mo,da).call(this)):(o=(t=O(this,uo).options).onData)==null||o.call(t,i.data,i.start)}O(this,mn).length=0}finalize(){O(this,ro)&&Re(this,mo,da).call(this,!0)}};uo=new WeakMap;mn=new WeakMap;ro=new WeakMap;qt=new WeakMap;St=new WeakMap;ca=new WeakSet;Mi=function(a,n){let t=O(this,St).findIndex(c=>c.start<=n&&n<c.start+O(this,qt));t===-1&&(t=Re(this,rr,Sl).call(this,n));let o=O(this,St)[t],i=n-o.start,r=a.subarray(0,Math.min(O(this,qt)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Re(this,ir,Vl).call(this,o,s),o.written[0].start===0&&o.written[0].end===O(this,qt)&&(o.shouldFlush=!0),O(this,St).length>gf){for(let c=0;c<O(this,St).length-1;c++)O(this,St)[c].shouldFlush=!0;Re(this,mo,da).call(this)}r.byteLength<a.byteLength&&Re(this,ca,Mi).call(this,a.subarray(r.byteLength),n+r.byteLength)};ir=new WeakSet;Vl=function(a,n){let t=0,o=a.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);a.written[r].start<=n.start?(t=r+1,i=r):o=r-1}for(a.written.splice(i+1,0,n),(i===-1||a.written[i].end<n.start)&&i++;i<a.written.length-1&&a.written[i].end>=a.written[i+1].start;)a.written[i].end=Math.max(a.written[i].end,a.written[i+1].end),a.written.splice(i+1,1)};rr=new WeakSet;Sl=function(a){let t={start:Math.floor(a/O(this,qt))*O(this,qt),data:new Uint8Array(O(this,qt)),written:[],shouldFlush:!1};return O(this,St).push(t),O(this,St).sort((o,i)=>o.start-i.start),O(this,St).indexOf(t)};mo=new WeakSet;da=function(a=!1){var n,t;for(let o=0;o<O(this,St).length;o++){let i=O(this,St)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=O(this,uo).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);O(this,St).splice(o--,1)}}};var yf=class extends sr{constructor(a){var n;super(new xl({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},Bi=1e3,wf=["avc","hevc","vp9","av1"],bf=["aac","opus"],kf=2082844800,xf=["strict","offset","cross-track-offset"],Ce,Te,ua,Et,lt,at,Fn,In,lr,pn,fn,po,Fi,Cl,Ii,Nl,cr,_l,Ri,Tl,dr,Ml,Qo,$i,zt,Kt,ur,Bl,fo,ma,pa,mr,An,bo,ea,Di,Fl=class{constructor(a){if(Ie(this,Fi),Ie(this,Ii),Ie(this,cr),Ie(this,Ri),Ie(this,dr),Ie(this,Qo),Ie(this,zt),Ie(this,ur),Ie(this,fo),Ie(this,pa),Ie(this,An),Ie(this,ea),Ie(this,Ce,void 0),Ie(this,Te,void 0),Ie(this,ua,void 0),Ie(this,Et,void 0),Ie(this,lt,null),Ie(this,at,null),Ie(this,Fn,Math.floor(Date.now()/1e3)+kf),Ie(this,In,[]),Ie(this,lr,1),Ie(this,pn,[]),Ie(this,fn,[]),Ie(this,po,!1),Re(this,Fi,Cl).call(this,a),a.video=co(a.video),a.audio=co(a.audio),a.fastStart=co(a.fastStart),this.target=a.target,it(this,Ce,{firstTimestampBehavior:"strict",...a}),a.target instanceof ar)it(this,Te,new hf(a.target));else if(a.target instanceof xl)it(this,Te,new sr(a.target));else if(a.target instanceof ff)it(this,Te,new yf(a.target));else throw new Error(`Invalid target: ${a.target}`);Re(this,Ri,Tl).call(this),Re(this,Ii,Nl).call(this)}addVideoChunk(a,n,t,o){if(!(a instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(n&&typeof n!="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(o!==void 0&&!Number.isFinite(o))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(a.byteLength);a.copyTo(i),this.addVideoChunkRaw(i,a.type,t??a.timestamp,a.duration,n,o)}addVideoChunkRaw(a,n,t,o,i,r){if(!(a instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(r!==void 0&&!Number.isFinite(r))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Re(this,ea,Di).call(this),!O(this,Ce).video)throw new Error("No video track declared.");if(typeof O(this,Ce).fastStart=="object"&&O(this,lt).samples.length===O(this,Ce).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${O(this,Ce).fastStart.expectedVideoChunks}).`);let s=Re(this,Qo,$i).call(this,O(this,lt),a,n,t,o,i,r);if(O(this,Ce).fastStart==="fragmented"&&O(this,at)){for(;O(this,fn).length>0&&O(this,fn)[0].decodeTimestamp<=s.decodeTimestamp;){let c=O(this,fn).shift();Re(this,zt,Kt).call(this,O(this,at),c)}s.decodeTimestamp<=O(this,at).lastDecodeTimestamp?Re(this,zt,Kt).call(this,O(this,lt),s):O(this,pn).push(s)}else Re(this,zt,Kt).call(this,O(this,lt),s)}addAudioChunk(a,n,t){if(!(a instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(n&&typeof n!="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 o=new Uint8Array(a.byteLength);a.copyTo(o),this.addAudioChunkRaw(o,a.type,t??a.timestamp,a.duration,n)}addAudioChunkRaw(a,n,t,o,i){if(!(a instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Re(this,ea,Di).call(this),!O(this,Ce).audio)throw new Error("No audio track declared.");if(typeof O(this,Ce).fastStart=="object"&&O(this,at).samples.length===O(this,Ce).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${O(this,Ce).fastStart.expectedAudioChunks}).`);let r=Re(this,Qo,$i).call(this,O(this,at),a,n,t,o,i);if(O(this,Ce).fastStart==="fragmented"&&O(this,lt)){for(;O(this,pn).length>0&&O(this,pn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=O(this,pn).shift();Re(this,zt,Kt).call(this,O(this,lt),s)}r.decodeTimestamp<=O(this,lt).lastDecodeTimestamp?Re(this,zt,Kt).call(this,O(this,at),r):O(this,fn).push(r)}else Re(this,zt,Kt).call(this,O(this,at),r)}finalize(){if(O(this,po))throw new Error("Cannot finalize a muxer more than once.");if(O(this,Ce).fastStart==="fragmented"){for(let n of O(this,pn))Re(this,zt,Kt).call(this,O(this,lt),n);for(let n of O(this,fn))Re(this,zt,Kt).call(this,O(this,at),n);Re(this,pa,mr).call(this,!1)}else O(this,lt)&&Re(this,fo,ma).call(this,O(this,lt)),O(this,at)&&Re(this,fo,ma).call(this,O(this,at));let a=[O(this,lt),O(this,at)].filter(Boolean);if(O(this,Ce).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=Yo(a,O(this,Fn)),r=O(this,Te).measureBox(i);n=O(this,Te).measureBox(O(this,Et));let s=O(this,Te).pos+r+n;for(let c of O(this,In)){c.offset=s;for(let{data:l}of c.samples)s+=l.byteLength,n+=l.byteLength}if(s<2**32)break;n>=2**32&&(O(this,Et).largeSize=!0)}let t=Yo(a,O(this,Fn));O(this,Te).writeBox(t),O(this,Et).size=n,O(this,Te).writeBox(O(this,Et));for(let o of O(this,In))for(let i of o.samples)O(this,Te).write(i.data),i.data=null}else if(O(this,Ce).fastStart==="fragmented"){let n=O(this,Te).pos,t=sf(a);O(this,Te).writeBox(t);let o=O(this,Te).pos-n;O(this,Te).seek(O(this,Te).pos-4),O(this,Te).writeU32(o)}else{let n=O(this,Te).offsets.get(O(this,Et)),t=O(this,Te).pos-n;O(this,Et).size=t,O(this,Et).largeSize=t>=2**32,O(this,Te).patchBox(O(this,Et));let o=Yo(a,O(this,Fn));if(typeof O(this,Ce).fastStart=="object"){O(this,Te).seek(O(this,ua)),O(this,Te).writeBox(o);let i=n-O(this,Te).pos;O(this,Te).writeBox(bp(i))}else O(this,Te).writeBox(o)}Re(this,An,bo).call(this),O(this,Te).finalize(),it(this,po,!0)}};Ce=new WeakMap;Te=new WeakMap;ua=new WeakMap;Et=new WeakMap;lt=new WeakMap;at=new WeakMap;Fn=new WeakMap;In=new WeakMap;lr=new WeakMap;pn=new WeakMap;fn=new WeakMap;po=new WeakMap;Fi=new WeakSet;Cl=function(a){if(typeof a!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(a.target instanceof ka))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!wf.includes(a.video.codec))throw new TypeError(`Unsupported video codec: ${a.video.codec}`);if(!Number.isInteger(a.video.width)||a.video.width<=0)throw new TypeError(`Invalid video width: ${a.video.width}. Must be a positive integer.`);if(!Number.isInteger(a.video.height)||a.video.height<=0)throw new TypeError(`Invalid video height: ${a.video.height}. Must be a positive integer.`);const n=a.video.rotation;if(typeof n=="number"&&![0,90,180,270].includes(n))throw new TypeError(`Invalid video rotation: ${n}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(n)&&(n.length!==9||n.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${n.join()}`);if(a.video.frameRate!==void 0&&(!Number.isInteger(a.video.frameRate)||a.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${a.video.frameRate}. Must be a positive integer.`)}if(a.audio){if(!bf.includes(a.audio.codec))throw new TypeError(`Unsupported audio codec: ${a.audio.codec}`);if(!Number.isInteger(a.audio.numberOfChannels)||a.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${a.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(a.audio.sampleRate)||a.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${a.audio.sampleRate}. Must be a positive integer.`)}if(a.firstTimestampBehavior&&!xf.includes(a.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${a.firstTimestampBehavior}`);if(typeof a.fastStart=="object"){if(a.video){if(a.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(a.fastStart.expectedVideoChunks)||a.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(a.audio){if(a.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(a.fastStart.expectedAudioChunks)||a.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(a.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(a.minFragmentDuration!==void 0&&(!Number.isFinite(a.minFragmentDuration)||a.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Ii=new WeakSet;Nl=function(){var a;if(O(this,Te).writeBox(wp({holdsAvc:((a=O(this,Ce).video)==null?void 0:a.codec)==="avc",fragmented:O(this,Ce).fastStart==="fragmented"})),it(this,ua,O(this,Te).pos),O(this,Ce).fastStart==="in-memory")it(this,Et,_i(!1));else if(O(this,Ce).fastStart!=="fragmented"){if(typeof O(this,Ce).fastStart=="object"){let n=Re(this,cr,_l).call(this);O(this,Te).seek(O(this,Te).pos+n)}it(this,Et,_i(!0)),O(this,Te).writeBox(O(this,Et))}Re(this,An,bo).call(this)};cr=new WeakSet;_l=function(){if(typeof O(this,Ce).fastStart!="object")return;let a=0,n=[O(this,Ce).fastStart.expectedVideoChunks,O(this,Ce).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};Ri=new WeakSet;Tl=function(){if(O(this,Ce).video&&it(this,lt,{id:1,info:{type:"video",codec:O(this,Ce).video.codec,width:O(this,Ce).video.width,height:O(this,Ce).video.height,rotation:O(this,Ce).video.rotation??0,decoderConfig:null},timescale:O(this,Ce).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),O(this,Ce).audio&&(it(this,at,{id:O(this,Ce).video?2:1,info:{type:"audio",codec:O(this,Ce).audio.codec,numberOfChannels:O(this,Ce).audio.numberOfChannels,sampleRate:O(this,Ce).audio.sampleRate,decoderConfig:null},timescale:O(this,Ce).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),O(this,Ce).audio.codec==="aac")){let a=Re(this,dr,Ml).call(this,2,O(this,Ce).audio.sampleRate,O(this,Ce).audio.numberOfChannels);O(this,at).info.decoderConfig={codec:O(this,Ce).audio.codec,description:a,numberOfChannels:O(this,Ce).audio.numberOfChannels,sampleRate:O(this,Ce).audio.sampleRate}}};dr=new WeakSet;Ml=function(a,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=a.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=n.toString(2).padStart(24,"0")),s+=r.toString(2).padStart(4,"0");let c=Math.ceil(s.length/8)*8;s=s.padEnd(c,"0");let l=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)l[d/8]=parseInt(s.slice(d,d+8),2);return l};Qo=new WeakSet;$i=function(a,n,t,o,i,r,s){let c=o/1e6,l=(o-(s??0))/1e6,d=i/1e6,u=Re(this,ur,Bl).call(this,c,l,a);return c=u.presentationTimestamp,l=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:c,decodeTimestamp:l,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:Wt(d,a.timescale)}};zt=new WeakSet;Kt=function(a,n){O(this,Ce).fastStart!=="fragmented"&&a.samples.push(n);const t=Wt(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=Wt(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,O(this,Ce).fastStart!=="fragmented"){let s=la(a.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,a.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const c=la(a.compositionTimeOffsetTable);c.sampleCompositionTimeOffset===t?c.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,O(this,Ce).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:Wt(n.duration,a.timescale)}),a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));a.lastSample=n;let o=!1;if(!a.currentChunk)o=!0;else{let i=n.presentationTimestamp-a.currentChunk.startTimestamp;if(O(this,Ce).fastStart==="fragmented"){let r=O(this,lt)??O(this,at);const s=O(this,Ce).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,Re(this,pa,mr).call(this))}else o=i>=.5}o&&(a.currentChunk&&Re(this,fo,ma).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};ur=new WeakSet;Bl=function(a,n,t){var s,c;const o=O(this,Ce).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).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
19
 
20
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(O(this,Ce).firstTimestampBehavior==="offset"||O(this,Ce).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let l;O(this,Ce).firstTimestampBehavior==="offset"?l=t.firstDecodeTimestamp:l=Math.min(((s=O(this,lt))==null?void 0:s.firstDecodeTimestamp)??1/0,((c=O(this,at))==null?void 0:c.firstDecodeTimestamp)??1/0),n-=l,a-=l}if(n<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${n*1e6}).`);return t.lastDecodeTimestamp=n,{presentationTimestamp:a,decodeTimestamp:n}};po=new WeakSet;ua=function(a){if(O(this,Ce).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),O(this,Fn).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||sa(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),O(this,Ce).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=O(this,Te).pos;for(let n of a.currentChunk.samples)O(this,Te).write(n.data),n.data=null;Re(this,Un,wo).call(this)}};ma=new WeakSet;lr=function(a=!0){if(O(this,Ce).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[O(this,lt),O(this,at)].filter(c=>c&&c.currentChunk);if(n.length===0)return;let t=mp(this,ar)._++;if(t===1){let c=Jo(n,O(this,Bn),!0);O(this,Te).writeBox(c)}let o=O(this,Te).pos,i=cs(t,n);O(this,Te).writeBox(i);{let c=Vi(!1),l=0;for(let u of n)for(let m of u.currentChunk.samples)l+=m.size;let d=O(this,Te).measureBox(c)+l;d>=2**32&&(c.largeSize=!0,d=O(this,Te).measureBox(c)+l),c.size=d,O(this,Te).writeBox(c)}for(let c of n){c.currentChunk.offset=O(this,Te).pos,c.currentChunk.moofOffset=o;for(let l of c.currentChunk.samples)O(this,Te).write(l.data),l.data=null}let r=O(this,Te).pos;O(this,Te).seek(O(this,Te).offsets.get(i));let s=cs(t,n);O(this,Te).writeBox(s),O(this,Te).seek(r);for(let c of n)c.finalizedChunks.push(c.currentChunk),O(this,Fn).push(c.currentChunk),c.currentChunk=null;a&&Re(this,Un,wo).call(this)};Un=new WeakSet;wo=function(){O(this,Te)instanceof or&&O(this,Te).flush()};Qo=new WeakSet;Fi=function(){if(O(this,mo))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const go=30;class An extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);L(this,"message");L(this,"code");this.code=o,this.message=t}}class qt extends An{}class Ke extends An{}class pa extends An{}class ds extends An{}function wf(a,n=go){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function In(a,n=go){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class we{constructor(n=0){L(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return wf(this.millis/1e3)}set frames(n){this.millis=In(n)}get seconds(){return this.millis/1e3}set seconds(n){this.millis=n*1e3}addMillis(n){return this.millis=this.millis+n,this}addFrames(n){const t=In(n);return this.millis=this.millis+t,this}add(n){return new we(n.millis+this.millis)}subtract(n){return new we(this.millis-n.millis)}static fromSeconds(n){const t=new we;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new we;return o.millis=In(n,t),o}copy(){return new we(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new we(n)}}function us(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function ea(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function bf(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function ms(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function kf(a){const n=a.numberOfChannels,t=a.length,o=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=a.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*n+r]=s}return o}function xf(a,n=44100,t=2){if(a.sampleRate==n&&a.numberOfChannels==t)return a;const o=Math.floor(a.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,o,n);for(let r=0;r<a.numberOfChannels;r++){const s=a.getChannelData(r),c=i.getChannelData(r),l=a.sampleRate/n;for(let d=0;d<c.length;d++){const u=d*l,m=Math.floor(u),f=Math.ceil(u);if(f>=s.length)c[d]=s[m];else{const p=u-m;c[d]=s[m]*(1-p)+s[f]*p}}}return i}async function Ef(a){const{fps:n,height:t,width:o,bitrate:i}=a,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],c=[];for(const d of r)for(const u of s)c.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const l=[];if(!("VideoEncoder"in window))return l;for(const d of c){const u=await VideoEncoder.isConfigSupported(d);u.supported&&l.push(u.config??d)}return l.sort(Vf)}function Vf(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function Sf(a,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof a=="string"&&a.startsWith("data:image/svg+xml;base64,")){const o=a.split(",")[1],i=atob(o),r=new Array(i.length);for(let l=0;l<i.length;l++)r[l]=i.charCodeAt(l);const s=new Uint8Array(r),c=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(c),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function ps(a){return`${a.hours.toString().padStart(2,"0")}:${a.minutes.toString().padStart(2,"0")}:${a.seconds.toString().padStart(2,"0")},`+a.milliseconds.toString().padStart(3,"0")}function fs(a){const n=new Date(1970,0,1);return n.setSeconds(a),n.setMilliseconds(Math.round(a%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class Lo{constructor(n){L(this,"words",[]);n&&(this.words=n)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:n})=>n).join(" ")}get start(){var n;return((n=this.words.at(0))==null?void 0:n.start)??new we}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new we}}var Ii=(a=>(a.en="en",a.de="de",a))(Ii||{});class hs{constructor(n,t,o,i){L(this,"id",crypto.randomUUID());L(this,"text");L(this,"start");L(this,"stop");L(this,"confidence");this.text=n,this.start=new we(t),this.stop=new we(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class hn{constructor(n=[],t=Ii.en){L(this,"id",crypto.randomUUID());L(this,"language",Ii.en);L(this,"groups",[]);this.groups=n,this.language=t}get text(){return this.groups.map(({text:n})=>n).join(" ")}get words(){return this.groups.flatMap(({words:n})=>n)}*iter({count:n,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,c]of i.words.entries())r&&(n&&r.words.length>=ea(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=ea(...t)?(yield r,r=void 0):o&&r.text.length>=ea(...o)&&(yield r,r=void 0)),r?r.words.push(c):r=new Lo([c]),s==i.words.length-1&&(yield r)}}optimize(){const n=this.groups.flatMap(t=>t.words);for(let t=0;t<n.length-1;t++){const o=n[t],i=n[t+1];i.start.millis-o.stop.millis<0?i.start.millis=o.stop.millis+1:o.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,o="";for(const i of this.iter(n)){const r=fs(i.start.seconds),s=fs(i.stop.seconds);o+=`${t}
22
- `+ps(r)+" --> "+ps(s)+`
21
+ `);if(O(this,Ce).firstTimestampBehavior==="offset"||O(this,Ce).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let l;O(this,Ce).firstTimestampBehavior==="offset"?l=t.firstDecodeTimestamp:l=Math.min(((s=O(this,lt))==null?void 0:s.firstDecodeTimestamp)??1/0,((c=O(this,at))==null?void 0:c.firstDecodeTimestamp)??1/0),n-=l,a-=l}if(n<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${n*1e6}).`);return t.lastDecodeTimestamp=n,{presentationTimestamp:a,decodeTimestamp:n}};fo=new WeakSet;ma=function(a){if(O(this,Ce).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),O(this,In).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||la(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),O(this,Ce).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=O(this,Te).pos;for(let n of a.currentChunk.samples)O(this,Te).write(n.data),n.data=null;Re(this,An,bo).call(this)}};pa=new WeakSet;mr=function(a=!0){if(O(this,Ce).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[O(this,lt),O(this,at)].filter(c=>c&&c.currentChunk);if(n.length===0)return;let t=vp(this,lr)._++;if(t===1){let c=Yo(n,O(this,Fn),!0);O(this,Te).writeBox(c)}let o=O(this,Te).pos,i=ps(t,n);O(this,Te).writeBox(i);{let c=_i(!1),l=0;for(let u of n)for(let m of u.currentChunk.samples)l+=m.size;let d=O(this,Te).measureBox(c)+l;d>=2**32&&(c.largeSize=!0,d=O(this,Te).measureBox(c)+l),c.size=d,O(this,Te).writeBox(c)}for(let c of n){c.currentChunk.offset=O(this,Te).pos,c.currentChunk.moofOffset=o;for(let l of c.currentChunk.samples)O(this,Te).write(l.data),l.data=null}let r=O(this,Te).pos;O(this,Te).seek(O(this,Te).offsets.get(i));let s=ps(t,n);O(this,Te).writeBox(s),O(this,Te).seek(r);for(let c of n)c.finalizedChunks.push(c.currentChunk),O(this,In).push(c.currentChunk),c.currentChunk=null;a&&Re(this,An,bo).call(this)};An=new WeakSet;bo=function(){O(this,Te)instanceof sr&&O(this,Te).flush()};ea=new WeakSet;Di=function(){if(O(this,po))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const yo=30;class On extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);L(this,"message");L(this,"code");this.code=o,this.message=t}}class Qt extends On{}class Ke extends On{}class fa extends On{}class fs extends On{}function Ef(a,n=yo){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function Rn(a,n=yo){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class we{constructor(n=0){L(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return Ef(this.millis/1e3)}set frames(n){this.millis=Rn(n)}get seconds(){return this.millis/1e3}set seconds(n){this.millis=n*1e3}addMillis(n){return this.millis=this.millis+n,this}addFrames(n){const t=Rn(n);return this.millis=this.millis+t,this}add(n){return new we(n.millis+this.millis)}subtract(n){return new we(this.millis-n.millis)}static fromSeconds(n){const t=new we;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new we;return o.millis=Rn(n,t),o}copy(){return new we(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new we(n)}}function hs(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function ta(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function Vf(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function vs(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function Sf(a){const n=a.numberOfChannels,t=a.length,o=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=a.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*n+r]=s}return o}function Cf(a,n=44100,t=2){if(a.sampleRate==n&&a.numberOfChannels==t)return a;const o=Math.floor(a.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,o,n);for(let r=0;r<a.numberOfChannels;r++){const s=a.getChannelData(r),c=i.getChannelData(r),l=a.sampleRate/n;for(let d=0;d<c.length;d++){const u=d*l,m=Math.floor(u),f=Math.ceil(u);if(f>=s.length)c[d]=s[m];else{const p=u-m;c[d]=s[m]*(1-p)+s[f]*p}}}return i}async function Nf(a){const{fps:n,height:t,width:o,bitrate:i}=a,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],c=[];for(const d of r)for(const u of s)c.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const l=[];if(!("VideoEncoder"in window))return l;for(const d of c){const u=await VideoEncoder.isConfigSupported(d);u.supported&&l.push(u.config??d)}return l.sort(_f)}function _f(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function Tf(a,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof a=="string"&&a.startsWith("data:image/svg+xml;base64,")){const o=a.split(",")[1],i=atob(o),r=new Array(i.length);for(let l=0;l<i.length;l++)r[l]=i.charCodeAt(l);const s=new Uint8Array(r),c=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(c),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function gs(a){return`${a.hours.toString().padStart(2,"0")}:${a.minutes.toString().padStart(2,"0")}:${a.seconds.toString().padStart(2,"0")},`+a.milliseconds.toString().padStart(3,"0")}function ys(a){const n=new Date(1970,0,1);return n.setSeconds(a),n.setMilliseconds(Math.round(a%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class zo{constructor(n){L(this,"words",[]);n&&(this.words=n)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:n})=>n).join(" ")}get start(){var n;return((n=this.words.at(0))==null?void 0:n.start)??new we}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new we}}var Ui=(a=>(a.en="en",a.de="de",a))(Ui||{});class ws{constructor(n,t,o,i){L(this,"id",crypto.randomUUID());L(this,"text");L(this,"start");L(this,"stop");L(this,"confidence");this.text=n,this.start=new we(t),this.stop=new we(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class vn{constructor(n=[],t=Ui.en){L(this,"id",crypto.randomUUID());L(this,"language",Ui.en);L(this,"groups",[]);this.groups=n,this.language=t}get text(){return this.groups.map(({text:n})=>n).join(" ")}get words(){return this.groups.flatMap(({words:n})=>n)}*iter({count:n,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,c]of i.words.entries())r&&(n&&r.words.length>=ta(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=ta(...t)?(yield r,r=void 0):o&&r.text.length>=ta(...o)&&(yield r,r=void 0)),r?r.words.push(c):r=new zo([c]),s==i.words.length-1&&(yield r)}}optimize(){const n=this.groups.flatMap(t=>t.words);for(let t=0;t<n.length-1;t++){const o=n[t],i=n[t+1];i.start.millis-o.stop.millis<0?i.start.millis=o.stop.millis+1:o.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,o="";for(const i of this.iter(n)){const r=ys(i.start.seconds),s=ys(i.stop.seconds);o+=`${t}
22
+ `+gs(r)+" --> "+gs(s)+`
23
23
  ${i.text}
24
24
 
25
- `,t+=1}return{text:o,blob:new Blob([o],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(n=>n.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(n,t=!0){let o=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(o=s.start.millis),i.push(new hs(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new hn([new Lo(i)]);return new hn([new Lo(i)])}copy(){return hn.fromJSON(this.toJSON())}static fromJSON(n){const t=new hn;for(const o of n){const i=new Lo;for(const r of o)i.words.push(new hs(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const o=await fetch(n,t);if(!o.ok)throw new qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return hn.fromJSON(await o.json())}}function ta(a,n,t){return a+(n-a)*t}function Cf(a,n,t){const o=Number.parseInt(a.slice(1),16),i=Number.parseInt(n.slice(1),16),r=o>>16&255,s=o>>8&255,c=o&255,l=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(ta(r,l,t)),f=Math.round(ta(s,d,t)),p=Math.round(ta(c,u,t));return`#${((1<<24)+(m<<16)+(f<<8)+p).toString(16).slice(1)}`}const Nf={linear:a=>a,easeIn:a=>a*a,easeOut:a=>a*(2-a),easeInOut:a=>a<.5?2*a*a:-1+(4-2*a)*a};class Ve{constructor(n,t,o={}){L(this,"input");L(this,"output");L(this,"options");if(n.length!==t.length)throw new Ke({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>In(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(n){const{input:t}=this;if(n<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(n-t[0])/(t[1]-t[0]),segment:0};if(n>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(n-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(n,t){const o=this.output[t],i=this.output[t+1],r=Nf[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return ta(o,i,r);if(typeof o=="string"&&typeof i=="string")return Cf(o,i,r);if(this.output.length==1)return this.output[0];throw new Ke({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:o}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,o)}push(n,t){return this.input.push(In(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ve([],[]);return Object.assign(t,n),t}}class _t{constructor(){L(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(n.hasOwnProperty(o))if(i){const r=i.fromJSON(n[o]);t[o]=r}else t[o]=n[o]}),t}}function ye(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function bo(a){return class extends a{constructor(){super(...arguments);L(this,"_handlers",{})}on(t,o){if(typeof o!="function")throw new Error("The callback of an event listener needs to be a function.");const i=crypto.randomUUID();return this._handlers[t]?this._handlers[t][i]=o:this._handlers[t]={[i]:o},i}off(t,...o){if(t){if(t==="*"){this._handlers={};return}for(const i of Object.values(this._handlers))t in i&&delete i[t];for(const i of o)this.off(i)}}trigger(t,o){var r,s;const i=new CustomEvent(t,{detail:o});Object.defineProperty(i,"currentTarget",{writable:!1,value:this});for(const c in this._handlers[t]??{})(r=this._handlers[t])==null||r[c](i);for(const c in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[c](i)}bubble(t){return this.on("*",o=>{t.trigger(o.type,o.detail)})}resolve(t){return(o,i)=>{this.on("error",i),this.on(t,o)}}}}function cr(a,n,t=0){if(!(a instanceof ze.Container||a instanceof ze.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Ve&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&cr(i,n,t+1))}}var _f=Object.defineProperty,ka=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&_f(n,t,i),i};const ko=class Tl extends bo(_t){constructor(t={}){super();L(this,"_name");L(this,"_start",new we);L(this,"_stop",we.fromSeconds(16));L(this,"type","base");L(this,"source");L(this,"view",new ze.Container);L(this,"createdAt",new Date);L(this,"disabled",!1);L(this,"state","IDLE");L(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",we.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 r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=we.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ke({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),cr(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(c=>c.id==this.id);return await this.track.add(o,i+1),o}copy(){return Tl.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};ka([ye()],ko.prototype,"_name");ka([ye(we)],ko.prototype,"_start");ka([ye(we)],ko.prototype,"_stop");ka([ye()],ko.prototype,"disabled");let xo=ko;var Tf=Object.defineProperty,xn=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Tf(n,t,i),i};class Zt extends bo(_t){constructor(){super(...arguments);L(this,"state","IDLE");L(this,"metadata");L(this,"objectURL");L(this,"duration",we.fromSeconds(16));L(this,"added",!1);L(this,"type","base");L(this,"name","");L(this,"mimeType");L(this,"externalURL");L(this,"external",!1);L(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 Ke({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Ui(t.type),this.external=!1,this.file=t}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});const r=await i.blob();this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.file=new File([r],this.name,{type:r.type}),this.externalURL=t,this.mimeType=Ui(r.type)}async from(t,o){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,o),this.state="READY",this.trigger("load",void 0)}catch(i){throw this.state=="ERROR",this.trigger("error",new Error(String(i))),i}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();Sf(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}xn([ye()],Zt.prototype,"objectURL");xn([ye()],Zt.prototype,"duration");xn([ye()],Zt.prototype,"type");xn([ye()],Zt.prototype,"name");xn([ye()],Zt.prototype,"mimeType");xn([ye()],Zt.prototype,"externalURL");xn([ye()],Zt.prototype,"external");const vs="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Mf(a){const n=new TextEncoder().encode(a);let t="";const o=n.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function gs(a){if(!a||!a.body)return vs;const n=a.body.scrollWidth,t=a.body.scrollHeight,o=a.cloneNode(!0),i=o.getElementsByTagName("style").item(0),r=o.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return vs;const s=new XMLSerializer,c=i?s.serializeToString(i):"",l=s.serializeToString(r),d=`
25
+ `,t+=1}return{text:o,blob:new Blob([o],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(n=>n.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(n,t=!0){let o=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(o=s.start.millis),i.push(new ws(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new vn([new zo(i)]);return new vn([new zo(i)])}copy(){return vn.fromJSON(this.toJSON())}static fromJSON(n){const t=new vn;for(const o of n){const i=new zo;for(const r of o)i.words.push(new ws(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const o=await fetch(n,t);if(!o.ok)throw new Qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return vn.fromJSON(await o.json())}}function na(a,n,t){return a+(n-a)*t}function Mf(a,n,t){const o=Number.parseInt(a.slice(1),16),i=Number.parseInt(n.slice(1),16),r=o>>16&255,s=o>>8&255,c=o&255,l=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(na(r,l,t)),f=Math.round(na(s,d,t)),p=Math.round(na(c,u,t));return`#${((1<<24)+(m<<16)+(f<<8)+p).toString(16).slice(1)}`}const Bf={linear:a=>a,easeIn:a=>a*a,easeOut:a=>a*(2-a),easeInOut:a=>a<.5?2*a*a:-1+(4-2*a)*a};class Ve{constructor(n,t,o={}){L(this,"input");L(this,"output");L(this,"options");if(n.length!==t.length)throw new Ke({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>Rn(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(n){const{input:t}=this;if(n<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(n-t[0])/(t[1]-t[0]),segment:0};if(n>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(n-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(n,t){const o=this.output[t],i=this.output[t+1],r=Bf[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return na(o,i,r);if(typeof o=="string"&&typeof i=="string")return Mf(o,i,r);if(this.output.length==1)return this.output[0];throw new Ke({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:o}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,o)}push(n,t){return this.input.push(Rn(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ve([],[]);return Object.assign(t,n),t}}class _t{constructor(){L(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(n.hasOwnProperty(o))if(i){const r=i.fromJSON(n[o]);t[o]=r}else t[o]=n[o]}),t}}function ye(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function ko(a){return class extends a{constructor(){super(...arguments);L(this,"_handlers",{})}on(t,o){if(typeof o!="function")throw new Error("The callback of an event listener needs to be a function.");const i=crypto.randomUUID();return this._handlers[t]?this._handlers[t][i]=o:this._handlers[t]={[i]:o},i}off(t,...o){if(t){if(t==="*"){this._handlers={};return}for(const i of Object.values(this._handlers))t in i&&delete i[t];for(const i of o)this.off(i)}}trigger(t,o){var r,s;const i=new CustomEvent(t,{detail:o});Object.defineProperty(i,"currentTarget",{writable:!1,value:this});for(const c in this._handlers[t]??{})(r=this._handlers[t])==null||r[c](i);for(const c in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[c](i)}bubble(t){return this.on("*",o=>{t.trigger(o.type,o.detail)})}resolve(t){return(o,i)=>{this.on("error",i),this.on(t,o)}}}}function pr(a,n,t=0){if(!(a instanceof ze.Container||a instanceof ze.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Ve&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&pr(i,n,t+1))}}var Ff=Object.defineProperty,xa=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ff(n,t,i),i};const xo=class Il extends ko(_t){constructor(t={}){super();L(this,"_name");L(this,"_start",new we);L(this,"_stop",we.fromSeconds(16));L(this,"type","base");L(this,"source");L(this,"view",new ze.Container);L(this,"createdAt",new Date);L(this,"disabled",!1);L(this,"state","IDLE");L(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",we.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 r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=we.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ke({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),pr(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(c=>c.id==this.id);return await this.track.add(o,i+1),o}copy(){return Il.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};xa([ye()],xo.prototype,"_name");xa([ye(we)],xo.prototype,"_start");xa([ye(we)],xo.prototype,"_stop");xa([ye()],xo.prototype,"disabled");let Eo=xo;var If=Object.defineProperty,En=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&If(n,t,i),i};class Xt extends ko(_t){constructor(){super(...arguments);L(this,"state","IDLE");L(this,"metadata");L(this,"objectURL");L(this,"duration",we.fromSeconds(16));L(this,"added",!1);L(this,"type","base");L(this,"name","");L(this,"mimeType");L(this,"externalURL");L(this,"external",!1);L(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 Ke({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=zi(t.type),this.external=!1,this.file=t}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});const r=await i.blob();this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.file=new File([r],this.name,{type:r.type}),this.externalURL=t,this.mimeType=zi(r.type)}async from(t,o){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,o),this.state="READY",this.trigger("load",void 0)}catch(i){throw this.state=="ERROR",this.trigger("error",new Error(String(i))),i}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();Tf(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}En([ye()],Xt.prototype,"objectURL");En([ye()],Xt.prototype,"duration");En([ye()],Xt.prototype,"type");En([ye()],Xt.prototype,"name");En([ye()],Xt.prototype,"mimeType");En([ye()],Xt.prototype,"externalURL");En([ye()],Xt.prototype,"external");const bs="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Rf(a){const n=new TextEncoder().encode(a);let t="";const o=n.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function ks(a){if(!a||!a.body)return bs;const n=a.body.scrollWidth,t=a.body.scrollHeight,o=a.cloneNode(!0),i=o.getElementsByTagName("style").item(0),r=o.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return bs;const s=new XMLSerializer,c=i?s.serializeToString(i):"",l=s.serializeToString(r),d=`
26
26
  <svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}">
27
27
  body { padding: 0; }
28
28
  ${c}
29
29
  <foreignObject width="100%" height="100%">
30
30
  ${l}
31
31
  </foreignObject>
32
- </svg>`;return"data:image/svg+xml;base64,"+Mf(d)}class ys extends Zt{constructor(){super();L(this,"type","html");L(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=gs(this.document),this.objectURL)}async loadUrl(t,o){await super.loadUrl(t,o),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((i,r)=>{this.iframe.onload=()=>i(),this.iframe.onerror=s=>r(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((o,i)=>{this.iframe.onload=()=>o(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=gs(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 Bf(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),c=a.sampleRate,l=Math.floor(i/1e3*c);let d=null,u=0;for(let m=0;m<s.length;m+=o){let f=0;const p=Math.min(m+o,s.length);for(let v=m;v<p;v++)f+=s[v]*s[v];f=Math.sqrt(f/(p-m)),f<t?(u+=o,d===null&&(d=m)):(d!==null&&u>=l&&r.push({start:we.fromSeconds(d/c),stop:we.fromSeconds(m/c)}),d=null,u=0)}return d!==null&&u>=l&&r.push({start:we.fromSeconds(d/c),stop:we.fromSeconds(s.length/c)}),r}const di=3e3;class sn extends Zt{constructor(){super(...arguments);L(this,"type","audio");L(this,"decoding",!1);L(this,"_silences");L(this,"transcript");L(this,"audioBuffer")}async decode(t=2,o=48e3,i=!1){if(this.decoding&&i&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const r=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,o).decodeAudioData(r);return this.duration.seconds=s.duration,i&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,o=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/o),c=r.sampleRate*r.duration-s,l=Math.ceil(c/t),d=r.getChannelData(0),u=[];for(let m=0;m<c;m+=l){let f=0;for(let p=m;p<m+s;p++)f+=Math.abs(d[m]);u.push(Math.log1p(f/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,di,!0),c=s.getChannelData(0),l=Math.floor(Math.max(o*di/1e3,0)),d=i?Math.floor(Math.min(i*di/1e3,s.length)):s.length,u=Math.floor((d-l)/t),m=new Float32Array(t);for(let f=0;f<t;f++){const p=l+f*u,v=p+u;let g=-1/0;for(let E=p;E<v;E++){const T=c[E];T>g&&(g=T)}m[f]=r?Math.log2(1+g):g}return m}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=Bf(r,t),i.close(),this._silences}}class Ri extends Zt{constructor(){super(...arguments);L(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 vn extends sn{constructor(){super(...arguments);L(this,"type","video");L(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new qt({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=Ui(i.headers.get("Content-type")),this.getBlob(i)}async getFile(){if(!this.file&&this.downloadInProgress&&await new Promise(this.resolve("load")),!this.file)throw new Ke({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",o=>{const i=o.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=o.clientX-((r==null?void 0:r.left)??0),c=i==null?void 0:i.duration;c&&r&&r.width>0&&(i.currentTime=Math.round(c*(s/r.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const o=await t.blob();this.file=new File([o],this.name,{type:o.type}),this.trigger("load",void 0)}catch(o){this.state=="ERROR",this.trigger("error",new Error(String(o)))}finally{this.downloadInProgress=!1}}}class Ff{static fromJSON(n){return[new we(n[0]),new we(n[1])]}}var If=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,Ln=(a,n,t,o)=>{for(var i=o>1?void 0:o?Rf(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&If(n,t,i),i};const En=class Ml extends xo{constructor(t={}){super();L(this,"source",new sn);L(this,"_offset",new we);L(this,"playing",!1);L(this,"duration",new we);L(this,"range",[new we,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=we.fromFrames(t));const o=t.subtract(this.offset);o.millis>=0&&o.millis<this.range[1].millis?this.range[0].millis=o.millis:o.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=we.fromFrames(t));const o=t.subtract(this.offset);o.millis>this.range[0].millis&&o.millis<=this.duration.millis?this.range[1]=o:o.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",we.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((o,i)=>{if(!this.element)return i(new ds({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 r;return i((r=this.element)==null?void 0:r.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>o()})}subclip(t,o){if(t||(t=this.range[0]),o||(o=this.range[1]),typeof t=="number"&&(t=we.fromFrames(t)),typeof o=="number"&&(o=we.fromFrames(o)),t.millis>=o.millis)throw new Ke({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]),o.millis>this.duration.millis&&this.duration.millis&&(o=this.duration),this.range=[t,o],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=Ml.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}async split(t){var r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=we.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new ds({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const o=this.copy();this.range[1]=t.copy(),o.range[0]=t.copy().addMillis(1),cr(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(c=>c.id==this.id);return await this.track.add(o,i+1),o}async addCaptions(t){var o;if(!((o=this.track)!=null&&o.composition))throw new Ke({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 o=(await this.source.silences(t)).filter(s=>ws(s,this.range)).sort((s,c)=>s.start.millis-c.start.millis);if(o.length==0)return[this];const i=t.padding??500,r=[this];for(const s of o){const c=r.at(-1);if(!c)break;if(!ws(s,c.range))continue;const l=new we(Math.min(s.start.millis+i,s.stop.millis));if(s.start.millis>c.range[0].millis&&s.stop.millis<c.range[1].millis){const d=c.copy();c.range[1]=l,d.range[0]=s.stop,r.push(d)}else s.start.millis<=c.range[0].millis?c.range[0]=s.stop:s.stop.millis>=c.range[1].millis&&(c.range[1]=l)}return r}};Ln([ye(we)],En.prototype,"_offset",2);Ln([ye(we)],En.prototype,"duration",2);Ln([ye(Ff)],En.prototype,"range",2);Ln([ye(hn)],En.prototype,"transcript",1);Ln([ye()],En.prototype,"muted",1);Ln([ye()],En.prototype,"volume",1);let xa=En;function ws(a,n){return a.start.millis>=n[0].millis&&a.start.millis<=n[1].millis||a.stop.millis<=n[1].millis&&a.stop.millis>=n[0].millis}class zo{static fromJSON(n){return typeof n=="object"?Ve.fromJSON(n):n}}class ui{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ve.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ve.fromJSON(n.y)),n}}let $f=class{constructor(a){L(this,"target");L(this,"animation");this.target=a}init(a,n,t=0,o){if(!(a in this.target))throw new Error(`Property [${String(a)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[a]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[a])),this.target[a]=this.animation=new Ve(i,r,{easing:o})}};function Df(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Ke({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new we(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(o,i,r,s),n)}});return n}class Uf extends $f{}var Af=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,on=(a,n,t,o)=>{for(var i=o>1?void 0:o?Of(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Af(n,t,i),i};function Ea(a){class n extends a{constructor(){super(...arguments);L(this,"filters");L(this,"_height");L(this,"_width");L(this,"_position",{x:this.view.position.x,y:this.view.position.y});L(this,"_scale");L(this,"rotation",this.view.angle);L(this,"alpha",1);L(this,"translate",{x:0,y:0})}get position(){return this._position}set position(i){typeof i=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=i}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(i){typeof i=="number"||i instanceof Ve||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof ze.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(i){const r=typeof i=="number"?{x:i,y:i}:i;for(const s of this.view.children)s instanceof ze.Sprite&&s.anchor.set(r.x,r.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return Df(new Uf(this))}}return on([ye(zo)],n.prototype,"_height",2),on([ye(zo)],n.prototype,"_width",2),on([ye(ui)],n.prototype,"_position",2),on([ye(ui)],n.prototype,"_scale",2),on([ye(zo)],n.prototype,"rotation",2),on([ye(zo)],n.prototype,"alpha",2),on([ye(ui)],n.prototype,"translate",2),on([ye()],n.prototype,"anchor",1),n}function Va(a,n,t){const o=t.value;return t.value=function(...i){var m,f,p,v;const r=i[0].subtract(this.start),s={width:((f=(m=this.track)==null?void 0:m.composition)==null?void 0:f.width)??1920,height:((v=(p=this.track)==null?void 0:p.composition)==null?void 0:v.height)??1080};let c;typeof this.translate.x=="number"?c=this.translate.x:typeof this.translate.x=="function"?c=this.translate.x.bind(this)(r):c=this.translate.x.value(r);let l;typeof this.translate.y=="number"?l=this.translate.y:typeof this.translate.y=="function"?l=this.translate.y.bind(this)(r):l=this.translate.y.value(r);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)(r):d=this._position.x.value(r);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)(r):u=this._position.y.value(r),this.view.position.set(d+c,u+l),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(r):typeof this._height=="function"?this.view.height=this._height.bind(this)(r):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(r):typeof this._width=="function"?this.view.width=this._width.bind(this)(r):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let g;typeof this._scale.x=="number"?g=this._scale.x:typeof this._scale.x=="function"?g=this._scale.x.bind(this)(r):g=this._scale.x.value(r);let E;typeof this._scale.y=="number"?E=this._scale.y:typeof this._scale.y=="function"?E=this._scale.y.bind(this)(r):E=this._scale.y.value(r),(this._width||this._height)&&(g*=this.view.scale._x,E*=this.view.scale._y),this.view.scale.set(g,E)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(r):this.view.angle=this.rotation.value(r),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(r):this.view.alpha=this.alpha.value(r),o.apply(this,i)},t}var Lf=Object.defineProperty,zf=Object.getOwnPropertyDescriptor,Pf=(a,n,t,o)=>{for(var i=zf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Lf(n,t,i),i};const Bl=class Fl extends Ea(xo){constructor(t,o={}){super();L(this,"type","image");L(this,"element",new Image);L(this,"source",new Ri);L(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),t instanceof Ri&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,o)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{this.sprite.texture=ze.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new qt({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}};Pf([Va],Bl.prototype,"update");let jf=Bl;const Po={"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 Wf=Object.defineProperty,Sa=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Wf(n,t,i),i};const Eo=class $i extends bo(_t){constructor(t){super();L(this,"loaded",!1);L(this,"family");L(this,"weight");L(this,"source");L(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(o=>{t.load().then(i=>{document.fonts.add(i),o(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=$i.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 o of await window.queryLocalFonts()){if(o.family in t){t[o.family].push(o);continue}t[o.family]=[o]}return Object.keys(t).map(o=>({family:o,variants:t[o].map(i=>({family:o,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(Po).map(t=>({family:t,variants:Po[t].weights.map(o=>({family:t,source:`url(${Po[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new $i({family:t,source:`url(${Po[t].url})`,weight:o})}};Sa([ye()],Eo.prototype,"family");Sa([ye()],Eo.prototype,"weight");Sa([ye()],Eo.prototype,"source");Sa([ye()],Eo.prototype,"style");let ut=Eo;const Pt=4,Il={center:.5,justify:.5,left:0,right:1},Rl={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Zf=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,kt=(a,n,t,o)=>{for(var i=Xf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Zf(n,t,i),i};const vt=class $l extends Ea(xo){constructor(t){super();L(this,"type","text");L(this,"_text","");L(this,"_textCase");L(this,"_anchor",{x:0,y:0});L(this,"_font",new ut);L(this,"style",new ze.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 o=new ze.Text({text:this.transformedText,style:this.style,resolution:Pt,scale:Pt});this.view.addChild(o)}this.view.children[0]instanceof ze.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*Pt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Pt):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=Rl[t]}get fillStyle(){const{fill:t}=this.style;return new ze.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:o=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new ze.Color(t).toHex().toUpperCase(),{color:t,alpha:o,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:o="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:c}=t;this.style.stroke={color:o,alpha:i,width:r,join:s,miterLimit:c}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof ze.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:o,blur:i,color:r,distance:s}=this.style.dropShadow,c=new ze.Color(r).toHex().toUpperCase();return{alpha:t,angle:o,blur:i,color:c,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=$l.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 r,s,c;const t=((r=this.view.children[0])==null?void 0:r.width)??0,o=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((c=this.style.dropShadow)==null?void 0:c.distance)??0)*Pt;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};kt([ye()],vt.prototype,"text");kt([ye(ut)],vt.prototype,"font");kt([ye()],vt.prototype,"maxWidth");kt([ye()],vt.prototype,"textAlign");kt([ye()],vt.prototype,"padding");kt([ye()],vt.prototype,"textBaseline");kt([ye()],vt.prototype,"fillStyle");kt([ye()],vt.prototype,"anchor");kt([ye()],vt.prototype,"stroke");kt([ye()],vt.prototype,"textCase");kt([ye()],vt.prototype,"shadow");kt([ye()],vt.prototype,"fontSize");kt([ye()],vt.prototype,"leading");kt([Va],vt.prototype,"update");let zn=vt;function mi(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Hf={get(a,n){const t=a[n];return typeof t=="number"?t*Pt:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*Pt):t}};function Gf(a){return new Proxy(a,Hf)}class Jf{constructor(){L(this,"tokens",[])}get width(){return this.tokens.reduce((n,t)=>n+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(n=>n.metrics.lineHeight))}}class bs{constructor(){L(this,"lines",[])}get width(){return Math.max(...this.lines.map(n=>n.width))}get height(){return this.lines.reduce((n,t)=>n+t.height,0)}}class Yf{static fromJSON(n){return n.map(t=>(t.font&&(t.font=ut.fromJSON(t.font)),t))}}var Kf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Pn=(a,n,t,o)=>{for(var i=o>1?void 0:o?qf(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Kf(n,t,i),i};const Vn=class Dl extends zn{constructor(t){super();L(this,"type","complex_text");L(this,"_maxWidth");L(this,"_textAlign","left");L(this,"_textBaseline","top");L(this,"model",new ze.Container);L(this,"segments",[]);L(this,"metrics",new bs);L(this,"background");L(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 o=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(o-i.width)/2),t=="right"&&(r=o-i.width);for(const s of i.tokens)this.model.children[s.index].x=r,r+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=Rl[t];let o=0;for(const i of this.metrics.lines){const r=i.height;for(const s of i.tokens){let c=0;t=="middle"&&(c=(r-s.metrics.lineHeight)/2),t=="bottom"&&(c=r-s.metrics.lineHeight),this.model.children[s.index].y=o+c}o+=r}}copy(){const t=Dl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const o=this.transformedText??"",i=[{index:void 0,tokens:mi(o.substring(0,(r=t==null?void 0:t.at(0))==null?void 0:r.start))}];for(let c=0;c<t.length;c++)i.push({index:t[c].index,tokens:mi(o.substring(t[c].start,t[c].stop))}),!((t[c].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:mi(o.substring(t[c].stop,(s=t.at(c+1))==null?void 0:s.start))});return i.filter(c=>c.tokens.join("").trim().length)}createTextMetrics(t,o){var r,s,c;const i=new bs;for(const l of t){const d=l.index!=null?o[l.index]:this.style;for(let u=0;u<l.tokens.length;u++){const m=Gf(ze.CanvasTextMetrics.measureText(l.tokens[u],d)),f=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=l.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(f>p||v||!i.lines.length)&&i.lines.push(new Jf),this.model.addChild(new ze.Text({text:l.tokens[u],style:d,resolution:Pt,scale:Pt})),(c=i.lines.at(-1))==null||c.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var c,l;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((c=this.background.padding)==null?void 0:c.x)??40,r=((l=this.background.padding)==null?void 0:l.y)??10,s=new ze.Graphics;s.roundRect(0-i/2,2-r/2,t+i,o+r,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var c;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),o=this.createTextStyles();this.metrics=this.createTextMetrics(t,o),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const i=this.view.width,r=this.view.height,s=(((c=this.style.dropShadow)==null?void 0:c.distance)??0)*Pt;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Pn([ye()],Vn.prototype,"background",2);Pn([ye(Yf)],Vn.prototype,"styles",2);Pn([ye()],Vn.prototype,"text",1);Pn([ye()],Vn.prototype,"maxWidth",1);Pn([ye()],Vn.prototype,"textAlign",1);Pn([ye()],Vn.prototype,"textBaseline",1);let Ca=Vn;const Ul="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Qf=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),ks=typeof self<"u"&&self.Blob&&new Blob([Qf(Ul)],{type:"text/javascript;charset=utf-8"});function eh(a){let n;try{if(n=ks&&(self.URL||self.webkitURL).createObjectURL(ks),!n)throw"";const t=new Worker(n,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+Ul,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class th{constructor(){L(this,"frames",[]);L(this,"state","active");L(this,"onenqueue");L(this,"onclose")}enqueue(n){var t;this.frames.unshift(n),(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 n;this.state="closed",(n=this.onclose)==null||n.call(this)}terminate(){for(const n of this.frames)n.close()}async waitFor(n){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function nh(a,n,t){const o=t.value;return t.value=function(...i){var r,s,c,l;return(s=(r=this.track)==null?void 0:r.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((l=(c=this.track)==null?void 0:c.composition)!=null&&l.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var oh=Object.defineProperty,ah=Object.getOwnPropertyDescriptor,ih=(a,n,t,o)=>{for(var i=ah(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&oh(n,t,i),i};const Al=class Ol extends Ea(xa){constructor(t,o={}){super();L(this,"source",new vn);L(this,"type","video");L(this,"worker");L(this,"buffer");L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"element",document.createElement("video"));L(this,"textrues",{html5:ze.Texture.from(this.element),canvas:ze.Texture.from(this.canvas)});L(this,"sprite",new ze.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 vn&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}async connect(t){var i;super.connect(t);const o=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(we.fromFrames(o))}enter(){var t,o,i;super.enter(),(o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var o,i,r,s,c,l;if((i=(o=this.track)==null?void 0:o.composition)!=null&&i.playing&&!this.playing)this.element.play();else if(!((s=(r=this.track)==null?void 0:r.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((l=(c=this.track)==null?void 0:c.composition)!=null&&l.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=Ol.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,o;return this.buffer=new th,this.worker=new eh,this.worker.addEventListener("message",i=>{var r,s;i.data.type=="frame"?(r=this.buffer)==null||r.enqueue(i.data.frame):i.data.type=="error"?this.cancelDecoding():i.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((o=(t=this.track)==null?void 0:t.composition)==null?void 0:o.fps)??go}),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 r;const t=(r=this.track)==null?void 0:r.composition;let o;this.start.millis<0?o=Math.abs(this.offset.seconds):o=this.range[0].seconds;let i;return t&&this.stop.millis>t.duration.millis?i=t.duration.subtract(this.offset).seconds:i=this.range[1].seconds,[o,i]}cancelDecoding(){var t,o;(t=this.worker)==null||t.terminate(),this.worker=void 0,(o=this.buffer)==null||o.terminate(),this.buffer=void 0}};ih([Va,nh],Al.prototype,"update");let Di=Al;class fa extends xa{constructor(t,o={}){super();L(this,"type","audio");L(this,"source",new sn);L(this,"element",new Audio);t instanceof sn&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,o,i,r,s,c;if((o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering)return this.exit();(r=(i=this.track)==null?void 0:i.composition)!=null&&r.playing&&!this.playing?this.element.play():!((c=(s=this.track)==null?void 0:s.composition)!=null&&c.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=fa.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const rh={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 Ui(a){if(!Object.keys(rh.MIXED).includes(a??""))throw new Ke({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var sh=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,ch=(a,n,t,o)=>{for(var i=lh(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&sh(n,t,i),i};const dh=class Ll extends Ea(xo){constructor(t,o={}){super();L(this,"type","html");L(this,"source",new ys);L(this,"element",new Image);L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof ys&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,c,l,d;const i=(c=(s=this.source.document)==null?void 0:s.body)==null?void 0:c.scrollWidth,r=(d=(l=this.source.document)==null?void 0:l.body)==null?void 0:d.scrollHeight;!i||!r||(this.canvas.width=i,this.canvas.height=r,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=ze.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new qt({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,o)=>{this.element.onload=()=>{var s,c,l,d;const i=(c=(s=this.source.document)==null?void 0:s.body)==null?void 0:c.scrollWidth,r=(d=(l=this.source.document)==null?void 0:l.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new qt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Ll.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};ch([Va],dh.prototype,"update");const zl=["DEFAULT","STACK"];class xs{constructor(){L(this,"mode",zl[0]);L(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=Ss(n,t.clips[i]),!!o);i++)Vs(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(Es))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Es);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!Ss(n,t.clips[o]))break;Vs(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class uh{constructor(){L(this,"mode",zl[1])}add(n,t,o=void 0){var r;let i=-1;(o!=null&&o>0||o==null)&&(i=((r=t.clips.at((o??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new we(i-n.start.millis+1)),o==null?t.clips.push(n):(t.clips.splice(o,0,n),t.clips.slice(o+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new we(r))}o=i.stop.millis+1}}offset(){}}function Es(a,n){return a.start.millis-n.start.millis}function Vs(a,n){a.start.millis>=n.start.millis&&a.start.millis<=n.stop.millis&&(a.start=n.stop.copy().addMillis(1)),a.stop.millis>=n.start.millis&&a.stop.millis<=n.stop.millis&&(a.stop=n.start.copy().addMillis(-1))}function Ss(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const c=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(l=>l.type==a.type&&!l.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return c?(c.add(a.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(a.type))==null||s.add(a.detach()),!1)}return!0}class jn extends bo(_t){constructor(){super(...arguments);L(this,"_disabled",!1);L(this,"view",new ze.Container);L(this,"clips",[]);L(this,"pointer",0);L(this,"composition");L(this,"type","base");L(this,"strategy",new xs)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&fi(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(o=this.clipRef)==null||o.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new uh,this.strategy.update(new xo,this)):this.strategy=new xs,this.trigger("update",void 0),this}layer(t){var c,l;const o=((c=this.composition)==null?void 0:c.tracks)??[],i=o.findIndex(d=>d.id==this.id),r=o.length-1;if(i==-1)return this;let s=0;return t=="bottom"?s=r:t=="top"||t<0?s=0:t>r?s=r:s=t,bf(o,i,s),(l=this.composition)==null||l.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(we.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:o}=t;if(fi(this.clipRef)&&(!pi(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!pi(o,this))for(let s=0;s<this.clips.length;s++){const c=(this.pointer+s)%this.clips.length,l=this.clips[c],d=this.clips[c-1];if(pi(o,l)&&!l.disabled)return this.pointer=c,fi(l)||(l.enter(),this.view.addChild(l.view)),l.update(t);if(o<l.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=c;return}}}async add(t,o){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,o),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const o=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),o!=null&&o>=0)return this.clips.splice(o,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 we}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new we}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 pi(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function fi(a){return a?!!a.view.parent:!1}class mh{static fromType(n){switch(n.type){case"video":return new ph;case"audio":return new hh;case"html":return new vh;case"image":return new fh;case"text":return new Cs;case"complex_text":return new Cs;case"caption":return new yh;default:return new jn}}}class Pl extends jn{constructor(){super(...arguments);L(this,"clips",[])}async seek(t){for(const o of this.clips)await o.seek(t)}async removeSilences(t={}){const o=[];for(const i of this.clips.map(r=>r.detach()))o.push(...await i.removeSilences(t));for(const i of o)await this.add(i)}}class ph extends Pl{constructor(){super(...arguments);L(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class fh extends jn{constructor(){super(...arguments);L(this,"type","image")}}class hh extends Pl{constructor(){super(...arguments);L(this,"type","audio")}}class Cs extends jn{constructor(){super(...arguments);L(this,"type","text")}}class vh extends jn{constructor(){super(...arguments);L(this,"type","html")}}var gh=Object.defineProperty,dr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&gh(n,t,i),i};class Vo extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CLASSIC");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Figtree",weight:"700"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))await t.add(new zn({text:l.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:i,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:l.stop.add(o),start:l.start.add(o),scale:new Ve([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ve([0,4],[0,1],{easing:"easeOut"})}))}}dr([ye()],Vo.prototype,"generatorOptions");dr([ye()],Vo.prototype,"type");dr([ye()],Vo.prototype,"position");class yh extends jn{constructor(){super(...arguments);L(this,"clip");L(this,"type","caption");L(this,"preset",new Vo)}from(t){var o;return this.clip=t,(o=this.clip)==null||o.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let o=this.preset;return typeof t=="object"?o=t:t&&(o=new t),this.clips=[],this.trigger("update",void 0),this.preset=o,await o.applyTo(this),this.trigger("update",void 0),this}}var wh=Object.defineProperty,Na=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&wh(n,t,i),i};class So extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SPOTLIGHT");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Ca({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:i,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:l.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:l.words[d].stop.add(o),start:l.words[d].start.add(o)}))}}}Na([ye()],So.prototype,"generatorOptions");Na([ye()],So.prototype,"type");Na([ye()],So.prototype,"color");Na([ye()],So.prototype,"position");var bh=Object.defineProperty,ur=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&bh(n,t,i),i};class _a extends _t{constructor(t={}){super();L(this,"type","GUINEA");L(this,"colors");L(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,c,l,d,u,m;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const f of t.clip.transcript.iter({length:[18]})){const{segments:p,words:v}=this.splitSequence(f);for(let g=0;g<f.words.length;g++){const E=(d=(l=v[g])==null?void 0:l.at(0))==null?void 0:d.start,T=(m=(u=v[g])==null?void 0:u.at(-1))==null?void 0:m.stop;!E||!T||await t.add(new Ca({text:p.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:i,textCase:"upper",position:this.position,stop:T.add(o),start:E.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:ea(0,2),start:p.slice(0,g).join(" ").length,stop:p.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let l=i,d=i;l>0&&d<t.text.length-1;l--,d++){if(o[l].match(/ /)){r=l;break}if(o[d].match(/ /)){r=d;break}}const s=[...us(o,r).map(l=>l.trim())],c=us(t.words,s[0].split(/ /).length);return{segments:s,words:c}}}ur([ye()],_a.prototype,"type");ur([ye()],_a.prototype,"colors");ur([ye()],_a.prototype,"position");var kh=Object.defineProperty,mr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&kh(n,t,i),i};class Ta extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CASCADE");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Geologica",weight:"400"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=()=>l.words.length==1?l.text:l.words.map(m=>m.text).slice(0,d+1).join(" ");await t.add(new zn({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:i,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:l.words[d].stop.add(o),start:l.words[d].start.add(o)}))}}}mr([ye()],Ta.prototype,"generatorOptions");mr([ye()],Ta.prototype,"type");mr([ye()],Ta.prototype,"position");var xh=Object.defineProperty,pr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&xh(n,t,i),i};class Ma extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SOLAR");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,c,l;if(!((s=t.clip)!=null&&s.transcript)||!((c=t.composition)!=null&&c.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await ut.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((l=t.clip)==null?void 0:l.offset)??new we,r=new Rd.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new zn({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:o,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(i),start:d.start.add(i),scale:new Ve([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ve([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}pr([ye()],Ma.prototype,"generatorOptions");pr([ye()],Ma.prototype,"type");pr([ye()],Ma.prototype,"position");var Eh=Object.defineProperty,Ba=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Eh(n,t,i),i};class Co extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","WHISPER");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Montserrat",weight:"300"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Ca({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:i,position:this.position,styles:[{fillStyle:this.color}],stop:l.words[d].stop.add(o),start:l.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Ba([ye()],Co.prototype,"generatorOptions");Ba([ye()],Co.prototype,"type");Ba([ye()],Co.prototype,"color");Ba([ye()],Co.prototype,"position");var Vh=Object.defineProperty,Fa=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Vh(n,t,i),i};class Ia extends _t{constructor(t={}){super();L(this,"type","VERDANT");L(this,"generatorOptions");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Montserrat",weight:"800"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Ca({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:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:l.words[d].stop.add(o),start:l.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Fa([ye()],Ia.prototype,"type");Fa([ye()],Ia.prototype,"generatorOptions");Fa([ye()],Ia.prototype,"color");Fa([ye()],Ia.prototype,"position");class Sh extends bo(_t){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();L(this,"_duration",new we);L(this,"renderer");L(this,"stage",new ze.Container);L(this,"settings");L(this,"tracks",[]);L(this,"frame",0);L(this,"fixedDuration");L(this,"state","IDLE");L(this,"fps",go);L(this,"canvas");L(this,"context");this.settings={height:t,width:o,background:i,backend:r},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)),ze.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new An({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 o;t?t instanceof we?this.fixedDuration=t:this.fixedDuration=we.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((o=this.fixedDuration)==null?void 0:o.frames)??0)}resize(t,o){var i;this.settings.width=t,this.settings.height=o,(i=this.renderer)==null||i.resize(t,o),this.canvas&&(this.canvas.height=o,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 o=typeof t=="object"?t:new t;return o.connect(this),this.stage.addChild(o.view),this.tracks.unshift(o),o.bubble(this),this.trigger("update",void 0),o}createTrack(t){const o=mh.fromType({type:t});return this.shiftTrack(o),o}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const o of this.tracks)if(o.clips.find(i=>i.id==t.id))return o.remove(t)}removeTracks(t){const o=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),o.forEach(i=>this.removeTrack(i)),o}findTracks(t){return this.tracks.filter(o=>{let i;return ms(t)?i=o instanceof t:i=t(o),i})}findClips(t){const o=[];for(const i of this.tracks)for(const r of i.clips){let s;ms(t)?s=r instanceof t:s=t(r),s&&o.push(r)}return o}computeFrame(){var t,o;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(we.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(o=this.context)==null||o.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",o=1){if(this.computeFrame(),!this.renderer)throw new An({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,o)}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 o of this.tracks)await o.seek(we.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(we.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,o=48e3){var s;const i=this.duration.seconds*o,r=new OfflineAudioContext({sampleRate:o,length:i,numberOfChannels:t}).createBuffer(t,i,o);for(const c of this.findClips(xa)){if(c.disabled||c.muted||(s=c.track)!=null&&s.disabled)continue;const l=Math.round(c.offset.seconds*r.sampleRate),d=Math.round(c.range[0].seconds*r.sampleRate),u=Math.round(c.range[1].seconds*r.sampleRate);try{const m=await c.source.decode(t,o),f=m.numberOfChannels-1;for(let p=0;p<t;p++){const v=r.getChannelData(p),g=m.getChannelData(p>f?f:p);for(let E=0;E<v.length-1;E++)E<l+d||E>l+u||E-l<0||(v[E]+=(g[E-l]??0)*c.volume,v[E]>1&&(v[E]=1),v[E]<-1&&(v[E]=-1));r.getChannelData(p).set(v)}}catch{}}return r}time(t){const o=In(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(o).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const o=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),o!=null&&o>=0)return this.tracks.splice(o,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/go;let o=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-o<t-i||(i=Math.min(t,i+r-o-t),o=r,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 o;return((o=t.stop)==null?void 0:o.frames)??0}),0),this.computeFrame()}}function Ch(a,n){const t=new Uint8Array(19);return t[0]=79,t[1]=112,t[2]=117,t[3]=115,t[4]=72,t[5]=101,t[6]=97,t[7]=100,t[8]=1,t[9]=n,t[10]=0,t[11]=0,t[12]=a&255,t[13]=a>>8&255,t[14]=a>>16&255,t[15]=a>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Ai=[8e3,12e3,16e3,24e3,48e3],Nh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",_h="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class Th{constructor(n){L(this,"output");L(this,"error");L(this,"config");L(this,"encoder");L(this,"opus");L(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(_h),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Ai.includes(i))throw new pa({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Ai.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?Nh:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:Ch(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new pa({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let c=0;const l=s/i*1e6;for(;c<t;){const d=n.subarray(c*r,(c+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const m=4e3,f=this.opus._malloc(m),p=this.opus._opus_encode(this.encoder,u,s,f,m);if(p>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(f,f+p));this.output({data:v,timestamp:o,type:"key",duration:l},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(f),c+=s,o+=l}}}function Mh(a){const n=Ai;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class Bh{constructor(n,t){L(this,"canvas");L(this,"muxer");L(this,"videoEncoder");L(this,"frame",0);L(this,"sampleRate");L(this,"numberOfChannels");L(this,"videoBitrate");L(this,"gpuBatchSize");L(this,"fps");L(this,"height");L(this,"width");L(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=Mh((t==null?void 0:t.sampleRate)??48e3),this.numberOfChannels=(t==null?void 0:t.numberOfChannels)??2,this.videoBitrate=(t==null?void 0:t.videoBitrate)??1e7,this.gpuBatchSize=(t==null?void 0:t.gpuBatchSize)??5,this.audio=(t==null?void 0:t.audio)??!1}async init(){const n=await Ef({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new _l({target:new er,video:{...n[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(o,i)=>{i&&this.muxer.addVideoChunk(o,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var o;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(n??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(o=this.videoEncoder)==null||o.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new pa({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=xf(n,this.sampleRate,this.numberOfChannels),o=new Th({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await o.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),o.encode({data:kf(t),numberOfFrames:t.length})}async blob(){var t,o,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(o=this.muxer)==null||o.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new pa({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([n],{type:"video/mp4"})}async export(){return this.blob()}}async function Fh(a){var o,i;const n=(o=a.metadata)==null?void 0:o.source_url;if(n)return n;const t=(i=a.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}function Mt(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function jo(a){return a>5?a/100:a}function Bt(a,n,t){return Math.min(t,Math.max(n,a))}function yt(){return new Ye.ColorMatrixFilter}function Ih(a,n){switch(a){case"brightness":{const t=yt(),o=Mt(n.value??n.brightness,1);return t.brightness(Bt(jo(o),0,5),!1),t}case"contrast":{const t=yt(),o=Mt(n.value??n.contrast,1);return t.contrast(Bt(jo(o),0,5),!1),t}case"saturation":{const t=yt(),o=Mt(n.value??n.saturation,1);return t.saturate(Bt(jo(o),0,5),!1),t}case"hue":{const t=yt(),o=Mt(n.degrees??n.value,0);return t.hue(Bt(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=Mt(n.radius??n.blur??n.value,t);return new Ye.BlurFilter({strength:Bt(o,0,32),quality:4})}case"grayscale":{const t=yt(),o=Bt(Mt(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=yt();return o.sepia(!1),o}case"invert":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=yt();return o.negative(!1),o}case"warmth":{const t=yt(),o=Bt(Mt(n.value,0),-50,50);return o>0?(t.sepia(!1),t.saturate(1+o/100,!1)):o<0&&t.hue(Math.abs(o)/50*-20,!1),t}case"tint":{const t=yt(),o=Bt(Mt(n.intensity,.3),0,1),i=typeof n.color=="string"?n.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,c=parseInt(r.slice(2,4),16)/255,l=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1,0]}return t}case"vintage":{const t=yt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=yt(),o=Bt(jo(Mt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=yt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=yt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=yt();return t.brightness(1.05,!1),t.saturate(.9,!1),t.contrast(.95,!1),t}default:return null}}typeof window<"u"&&!window.PIXI&&(window.PIXI=Ye);class jl{constructor(n=1920,t=1080,o=30,i){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=o,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new Sh({width:n,height:t,background:"#000000"}),this.initPromise=new Promise(r=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),r()};this.composition.on("init",s),queueMicrotask(()=>{var l,d,u,m;const c=this.composition;((d=(l=c==null?void 0:c.app)==null?void 0:l.renderer)!=null&&d.view||(u=c==null?void 0:c.renderer)!=null&&u.view||(m=c==null?void 0:c.renderer)!=null&&m.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...n){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await Fh(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(n,t){var o,i;try{const r=n.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((o=vn.from)==null?void 0:o.call(vn,r,{crossOrigin:"anonymous"}))??await vn.from(r),c=new Di(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let l=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const f=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),p=n.sourceOut!==void 0?Math.max(f+1,Math.floor(n.sourceOut*this.fps)):null;l=f,d=p;try{if(c.offset=c.offset||{frames:0},c.offset.frames=f,p!==null){const v=Math.max(1,p-f);c.duration=c.duration||{frames:v},c.duration.frames=v}}catch{}}const u=await this.composition.add(c);if(d!==null&&l>=0)try{const f=Math.max(1,d-l);u.offset=u.offset||{frames:0},u.offset.frames=l,u.duration=u.duration||{frames:f},u.duration.frames=f}catch{}const m=Math.floor(n.timelineStart*this.fps);m>0&&u.offsetBy(m),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(f=>requestAnimationFrame(f)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=ut.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new zn({text:n.content,font:t,fontSize:n.fontSize||34,position:n.position||"center",fillStyle:n.color||"#FFFFFF",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"});if(n.animation){const r=n.animation.duration||1,s=0,c=r*this.fps,l=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Ve([s,c],[n.animation.rotation.from,n.animation.rotation.to],{easing:l}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Ve([s,c],[n.animation.scale.from,n.animation.scale.to],{easing:l}))}n.startTime&&n.startTime>0&&o.offsetBy(n.startTime*this.fps),n.duration&&o.subclip(0,n.duration*this.fps);const i=await this.composition.add(o);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(l=>l.id));for(const[l,d]of i.entries())if(!r.has(l)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(l)}const s=[];for(const l of t){const d=this.buildFilterSignature(l),u=i.get(l.id);let m=null;if(u&&u.signature===d)m=u.instance;else{if(u)try{u.instance.destroy()}catch{}m=this.createPixiFilter(l),m?i.set(l.id,{instance:m,signature:d}):i.delete(l.id)}m&&s.push(m)}this.filterCache.set(n,i);const c=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(c&&"filters"in c)try{c.filters=s}catch{}typeof o.enter=="function"&&o.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:n.filterId,intensity:n.intensity??1,params:o})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,o=n.params||{};if(ct.getFilter(n.filterId)&&!ct.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=Pd(n.filterId,o);return r||(r=Ih(n.filterId,o)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!o.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(n={}){var s,c,l,d,u,m,f,p,v;const t=n.fps??this.fps,o=this.composition.canvas??((c=(s=this.composition)==null?void 0:s.renderer)==null?void 0:c.view)??((u=(d=(l=this.composition)==null?void 0:l.app)==null?void 0:d.renderer)==null?void 0:u.view)??((f=(m=this.composition)==null?void 0:m.renderer)==null?void 0:f.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(p=n.onProgress)==null||p.call(n,0);const i=new Bh(o,{fps:t});await i.init();const r=await i.export();return(v=n.onProgress)==null||v.call(n,100),r}destroy(){if(this.stopRenderLoop(),this.composition.pause(),this.clips.clear(),this.clipTimelineStart.clear(),this.filterCache.clear(),this.player&&this.composition.detachPlayer(this.player),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}this.player=null}startRenderLoop(){this.stopRenderLoop(),this.isDebug()&&this.dbg("renderLoop:start");const n=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(n)};n()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(n,t),this.composition.computeFrame())}setFitMode(n){this.fitMode=n,this.applyFitModeToClips()}applyFitModeToClips(){for(const n of this.clips.values())"scale"in n&&typeof n.scale<"u"&&this.applyFitToClip(n);this.composition.computeFrame()}applyFitToClip(n){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=n.source,c=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),l=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!c||!l)return;const d=Math.min(i/c,r/l),u=Math.max(i/c,r/l),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,c=Math.floor(s*this.fps),l=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=c+l;if(n>=c&&n<d){const u=n-c;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const Rh=["src"],$h={class:"preview-controls"},Dh=["aria-label"],Uh={class:"time-display"},Ah={class:"current-time"},Oh={class:"total-time"},Lh={key:2,class:"loading-overlay"},zh={key:3,class:"error-overlay"},Ph=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(),s=e.ref(),c=e.ref(!1),l=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),m=e.ref(0),f=e.ref(0);let p=null;const v=e.computed(()=>!!t.enableEngine&&!!t.recipe),g=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),E=e.computed(()=>{var k,B;return(k=t.media)!=null&&k.url?t.media.url:(((B=t.media)==null?void 0:B.file)instanceof File,"")});async function T(){var k,B,R;if(!(!r.value||!t.recipe))try{c.value=!0,l.value="Initializing video engine...";const U=((k=t.recipe.source)==null?void 0:k.original_width)||1920,_=((B=t.recipe.source)==null?void 0:B.original_height)||1080,z=((R=t.recipe.output)==null?void 0:R.fps)||30;p=new jl(U,_,z,{fitMode:t.fitMode}),p.attachPlayer(r.value),l.value="Loading composition...",await p.loadFromRecipe(t.recipe),f.value=p.durationInSeconds,o("duration-change",f.value),N(),c.value=!1,o("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(U){const _=U instanceof Error?U.message:String(U);d.value=`Failed to initialize: ${_}`,c.value=!1}}function N(){if(!p)return;const k=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,o("time-update",m.value))},100);A.value=k}function w(){v.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,o("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,o("play-state-change",u.value))}function h(k){const B=Math.floor(k/60),R=Math.floor(k%60);return`${B}:${R.toString().padStart(2,"0")}`}function x(){d.value=null,v.value&&T()}function D(){!v.value&&s.value&&(f.value=s.value.duration,o("duration-change",f.value))}function C(){!v.value&&s.value&&(m.value=s.value.currentTime,o("time-update",m.value))}function y(){u.value=!1,o("play-state-change",!1)}function S(k){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&T()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),A.value&&(clearInterval(A.value),A.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(p)try{await p.loadFromRecipe(k),f.value=p.durationInSeconds,o("duration-change",f.value)}catch{}else await T()}),e.watch(()=>t.enableEngine,async k=>{k?await T():p&&(A.value&&(clearInterval(A.value),A.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!v.value||!p))try{p.setFitMode(k||"contain")}catch{}});const A=e.ref(null);return(k,B)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[v.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:r,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:E.value,onLoadedmetadata:D,onTimeupdate:C,onEnded:y,onError:S,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,Rh)),e.createElementVNode("div",$h,[e.createElementVNode("button",{class:"play-button",onClick:w,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.value?e.unref(sl):e.unref(cl)},null,8,["icon"])],8,Dh),e.createElementVNode("div",Uh,[e.createElementVNode("span",Ah,e.toDisplayString(h(m.value)),1),B[0]||(B[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Oh,e.toDisplayString(h(f.value)),1)])]),c.value?(e.openBlock(),e.createElementBlock("div",Lh,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(l.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",zh,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ji)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:x},"Retry")])):e.createCommentVNode("",!0)],512))}}),Ns=Be(Ph,[["__scopeId","data-v-7e604791"]]),jh=["aria-label"],Wh=["aria-label"],Zh={class:"clip-content"},Xh={key:0,class:"clip-thumbnail"},Hh=["src","alt"],Gh={class:"clip-waveform"},Jh={class:"clip-info"},Yh={class:"clip-label"},Kh={class:"clip-duration"},qh={key:1,class:"filter-indicators"},Qh={key:2,class:"speed-indicator"},ev={key:0,class:"selection-overlay"},tv=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref(null),c=e.ref(0),l=e.ref(0),d=e.computed(()=>{const S=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${S}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),m=e.computed(()=>{const y=t.clip.timelineEnd-t.clip.timelineStart;return v(y)}),f=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),p=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 S=Math.floor(y/60),A=Math.floor(y%60);return`${S}:${A.toString().padStart(2,"0")}`}}function g(y){return!y||typeof y!="string"?is:y.includes("color")||y.includes("brightness")?rn:y.includes("blur")?yu:y.includes("style")?no:y.includes("effect")?an:is}function E(){r.value||o("select")}function T(y){y.button===0&&(h("move",y.clientX),y.preventDefault())}function N(y){if(y.touches.length!==1)return;const S=y.touches[0];h("move",S.clientX),y.preventDefault()}function w(y,S){const A="touches"in S?S.touches[0].clientX:S.clientX;s.value=y==="start"?"trim-start":"trim-end",h(s.value,A),S.preventDefault(),S.stopPropagation()}function h(y,S){r.value=!0,s.value=y,c.value=S,y==="move"?l.value=t.clip.timelineStart:y==="trim-start"?l.value=t.clip.sourceIn:y==="trim-end"&&(l.value=t.clip.sourceOut),document.addEventListener("mousemove",x),document.addEventListener("mouseup",D),document.addEventListener("touchmove",x),document.addEventListener("touchend",D),t.selected||o("select")}function x(y){if(!r.value||!s.value)return;const S="touches"in y?y.touches[0].clientX:y.clientX,k=S-c.value;s.value==="move"?(o("drag",k),o("drag-abs",S)):s.value==="trim-start"?(o("trim-start",k),o("trim-start-abs",S)):s.value==="trim-end"&&(o("trim-end",k),o("trim-end-abs",S))}function D(){r.value=!1,s.value=null,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",D),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",D)}function C(){if(!i.value)return;const y=i.value,S=y.getContext("2d");if(!S)return;y.width=y.clientWidth*window.devicePixelRatio,y.height=y.clientHeight*window.devicePixelRatio,S.scale(window.devicePixelRatio,window.devicePixelRatio),S.strokeStyle="rgba(255, 255, 255, 0.3)",S.lineWidth=1,S.beginPath();const A=y.clientWidth,k=y.clientHeight,B=k/2;S.moveTo(0,B),S.lineTo(A,B);for(let R=0;R<A;R+=4){const U=Math.sin(R*.05)*(k*.3);S.moveTo(R,B-U),S.lineTo(R,B+U)}S.stroke()}return e.onMounted(()=>{C(),window.addEventListener("resize",C)}),e.onUnmounted(()=>{D(),window.removeEventListener("resize",C)}),(y,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:y.selected,mobile:y.isMobile,"has-filters":f.value}]),style:e.normalizeStyle(d.value),onClick:E,onMousedown:T,onTouchstart:N},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:S[0]||(S[0]=e.withModifiers(A=>w("start",A),["stop"])),onTouchstart:S[1]||(S[1]=e.withModifiers(A=>w("start",A),["stop"])),"aria-label":`Trim start of ${y.clip.label||"clip"}`},[...S[4]||(S[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,jh),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:S[2]||(S[2]=e.withModifiers(A=>w("end",A),["stop"])),onTouchstart:S[3]||(S[3]=e.withModifiers(A=>w("end",A),["stop"])),"aria-label":`Trim end of ${y.clip.label||"clip"}`},[...S[5]||(S[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Wh),e.createElementVNode("div",Zh,[y.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Xh,[e.createElementVNode("img",{src:y.clip.thumbnail,alt:y.clip.label||"Video clip"},null,8,Hh)])):e.createCommentVNode("",!0),e.createElementVNode("div",Gh,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",Jh,[e.createElementVNode("span",Yh,e.toDisplayString(u.value),1),e.createElementVNode("span",Kh,e.toDisplayString(m.value),1)]),f.value?(e.openBlock(),e.createElementBlock("div",qh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,A=>(e.openBlock(),e.createBlock(e.unref(I.IonIcon),{key:A.id||A.filterId,icon:g(A.filterId||A.id),title:`Filter: ${A.filterId||A.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),y.clip.speed&&y.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Qh,e.toDisplayString(y.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),y.selected?(e.openBlock(),e.createElementBlock("div",ev)):e.createCommentVNode("",!0)],38))}}),nv=Be(tv,[["__scopeId","data-v-943b6167"]]);class Wl{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Di(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await vn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=we.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,c;i instanceof Di&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((c=i.source)==null?void 0:c.objectURL)||""))}),t}applyTransformations(n,t){(t.x!==void 0||t.y!==void 0)&&(n.x=t.x||0,n.y=t.y||0),t.rotation!==void 0&&(n.rotation=t.rotation),t.opacity!==void 0&&(n.alpha=t.opacity),t.scale!==void 0&&(n.scale={x:t.scale,y:t.scale})}secondsToFrames(n){return Math.round(n*this.fps)}framesToSeconds(n){return n/this.fps}framesToTime(n){const t=this.framesToSeconds(n),o=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),o=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return o}timeToFrames(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return this.secondsToFrames(o)}}const ov={class:"time-markers"},av=["aria-label","title"],iv={key:0,class:"timeline-scrollbar"},rv=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(a,{emit:n}){const t=a,o=e.computed(()=>t.isMobile===!0),i=n,r=e.ref(),s=e.ref(t.selectedClipId||null),c=e.ref(!1),l=e.ref(0),d=e.ref(),u=e.ref(0),m=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,K=>{K!==void 0&&(s.value=K)});const f=new Wl(t.fps),p=e.ref(!1),v=e.ref(null),g=e.ref(0),E=e.ref(0),T=e.ref(0),N=e.ref(0),w=e.ref(0),h=e.ref(!1),x=e.ref(0),D=e.ref(t.zoomLevel),C=e.computed(()=>t.zoomLevel);function y(K){const de=t.clips.find(he=>he.id===K);if(!de)return null;const ie=t.clips.filter(he=>he.id!==K&&he.timelineStart>=de.timelineEnd-1e-9).map(he=>he.timelineStart);return ie.length?Math.min(...ie):null}function S(K){const de=K.sourceMaxOut??t.duration,ie=K.timelineStart+(de-K.sourceIn),he=y(K.id),_e=he!=null?Math.max(K.timelineStart,he):1/0;return Math.min(ie,_e)}function A(K){const de=K.sourceMinIn??0,he=(K.sourceMaxOut??t.duration)-de,_e=K.sourceIn-de;return{left:`${(K.timelineStart-_e)*C.value-l.value}px`,width:`${he*C.value}px`,top:"0px",height:"80px",opacity:m.value===K.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),B=e.computed(()=>f.secondsToFrames(t.duration)),R=e.computed(()=>t.useFrameMode?B.value*k.value:t.duration*C.value),U=e.computed(()=>{var K;return u.value||((K=r.value)==null?void 0:K.clientWidth)||800}),_=e.computed(()=>R.value>U.value),z=e.computed(()=>Math.max(0,R.value-U.value)),H=e.computed(()=>l.value>0),M=e.computed(()=>l.value<z.value),$=e.computed(()=>t.useFrameMode?f.secondsToFrames(t.playhead)*k.value-l.value:t.playhead*C.value-l.value),X=e.computed(()=>{const K=Math.max(50,U.value/R.value*U.value),de=l.value/z.value*(U.value-K);return{width:`${K}px`,left:`${de}px`}}),j=e.computed(()=>{const K=[],de=te();for(let ie=0;ie<=t.duration;ie+=de){const he=ie*C.value-l.value;he>=-50&&he<=U.value+50&&K.push({position:he,label:ge(ie),time:ie})}return K});function te(){const de=80/C.value;return de<=1?1:de<=5?5:de<=10?10:de<=30?30:de<=60?60:Math.ceil(de/60)*60}function ge(K){if(t.useFrameMode)return`F${f.secondsToFrames(K)}`;{const de=Math.floor(K/60),ie=Math.floor(K%60),he=Math.floor(K%1*t.fps);return C.value>100?`${de}:${ie.toString().padStart(2,"0")}:${he.toString().padStart(2,"0")}`:`${de}:${ie.toString().padStart(2,"0")}`}}function Ne(K){const de=r.value.getBoundingClientRect();let he=(K.clientX-de.left+l.value)/C.value;const _e=t.clips.find(J=>he>=J.timelineStart&&he<=J.timelineEnd);if(_e)he=Math.max(_e.timelineStart,Math.min(_e.timelineEnd,he));else if(t.selectedClipId){const J=t.clips.find(ue=>ue.id===t.selectedClipId);if(J){const ue=Math.abs(he-J.timelineStart),ve=Math.abs(he-J.timelineEnd);he=ue<ve?J.timelineStart:J.timelineEnd}}else he=Math.max(0,Math.min(he,t.duration));i("update:playhead",he)}function ee(K){if(!_.value)return;const de=Math.abs(K.deltaX)>Math.abs(K.deltaY)?K.deltaX:K.deltaY;de!==0&&(K.preventDefault(),l.value=Math.max(0,Math.min(z.value,l.value+de)))}function F(K){if(K.touches.length===2){h.value=!0;const de=K.touches[0],ie=K.touches[1];x.value=Math.hypot(ie.clientX-de.clientX,ie.clientY-de.clientY),D.value=t.zoomLevel}else K.touches.length===1&&(T.value=K.touches[0].clientX,N.value=K.touches[0].clientY,w.value=T.value)}function P(K){if(h.value&&K.touches.length===2){const de=K.touches[0],ie=K.touches[1],_e=Math.hypot(ie.clientX-de.clientX,ie.clientY-de.clientY)/x.value;Math.max(10,Math.min(200,D.value*_e)),i("update:playhead",t.playhead)}else if(K.touches.length===1&&!h.value){const de=K.touches[0],ie=w.value-de.clientX;Math.abs(ie)>Math.abs(de.clientY-N.value)&&(K.preventDefault(),l.value=Math.max(0,Math.min(R.value-U.value,l.value+ie)),w.value=de.clientX)}}function fe(){h.value=!1}function ne(K){const de=K.target;if(de.closest(".playhead-handle"))return;const ie=K.button===1,he=!!de.closest(".video-track");(ie||!he&&_.value)&&Y(K)}function Y(K){p.value=!0,v.value="pan",g.value=K.clientX,E.value=l.value,document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke)}function Me(K){K.preventDefault(),K.stopPropagation(),p.value=!0,v.value="playhead";const de="touches"in K?K.touches[0].clientX:K.clientX;g.value=de,E.value=t.playhead,"touches"in K?(document.addEventListener("touchmove",se),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke))}function ce(K){K.preventDefault(),K.stopPropagation(),p.value=!0,v.value="scrollbar";const de="touches"in K?K.touches[0].clientX:K.clientX;g.value=de,E.value=l.value,"touches"in K?(document.addEventListener("touchmove",se),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke))}function se(K){if(!p.value)return;const ie=("touches"in K?K.touches[0].clientX:K.clientX)-g.value;if(v.value==="playhead"){const he=ie/C.value;let _e=E.value+he;if(t.selectedClipId){const J=t.clips.find(ue=>ue.id===t.selectedClipId);J?_e=Math.max(J.timelineStart,Math.min(J.timelineEnd,_e)):_e=Math.max(0,Math.min(t.duration,_e))}else{const J=t.clips.find(ue=>t.playhead>=ue.timelineStart&&t.playhead<=ue.timelineEnd);J?_e=Math.max(J.timelineStart,Math.min(J.timelineEnd,_e)):_e=Math.max(0,Math.min(t.duration,_e))}i("update:playhead",_e)}else if(v.value==="scrollbar"){const he=ie/U.value*R.value;l.value=Math.max(0,Math.min(z.value,E.value+he))}else if(v.value==="pan"){const he=E.value-ie;l.value=Math.max(0,Math.min(z.value,he))}}function ke(){p.value=!1,v.value=null,document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ke),document.removeEventListener("touchmove",se),document.removeEventListener("touchend",ke)}function oe(K){s.value=s.value===K?null:K,i("clip-select",s.value)}function le(K,de){const ie=t.clips.find(_e=>_e.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity;if(t.useFrameMode){const _e=f.secondsToFrames(ie.sourceIn),J=f.secondsToFrames(he),ue=Math.max(0,_e+J),ve=f.framesToSeconds(ue);i("trim",K,"start",ve)}else{const _e=Math.max(0,ie.sourceIn+he);i("trim",K,"start",_e)}}function Ee(K,de){const ie=t.clips.find(ae=>ae.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),_e=de-he.left,J=80;if(_e<J)l.value=Math.max(0,l.value-8);else if(_e>he.width-J){const ae=Math.max(0,R.value-U.value);l.value=Math.min(ae,l.value+8)}const ue=_e+l.value,ve=1/t.fps;let Z=ue/C.value;Z=Math.max(0,Math.min(Z,ie.timelineEnd-ve));let Q=ie.sourceIn+(Z-ie.timelineStart);Q=Math.round(Q*t.fps)/t.fps,i("trim",K,"start",Q)}function Se(K,de){const ie=t.clips.find(xe=>xe.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),_e=de-he.left,J=80;if(_e<J)l.value=Math.max(0,l.value-8);else if(_e>he.width-J){const xe=Math.max(0,R.value-U.value);l.value=Math.min(xe,l.value+8)}const ue=_e+l.value,ve=1/t.fps,Z=S(ie);let Q=ue/C.value;Q=Math.max(ie.timelineStart+ve,Math.min(Q,Z));let ae=ie.sourceIn+(Q-ie.timelineStart);ae=Math.round(ae*t.fps)/t.fps,i("trim",K,"end",ae)}function rt(K,de){const ie=t.clips.find(Z=>Z.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),J=de-he.left+l.value,ue=ie.timelineEnd-ie.timelineStart;let ve=J/C.value;ve=Math.max(0,Math.min(ve,t.duration-ue)),ve=Math.round(ve*t.fps)/t.fps,i("clip-move",K,ve)}function He(K,de){const ie=t.clips.find(J=>J.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity,_e=J=>Math.max(0,Math.round(J*t.fps)/t.fps);if(t.useFrameMode){const J=f.secondsToFrames(ie.sourceOut),ue=f.secondsToFrames(he),ve=S(ie),Z=ie.sourceIn+(ve-ie.timelineStart),Q=f.secondsToFrames(Z),ae=Math.min(Q,J+ue),xe=f.framesToSeconds(ae);i("trim",K,"end",xe)}else{const J=S(ie),ue=ie.sourceIn+(J-ie.timelineStart),ve=Math.min(ue,ie.sourceOut+he),Z=_e(ve);i("trim",K,"end",Z)}}function pt(K,de){const ie=t.clips.find(J=>J.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity,_e=J=>Math.max(0,Math.round(J*t.fps)/t.fps);if(t.useFrameMode){const J=f.secondsToFrames(ie.timelineStart),ue=f.secondsToFrames(he),ve=Math.max(0,J+ue),Z=f.framesToSeconds(ve);i("clip-move",K,Z)}else{const J=Math.max(0,ie.timelineStart+he),ue=_e(J);i("clip-move",K,ue)}}return e.watch(()=>t.playhead,K=>{const de=K*C.value;de<l.value+50?l.value=Math.max(0,de-50):de>l.value+U.value-50&&(l.value=Math.min(z.value,de-U.value+50))}),e.onMounted(()=>{const K=new ResizeObserver(de=>{de[0]&&(u.value=Math.round(de[0].contentRect.width))});r.value&&K.observe(r.value),e.onUnmounted(()=>K.disconnect())}),e.onUnmounted(()=>{ke()}),e.watch([R,U],()=>{l.value>z.value&&(l.value=z.value)}),(K,de)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:o.value}]),ref_key:"timelineRef",ref:r,onWheel:ee},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Ne},[e.createElementVNode("div",ov,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.value,ie=>(e.openBlock(),e.createElementBlock("span",{key:ie.position,class:"time-marker",style:e.normalizeStyle({left:`${ie.position}px`})},e.toDisplayString(ie.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":_.value,"is-panning":p.value&&v.value==="pan","overflow-left":H.value,"overflow-right":M.value}]),onTouchstart:F,onTouchmove:P,onTouchend:fe,onMousedown:ne},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.clips,ie=>(e.openBlock(),e.createElementBlock("div",{key:`${ie.id}-extent`,class:"clip-extent",style:e.normalizeStyle(A(ie)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.clips,ie=>(e.openBlock(),e.createBlock(nv,{key:ie.id,clip:ie,scale:C.value,"scroll-offset":l.value,selected:m.value===ie.id,"is-mobile":o.value,onSelect:he=>oe(ie.id),onTrimStart:he=>le(ie.id,he),onTrimEnd:he=>He(ie.id,he),onDrag:he=>pt(ie.id,he),onTrimStartAbs:he=>Ee(ie.id,he),onTrimEndAbs:he=>Se(ie.id,he),onDragAbs:he=>rt(ie.id,he)},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:`${$.value}px`}),onMousedown:Me,onTouchstart:Me},[...de[1]||(de[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${$.value}px`})},null,4)):e.createCommentVNode("",!0),o.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:de[0]||(de[0]=ie=>K.$emit("toggle-frame-mode")),"aria-label":K.useFrameMode?"Switch to time mode":"Switch to frame mode",title:K.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(K.useFrameMode?"F":"T"),9,av))],34),_.value?(e.openBlock(),e.createElementBlock("div",iv,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(X.value),onMousedown:ce,onTouchstart:ce},null,36)])):e.createCommentVNode("",!0)],34))}}),_s=Be(rv,[["__scopeId","data-v-6fa3968c"]]),sv={class:"control-group zoom-controls"},lv={class:"zoom-slider"},cv=["value"],dv={class:"control-group playback-controls"},uv=["aria-label"],mv={key:0,class:"control-group speed-control"},pv=["value"],fv=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(a,{emit:n}){const t=n;function o(u){const m=u.target;t("zoom-change",Number(m.value))}function i(){t("fit-to-window")}function r(){t("frame-forward")}function s(){t("frame-backward")}function c(){t("skip-to-start")}function l(){t("skip-to-end")}function d(u){const m=u.target;t("speed-change",Number(m.value))}return(u,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",sv,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=f=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Iu)},null,8,["icon"])]),e.createElementVNode("div",lv,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:o,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,cv)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=f=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(iu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(gu)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",dv,[e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to start"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Bu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Nu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=f=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.isPlaying?e.unref(ll):e.unref(dl)},null,8,["icon"])],8,uv),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Mu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to end"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Fu)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",mv,[m[5]||(m[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...m[4]||(m[4]=[e.createStaticVNode('<option value="0.25" data-v-7bf65ab9>0.25x</option><option value="0.5" data-v-7bf65ab9>0.5x</option><option value="1" data-v-7bf65ab9>1x</option><option value="1.5" data-v-7bf65ab9>1.5x</option><option value="2" data-v-7bf65ab9>2x</option>',5)])],40,pv)]))],2))}}),hv=Be(fv,[["__scopeId","data-v-7bf65ab9"]]),vv={key:0,class:"category-section"},gv={class:"category-carousel-wrapper"},yv=["disabled"],wv=["onClick","data-testid","aria-label"],bv={class:"category-name"},kv=["disabled"],xv={class:"filter-section"},Ev={class:"filter-carousel-wrapper"},Vv=["disabled"],Sv=["onClick","onKeydown","data-testid","aria-label"],Cv=["onClick"],Nv={class:"filter-preview"},_v={class:"filter-placeholder"},Tv={class:"filter-name"},Mv=["disabled"],Bv={class:"carousel-pagination"},Fv=["onClick"],Iv={key:1,class:"filter-adjustments"},Rv={class:"adjustment-header"},$v={class:"adjustment-actions"},Dv={key:0},Uv={key:0,class:"slider-control"},Av={class:"control-label"},Ov={class:"slider-wrapper"},Lv={class:"slider-value"},zv={key:1,class:"color-control"},Pv={class:"control-label"},jv={class:"color-wrapper"},Wv=["value","onInput","disabled"],Zv={class:"color-value"},Xv={key:2,class:"toggle-control"},Hv={class:"control-label"},Gv={key:3,class:"select-control"},Jv={class:"control-label"},Yv=["value","onChange","disabled"],Kv=["value"],qv={key:1,class:"no-params"},Qv=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),c=e.ref(0),l=e.ref(new Map),d=e.ref(),u=e.ref(),m={all:an,adjust:Yn,color:rn,blur:Ao,light:Kn,effects:ri,stylize:no,advanced:an,distortion:oo,transform:oo};function f(M){return M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(M){return M.replace(/[-_]/g," ").replace(/\b\w/g,$=>$.toUpperCase())}function v(M){return m[M.toLowerCase()]??an}const g=e.computed(()=>{const M=Array.from(new Set(t.filters.map($=>$.category).filter($=>typeof $=="string"&&$.length>0))).sort(($,X)=>$.localeCompare(X));return[{id:"all",name:"All",icon:an},...M.map($=>({id:$,name:p($),icon:v($)}))]}),E=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(M=>M.category===i.value));e.watch(g,M=>{new Set(M.map(j=>j.id)).has(i.value)||(i.value="all");const X=Math.max(0,M.length-3);s.value>X&&(s.value=X)},{immediate:!0});function T(M){var $;return(($=t.activeFilters)==null?void 0:$.has(M))||!1}function N(M){if(r.value=M,!T(M.id)&&(o("apply-filter",M),M.params&&M.params.length>0)){const $=new Map;M.params.forEach(X=>{$.set(X.id,X.default)}),l.value.set(M.id,$)}o("preview-filter",M)}function w(M){var $;o("remove-filter",M),l.value.delete(M),(($=r.value)==null?void 0:$.id)===M&&(r.value=null)}function h(M){if(typeof M=="number"&&Number.isFinite(M))return M;if(typeof M=="string"){const $=Number(M);return Number.isFinite($)?$:null}return null}function x(M,$){var F;const X=t.filters.find(P=>P.id===M),j=X==null?void 0:X.params.find(P=>P.id===$),te=(j==null?void 0:j.default)??0,ge=P=>typeof te=="number"?h(P)??te:typeof te=="boolean"?typeof P=="boolean"?P:te:typeof P=="string"?P:te,Ne=(F=t.activeFilters)==null?void 0:F.get(M);if(Ne&&Ne.params){const P=Ne.params[$];if(P!=null)return ge(P)}const ee=l.value.get(M);if(ee){const P=ee.get($);if(P!=null)return ge(P)}return te}function D(M,$,X){var j;l.value.has(M)||l.value.set(M,new Map),(j=l.value.get(M))==null||j.set($,X),o("update-param",M,$,X)}function C(M){if(typeof M=="boolean")return M?"On":"Off";if(typeof M=="string"){const X=h(M);return X===null?"0":Number.isInteger(X)?X.toString():X.toFixed(2)}const $=h(M);return $===null?"0":Number.isInteger($)?$.toString():$.toFixed(2)}function y(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const M=new Map;r.value.params.forEach($=>{M.set($.id,$.default)}),l.value.set(r.value.id,M)}}function S(M){const $=t.filters.find(X=>X.id===M);$&&$.params&&$.params.forEach(X=>{D(M,X.id,X.default)})}function A(M){return{basic:Yn,color:rn,blur:Ao,light:Kn,effects:ri,stylize:no,adjustment:Yn,"color-matrix":rn,glow:an,distortion:oo}[M]||an}function k(M){return{adjustment:Yn,brightness:Kn,contrast:Yn,saturation:rn,blur:Ao,"gaussian-blur":Ao,"color-matrix":rn,grayscale:no,sepia:no,vignette:oo,glow:an,glitch:ri,godray:Kn,lightmap:Kn}[M.id]||A(M.category)}function B(){s.value>0&&(s.value--,H(d.value,s.value))}function R(){s.value<g.value.length-3&&(s.value++,H(d.value,s.value))}function U(){c.value>0&&(c.value--,H(u.value,c.value))}function _(){c.value<E.value.length-4&&(c.value++,H(u.value,c.value))}function z(M){c.value=M*4,H(u.value,c.value)}function H(M,$){var X;if(M){const j=((X=M.querySelector(".category-chip, .filter-card"))==null?void 0:X.clientWidth)||100;M.scrollTo({left:$*(j+8),behavior:"smooth"})}}return(M,$)=>{var X;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:M.compact}])},[M.showCategories?(e.openBlock(),e.createElementBlock("div",vv,[e.createElementVNode("div",gv,[e.createElementVNode("button",{onClick:B,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(es)},null,8,["icon"])],8,yv),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,j=>(e.openBlock(),e.createElementBlock("button",{key:j.id,onClick:te=>i.value=j.id,class:e.normalizeClass(["category-chip",{active:i.value===j.id}]),"data-testid":`btn-filter-category-${f(j.id)}`,"aria-label":`Filter category ${j.name}`},[e.createVNode(e.unref(I.IonIcon),{icon:j.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",bv,e.toDisplayString(j.name),1)],10,wv))),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ts)},null,8,["icon"])],8,kv)])])):e.createCommentVNode("",!0),e.createElementVNode("div",xv,[e.createElementVNode("div",Ev,[e.createElementVNode("button",{onClick:U,class:"carousel-nav carousel-nav-left",disabled:c.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(es)},null,8,["icon"])],8,Vv),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,j=>{var te;return e.openBlock(),e.createElementBlock("div",{key:j.id,class:e.normalizeClass(["filter-card",{active:T(j.id),selected:((te=r.value)==null?void 0:te.id)===j.id}]),onClick:ge=>N(j),onKeydown:[e.withKeys(ge=>N(j),["enter"]),e.withKeys(e.withModifiers(ge=>N(j),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${f(j.id)}`,"aria-label":`Select filter ${j.name}`},[T(j.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ge=>w(j.id),["stop"])},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(al)},null,8,["icon"])],8,Cv)):e.createCommentVNode("",!0),e.createElementVNode("div",Nv,[e.createElementVNode("div",_v,[e.createVNode(e.unref(I.IonIcon),{icon:k(j),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",Tv,e.toDisplayString(j.name),1)],42,Sv)}),128))],512),e.createElementVNode("button",{onClick:_,class:"carousel-nav carousel-nav-right",disabled:c.value>=Math.max(0,E.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ts)},null,8,["icon"])],8,Mv)]),e.createElementVNode("div",Bv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(E.value.length/4),(j,te)=>(e.openBlock(),e.createElementBlock("span",{key:te,class:e.normalizeClass(["pagination-dot",{active:Math.floor(c.value/4)===te}]),onClick:ge=>z(te)},null,10,Fv))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",Iv,[e.createElementVNode("div",Rv,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",$v,[T(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:y,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),T(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:$[0]||($[0]=j=>w(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),T(r.value.id)&&((X=r.value.params)==null?void 0:X.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:$[1]||($[1]=j=>S(r.value.id)),class:"reset-btn","data-testid":"btn-reset-selected-filter"}," Reset ")):e.createCommentVNode("",!0)])]),r.value.params&&r.value.params.length>0?(e.openBlock(),e.createElementBlock("div",Dv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,j=>(e.openBlock(),e.createElementBlock("div",{key:j.id,class:"adjustment-control"},[!j.type||j.type==="slider"?(e.openBlock(),e.createElementBlock("div",Uv,[e.createElementVNode("label",Av,e.toDisplayString(j.label||j.id),1),e.createElementVNode("div",Ov,[e.createVNode(e.unref(I.IonRange),{value:x(r.value.id,j.id),onIonChange:te=>D(r.value.id,j.id,te.detail.value),min:j.min,max:j.max,step:j.step||.01,color:"primary",class:"compact-slider",disabled:!T(r.value.id),"data-testid":`range-filter-${f(r.value.id)}-${f(j.id)}`,"aria-label":`Adjust ${j.label||j.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Lv,e.toDisplayString(C(x(r.value.id,j.id))),1)])])):j.type==="color"?(e.openBlock(),e.createElementBlock("div",zv,[e.createElementVNode("label",Pv,e.toDisplayString(j.label||j.id),1),e.createElementVNode("div",jv,[e.createElementVNode("input",{type:"color",value:x(r.value.id,j.id),onInput:te=>D(r.value.id,j.id,te.target.value),disabled:!T(r.value.id),class:"color-input"},null,40,Wv),e.createElementVNode("span",Zv,e.toDisplayString(x(r.value.id,j.id)),1)])])):j.type==="toggle"?(e.openBlock(),e.createElementBlock("div",Xv,[e.createElementVNode("label",Hv,e.toDisplayString(j.label||j.id),1),e.createVNode(e.unref(I.IonToggle),{checked:!!x(r.value.id,j.id),onIonChange:te=>D(r.value.id,j.id,te.detail.checked),disabled:!T(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):j.type==="select"?(e.openBlock(),e.createElementBlock("div",Gv,[e.createElementVNode("label",Jv,e.toDisplayString(j.label||j.id),1),e.createElementVNode("select",{value:x(r.value.id,j.id),onChange:te=>D(r.value.id,j.id,te.target.value),disabled:!T(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.options,te=>(e.openBlock(),e.createElementBlock("option",{key:String(te.value),value:te.value},e.toDisplayString(te.label),9,Kv))),128))],40,Yv)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",qv," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),e0=Be(Qv,[["__scopeId","data-v-9efd15d9"]]);class t0{constructor(n){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=n}setComposition(n){this.composition=n}mapMediablesToPIXI(n){switch(n.filterId){case"blur":return this.createBlurFilter(n.params);case"brightness":return this.createBrightnessFilter(n.params);case"contrast":return this.createContrastFilter(n.params);case"saturation":return this.createSaturationFilter(n.params);case"hue":return this.createHueFilter(n.params);case"vintage":return this.createVintageFilter(n.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.BlurFilter;if(!i)return null;const r=new i;return r.blur=n.intensity||5,r.quality=n.quality||4,r}catch{return null}}createBrightnessFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),n.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const o=this.mapMediablesToPIXI(t);o&&(this.pixiFilters.set(t.id,o),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,o))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const o=this.pixiFilters.get(n);o&&(this.filterParams.set(n,t),"blur"in o&&(o.blur=t.intensity||o.blur),"brightness"in o&&o.brightness(t.value||1,!1),"contrast"in o&&o.contrast(t.value||1,!1),"saturate"in o&&o.saturate(t.value||1,!1),"hue"in o&&o.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(n){return this.filterParams.get(n)||{}}removeFilter(n){var t;this.pixiFilters.delete(n),this.filterParams.delete(n),this.filterTypes.delete(n),this.filterIntensity.delete(n),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(n)}clearFilters(){var n;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(n=this.composition)!=null&&n.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const n=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;n.push({id:o,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const n0={class:"video-filter-preview"},o0={class:"preview-title"},a0={class:"filter-controls"},i0={class:"control-input"},r0=["value","onInput","min","max","step"],s0={class:"param-value"},l0={class:"preview-container"},c0={key:0,class:"filter-presets"},d0=["onClick"],u0={class:"preview-actions"},m0=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let c,l,d=null,u=null;const m=e.computed(()=>{var y;return((y=t.filter)==null?void 0:y.paramRanges)||{}}),f=e.computed(()=>p.value.length>0),p=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(i.value){t.useVideoEngine&&t.composition&&(u=new t0(t.composition));try{if(c=new Ye.Application,await c.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(y=t.currentFrame)!=null&&y.dataUrl){const S=await Ye.Assets.load(t.currentFrame.dataUrl);l=new Ye.Sprite(S);const A=Math.min(c.screen.width/l.texture.width,c.screen.height/l.texture.height);l.scale.set(A),l.anchor.set(.5),l.position.set(c.screen.width/2,c.screen.height/2),c.stage.addChild(l)}g()}catch{}}}function g(){if(!(!l||!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(S=>{}),d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(l.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(l.filters=r.value?null:[d])}function E(y,S){switch(y){case"brightness":{const A=new Ye.ColorMatrixFilter,k=1+(S.value??0);return typeof A.brightness=="function"&&A.brightness(k,!1),A}case"contrast":{const A=new Ye.ColorMatrixFilter,k=S.value??1;return typeof A.contrast=="function"&&A.contrast(k,!1),A}case"saturation":{const A=new Ye.ColorMatrixFilter,k=S.value??1;return typeof A.saturate=="function"&&A.saturate(k,!1),A}case"hue":{const A=new Ye.ColorMatrixFilter,k=S.value??0;return typeof A.hue=="function"&&A.hue(k,!1),A}case"gaussian-blur":{const A=S.value??5;return new Ye.BlurFilter({strength:A,quality:4})}case"sepia":{const A=new Ye.ColorMatrixFilter;return typeof A.sepia=="function"&&A.sepia(!1),A}case"grayscale":{const A=new Ye.ColorMatrixFilter;return typeof A.desaturate=="function"&&A.desaturate(),A}default:return null}}function T(y,S){const A=S.target,k=Number.parseFloat(A.value),B=Number.isFinite(k)?k:0;s.value={...s.value,[y]:B},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),g()}function N(y){return y.charAt(0).toUpperCase()+y.slice(1).replace(/_/g," ")}function w(y,S){var k;const A=typeof y=="number"?y:Number(y);return Number.isFinite(A)?S==="hue"||S==="angle"?`${A}°`:S==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+A)*100)}%`:Number.isInteger(A)?A.toString():A.toFixed(2):"0"}function h(){var y;s.value=((y=t.filter)==null?void 0:y.defaultParams)||{},o("update-params",s.value),g()}function x(y){s.value={...y.params},o("update-params",s.value),g()}function D(y){return JSON.stringify(y.params)===JSON.stringify(s.value)}function C(){o("apply")}return e.watch(()=>t.filter,y=>{y&&(s.value={...y.defaultParams},g())}),e.watch(()=>t.currentFrame,async y=>{if(y!=null&&y.dataUrl&&l){const S=await Ye.Assets.load(y.dataUrl);l.texture=S}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),v()}),e.onUnmounted(()=>{c&&c.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(y,S)=>{var A;return e.openBlock(),e.createElementBlock("div",n0,[e.createElementVNode("h4",o0,e.toDisplayString((A=y.filter)==null?void 0:A.name)+" Settings",1),e.createElementVNode("div",a0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(k,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(N(B)),1),e.createElementVNode("div",i0,[e.createElementVNode("input",{type:"range",value:s.value[B],onInput:R=>T(B,R),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,r0),e.createElementVNode("span",s0,e.toDisplayString(w(s.value[B],B)),1)])]))),128))]),e.createElementVNode("div",l0,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:S[0]||(S[0]=k=>r.value=!0),onMouseup:S[1]||(S[1]=k=>r.value=!1),onTouchstart:S[2]||(S[2]=k=>r.value=!0),onTouchend:S[3]||(S[3]=k=>r.value=!1)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(oo)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),f.value?(e.openBlock(),e.createElementBlock("div",c0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.name,class:e.normalizeClass(["preset-button",{active:D(k)}]),onClick:B=>x(k)},e.toDisplayString(k.name),11,d0))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",u0,[e.createElementVNode("button",{class:"action-button",onClick:h},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On)},null,8,["icon"]),S[5]||(S[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:C},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(il)},null,8,["icon"]),S[6]||(S[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),p0=Be(m0,[["__scopeId","data-v-3de3dd04"]]),f0={class:"export-settings"},h0={class:"setting-group"},v0={class:"setting-group"},g0={class:"estimated-size"},y0={key:0,class:"export-progress"},w0={class:"progress-header"},b0={class:"progress-percentage"},k0={class:"progress-time"},x0={class:"action-buttons"},E0=["disabled"],V0=["disabled"],S0=["disabled"],C0={class:"export-options"},N0=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(a,{emit:n}){const t=a,o=n,i=e.ref("1080p"),r=e.ref("mp4"),s=e.ref(!0),c=e.ref(!1),l=e.ref(0),d=e.ref(0),u=e.ref(0);let m=null;const f=e.computed(()=>{const h=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return h<1e3?`~${Math.round(h)} MB`:`~${(h/1e3).toFixed(1)} GB`});function p(){t.isExporting?(o("cancel-export"),E()):v()}function v(){const N={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:c.value};o("export",N),g()}function g(){l.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-l.value)/1e3),t.exportProgress>0){const N=d.value/t.exportProgress*100;u.value=Math.max(0,N-d.value)}},1e3)}function E(){m&&(clearInterval(m),m=null)}function T(N){const w=Math.floor(N/60),h=Math.floor(N%60);return`${w}:${h.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,N=>{N||E()}),e.onUnmounted(()=>{E()}),(N,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:N.isMobile}])},[e.createElementVNode("div",f0,[w[10]||(w[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",h0,[w[7]||(w[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[0]||(w[0]=h=>i.value=h),class:"setting-select"},[...w[6]||(w[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,i.value]])]),e.createElementVNode("div",v0,[w[9]||(w[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[1]||(w[1]=h=>r.value=h),class:"setting-select"},[...w[8]||(w[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,r.value]])]),e.createElementVNode("div",g0,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ku)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(f.value),1)])]),N.isExporting?(e.openBlock(),e.createElementBlock("div",y0,[e.createElementVNode("div",w0,[w[11]||(w[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",b0,e.toDisplayString(N.exportProgress??0)+"%",1)]),e.createVNode(e.unref(I.IonProgressBar),{value:(N.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",k0,[e.createElementVNode("span",null,e.toDisplayString(T(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(T(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",x0,[e.createElementVNode("button",{class:"control-button secondary",onClick:w[2]||(w[2]=h=>N.$emit("save-draft")),disabled:!N.canExport||N.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Yi)},null,8,["icon"]),w[12]||(w[12]=e.createTextVNode(" Save Draft ",-1))],8,E0),e.createElementVNode("button",{class:"control-button secondary",onClick:w[3]||(w[3]=h=>N.$emit("reset")),disabled:N.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On)},null,8,["icon"]),w[13]||(w[13]=e.createTextVNode(" Reset ",-1))],8,V0),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!N.canExport&&!N.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(I.IonIcon),{icon:N.isExporting?e.unref($n):e.unref(ho)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(N.isExporting?"Cancel":"Export Video"),1)],8,S0)]),e.createElementVNode("div",C0,[e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":w[4]||(w[4]=h=>s.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...w[14]||(w[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:c.value,"onUpdate:modelValue":w[5]||(w[5]=h=>c.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...w[15]||(w[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),_0=Be(N0,[["__scopeId","data-v-e1338d5e"]]),T0={class:"thumbnail-picker"},M0={class:"thumbnail-grid"},B0=["onClick"],F0=["src","alt"],I0={key:1,class:"thumbnail-placeholder"},R0={class:"thumbnail-time"},$0={class:"custom-selector"},D0={class:"time-input-group"},U0=["max"],A0={class:"time-value"},O0=["disabled"],L0={class:"picker-actions"},z0=["disabled"],P0=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),c=e.ref(!1);function l(){const T=[];if(t.duration<=10)for(let w=0;w<Math.min(9,t.duration);w++)T.push(w);else{const w=t.duration/10;for(let h=1;h<=9;h++)T.push(w*h)}return T}async function d(T){try{const N=document.createElement("video");return N.crossOrigin="anonymous",N.src=await u(),new Promise(w=>{N.addEventListener("loadedmetadata",()=>{N.currentTime=T}),N.addEventListener("seeked",()=>{const h=document.createElement("canvas");h.width=N.videoWidth,h.height=N.videoHeight;const x=h.getContext("2d");x?(x.drawImage(N,0,0),w(h.toDataURL("image/jpeg",.8))):w(null),N.remove()}),N.addEventListener("error",()=>{w(null),N.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 m(){const T=l();i.value=T.map(w=>({time:w,loading:!0}));const N=3;for(let w=0;w<i.value.length;w+=N){const h=i.value.slice(w,w+N);await Promise.all(h.map(async x=>{const D=await d(x.time);D&&(x.dataUrl=D),x.loading=!1}))}}function f(T){r.value=T,s.value=i.value[T].time}function p(){r.value=-1}async function v(){c.value=!0;try{const T=await d(s.value);if(T){const N=i.value.findIndex(w=>Math.abs(w.time-s.value)<.1);N>=0?(i.value[N].dataUrl=T,r.value=N):(i.value.push({time:s.value,dataUrl:T}),r.value=i.value.length-1,i.value.sort((w,h)=>w.time-h.time),r.value=i.value.findIndex(w=>w.time===s.value))}}finally{c.value=!1}}function g(){const T=r.value>=0?i.value[r.value].time:s.value;o("select",T)}function E(T){const N=Math.floor(T/60),w=Math.floor(T%60),h=Math.floor(T%1*100);return N>0?`${N}:${w.toString().padStart(2,"0")}.${h.toString().padStart(2,"0")}`:`${w}.${h.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(T,N)=>(e.openBlock(),e.createElementBlock("div",T0,[N[5]||(N[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",M0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(w,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["thumbnail-item",{selected:r.value===h}]),onClick:x=>f(h)},[w.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.dataUrl,alt:`Frame at ${E(w.time)}`},null,8,F0)):(e.openBlock(),e.createElementBlock("div",I0,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",R0,e.toDisplayString(E(w.time)),1)],10,B0))),128))]),e.createElementVNode("div",$0,[N[3]||(N[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",D0,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":N[0]||(N[0]=w=>s.value=w),min:0,max:T.duration,step:.1,onInput:p,class:"time-slider"},null,40,U0),[[e.vModelText,s.value]]),e.createElementVNode("span",A0,e.toDisplayString(E(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:c.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cu)},null,8,["icon"]),N[2]||(N[2]=e.createTextVNode(" Capture Frame ",-1))],8,O0)]),e.createElementVNode("div",L0,[e.createElementVNode("button",{class:"action-button",onClick:N[1]||(N[1]=w=>T.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:g,disabled:r.value===-1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(il)},null,8,["icon"]),N[4]||(N[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,z0)])]))}}),j0=Be(P0,[["__scopeId","data-v-336c322c"]]),W0={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Z0={class:"mb-4"},X0={class:"space-y-2 max-h-64 overflow-y-auto"},H0={class:"flex items-center justify-between"},G0={class:"flex-1"},J0={class:"font-medium text-gray-900 dark:text-white"},Y0={class:"text-sm text-gray-500 dark:text-gray-400"},K0={class:"flex items-center space-x-2"},q0=["onClick"],Q0=["onClick"],e1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},t1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},n1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},o1={class:"space-y-4"},a1={class:"grid grid-cols-2 gap-4"},i1={class:"grid grid-cols-2 gap-4"},r1={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},s1={class:"grid grid-cols-2 gap-3"},l1={class:"flex justify-end space-x-3 mt-6"},c1=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function c(f){Object.assign(s,f),i.value=f}function l(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const f={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(f.animation={type:s.animationType},s.animationDuration!==void 0&&(f.animation.duration=s.animationDuration),s.animationEasing&&(f.animation.easing=s.animationEasing),f.animation))switch(s.animationType){case"rotate":f.animation.rotation={from:0,to:360};break;case"scale":f.animation.scale={from:.5,to:1};break;case"slide":f.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,f):t("add-overlay",f),l()}function u(f){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",f)}function m(f){const p=Math.floor(f/60),v=Math.floor(f%60);return`${p}:${v.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",W0,[e.createElementVNode("div",Z0,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=v=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-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 Text Overlay ",-1)])])]),e.createElementVNode("div",X0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.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",H0,[e.createElementVNode("div",G0,[e.createElementVNode("div",J0,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",Y0,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",K0,[e.createElementVNode("button",{onClick:g=>c(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[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,q0),e.createElementVNode("button",{onClick:g=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[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,Q0)])])]))),128)),f.overlays.length===0?(e.openBlock(),e.createElementBlock("div",e1," No text overlays added yet ")):e.createCommentVNode("",!0)]),o.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(l,["self"])},[e.createElementVNode("div",t1,[e.createElementVNode("h4",n1,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",o1,[e.createElementVNode("div",null,[p[14]||(p[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":p[1]||(p[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",a1,[e.createElementVNode("div",null,[p[15]||(p[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":p[2]||(p[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,[p[16]||(p[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":p[3]||(p[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,[p[18]||(p[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":p[4]||(p[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"},[...p[17]||(p[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",i1,[e.createElementVNode("div",null,[p[19]||(p[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":p[5]||(p[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,[p[20]||(p[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":p[6]||(p[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,[p[22]||(p[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":p[7]||(p[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"},[...p[21]||(p[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",r1,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",s1,[e.createElementVNode("div",null,[p[23]||(p[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":p[8]||(p[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,[p[25]||(p[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":p[9]||(p[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"},[...p[24]||(p[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",l1,[e.createElementVNode("button",{onClick:l,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(i.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),d1=Be(c1,[["__scopeId","data-v-f86e688c"]]),fo=class fo{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",c=this.findTrackForClip(n),l=this.findTrackForClip(t);if(!c||!l)throw new Error("Clips must be added to composition before applying transitions");const d=n.stop.frames-r,u=n.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(n,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(n,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(n,t,o.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,o.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,o.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,o.type,d,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Ve([o,i],[1,0],{easing:r}),t.alpha=new Ve([o,i],[0,1],{easing:r}),t.start=we.fromFrames(o)}async applyCrossFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Ve([o,i],[1,0],{easing:r}),t.alpha=new Ve([o,i],[0,1],{easing:r}),t.start=we.fromFrames(o)}async applyWipeTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const c={x:0,y:0},l={x:0,y:0};switch(o){case"wipe-left":c.x=new Ve([i,r],[0,-1920],{easing:s}),l.x=new Ve([i,r],[1920,0],{easing:s});break;case"wipe-right":c.x=new Ve([i,r],[0,1920],{easing:s}),l.x=new Ve([i,r],[-1920,0],{easing:s});break;case"wipe-up":c.y=new Ve([i,r],[0,-1080],{easing:s}),l.y=new Ve([i,r],[1080,0],{easing:s});break;case"wipe-down":c.y=new Ve([i,r],[0,1080],{easing:s}),l.y=new Ve([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=we.fromFrames(i)}async applySlideTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const c={x:0,y:0},l={x:0,y:0};switch(o){case"slide-left":c.x=new Ve([i,r],[0,-1920],{easing:s}),l.x=new Ve([i,r],[1920,0],{easing:s});break;case"slide-right":c.x=new Ve([i,r],[0,1920],{easing:s}),l.x=new Ve([i,r],[-1920,0],{easing:s});break;case"slide-up":c.y=new Ve([i,r],[0,-1080],{easing:s}),l.y=new Ve([i,r],[1080,0],{easing:s});break;case"slide-down":c.y=new Ve([i,r],[0,1080],{easing:s}),l.y=new Ve([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=we.fromFrames(i)}async applyZoomTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(n.scale=new Ve([i,r],[1,2],{easing:s}),n.alpha=new Ve([i,r],[1,0],{easing:s}),t.scale=new Ve([i,r],[.5,1],{easing:s}),t.alpha=new Ve([i,r],[0,1],{easing:s})):(n.scale=new Ve([i,r],[1,.5],{easing:s}),n.alpha=new Ve([i,r],[1,0],{easing:s}),t.scale=new Ve([i,r],[2,1],{easing:s}),t.alpha=new Ve([i,r],[0,1],{easing:s})),t.start=we.fromFrames(i)}async applyDipTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const c=Math.round((i+r)/2),l=o==="dip-to-black"?"#000000":"#ffffff",d=await Ri.fromColor(l),u=new jf(d,{start:we.fromFrames(i),stop:we.fromFrames(r)});n.alpha=new Ve([i,c],[1,0],{easing:s}),u.alpha=new Ve([i,c,r],[0,1,0],{easing:s}),t.alpha=new Ve([c,r],[0,1],{easing:s}),await this.composition.add(u),t.start=we.fromFrames(c)}findTrackForClip(n){for(const t of this.composition.tracks)if(t.clips.includes(n))return t}removeTransition(n){this.transitions.delete(n)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...fo.TRANSITIONS]}static previewTransition(n){return fo.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};fo.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 ha=fo;const u1={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},m1={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},p1=["onClick"],f1={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"},h1={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},v1={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},g1={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},y1={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"},w1={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"},b1={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"},k1={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},x1={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},E1={class:"space-y-3"},V1={class:"flex items-center space-x-2"},S1=["disabled"],C1=["disabled"],N1={key:1,class:"mt-4"},_1={class:"space-y-2 max-h-32 overflow-y-auto"},T1={class:"text-sm text-gray-700 dark:text-gray-300"},M1=["onClick"],B1=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(ha.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),c=e.ref("linear"),l=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function d(v){r.value=v}function u(){if(!r.value||!l.value)return;const v={type:r.value.type,duration:s.value,easing:c.value};o("apply-transition",v),r.value=null}function m(){if(!r.value)return;const v={type:r.value.type,duration:s.value,easing:c.value};o("preview-transition",v)}function f(v){o("remove-transition",v)}function p(v){return["fade","wipe","slide","zoom"].some(g=>v.includes(g))}return(v,g)=>(e.openBlock(),e.createElementBlock("div",u1,[g[9]||(g[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",m1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,E=>{var T;return e.openBlock(),e.createElementBlock("div",{key:E.type,onClick:N=>d(E),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((T=r.value)==null?void 0:T.type)===E.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",f1,[p(E.type)?(e.openBlock(),e.createElementBlock("svg",h1,[E.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",v1)):E.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",g1)):E.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",y1)):E.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",w1)):(e.openBlock(),e.createElementBlock("path",b1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",k1,e.toDisplayString(E.name),1)],10,p1)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",x1,[g[6]||(g[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",E1,[e.createElementVNode("div",null,[g[3]||(g[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",V1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=E=>s.value=E),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":g[1]||(g[1]=E=>s.value=E),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,[g[5]||(g[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":g[2]||(g[2]=E=>c.value=E),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"},[...g[4]||(g[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,c.value]])]),e.createElementVNode("button",{onClick:u,disabled:!l.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",l.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,S1),e.createElementVNode("button",{onClick:m,disabled:!r.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,C1)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",N1,[g[8]||(g[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",_1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(E,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",T1,e.toDisplayString(E.name)+" ("+e.toDisplayString(E.duration)+"s) ",1),e.createElementVNode("button",{onClick:N=>f(T),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[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,M1)]))),128))])])):e.createCommentVNode("",!0),g[10]||(g[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))]))}}),F1=Be(B1,[["__scopeId","data-v-5ef1b100"]]),I1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},R1={class:"mb-4"},$1={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},D1={class:"flex items-center justify-between mb-2"},U1={class:"text-sm text-gray-600 dark:text-gray-400"},A1={class:"flex items-center space-x-2"},O1={class:"space-y-3 max-h-64 overflow-y-auto"},L1={class:"flex items-center justify-between mb-2"},z1={class:"font-medium text-gray-900 dark:text-white"},P1={class:"flex items-center space-x-2"},j1=["onClick","title"],W1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Z1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},X1=["onClick"],H1=["onClick"],G1={class:"flex items-center space-x-2"},J1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},Y1=["value","onInput","disabled"],K1={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},q1={key:0,class:"ml-2"},Q1={key:1,class:"ml-2"},eg={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},tg={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},ng={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},og={class:"space-y-4"},ag={class:"space-y-2"},ig={class:"flex items-center"},rg={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},sg={class:"grid grid-cols-2 gap-4"},lg={class:"grid grid-cols-2 gap-4"},cg={class:"flex items-center"},dg={class:"flex justify-end space-x-3 mt-6"},ug=["disabled"],mg=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),c=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),l=e.reactive(c()),d=e.computed(()=>l.sourceUrl||l.sourceFile);function u(w){const h=w.target;h.files&&h.files[0]&&(l.sourceFile=h.files[0],l.name=l.name||h.files[0].name.replace(/\.[^/.]+$/,""))}function m(w){Object.assign(l,w),r.value=w}function f(){i.value=!1,r.value=null,Object.assign(l,c())}function p(){if(!d.value)return;const w={source:l.sourceFile??l.sourceUrl??"",name:l.name,volume:l.volume,startTime:l.startTime,loop:l.loop};l.duration!==void 0&&(w.duration=l.duration),l.fadeIn>0&&(w.fadeIn=l.fadeIn),l.fadeOut>0&&(w.fadeOut=l.fadeOut),r.value?o("update-track",r.value.id,w):o("add-track",w),f()}function v(w){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",w)}function g(w,h){const x=h.target,D=parseFloat(x.value);o("update-volume",w.id,D)}function E(w){o("toggle-mute",w.id,!w.muted)}function T(){o("update-master-volume",s.value)}function N(w){const h=Math.floor(w/60),x=Math.floor(w%60);return`${h}:${x.toString().padStart(2,"0")}`}return(w,h)=>(e.openBlock(),e.createElementBlock("div",I1,[e.createElementVNode("div",R1,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=x=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-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 Audio Track ",-1)])])]),e.createElementVNode("div",$1,[e.createElementVNode("div",D1,[h[12]||(h[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",U1,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",A1,[h[13]||(h[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":h[1]||(h[1]=x=>s.value=x),onInput:T,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),h[14]||(h[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",O1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.audioLayers,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",L1,[e.createElementVNode("div",z1,e.toDisplayString(x.name),1),e.createElementVNode("div",P1,[e.createElementVNode("button",{onClick:D=>E(x),class:e.normalizeClass(["p-1 rounded",x.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:x.muted?"Unmute":"Mute"},[x.muted?(e.openBlock(),e.createElementBlock("svg",Z1,[...h[16]||(h[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",W1,[...h[15]||(h[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,j1),e.createElementVNode("button",{onClick:D=>m(x),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...h[17]||(h[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,X1),e.createElementVNode("button",{onClick:D=>v(x.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[18]||(h[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,H1)])]),e.createElementVNode("div",G1,[e.createElementVNode("span",J1,e.toDisplayString(Math.round((x.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:x.volume||1,onInput:D=>g(x,D),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:x.muted},null,40,Y1)]),e.createElementVNode("div",K1,[e.createTextVNode(e.toDisplayString(N(x.startTime||0))+" - "+e.toDisplayString(N((x.startTime||0)+(x.duration||0)))+" ",1),x.fadeIn?(e.openBlock(),e.createElementBlock("span",q1,"Fade In: "+e.toDisplayString(x.fadeIn)+"s",1)):e.createCommentVNode("",!0),x.fadeOut?(e.openBlock(),e.createElementBlock("span",Q1,"Fade Out: "+e.toDisplayString(x.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),w.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",eg," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.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(f,["self"])},[e.createElementVNode("div",tg,[e.createElementVNode("h4",ng,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",og,[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"}," Audio Source ",-1)),e.createElementVNode("div",ag,[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",ig,[h[19]||(h[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":h[2]||(h[2]=x=>l.sourceUrl=x),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,l.sourceUrl]])])])]),e.createElementVNode("div",null,[h[21]||(h[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":h[3]||(h[3]=x=>l.name=x),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,l.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",rg," Volume: "+e.toDisplayString(Math.round(l.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[4]||(h[4]=x=>l.volume=x),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,l.volume,void 0,{number:!0}]])]),e.createElementVNode("div",sg,[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"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=x=>l.startTime=x),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,l.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[23]||(h[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":h[6]||(h[6]=x=>l.duration=x),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,l.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",lg,[e.createElementVNode("div",null,[h[24]||(h[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":h[7]||(h[7]=x=>l.fadeIn=x),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,l.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[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":h[8]||(h[8]=x=>l.fadeOut=x),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,l.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",cg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[9]||(h[9]=x=>l.loop=x),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,l.loop]]),h[26]||(h[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",dg,[e.createElementVNode("button",{onClick:f,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:p,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(r.value?"Save":"Add"),11,ug)])])])):e.createCommentVNode("",!0)]))}}),pg=Be(mg,[["__scopeId","data-v-593719ac"]]);function Ue(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function Ts(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let Ms=!1;function fg(){if(Ms)return;Ms=!0;const a=`
32
+ </svg>`;return"data:image/svg+xml;base64,"+Rf(d)}class xs extends Xt{constructor(){super();L(this,"type","html");L(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=ks(this.document),this.objectURL)}async loadUrl(t,o){await super.loadUrl(t,o),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((i,r)=>{this.iframe.onload=()=>i(),this.iframe.onerror=s=>r(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((o,i)=>{this.iframe.onload=()=>o(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=ks(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 $f(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),c=a.sampleRate,l=Math.floor(i/1e3*c);let d=null,u=0;for(let m=0;m<s.length;m+=o){let f=0;const p=Math.min(m+o,s.length);for(let v=m;v<p;v++)f+=s[v]*s[v];f=Math.sqrt(f/(p-m)),f<t?(u+=o,d===null&&(d=m)):(d!==null&&u>=l&&r.push({start:we.fromSeconds(d/c),stop:we.fromSeconds(m/c)}),d=null,u=0)}return d!==null&&u>=l&&r.push({start:we.fromSeconds(d/c),stop:we.fromSeconds(s.length/c)}),r}const fi=3e3;class ln extends Xt{constructor(){super(...arguments);L(this,"type","audio");L(this,"decoding",!1);L(this,"_silences");L(this,"transcript");L(this,"audioBuffer")}async decode(t=2,o=48e3,i=!1){if(this.decoding&&i&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const r=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,o).decodeAudioData(r);return this.duration.seconds=s.duration,i&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,o=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/o),c=r.sampleRate*r.duration-s,l=Math.ceil(c/t),d=r.getChannelData(0),u=[];for(let m=0;m<c;m+=l){let f=0;for(let p=m;p<m+s;p++)f+=Math.abs(d[m]);u.push(Math.log1p(f/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,fi,!0),c=s.getChannelData(0),l=Math.floor(Math.max(o*fi/1e3,0)),d=i?Math.floor(Math.min(i*fi/1e3,s.length)):s.length,u=Math.floor((d-l)/t),m=new Float32Array(t);for(let f=0;f<t;f++){const p=l+f*u,v=p+u;let g=-1/0;for(let E=p;E<v;E++){const T=c[E];T>g&&(g=T)}m[f]=r?Math.log2(1+g):g}return m}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=$f(r,t),i.close(),this._silences}}class Ai extends Xt{constructor(){super(...arguments);L(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 gn extends ln{constructor(){super(...arguments);L(this,"type","video");L(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Qt({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=zi(i.headers.get("Content-type")),this.getBlob(i)}async getFile(){if(!this.file&&this.downloadInProgress&&await new Promise(this.resolve("load")),!this.file)throw new Ke({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",o=>{const i=o.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=o.clientX-((r==null?void 0:r.left)??0),c=i==null?void 0:i.duration;c&&r&&r.width>0&&(i.currentTime=Math.round(c*(s/r.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const o=await t.blob();this.file=new File([o],this.name,{type:o.type}),this.trigger("load",void 0)}catch(o){this.state=="ERROR",this.trigger("error",new Error(String(o)))}finally{this.downloadInProgress=!1}}}class Df{static fromJSON(n){return[new we(n[0]),new we(n[1])]}}var Uf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,zn=(a,n,t,o)=>{for(var i=o>1?void 0:o?Af(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Uf(n,t,i),i};const Vn=class Rl extends Eo{constructor(t={}){super();L(this,"source",new ln);L(this,"_offset",new we);L(this,"playing",!1);L(this,"duration",new we);L(this,"range",[new we,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=we.fromFrames(t));const o=t.subtract(this.offset);o.millis>=0&&o.millis<this.range[1].millis?this.range[0].millis=o.millis:o.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=we.fromFrames(t));const o=t.subtract(this.offset);o.millis>this.range[0].millis&&o.millis<=this.duration.millis?this.range[1]=o:o.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",we.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((o,i)=>{if(!this.element)return i(new fs({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 r;return i((r=this.element)==null?void 0:r.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>o()})}subclip(t,o){if(t||(t=this.range[0]),o||(o=this.range[1]),typeof t=="number"&&(t=we.fromFrames(t)),typeof o=="number"&&(o=we.fromFrames(o)),t.millis>=o.millis)throw new Ke({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]),o.millis>this.duration.millis&&this.duration.millis&&(o=this.duration),this.range=[t,o],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=Rl.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}async split(t){var r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=we.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new fs({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const o=this.copy();this.range[1]=t.copy(),o.range[0]=t.copy().addMillis(1),pr(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(c=>c.id==this.id);return await this.track.add(o,i+1),o}async addCaptions(t){var o;if(!((o=this.track)!=null&&o.composition))throw new Ke({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 o=(await this.source.silences(t)).filter(s=>Es(s,this.range)).sort((s,c)=>s.start.millis-c.start.millis);if(o.length==0)return[this];const i=t.padding??500,r=[this];for(const s of o){const c=r.at(-1);if(!c)break;if(!Es(s,c.range))continue;const l=new we(Math.min(s.start.millis+i,s.stop.millis));if(s.start.millis>c.range[0].millis&&s.stop.millis<c.range[1].millis){const d=c.copy();c.range[1]=l,d.range[0]=s.stop,r.push(d)}else s.start.millis<=c.range[0].millis?c.range[0]=s.stop:s.stop.millis>=c.range[1].millis&&(c.range[1]=l)}return r}};zn([ye(we)],Vn.prototype,"_offset",2);zn([ye(we)],Vn.prototype,"duration",2);zn([ye(Df)],Vn.prototype,"range",2);zn([ye(vn)],Vn.prototype,"transcript",1);zn([ye()],Vn.prototype,"muted",1);zn([ye()],Vn.prototype,"volume",1);let Ea=Vn;function Es(a,n){return a.start.millis>=n[0].millis&&a.start.millis<=n[1].millis||a.stop.millis<=n[1].millis&&a.stop.millis>=n[0].millis}class Po{static fromJSON(n){return typeof n=="object"?Ve.fromJSON(n):n}}class hi{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ve.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ve.fromJSON(n.y)),n}}let Of=class{constructor(a){L(this,"target");L(this,"animation");this.target=a}init(a,n,t=0,o){if(!(a in this.target))throw new Error(`Property [${String(a)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[a]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[a])),this.target[a]=this.animation=new Ve(i,r,{easing:o})}};function Lf(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Ke({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new we(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(o,i,r,s),n)}});return n}class zf extends Of{}var Pf=Object.defineProperty,jf=Object.getOwnPropertyDescriptor,an=(a,n,t,o)=>{for(var i=o>1?void 0:o?jf(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Pf(n,t,i),i};function Va(a){class n extends a{constructor(){super(...arguments);L(this,"filters");L(this,"_height");L(this,"_width");L(this,"_position",{x:this.view.position.x,y:this.view.position.y});L(this,"_scale");L(this,"rotation",this.view.angle);L(this,"alpha",1);L(this,"translate",{x:0,y:0})}get position(){return this._position}set position(i){typeof i=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=i}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(i){typeof i=="number"||i instanceof Ve||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof ze.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(i){const r=typeof i=="number"?{x:i,y:i}:i;for(const s of this.view.children)s instanceof ze.Sprite&&s.anchor.set(r.x,r.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return Lf(new zf(this))}}return an([ye(Po)],n.prototype,"_height",2),an([ye(Po)],n.prototype,"_width",2),an([ye(hi)],n.prototype,"_position",2),an([ye(hi)],n.prototype,"_scale",2),an([ye(Po)],n.prototype,"rotation",2),an([ye(Po)],n.prototype,"alpha",2),an([ye(hi)],n.prototype,"translate",2),an([ye()],n.prototype,"anchor",1),n}function Sa(a,n,t){const o=t.value;return t.value=function(...i){var m,f,p,v;const r=i[0].subtract(this.start),s={width:((f=(m=this.track)==null?void 0:m.composition)==null?void 0:f.width)??1920,height:((v=(p=this.track)==null?void 0:p.composition)==null?void 0:v.height)??1080};let c;typeof this.translate.x=="number"?c=this.translate.x:typeof this.translate.x=="function"?c=this.translate.x.bind(this)(r):c=this.translate.x.value(r);let l;typeof this.translate.y=="number"?l=this.translate.y:typeof this.translate.y=="function"?l=this.translate.y.bind(this)(r):l=this.translate.y.value(r);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)(r):d=this._position.x.value(r);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)(r):u=this._position.y.value(r),this.view.position.set(d+c,u+l),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(r):typeof this._height=="function"?this.view.height=this._height.bind(this)(r):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(r):typeof this._width=="function"?this.view.width=this._width.bind(this)(r):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let g;typeof this._scale.x=="number"?g=this._scale.x:typeof this._scale.x=="function"?g=this._scale.x.bind(this)(r):g=this._scale.x.value(r);let E;typeof this._scale.y=="number"?E=this._scale.y:typeof this._scale.y=="function"?E=this._scale.y.bind(this)(r):E=this._scale.y.value(r),(this._width||this._height)&&(g*=this.view.scale._x,E*=this.view.scale._y),this.view.scale.set(g,E)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(r):this.view.angle=this.rotation.value(r),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(r):this.view.alpha=this.alpha.value(r),o.apply(this,i)},t}var Wf=Object.defineProperty,Zf=Object.getOwnPropertyDescriptor,Xf=(a,n,t,o)=>{for(var i=Zf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Wf(n,t,i),i};const $l=class Dl extends Va(Eo){constructor(t,o={}){super();L(this,"type","image");L(this,"element",new Image);L(this,"source",new Ai);L(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),t instanceof Ai&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,o)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{this.sprite.texture=ze.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Qt({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}};Xf([Sa],$l.prototype,"update");let Hf=$l;const jo={"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 Gf=Object.defineProperty,Ca=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Gf(n,t,i),i};const Vo=class Oi extends ko(_t){constructor(t){super();L(this,"loaded",!1);L(this,"family");L(this,"weight");L(this,"source");L(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(o=>{t.load().then(i=>{document.fonts.add(i),o(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Oi.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 o of await window.queryLocalFonts()){if(o.family in t){t[o.family].push(o);continue}t[o.family]=[o]}return Object.keys(t).map(o=>({family:o,variants:t[o].map(i=>({family:o,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(jo).map(t=>({family:t,variants:jo[t].weights.map(o=>({family:t,source:`url(${jo[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new Oi({family:t,source:`url(${jo[t].url})`,weight:o})}};Ca([ye()],Vo.prototype,"family");Ca([ye()],Vo.prototype,"weight");Ca([ye()],Vo.prototype,"source");Ca([ye()],Vo.prototype,"style");let ut=Vo;const jt=4,Ul={center:.5,justify:.5,left:0,right:1},Al={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Jf=Object.defineProperty,Yf=Object.getOwnPropertyDescriptor,kt=(a,n,t,o)=>{for(var i=Yf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Jf(n,t,i),i};const vt=class Ol extends Va(Eo){constructor(t){super();L(this,"type","text");L(this,"_text","");L(this,"_textCase");L(this,"_anchor",{x:0,y:0});L(this,"_font",new ut);L(this,"style",new ze.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 o=new ze.Text({text:this.transformedText,style:this.style,resolution:jt,scale:jt});this.view.addChild(o)}this.view.children[0]instanceof ze.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*jt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/jt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Ul[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=Al[t]}get fillStyle(){const{fill:t}=this.style;return new ze.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:o=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new ze.Color(t).toHex().toUpperCase(),{color:t,alpha:o,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:o="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:c}=t;this.style.stroke={color:o,alpha:i,width:r,join:s,miterLimit:c}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof ze.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:o,blur:i,color:r,distance:s}=this.style.dropShadow,c=new ze.Color(r).toHex().toUpperCase();return{alpha:t,angle:o,blur:i,color:c,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=Ol.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 r,s,c;const t=((r=this.view.children[0])==null?void 0:r.width)??0,o=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((c=this.style.dropShadow)==null?void 0:c.distance)??0)*jt;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};kt([ye()],vt.prototype,"text");kt([ye(ut)],vt.prototype,"font");kt([ye()],vt.prototype,"maxWidth");kt([ye()],vt.prototype,"textAlign");kt([ye()],vt.prototype,"padding");kt([ye()],vt.prototype,"textBaseline");kt([ye()],vt.prototype,"fillStyle");kt([ye()],vt.prototype,"anchor");kt([ye()],vt.prototype,"stroke");kt([ye()],vt.prototype,"textCase");kt([ye()],vt.prototype,"shadow");kt([ye()],vt.prototype,"fontSize");kt([ye()],vt.prototype,"leading");kt([Sa],vt.prototype,"update");let Pn=vt;function vi(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Kf={get(a,n){const t=a[n];return typeof t=="number"?t*jt:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*jt):t}};function qf(a){return new Proxy(a,Kf)}class Qf{constructor(){L(this,"tokens",[])}get width(){return this.tokens.reduce((n,t)=>n+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(n=>n.metrics.lineHeight))}}class Vs{constructor(){L(this,"lines",[])}get width(){return Math.max(...this.lines.map(n=>n.width))}get height(){return this.lines.reduce((n,t)=>n+t.height,0)}}class eh{static fromJSON(n){return n.map(t=>(t.font&&(t.font=ut.fromJSON(t.font)),t))}}var th=Object.defineProperty,nh=Object.getOwnPropertyDescriptor,jn=(a,n,t,o)=>{for(var i=o>1?void 0:o?nh(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&th(n,t,i),i};const Sn=class Ll extends Pn{constructor(t){super();L(this,"type","complex_text");L(this,"_maxWidth");L(this,"_textAlign","left");L(this,"_textBaseline","top");L(this,"model",new ze.Container);L(this,"segments",[]);L(this,"metrics",new Vs);L(this,"background");L(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=Ul[t];const o=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(o-i.width)/2),t=="right"&&(r=o-i.width);for(const s of i.tokens)this.model.children[s.index].x=r,r+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=Al[t];let o=0;for(const i of this.metrics.lines){const r=i.height;for(const s of i.tokens){let c=0;t=="middle"&&(c=(r-s.metrics.lineHeight)/2),t=="bottom"&&(c=r-s.metrics.lineHeight),this.model.children[s.index].y=o+c}o+=r}}copy(){const t=Ll.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const o=this.transformedText??"",i=[{index:void 0,tokens:vi(o.substring(0,(r=t==null?void 0:t.at(0))==null?void 0:r.start))}];for(let c=0;c<t.length;c++)i.push({index:t[c].index,tokens:vi(o.substring(t[c].start,t[c].stop))}),!((t[c].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:vi(o.substring(t[c].stop,(s=t.at(c+1))==null?void 0:s.start))});return i.filter(c=>c.tokens.join("").trim().length)}createTextMetrics(t,o){var r,s,c;const i=new Vs;for(const l of t){const d=l.index!=null?o[l.index]:this.style;for(let u=0;u<l.tokens.length;u++){const m=qf(ze.CanvasTextMetrics.measureText(l.tokens[u],d)),f=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=l.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(f>p||v||!i.lines.length)&&i.lines.push(new Qf),this.model.addChild(new ze.Text({text:l.tokens[u],style:d,resolution:jt,scale:jt})),(c=i.lines.at(-1))==null||c.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var c,l;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((c=this.background.padding)==null?void 0:c.x)??40,r=((l=this.background.padding)==null?void 0:l.y)??10,s=new ze.Graphics;s.roundRect(0-i/2,2-r/2,t+i,o+r,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var c;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),o=this.createTextStyles();this.metrics=this.createTextMetrics(t,o),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const i=this.view.width,r=this.view.height,s=(((c=this.style.dropShadow)==null?void 0:c.distance)??0)*jt;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};jn([ye()],Sn.prototype,"background",2);jn([ye(eh)],Sn.prototype,"styles",2);jn([ye()],Sn.prototype,"text",1);jn([ye()],Sn.prototype,"maxWidth",1);jn([ye()],Sn.prototype,"textAlign",1);jn([ye()],Sn.prototype,"textBaseline",1);let Na=Sn;const zl="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",oh=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),Ss=typeof self<"u"&&self.Blob&&new Blob([oh(zl)],{type:"text/javascript;charset=utf-8"});function ah(a){let n;try{if(n=Ss&&(self.URL||self.webkitURL).createObjectURL(Ss),!n)throw"";const t=new Worker(n,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+zl,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class ih{constructor(){L(this,"frames",[]);L(this,"state","active");L(this,"onenqueue");L(this,"onclose")}enqueue(n){var t;this.frames.unshift(n),(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 n;this.state="closed",(n=this.onclose)==null||n.call(this)}terminate(){for(const n of this.frames)n.close()}async waitFor(n){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function rh(a,n,t){const o=t.value;return t.value=function(...i){var r,s,c,l;return(s=(r=this.track)==null?void 0:r.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((l=(c=this.track)==null?void 0:c.composition)!=null&&l.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var sh=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,ch=(a,n,t,o)=>{for(var i=lh(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&sh(n,t,i),i};const Pl=class jl extends Va(Ea){constructor(t,o={}){super();L(this,"source",new gn);L(this,"type","video");L(this,"worker");L(this,"buffer");L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"element",document.createElement("video"));L(this,"textrues",{html5:ze.Texture.from(this.element),canvas:ze.Texture.from(this.canvas)});L(this,"sprite",new ze.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 gn&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}async connect(t){var i;super.connect(t);const o=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(we.fromFrames(o))}enter(){var t,o,i;super.enter(),(o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var o,i,r,s,c,l;if((i=(o=this.track)==null?void 0:o.composition)!=null&&i.playing&&!this.playing)this.element.play();else if(!((s=(r=this.track)==null?void 0:r.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((l=(c=this.track)==null?void 0:c.composition)!=null&&l.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=jl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,o;return this.buffer=new ih,this.worker=new ah,this.worker.addEventListener("message",i=>{var r,s;i.data.type=="frame"?(r=this.buffer)==null||r.enqueue(i.data.frame):i.data.type=="error"?this.cancelDecoding():i.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((o=(t=this.track)==null?void 0:t.composition)==null?void 0:o.fps)??yo}),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 r;const t=(r=this.track)==null?void 0:r.composition;let o;this.start.millis<0?o=Math.abs(this.offset.seconds):o=this.range[0].seconds;let i;return t&&this.stop.millis>t.duration.millis?i=t.duration.subtract(this.offset).seconds:i=this.range[1].seconds,[o,i]}cancelDecoding(){var t,o;(t=this.worker)==null||t.terminate(),this.worker=void 0,(o=this.buffer)==null||o.terminate(),this.buffer=void 0}};ch([Sa,rh],Pl.prototype,"update");let Li=Pl;class ha extends Ea{constructor(t,o={}){super();L(this,"type","audio");L(this,"source",new ln);L(this,"element",new Audio);t instanceof ln&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,o,i,r,s,c;if((o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering)return this.exit();(r=(i=this.track)==null?void 0:i.composition)!=null&&r.playing&&!this.playing?this.element.play():!((c=(s=this.track)==null?void 0:s.composition)!=null&&c.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=ha.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const dh={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 zi(a){if(!Object.keys(dh.MIXED).includes(a??""))throw new Ke({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var uh=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,ph=(a,n,t,o)=>{for(var i=mh(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&uh(n,t,i),i};const fh=class Wl extends Va(Eo){constructor(t,o={}){super();L(this,"type","html");L(this,"source",new xs);L(this,"element",new Image);L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof xs&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,c,l,d;const i=(c=(s=this.source.document)==null?void 0:s.body)==null?void 0:c.scrollWidth,r=(d=(l=this.source.document)==null?void 0:l.body)==null?void 0:d.scrollHeight;!i||!r||(this.canvas.width=i,this.canvas.height=r,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=ze.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Qt({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,o)=>{this.element.onload=()=>{var s,c,l,d;const i=(c=(s=this.source.document)==null?void 0:s.body)==null?void 0:c.scrollWidth,r=(d=(l=this.source.document)==null?void 0:l.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new Qt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Wl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};ph([Sa],fh.prototype,"update");const Zl=["DEFAULT","STACK"];class Cs{constructor(){L(this,"mode",Zl[0]);L(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=Ts(n,t.clips[i]),!!o);i++)_s(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(Ns))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Ns);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!Ts(n,t.clips[o]))break;_s(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class hh{constructor(){L(this,"mode",Zl[1])}add(n,t,o=void 0){var r;let i=-1;(o!=null&&o>0||o==null)&&(i=((r=t.clips.at((o??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new we(i-n.start.millis+1)),o==null?t.clips.push(n):(t.clips.splice(o,0,n),t.clips.slice(o+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new we(r))}o=i.stop.millis+1}}offset(){}}function Ns(a,n){return a.start.millis-n.start.millis}function _s(a,n){a.start.millis>=n.start.millis&&a.start.millis<=n.stop.millis&&(a.start=n.stop.copy().addMillis(1)),a.stop.millis>=n.start.millis&&a.stop.millis<=n.stop.millis&&(a.stop=n.start.copy().addMillis(-1))}function Ts(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const c=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(l=>l.type==a.type&&!l.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return c?(c.add(a.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(a.type))==null||s.add(a.detach()),!1)}return!0}class Wn extends ko(_t){constructor(){super(...arguments);L(this,"_disabled",!1);L(this,"view",new ze.Container);L(this,"clips",[]);L(this,"pointer",0);L(this,"composition");L(this,"type","base");L(this,"strategy",new Cs)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&yi(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(o=this.clipRef)==null||o.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new hh,this.strategy.update(new Eo,this)):this.strategy=new Cs,this.trigger("update",void 0),this}layer(t){var c,l;const o=((c=this.composition)==null?void 0:c.tracks)??[],i=o.findIndex(d=>d.id==this.id),r=o.length-1;if(i==-1)return this;let s=0;return t=="bottom"?s=r:t=="top"||t<0?s=0:t>r?s=r:s=t,Vf(o,i,s),(l=this.composition)==null||l.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(we.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:o}=t;if(yi(this.clipRef)&&(!gi(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!gi(o,this))for(let s=0;s<this.clips.length;s++){const c=(this.pointer+s)%this.clips.length,l=this.clips[c],d=this.clips[c-1];if(gi(o,l)&&!l.disabled)return this.pointer=c,yi(l)||(l.enter(),this.view.addChild(l.view)),l.update(t);if(o<l.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=c;return}}}async add(t,o){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,o),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const o=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),o!=null&&o>=0)return this.clips.splice(o,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 we}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new we}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 gi(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function yi(a){return a?!!a.view.parent:!1}class vh{static fromType(n){switch(n.type){case"video":return new gh;case"audio":return new wh;case"html":return new bh;case"image":return new yh;case"text":return new Ms;case"complex_text":return new Ms;case"caption":return new xh;default:return new Wn}}}class Xl extends Wn{constructor(){super(...arguments);L(this,"clips",[])}async seek(t){for(const o of this.clips)await o.seek(t)}async removeSilences(t={}){const o=[];for(const i of this.clips.map(r=>r.detach()))o.push(...await i.removeSilences(t));for(const i of o)await this.add(i)}}class gh extends Xl{constructor(){super(...arguments);L(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class yh extends Wn{constructor(){super(...arguments);L(this,"type","image")}}class wh extends Xl{constructor(){super(...arguments);L(this,"type","audio")}}class Ms extends Wn{constructor(){super(...arguments);L(this,"type","text")}}class bh extends Wn{constructor(){super(...arguments);L(this,"type","html")}}var kh=Object.defineProperty,fr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&kh(n,t,i),i};class So extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CLASSIC");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Figtree",weight:"700"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))await t.add(new Pn({text:l.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:i,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:l.stop.add(o),start:l.start.add(o),scale:new Ve([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ve([0,4],[0,1],{easing:"easeOut"})}))}}fr([ye()],So.prototype,"generatorOptions");fr([ye()],So.prototype,"type");fr([ye()],So.prototype,"position");class xh extends Wn{constructor(){super(...arguments);L(this,"clip");L(this,"type","caption");L(this,"preset",new So)}from(t){var o;return this.clip=t,(o=this.clip)==null||o.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let o=this.preset;return typeof t=="object"?o=t:t&&(o=new t),this.clips=[],this.trigger("update",void 0),this.preset=o,await o.applyTo(this),this.trigger("update",void 0),this}}var Eh=Object.defineProperty,_a=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Eh(n,t,i),i};class Co extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SPOTLIGHT");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Na({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:i,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:l.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:l.words[d].stop.add(o),start:l.words[d].start.add(o)}))}}}_a([ye()],Co.prototype,"generatorOptions");_a([ye()],Co.prototype,"type");_a([ye()],Co.prototype,"color");_a([ye()],Co.prototype,"position");var Vh=Object.defineProperty,hr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Vh(n,t,i),i};class Ta extends _t{constructor(t={}){super();L(this,"type","GUINEA");L(this,"colors");L(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,c,l,d,u,m;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const f of t.clip.transcript.iter({length:[18]})){const{segments:p,words:v}=this.splitSequence(f);for(let g=0;g<f.words.length;g++){const E=(d=(l=v[g])==null?void 0:l.at(0))==null?void 0:d.start,T=(m=(u=v[g])==null?void 0:u.at(-1))==null?void 0:m.stop;!E||!T||await t.add(new Na({text:p.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:i,textCase:"upper",position:this.position,stop:T.add(o),start:E.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:ta(0,2),start:p.slice(0,g).join(" ").length,stop:p.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let l=i,d=i;l>0&&d<t.text.length-1;l--,d++){if(o[l].match(/ /)){r=l;break}if(o[d].match(/ /)){r=d;break}}const s=[...hs(o,r).map(l=>l.trim())],c=hs(t.words,s[0].split(/ /).length);return{segments:s,words:c}}}hr([ye()],Ta.prototype,"type");hr([ye()],Ta.prototype,"colors");hr([ye()],Ta.prototype,"position");var Sh=Object.defineProperty,vr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Sh(n,t,i),i};class Ma extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CASCADE");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Geologica",weight:"400"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=()=>l.words.length==1?l.text:l.words.map(m=>m.text).slice(0,d+1).join(" ");await t.add(new Pn({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:i,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:l.words[d].stop.add(o),start:l.words[d].start.add(o)}))}}}vr([ye()],Ma.prototype,"generatorOptions");vr([ye()],Ma.prototype,"type");vr([ye()],Ma.prototype,"position");var Ch=Object.defineProperty,gr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ch(n,t,i),i};class Ba extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SOLAR");L(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,c,l;if(!((s=t.clip)!=null&&s.transcript)||!((c=t.composition)!=null&&c.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await ut.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((l=t.clip)==null?void 0:l.offset)??new we,r=new Ad.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Pn({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:o,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(i),start:d.start.add(i),scale:new Ve([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ve([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}gr([ye()],Ba.prototype,"generatorOptions");gr([ye()],Ba.prototype,"type");gr([ye()],Ba.prototype,"position");var Nh=Object.defineProperty,Fa=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Nh(n,t,i),i};class No extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","WHISPER");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Montserrat",weight:"300"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Na({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:i,position:this.position,styles:[{fillStyle:this.color}],stop:l.words[d].stop.add(o),start:l.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Fa([ye()],No.prototype,"generatorOptions");Fa([ye()],No.prototype,"type");Fa([ye()],No.prototype,"color");Fa([ye()],No.prototype,"position");var _h=Object.defineProperty,Ia=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&_h(n,t,i),i};class Ra extends _t{constructor(t={}){super();L(this,"type","VERDANT");L(this,"generatorOptions");L(this,"color");L(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 r,s,c;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((c=t.clip)==null?void 0:c.offset)??new we,i=await ut.fromFamily({family:"Montserrat",weight:"800"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<l.words.length;d++){const u=l.words.map(m=>m.text);await t.add(new Na({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:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:l.words[d].stop.add(o),start:l.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Ia([ye()],Ra.prototype,"type");Ia([ye()],Ra.prototype,"generatorOptions");Ia([ye()],Ra.prototype,"color");Ia([ye()],Ra.prototype,"position");class Th extends ko(_t){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();L(this,"_duration",new we);L(this,"renderer");L(this,"stage",new ze.Container);L(this,"settings");L(this,"tracks",[]);L(this,"frame",0);L(this,"fixedDuration");L(this,"state","IDLE");L(this,"fps",yo);L(this,"canvas");L(this,"context");this.settings={height:t,width:o,background:i,backend:r},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)),ze.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new On({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 o;t?t instanceof we?this.fixedDuration=t:this.fixedDuration=we.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((o=this.fixedDuration)==null?void 0:o.frames)??0)}resize(t,o){var i;this.settings.width=t,this.settings.height=o,(i=this.renderer)==null||i.resize(t,o),this.canvas&&(this.canvas.height=o,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 o=typeof t=="object"?t:new t;return o.connect(this),this.stage.addChild(o.view),this.tracks.unshift(o),o.bubble(this),this.trigger("update",void 0),o}createTrack(t){const o=vh.fromType({type:t});return this.shiftTrack(o),o}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const o of this.tracks)if(o.clips.find(i=>i.id==t.id))return o.remove(t)}removeTracks(t){const o=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),o.forEach(i=>this.removeTrack(i)),o}findTracks(t){return this.tracks.filter(o=>{let i;return vs(t)?i=o instanceof t:i=t(o),i})}findClips(t){const o=[];for(const i of this.tracks)for(const r of i.clips){let s;vs(t)?s=r instanceof t:s=t(r),s&&o.push(r)}return o}computeFrame(){var t,o;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(we.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(o=this.context)==null||o.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",o=1){if(this.computeFrame(),!this.renderer)throw new On({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,o)}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 o of this.tracks)await o.seek(we.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(we.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,o=48e3){var s;const i=this.duration.seconds*o,r=new OfflineAudioContext({sampleRate:o,length:i,numberOfChannels:t}).createBuffer(t,i,o);for(const c of this.findClips(Ea)){if(c.disabled||c.muted||(s=c.track)!=null&&s.disabled)continue;const l=Math.round(c.offset.seconds*r.sampleRate),d=Math.round(c.range[0].seconds*r.sampleRate),u=Math.round(c.range[1].seconds*r.sampleRate);try{const m=await c.source.decode(t,o),f=m.numberOfChannels-1;for(let p=0;p<t;p++){const v=r.getChannelData(p),g=m.getChannelData(p>f?f:p);for(let E=0;E<v.length-1;E++)E<l+d||E>l+u||E-l<0||(v[E]+=(g[E-l]??0)*c.volume,v[E]>1&&(v[E]=1),v[E]<-1&&(v[E]=-1));r.getChannelData(p).set(v)}}catch{}}return r}time(t){const o=Rn(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(o).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const o=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),o!=null&&o>=0)return this.tracks.splice(o,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/yo;let o=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-o<t-i||(i=Math.min(t,i+r-o-t),o=r,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 o;return((o=t.stop)==null?void 0:o.frames)??0}),0),this.computeFrame()}}function Mh(a,n){const t=new Uint8Array(19);return t[0]=79,t[1]=112,t[2]=117,t[3]=115,t[4]=72,t[5]=101,t[6]=97,t[7]=100,t[8]=1,t[9]=n,t[10]=0,t[11]=0,t[12]=a&255,t[13]=a>>8&255,t[14]=a>>16&255,t[15]=a>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Pi=[8e3,12e3,16e3,24e3,48e3],Bh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",Fh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class Ih{constructor(n){L(this,"output");L(this,"error");L(this,"config");L(this,"encoder");L(this,"opus");L(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(Fh),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Pi.includes(i))throw new fa({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Pi.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?Bh:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:Mh(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new fa({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let c=0;const l=s/i*1e6;for(;c<t;){const d=n.subarray(c*r,(c+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const m=4e3,f=this.opus._malloc(m),p=this.opus._opus_encode(this.encoder,u,s,f,m);if(p>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(f,f+p));this.output({data:v,timestamp:o,type:"key",duration:l},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(f),c+=s,o+=l}}}function Rh(a){const n=Pi;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class $h{constructor(n,t){L(this,"canvas");L(this,"muxer");L(this,"videoEncoder");L(this,"frame",0);L(this,"sampleRate");L(this,"numberOfChannels");L(this,"videoBitrate");L(this,"gpuBatchSize");L(this,"fps");L(this,"height");L(this,"width");L(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=Rh((t==null?void 0:t.sampleRate)??48e3),this.numberOfChannels=(t==null?void 0:t.numberOfChannels)??2,this.videoBitrate=(t==null?void 0:t.videoBitrate)??1e7,this.gpuBatchSize=(t==null?void 0:t.gpuBatchSize)??5,this.audio=(t==null?void 0:t.audio)??!1}async init(){const n=await Nf({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Fl({target:new ar,video:{...n[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(o,i)=>{i&&this.muxer.addVideoChunk(o,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var o;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(n??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(o=this.videoEncoder)==null||o.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new fa({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=Cf(n,this.sampleRate,this.numberOfChannels),o=new Ih({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await o.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),o.encode({data:Sf(t),numberOfFrames:t.length})}async blob(){var t,o,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(o=this.muxer)==null||o.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new fa({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([n],{type:"video/mp4"})}async export(){return this.blob()}}async function Dh(a){var o,i;const n=(o=a.metadata)==null?void 0:o.source_url;if(n)return n;const t=(i=a.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}function Mt(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Wo(a){return a>5?a/100:a}function Bt(a,n,t){return Math.min(t,Math.max(n,a))}function yt(){return new Ye.ColorMatrixFilter}function Uh(a,n){switch(a){case"brightness":{const t=yt(),o=Mt(n.value??n.brightness,1);return t.brightness(Bt(Wo(o),0,5),!1),t}case"contrast":{const t=yt(),o=Mt(n.value??n.contrast,1);return t.contrast(Bt(Wo(o),0,5),!1),t}case"saturation":{const t=yt(),o=Mt(n.value??n.saturation,1);return t.saturate(Bt(Wo(o),0,5),!1),t}case"hue":{const t=yt(),o=Mt(n.degrees??n.value,0);return t.hue(Bt(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=Mt(n.radius??n.blur??n.value,t);return new Ye.BlurFilter({strength:Bt(o,0,32),quality:4})}case"grayscale":{const t=yt(),o=Bt(Mt(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=yt();return o.sepia(!1),o}case"invert":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=yt();return o.negative(!1),o}case"warmth":{const t=yt(),o=Bt(Mt(n.value,0),-50,50);return o>0?(t.sepia(!1),t.saturate(1+o/100,!1)):o<0&&t.hue(Math.abs(o)/50*-20,!1),t}case"tint":{const t=yt(),o=Bt(Mt(n.intensity,.3),0,1),i=typeof n.color=="string"?n.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,c=parseInt(r.slice(2,4),16)/255,l=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1,0]}return t}case"vintage":{const t=yt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=yt(),o=Bt(Wo(Mt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=yt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=yt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=yt();return t.brightness(1.05,!1),t.saturate(.9,!1),t.contrast(.95,!1),t}default:return null}}typeof window<"u"&&!window.PIXI&&(window.PIXI=Ye);class Hl{constructor(n=1920,t=1080,o=30,i){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=o,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new Th({width:n,height:t,background:"#000000"}),this.initPromise=new Promise(r=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),r()};this.composition.on("init",s),queueMicrotask(()=>{var l,d,u,m;const c=this.composition;((d=(l=c==null?void 0:c.app)==null?void 0:l.renderer)!=null&&d.view||(u=c==null?void 0:c.renderer)!=null&&u.view||(m=c==null?void 0:c.renderer)!=null&&m.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...n){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await Dh(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(n,t){var o,i;try{const r=n.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((o=gn.from)==null?void 0:o.call(gn,r,{crossOrigin:"anonymous"}))??await gn.from(r),c=new Li(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let l=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const f=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),p=n.sourceOut!==void 0?Math.max(f+1,Math.floor(n.sourceOut*this.fps)):null;l=f,d=p;try{if(c.offset=c.offset||{frames:0},c.offset.frames=f,p!==null){const v=Math.max(1,p-f);c.duration=c.duration||{frames:v},c.duration.frames=v}}catch{}}const u=await this.composition.add(c);if(d!==null&&l>=0)try{const f=Math.max(1,d-l);u.offset=u.offset||{frames:0},u.offset.frames=l,u.duration=u.duration||{frames:f},u.duration.frames=f}catch{}const m=Math.floor(n.timelineStart*this.fps);m>0&&u.offsetBy(m),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(f=>requestAnimationFrame(f)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=ut.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new Pn({text:n.content,font:t,fontSize:n.fontSize||34,position:n.position||"center",fillStyle:n.color||"#FFFFFF",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"});if(n.animation){const r=n.animation.duration||1,s=0,c=r*this.fps,l=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Ve([s,c],[n.animation.rotation.from,n.animation.rotation.to],{easing:l}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Ve([s,c],[n.animation.scale.from,n.animation.scale.to],{easing:l}))}n.startTime&&n.startTime>0&&o.offsetBy(n.startTime*this.fps),n.duration&&o.subclip(0,n.duration*this.fps);const i=await this.composition.add(o);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(l=>l.id));for(const[l,d]of i.entries())if(!r.has(l)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(l)}const s=[];for(const l of t){const d=this.buildFilterSignature(l),u=i.get(l.id);let m=null;if(u&&u.signature===d)m=u.instance;else{if(u)try{u.instance.destroy()}catch{}m=this.createPixiFilter(l),m?i.set(l.id,{instance:m,signature:d}):i.delete(l.id)}m&&s.push(m)}this.filterCache.set(n,i);const c=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(c&&"filters"in c)try{c.filters=s}catch{}typeof o.enter=="function"&&o.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:n.filterId,intensity:n.intensity??1,params:o})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,o=n.params||{};if(ct.getFilter(n.filterId)&&!ct.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=Xd(n.filterId,o);return r||(r=Uh(n.filterId,o)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!o.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(n={}){var s,c,l,d,u,m,f,p,v;const t=n.fps??this.fps,o=this.composition.canvas??((c=(s=this.composition)==null?void 0:s.renderer)==null?void 0:c.view)??((u=(d=(l=this.composition)==null?void 0:l.app)==null?void 0:d.renderer)==null?void 0:u.view)??((f=(m=this.composition)==null?void 0:m.renderer)==null?void 0:f.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(p=n.onProgress)==null||p.call(n,0);const i=new $h(o,{fps:t});await i.init();const r=await i.export();return(v=n.onProgress)==null||v.call(n,100),r}destroy(){if(this.stopRenderLoop(),this.composition.pause(),this.clips.clear(),this.clipTimelineStart.clear(),this.filterCache.clear(),this.player&&this.composition.detachPlayer(this.player),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}this.player=null}startRenderLoop(){this.stopRenderLoop(),this.isDebug()&&this.dbg("renderLoop:start");const n=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(n)};n()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(n,t),this.composition.computeFrame())}setFitMode(n){this.fitMode=n,this.applyFitModeToClips()}applyFitModeToClips(){for(const n of this.clips.values())"scale"in n&&typeof n.scale<"u"&&this.applyFitToClip(n);this.composition.computeFrame()}applyFitToClip(n){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=n.source,c=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),l=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!c||!l)return;const d=Math.min(i/c,r/l),u=Math.max(i/c,r/l),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,c=Math.floor(s*this.fps),l=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=c+l;if(n>=c&&n<d){const u=n-c;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const Ah=["src"],Oh={class:"preview-controls"},Lh=["aria-label"],zh={class:"time-display"},Ph={class:"current-time"},jh={class:"total-time"},Wh={key:2,class:"loading-overlay"},Zh={key:3,class:"error-overlay"},Xh=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(),s=e.ref(),c=e.ref(!1),l=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),m=e.ref(0),f=e.ref(0);let p=null;const v=e.computed(()=>!!t.enableEngine&&!!t.recipe),g=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),E=e.computed(()=>{var k,B;return(k=t.media)!=null&&k.url?t.media.url:(((B=t.media)==null?void 0:B.file)instanceof File,"")});async function T(){var k,B,R;if(!(!r.value||!t.recipe))try{c.value=!0,l.value="Initializing video engine...";const U=((k=t.recipe.source)==null?void 0:k.original_width)||1920,_=((B=t.recipe.source)==null?void 0:B.original_height)||1080,z=((R=t.recipe.output)==null?void 0:R.fps)||30;p=new Hl(U,_,z,{fitMode:t.fitMode}),p.attachPlayer(r.value),l.value="Loading composition...",await p.loadFromRecipe(t.recipe),f.value=p.durationInSeconds,o("duration-change",f.value),N(),c.value=!1,o("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(U){const _=U instanceof Error?U.message:String(U);d.value=`Failed to initialize: ${_}`,c.value=!1}}function N(){if(!p)return;const k=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,o("time-update",m.value))},100);A.value=k}function w(){v.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,o("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,o("play-state-change",u.value))}function h(k){const B=Math.floor(k/60),R=Math.floor(k%60);return`${B}:${R.toString().padStart(2,"0")}`}function x(){d.value=null,v.value&&T()}function D(){!v.value&&s.value&&(f.value=s.value.duration,o("duration-change",f.value))}function C(){!v.value&&s.value&&(m.value=s.value.currentTime,o("time-update",m.value))}function y(){u.value=!1,o("play-state-change",!1)}function S(k){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&T()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),A.value&&(clearInterval(A.value),A.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(p)try{await p.loadFromRecipe(k),f.value=p.durationInSeconds,o("duration-change",f.value)}catch{}else await T()}),e.watch(()=>t.enableEngine,async k=>{k?await T():p&&(A.value&&(clearInterval(A.value),A.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!v.value||!p))try{p.setFitMode(k||"contain")}catch{}});const A=e.ref(null);return(k,B)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[v.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:r,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:E.value,onLoadedmetadata:D,onTimeupdate:C,onEnded:y,onError:S,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,Ah)),e.createElementVNode("div",Oh,[e.createElementVNode("button",{class:"play-button",onClick:w,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.value?e.unref(ul):e.unref(pl)},null,8,["icon"])],8,Lh),e.createElementVNode("div",zh,[e.createElementVNode("span",Ph,e.toDisplayString(h(m.value)),1),B[0]||(B[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",jh,e.toDisplayString(h(f.value)),1)])]),c.value?(e.openBlock(),e.createElementBlock("div",Wh,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(l.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Zh,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:x},"Retry")])):e.createCommentVNode("",!0)],512))}}),Bs=Be(Xh,[["__scopeId","data-v-7e604791"]]),Hh=["aria-label"],Gh=["aria-label"],Jh={class:"clip-content"},Yh={key:0,class:"clip-thumbnail"},Kh=["src","alt"],qh={class:"clip-waveform"},Qh={class:"clip-info"},ev={class:"clip-label"},tv={class:"clip-duration"},nv={key:1,class:"filter-indicators"},ov={key:2,class:"speed-indicator"},av={key:0,class:"selection-overlay"},iv=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref(null),c=e.ref(0),l=e.ref(0),d=e.computed(()=>{const S=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${S}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),m=e.computed(()=>{const y=t.clip.timelineEnd-t.clip.timelineStart;return v(y)}),f=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),p=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 S=Math.floor(y/60),A=Math.floor(y%60);return`${S}:${A.toString().padStart(2,"0")}`}}function g(y){return!y||typeof y!="string"?cs:y.includes("color")||y.includes("brightness")?sn:y.includes("blur")?xu:y.includes("style")?oo:y.includes("effect")?rn:cs}function E(){r.value||o("select")}function T(y){y.button===0&&(h("move",y.clientX),y.preventDefault())}function N(y){if(y.touches.length!==1)return;const S=y.touches[0];h("move",S.clientX),y.preventDefault()}function w(y,S){const A="touches"in S?S.touches[0].clientX:S.clientX;s.value=y==="start"?"trim-start":"trim-end",h(s.value,A),S.preventDefault(),S.stopPropagation()}function h(y,S){r.value=!0,s.value=y,c.value=S,y==="move"?l.value=t.clip.timelineStart:y==="trim-start"?l.value=t.clip.sourceIn:y==="trim-end"&&(l.value=t.clip.sourceOut),document.addEventListener("mousemove",x),document.addEventListener("mouseup",D),document.addEventListener("touchmove",x),document.addEventListener("touchend",D),t.selected||o("select")}function x(y){if(!r.value||!s.value)return;const S="touches"in y?y.touches[0].clientX:y.clientX,k=S-c.value;s.value==="move"?(o("drag",k),o("drag-abs",S)):s.value==="trim-start"?(o("trim-start",k),o("trim-start-abs",S)):s.value==="trim-end"&&(o("trim-end",k),o("trim-end-abs",S))}function D(){r.value=!1,s.value=null,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",D),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",D)}function C(){if(!i.value)return;const y=i.value,S=y.getContext("2d");if(!S)return;y.width=y.clientWidth*window.devicePixelRatio,y.height=y.clientHeight*window.devicePixelRatio,S.scale(window.devicePixelRatio,window.devicePixelRatio),S.strokeStyle="rgba(255, 255, 255, 0.3)",S.lineWidth=1,S.beginPath();const A=y.clientWidth,k=y.clientHeight,B=k/2;S.moveTo(0,B),S.lineTo(A,B);for(let R=0;R<A;R+=4){const U=Math.sin(R*.05)*(k*.3);S.moveTo(R,B-U),S.lineTo(R,B+U)}S.stroke()}return e.onMounted(()=>{C(),window.addEventListener("resize",C)}),e.onUnmounted(()=>{D(),window.removeEventListener("resize",C)}),(y,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:y.selected,mobile:y.isMobile,"has-filters":f.value}]),style:e.normalizeStyle(d.value),onClick:E,onMousedown:T,onTouchstart:N},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:S[0]||(S[0]=e.withModifiers(A=>w("start",A),["stop"])),onTouchstart:S[1]||(S[1]=e.withModifiers(A=>w("start",A),["stop"])),"aria-label":`Trim start of ${y.clip.label||"clip"}`},[...S[4]||(S[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Hh),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:S[2]||(S[2]=e.withModifiers(A=>w("end",A),["stop"])),onTouchstart:S[3]||(S[3]=e.withModifiers(A=>w("end",A),["stop"])),"aria-label":`Trim end of ${y.clip.label||"clip"}`},[...S[5]||(S[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Gh),e.createElementVNode("div",Jh,[y.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Yh,[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:i},null,512)]),e.createElementVNode("div",Qh,[e.createElementVNode("span",ev,e.toDisplayString(u.value),1),e.createElementVNode("span",tv,e.toDisplayString(m.value),1)]),f.value?(e.openBlock(),e.createElementBlock("div",nv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,A=>(e.openBlock(),e.createBlock(e.unref(I.IonIcon),{key:A.id||A.filterId,icon:g(A.filterId||A.id),title:`Filter: ${A.filterId||A.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),y.clip.speed&&y.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",ov,e.toDisplayString(y.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),y.selected?(e.openBlock(),e.createElementBlock("div",av)):e.createCommentVNode("",!0)],38))}}),rv=Be(iv,[["__scopeId","data-v-943b6167"]]);class Gl{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Li(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await gn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=we.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,c;i instanceof Li&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((c=i.source)==null?void 0:c.objectURL)||""))}),t}applyTransformations(n,t){(t.x!==void 0||t.y!==void 0)&&(n.x=t.x||0,n.y=t.y||0),t.rotation!==void 0&&(n.rotation=t.rotation),t.opacity!==void 0&&(n.alpha=t.opacity),t.scale!==void 0&&(n.scale={x:t.scale,y:t.scale})}secondsToFrames(n){return Math.round(n*this.fps)}framesToSeconds(n){return n/this.fps}framesToTime(n){const t=this.framesToSeconds(n),o=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),o=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return o}timeToFrames(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return this.secondsToFrames(o)}}const sv={class:"time-markers"},lv=["aria-label","title"],cv={key:0,class:"timeline-scrollbar"},dv=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(a,{emit:n}){const t=a,o=e.computed(()=>t.isMobile===!0),i=n,r=e.ref(),s=e.ref(t.selectedClipId||null),c=e.ref(!1),l=e.ref(0),d=e.ref(),u=e.ref(0),m=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,K=>{K!==void 0&&(s.value=K)});const f=new Gl(t.fps),p=e.ref(!1),v=e.ref(null),g=e.ref(0),E=e.ref(0),T=e.ref(0),N=e.ref(0),w=e.ref(0),h=e.ref(!1),x=e.ref(0),D=e.ref(t.zoomLevel),C=e.computed(()=>t.zoomLevel);function y(K){const de=t.clips.find(he=>he.id===K);if(!de)return null;const ie=t.clips.filter(he=>he.id!==K&&he.timelineStart>=de.timelineEnd-1e-9).map(he=>he.timelineStart);return ie.length?Math.min(...ie):null}function S(K){const de=K.sourceMaxOut??t.duration,ie=K.timelineStart+(de-K.sourceIn),he=y(K.id),_e=he!=null?Math.max(K.timelineStart,he):1/0;return Math.min(ie,_e)}function A(K){const de=K.sourceMinIn??0,he=(K.sourceMaxOut??t.duration)-de,_e=K.sourceIn-de;return{left:`${(K.timelineStart-_e)*C.value-l.value}px`,width:`${he*C.value}px`,top:"0px",height:"80px",opacity:m.value===K.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),B=e.computed(()=>f.secondsToFrames(t.duration)),R=e.computed(()=>t.useFrameMode?B.value*k.value:t.duration*C.value),U=e.computed(()=>{var K;return u.value||((K=r.value)==null?void 0:K.clientWidth)||800}),_=e.computed(()=>R.value>U.value),z=e.computed(()=>Math.max(0,R.value-U.value)),H=e.computed(()=>l.value>0),M=e.computed(()=>l.value<z.value),$=e.computed(()=>t.useFrameMode?f.secondsToFrames(t.playhead)*k.value-l.value:t.playhead*C.value-l.value),X=e.computed(()=>{const K=Math.max(50,U.value/R.value*U.value),de=l.value/z.value*(U.value-K);return{width:`${K}px`,left:`${de}px`}}),W=e.computed(()=>{const K=[],de=te();for(let ie=0;ie<=t.duration;ie+=de){const he=ie*C.value-l.value;he>=-50&&he<=U.value+50&&K.push({position:he,label:ge(ie),time:ie})}return K});function te(){const de=80/C.value;return de<=1?1:de<=5?5:de<=10?10:de<=30?30:de<=60?60:Math.ceil(de/60)*60}function ge(K){if(t.useFrameMode)return`F${f.secondsToFrames(K)}`;{const de=Math.floor(K/60),ie=Math.floor(K%60),he=Math.floor(K%1*t.fps);return C.value>100?`${de}:${ie.toString().padStart(2,"0")}:${he.toString().padStart(2,"0")}`:`${de}:${ie.toString().padStart(2,"0")}`}}function Ne(K){const de=r.value.getBoundingClientRect();let he=(K.clientX-de.left+l.value)/C.value;const _e=t.clips.find(J=>he>=J.timelineStart&&he<=J.timelineEnd);if(_e)he=Math.max(_e.timelineStart,Math.min(_e.timelineEnd,he));else if(t.selectedClipId){const J=t.clips.find(ue=>ue.id===t.selectedClipId);if(J){const ue=Math.abs(he-J.timelineStart),ve=Math.abs(he-J.timelineEnd);he=ue<ve?J.timelineStart:J.timelineEnd}}else he=Math.max(0,Math.min(he,t.duration));i("update:playhead",he)}function ee(K){if(!_.value)return;const de=Math.abs(K.deltaX)>Math.abs(K.deltaY)?K.deltaX:K.deltaY;de!==0&&(K.preventDefault(),l.value=Math.max(0,Math.min(z.value,l.value+de)))}function F(K){if(K.touches.length===2){h.value=!0;const de=K.touches[0],ie=K.touches[1];x.value=Math.hypot(ie.clientX-de.clientX,ie.clientY-de.clientY),D.value=t.zoomLevel}else K.touches.length===1&&(T.value=K.touches[0].clientX,N.value=K.touches[0].clientY,w.value=T.value)}function P(K){if(h.value&&K.touches.length===2){const de=K.touches[0],ie=K.touches[1],_e=Math.hypot(ie.clientX-de.clientX,ie.clientY-de.clientY)/x.value;Math.max(10,Math.min(200,D.value*_e)),i("update:playhead",t.playhead)}else if(K.touches.length===1&&!h.value){const de=K.touches[0],ie=w.value-de.clientX;Math.abs(ie)>Math.abs(de.clientY-N.value)&&(K.preventDefault(),l.value=Math.max(0,Math.min(R.value-U.value,l.value+ie)),w.value=de.clientX)}}function pe(){h.value=!1}function ne(K){const de=K.target;if(de.closest(".playhead-handle"))return;const ie=K.button===1,he=!!de.closest(".video-track");(ie||!he&&_.value)&&Y(K)}function Y(K){p.value=!0,v.value="pan",g.value=K.clientX,E.value=l.value,document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke)}function Me(K){K.preventDefault(),K.stopPropagation(),p.value=!0,v.value="playhead";const de="touches"in K?K.touches[0].clientX:K.clientX;g.value=de,E.value=t.playhead,"touches"in K?(document.addEventListener("touchmove",se),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke))}function ce(K){K.preventDefault(),K.stopPropagation(),p.value=!0,v.value="scrollbar";const de="touches"in K?K.touches[0].clientX:K.clientX;g.value=de,E.value=l.value,"touches"in K?(document.addEventListener("touchmove",se),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",ke))}function se(K){if(!p.value)return;const ie=("touches"in K?K.touches[0].clientX:K.clientX)-g.value;if(v.value==="playhead"){const he=ie/C.value;let _e=E.value+he;if(t.selectedClipId){const J=t.clips.find(ue=>ue.id===t.selectedClipId);J?_e=Math.max(J.timelineStart,Math.min(J.timelineEnd,_e)):_e=Math.max(0,Math.min(t.duration,_e))}else{const J=t.clips.find(ue=>t.playhead>=ue.timelineStart&&t.playhead<=ue.timelineEnd);J?_e=Math.max(J.timelineStart,Math.min(J.timelineEnd,_e)):_e=Math.max(0,Math.min(t.duration,_e))}i("update:playhead",_e)}else if(v.value==="scrollbar"){const he=ie/U.value*R.value;l.value=Math.max(0,Math.min(z.value,E.value+he))}else if(v.value==="pan"){const he=E.value-ie;l.value=Math.max(0,Math.min(z.value,he))}}function ke(){p.value=!1,v.value=null,document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ke),document.removeEventListener("touchmove",se),document.removeEventListener("touchend",ke)}function oe(K){s.value=s.value===K?null:K,i("clip-select",s.value)}function le(K,de){const ie=t.clips.find(_e=>_e.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity;if(t.useFrameMode){const _e=f.secondsToFrames(ie.sourceIn),J=f.secondsToFrames(he),ue=Math.max(0,_e+J),ve=f.framesToSeconds(ue);i("trim",K,"start",ve)}else{const _e=Math.max(0,ie.sourceIn+he);i("trim",K,"start",_e)}}function Ee(K,de){const ie=t.clips.find(ae=>ae.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),_e=de-he.left,J=80;if(_e<J)l.value=Math.max(0,l.value-8);else if(_e>he.width-J){const ae=Math.max(0,R.value-U.value);l.value=Math.min(ae,l.value+8)}const ue=_e+l.value,ve=1/t.fps;let Z=ue/C.value;Z=Math.max(0,Math.min(Z,ie.timelineEnd-ve));let Q=ie.sourceIn+(Z-ie.timelineStart);Q=Math.round(Q*t.fps)/t.fps,i("trim",K,"start",Q)}function Se(K,de){const ie=t.clips.find(xe=>xe.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),_e=de-he.left,J=80;if(_e<J)l.value=Math.max(0,l.value-8);else if(_e>he.width-J){const xe=Math.max(0,R.value-U.value);l.value=Math.min(xe,l.value+8)}const ue=_e+l.value,ve=1/t.fps,Z=S(ie);let Q=ue/C.value;Q=Math.max(ie.timelineStart+ve,Math.min(Q,Z));let ae=ie.sourceIn+(Q-ie.timelineStart);ae=Math.round(ae*t.fps)/t.fps,i("trim",K,"end",ae)}function rt(K,de){const ie=t.clips.find(Z=>Z.id===K);if(!ie||!r.value)return;const he=r.value.getBoundingClientRect(),J=de-he.left+l.value,ue=ie.timelineEnd-ie.timelineStart;let ve=J/C.value;ve=Math.max(0,Math.min(ve,t.duration-ue)),ve=Math.round(ve*t.fps)/t.fps,i("clip-move",K,ve)}function He(K,de){const ie=t.clips.find(J=>J.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity,_e=J=>Math.max(0,Math.round(J*t.fps)/t.fps);if(t.useFrameMode){const J=f.secondsToFrames(ie.sourceOut),ue=f.secondsToFrames(he),ve=S(ie),Z=ie.sourceIn+(ve-ie.timelineStart),Q=f.secondsToFrames(Z),ae=Math.min(Q,J+ue),xe=f.framesToSeconds(ae);i("trim",K,"end",xe)}else{const J=S(ie),ue=ie.sourceIn+(J-ie.timelineStart),ve=Math.min(ue,ie.sourceOut+he),Z=_e(ve);i("trim",K,"end",Z)}}function pt(K,de){const ie=t.clips.find(J=>J.id===K);if(!ie||Math.abs(de)<2)return;const he=de/C.value*t.sensitivity,_e=J=>Math.max(0,Math.round(J*t.fps)/t.fps);if(t.useFrameMode){const J=f.secondsToFrames(ie.timelineStart),ue=f.secondsToFrames(he),ve=Math.max(0,J+ue),Z=f.framesToSeconds(ve);i("clip-move",K,Z)}else{const J=Math.max(0,ie.timelineStart+he),ue=_e(J);i("clip-move",K,ue)}}return e.watch(()=>t.playhead,K=>{const de=K*C.value;de<l.value+50?l.value=Math.max(0,de-50):de>l.value+U.value-50&&(l.value=Math.min(z.value,de-U.value+50))}),e.onMounted(()=>{const K=new ResizeObserver(de=>{de[0]&&(u.value=Math.round(de[0].contentRect.width))});r.value&&K.observe(r.value),e.onUnmounted(()=>K.disconnect())}),e.onUnmounted(()=>{ke()}),e.watch([R,U],()=>{l.value>z.value&&(l.value=z.value)}),(K,de)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:o.value}]),ref_key:"timelineRef",ref:r,onWheel:ee},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Ne},[e.createElementVNode("div",sv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,ie=>(e.openBlock(),e.createElementBlock("span",{key:ie.position,class:"time-marker",style:e.normalizeStyle({left:`${ie.position}px`})},e.toDisplayString(ie.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":_.value,"is-panning":p.value&&v.value==="pan","overflow-left":H.value,"overflow-right":M.value}]),onTouchstart:F,onTouchmove:P,onTouchend:pe,onMousedown:ne},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.clips,ie=>(e.openBlock(),e.createElementBlock("div",{key:`${ie.id}-extent`,class:"clip-extent",style:e.normalizeStyle(A(ie)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.clips,ie=>(e.openBlock(),e.createBlock(rv,{key:ie.id,clip:ie,scale:C.value,"scroll-offset":l.value,selected:m.value===ie.id,"is-mobile":o.value,onSelect:he=>oe(ie.id),onTrimStart:he=>le(ie.id,he),onTrimEnd:he=>He(ie.id,he),onDrag:he=>pt(ie.id,he),onTrimStartAbs:he=>Ee(ie.id,he),onTrimEndAbs:he=>Se(ie.id,he),onDragAbs:he=>rt(ie.id,he)},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:`${$.value}px`}),onMousedown:Me,onTouchstart:Me},[...de[1]||(de[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${$.value}px`})},null,4)):e.createCommentVNode("",!0),o.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:de[0]||(de[0]=ie=>K.$emit("toggle-frame-mode")),"aria-label":K.useFrameMode?"Switch to time mode":"Switch to frame mode",title:K.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(K.useFrameMode?"F":"T"),9,lv))],34),_.value?(e.openBlock(),e.createElementBlock("div",cv,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(X.value),onMousedown:ce,onTouchstart:ce},null,36)])):e.createCommentVNode("",!0)],34))}}),Fs=Be(dv,[["__scopeId","data-v-6fa3968c"]]),uv={class:"control-group zoom-controls"},mv={class:"zoom-slider"},pv=["value"],fv={class:"control-group playback-controls"},hv=["aria-label"],vv={key:0,class:"control-group speed-control"},gv=["value"],yv=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(a,{emit:n}){const t=n;function o(u){const m=u.target;t("zoom-change",Number(m.value))}function i(){t("fit-to-window")}function r(){t("frame-forward")}function s(){t("frame-backward")}function c(){t("skip-to-start")}function l(){t("skip-to-end")}function d(u){const m=u.target;t("speed-change",Number(m.value))}return(u,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",uv,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=f=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Uu)},null,8,["icon"])]),e.createElementVNode("div",mv,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:o,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,pv)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=f=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ku)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",fv,[e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to start"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($u)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Bu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=f=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.isPlaying?e.unref(ml):e.unref(fl)},null,8,["icon"])],8,hv),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ru)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to end"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Du)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",vv,[m[5]||(m[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...m[4]||(m[4]=[e.createStaticVNode('<option value="0.25" data-v-7bf65ab9>0.25x</option><option value="0.5" data-v-7bf65ab9>0.5x</option><option value="1" data-v-7bf65ab9>1x</option><option value="1.5" data-v-7bf65ab9>1.5x</option><option value="2" data-v-7bf65ab9>2x</option>',5)])],40,gv)]))],2))}}),wv=Be(yv,[["__scopeId","data-v-7bf65ab9"]]),bv={key:0,class:"category-section"},kv={class:"category-carousel-wrapper"},xv=["disabled"],Ev=["onClick","data-testid","aria-label"],Vv={class:"category-name"},Sv=["disabled"],Cv={class:"filter-section"},Nv={class:"filter-carousel-wrapper"},_v=["disabled"],Tv=["onClick","onKeydown","data-testid","aria-label"],Mv=["onClick"],Bv={class:"filter-preview"},Fv={class:"filter-placeholder"},Iv={class:"filter-name"},Rv=["disabled"],$v={class:"carousel-pagination"},Dv=["onClick"],Uv={key:1,class:"filter-adjustments"},Av={class:"adjustment-header"},Ov={class:"adjustment-actions"},Lv={key:0},zv={key:0,class:"slider-control"},Pv={class:"control-label"},jv={class:"slider-wrapper"},Wv={class:"slider-value"},Zv={key:1,class:"color-control"},Xv={class:"control-label"},Hv={class:"color-wrapper"},Gv=["value","onInput","disabled"],Jv={class:"color-value"},Yv={key:2,class:"toggle-control"},Kv={class:"control-label"},qv={key:3,class:"select-control"},Qv={class:"control-label"},e0=["value","onChange","disabled"],t0=["value"],n0={key:1,class:"no-params"},o0=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),c=e.ref(0),l=e.ref(new Map),d=e.ref(),u=e.ref(),m={all:rn,adjust:Kn,color:sn,blur:Oo,light:qn,effects:di,stylize:oo,advanced:rn,distortion:ao,transform:ao};function f(M){return M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(M){return M.replace(/[-_]/g," ").replace(/\b\w/g,$=>$.toUpperCase())}function v(M){return m[M.toLowerCase()]??rn}const g=e.computed(()=>{const M=Array.from(new Set(t.filters.map($=>$.category).filter($=>typeof $=="string"&&$.length>0))).sort(($,X)=>$.localeCompare(X));return[{id:"all",name:"All",icon:rn},...M.map($=>({id:$,name:p($),icon:v($)}))]}),E=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(M=>M.category===i.value));e.watch(g,M=>{new Set(M.map(W=>W.id)).has(i.value)||(i.value="all");const X=Math.max(0,M.length-3);s.value>X&&(s.value=X)},{immediate:!0});function T(M){var $;return(($=t.activeFilters)==null?void 0:$.has(M))||!1}function N(M){if(r.value=M,!T(M.id)&&(o("apply-filter",M),M.params&&M.params.length>0)){const $=new Map;M.params.forEach(X=>{$.set(X.id,X.default)}),l.value.set(M.id,$)}o("preview-filter",M)}function w(M){var $;o("remove-filter",M),l.value.delete(M),(($=r.value)==null?void 0:$.id)===M&&(r.value=null)}function h(M){if(typeof M=="number"&&Number.isFinite(M))return M;if(typeof M=="string"){const $=Number(M);return Number.isFinite($)?$:null}return null}function x(M,$){var F;const X=t.filters.find(P=>P.id===M),W=X==null?void 0:X.params.find(P=>P.id===$),te=(W==null?void 0:W.default)??0,ge=P=>typeof te=="number"?h(P)??te:typeof te=="boolean"?typeof P=="boolean"?P:te:typeof P=="string"?P:te,Ne=(F=t.activeFilters)==null?void 0:F.get(M);if(Ne&&Ne.params){const P=Ne.params[$];if(P!=null)return ge(P)}const ee=l.value.get(M);if(ee){const P=ee.get($);if(P!=null)return ge(P)}return te}function D(M,$,X){var W;l.value.has(M)||l.value.set(M,new Map),(W=l.value.get(M))==null||W.set($,X),o("update-param",M,$,X)}function C(M){if(typeof M=="boolean")return M?"On":"Off";if(typeof M=="string"){const X=h(M);return X===null?"0":Number.isInteger(X)?X.toString():X.toFixed(2)}const $=h(M);return $===null?"0":Number.isInteger($)?$.toString():$.toFixed(2)}function y(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const M=new Map;r.value.params.forEach($=>{M.set($.id,$.default)}),l.value.set(r.value.id,M)}}function S(M){const $=t.filters.find(X=>X.id===M);$&&$.params&&$.params.forEach(X=>{D(M,X.id,X.default)})}function A(M){return{basic:Kn,color:sn,blur:Oo,light:qn,effects:di,stylize:oo,adjustment:Kn,"color-matrix":sn,glow:rn,distortion:ao}[M]||rn}function k(M){return{adjustment:Kn,brightness:qn,contrast:Kn,saturation:sn,blur:Oo,"gaussian-blur":Oo,"color-matrix":sn,grayscale:oo,sepia:oo,vignette:ao,glow:rn,glitch:di,godray:qn,lightmap:qn}[M.id]||A(M.category)}function B(){s.value>0&&(s.value--,H(d.value,s.value))}function R(){s.value<g.value.length-3&&(s.value++,H(d.value,s.value))}function U(){c.value>0&&(c.value--,H(u.value,c.value))}function _(){c.value<E.value.length-4&&(c.value++,H(u.value,c.value))}function z(M){c.value=M*4,H(u.value,c.value)}function H(M,$){var X;if(M){const W=((X=M.querySelector(".category-chip, .filter-card"))==null?void 0:X.clientWidth)||100;M.scrollTo({left:$*(W+8),behavior:"smooth"})}}return(M,$)=>{var X;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:M.compact}])},[M.showCategories?(e.openBlock(),e.createElementBlock("div",bv,[e.createElementVNode("div",kv,[e.createElementVNode("button",{onClick:B,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(as)},null,8,["icon"])],8,xv),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,W=>(e.openBlock(),e.createElementBlock("button",{key:W.id,onClick:te=>i.value=W.id,class:e.normalizeClass(["category-chip",{active:i.value===W.id}]),"data-testid":`btn-filter-category-${f(W.id)}`,"aria-label":`Filter category ${W.name}`},[e.createVNode(e.unref(I.IonIcon),{icon:W.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",Vv,e.toDisplayString(W.name),1)],10,Ev))),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(is)},null,8,["icon"])],8,Sv)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Cv,[e.createElementVNode("div",Nv,[e.createElementVNode("button",{onClick:U,class:"carousel-nav carousel-nav-left",disabled:c.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(as)},null,8,["icon"])],8,_v),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,W=>{var te;return e.openBlock(),e.createElementBlock("div",{key:W.id,class:e.normalizeClass(["filter-card",{active:T(W.id),selected:((te=r.value)==null?void 0:te.id)===W.id}]),onClick:ge=>N(W),onKeydown:[e.withKeys(ge=>N(W),["enter"]),e.withKeys(e.withModifiers(ge=>N(W),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${f(W.id)}`,"aria-label":`Select filter ${W.name}`},[T(W.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ge=>w(W.id),["stop"])},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ll)},null,8,["icon"])],8,Mv)):e.createCommentVNode("",!0),e.createElementVNode("div",Bv,[e.createElementVNode("div",Fv,[e.createVNode(e.unref(I.IonIcon),{icon:k(W),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",Iv,e.toDisplayString(W.name),1)],42,Tv)}),128))],512),e.createElementVNode("button",{onClick:_,class:"carousel-nav carousel-nav-right",disabled:c.value>=Math.max(0,E.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(is)},null,8,["icon"])],8,Rv)]),e.createElementVNode("div",$v,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(E.value.length/4),(W,te)=>(e.openBlock(),e.createElementBlock("span",{key:te,class:e.normalizeClass(["pagination-dot",{active:Math.floor(c.value/4)===te}]),onClick:ge=>z(te)},null,10,Dv))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",Uv,[e.createElementVNode("div",Av,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",Ov,[T(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:y,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),T(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:$[0]||($[0]=W=>w(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),T(r.value.id)&&((X=r.value.params)==null?void 0:X.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:$[1]||($[1]=W=>S(r.value.id)),class:"reset-btn","data-testid":"btn-reset-selected-filter"}," Reset ")):e.createCommentVNode("",!0)])]),r.value.params&&r.value.params.length>0?(e.openBlock(),e.createElementBlock("div",Lv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,W=>(e.openBlock(),e.createElementBlock("div",{key:W.id,class:"adjustment-control"},[!W.type||W.type==="slider"?(e.openBlock(),e.createElementBlock("div",zv,[e.createElementVNode("label",Pv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",jv,[e.createVNode(e.unref(I.IonRange),{value:x(r.value.id,W.id),onIonChange:te=>D(r.value.id,W.id,te.detail.value),min:W.min,max:W.max,step:W.step||.01,color:"primary",class:"compact-slider",disabled:!T(r.value.id),"data-testid":`range-filter-${f(r.value.id)}-${f(W.id)}`,"aria-label":`Adjust ${W.label||W.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Wv,e.toDisplayString(C(x(r.value.id,W.id))),1)])])):W.type==="color"?(e.openBlock(),e.createElementBlock("div",Zv,[e.createElementVNode("label",Xv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",Hv,[e.createElementVNode("input",{type:"color",value:x(r.value.id,W.id),onInput:te=>D(r.value.id,W.id,te.target.value),disabled:!T(r.value.id),class:"color-input"},null,40,Gv),e.createElementVNode("span",Jv,e.toDisplayString(x(r.value.id,W.id)),1)])])):W.type==="toggle"?(e.openBlock(),e.createElementBlock("div",Yv,[e.createElementVNode("label",Kv,e.toDisplayString(W.label||W.id),1),e.createVNode(e.unref(I.IonToggle),{checked:!!x(r.value.id,W.id),onIonChange:te=>D(r.value.id,W.id,te.detail.checked),disabled:!T(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):W.type==="select"?(e.openBlock(),e.createElementBlock("div",qv,[e.createElementVNode("label",Qv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("select",{value:x(r.value.id,W.id),onChange:te=>D(r.value.id,W.id,te.target.value),disabled:!T(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.options,te=>(e.openBlock(),e.createElementBlock("option",{key:String(te.value),value:te.value},e.toDisplayString(te.label),9,t0))),128))],40,e0)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",n0," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),a0=Be(o0,[["__scopeId","data-v-9efd15d9"]]);class i0{constructor(n){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=n}setComposition(n){this.composition=n}mapMediablesToPIXI(n){switch(n.filterId){case"blur":return this.createBlurFilter(n.params);case"brightness":return this.createBrightnessFilter(n.params);case"contrast":return this.createContrastFilter(n.params);case"saturation":return this.createSaturationFilter(n.params);case"hue":return this.createHueFilter(n.params);case"vintage":return this.createVintageFilter(n.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.BlurFilter;if(!i)return null;const r=new i;return r.blur=n.intensity||5,r.quality=n.quality||4,r}catch{return null}}createBrightnessFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),n.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const o=this.mapMediablesToPIXI(t);o&&(this.pixiFilters.set(t.id,o),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,o))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const o=this.pixiFilters.get(n);o&&(this.filterParams.set(n,t),"blur"in o&&(o.blur=t.intensity||o.blur),"brightness"in o&&o.brightness(t.value||1,!1),"contrast"in o&&o.contrast(t.value||1,!1),"saturate"in o&&o.saturate(t.value||1,!1),"hue"in o&&o.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(n){return this.filterParams.get(n)||{}}removeFilter(n){var t;this.pixiFilters.delete(n),this.filterParams.delete(n),this.filterTypes.delete(n),this.filterIntensity.delete(n),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(n)}clearFilters(){var n;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(n=this.composition)!=null&&n.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const n=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;n.push({id:o,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const r0={class:"video-filter-preview"},s0={class:"preview-title"},l0={class:"filter-controls"},c0={class:"control-input"},d0=["value","onInput","min","max","step"],u0={class:"param-value"},m0={class:"preview-container"},p0={key:0,class:"filter-presets"},f0=["onClick"],h0={class:"preview-actions"},v0=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let c,l,d=null,u=null;const m=e.computed(()=>{var y;return((y=t.filter)==null?void 0:y.paramRanges)||{}}),f=e.computed(()=>p.value.length>0),p=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(i.value){t.useVideoEngine&&t.composition&&(u=new i0(t.composition));try{if(c=new Ye.Application,await c.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(y=t.currentFrame)!=null&&y.dataUrl){const S=await Ye.Assets.load(t.currentFrame.dataUrl);l=new Ye.Sprite(S);const A=Math.min(c.screen.width/l.texture.width,c.screen.height/l.texture.height);l.scale.set(A),l.anchor.set(.5),l.position.set(c.screen.width/2,c.screen.height/2),c.stage.addChild(l)}g()}catch{}}}function g(){if(!(!l||!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(S=>{}),d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(l.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(l.filters=r.value?null:[d])}function E(y,S){switch(y){case"brightness":{const A=new Ye.ColorMatrixFilter,k=1+(S.value??0);return typeof A.brightness=="function"&&A.brightness(k,!1),A}case"contrast":{const A=new Ye.ColorMatrixFilter,k=S.value??1;return typeof A.contrast=="function"&&A.contrast(k,!1),A}case"saturation":{const A=new Ye.ColorMatrixFilter,k=S.value??1;return typeof A.saturate=="function"&&A.saturate(k,!1),A}case"hue":{const A=new Ye.ColorMatrixFilter,k=S.value??0;return typeof A.hue=="function"&&A.hue(k,!1),A}case"gaussian-blur":{const A=S.value??5;return new Ye.BlurFilter({strength:A,quality:4})}case"sepia":{const A=new Ye.ColorMatrixFilter;return typeof A.sepia=="function"&&A.sepia(!1),A}case"grayscale":{const A=new Ye.ColorMatrixFilter;return typeof A.desaturate=="function"&&A.desaturate(),A}default:return null}}function T(y,S){const A=S.target,k=Number.parseFloat(A.value),B=Number.isFinite(k)?k:0;s.value={...s.value,[y]:B},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),g()}function N(y){return y.charAt(0).toUpperCase()+y.slice(1).replace(/_/g," ")}function w(y,S){var k;const A=typeof y=="number"?y:Number(y);return Number.isFinite(A)?S==="hue"||S==="angle"?`${A}°`:S==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+A)*100)}%`:Number.isInteger(A)?A.toString():A.toFixed(2):"0"}function h(){var y;s.value=((y=t.filter)==null?void 0:y.defaultParams)||{},o("update-params",s.value),g()}function x(y){s.value={...y.params},o("update-params",s.value),g()}function D(y){return JSON.stringify(y.params)===JSON.stringify(s.value)}function C(){o("apply")}return e.watch(()=>t.filter,y=>{y&&(s.value={...y.defaultParams},g())}),e.watch(()=>t.currentFrame,async y=>{if(y!=null&&y.dataUrl&&l){const S=await Ye.Assets.load(y.dataUrl);l.texture=S}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),v()}),e.onUnmounted(()=>{c&&c.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(y,S)=>{var A;return e.openBlock(),e.createElementBlock("div",r0,[e.createElementVNode("h4",s0,e.toDisplayString((A=y.filter)==null?void 0:A.name)+" Settings",1),e.createElementVNode("div",l0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(k,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(N(B)),1),e.createElementVNode("div",c0,[e.createElementVNode("input",{type:"range",value:s.value[B],onInput:R=>T(B,R),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,d0),e.createElementVNode("span",u0,e.toDisplayString(w(s.value[B],B)),1)])]))),128))]),e.createElementVNode("div",m0,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:S[0]||(S[0]=k=>r.value=!0),onMouseup:S[1]||(S[1]=k=>r.value=!1),onTouchstart:S[2]||(S[2]=k=>r.value=!0),onTouchend:S[3]||(S[3]=k=>r.value=!1)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ao)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),f.value?(e.openBlock(),e.createElementBlock("div",p0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.name,class:e.normalizeClass(["preset-button",{active:D(k)}]),onClick:B=>x(k)},e.toDisplayString(k.name),11,f0))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",h0,[e.createElementVNode("button",{class:"action-button",onClick:h},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln)},null,8,["icon"]),S[5]||(S[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:C},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cl)},null,8,["icon"]),S[6]||(S[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),g0=Be(v0,[["__scopeId","data-v-3de3dd04"]]),y0={class:"export-settings"},w0={class:"setting-group"},b0={class:"setting-group"},k0={class:"estimated-size"},x0={key:0,class:"export-progress"},E0={class:"progress-header"},V0={class:"progress-percentage"},S0={class:"progress-time"},C0={class:"action-buttons"},N0=["disabled"],_0=["disabled"],T0=["disabled"],M0={class:"export-options"},B0=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(a,{emit:n}){const t=a,o=n,i=e.ref("1080p"),r=e.ref("mp4"),s=e.ref(!0),c=e.ref(!1),l=e.ref(0),d=e.ref(0),u=e.ref(0);let m=null;const f=e.computed(()=>{const h=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return h<1e3?`~${Math.round(h)} MB`:`~${(h/1e3).toFixed(1)} GB`});function p(){t.isExporting?(o("cancel-export"),E()):v()}function v(){const N={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:c.value};o("export",N),g()}function g(){l.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-l.value)/1e3),t.exportProgress>0){const N=d.value/t.exportProgress*100;u.value=Math.max(0,N-d.value)}},1e3)}function E(){m&&(clearInterval(m),m=null)}function T(N){const w=Math.floor(N/60),h=Math.floor(N%60);return`${w}:${h.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,N=>{N||E()}),e.onUnmounted(()=>{E()}),(N,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:N.isMobile}])},[e.createElementVNode("div",y0,[w[10]||(w[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",w0,[w[7]||(w[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[0]||(w[0]=h=>i.value=h),class:"setting-select"},[...w[6]||(w[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,i.value]])]),e.createElementVNode("div",b0,[w[9]||(w[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[1]||(w[1]=h=>r.value=h),class:"setting-select"},[...w[8]||(w[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,r.value]])]),e.createElementVNode("div",k0,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Su)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(f.value),1)])]),N.isExporting?(e.openBlock(),e.createElementBlock("div",x0,[e.createElementVNode("div",E0,[w[11]||(w[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",V0,e.toDisplayString(N.exportProgress??0)+"%",1)]),e.createVNode(e.unref(I.IonProgressBar),{value:(N.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",S0,[e.createElementVNode("span",null,e.toDisplayString(T(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(T(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",C0,[e.createElementVNode("button",{class:"control-button secondary",onClick:w[2]||(w[2]=h=>N.$emit("save-draft")),disabled:!N.canExport||N.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(er)},null,8,["icon"]),w[12]||(w[12]=e.createTextVNode(" Save Draft ",-1))],8,N0),e.createElementVNode("button",{class:"control-button secondary",onClick:w[3]||(w[3]=h=>N.$emit("reset")),disabled:N.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln)},null,8,["icon"]),w[13]||(w[13]=e.createTextVNode(" Reset ",-1))],8,_0),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!N.canExport&&!N.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(I.IonIcon),{icon:N.isExporting?e.unref(Dn):e.unref(vo)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(N.isExporting?"Cancel":"Export Video"),1)],8,T0)]),e.createElementVNode("div",M0,[e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":w[4]||(w[4]=h=>s.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...w[14]||(w[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:c.value,"onUpdate:modelValue":w[5]||(w[5]=h=>c.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...w[15]||(w[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),F0=Be(B0,[["__scopeId","data-v-e1338d5e"]]),I0={class:"thumbnail-picker"},R0={class:"thumbnail-grid"},$0=["onClick"],D0=["src","alt"],U0={key:1,class:"thumbnail-placeholder"},A0={class:"thumbnail-time"},O0={class:"custom-selector"},L0={class:"time-input-group"},z0=["max"],P0={class:"time-value"},j0=["disabled"],W0={class:"picker-actions"},Z0=["disabled"],X0=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),c=e.ref(!1);function l(){const T=[];if(t.duration<=10)for(let w=0;w<Math.min(9,t.duration);w++)T.push(w);else{const w=t.duration/10;for(let h=1;h<=9;h++)T.push(w*h)}return T}async function d(T){try{const N=document.createElement("video");return N.crossOrigin="anonymous",N.src=await u(),new Promise(w=>{N.addEventListener("loadedmetadata",()=>{N.currentTime=T}),N.addEventListener("seeked",()=>{const h=document.createElement("canvas");h.width=N.videoWidth,h.height=N.videoHeight;const x=h.getContext("2d");x?(x.drawImage(N,0,0),w(h.toDataURL("image/jpeg",.8))):w(null),N.remove()}),N.addEventListener("error",()=>{w(null),N.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 m(){const T=l();i.value=T.map(w=>({time:w,loading:!0}));const N=3;for(let w=0;w<i.value.length;w+=N){const h=i.value.slice(w,w+N);await Promise.all(h.map(async x=>{const D=await d(x.time);D&&(x.dataUrl=D),x.loading=!1}))}}function f(T){r.value=T,s.value=i.value[T].time}function p(){r.value=-1}async function v(){c.value=!0;try{const T=await d(s.value);if(T){const N=i.value.findIndex(w=>Math.abs(w.time-s.value)<.1);N>=0?(i.value[N].dataUrl=T,r.value=N):(i.value.push({time:s.value,dataUrl:T}),r.value=i.value.length-1,i.value.sort((w,h)=>w.time-h.time),r.value=i.value.findIndex(w=>w.time===s.value))}}finally{c.value=!1}}function g(){const T=r.value>=0?i.value[r.value].time:s.value;o("select",T)}function E(T){const N=Math.floor(T/60),w=Math.floor(T%60),h=Math.floor(T%1*100);return N>0?`${N}:${w.toString().padStart(2,"0")}.${h.toString().padStart(2,"0")}`:`${w}.${h.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(T,N)=>(e.openBlock(),e.createElementBlock("div",I0,[N[5]||(N[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",R0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(w,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["thumbnail-item",{selected:r.value===h}]),onClick:x=>f(h)},[w.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.dataUrl,alt:`Frame at ${E(w.time)}`},null,8,D0)):(e.openBlock(),e.createElementBlock("div",U0,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",A0,e.toDisplayString(E(w.time)),1)],10,$0))),128))]),e.createElementVNode("div",O0,[N[3]||(N[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",L0,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":N[0]||(N[0]=w=>s.value=w),min:0,max:T.duration,step:.1,onInput:p,class:"time-slider"},null,40,z0),[[e.vModelText,s.value]]),e.createElementVNode("span",P0,e.toDisplayString(E(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:c.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(pu)},null,8,["icon"]),N[2]||(N[2]=e.createTextVNode(" Capture Frame ",-1))],8,j0)]),e.createElementVNode("div",W0,[e.createElementVNode("button",{class:"action-button",onClick:N[1]||(N[1]=w=>T.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:g,disabled:r.value===-1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cl)},null,8,["icon"]),N[4]||(N[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Z0)])]))}}),H0=Be(X0,[["__scopeId","data-v-336c322c"]]),G0={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},J0={class:"mb-4"},Y0={class:"space-y-2 max-h-64 overflow-y-auto"},K0={class:"flex items-center justify-between"},q0={class:"flex-1"},Q0={class:"font-medium text-gray-900 dark:text-white"},e1={class:"text-sm text-gray-500 dark:text-gray-400"},t1={class:"flex items-center space-x-2"},n1=["onClick"],o1=["onClick"],a1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},i1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},r1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},s1={class:"space-y-4"},l1={class:"grid grid-cols-2 gap-4"},c1={class:"grid grid-cols-2 gap-4"},d1={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},u1={class:"grid grid-cols-2 gap-3"},m1={class:"flex justify-end space-x-3 mt-6"},p1=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function c(f){Object.assign(s,f),i.value=f}function l(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const f={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(f.animation={type:s.animationType},s.animationDuration!==void 0&&(f.animation.duration=s.animationDuration),s.animationEasing&&(f.animation.easing=s.animationEasing),f.animation))switch(s.animationType){case"rotate":f.animation.rotation={from:0,to:360};break;case"scale":f.animation.scale={from:.5,to:1};break;case"slide":f.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,f):t("add-overlay",f),l()}function u(f){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",f)}function m(f){const p=Math.floor(f/60),v=Math.floor(f%60);return`${p}:${v.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",G0,[e.createElementVNode("div",J0,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=v=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-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 Text Overlay ",-1)])])]),e.createElementVNode("div",Y0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.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",K0,[e.createElementVNode("div",q0,[e.createElementVNode("div",Q0,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",e1,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",t1,[e.createElementVNode("button",{onClick:g=>c(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[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,n1),e.createElementVNode("button",{onClick:g=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[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,o1)])])]))),128)),f.overlays.length===0?(e.openBlock(),e.createElementBlock("div",a1," No text overlays added yet ")):e.createCommentVNode("",!0)]),o.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(l,["self"])},[e.createElementVNode("div",i1,[e.createElementVNode("h4",r1,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",s1,[e.createElementVNode("div",null,[p[14]||(p[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":p[1]||(p[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",l1,[e.createElementVNode("div",null,[p[15]||(p[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":p[2]||(p[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,[p[16]||(p[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":p[3]||(p[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,[p[18]||(p[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":p[4]||(p[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"},[...p[17]||(p[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",c1,[e.createElementVNode("div",null,[p[19]||(p[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":p[5]||(p[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,[p[20]||(p[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":p[6]||(p[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,[p[22]||(p[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":p[7]||(p[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"},[...p[21]||(p[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",d1,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",u1,[e.createElementVNode("div",null,[p[23]||(p[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":p[8]||(p[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,[p[25]||(p[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":p[9]||(p[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"},[...p[24]||(p[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",m1,[e.createElementVNode("button",{onClick:l,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(i.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),f1=Be(p1,[["__scopeId","data-v-f86e688c"]]),ho=class ho{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",c=this.findTrackForClip(n),l=this.findTrackForClip(t);if(!c||!l)throw new Error("Clips must be added to composition before applying transitions");const d=n.stop.frames-r,u=n.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(n,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(n,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(n,t,o.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,o.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,o.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,o.type,d,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Ve([o,i],[1,0],{easing:r}),t.alpha=new Ve([o,i],[0,1],{easing:r}),t.start=we.fromFrames(o)}async applyCrossFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Ve([o,i],[1,0],{easing:r}),t.alpha=new Ve([o,i],[0,1],{easing:r}),t.start=we.fromFrames(o)}async applyWipeTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const c={x:0,y:0},l={x:0,y:0};switch(o){case"wipe-left":c.x=new Ve([i,r],[0,-1920],{easing:s}),l.x=new Ve([i,r],[1920,0],{easing:s});break;case"wipe-right":c.x=new Ve([i,r],[0,1920],{easing:s}),l.x=new Ve([i,r],[-1920,0],{easing:s});break;case"wipe-up":c.y=new Ve([i,r],[0,-1080],{easing:s}),l.y=new Ve([i,r],[1080,0],{easing:s});break;case"wipe-down":c.y=new Ve([i,r],[0,1080],{easing:s}),l.y=new Ve([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=we.fromFrames(i)}async applySlideTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const c={x:0,y:0},l={x:0,y:0};switch(o){case"slide-left":c.x=new Ve([i,r],[0,-1920],{easing:s}),l.x=new Ve([i,r],[1920,0],{easing:s});break;case"slide-right":c.x=new Ve([i,r],[0,1920],{easing:s}),l.x=new Ve([i,r],[-1920,0],{easing:s});break;case"slide-up":c.y=new Ve([i,r],[0,-1080],{easing:s}),l.y=new Ve([i,r],[1080,0],{easing:s});break;case"slide-down":c.y=new Ve([i,r],[0,1080],{easing:s}),l.y=new Ve([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=we.fromFrames(i)}async applyZoomTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(n.scale=new Ve([i,r],[1,2],{easing:s}),n.alpha=new Ve([i,r],[1,0],{easing:s}),t.scale=new Ve([i,r],[.5,1],{easing:s}),t.alpha=new Ve([i,r],[0,1],{easing:s})):(n.scale=new Ve([i,r],[1,.5],{easing:s}),n.alpha=new Ve([i,r],[1,0],{easing:s}),t.scale=new Ve([i,r],[2,1],{easing:s}),t.alpha=new Ve([i,r],[0,1],{easing:s})),t.start=we.fromFrames(i)}async applyDipTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const c=Math.round((i+r)/2),l=o==="dip-to-black"?"#000000":"#ffffff",d=await Ai.fromColor(l),u=new Hf(d,{start:we.fromFrames(i),stop:we.fromFrames(r)});n.alpha=new Ve([i,c],[1,0],{easing:s}),u.alpha=new Ve([i,c,r],[0,1,0],{easing:s}),t.alpha=new Ve([c,r],[0,1],{easing:s}),await this.composition.add(u),t.start=we.fromFrames(c)}findTrackForClip(n){for(const t of this.composition.tracks)if(t.clips.includes(n))return t}removeTransition(n){this.transitions.delete(n)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...ho.TRANSITIONS]}static previewTransition(n){return ho.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};ho.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 va=ho;const h1={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},v1={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},g1=["onClick"],y1={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"},w1={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},b1={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},k1={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},x1={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"},E1={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"},V1={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"},S1={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},C1={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},N1={class:"space-y-3"},_1={class:"flex items-center space-x-2"},T1=["disabled"],M1=["disabled"],B1={key:1,class:"mt-4"},F1={class:"space-y-2 max-h-32 overflow-y-auto"},I1={class:"text-sm text-gray-700 dark:text-gray-300"},R1=["onClick"],$1=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(va.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),c=e.ref("linear"),l=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function d(v){r.value=v}function u(){if(!r.value||!l.value)return;const v={type:r.value.type,duration:s.value,easing:c.value};o("apply-transition",v),r.value=null}function m(){if(!r.value)return;const v={type:r.value.type,duration:s.value,easing:c.value};o("preview-transition",v)}function f(v){o("remove-transition",v)}function p(v){return["fade","wipe","slide","zoom"].some(g=>v.includes(g))}return(v,g)=>(e.openBlock(),e.createElementBlock("div",h1,[g[9]||(g[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",v1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,E=>{var T;return e.openBlock(),e.createElementBlock("div",{key:E.type,onClick:N=>d(E),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((T=r.value)==null?void 0:T.type)===E.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",y1,[p(E.type)?(e.openBlock(),e.createElementBlock("svg",w1,[E.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",b1)):E.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",k1)):E.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",x1)):E.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",E1)):(e.openBlock(),e.createElementBlock("path",V1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",S1,e.toDisplayString(E.name),1)],10,g1)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",C1,[g[6]||(g[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",N1,[e.createElementVNode("div",null,[g[3]||(g[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",_1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=E=>s.value=E),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":g[1]||(g[1]=E=>s.value=E),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,[g[5]||(g[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":g[2]||(g[2]=E=>c.value=E),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"},[...g[4]||(g[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,c.value]])]),e.createElementVNode("button",{onClick:u,disabled:!l.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",l.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,T1),e.createElementVNode("button",{onClick:m,disabled:!r.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,M1)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",B1,[g[8]||(g[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",F1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(E,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",I1,e.toDisplayString(E.name)+" ("+e.toDisplayString(E.duration)+"s) ",1),e.createElementVNode("button",{onClick:N=>f(T),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[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,R1)]))),128))])])):e.createCommentVNode("",!0),g[10]||(g[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))]))}}),D1=Be($1,[["__scopeId","data-v-5ef1b100"]]),U1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},A1={class:"mb-4"},O1={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},L1={class:"flex items-center justify-between mb-2"},z1={class:"text-sm text-gray-600 dark:text-gray-400"},P1={class:"flex items-center space-x-2"},j1={class:"space-y-3 max-h-64 overflow-y-auto"},W1={class:"flex items-center justify-between mb-2"},Z1={class:"font-medium text-gray-900 dark:text-white"},X1={class:"flex items-center space-x-2"},H1=["onClick","title"],G1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},J1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Y1=["onClick"],K1=["onClick"],q1={class:"flex items-center space-x-2"},Q1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},eg=["value","onInput","disabled"],tg={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},ng={key:0,class:"ml-2"},og={key:1,class:"ml-2"},ag={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},ig={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"},sg={class:"space-y-4"},lg={class:"space-y-2"},cg={class:"flex items-center"},dg={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},ug={class:"grid grid-cols-2 gap-4"},mg={class:"grid grid-cols-2 gap-4"},pg={class:"flex items-center"},fg={class:"flex justify-end space-x-3 mt-6"},hg=["disabled"],vg=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),c=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),l=e.reactive(c()),d=e.computed(()=>l.sourceUrl||l.sourceFile);function u(w){const h=w.target;h.files&&h.files[0]&&(l.sourceFile=h.files[0],l.name=l.name||h.files[0].name.replace(/\.[^/.]+$/,""))}function m(w){Object.assign(l,w),r.value=w}function f(){i.value=!1,r.value=null,Object.assign(l,c())}function p(){if(!d.value)return;const w={source:l.sourceFile??l.sourceUrl??"",name:l.name,volume:l.volume,startTime:l.startTime,loop:l.loop};l.duration!==void 0&&(w.duration=l.duration),l.fadeIn>0&&(w.fadeIn=l.fadeIn),l.fadeOut>0&&(w.fadeOut=l.fadeOut),r.value?o("update-track",r.value.id,w):o("add-track",w),f()}function v(w){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",w)}function g(w,h){const x=h.target,D=parseFloat(x.value);o("update-volume",w.id,D)}function E(w){o("toggle-mute",w.id,!w.muted)}function T(){o("update-master-volume",s.value)}function N(w){const h=Math.floor(w/60),x=Math.floor(w%60);return`${h}:${x.toString().padStart(2,"0")}`}return(w,h)=>(e.openBlock(),e.createElementBlock("div",U1,[e.createElementVNode("div",A1,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=x=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-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 Audio Track ",-1)])])]),e.createElementVNode("div",O1,[e.createElementVNode("div",L1,[h[12]||(h[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",z1,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",P1,[h[13]||(h[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":h[1]||(h[1]=x=>s.value=x),onInput:T,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),h[14]||(h[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",j1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.audioLayers,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",W1,[e.createElementVNode("div",Z1,e.toDisplayString(x.name),1),e.createElementVNode("div",X1,[e.createElementVNode("button",{onClick:D=>E(x),class:e.normalizeClass(["p-1 rounded",x.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:x.muted?"Unmute":"Mute"},[x.muted?(e.openBlock(),e.createElementBlock("svg",J1,[...h[16]||(h[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",G1,[...h[15]||(h[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,H1),e.createElementVNode("button",{onClick:D=>m(x),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...h[17]||(h[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,Y1),e.createElementVNode("button",{onClick:D=>v(x.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[18]||(h[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,K1)])]),e.createElementVNode("div",q1,[e.createElementVNode("span",Q1,e.toDisplayString(Math.round((x.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:x.volume||1,onInput:D=>g(x,D),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:x.muted},null,40,eg)]),e.createElementVNode("div",tg,[e.createTextVNode(e.toDisplayString(N(x.startTime||0))+" - "+e.toDisplayString(N((x.startTime||0)+(x.duration||0)))+" ",1),x.fadeIn?(e.openBlock(),e.createElementBlock("span",ng,"Fade In: "+e.toDisplayString(x.fadeIn)+"s",1)):e.createCommentVNode("",!0),x.fadeOut?(e.openBlock(),e.createElementBlock("span",og,"Fade Out: "+e.toDisplayString(x.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),w.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",ag," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.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(f,["self"])},[e.createElementVNode("div",ig,[e.createElementVNode("h4",rg,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",sg,[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"}," Audio Source ",-1)),e.createElementVNode("div",lg,[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",cg,[h[19]||(h[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":h[2]||(h[2]=x=>l.sourceUrl=x),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,l.sourceUrl]])])])]),e.createElementVNode("div",null,[h[21]||(h[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":h[3]||(h[3]=x=>l.name=x),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,l.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",dg," Volume: "+e.toDisplayString(Math.round(l.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[4]||(h[4]=x=>l.volume=x),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,l.volume,void 0,{number:!0}]])]),e.createElementVNode("div",ug,[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"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=x=>l.startTime=x),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,l.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[23]||(h[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":h[6]||(h[6]=x=>l.duration=x),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,l.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",mg,[e.createElementVNode("div",null,[h[24]||(h[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":h[7]||(h[7]=x=>l.fadeIn=x),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,l.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[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":h[8]||(h[8]=x=>l.fadeOut=x),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,l.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",pg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[9]||(h[9]=x=>l.loop=x),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,l.loop]]),h[26]||(h[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",fg,[e.createElementVNode("button",{onClick:f,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:p,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(r.value?"Save":"Add"),11,hg)])])])):e.createCommentVNode("",!0)]))}}),gg=Be(vg,[["__scopeId","data-v-593719ac"]]);function Ue(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function Is(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let Rs=!1;function yg(){if(Rs)return;Rs=!0;const a=`
34
34
  /* ── MobileVideoFilterPanel — global (not scoped) ── */
35
35
  .mvfp {
36
36
  display: flex;
@@ -333,10 +333,10 @@ ${i.text}
333
333
  font-size: 13px;
334
334
  padding: 12px 0;
335
335
  }
336
- `,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class hg{constructor({filters:n=[],callbacks:t={}}){fg(),this._filters=n,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(n){return this._root=Ue("div",{className:"mvfp"}),this._catRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Ue("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=Ue("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=Ue("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Ue("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Ue("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Ue("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(l=>l.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Ue("div",{className:`mvfp-achip${i?" selected":""}`}),s=Ue("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),c=Ue("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:l=>{l.stopPropagation(),this._removeFilter(t)}});c.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(s),r.appendChild(c),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=Ue("div",{className:"mvfp-drawer"});const n=Ue("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Ue("span",{className:"mvfp-drawer-title"},"Filter");const t=Ue("div",{className:"mvfp-drawer-actions"});t.appendChild(Ue("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Ue("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=Ue("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Ue("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(Ue("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=Ue("div",{className:"mvfp-ctl"}),c=Ue("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(c);const l=i.type||"slider";if(l==="slider"||l==="range"){const d=Ue("div",{className:"mvfp-slider-row"}),u=Ue("span",{className:"mvfp-range-val"},Ts(r)),m=Ue("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:f=>{var v,g;const p=parseFloat(f.target.value);u.textContent=Ts(p),(g=(v=this._cb).onUpdateParam)==null||g.call(v,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(l==="toggle"||l==="checkbox"){const d=Ue("div",{className:"mvfp-toggle-row"}),u=Ue("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(l==="color"){const d=Ue("div",{className:"mvfp-color-row"}),u=Ue("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(l==="select"||l==="dropdown"){const d=Ue("div",{className:"mvfp-select-row"}),u=Ue("select",{className:"mvfp-select",onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const f=Ue("option",{value:m.value},m.label||String(m.value));m.value===r&&(f.selected=!0),u.appendChild(f)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function Bs(a){var s,c;vg(a);const n=gg(a.clips),t=[],o=yg(a),i=wg(a),r={version:"1.0",source:{media_uuid:a.mediaUuid,duration:a.originalDuration,original_width:((s=a.media)==null?void 0:s.width)||1920,original_height:((c=a.media)==null?void 0:c.height)||1080},timeline:n,filters:t,audio:o,output:i,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return a.textOverlays&&(r.textOverlays=a.textOverlays),a.audioTracks&&(r.audioTracks=a.audioTracks.filter(l=>typeof l.source=="string")),r}function vg(a){if(!a.mediaUuid)throw new Error("Media UUID is required");if(!a.clips||a.clips.length===0)throw new Error("At least one clip is required");const n=[...a.clips].sort((t,o)=>t.timelineStart-o.timelineStart);for(let t=1;t<n.length;t++)if(n[t].timelineStart<n[t-1].timelineEnd)throw new Error(`Clips ${n[t-1].id} and ${n[t].id} overlap on timeline`)}function gg(a){return a.map(n=>{const t=n.speed||1,o=typeof n.sourceIn=="number"&&!Number.isNaN(n.sourceIn),i=typeof n.sourceOut=="number"&&!Number.isNaN(n.sourceOut),r=Math.max(0,n.timelineEnd-n.timelineStart),s=n.sourceOffset??n.trimStart??0;let c=Number(o?n.sourceIn:s),l=i?Number(n.sourceOut):Number(s)+r/t;return l>c||(l=c+Math.max(.033,r/Math.max(1e-6,t))),{id:n.id,type:"clip",timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:c,sourceOut:l,speed:t,filters:n.filters?[...n.filters]:[]}})}function yg(a){const n={volume:a.audioVolume,muted:a.audioVolume===0};return a.audioFadeIn>0&&(n.fadeIn=a.audioFadeIn),a.audioFadeOut>0&&(n.fadeOut=a.audioFadeOut),n}function wg(a){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[a.exportQuality]||n["1080p"],o=(r=a.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:a.exportFormat||"mp4",codec:"h264",quality:a.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function bg(a,n,t){var ue,ve;const o=typeof a=="string"&&a.trim()!==""?a.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:o,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),c=e.ref([]),l=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),m=e.shallowRef(null),f=new Wl(30),p=e.ref(30),v=e.ref(!1),g=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(C(n),(ue=n.output)!=null&&ue.fps&&(p.value=n.output.fps,f.setFps(p.value))):(h(),n&&((ve=n.output)!=null&&ve.fps&&(p.value=n.output.fps,f.setFps(p.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const E=e.ref(1),T=e.computed(()=>i.selectedClipId?i.clips.find(Z=>Z.id===i.selectedClipId)??null:null);e.watch(T,Z=>{E.value=(Z==null?void 0:Z.speed)??1},{immediate:!0});const N=e.computed(()=>s.value.length>0),w=e.computed(()=>c.value.length>0);function h(){const Z=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=Z,i.totalDuration=Z;const Q=fe(),ae={id:Q,type:"clip",timelineStart:0,timelineEnd:Z,sourceIn:0,sourceOut:Z,sourceMinIn:0,sourceMaxOut:Z,speed:1};i.clips=[ae],i.selectedClipId=Q,l.value=Q,!(t||o.startsWith("temp-"))&&(async()=>{try{const xe=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!xe.ok)throw new Error(`Failed to fetch media: ${xe.status}`);const De=await xe.json(),Qe=typeof De=="object"&&De!==null&&"data"in De?De.data:De;if(!Qe||typeof Qe!="object")throw new Error("Failed to parse media payload");const We=Qe;i.media=We;const ft=typeof We.duration=="number"&&We.duration>0?We.duration:Z;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==Q)return;i.originalDuration=ft,i.totalDuration=ft;const Ze=i.clips[0];Ze.timelineStart=0,Ze.timelineEnd=ft,Ze.sourceIn=0,Ze.sourceOut=ft,Ze.sourceMinIn=0,Ze.sourceMaxOut=ft,H(),d=!0}catch{}})()}function x(Z,Q){if(Z.originalDuration!==1)return;Z.originalDuration=Q,Z.totalDuration===1&&(Z.totalDuration=Q);const ae=Z.clips[0],xe=!n&&Z.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1;for(const De of Z.clips)(De.sourceMaxOut===1||De.sourceMaxOut===void 0)&&(De.sourceMaxOut=Q);xe&&ae!==void 0&&(ae.sourceOut=Q,ae.timelineEnd=Q)}function D(Z){if(!Number.isFinite(Z)||Z<=0||d)return;const Q=i.hasChanges;i.originalDuration=Z,i.totalDuration=Math.max(i.totalDuration,Z),i.media&&(i.media.duration=Z);for(const De of i.clips)De.sourceMaxOut=Z;const ae=i.clips[0];!n&&i.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1&&ae!==void 0&&(ae.sourceOut=Z,ae.timelineEnd=ae.timelineStart+(ae.sourceOut-ae.sourceIn)),H();for(const De of s.value)x(De,Z);for(const De of c.value)x(De,Z);d=!0,e.nextTick(()=>{Q||(i.hasChanges=!1)})}function C(Z){i.clips=Z.timeline.map(Q=>({...Q,sourceMinIn:Q.sourceMinIn??0,sourceMaxOut:Q.sourceMaxOut??Z.source.duration})),i.filters=[],i.audioVolume=Z.audio.volume,i.audioFadeIn=Z.audio.fadeIn||0,i.audioFadeOut=Z.audio.fadeOut||0,i.exportFormat=Z.output.format,i.exportQuality=Z.output.quality,i.originalDuration=Z.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,l.value=i.selectedClipId):(delete i.selectedClipId,l.value=void 0),H()}function y(){s.value.push(JSON.parse(JSON.stringify(i))),c.value=[],i.hasChanges=!0}function S(){if(!N.value)return;const Z=s.value.pop();c.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,Z)}function A(){if(!w.value)return;const Z=c.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,Z)}function k(Z,Q,ae){y();const xe=i.clips.find(Ze=>Ze.id===Z);if(!xe)return;const Qe=1/30,We=xe.sourceMinIn??0,ft=xe.sourceMaxOut??i.originalDuration;if(Q==="start"){const Ze=xe.sourceIn,Xt=Math.max(We,Math.min(ae,xe.sourceOut-Qe));xe.sourceIn=Xt;const Za=Xt-Ze;xe.timelineStart+=Za}else{const Ze=Math.max(xe.sourceIn+Qe,Math.min(ae,ft));xe.sourceOut=Ze;const Xt=xe.sourceOut-xe.sourceIn;xe.timelineEnd=xe.timelineStart+Xt}H(),m.value&&m.value.trimClip(Z,xe.sourceIn,xe.sourceOut)}function B(Z){y();const Q=i.clips.find(We=>Z>We.timelineStart&&Z<We.timelineEnd);if(!Q)return;const ae=Z-Q.timelineStart,xe=Q.sourceIn+ae,De={id:fe(),type:"clip",timelineStart:Z,timelineEnd:Q.timelineEnd,sourceIn:xe,sourceOut:Q.sourceOut,speed:Q.speed??1,sourceMinIn:Q.sourceMinIn??0,sourceMaxOut:Q.sourceMaxOut??i.originalDuration,filters:[...Q.filters||[]]};Q.timelineEnd=Z,Q.sourceOut=xe;const Qe=i.clips.indexOf(Q);i.clips.splice(Qe+1,0,De),i.selectedClipId=De.id}function R(){B(i.playheadPosition)}function U(Z){var ae;const Q=Z??i.selectedClipId??l.value??((ae=i.clips[0])==null?void 0:ae.id);Q&&(i.selectedClipId=Q,l.value=Q)}function _(){if(!i.selectedClipId||i.clips.length<=1)return;y();const Z=i.clips.findIndex(Q=>Q.id===i.selectedClipId);if(Z!==-1){i.clips.splice(Z,1);const Q=Math.min(Z,i.clips.length-1);i.selectedClipId=i.clips[Q].id,l.value=i.selectedClipId,H()}}function z(Z,Q){y();const ae=i.clips.find(De=>De.id===Z);if(!ae)return;const xe=Q-ae.timelineStart;ae.timelineStart=Q,ae.timelineEnd+=xe,H(),m.value&&m.value.moveClip(Z,Q)}function H(){if(i.clips.length===0){i.totalDuration=0;return}const Z=i.clips.reduce((Q,ae)=>ae.timelineEnd>Q.timelineEnd?ae:Q);i.totalDuration=Z.timelineEnd}function M(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function $(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function X(Z){i.zoomLevel=Math.max(10,Math.min(600,Math.round(Z)))}function j(){i.isPlaying=!i.isPlaying}function te(Z){i.isPlaying=Z}function ge(Z){i.playheadPosition=Math.max(0,Math.min(Z,i.totalDuration))}function Ne(){const Z=Bs(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(Z))}catch{}return Z}function ee(){i.hasChanges=!1}function F(){return confirm("Are you sure you want to reset all changes?")?(y(),h(),i.hasChanges=!1,!0):!1}function P(){return Bs(i)}function fe(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ne(Z=1920,Q=1080){if(u.value)try{m.value=new jl(Z,Q,p.value),await Y()}catch{m.value=null}}async function Y(){if(!(!m.value||g.value)){g.value=!0;try{const Z=P();await m.value.loadFromRecipe(Z);const Q=f.secondsToFrames(i.playheadPosition);m.value.seek(Q)}catch{}finally{g.value=!1}}}function Me(Z){}function ce(Z){return f.secondsToFrames(Z)}function se(Z){return f.framesToSeconds(Z)}function ke(Z){const Q=se(Z);ge(Q),m.value&&m.value.seek(Z)}function oe(){v.value=!v.value}function le(){Y()}function Ee(Z){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.clips.map(Z=>Z.id),()=>{var Q;if(!i.clips.length){delete i.selectedClipId,l.value=void 0;return}if(!i.clips.some(ae=>ae.id===i.selectedClipId)){const ae=l.value&&((Q=i.clips.find(xe=>xe.id===l.value))==null?void 0:Q.id);i.selectedClipId=ae??i.clips[0].id,l.value=i.selectedClipId}},{deep:!0});function Se(Z){const Q=i.selectedClipId?i.clips.find(ae=>ae.id===i.selectedClipId):i.clips[0];Q&&(Q.filters=[...Z],i.hasChanges=!0)}function rt(Z){i.textOverlays=[...Z]}function He(Z){i.audioTracks=[...Z]}e.watch(u,Z=>{Z?ne():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(p,Z=>{f.setFps(Z)});function pt(){if(!i.selectedClipId)return;y();const Z=i.clips.find(xe=>xe.id===i.selectedClipId);if(!Z)return;const Q={...Z,id:fe(),timelineStart:Z.timelineEnd,timelineEnd:Z.timelineEnd+(Z.timelineEnd-Z.timelineStart),filters:[...Z.filters||[]]},ae=i.clips.indexOf(Z);i.clips.splice(ae+1,0,Q),i.selectedClipId=Q.id,i.hasChanges=!0}function K(Z){const Q=Z??800,ae=i.totalDuration;if(ae<=0){i.zoomLevel=50;return}const xe=Q*.8/ae;i.zoomLevel=Math.max(10,Math.min(600,Math.round(xe)))}function de(){const Z=1/p.value;ge(Math.min(i.playheadPosition+Z,i.totalDuration))}function ie(){const Z=1/p.value;ge(Math.max(i.playheadPosition-Z,0))}function he(){ge(0)}function _e(){ge(i.totalDuration)}function J(Z){if(!Number.isFinite(Z)||Z<=0)return;const Q=T.value??i.clips[0];if(!Q){E.value=Z;return}const ae=Q.speed??1;if(ae===Z){E.value=Z;return}y();const xe=Math.max(1/p.value,Q.sourceOut-Q.sourceIn),De=xe/ae,Qe=xe/Z,We=Qe-De;Q.speed=Z,Q.timelineEnd=Q.timelineStart+Qe;const ft=i.clips.findIndex(Ze=>Ze.id===Q.id);if(ft!==-1&&We!==0)for(let Ze=ft+1;Ze<i.clips.length;Ze+=1){const Xt=i.clips[Ze];Xt.timelineStart+=We,Xt.timelineEnd+=We}H(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,E.value=Z}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:T,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:E,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:p,useFrameMode:v,handleTrim:k,handleSplit:B,handleClipSelect:U,splitAtPlayhead:R,deleteSelectedClip:_,duplicateSelectedClip:pt,setFilters:Se,setTextOverlays:rt,setAudioTracks:He,moveClip:z,saveDraft:Ne,clearHasChanges:ee,resetChanges:F,generateRecipe:P,zoomIn:M,zoomOut:$,setZoomLevel:X,fitToWindow:K,togglePlayback:j,setPlaying:te,seekTo:ge,frameForward:de,frameBackward:ie,skipToStart:he,skipToEnd:_e,setPlaybackSpeed:J,updateSourceDuration:D,undo:S,redo:A,canUndo:N,canRedo:w,initializeComposition:ne,syncCompositionWithState:Y,syncWithComposition:Me,convertToFrames:ce,convertToSeconds:se,seekToFrame:ke,toggleFrameMode:oe,onCompositionReady:le,onCompositionError:Ee}}const kg=[{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}}}],xg={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Ra(a){return typeof a=="object"&&a!==null}function Eg(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function $a(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function Vg(a){const n={id:a.id,type:a.type,label:a.label};a.property!==void 0&&(n.property=a.property),a.min!==void 0&&(n.min=a.min),a.max!==void 0&&(n.max=a.max),a.step!==void 0&&(n.step=a.step);const t=$a(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function Zl(a,n,t){const o=ct.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&Ra(r))for(const[s,c]of Object.entries(r))i[s]=$a(c)??null;for(const s of n){const c=s.property??s.id;i[c]===void 0&&s.default!==void 0&&(i[c]=s.default)}return i}function Xl(a){const n={};for(const t of a){if(t.type!=="slider")continue;const o=t.property??t.id;n[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function Sg(a,n,t,o){const i=o.map(Vg);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:Zl(a,i),paramRanges:Xl(i)}}function Cg(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var c;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,l=>l.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=$a((c=a.defaultParams)==null?void 0:c[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:Zl(a.id,t,a.defaultParams),paramRanges:Xl(t)}}function Ng(a,n){return n.toLowerCase()==="unlisted"?!1:ct.isFilterCompatibleWithMedia(a,"video")}function hi(a){return xg[a]??a}function ro(a){const n=Eg(a,1);return Math.max(0,Math.min(1,n))}function so(a){if(!Ra(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=$a(o)??null;return n}function _g(a){return!Ra(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:so(a.params),intensity:ro(a.intensity)}}function Tg(a){if(!Ra(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>_g(i)).filter(i=>i!==null),o=typeof a.created_at=="string"?a.created_at:new Date().toISOString();return{id:a.id,name:a.name,filters:t,created_at:o}}function Mg(){ct.initializeFilterRegistry();const a=e.ref([]),n=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const R=new Map,U=ct.getRegisteredFilters();for(const _ of U)Ng(_.id,_.category)&&R.set(_.id,Sg(_.id,_.name,_.category,_.controls));for(const _ of kg)R.has(_.id)||R.set(_.id,Cg(_));return Array.from(R.values())}),c=e.computed(()=>{const R=new Map;for(const U of s.value)R.set(U.id,U);return R}),l=e.computed(()=>a.value.length>0),d=e.computed(()=>{const R={};for(const U of s.value)R[U.category]||(R[U.category]=[]),R[U.category].push(U);return R});function u(R){const U=c.value.get(R);if(U)return U;const _=hi(R);return c.value.get(_)??null}function m(R){const U=c.value.get(R);if(U)return U.id;const _=hi(R),z=c.value.get(_);return z?z.id:null}function f(R){const U=R?u(R):n.value;if(!U)return;const _=U.defaultParams||{},z={id:S(),filterId:U.id,params:{..._},intensity:1};return a.value.push(z),i.value=z.id,n.value=U,Object.keys(r).forEach(H=>delete r[H]),Object.assign(r,z.params),t.value=null,z}function p(R){const U=u(R);if(!U)return;n.value=U;const _=U.defaultParams||k(R);Object.assign(r,_),t.value={id:"preview",filterId:U.id,params:{..._},intensity:1}}function v(R){if(Object.assign(r,R),t.value&&(t.value.params={...r}),i.value){const U=a.value.find(_=>_.id===i.value);U&&(U.params={...r})}}function g(R){const U=a.value.findIndex(_=>_.id===R);U!==-1&&a.value.splice(U,1)}function E(R,U){if(R<0||R>=a.value.length||U<0||U>=a.value.length)return;const[_]=a.value.splice(R,1);a.value.splice(U,0,_)}function T(R,U){const _=a.value.find(z=>z.id===R);_&&(_.intensity=Math.max(0,Math.min(1,U)))}function N(R){const U=a.value.find(_=>_.id===R);U&&(U.intensity=U.intensity>0?0:1)}function w(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(R=>delete r[R])}function h(R){const U={id:A(),name:R,filters:a.value.map(z=>({filterId:z.filterId,params:so(z.params),intensity:ro(z.intensity)})),created_at:new Date().toISOString()};o.value.push(U);const _=o.value.map(z=>({...z}));return localStorage.setItem("video-filter-presets",JSON.stringify(_)),U}function x(R){const U=o.value.find(_=>_.id===R);if(U){w();for(const _ of U.filters){const z=u(_.filterId);z&&a.value.push({id:S(),filterId:z.id,params:{..._.params},intensity:ro(_.intensity)})}}}function D(R){const U=o.value.findIndex(_=>_.id===R);U!==-1&&(o.value.splice(U,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function C(){try{const R=localStorage.getItem("video-filter-presets");if(!R)return;const U=JSON.parse(R);if(!Array.isArray(U))return;o.value=U.map(_=>Tg(_)).filter(_=>_!==null)}catch{}}function y(){if(a.value.length===0)return"No filters applied";const R=a.value.map(U=>{const _=B(U.filterId);return(_==null?void 0:_.name)||U.filterId});return R.length===1?R[0]:R.length===2?`${R[0]} + ${R[1]}`:`${R[0]} + ${R.length-1} more`}function S(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function A(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(R){const U=u(R);return U?U.defaultParams||{}:{}}function B(R){return u(R)}return C(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:l,filtersByCategory:d,applyFilter:f,previewFilterEffect:p,updateFilterParams:v,removeFilter:g,reorderFilters:E,updateFilterIntensity:T,toggleFilter:N,clearAllFilters:w,saveFilterPreset:h,loadFilterPreset:x,deleteFilterPreset:D,getFilterSummary:y,setActiveFilters(R){var _;const U=[];for(const z of R){const H=m(z.filterId);if(!H){const M=hi(z.filterId);U.push({...z,filterId:M,params:so(z.params),intensity:ro(z.intensity)});continue}U.push({...z,filterId:H,params:so(z.params),intensity:ro(z.intensity)})}a.value=U,i.value=((_=a.value[0])==null?void 0:_.id)??null,Object.keys(r).forEach(z=>delete r[z]),a.value[0]&&Object.assign(r,so(a.value[0].params))}}}class Bg{constructor(n){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new ut({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new ut({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new ut({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,o,i="400"){const r=new ut({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new ut({source:`local('${t}')`,family:t,weight:o});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,o={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},i=n.fontFamily||"default",r=this.fonts.get(i)||this.fonts.get("default");if(o.font=r,n.position)if(typeof n.position=="string")switch(n.position){case"center":o.position="center";break;case"top":o.x="50%",o.y="10%";break;case"bottom":o.x="50%",o.y="90%";break;case"left":o.x="10%",o.y="50%";break;case"right":o.x="90%",o.y="50%";break}else o.x=n.position.x,o.y=n.position.y;else o.position="center";if(n.startTime!==void 0&&(o.start=we.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;o.stop=we.fromSeconds(c+n.duration)}n.animation&&this.applyAnimation(o,n.animation,n);const s=new zn(o);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(n,t,o){if(!t)return;const i=o.startTime?Math.round(o.startTime*30):0,r=t.duration||1,s=Math.round(r*30),c=i+s,l=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Ve([i,c],[0,1],{easing:l});break;case"fade-out":n.alpha=new Ve([i,c],[1,0],{easing:l});break;case"rotate":t.rotation&&(n.rotation=new Ve([i,c],[t.rotation.from,t.rotation.to],{easing:l}));break;case"scale":t.scale&&(n.scale=new Ve([i,c],[t.scale.from,t.scale.to],{easing:l}));break;case"slide":t.translate&&(n.translate={x:new Ve([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ve([i,c],[t.translate.fromY,t.translate.toY],{easing:l})});break;case"typewriter":n.alpha=new Ve([i,c],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ve([i,c],[t.rotation.from,t.rotation.to],{easing:l})),t.scale&&(n.scale=new Ve([i,c],[t.scale.from,t.scale.to],{easing:l})),t.translate&&(n.translate={x:new Ve([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ve([i,c],[t.translate.fromY,t.translate.toY],{easing:l})});break}}async updateTextOverlay(n,t){if(!this.textClips.get(n))throw new Error(`Text overlay with id ${n} not found`);await this.removeTextOverlay(n);const i={...t};await this.addTextOverlay(i)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const o=this.composition.tracks;for(const i of o){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const n=Array.from(this.textClips.keys());for(const t of n)await this.removeTextOverlay(t)}getOverlays(){const n=[];return this.textClips.forEach((t,o)=>{const i={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};n.push({id:o,config:i})}),n}async addCaptions(n,t="classic",o){var l,d;const r={classic:Vo,cascade:Ta,guinea:_a,solar:Ma,spotlight:So,whisper:Co}[t],s=await this.composition.createTrack("caption"),c=new xa({transcript:n});if(await s.add(c),await((l=s.generate)==null?void 0:l.call(s,r)),o&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,o)}}}class Fg{constructor(n){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=n}async loadAudioSource(n,t){try{const o=await sn.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,o),o}catch(o){throw o instanceof Error?o:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`;let o;try{if(typeof n.source=="object"&&n.source instanceof sn)o=n.source;else if(typeof n.source=="string")o=await sn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)o=await sn.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(l){throw l instanceof Error?l:new Error("Failed to create audio source")}const i={source:o,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=we.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;i.stop=we.fromSeconds(l+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new fa(i);let s=this.composition.tracks.find(l=>l.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(r);const c={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,c),t}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,o=n.startTime?Math.round(n.startTime*30):0,i=n.duration,r=[],s=[];if(n.fadeIn){const c=Math.round(n.fadeIn*30);r.push(o,o+c),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const c=o+Math.round(i*30),l=Math.round(n.fadeOut*30);n.fadeIn||(r.push(c-l),s.push(t)),r.push(c),s.push(0)}return new Ve(r,s,{easing:"linear"})}async updateVolume(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));o.clip.volume=i*this.masterVolume,o.config.volume=i}async applyFadeIn(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeIn=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async applyFadeOut(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeOut=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);const o=t.track.clips.indexOf(t.clip);o!==-1&&t.track.clips.splice(o,1),this.audioLayers.delete(n)}async muteTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);t?o.clip.volume=0:o.clip.volume=(o.config.volume??1)*this.masterVolume}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));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(n){return this.audioLayers.get(n)}async clearAllAudioTracks(){const n=Array.from(this.audioLayers.keys());for(const t of n)await this.removeAudioTrack(t)}async syncWithVideo(n,t){for(const o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-n;if(i+r>t){o.config.duration=t-i;const s=new fa({source:o.clip.source,start:we.fromSeconds(i),stop:we.fromSeconds(t),volume:o.clip.volume}),c=o.track.clips.indexOf(o.clip);c!==-1&&(o.track.clips[c]=s,o.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(n=>({id:n.id,name:n.name,config:{...n.config,source:n.config.source&&typeof n.config.source=="object"&&"type"in n.config.source?"[AudioSource]":n.config.source}}))}async importConfiguration(n){for(const{name:t,config:o}of n)await this.addAudioTrack({...o,name:t})}}function Hl(a,n){return function(){return a.apply(n,arguments)}}const{toString:Ig}=Object.prototype,{getPrototypeOf:fr}=Object,{iterator:Da,toStringTag:Gl}=Symbol,Ua=(a=>n=>{const t=Ig.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),It=a=>(a=a.toLowerCase(),n=>Ua(n)===a),Aa=a=>n=>typeof n===a,{isArray:Wn}=Array,yo=Aa("undefined");function No(a){return a!==null&&!yo(a)&&a.constructor!==null&&!yo(a.constructor)&&wt(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const Jl=It("ArrayBuffer");function Rg(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&Jl(a.buffer),n}const $g=Aa("string"),wt=Aa("function"),Yl=Aa("number"),_o=a=>a!==null&&typeof a=="object",Dg=a=>a===!0||a===!1,na=a=>{if(Ua(a)!=="object")return!1;const n=fr(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Gl in a)&&!(Da in a)},Ug=a=>{if(!_o(a)||No(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},Ag=It("Date"),Og=It("File"),Lg=It("Blob"),zg=It("FileList"),Pg=a=>_o(a)&&wt(a.pipe),jg=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||wt(a.append)&&((n=Ua(a))==="formdata"||n==="object"&&wt(a.toString)&&a.toString()==="[object FormData]"))},Wg=It("URLSearchParams"),[Zg,Xg,Hg,Gg]=["ReadableStream","Request","Response","Headers"].map(It),Jg=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function To(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),Wn(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(No(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let c;for(o=0;o<s;o++)c=r[o],n.call(null,a[c],c,a)}}function Kl(a,n){if(No(a))return null;n=n.toLowerCase();const t=Object.keys(a);let o=t.length,i;for(;o-- >0;)if(i=t[o],n===i.toLowerCase())return i;return null}const gn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ql=a=>!yo(a)&&a!==gn;function Oi(){const{caseless:a}=ql(this)&&this||{},n={},t=(o,i)=>{const r=a&&Kl(n,i)||i;na(n[r])&&na(o)?n[r]=Oi(n[r],o):na(o)?n[r]=Oi({},o):Wn(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&To(arguments[o],t);return n}const Yg=(a,n,t,{allOwnKeys:o}={})=>(To(n,(i,r)=>{t&&wt(i)?a[r]=Hl(i,t):a[r]=i},{allOwnKeys:o}),a),Kg=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),qg=(a,n,t,o)=>{a.prototype=Object.create(n.prototype,o),a.prototype.constructor=a,Object.defineProperty(a,"super",{value:n.prototype}),t&&Object.assign(a.prototype,t)},Qg=(a,n,t,o)=>{let i,r,s;const c={};if(n=n||{},a==null)return n;do{for(i=Object.getOwnPropertyNames(a),r=i.length;r-- >0;)s=i[r],(!o||o(s,a,n))&&!c[s]&&(n[s]=a[s],c[s]=!0);a=t!==!1&&fr(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},ey=(a,n,t)=>{a=String(a),(t===void 0||t>a.length)&&(t=a.length),t-=n.length;const o=a.indexOf(n,t);return o!==-1&&o===t},ty=a=>{if(!a)return null;if(Wn(a))return a;let n=a.length;if(!Yl(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},ny=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&fr(Uint8Array)),oy=(a,n)=>{const o=(a&&a[Da]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},ay=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},iy=It("HTMLFormElement"),ry=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Fs=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),sy=It("RegExp"),Ql=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};To(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},ly=a=>{Ql(a,(n,t)=>{if(wt(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(wt(o)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},cy=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return Wn(a)?o(a):o(String(a).split(n)),t},dy=()=>{},uy=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function my(a){return!!(a&&wt(a.append)&&a[Gl]==="FormData"&&a[Da])}const py=a=>{const n=new Array(10),t=(o,i)=>{if(_o(o)){if(n.indexOf(o)>=0)return;if(No(o))return o;if(!("toJSON"in o)){n[i]=o;const r=Wn(o)?[]:{};return To(o,(s,c)=>{const l=t(s,i+1);!yo(l)&&(r[c]=l)}),n[i]=void 0,r}}return o};return t(a,0)},fy=It("AsyncFunction"),hy=a=>a&&(_o(a)||wt(a))&&wt(a.then)&&wt(a.catch),ec=((a,n)=>a?setImmediate:n?((t,o)=>(gn.addEventListener("message",({source:i,data:r})=>{i===gn&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),gn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",wt(gn.postMessage)),vy=typeof queueMicrotask<"u"?queueMicrotask.bind(gn):typeof process<"u"&&process.nextTick||ec,gy=a=>a!=null&&wt(a[Da]),G={isArray:Wn,isArrayBuffer:Jl,isBuffer:No,isFormData:jg,isArrayBufferView:Rg,isString:$g,isNumber:Yl,isBoolean:Dg,isObject:_o,isPlainObject:na,isEmptyObject:Ug,isReadableStream:Zg,isRequest:Xg,isResponse:Hg,isHeaders:Gg,isUndefined:yo,isDate:Ag,isFile:Og,isBlob:Lg,isRegExp:sy,isFunction:wt,isStream:Pg,isURLSearchParams:Wg,isTypedArray:ny,isFileList:zg,forEach:To,merge:Oi,extend:Yg,trim:Jg,stripBOM:Kg,inherits:qg,toFlatObject:Qg,kindOf:Ua,kindOfTest:It,endsWith:ey,toArray:ty,forEachEntry:oy,matchAll:ay,isHTMLForm:iy,hasOwnProperty:Fs,hasOwnProp:Fs,reduceDescriptors:Ql,freezeMethods:ly,toObjectSet:cy,toCamelCase:ry,noop:dy,toFiniteNumber:uy,findKey:Kl,global:gn,isContextDefined:ql,isSpecCompliantForm:my,toJSONObject:py,isAsyncFn:fy,isThenable:hy,setImmediate:ec,asap:vy,isIterable:gy};function Fe(a,n,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=a,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}G.inherits(Fe,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 tc=Fe.prototype,nc={};["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(a=>{nc[a]={value:a}});Object.defineProperties(Fe,nc);Object.defineProperty(tc,"isAxiosError",{value:!0});Fe.from=(a,n,t,o,i,r)=>{const s=Object.create(tc);return G.toFlatObject(a,s,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),Fe.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const yy=null;function Li(a){return G.isPlainObject(a)||G.isArray(a)}function oc(a){return G.endsWith(a,"[]")?a.slice(0,-2):a}function Is(a,n,t){return a?a.concat(n).map(function(i,r){return i=oc(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function wy(a){return G.isArray(a)&&!a.some(Li)}const by=G.toFlatObject(G,{},null,function(n){return/^is[A-Z]/.test(n)});function Oa(a,n,t){if(!G.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=G.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,E){return!G.isUndefined(E[g])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(n);if(!G.isFunction(i))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(!l&&G.isBlob(v))throw new Fe("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(v)||G.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,g,E){let T=v;if(v&&!E&&typeof v=="object"){if(G.endsWith(g,"{}"))g=o?g:g.slice(0,-2),v=JSON.stringify(v);else if(G.isArray(v)&&wy(v)||(G.isFileList(v)||G.endsWith(g,"[]"))&&(T=G.toArray(v)))return g=oc(g),T.forEach(function(w,h){!(G.isUndefined(w)||w===null)&&n.append(s===!0?Is([g],h,r):s===null?g:g+"[]",d(w))}),!1}return Li(v)?!0:(n.append(Is(E,g,r),d(v)),!1)}const m=[],f=Object.assign(by,{defaultVisitor:u,convertValue:d,isVisitable:Li});function p(v,g){if(!G.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(v),G.forEach(v,function(T,N){(!(G.isUndefined(T)||T===null)&&i.call(n,T,G.isString(N)?N.trim():N,g,f))===!0&&p(T,g?g.concat(N):[N])}),m.pop()}}if(!G.isObject(a))throw new TypeError("data must be an object");return p(a),n}function Rs(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function hr(a,n){this._pairs=[],a&&Oa(a,this,n)}const ac=hr.prototype;ac.append=function(n,t){this._pairs.push([n,t])};ac.toString=function(n){const t=n?function(o){return n.call(this,o,Rs)}:Rs;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function ky(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ic(a,n,t){if(!n)return a;const o=t&&t.encode||ky;G.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=G.isURLSearchParams(n)?n.toString():new hr(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class $s{constructor(){this.handlers=[]}use(n,t,o){return this.handlers.push({fulfilled:n,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){G.forEach(this.handlers,function(o){o!==null&&n(o)})}}const rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xy=typeof URLSearchParams<"u"?URLSearchParams:hr,Ey=typeof FormData<"u"?FormData:null,Vy=typeof Blob<"u"?Blob:null,Sy={isBrowser:!0,classes:{URLSearchParams:xy,FormData:Ey,Blob:Vy},protocols:["http","https","file","blob","url","data"]},vr=typeof window<"u"&&typeof document<"u",zi=typeof navigator=="object"&&navigator||void 0,Cy=vr&&(!zi||["ReactNative","NativeScript","NS"].indexOf(zi.product)<0),Ny=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",_y=vr&&window.location.href||"http://localhost",Ty=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vr,hasStandardBrowserEnv:Cy,hasStandardBrowserWebWorkerEnv:Ny,navigator:zi,origin:_y},Symbol.toStringTag,{value:"Module"})),mt={...Ty,...Sy};function My(a,n){return Oa(a,new mt.classes.URLSearchParams,{visitor:function(t,o,i,r){return mt.isNode&&G.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function By(a){return G.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Fy(a){const n={},t=Object.keys(a);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],n[r]=a[r];return n}function sc(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const c=Number.isFinite(+s),l=r>=t.length;return s=!s&&G.isArray(i)?i.length:s,l?(G.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!c):((!i[s]||!G.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&G.isArray(i[s])&&(i[s]=Fy(i[s])),!c)}if(G.isFormData(a)&&G.isFunction(a.entries)){const t={};return G.forEachEntry(a,(o,i)=>{n(By(o),i,t,0)}),t}return null}function Iy(a,n,t){if(G.isString(a))try{return(n||JSON.parse)(a),G.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const Mo={transitional:rc,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=G.isObject(n);if(r&&G.isHTMLForm(n)&&(n=new FormData(n)),G.isFormData(n))return i?JSON.stringify(sc(n)):n;if(G.isArrayBuffer(n)||G.isBuffer(n)||G.isStream(n)||G.isFile(n)||G.isBlob(n)||G.isReadableStream(n))return n;if(G.isArrayBufferView(n))return n.buffer;if(G.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return My(n,this.formSerializer).toString();if((c=G.isFileList(n))||o.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Oa(c?{"files[]":n}:n,l&&new l,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Iy(n)):n}],transformResponse:[function(n){const t=this.transitional||Mo.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(G.isResponse(n)||G.isReadableStream(n))return n;if(n&&G.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(c){if(s)throw c.name==="SyntaxError"?Fe.from(c,Fe.ERR_BAD_RESPONSE,this,null,this.response):c}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:mt.classes.FormData,Blob:mt.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],a=>{Mo.headers[a]={}});const Ry=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"]),$y=a=>{const n={};let t,o,i;return a&&a.split(`
337
- `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&Ry[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},Ds=Symbol("internals");function Qn(a){return a&&String(a).trim().toLowerCase()}function oa(a){return a===!1||a==null?a:G.isArray(a)?a.map(oa):String(a)}function Dy(a){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(a);)n[o[1]]=o[2];return n}const Uy=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function vi(a,n,t,o,i){if(G.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!G.isString(n)){if(G.isString(o))return n.indexOf(o)!==-1;if(G.isRegExp(o))return o.test(n)}}function Ay(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function Oy(a,n){const t=G.toCamelCase(" "+n);["get","set","has"].forEach(o=>{Object.defineProperty(a,o+t,{value:function(i,r,s){return this[o].call(this,n,i,r,s)},configurable:!0})})}let bt=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(c,l,d){const u=Qn(l);if(!u)throw new Error("header name must be a non-empty string");const m=G.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||l]=oa(c))}const s=(c,l)=>G.forEach(c,(d,u)=>r(d,u,l));if(G.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(G.isString(n)&&(n=n.trim())&&!Uy(n))s($y(n),t);else if(G.isObject(n)&&G.isIterable(n)){let c={},l,d;for(const u of n){if(!G.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[d=u[0]]=(l=c[d])?G.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}s(c,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=Qn(n),n){const o=G.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return Dy(i);if(G.isFunction(t))return t.call(this,i,o);if(G.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=Qn(n),n){const o=G.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||vi(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=Qn(s),s){const c=G.findKey(o,s);c&&(!t||vi(o,o[c],c,t))&&(delete o[c],i=!0)}}return G.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!n||vi(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return G.forEach(this,(i,r)=>{const s=G.findKey(o,r);if(s){t[s]=oa(i),delete t[r];return}const c=n?Ay(r):String(r).trim();c!==r&&delete t[r],t[c]=oa(i),o[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return G.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&G.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
338
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[Ds]=this[Ds]={accessors:{}}).accessors,i=this.prototype;function r(s){const c=Qn(s);o[c]||(Oy(i,s),o[c]=!0)}return G.isArray(n)?n.forEach(r):r(n),this}};bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);G.reduceDescriptors(bt.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});G.freezeMethods(bt);function gi(a,n){const t=this||Mo,o=n||t,i=bt.from(o.headers);let r=o.data;return G.forEach(a,function(c){r=c.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function lc(a){return!!(a&&a.__CANCEL__)}function Zn(a,n,t){Fe.call(this,a??"canceled",Fe.ERR_CANCELED,n,t),this.name="CanceledError"}G.inherits(Zn,Fe,{__CANCEL__:!0});function cc(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new Fe("Request failed with status code "+t.status,[Fe.ERR_BAD_REQUEST,Fe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Ly(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function zy(a,n){a=a||10;const t=new Array(a),o=new Array(a);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(l){const d=Date.now(),u=o[r];s||(s=d),t[i]=l,o[i]=d;let m=r,f=0;for(;m!==i;)f+=t[m++],m=m%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const p=u&&d-u;return p?Math.round(f*1e3/p):void 0}}function Py(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-m)))},()=>i&&s(i)]}const va=(a,n,t=3)=>{let o=0;const i=zy(50,250);return Py(r=>{const s=r.loaded,c=r.lengthComputable?r.total:void 0,l=s-o,d=i(l),u=s<=c;o=s;const m={loaded:s,total:c,progress:c?s/c:void 0,bytes:l,rate:d||void 0,estimated:d&&c&&u?(c-s)/d:void 0,event:r,lengthComputable:c!=null,[n?"download":"upload"]:!0};a(m)},t)},Us=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},As=a=>(...n)=>G.asap(()=>a(...n)),jy=mt.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,mt.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(mt.origin),mt.navigator&&/(msie|trident)/i.test(mt.navigator.userAgent)):()=>!0,Wy=mt.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];G.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),G.isString(o)&&s.push("path="+o),G.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(a){const n=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Zy(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function Xy(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function dc(a,n,t){let o=!Zy(n);return a&&(o||t==!1)?Xy(a,n):n}const Os=a=>a instanceof bt?{...a}:a;function kn(a,n){n=n||{};const t={};function o(d,u,m,f){return G.isPlainObject(d)&&G.isPlainObject(u)?G.merge.call({caseless:f},d,u):G.isPlainObject(u)?G.merge({},u):G.isArray(u)?u.slice():u}function i(d,u,m,f){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d,m,f)}else return o(d,u,m,f)}function r(d,u){if(!G.isUndefined(u))return o(void 0,u)}function s(d,u){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function c(d,u,m){if(m in n)return o(d,u);if(m in a)return o(void 0,d)}const l={url:r,method:r,data:r,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:c,headers:(d,u,m)=>i(Os(d),Os(u),m,!0)};return G.forEach(Object.keys({...a,...n}),function(u){const m=l[u]||i,f=m(a[u],n[u],u);G.isUndefined(f)&&m!==c||(t[u]=f)}),t}const uc=a=>{const n=kn({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:c}=n;n.headers=s=bt.from(s),n.url=ic(dc(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),c&&s.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(G.isFormData(t)){if(mt.hasStandardBrowserEnv||mt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((l=s.getContentType())!==!1){const[d,...u]=l?l.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(mt.hasStandardBrowserEnv&&(o&&G.isFunction(o)&&(o=o(n)),o||o!==!1&&jy(n.url))){const d=i&&r&&Wy.read(r);d&&s.set(i,d)}return n},Hy=typeof XMLHttpRequest<"u",Gy=Hy&&function(a){return new Promise(function(t,o){const i=uc(a);let r=i.data;const s=bt.from(i.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:d}=i,u,m,f,p,v;function g(){p&&p(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let E=new XMLHttpRequest;E.open(i.method.toUpperCase(),i.url,!0),E.timeout=i.timeout;function T(){if(!E)return;const w=bt.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:w,config:a,request:E};cc(function(C){t(C),g()},function(C){o(C),g()},x),E=null}"onloadend"in E?E.onloadend=T:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(T)},E.onabort=function(){E&&(o(new Fe("Request aborted",Fe.ECONNABORTED,a,E)),E=null)},E.onerror=function(){o(new Fe("Network Error",Fe.ERR_NETWORK,a,E)),E=null},E.ontimeout=function(){let h=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const x=i.transitional||rc;i.timeoutErrorMessage&&(h=i.timeoutErrorMessage),o(new Fe(h,x.clarifyTimeoutError?Fe.ETIMEDOUT:Fe.ECONNABORTED,a,E)),E=null},r===void 0&&s.setContentType(null),"setRequestHeader"in E&&G.forEach(s.toJSON(),function(h,x){E.setRequestHeader(x,h)}),G.isUndefined(i.withCredentials)||(E.withCredentials=!!i.withCredentials),c&&c!=="json"&&(E.responseType=i.responseType),d&&([f,v]=va(d,!0),E.addEventListener("progress",f)),l&&E.upload&&([m,p]=va(l),E.upload.addEventListener("progress",m),E.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=w=>{E&&(o(!w||w.type?new Zn(null,a,E):w),E.abort(),E=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const N=Ly(i.url);if(N&&mt.protocols.indexOf(N)===-1){o(new Fe("Unsupported protocol "+N+":",Fe.ERR_BAD_REQUEST,a));return}E.send(r||null)})},Jy=(a,n)=>{const{length:t}=a=a?a.filter(Boolean):[];if(n||t){let o=new AbortController,i;const r=function(d){if(!i){i=!0,c();const u=d instanceof Error?d:this.reason;o.abort(u instanceof Fe?u:new Zn(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Fe(`timeout ${n} of ms exceeded`,Fe.ETIMEDOUT))},n);const c=()=>{a&&(s&&clearTimeout(s),s=null,a.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),a=null)};a.forEach(d=>d.addEventListener("abort",r));const{signal:l}=o;return l.unsubscribe=()=>G.asap(c),l}},Yy=function*(a,n){let t=a.byteLength;if(t<n){yield a;return}let o=0,i;for(;o<t;)i=o+n,yield a.slice(o,i),o=i},Ky=async function*(a,n){for await(const t of qy(a))yield*Yy(t,n)},qy=async function*(a){if(a[Symbol.asyncIterator]){yield*a;return}const n=a.getReader();try{for(;;){const{done:t,value:o}=await n.read();if(t)break;yield o}}finally{await n.cancel()}},Ls=(a,n,t,o)=>{const i=Ky(a,n);let r=0,s,c=l=>{s||(s=!0,o&&o(l))};return new ReadableStream({async pull(l){try{const{done:d,value:u}=await i.next();if(d){c(),l.close();return}let m=u.byteLength;if(t){let f=r+=m;t(f)}l.enqueue(new Uint8Array(u))}catch(d){throw c(d),d}},cancel(l){return c(l),i.return()}},{highWaterMark:2})},La=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",mc=La&&typeof ReadableStream=="function",Qy=La&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),pc=(a,...n)=>{try{return!!a(...n)}catch{return!1}},ew=mc&&pc(()=>{let a=!1;const n=new Request(mt.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),zs=64*1024,Pi=mc&&pc(()=>G.isReadableStream(new Response("").body)),ga={stream:Pi&&(a=>a.body)};La&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!ga[n]&&(ga[n]=G.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new Fe(`Response type '${n}' is not supported`,Fe.ERR_NOT_SUPPORT,o)})})})(new Response);const tw=async a=>{if(a==null)return 0;if(G.isBlob(a))return a.size;if(G.isSpecCompliantForm(a))return(await new Request(mt.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(G.isArrayBufferView(a)||G.isArrayBuffer(a))return a.byteLength;if(G.isURLSearchParams(a)&&(a=a+""),G.isString(a))return(await Qy(a)).byteLength},nw=async(a,n)=>{const t=G.toFiniteNumber(a.getContentLength());return t??tw(n)},ow=La&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:c,onUploadProgress:l,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:f}=uc(a);d=d?(d+"").toLowerCase():"text";let p=Jy([i,r&&r.toAbortSignal()],s),v;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let E;try{if(l&&ew&&t!=="get"&&t!=="head"&&(E=await nw(u,o))!==0){let x=new Request(n,{method:"POST",body:o,duplex:"half"}),D;if(G.isFormData(o)&&(D=x.headers.get("content-type"))&&u.setContentType(D),x.body){const[C,y]=Us(E,va(As(l)));o=Ls(x.body,zs,C,y)}}G.isString(m)||(m=m?"include":"omit");const T="credentials"in Request.prototype;v=new Request(n,{...f,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:T?m:void 0});let N=await fetch(v,f);const w=Pi&&(d==="stream"||d==="response");if(Pi&&(c||w&&g)){const x={};["status","statusText","headers"].forEach(S=>{x[S]=N[S]});const D=G.toFiniteNumber(N.headers.get("content-length")),[C,y]=c&&Us(D,va(As(c),!0))||[];N=new Response(Ls(N.body,zs,C,()=>{y&&y(),g&&g()}),x)}d=d||"text";let h=await ga[G.findKey(ga,d)||"text"](N,a);return!w&&g&&g(),await new Promise((x,D)=>{cc(x,D,{data:h,headers:bt.from(N.headers),status:N.status,statusText:N.statusText,config:a,request:v})})}catch(T){throw g&&g(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Fe("Network Error",Fe.ERR_NETWORK,a,v),{cause:T.cause||T}):Fe.from(T,T&&T.code,a,v)}}),ji={http:yy,xhr:Gy,fetch:ow};G.forEach(ji,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const Ps=a=>`- ${a}`,aw=a=>G.isFunction(a)||a===null||a===!1,fc={getAdapter:a=>{a=G.isArray(a)?a:[a];const{length:n}=a;let t,o;const i={};for(let r=0;r<n;r++){t=a[r];let s;if(o=t,!aw(t)&&(o=ji[(s=String(t)).toLowerCase()],o===void 0))throw new Fe(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
339
- `+r.map(Ps).join(`
340
- `):" "+Ps(r[0]):"as no adapter specified";throw new Fe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:ji};function yi(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Zn(null,a)}function js(a){return yi(a),a.headers=bt.from(a.headers),a.data=gi.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),fc.getAdapter(a.adapter||Mo.adapter)(a).then(function(o){return yi(a),o.data=gi.call(a,a.transformResponse,o),o.headers=bt.from(o.headers),o},function(o){return lc(o)||(yi(a),o&&o.response&&(o.response.data=gi.call(a,a.transformResponse,o.response),o.response.headers=bt.from(o.response.headers))),Promise.reject(o)})}const hc="1.11.0",za={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{za[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const Ws={};za.transitional=function(n,t,o){function i(r,s){return"[Axios v"+hc+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,c)=>{if(n===!1)throw new Fe(i(s," has been removed"+(t?" in "+t:"")),Fe.ERR_DEPRECATED);return t&&!Ws[s]&&(Ws[s]=!0),n?n(r,s,c):!0}};za.spelling=function(n){return(t,o)=>!0};function iw(a,n,t){if(typeof a!="object")throw new Fe("options must be an object",Fe.ERR_BAD_OPTION_VALUE);const o=Object.keys(a);let i=o.length;for(;i-- >0;){const r=o[i],s=n[r];if(s){const c=a[r],l=c===void 0||s(c,r,a);if(l!==!0)throw new Fe("option "+r+" must be "+l,Fe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Fe("Unknown option "+r,Fe.ERR_BAD_OPTION)}}const aa={assertOptions:iw,validators:za},Ot=aa.validators;let wn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new $s,response:new $s}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
341
- `+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=kn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&aa.assertOptions(o,{silentJSONParsing:Ot.transitional(Ot.boolean),forcedJSONParsing:Ot.transitional(Ot.boolean),clarifyTimeoutError:Ot.transitional(Ot.boolean)},!1),i!=null&&(G.isFunction(i)?t.paramsSerializer={serialize:i}:aa.assertOptions(i,{encode:Ot.function,serialize:Ot.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),aa.assertOptions(t,{baseUrl:Ot.spelling("baseURL"),withXsrfToken:Ot.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&G.merge(r.common,r[t.method]);r&&G.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=bt.concat(s,r);const c=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(l=l&&g.synchronous,c.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,m=0,f;if(!l){const v=[js.bind(this),void 0];for(v.unshift(...c),v.push(...d),f=v.length,u=Promise.resolve(t);m<f;)u=u.then(v[m++],v[m++]);return u}f=c.length;let p=t;for(m=0;m<f;){const v=c[m++],g=c[m++];try{p=v(p)}catch(E){g.call(this,E);break}}try{u=js.call(this,p)}catch(v){return Promise.reject(v)}for(m=0,f=d.length;m<f;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=kn(this.defaults,n);const t=dc(n.baseURL,n.url,n.allowAbsoluteUrls);return ic(t,n.params,n.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(n){wn.prototype[n]=function(t,o){return this.request(kn(o||{},{method:n,url:t,data:(o||{}).data}))}});G.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,c){return this.request(kn(c||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}wn.prototype[n]=t(),wn.prototype[n+"Form"]=t(!0)});let rw=class vc{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(c=>{o.subscribe(c),r=c}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,c){o.reason||(o.reason=new Zn(r,s,c),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=o=>{n.abort(o)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new vc(function(i){n=i}),cancel:n}}};function sw(a){return function(t){return a.apply(null,t)}}function lw(a){return G.isObject(a)&&a.isAxiosError===!0}const Wi={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(Wi).forEach(([a,n])=>{Wi[n]=a});function gc(a){const n=new wn(a),t=Hl(wn.prototype.request,n);return G.extend(t,wn.prototype,n,{allOwnKeys:!0}),G.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return gc(kn(a,i))},t}const Je=gc(Mo);Je.Axios=wn;Je.CanceledError=Zn;Je.CancelToken=rw;Je.isCancel=lc;Je.VERSION=hc;Je.toFormData=Oa;Je.AxiosError=Fe;Je.Cancel=Je.CanceledError;Je.all=function(n){return Promise.all(n)};Je.spread=sw;Je.isAxiosError=lw;Je.mergeConfig=kn;Je.AxiosHeaders=bt;Je.formToJSON=a=>sc(G.isHTMLForm(a)?new FormData(a):a);Je.getAdapter=fc.getAdapter;Je.HttpStatusCode=Wi;Je.default=Je;const{Axios:j3,AxiosError:W3,CanceledError:Z3,isCancel:X3,CancelToken:H3,VERSION:G3,all:J3,Cancel:Y3,isAxiosError:K3,spread:q3,toFormData:Q3,AxiosHeaders:eV,HttpStatusCode:tV,formToJSON:nV,getAdapter:oV,mergeConfig:aV}=Je;class gr{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Je.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const o=this.getAuthToken();return o&&(t.headers.Authorization=`Bearer ${o}`),t}),this.api.interceptors.response.use(t=>t,t=>{var o;return(o=t.response)==null||o.status,Promise.reject(t)})}async createJob(n){try{const t=await this.api.post("/video/jobs",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(n){try{const t=await this.api.post("/video/jobs/render",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(n,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,c)=>{const l=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(l),s(d)):d.status==="failed"?(clearInterval(l),c(new Error(d.error_message??"Render job failed"))):Date.now()-r>i&&(clearInterval(l),c(new Error("Render job timed out")))}catch(d){clearInterval(l),c(d)}},o)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{await this.api.delete(`/video/jobs/${n}`),this.unsubscribeFromProgress(n)}catch(t){throw t}}async retryJob(n){try{const t=await this.api.post(`/video/jobs/${n}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(n,t){this.progressCallbacks.set(n,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(n)}unsubscribeFromProgress(n){this.progressCallbacks.delete(n),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const n=this.getAuthToken(),t=`/api/v1/video/jobs/events${n?`?token=${n}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",o=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const o=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(o.progress),(o.status==="completed"||o.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const o of t){const[i,r]=o.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(n){try{return(await this.api.get(`/video/jobs/${n}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(n,t=0){try{const o=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(n){const t=n,o={...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??""},i=t.output_media_id??t.outputMediaId;typeof i=="string"&&i!==""&&(o.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(o.error_message=r);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(o.started_at=s);const c=t.completed_at??t.completedAt;return typeof c=="string"&&c!==""&&(o.completed_at=c),o}}new gr;const cw={key:0,class:"mobile-layout"},dw={class:"mobile-toolbar"},uw={class:"mobile-toolbar-left"},mw=["aria-label"],pw={class:"mobile-toolbar-right"},fw=["disabled"],hw=["disabled"],vw={class:"preview-section"},gw={key:0,class:"mobile-export-overlay"},yw={class:"mobile-export-progress"},ww={class:"mobile-export-bar"},bw={class:"mobile-timeline-zoom"},kw={key:1,class:"desktop-layout"},xw={class:"desktop-main-row"},Ew={class:"preview-panel"},Vw={class:"fit-toggle"},Sw={class:"editor-content"},Cw={class:"editor-tabs"},Nw={class:"tab-header"},_w=["onClick"],Tw={class:"tab-content-area"},Mw={class:"filter-controls"},Bw={class:"text-controls"},Fw={class:"transition-controls"},Iw={class:"audio-controls"},Rw={class:"adjustments-controls"},$w={key:1,class:"no-filter-selected"},Dw={class:"export-controls"},Uw={key:0,"data-testid":"video-export-status-completed"},Aw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Ow={class:"desktop-timeline-row"},Lw={class:"timeline-zoom"},zw=["value"],Pw={class:"zoom-readout"},jw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Ww={class:"dev-editor-row"},Zw={class:"dev-editor-field"},Xw={class:"dev-editor-field"},Hw=["disabled"],Gw=["disabled"],Jw=["disabled"],Yw={class:"dev-editor-row"},Kw={class:"dev-editor-field dev-editor-field--wide"},qw=["value"],Qw=["disabled"],eb=["disabled"],tb=["disabled"],nb=["disabled"],ob=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:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const b=o.media.uuid??o.media.id;return typeof b=="string"&&b.trim()!==""?b.trim():void 0}),s=e.computed(()=>{const b=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return b!==""?b:r.value??`temp-${Date.now()}`}),c=e.ref(typeof window<"u"?window.innerWidth<768:!1),l=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const b=o.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=o.featureFlags;return V?{filters:typeof V.filters=="boolean"?V.filters:b.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:b.adjustments,text:typeof V.text=="boolean"?V.text:b.text,transitions:typeof V.transitions=="boolean"?V.transitions:b.transitions,audio:typeof V.audio=="boolean"?V.audio:b.audio,export:typeof V.export=="boolean"?V.export:b.export}:b}),m=e.computed(()=>c.value?l.value:d.value),f=e.computed(()=>m.value==="filters"||E.value),p=e.computed(()=>m.value!=="filters"&&!E.value),v=e.ref(null),g=e.ref(null),E=e.ref(!1),T=e.computed(()=>c.value?v.value:g.value);function N(b){return b==="contain"||b==="cover"||b==="none"}function w(b){if(!(b!=null&&b.metadata))return null;const V=b.metadata.fit_mode;return N(V)?V:null}const h=e.shallowRef(null),x=e.ref(null),D=e.ref(w(o.initialRecipe)??"contain"),C=e.ref(null),y=e.ref(null),S=e.ref(null),A=e.ref(!1),k=new Map,B=e.ref([]),R=e.ref([]),U=e.ref([]),_=e.ref([]),z=e.ref(1),H=()=>{c.value=window.innerWidth<768},M=[{id:"filters",label:"Filters",icon:rn},{id:"adjustments",label:"Adjust",icon:xu},{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:ho}],$=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],X=e.computed(()=>M.filter(b=>u.value[b.id])),j=e.computed(()=>$.filter(b=>u.value[b.id])),te=e.computed(()=>{var b,V;return((b=j.value[0])==null?void 0:b.id)??((V=X.value[0])==null?void 0:V.id)??"filters"});e.watch(u,b=>{b[l.value]||(l.value=te.value),b[d.value]||(d.value=te.value)},{immediate:!0,deep:!0}),e.watch(te,b=>{u.value[l.value]||(l.value=b),u.value[d.value]||(d.value=b)},{immediate:!0}),e.watch(u,b=>{b.export||(l.value==="export"&&(l.value=te.value),d.value==="export"&&(d.value=te.value))},{immediate:!0,deep:!0});const ge=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:Ne,playheadPosition:ee,timelineClips:F,totalDuration:P,hasChanges:fe,isPlaying:ne,selectedClip:Y,zoomLevel:Me,playbackSpeed:ce,handleTrim:se,handleSplit:ke,handleClipSelect:oe,splitAtPlayhead:le,deleteSelectedClip:Ee,duplicateSelectedClip:Se,setZoomLevel:rt,moveClip:He,setFilters:pt,setTextOverlays:K,setAudioTracks:de,saveDraft:ie,clearHasChanges:he,resetChanges:_e,generateRecipe:J,zoomIn:ue,zoomOut:ve,fitToWindow:Z,togglePlayback:Q,setPlaying:ae,seekTo:xe,frameForward:De,frameBackward:Qe,skipToStart:We,skipToEnd:ft,setPlaybackSpeed:Ze,updateSourceDuration:Xt}=bg(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:Za,activeFilters:et,selectedFilter:Nr,previewFilter:Bo,previewFilterEffect:_r,applyFilter:Tr,updateFilterParams:Bc,removeFilter:Fc,clearAllFilters:Mr,setActiveFilters:Ic}=Mg();function Xn(b){var W,q;const V=((W=Y.value)==null?void 0:W.id)??((q=F.value[0])==null?void 0:q.id);V&&(A.value=!0,typeof b=="object"&&b.id?Tr(b.id):typeof b=="string"&&Tr(b),pt(et.value),h.value?h.value.setClipFilters(V,et.value):k.set(V,[...et.value]),oe(V),A.value=!1,Dt())}function Rc(){var V,W;const b=((V=Y.value)==null?void 0:V.id)??((W=F.value[0])==null?void 0:W.id);b&&oe(b)}function Br(b){const V=et.value.find(W=>W.filterId===b);V&&Fc(V.id)}const Hn=e.computed(()=>Za.value.map(V=>{var q;const W=[];if(V.controls&&V.controls.length>0)for(const me of V.controls){const re=me.type;if(re==="button"||re==="text"||re==="range")continue;const pe={id:me.property||me.id,label:me.label||me.id,type:re,default:me.default??(re==="toggle"?!1:re==="color"?"#ffffff":0)};re==="slider"&&(pe.min=me.min??0,pe.max=me.max??1,pe.step=me.step??.01),re==="select"&&me.options&&(pe.options=me.options),W.push(pe)}else if(V.paramRanges){const me=Object.entries(V.paramRanges);for(const[re,pe]of me){const Ae=re.replace(/[-_]/g," ").replace(/\b\w/g,Ut=>Ut.toUpperCase()),ht=(q=V.defaultParams)==null?void 0:q[re],Jt=(pe.min+pe.max)/2;W.push({id:re,label:Ae,min:pe.min,max:pe.max,step:pe.step??.01,default:typeof ht=="number"?ht:Jt})}}return{id:V.id,name:V.name,category:V.category,params:W}})),Sn=e.ref("0.00"),Cn=e.ref("0.00"),Qt=e.ref("");e.watch(Hn,b=>{if(b.length===0){Qt.value="";return}b.some(W=>W.id===Qt.value)||(Qt.value=b[0].id)},{immediate:!0});const nt=e.ref(!1),Xe=e.ref(0),Ht=e.ref(!1),je=e.ref(null),Tt=e.ref(null);let Fo=null,Ct=!1,Gt=null;const Xa=e.computed(()=>{const b=new Map;return et.value.forEach(V=>b.set(V.filterId,V)),b}),$c=e.computed(()=>{var b,V;return Ne.value?Ne.value:((b=o.media)==null?void 0:b.thumbnail_url)||((V=o.media)==null?void 0:V.url)}),Rt=e.ref("");e.watch(()=>{var b,V;return{file:(b=o.media)==null?void 0:b.file,url:(V=o.media)==null?void 0:V.url}},(b,V,W)=>{var me,re;const q=Rt.value;W(()=>{q&&q.startsWith("blob:")&&URL.revokeObjectURL(q)}),(me=o.media)!=null&&me.file?Rt.value=URL.createObjectURL(o.media.file):(re=o.media)!=null&&re.url?Rt.value=o.media.url:Rt.value=""},{immediate:!0}),e.onUnmounted(()=>{Rt.value&&Rt.value.startsWith("blob:")&&URL.revokeObjectURL(Rt.value)});const Ha=e.computed(()=>Rt.value),Fr=e.computed(()=>{if(!o.media)return null;const{file:b,...V}=o.media;return{...V,url:Rt.value}}),Ir=e.computed(()=>{var V;const b=(V=o.media)==null?void 0:V.url;return!!(b&&/^https?:/i.test(b))}),Rr=e.computed(()=>et.value),$r=e.computed(()=>ee.value),Dc=e.computed(()=>!!Y.value&&ee.value>0),Uc=e.computed(()=>!!Y.value&&F.value.length>1),Ga=e.ref(0),$t=e.computed(()=>{try{const b=P.value??P;return b&&typeof b=="number"&&b>0?b:Ga.value}catch{return Ga.value}}),Nn=e.ref(),Ja=e.ref(),Io=e.ref(0),ln=e.ref(!1);let gt=null;e.watch($t,b=>{var W;if(ln.value||!b||b<=0)return;const V=Io.value||((W=Nn.value)==null?void 0:W.clientWidth)||0;V>0&&(ln.value=!0,Z(V))}),e.watch(Io,b=>{if(ln.value||!b||b<=0)return;$t.value>0&&(ln.value=!0,Z(b))});function _n(b){return Number.isFinite(b)?b.toFixed(2):"0.00"}function Dr(b){const V=Number(b);return Number.isFinite(V)?V:null}function Ac(b){b&&(Sn.value=_n(b.sourceIn),Cn.value=_n(b.sourceOut))}e.watch(()=>{var b,V,W;return[(b=Y.value)==null?void 0:b.id,(V=Y.value)==null?void 0:V.sourceIn,(W=Y.value)==null?void 0:W.sourceOut]},()=>{Ac(Y.value)},{immediate:!0});function Ur(b){const V=Y.value;if(!V)return;const W=1/30,q=V.sourceMinIn??0,me=V.sourceMaxOut??$t.value,re=V.sourceIn+(ee.value-V.timelineStart);if(b==="start"){const Ae=Math.max(q,Math.min(re,V.sourceOut-W));Sn.value=_n(Ae);return}const pe=Math.max(V.sourceIn+W,Math.min(re,me));Cn.value=_n(pe)}function Oc(){const b=Y.value;if(!b)return;const V=Dr(Sn.value),W=Dr(Cn.value);if(V===null||W===null)return;const q=1/30,me=b.sourceMinIn??0,re=b.sourceMaxOut??$t.value,pe=Math.max(me,Math.min(V,re-q)),Ae=Math.max(pe+q,Math.min(W,re));se(b.id,"start",pe),se(b.id,"end",Ae),Sn.value=_n(pe),Cn.value=_n(Ae),Y.value&&xe(Y.value.timelineStart)}function Lc(){Qt.value.trim()!==""&&Xn(Qt.value)}function zc(){var b;Mr(),pt(et.value),(b=Y.value)!=null&&b.id&&(h.value?h.value.setClipFilters(Y.value.id,et.value):k.set(Y.value.id,[...et.value])),Dt()}function Ar(b,V,W){var me,re;const q=et.value.find(pe=>pe.filterId===b);q?(q.params={...q.params,[V]:W},pt(et.value),h.value&&((me=Y.value)!=null&&me.id)?h.value.setClipFilters(Y.value.id,et.value):(re=Y.value)!=null&&re.id&&k.set(Y.value.id,[...et.value]),Dt(),Rc()):Bo.value&&Bo.value.filterId===b&&(Bo.value.params={...Bo.value.params||{},[V]:W})}function Or(b){xe(b)}function Lr(b){!b||!Number.isFinite(b.timestamp)||xe(b.timestamp)}function zr(b){ae(b)}function Ro(b){!Number.isFinite(b)||b<=0||(Ga.value=b,Xt(b))}function Pc(){var V;const b=Io.value||((V=Nn.value)==null?void 0:V.clientWidth)||800;Z(b)}function Ya(b){ln.value=!0,rt(b)}function jc(){ln.value=!0,ue()}function Wc(){ln.value=!0,ve()}function Zc(b){const V=b.target,W=Number(V.value);Ya(W)}function Pr(b){const V=Math.min(600,Math.max(10,Me.value+b));Ya(V)}function jr(b){var V;h.value=b,(V=h.value)!=null&&V.composition&&(C.value=new Bg(h.value.composition),y.value=new ha(h.value.composition),S.value=new Fg(h.value.composition));try{k.size&&(k.forEach((W,q)=>{h.value.setClipFilters(q,W)}),k.clear(),h.value.composition.computeFrame())}catch{}}function Xc(b){b!=null&&b.id&&_r(b.id)}function Hc(b){Bc(b),Dt()}async function Gc(b){if(!C.value)return;const V=await C.value.addTextOverlay(b);B.value.push({id:V,...b})}async function Jc(b,V){if(!C.value)return;await C.value.updateTextOverlay(b,V);const W=B.value.findIndex(q=>q.id===b);W!==-1&&(B.value[W]={...B.value[W],...V})}async function Yc(b){C.value&&(await C.value.removeTextOverlay(b),B.value=B.value.filter(V=>V.id!==b))}async function Kc(b){if(!y.value||_.value.length<2)return;const[V,W]=_.value,q=await y.value.applyTransition(V,W,b);R.value.push({id:q,...b,name:b.type})}function qc(b){if(!y.value)return;const V=R.value[b];V&&(y.value.removeTransition(V.id),R.value.splice(b,1))}function Qc(b){}async function ed(b){if(!S.value)return;const V=await S.value.addAudioTrack(b);U.value.push({id:V,...b})}async function td(b,V){if(!S.value)return;const W=U.value.findIndex(q=>q.id===b);W!==-1&&(U.value[W]={...U.value[W],...V})}async function nd(b){S.value&&(await S.value.removeAudioTrack(b),U.value=U.value.filter(V=>V.id!==b))}async function od(b,V){if(!S.value)return;await S.value.updateVolume(b,V);const W=U.value.find(q=>q.id===b);W&&(W.volume=V)}async function ad(b,V){if(!S.value)return;await S.value.muteTrack(b,V);const W=U.value.find(q=>q.id===b);W&&(W.muted=V)}function id(b){S.value&&(S.value.setMasterVolume(b),z.value=b)}function rd(b){i("thumbnail-selected",b)}function en(){Fo!==null&&(clearInterval(Fo),Fo=null)}function sd(b,V){return V?{...b,output:{...b.output,format:V.format,quality:V.quality}}:b}function Gn(b){var V;return b.metadata||(b.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),b.metadata.fit_mode=D.value,(V=o.media)!=null&&V.url&&/^https?:/i.test(o.media.url)?b.metadata.source_url=o.media.url:delete b.metadata.source_url,b}function Ge(b,V,W){return Math.min(W,Math.max(V,b))}function Ka(b,V){if(typeof b=="number"&&Number.isFinite(b))return b;if(typeof b=="string"){const W=Number(b);if(Number.isFinite(W))return W}return V}function dt(b,V,W){for(const q of V)if(q in b)return Ka(b[q],W);return W}function ld(b){const V=typeof b.params=="object"&&b.params!==null?b.params:{};switch(b.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Ge(dt(V,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Ge(dt(V,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Ge(dt(V,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Ge(dt(V,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Ge(dt(V,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const q=Ge(dt(V,["brightness"],1)-1,-1,1),me=Ge(dt(V,["contrast"],1),.1,3),re=Ge(dt(V,["saturation"],1),0,3);return[{type:"brightness",value:q},{type:"contrast",value:me},{type:"saturation",value:re}]}default:return[]}}function cd(b){const V=b.timeline[0],W=Array.isArray(V==null?void 0:V.filters)?V.filters:[],q=[];for(const re of W)if(q.push(...ld(re)),q.length>=12)break;const me={...b,filters:q.slice(0,12)};if(b.timeline.length===1&&V){const re=Math.max(0,Ka(V.sourceIn,0)),pe=Ka(V.sourceOut,re);pe>re&&(me.trim={start:re,end:pe})}return me}function dd(b){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[b??""]??[1920,1080]}function ud(b){if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const W=V.value;if(typeof W=="number"&&Number.isFinite(W)&&W>0)return W}return null}async function Wr(b,V,W){var Jt,Ut,Tn,nn;const q=b.timeline[0],me=q?Math.max(0,q.sourceIn):0,re=q?q.sourceOut:void 0,[pe,Ae]=dd((V==null?void 0:V.quality)??((Jt=b.output)==null?void 0:Jt.quality)),ht=((Ut=b.output)==null?void 0:Ut.fps)||30;ae(!1),E.value=!0,await e.nextTick();try{const ot=[200,500,1e3];let st=!1;for(const ii of ot){await new Promise(Bd=>setTimeout(Bd,ii));const Uo=T.value;if(!(!Uo||typeof Uo.captureFrameAt!="function")&&typeof Uo.ensureReadyForCapture=="function"&&(st=await Uo.ensureReadyForCapture(),st))break}const At=T.value;if(!At||typeof At.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!st)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Jn,isWebCodecsSupported:oi}=await Promise.resolve().then(()=>require("./PixiFrameExporter-BH1iOPjQ.cjs"));if(!oi())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Gt=new AbortController;const Do={width:pe,height:Ae,fps:ht,trimStart:me,signal:Gt.signal};re!==void 0&&(Do.trimEnd=re),W&&(Do.onProgress=W);const Qr=Rt.value;Qr!==""&&(Do.sourceUrl=Qr);const Cd=typeof At.duration=="number"&&At.duration>0?At.duration:((Tn=b.source)==null?void 0:Tn.duration)??re??0,Nd=await Jn({captureFrameAt:ii=>At.captureFrameAt(ii),duration:{value:Cd}},Do),ai=new File([Nd],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),_d=ud(At),Td=((nn=b.source)==null?void 0:nn.duration)??0,Md=Math.max(0,(re??_d??Td)-me);return{file:ai,recipe:b,meta:{duration:Md,width:pe,height:Ae,format:"mp4",sizeBytes:ai.size,size_bytes:ai.size}}}finally{E.value=!1,Gt=null}}async function md(b,V){var nn;en(),Ct=!1,Gt=null,Tt.value=null,je.value=null,Ht.value=!1,Xe.value=0;const W=Gn(b??J()),q=Kr(W),me=Array.isArray(q.filters)&&q.filters.length>0,re=ei(q);if(!(fe.value||me||re))return he(),i("video-exported",null),null;const Ae=q.timeline[0],ht=Ae?Math.max(0,Ae.sourceIn):0,Ut=((Ae==null?void 0:Ae.sourceOut)??((nn=q.source)==null?void 0:nn.duration)??$t.value)-ht,Tn=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&Ut>o.clientExportThreshold;if(Tn){nt.value=!0;try{return await pd(q),null}catch(ot){const st=ot instanceof Error?ot.message:"Server render failed";throw je.value=st,i("server-render-failed",st),ot}finally{nt.value=!1}}if(o.maxDuration>0&&Ut>o.maxDuration&&!Tn){const ot=`This video is too long for in-browser export (${Math.round(Ut)}s). Server rendering is not available. Try a shorter clip.`;return je.value=ot,i("video-exported",null),null}nt.value=!0;try{const ot=await Wr(q,V,st=>{Ct||(Xe.value=st)});return Ct?(je.value="Export canceled.",Xe.value=0,i("video-exported",null),null):(he(),i("recipe-generated",q),i("video-exported",ot),Xe.value=100,Ht.value=!0,ot)}catch(ot){if(Ct)return je.value="Export canceled.",Xe.value=0,i("video-exported",null),null;const st=ot instanceof Error?ot.message:"Local WebGL export failed.";throw je.value=st,new Error(`Video export failed: ${st}`)}finally{nt.value=!1}}function $o(){return new gr(o.serverRenderEndpoint??"/api/v1")}async function pd(b){const V=$o();je.value="Starting server render...",Xe.value=0;const W=await V.createRenderJob({source_media_uuid:s.value,recipe:b});Tt.value=W.id,i("server-render-started",W.id),i("export-started",W.id),je.value="Rendering on server...";const q=await V.pollRenderJob(W.id,(re,pe)=>{Xe.value=re,pe==="processing"&&(je.value=`Server rendering: ${re}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);Xe.value=100,Ht.value=!0,je.value="Server render complete!",he(),i("recipe-generated",b);const me={id:q.id};typeof q.output_media_id=="string"&&q.output_media_id!==""&&(me.output_media_id=q.output_media_id),i("server-render-completed",me)}async function Zr(){if(!nt.value)return;Ct=!0,E.value=!1,Gt&&(Gt.abort(),Gt=null),en();const b=Tt.value;if(b)try{await $o().cancelJob(b)}catch(V){const W=V instanceof Error?V.message:"Failed to cancel export";je.value=W,nt.value=!1,Tt.value=null;return}nt.value=!1,Xe.value=0,Ht.value=!1,Tt.value=null,je.value="Export canceled."}async function Xr(b){en(),Ct=!1,Gt=null,Tt.value=null,je.value=null,Ht.value=!1,nt.value=!0,Xe.value=0;try{const V=Gn(sd(J(),b));i("recipe-generated",V);const W=s.value.startsWith("temp-"),q=V.timeline[0],me=Array.isArray(q==null?void 0:q.filters)?q.filters:[],re=!0,pe=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(re)try{const st=await Wr(V,b,oi=>{Ct||(Xe.value=oi)});if(Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0;return}i("video-exported",st);const At=URL.createObjectURL(st.file),Jn=document.createElement("a");Jn.href=At,Jn.download=`edited-video-${Date.now()}.mp4`,Jn.click(),setTimeout(()=>URL.revokeObjectURL(At),100),nt.value=!1,Xe.value=100,Ht.value=!0;return}catch(st){if(Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0;return}if(W||!pe)throw st;Xe.value=0,je.value="Local filter export failed, falling back to server render."}const Ae={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},ht=(b==null?void 0:b.quality)??V.output.quality,Jt=Ae[ht]??"high",Ut={...cd(V),export:{format:(b==null?void 0:b.format)??V.output.format,quality:Jt,resolution:ht,framerate:V.output.fps}},nn=await $o().createJob({source_media_id:s.value,recipe:Ut}),ot=typeof nn.id=="string"?nn.id:null;if(!ot)throw new Error("Export failed: missing job id");Tt.value=ot,i("export-started",ot),Vd(ot)}catch(V){if(E.value=!1,Gt=null,Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0,Tt.value=null;return}try{const W=Gn(J()),q=new Blob([JSON.stringify(W,null,2)],{type:"application/json"}),me=URL.createObjectURL(q),re=document.createElement("a");re.href=me,re.download=`video-recipe-${Date.now()}.json`,re.click(),setTimeout(()=>URL.revokeObjectURL(me),100)}finally{nt.value=!1,Xe.value=0,Tt.value=null,je.value=V instanceof Error?V.message:"Export failed"}}}const qa=async b=>{await new Promise(V=>{window.setTimeout(V,b)})},Qa=b=>{if(!b||b.width<=0||b.height<=0)return null;try{return b.toDataURL("image/jpeg",.85)}catch{return null}},fd=b=>{if(!b||typeof b!="object")return null;const W=b.pixiCanvas;if(W&&typeof W=="object"&&"value"in W){const q=W.value;return q instanceof HTMLCanvasElement?q:null}return W instanceof HTMLCanvasElement?W:null},hd=b=>{if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const W=V.value;if(typeof W=="number"&&Number.isFinite(W))return W}return null},vd=b=>{if(!b||typeof b!="object")return null;const W=b.videoElement;if(W&&typeof W=="object"&&"value"in W){const q=W.value;return q instanceof HTMLVideoElement?q:null}return W instanceof HTMLVideoElement?W:null},Hr=b=>typeof b.params=="object"&&b.params!==null?b.params:{},gd=b=>{const V=[];for(const W of b){const q=Hr(W),me=W.filterId.trim().toLowerCase();if(me==="brightness"){const pe=(Ge(dt(q,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${pe.toFixed(2)}%)`);continue}if(me==="contrast"){const re=Ge(dt(q,["value","contrast"],1),.1,4);V.push(`contrast(${(re*100).toFixed(2)}%)`);continue}if(me==="saturation"||me==="saturate"){const re=Ge(dt(q,["value","saturation"],1),0,4);V.push(`saturate(${(re*100).toFixed(2)}%)`);continue}if(me==="grayscale"){V.push("grayscale(100%)");continue}if(me==="sepia"){V.push("sepia(100%)");continue}if(me==="blur"||me==="gaussian-blur"||me==="kawase-blur"){const re=Ge(dt(q,["value","blur","radius"],0),0,30);re>.01&&V.push(`blur(${re.toFixed(2)}px)`);continue}if(me==="adjustment"){const re=dt(q,["brightness"],1),pe=dt(q,["contrast"],1),Ae=dt(q,["saturation"],1);Math.abs(re-1)>.01&&V.push(`brightness(${(Ge(re,0,5)*100).toFixed(2)}%)`),Math.abs(pe-1)>.01&&V.push(`contrast(${(Ge(pe,.1,5)*100).toFixed(2)}%)`),Math.abs(Ae-1)>.01&&V.push(`saturate(${(Ge(Ae,0,5)*100).toFixed(2)}%)`);continue}if(me==="cinematic"){V.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(me==="dramatic"){V.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(me==="dreamy"){V.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return V.join(" ")},yd=b=>{const V=b.find(me=>me.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const W=Hr(V),q=dt(W,["noise","value","amount","intensity"],.2);return q<=1?Ge(q,0,1):Ge(q/100,0,1)},wd=(b,V,W,q)=>{if(q<=0)return;const me=b.getImageData(0,0,V,W),re=255*q;for(let pe=0;pe<me.data.length;pe+=4){const Ae=(Math.random()*2-1)*re;me.data[pe]=Ge(me.data[pe]+Ae,0,255),me.data[pe+1]=Ge(me.data[pe+1]+Ae,0,255),me.data[pe+2]=Ge(me.data[pe+2]+Ae,0,255)}b.putImageData(me,0,0)},Gr=async b=>{b.readyState>=2&&b.videoWidth>0&&b.videoHeight>0||await new Promise(V=>{let W=!1,q=0;const me=()=>{W||(W=!0,b.removeEventListener("loadedmetadata",re),b.removeEventListener("loadeddata",re),b.removeEventListener("canplay",re),window.clearTimeout(q),V())},re=()=>{me()};b.addEventListener("loadedmetadata",re),b.addEventListener("loadeddata",re),b.addEventListener("canplay",re),q=window.setTimeout(()=>me(),800),b.play().catch(()=>{})})},bd=async(b,V)=>{await new Promise(W=>{let q=!1,me=0;const re=()=>{q||(q=!0,b.removeEventListener("seeked",pe),window.clearTimeout(me),W())},pe=()=>{re()};if(Math.abs(b.currentTime-V)<.016){requestAnimationFrame(()=>re());return}b.addEventListener("seeked",pe),me=window.setTimeout(()=>re(),700),b.currentTime=V})},Jr=async(b,V)=>{await Gr(b);const W=Math.floor(b.videoWidth),q=Math.floor(b.videoHeight);if(W<=0||q<=0)return null;const me=Number.isFinite(b.duration)&&b.duration>0?b.duration:0,re=me>0?Ge(V,0,me):0;await bd(b,re);const pe=document.createElement("canvas");pe.width=W,pe.height=q;const Ae=pe.getContext("2d");if(!Ae)return null;const ht=gd(et.value);ht!==""&&(Ae.filter=ht);try{Ae.drawImage(b,0,0,W,q)}catch{return null}const Jt=yd(et.value);return wd(Ae,W,q,Jt),Qa(pe)},kd=async(b,V)=>{const W=document.createElement("video");W.src=b,W.muted=!0,W.playsInline=!0,W.preload="auto",b.startsWith("blob:")||(W.crossOrigin="anonymous");try{return await Gr(W),await Jr(W,V)}catch{return null}finally{W.pause(),W.removeAttribute("src"),W.load()}},xd=async b=>{const V=T.value,W=Qa(fd(V));if(W)return W;if(V!=null&&V.captureFrameAt)for(let re=0;re<4;re+=1){const pe=hd(V);if(pe!==null&&pe<=0&&re<2){await qa(80);continue}const Ae=await Promise.race([V.captureFrameAt(b),qa(450).then(()=>null)]),ht=Qa(Ae);if(ht)return ht;await qa(80)}const q=vd(V);if(q){const re=await Jr(q,b);if(re)return re}const me=Ha.value.trim();if(me!==""){const re=await kd(me,b);if(re)return re}return null},Yr=b=>b.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function Kr(b){const V=Yr(et.value);if(!ei(b)&&V.length>0&&Array.isArray(b.timeline)&&b.timeline.length>0){const q=b.timeline[0];q&&(b.timeline=[{...q,filters:V},...b.timeline.slice(1)])}return b}const ei=b=>Array.isArray(b.timeline)?b.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,Ed=b=>{if(!b||typeof b!="object")return null;const V=b.posterFrame;if(typeof V!="string")return null;const W=V.trim();return W!==""?W:null};async function ti(){const b=Gn(Kr(ie())),V=Yr(et.value),W=ei(b)||V.length>0,q=Ed(o.initialRecipe);if(W){const me=ee.value>0?ee.value:.1;try{const re=await xd(me);re?b.posterFrame=re:q&&(b.posterFrame=q)}catch{q&&(b.posterFrame=q)}}else delete b.posterFrame;return he(),i("draft-saved",b),b}function qr(){_e()&&(Mr(),Dt())}async function Vd(b){en();const V=$o();Fo=window.setInterval(async()=>{try{if(Ct){en();return}const W=await V.getJob(b),q=Number(W.progress??0);if(Xe.value=Number.isFinite(q)?q:0,W.status==="completed"||W.status==="failed"||W.status==="cancelled")if(en(),nt.value=!1,Tt.value=null,W.status==="completed")Xe.value=100,Ht.value=!0,je.value=null;else{const me=W.status==="cancelled"||typeof W.error_message=="string"&&/cancel/i.test(W.error_message);je.value=me?"Export canceled.":typeof W.error_message=="string"&&W.error_message.trim()!==""?W.error_message:"Export failed"}}catch(W){en(),nt.value=!1,Tt.value=null,je.value=W instanceof Error?W.message:"Failed to check export progress"}},2e3)}function ni(){const b=Gn(J());try{const V=b.timeline??[]}catch{}x.value=b}let cn=null;function Dt(){cn&&clearTimeout(cn),cn=setTimeout(()=>{ni(),cn=null},200)}e.watch(()=>F.value,Dt,{deep:!0}),e.watch(()=>Y.value,b=>{if(A.value||!b)return;const V=(b==null?void 0:b.filters)??[];Ic(V)},{immediate:!0}),e.watch(()=>et.value,b=>{pt(b),Dt()},{deep:!0}),e.watch(()=>B.value,b=>{K(b),Dt()},{deep:!0}),e.watch(()=>U.value,b=>{const V=b.map(W=>({...W,source:typeof W.source=="string"?W.source:void 0}));de(V),Dt()},{deep:!0}),e.watch(()=>ee.value,Dt),n({saveDraft:ti,exportForUpload:md}),ni(),e.onUnmounted(()=>{en(),Ct=!0,cn&&(clearTimeout(cn),cn=null),h.value&&(h.value.destroy(),h.value=null),C.value=null,y.value=null,S.value=null});function Sd(){gt||!Ja.value||(gt=new hg({filters:Hn.value,callbacks:{onApplyFilter:b=>{Xn(b.id)},onRemoveFilter:b=>{Br(b)},onUpdateParam:(b,V,W)=>{Ar(b,V,W)},onPreviewFilter:b=>{_r(b.id)}}}),gt.mount(Ja.value),gt.setActiveFilters(Xa.value))}e.watch(Xa,b=>{gt==null||gt.setActiveFilters(b)},{deep:!0}),e.watch(Hn,b=>{gt==null||gt.setFilters(b)});let tn=null;return e.onMounted(()=>{window.addEventListener("resize",H);const b=()=>{!Nn.value||tn||(tn=new ResizeObserver(V=>{V[0]&&(Io.value=Math.round(V[0].contentRect.width))}),tn.observe(Nn.value))};b(),tn||e.nextTick(b),o.media&&ni(),c.value&&e.nextTick(()=>{Sd()}),e.nextTick(()=>{const V=document.querySelector(".video-editor");V&&V.getBoundingClientRect();const W=document.querySelector(".mobile-layout");W&&W.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",H),tn==null||tn.disconnect(),tn=null,gt==null||gt.destroy(),gt=null}),(b,V)=>{var W,q,me,re;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:c.value}])},[c.value?(e.openBlock(),e.createElementBlock("div",cw,[e.createElementVNode("div",dw,[e.createElementVNode("div",uw,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ne)}]),onClick:V[0]||(V[0]=(...pe)=>e.unref(Q)&&e.unref(Q)(...pe)),"aria-label":e.unref(ne)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ne)?e.unref(ll):e.unref(dl)},null,8,["icon"])],10,mw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:qr,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On)},null,8,["icon"])])]),e.createElementVNode("div",pw,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:ti,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(fe)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Yi)},null,8,["icon"]),V[14]||(V[14]=e.createElementVNode("span",null,"Save",-1))],8,fw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[1]||(V[1]=pe=>Xr()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:nt.value||!e.unref(fe)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ho)},null,8,["icon"])],8,hw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[2]||(V[2]=pe=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($n)},null,8,["icon"])])])]),e.createElementVNode("div",vw,[e.withDirectives(e.createVNode(ls,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!f.value,class:"preview-host-child",source:Ha.value,"fallback-duration":$t.value,filters:Rr.value,playhead:$r.value,"is-playing":e.unref(ne),"fit-mode":D.value,active:f.value,onPlayPause:e.unref(Q),onFrameUpdate:Lr,onDurationChange:Ro},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Ns,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Fr.value,"enable-engine":p.value&&Ir.value,"fit-mode":D.value,onTimeUpdate:Or,onPlayStateChange:zr,onDurationChange:Ro,onEngineReady:jr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),nt.value?(e.openBlock(),e.createElementBlock("div",gw,[e.createElementVNode("div",yw,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Xe.value)+"%",1),e.createElementVNode("div",ww,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Xe.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Zr},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Nn,class:"timeline-section"},[e.createElementVNode("div",bw,[e.createElementVNode("button",{class:"mobile-zoom-btn",onClick:V[3]||(V[3]=pe=>Pr(-20)),"aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...V[15]||(V[15]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])]),e.createElementVNode("button",{class:"mobile-zoom-btn",onClick:V[4]||(V[4]=pe=>Pr(20)),"aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...V[16]||(V[16]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8M8 4v8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])])]),e.createVNode(_s,{playhead:e.unref(ee),clips:e.unref(F),"selected-clip-id":((W=e.unref(Y))==null?void 0:W.id)??((q=e.unref(F)[0])==null?void 0:q.id)??null,duration:$t.value,"zoom-level":e.unref(Me),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(xe),onTrim:e.unref(se),onSplit:e.unref(ke),onClipSelect:e.unref(oe),onClipMove:e.unref(He)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])],512),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Ja,class:"controls-section mobile-controls"},null,512)])):(e.openBlock(),e.createElementBlock("div",kw,[e.createElementVNode("div",xw,[e.createElementVNode("div",Ew,[e.createElementVNode("div",Vw,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[5]||(V[5]=pe=>D.value=pe),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...V[17]||(V[17]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,D.value]])])]),e.withDirectives(e.createVNode(ls,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!f.value,class:"preview-host-child",source:Ha.value,"fallback-duration":$t.value,filters:Rr.value,playhead:$r.value,"is-playing":e.unref(ne),"fit-mode":D.value,active:f.value,onPlayPause:e.unref(Q),onFrameUpdate:Lr,onDurationChange:Ro},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Ns,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Fr.value,"enable-engine":p.value&&Ir.value,"fit-mode":D.value,onTimeUpdate:Or,onPlayStateChange:zr,onDurationChange:Ro,onEngineReady:jr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),b.showThumbnailPicker?(e.openBlock(),e.createBlock(j0,{key:0,"media-uuid":s.value,duration:$t.value,onSelect:rd},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Sw,[e.createElementVNode("div",Cw,[e.createElementVNode("div",Nw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.value,pe=>(e.openBlock(),e.createElementBlock("button",{key:pe.id,class:e.normalizeClass(["tab-btn",{active:d.value===pe.id}]),onClick:Ae=>d.value=pe.id},e.toDisplayString(pe.label),11,_w))),128))]),e.createElementVNode("div",Tw,[e.withDirectives(e.createElementVNode("div",Mw,[e.createVNode(e0,{filters:Hn.value,"active-filters":Xa.value,"thumbnail-url":$c.value,onApplyFilter:Xn,onRemoveFilter:Br,onUpdateParam:Ar,onPreviewFilter:Xc},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",Bw,[e.createVNode(d1,{overlays:B.value,onAddOverlay:Gc,onUpdateOverlay:Jc,onRemoveOverlay:Yc},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",Fw,[e.createVNode(F1,{"selected-clips":_.value,"applied-transitions":R.value,onApplyTransition:Kc,onRemoveTransition:qc,onPreviewTransition:Qc},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",Iw,[e.createVNode(pg,{"audio-layers":U.value,"master-volume":z.value,onAddTrack:ed,onUpdateTrack:td,onRemoveTrack:nd,onUpdateVolume:od,onToggleMute:ad,onUpdateMasterVolume:id},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Rw,[e.unref(Nr)?(e.openBlock(),e.createBlock(p0,{key:0,filter:e.unref(Nr),"current-frame":e.unref(Ne),onUpdateParams:Hc},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",$w,[...V[18]||(V[18]=[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",Dw,[e.createVNode(_0,{"can-export":e.unref(fe),"is-exporting":nt.value,"export-progress":Xe.value,onExport:Xr,onCancelExport:Zr,onSaveDraft:ti,onReset:qr},null,8,["can-export","is-exporting","export-progress"]),Ht.value?(e.openBlock(),e.createElementBlock("div",Uw," Export complete ")):e.createCommentVNode("",!0),je.value&&!Ht.value?(e.openBlock(),e.createElementBlock("div",Aw,e.toDisplayString(je.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Ow,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Nn,class:"timeline-container"},[e.createElementVNode("div",Lw,[e.createElementVNode("label",null,[V[19]||(V[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(Me),onInput:V[6]||(V[6]=pe=>Zc(pe))},null,40,zw)]),e.createElementVNode("span",Pw,e.toDisplayString(Math.round(e.unref(Me)))+" px/s",1)]),e.createVNode(_s,{playhead:e.unref(ee),clips:e.unref(F),"selected-clip-id":((me=e.unref(Y))==null?void 0:me.id)??((re=e.unref(F)[0])==null?void 0:re.id)??null,duration:$t.value,"zoom-level":e.unref(Me),sensitivity:.25,"onUpdate:playhead":e.unref(xe),onTrim:e.unref(se),onSplit:e.unref(ke),onClipSelect:e.unref(oe),onClipMove:e.unref(He)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(hv,{"selected-clip":e.unref(Y),"can-split":Dc.value,"can-delete":Uc.value,"is-playing":e.unref(ne),"zoom-level":e.unref(Me),"playback-speed":e.unref(ce),onSplit:e.unref(le),onDelete:e.unref(Ee),onDuplicate:e.unref(Se),onZoomIn:jc,onZoomOut:Wc,onZoomChange:Ya,onFitToWindow:Pc,onPlayPause:e.unref(Q),onFrameForward:e.unref(De),onFrameBackward:e.unref(Qe),onSkipToStart:e.unref(We),onSkipToEnd:e.unref(ft),onSpeedChange:e.unref(Ze)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),ge.value?(e.openBlock(),e.createElementBlock("div",jw,[e.createElementVNode("div",Ww,[e.createElementVNode("label",Zw,[V[20]||(V[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[7]||(V[7]=pe=>Sn.value=pe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Sn.value]])]),e.createElementVNode("label",Xw,[V[21]||(V[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[8]||(V[8]=pe=>Cn.value=pe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Cn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(Y),onClick:V[9]||(V[9]=pe=>Ur("start"))}," Start = Playhead ",8,Hw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(Y),onClick:V[10]||(V[10]=pe=>Ur("end"))}," End = Playhead ",8,Gw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(Y),onClick:Oc}," Apply Trim ",8,Jw)]),e.createElementVNode("div",Yw,[e.createElementVNode("label",Kw,[V[22]||(V[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[11]||(V[11]=pe=>Qt.value=pe),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Hn.value,pe=>(e.openBlock(),e.createElementBlock("option",{key:pe.id,value:pe.id},e.toDisplayString(pe.name),9,qw))),128))],512),[[e.vModelSelect,Qt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(Y)||Qt.value==="",onClick:Lc}," Apply Filter ",8,Qw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(et).length===0,onClick:zc}," Clear Filters ",8,eb),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(Y),onClick:V[12]||(V[12]=pe=>Xn("noise"))}," QA: Noise ",8,tb),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(Y),onClick:V[13]||(V[13]=pe=>Xn("grayscale"))}," QA: Grayscale ",8,nb)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Zi=Be(ob,[["__scopeId","data-v-c3f87d95"]]),Ft=a=>a===null||typeof a!="object"||Array.isArray(a)?null:a,Oe=a=>{if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const n=Number(a);return Number.isFinite(n)?n:null}return null},ab=(a,n)=>{if(n===null)return;const t=Ft(a.source)??{},o=Oe(t.duration);if(!(o!==null&&o>0&&o<=1&&n>o))return;t.duration=n,a.source=t;const r=Array.isArray(a.timeline)?a.timeline:[];if(r.length===1){const l=Ft(r[0]);if(l!==null){const d=Oe(l.sourceIn)??0,u=Oe(l.sourceOut)??Oe(l.end)??Oe(l.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){l.sourceOut=n;const f=Oe(l.end);f!==null&&f>0&&f<=1&&(l.end=n);const p=Oe(l.timelineEnd);p!==null&&p>0&&p<=1&&(l.timelineEnd=n)}}}const s=Oe(a.trimEnd)??Oe(a.trim_end);s!==null&&s>0&&s<=1&&(a.trimEnd=n);const c=Ft(a.trim);if(c!==null){const l=Oe(c.end);l!==null&&l>0&&l<=1&&(c.end=n,a.trim=c)}},ib=(a,n)=>{if(!a)return!1;const t=Ft(a);if(t===null)return!1;const o=Ft(t.trim),i=Ft(t.source),s=Oe(i==null?void 0:i.duration)??n,c=Array.isArray(a.filters)&&a.filters.length>0;let l=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(l=!0)}let d=!1;const u=Oe(t.trimStart)??Oe(t.trim_start)??Oe(o==null?void 0:o.start),m=Oe(t.trimEnd)??Oe(t.trim_end)??Oe(o==null?void 0:o.end);if(u!==null&&u>0&&(d=!0),m!==null&&s!==void 0&&m<s&&(d=!0),!d&&Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const v=Oe(p.sourceIn),g=Oe(p.sourceOut);v!==null&&v>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let f=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const v=Oe(p.speed);f=v!==null&&v!==1}}return c||l||d||f},yc=a=>{if(!a)return!1;const n=Ft(a);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(a.timeline)&&a.timeline.length>1)},rb=(a,n={})=>{var f,p;const t=JSON.parse(JSON.stringify(a)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?Ft(o[0]):null,r=Array.isArray(i==null?void 0:i.filters)?i.filters:[],s=Array.isArray(t.filters)?t.filters:[];if(s.length>0?t.filters=s:t.filters=r,o.length===1&&i!==null){const v=Oe(i.sourceIn),g=Oe(i.sourceOut);v!==null&&t.trimStart===void 0&&(t.trimStart=v),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const c=Ft(t.trim);if(t.trimStart===void 0){const v=Oe(c==null?void 0:c.start);v!==null&&(t.trimStart=v)}if(t.trimEnd===void 0){const v=Oe(c==null?void 0:c.end);v!==null&&(t.trimEnd=v)}const l=Ft(t.source),d=Oe(t.width)??Oe(l==null?void 0:l.original_width)??Oe((f=n.exportMeta)==null?void 0:f.width);d!==null&&(t.width=d);const u=Oe(t.height)??Oe(l==null?void 0:l.original_height)??Oe((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Ft(t.output);return t.fps=Oe(t.fps)??Oe(m==null?void 0:m.fps)??30,ab(t,n.mediaDuration??null),t},sb={key:0},lb=["data-testid"],cb={class:"ve-mobile-header"},db=["data-testid","disabled"],ub={class:"ve-mobile-title"},mb=["data-testid","disabled"],pb={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},fb={class:"ve-body"},hb=["data-testid"],vb=["aria-label"],gb={class:"ve-header"},yb={class:"ve-title"},wb=["data-testid","disabled"],bb={class:"ve-body"},kb={class:"ve-footer"},xb=["data-testid","disabled"],Eb=["data-testid","disabled"],Vb=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),c=e.computed(()=>o.saveImmediate===!1),l=e.computed(()=>o.closeText),d=e.computed(()=>m.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),m=e.ref(!1),f=e.ref(!1),p=e.ref(null),v=`temp-${Date.now()}`,g=e.computed(()=>{var z;const _=(z=o.featureFlags)==null?void 0:z.export;return typeof _=="boolean"?_:o.workflowMode==="full"}),E=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():v),T=e.computed(()=>{const _={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&(_.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&(_.initialRecipe=o.initialRecipe),o.media!==void 0&&(_.media=o.media),_}),N=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",N)}),e.onUnmounted(()=>{window.removeEventListener("resize",N)}),e.onErrorCaptured(()=>(f.value=!0,!1));const w=_=>{const z=Array.isArray(_.timeline)?_.timeline:[];if(z.length===0)return 0;let H=0;for(const M of z){const $=Number(M.sourceIn),X=Number(M.sourceOut),j=Number(M.speed??1),te=Number.isFinite(j)&&j>0?j:1;if(Number.isFinite($)&&Number.isFinite(X)&&X>$){H+=(X-$)/te;continue}const ge=Number(M.timelineStart),Ne=Number(M.timelineEnd);Number.isFinite(ge)&&Number.isFinite(Ne)&&Ne>ge&&(H+=Ne-ge)}return H},h=(_,z,H)=>{let M=null;const $=new Promise((X,j)=>{M=setTimeout(()=>j(new Error(`${H} timed out after ${z}ms`)),z)});return Promise.race([_,$]).finally(()=>{M!==null&&clearTimeout(M)})},x=()=>{var $;const H=($=o.media)==null?void 0:$.duration;if(typeof H!="number"||!Number.isFinite(H)||H<=0)return 12e3;const M=Math.round(H*1e3);return Math.min(45e3,Math.max(12e3,M))},D=()=>{i("close"),i("update:open",!1)},C=()=>{m.value||D()},y=_=>{i("recipe-generated",_)},S=_=>{i("export-started",_),i("save-started",_)},A=_=>{i("video-exported",_)},k=_=>{i("thumbnail-selected",_)},B=(_,z,H)=>{i("save-recipe",_);const M={recipe:_,exportPayload:z};H!==void 0&&(M.toastDescription=H),i("save-complete",M),D()},R=_=>{m.value||(i("draft-saved",_),B(_,null))},U=async()=>{var _;if(!m.value){if(f.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),D();return}m.value=!0;try{const z=await h(p.value.saveDraft(),x(),"saveDraft");let H=null,M=!1,$;const X=w(z),j=X>0?X:((_=o.media)==null?void 0:_.duration)??0;if(g.value&&j>0&&j<=o.clientExportThreshold&&typeof p.value.exportForUpload=="function"){M=!0;const ge=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{H=await h(p.value.exportForUpload(z),ge,"exportForUpload")}catch{H=null}}if(yc(z)&&H===null){i("save-error",{code:"unsupported-client-export-required",message:"These edits require in-browser export. Shorten the clip or remove text overlays, transitions, or extra clips and try again."});return}M&&H===null&&($="Video edits saved. Final render will happen when you share."),B(z,H,$)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),D()}finally{m.value=!1}}};return n({saveDraft:U}),(_,z)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",sb,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",cb,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,disabled:m.value,onClick:C},e.toDisplayString(l.value),9,db),e.createElementVNode("h2",ub,e.toDisplayString(_.title),1),c.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-mobile-action ve-mobile-action--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:U},e.toDisplayString(d.value),9,mb)):(e.openBlock(),e.createElementBlock("span",pb))]),e.createElementVNode("section",fb,[e.createVNode(Zi,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":E.value},T.value,{onClose:C,onDraftSaved:R,onExportStarted:S,onRecipeGenerated:y,onThumbnailSelected:k,onVideoExported:A}),null,16,["media-uuid"])])],8,lb)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(C,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":_.title,"aria-modal":"true"},[e.createElementVNode("header",gb,[e.createElementVNode("h2",yb,e.toDisplayString(_.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,disabled:m.value,"aria-label":"Close",onClick:C}," ✕ ",8,wb)]),e.createElementVNode("section",bb,[e.createVNode(Zi,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":E.value},T.value,{onClose:C,onDraftSaved:R,onExportStarted:S,onRecipeGenerated:y,onThumbnailSelected:k,onVideoExported:A}),null,16,["media-uuid"])]),e.createElementVNode("footer",kb,[e.renderSlot(_.$slots,"footer",{close:C,isSaving:m.value,save:U},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,disabled:m.value,onClick:C},e.toDisplayString(l.value),9,xb),c.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:U},e.toDisplayString(d.value),9,Eb)):e.createCommentVNode("",!0)],!0)])],8,vb)],8,hb))])):e.createCommentVNode("",!0)]))}}),Sb=Be(Vb,[["__scopeId","data-v-cdf43562"]]),Cb={class:"video-editor-modal"},Nb={class:"video-preview-container"},_b=["src"],Tb={class:"video-overlay-controls"},Mb=["aria-label"],Bb={class:"time-display"},Fb={class:"timeline-container"},Ib={class:"clip-name"},Rb={class:"timeline-time-labels"},$b={class:"tool-tabs"},Db=["onClick"],Ub={class:"tool-panel"},Ab={key:0,class:"trim-panel"},Ob={class:"trim-controls"},Lb={key:1,class:"filters-panel"},zb={class:"filter-grid"},Pb=["onClick"],jb={key:2,class:"text-panel"},Wb={key:3,class:"transitions-panel"},Zb={class:"transition-grid"},Xb=["onClick"],Hb={class:"action-buttons"},Gb=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),c=e.ref(0),l=e.ref(0),d=e.ref("video-1"),u=e.ref(0),m=e.ref(0),f=e.ref(null),p=e.ref("trim"),v=e.ref(null),g=e.ref(""),E=[{id:"trim",label:"Trim",icon:rl},{id:"filters",label:"Filters",icon:mu},{id:"text",label:"Text",icon:ul},{id:"transitions",label:"Transitions",icon:bu}],T=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],N=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],w=e.ref();e.onMounted(()=>{var M,$;(M=t.media)!=null&&M.url?r.value=t.media.url:($=t.media)!=null&&$.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var M;(M=t.media)!=null&&M.file&&r.value&&URL.revokeObjectURL(r.value)});function h(){i.value&&(l.value=i.value.duration,m.value=l.value)}function x(){i.value&&(c.value=i.value.currentTime)}function D(){s.value=!1}function C(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function y(M){if(!M||isNaN(M))return"00:00";const $=Math.floor(M/60),X=Math.floor(M%60);return`${$.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`}function S(M){if(!i.value||!w.value)return;const $=w.value.getBoundingClientRect(),te=(M.clientX-$.left)/$.width*l.value;i.value.currentTime=Math.max(0,Math.min(te,l.value))}function A(){u.value=c.value}function k(){m.value=c.value}function B(){u.value=0,m.value=l.value}function R(M){f.value=M;const $=j=>{if(!f.value||!w.value)return;const te=w.value.getBoundingClientRect(),ee=(j.clientX-te.left)/te.width*l.value;f.value==="start"?u.value=Math.max(0,Math.min(ee,m.value-1)):m.value=Math.max(u.value+1,Math.min(ee,l.value))},X=()=>{f.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",X)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",X)}function U(M){if(v.value=M,!i.value)return;const $={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=$[M]||"none"}function _(){}function z(M){}function H(){const M={timeline:[{id:d.value,url:r.value,startTime:0,endTime:l.value,sourceIn:u.value,sourceOut:m.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:m.value-u.value};o("save",M)}return(M,$)=>(e.openBlock(),e.createElementBlock("div",Cb,[e.createElementVNode("div",Nb,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:h,onTimeupdate:x,onEnded:D,controls:""},null,40,_b),e.createElementVNode("div",Tb,[e.createElementVNode("button",{class:"play-pause-btn",onClick:C,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:s.value?e.unref(Vu):e.unref(_u)},null,8,["icon"])],8,Mb),e.createElementVNode("div",Bb,e.toDisplayString(y(c.value))+" / "+e.toDisplayString(y(l.value)),1)])]),e.createElementVNode("div",Fb,[e.createElementVNode("div",{class:"timeline-track",onClick:S,ref_key:"timelineTrack",ref:w},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/l.value*100}%`,right:`${100-m.value/l.value*100}%`})},[e.createElementVNode("span",Ib,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${c.value/l.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/l.value*100}%`}),onMousedown:$[0]||($[0]=X=>R("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/l.value*100}%`}),onMousedown:$[1]||($[1]=X=>R("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",Rb,[e.createElementVNode("span",null,e.toDisplayString(y(0)),1),e.createElementVNode("span",null,e.toDisplayString(y(l.value)),1)])]),e.createElementVNode("div",$b,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["tool-tab",{active:p.value===X.id}]),onClick:j=>p.value=X.id},[e.createVNode(e.unref(I.IonIcon),{icon:X.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(X.label),1)],10,Db)),64))]),e.createElementVNode("div",Ub,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",Ab,[$[7]||($[7]=e.createElementVNode("h3",null,"Trim Video",-1)),$[8]||($[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",Ob,[e.createElementVNode("button",{class:"btn-trim",onClick:A},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(os)},null,8,["icon"]),$[4]||($[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(os)},null,8,["icon"]),$[5]||($[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:B},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($n)},null,8,["icon"]),$[6]||($[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",Lb,[$[9]||($[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",zb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(T,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["filter-option",{active:v.value===X.id}]),onClick:j=>U(X.id)},e.toDisplayString(X.name),11,Pb)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",jb,[$[10]||($[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[2]||($[2]=X=>g.value=X),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:_},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",Wb,[$[11]||($[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Zb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(N,X=>e.createElementVNode("button",{key:X.id,class:"transition-option",onClick:j=>(X.id,void 0)},e.toDisplayString(X.name),9,Xb)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Hb,[e.createElementVNode("button",{class:"btn-cancel",onClick:$[3]||($[3]=X=>M.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:H},"SAVE")])]))}}),Jb=Be(Gb,[["__scopeId","data-v-b933f33b"]]),Yb={class:"time-label"},Kb=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(a){const n=a,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),o=e.computed(()=>{const s=[],c=i(n.duration,n.zoom);for(let l=0;l<=n.duration;l+=c){const d=`${l/n.duration*100}%`,u=r(l),m=l%(c*5)===0;s.push({time:l,position:d,label:u,major:m})}return s});function i(s,c){const l=s/(10*c);return l<=1?1:l<=5?5:l<=10?10:l<=30?30:l<=60?60:Math.ceil(l/60)*60}function r(s){const c=Math.floor(s/60),l=Math.floor(s%60);return c===0?`${l}s`:l===0?`${c}m`:`${c}:${l.toString().padStart(2,"0")}`}return(s,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.time,class:"time-mark",style:e.normalizeStyle({left:l.position})},[e.createElementVNode("span",Yb,e.toDisplayString(l.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:l.major}])},null,2)],4))),128))],4))}}),qb=Be(Kb,[["__scopeId","data-v-0ef9c910"]]),Qb=["data-track-index"],e2={class:"track-header"},t2={class:"track-label"},n2={class:"track-controls"},o2=["data-testid","aria-label"],a2=["data-testid","onMousedown","onClick"],i2={class:"clip-content"},r2={class:"clip-name"},s2={key:0,class:"clip-thumbnail"},l2=["src","alt"],c2=["onMousedown","aria-label"],d2=["onMousedown","aria-label"],u2=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),c=e.ref(null),l=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(E){const T=E.timelineEnd-E.timelineStart,N=E.timelineStart/t.duration*100,w=T/t.duration*100;return{left:`${N}%`,width:`${w}%`,backgroundColor:u(E)}}function u(E){const T=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],N=parseInt(E.id.replace(/\D/g,""))%T.length;return T[N]}function m(E){return E.label?E.label:E.url?(E.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${E.id.slice(-4)}`}function f(E){i.value=E.id,o("clip-select",E.id)}function p(){r.value=!r.value}function v(E,T){if(c.value)return;s.value=!0;const N=T.clientX,w=E.timelineStart,h=D=>{if(!s.value)return;const C=D.clientX-N,y=parseFloat(l.value.width),S=C/(t.zoom*100)*(t.duration/y),A=Math.max(0,w+S);o("clip-move",E.id,A)},x=()=>{s.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",x)}function g(E,T,N){c.value=T;const w=N.clientX,h=E.sourceIn,x=E.sourceOut,D=y=>{if(!c.value)return;const S=y.clientX-w,A=parseFloat(l.value.width),k=S/(t.zoom*100)*(t.duration/A);if(c.value==="start"){const B=Math.max(0,h+k);o("clip-trim",E.id,B,x)}else{const B=Math.max(h+1,x+k);o("clip-trim",E.id,h,B)}},C=()=>{c.value=null,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",C)}return(E,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":E.trackIndex},[e.createElementVNode("div",e2,[e.createElementVNode("span",t2,"Track "+e.toDisplayString(E.trackIndex+1),1),e.createElementVNode("div",n2,[E.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${E.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${E.trackIndex+1}`,onClick:p},[e.createVNode(e.unref(I.IonIcon),{icon:r.value?e.unref(ju):e.unref(zu)},null,8,["icon"])],8,o2)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(l.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.clips,N=>(e.openBlock(),e.createElementBlock("div",{key:N.id,class:e.normalizeClass(["timeline-clip",{selected:N.id===i.value}]),style:e.normalizeStyle(d(N)),"data-testid":`clip-${N.id}`,onMousedown:w=>v(N,w),onClick:w=>f(N)},[e.createElementVNode("div",i2,[e.createElementVNode("span",r2,e.toDisplayString(m(N)),1),N.thumbnail?(e.openBlock(),e.createElementBlock("div",s2,[e.createElementVNode("img",{src:N.thumbnail,alt:m(N)},null,8,l2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(w=>g(N,"start",w),["stop"]),"aria-label":`Trim start of ${m(N)}`},null,40,c2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(w=>g(N,"end",w),["stop"]),"aria-label":`Trim end of ${m(N)}`},null,40,d2)],46,a2))),128))],4)],8,Qb))}}),m2=Be(u2,[["__scopeId","data-v-48e480d2"]]),p2={class:"video-timeline"},f2={class:"timeline-tracks"},h2=["aria-label","aria-valuenow","aria-valuemax"],v2={class:"timeline-controls"},g2={class:"zoom-level"},y2=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),c=e.ref(),l=e.computed(()=>{const w=Math.max(0,...t.clips.map(h=>h.track||0));return Array(w+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(w){return t.clips.filter(h=>(h.track||0)===w)}function m(w){const h=Math.floor(w/60),x=Math.floor(w%60);return`${h}:${x.toString().padStart(2,"0")}`}function f(w,h){o("clip-move",w,h)}function p(w,h,x){o("clip-trim",w,h,x)}function v(w){r.value=w}function g(){i.value=Math.min(i.value*1.2,5)}function E(){i.value=Math.max(i.value/1.2,.5)}function T(){s.value=!0;const w=x=>{if(!s.value||!c.value)return;const D=c.value.getBoundingClientRect(),S=Math.max(0,Math.min(x.clientX-D.left,D.width))/D.width*t.duration;o("seek",S)},h=()=>{s.value=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",h)}function N(w){let h=t.currentTime;switch(w.key){case"ArrowLeft":h=Math.max(0,t.currentTime-1);break;case"ArrowRight":h=Math.min(t.duration,t.currentTime+1);break;case"Home":h=0;break;case"End":h=t.duration;break;default:return}w.preventDefault(),o("seek",h)}return e.onMounted(()=>{c.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(w,h)=>(e.openBlock(),e.createElementBlock("div",p2,[e.createVNode(qb,{duration:w.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",f2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(x,D)=>(e.openBlock(),e.createBlock(m2,{key:`track-${D}`,"data-testid":`track-${D}`,clips:u(D),"track-index":D,zoom:i.value,duration:w.duration,onClipMove:f,onClipTrim:p,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:T,"data-testid":"playhead","aria-label":`Playhead at ${m(w.currentTime)}`,role:"slider","aria-valuenow":w.currentTime,"aria-valuemax":w.duration,tabindex:"0",onKeydown:N},null,44,h2),e.createElementVNode("div",v2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Gi)},null,8,["icon"])]),e.createElementVNode("span",g2,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:E},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ru)},null,8,["icon"])])])]))}}),w2=Be(y2,[["__scopeId","data-v-001df415"]]),b2={class:"video-filters-panel"},k2={class:"filter-controls"},x2=["for"],E2={class:"filter-slider-group"},V2=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],S2={class:"filter-value"},C2={class:"filter-actions"},N2={key:0,class:"filter-presets"},_2={class:"preset-list"},T2=["data-testid","aria-label","onClick"],M2=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(a,{emit:n}){const t=n,o=[{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}],i=e.reactive(o.reduce((f,p)=>(f[p.type]=p.default,f),{})),r=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(f,p){switch(f){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function c(f){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(f)}function l(f){if(!c(f))return;const p={id:`filter-${f}`,filterId:f,params:{value:i[f]},intensity:1};t("filter-change",p)}function d(){o.forEach(f=>{i[f.type]=f.default,l(f.type)})}function u(){const f=prompt("Enter preset name:");if(!f)return;const p={id:`custom-${Date.now()}`,name:f,values:{...i}};r.value.push(p)}function m(f){Object.entries(f.values).forEach(([p,v])=>{i[p]=v,l(p)})}return(f,p)=>(e.openBlock(),e.createElementBlock("div",b2,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",k2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,x2),e.createElementVNode("div",E2,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":g=>i[v.type]=g,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":i[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:g=>l(v.type)},null,40,V2),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",S2,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",C2,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:d},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Yi)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",N2,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",_2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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:g=>m(v)},e.toDisplayString(v.name),9,T2))),128))])])):e.createCommentVNode("",!0)]))}}),B2=Be(M2,[["__scopeId","data-v-5ad2ac63"]]),F2={class:"video-text-panel"},I2={class:"text-input-group"},R2={class:"text-options"},$2={class:"option-row"},D2={class:"option-row"},U2={class:"option-row"},A2={class:"option-row"},O2={class:"checkbox-label"},L2={class:"option-row"},z2={class:"text-overlay-list"},P2={key:0,class:"empty-state"},j2=["data-testid"],W2={class:"overlay-preview"},Z2={class:"overlay-controls"},X2=["data-testid","aria-label","onClick"],H2=["data-testid","aria-label","onClick"],G2=["data-testid","aria-label","onClick"],J2=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const d={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(m=>m.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function c(d){i.text=d.text,i.fontFamily=d.fontFamily||"Arial",i.fontSize=d.fontSize,i.color=d.color,i.backgroundColor=d.backgroundColor||"#000000",i.hasBackground=!!d.backgroundColor,i.animation=d.animation||"none",s(d.id)}function l(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};o.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",F2,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",I2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=m=>i.text=m),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Gi)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",R2,[e.createElementVNode("div",$2,[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]=m=>i.fontFamily=m),"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,i.fontFamily]])]),e.createElementVNode("div",D2,[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]=m=>i.fontSize=m),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",U2,[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]=m=>i.color=m),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",A2,[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]=m=>i.backgroundColor=m),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",O2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=m=>i.hasBackground=m),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",L2,[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]=m=>i.animation=m),"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,i.animation]])])]),e.createElementVNode("div",z2,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",P2," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(m,f)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${f}`},[e.createElementVNode("div",W2,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:m.fontFamily,fontSize:`${Math.min(m.fontSize/4,16)}px`,color:m.color})},e.toDisplayString(m.text),5)]),e.createElementVNode("div",Z2,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${f}`,"aria-label":`Edit overlay: ${m.text}`,onClick:p=>c(m)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(hu)},null,8,["icon"])],8,X2),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${f}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:p=>l(m)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(fu)},null,8,["icon"])],8,H2),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${f}`,"aria-label":`Remove overlay: ${m.text}`,onClick:p=>s(m.id)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Uu)},null,8,["icon"])],8,G2)])],8,j2))),128))])]))}}),Y2=Be(J2,[["__scopeId","data-v-4d240e1e"]]),K2={class:"video-tools-panel"},q2={class:"tool-tabs"},Q2=["data-testid","aria-label","aria-selected","onClick"],ek={class:"tool-content"},tk={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},nk={class:"trim-actions"},ok={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},ak={class:"transition-types"},ik=["data-testid","aria-label","onClick"],rk={class:"transition-preview"},sk=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(a){const n=[{id:"trim",name:"Trim",icon:rl},{id:"filters",name:"Filters",icon:rn},{id:"text",name:"Text",icon:ul},{id:"transitions",name:"Transitions",icon:rs}],t=[{id:"fade",name:"Fade",icon:li},{id:"slide-left",name:"Slide Left",icon:su},{id:"slide-right",name:"Slide Right",icon:lu},{id:"dissolve",name:"Dissolve",icon:li},{id:"wipe",name:"Wipe",icon:rs},{id:"zoom",name:"Zoom",icon:li}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",K2,[e.createElementVNode("div",q2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:o.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":o.activeTool===r.id,role:"tab",onClick:s=>o.$emit("tool-change",r.id)},[e.createVNode(e.unref(I.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,Q2)),64))]),e.createElementVNode("div",ek,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",tk,[i[8]||(i[8]=e.createElementVNode("h3",null,"Trim Video",-1)),i[9]||(i[9]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",nk,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:i[0]||(i[0]=r=>o.$emit("trim-set-start"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(as)},null,8,["icon"]),i[5]||(i[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:i[1]||(i[1]=r=>o.$emit("trim-set-end"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(as)},null,8,["icon"]),i[6]||(i[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:i[2]||(i[2]=r=>o.$emit("trim-clear"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($n)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(B2,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(Y2,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",ok,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",ak,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,r=>e.createElementVNode("button",{key:r.id,class:"transition-btn","data-testid":`transition-${r.id}`,"aria-label":`Add ${r.name} transition`,onClick:s=>o.$emit("transition-add",r.id)},[e.createElementVNode("div",rk,[e.createVNode(e.unref(I.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,ik)),64))])])):e.createCommentVNode("",!0)])]))}}),lk=Be(sk,[["__scopeId","data-v-fc135306"]]),ck={class:"video-export-panel"},dk={class:"export-presets"},uk=["value"],mk={key:0,class:"preset-details"},pk={class:"detail-row"},fk={class:"detail-row"},hk={class:"detail-row"},vk={class:"advanced-options"},gk={class:"options-content"},yk={class:"option-group"},wk={class:"option-group"},bk={class:"option-group"},kk=["disabled"],xk={key:1,class:"export-progress"},Ek={class:"progress-message"},Vk={class:"progress-bar"},Sk=["aria-valuenow"],Ck={class:"progress-percentage"},Nk=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===i.value)),c=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 l(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",ck,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",dk,[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]=m=>i.value=m),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,m=>(e.openBlock(),e.createElementBlock("option",{key:m.id,value:m.id},e.toDisplayString(m.name),9,uk))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",mk,[e.createElementVNode("div",pk,[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",fk,[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",hk,[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",vk,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",gk,[e.createElementVNode("div",yk,[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]=m=>r.quality=m),"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,r.quality]])]),e.createElementVNode("div",wk,[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]=m=>r.bitrate=m),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",bk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=m=>r.includeAudio=m),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.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:l},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ho)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,kk),d.isExporting?(e.openBlock(),e.createElementBlock("div",xk,[e.createElementVNode("div",Ek,e.toDisplayString(c.value),1),e.createElementVNode("div",Vk,[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,Sk)]),e.createElementVNode("div",Ck,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),_k=Be(Nk,[["__scopeId","data-v-5caf8fe6"]]),Tk=["data-testid"],Mk={class:"progress-header"},Bk={class:"file-info"},Fk={class:"file-details"},Ik={class:"file-name"},Rk={class:"file-meta"},$k={class:"file-size"},Dk={key:0,class:"separator"},Uk={key:1,class:"upload-speed"},Ak={key:2,class:"separator"},Ok={key:3,class:"time-remaining"},Lk={class:"progress-actions"},zk={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},Pk={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},jk={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},Wk=["aria-valuenow","aria-label"],Zk={class:"progress-bar"},Xk={class:"progress-percent"},Hk={key:1,class:"error-message","data-testid":"video-upload-error"},Gk={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},Jk=["src","alt"],Yk={key:0,class:"video-duration"},Kk=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(a){const n=a,t=e.computed(()=>({"is-uploading":n.upload.status==="uploading","is-processing":n.upload.status==="processing","is-completed":n.upload.status==="completed","is-error":n.upload.status==="error","is-pending":n.upload.status==="pending"})),o=e.computed(()=>ml),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const f=n.upload.timeRemaining;if(f<60)return`${Math.round(f)}s`;const p=Math.floor(f/60);return p<60?`${p}m ${Math.round(f%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),c=e.computed(()=>{var f;return n.upload.status==="completed"&&((f=n.upload.media)!=null&&f.thumbnail_url)?n.upload.media.thumbnail_url:null}),l=e.computed(()=>{var f;return(f=n.upload.media)==null?void 0:f.duration});function d(f){if(f===0)return"0 B";const p=["B","KB","MB","GB","TB"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function u(f){if(f===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function m(f){const p=Math.floor(f/3600),v=Math.floor(f%3600/60),g=Math.floor(f%60);return p>0?`${p}:${v.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${v}:${g.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${f.upload.id}`},[e.createElementVNode("div",Mk,[e.createElementVNode("div",Bk,[e.createVNode(e.unref(I.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",Fk,[e.createElementVNode("h4",Ik,e.toDisplayString(f.upload.filename),1),e.createElementVNode("p",Rk,[e.createElementVNode("span",$k,e.toDisplayString(d(f.upload.bytesTotal||0)),1),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Dk,"•")):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Uk,e.toDisplayString(u(f.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Ak,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Ok,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Lk,[f.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",zk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(al)},null,8,["icon"])])):f.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",Pk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ru),"aria-hidden":"true"},null,8,["icon"])])):f.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",jk,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=v=>f.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($n),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=v=>f.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=v=>f.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($n),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":f.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",Zk,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:f.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",Xk,e.toDisplayString(Math.round(r.value))+"%",1)],8,Wk)):e.createCommentVNode("",!0),f.upload.error?(e.openBlock(),e.createElementBlock("div",Hk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Wu)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(f.upload.error),1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",Gk,[e.createElementVNode("img",{src:c.value,alt:f.upload.filename},null,8,Jk),l.value?(e.openBlock(),e.createElementBlock("div",Yk,e.toDisplayString(m(l.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,Tk))}}),qk=Be(Kk,[["__scopeId","data-v-9eacbf91"]]),wi=4,Qk=500,ex=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Pa(a){return typeof a=="object"&&a!==null}function Zs(a){return Pa(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function tx(a){if(Zs(a))return a;if(Pa(a)&&Zs(a.data))return a.data;throw new Error("Invalid upload response from backend")}function Xs(a){return Pa(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function nx(a){if(Xs(a))return a;if(Pa(a)&&Xs(a.data))return a.data;throw new Error("Invalid media response from backend")}function Wo(a){return a?{...a}:{}}function Hs(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function ox(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function ax(a){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(a)))}catch{return btoa(a)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function ix(a,n){return[["filename",a.filename],["filetype",a.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([o,i])=>`${o} ${ax(i)}`).join(",")}function Zo(a,n){const t=Math.max(a.bytesTotal,1);a.bytesUploaded=n,a.progress=Math.min(100,n/t*100);const o=Math.max((Date.now()-a.startedAt.getTime())/1e3,.001);a.uploadSpeed=n/o;const i=Math.max(t-n,0);a.timeRemaining=i/Math.max(a.uploadSpeed,1)}function rx(a,n){return a instanceof Error?a:new Error(n)}function sx(a){if(!(a instanceof Error))return!1;const n=a.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function Gs(a){const n=Math.max(0,a-1),t=Qk*Math.pow(2,n);return Math.min(5e3,t)}function Js(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Ys(a,n){for(let t=1;t<=wi;t+=1)try{const o=await n();if(o.ok||!ex.has(o.status)||t>=wi)return o;await Js(Gs(t))}catch(o){if(!sx(o)||t>=wi)throw o;await Js(Gs(t))}throw new Error(`${a} failed after retry attempts`)}function lx(a={}){const n=e.ref(new Map),t=e.ref(new Set),o=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),c=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>{const k=Array.from(n.value.values());return k.length===0?0:k.reduce((R,U)=>R+U.progress,0)/k.length});function d(k){o.value=k}function u(){}async function m(k){var R;const B=k.filter(U=>f(U));if(B.length!==0&&((R=a.onFilesSelected)==null||R.call(a,B),a.autoUpload!==!1))for(const U of B)await p(U)}function f(k){return!(a.maxFileSize&&k.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(k.type))}async function p(k){var U,_,z;const B=A(k);if(n.value.has(B)){const H=n.value.get(B);if((H==null?void 0:H.status)==="uploading")return}const R={id:B,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};n.value.set(R.id,R),t.value.add(R.id);try{R.status="uploading",(U=a.onUploadStart)==null||U.call(a,R);const H=await v(k);a.resumable===!0||H.resumable===!0?await E(R,H):await g(R,H),R.status="processing",R.progress=100;const $=await x(H.media_uuid);R.status="completed",R.media=$,(_=a.onUploadComplete)==null||_.call(a,$)}catch(H){if(R.status!=="cancelled"){const M=rx(H,"Upload failed");R.status="error",R.error=M.message,(z=a.onUploadError)==null||z.call(a,M,R)}}finally{t.value.delete(R.id),i.delete(R.id),r.delete(R.id)}}async function v(k){if(!o.value)throw new Error("API client not configured");const B={collection:a.collection||"videos",filename:k.name,size:k.size,mime_type:k.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},R=await o.value.post("/api/v1/video/upload",B);return tx(R)}async function g(k,B){const R=new XMLHttpRequest,U=Hs(B),_=Wo(B.headers);return new Promise((z,H)=>{R.upload.addEventListener("progress",M=>{var $;M.lengthComputable&&(Zo(k,M.loaded),($=a.onUploadProgress)==null||$.call(a,k))}),R.addEventListener("load",()=>{i.delete(k.id),R.status>=200&&R.status<300?z():H(new Error(`Upload failed with status ${R.status}`))}),R.addEventListener("error",()=>{i.delete(k.id),H(new Error("Upload failed"))}),R.addEventListener("abort",()=>{i.delete(k.id),H(new Error("Upload cancelled"))}),R.open(U,B.upload_url),Object.entries(_).forEach(([M,$])=>{R.setRequestHeader(M,$)}),!Object.keys(_).some(M=>M.toLowerCase()==="content-type")&&k.file.type&&R.setRequestHeader("Content-Type",k.file.type),i.set(k.id,R),R.send(k.file)})}async function E(k,B){var H;if(ox(B)){await T(k,B);return}const R=a.chunkSize||5*1024*1024,U=N(k.file,R),_=new AbortController;r.set(k.id,_);const z=await h(B.upload_id);z&&(U.forEach(M=>{M.end<=z.bytesUploaded&&(M.uploaded=!0)}),Zo(k,z.bytesUploaded));for(const M of U)M.uploaded||(await w(k,B,M,_),Zo(k,M.end),(H=a.onUploadProgress)==null||H.call(a,k))}async function T(k,B){var X;const R=new AbortController;r.set(k.id,R);const U={...Wo(B.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":ix(k,B)},_=await Ys("Resumable upload initialization",()=>fetch(B.upload_url,{method:"POST",headers:U,signal:R.signal}));if(!_.ok)throw new Error(`Failed to initialize resumable upload: ${_.status}`);const z=_.headers.get("Location");if(!z)throw new Error("Resumable upload endpoint did not return upload location");const H=new URL(z,B.upload_url).toString(),M=a.chunkSize||5*1024*1024;let $=0;for(;$<k.file.size;){const j=Math.min($+M,k.file.size),te=k.file.slice($,j),ge={...Wo(B.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String($),"Content-Type":"application/offset+octet-stream"},Ne=await Ys("Resumable chunk upload",()=>fetch(H,{method:"PATCH",headers:ge,body:te,signal:R.signal}));if(Ne.status===409){const F=Number(Ne.headers.get("Upload-Offset")??"-1");if(Number.isFinite(F)&&F>=0){$=F;continue}}if(!Ne.ok)throw new Error(`Resumable chunk upload failed: ${Ne.status}`);const ee=Number(Ne.headers.get("Upload-Offset")??String(j));$=Number.isFinite(ee)&&ee>$?ee:j,Zo(k,$),(X=a.onUploadProgress)==null||X.call(a,k)}}function N(k,B){const R=[];let U=0,_=0;for(;U<k.size;){const z=Math.min(U+B,k.size);R.push({start:U,end:z,blob:k.slice(U,z),index:_,uploaded:!1}),U=z,_++}return R}async function w(k,B,R,U){const _={...Wo(B.headers),"Content-Range":`bytes ${R.start}-${R.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},z=await fetch(B.upload_url,{method:Hs(B),headers:_,body:R.blob,signal:U.signal});if(!z.ok)throw new Error(`Chunk upload failed: ${z.status}`);R.uploaded=!0}async function h(k){return null}async function x(k){if(!o.value)throw new Error("API client not configured");const B=60;let R=0;for(;R<B;){const U=await o.value.get(`/api/v1/video/${k}`),_=nx(U),z=String(_.processing_status);if(z==="ready")return _;if(z==="failed"||z==="error")throw new Error("Video processing failed");await new Promise(H=>{window.setTimeout(H,5e3)}),R++}throw new Error("Video processing timeout")}function D(k){const B=n.value.get(k);if(!B)return;const R=i.get(k);R&&(R.abort(),i.delete(k));const U=r.get(k);U&&(U.abort(),r.delete(k)),B.status="cancelled",B.error="Upload cancelled",t.value.delete(k)}async function C(k){const B=n.value.get(k);B&&(B.status="pending",B.error="",B.progress=0,B.bytesUploaded=0,await p(B.file))}function y(k){n.value.delete(k),t.value.delete(k),i.delete(k),r.delete(k)}function S(){Array.from(n.value.entries()).forEach(([k,B])=>{B.status==="completed"&&n.value.delete(k)})}function A(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:c,isUploading:s,totalProgress:l,openFilePicker:u,handleFileSelect:m,validateFile:f,startUpload:p,cancelUpload:D,retryUpload:C,removeUpload:y,clearCompleted:S,setApiClient:d}}const cx=["accept","multiple"],dx={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},ux=["onKeydown"],mx={key:1,class:"upload-list","data-testid":"video-upload-list"},px={class:"drag-content"},fx=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:c,handleFileSelect:l,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:f}=lx({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:h=>o("upload-start",h),onUploadProgress:h=>o("upload-progress",h),onUploadComplete:h=>o("upload-complete",h),onUploadError:(h,x)=>o("upload-error",h,x),onFilesSelected:h=>o("files-selected",h)});t.apiClient&&f(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function E(h){const x=h.target,D=Array.from(x.files||[]);D.length>0&&(l(D),x.value="")}function T(h){var C;h.preventDefault(),r.value=!1;const D=Array.from(((C=h.dataTransfer)==null?void 0:C.files)||[]).filter(y=>y.type.startsWith("video/"));D.length>0&&l(D)}function N(h){var x;h.preventDefault(),(x=h.dataTransfer)!=null&&x.types.includes("Files")&&(r.value=!0)}function w(h){h.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",N),document.addEventListener("dragleave",w),document.addEventListener("drop",h=>h.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",N),document.removeEventListener("dragleave",w),document.removeEventListener("drop",h=>h.preventDefault())}),(h,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(c)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:h.multiple,onChange:E,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,cx),!e.unref(c)||v.value?(e.openBlock(),e.createElementBlock("div",dx,[e.renderSlot(h.$slots,"trigger",{open:g},()=>[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:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ml),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(h.label),1),e.createElementVNode("p",null,e.toDisplayString(h.description),1),e.createVNode(e.unref(I.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Gi),slot:"start","aria-hidden":"true"},null,8,["icon"]),x[2]||(x[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,ux)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",mx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),D=>(e.openBlock(),e.createBlock(qk,{key:D.id,upload:D,onCancel:C=>e.unref(d)(D.id),onRetry:C=>e.unref(u)(D.id),onRemove:C=>e.unref(m)(D.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:T,onDragover:x[0]||(x[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:x[1]||(x[1]=D=>r.value=!1)},[e.createElementVNode("div",px,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ho),"aria-hidden":"true"},null,8,["icon"]),x[3]||(x[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),hx=Be(fx,[["__scopeId","data-v-ea7587f7"]]),vx=["aria-valuenow","aria-valuemax","aria-label"],gx={class:"progress-bar"},yx={class:"time-display","data-testid":"video-time-display"},wx={class:"current-time"},bx={class:"duration"},kx={class:"control-buttons"},xx={class:"controls-left"},Ex=["aria-label"],Vx={class:"controls-center"},Sx={key:0,class:"volume-controls"},Cx=["aria-label"],Nx=["value"],_x={class:"controls-right"},Tx={key:0,class:"quality-selector"},Mx=["aria-expanded"],Bx={class:"quality-label"},Fx={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},Ix=["data-testid","aria-label","onClick"],Rx=["aria-label"],$x=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(a,{emit:n}){const t=a,o=n,i=e.ref(!0),r=e.ref(!1),s=e.ref(),c=I.isPlatform("mobile"),l="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),m=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let h=0;h<t.buffered.length;h++){const x=t.buffered.start(h),D=t.buffered.end(h);if(t.currentTime>=x&&t.currentTime<=D)return{width:`${D/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),f=e.computed(()=>t.muted||t.volume===0?Pu:t.volume<33?Ou:t.volume<66?Lu:Au);let p=null;function v(){i.value=!0,g()}function g(){p&&clearTimeout(p),t.playing&&!c&&(p=setTimeout(()=>{i.value=!1},3e3))}function E(h){if(!s.value||t.isLive)return;const x=s.value.getBoundingClientRect(),C=(h.clientX-x.left)/x.width*t.duration;o("seek",Math.max(0,Math.min(C,t.duration)))}function T(h){const x=h.target;o("setVolume",parseInt(x.value))}function N(h){o("selectQuality",h),r.value=!1}function w(h){if(!isFinite(h))return"0:00";const x=Math.floor(h/3600),D=Math.floor(h%3600/60),C=Math.floor(h%60);return x>0?`${x}:${D.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`:`${D}:${C.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),p&&clearTimeout(p)}),(h,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":i.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(h.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(h.duration),"aria-label":h.isLive?"Live stream":"Video progress",tabindex:"0",onClick:E},[e.createElementVNode("div",gx,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(m.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",yx,[e.createElementVNode("span",wx,e.toDisplayString(w(h.currentTime)),1),x[7]||(x[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",bx,e.toDisplayString(h.isLive?"LIVE":w(h.duration)),1)])],8,vx),e.createElementVNode("div",kx,[e.createElementVNode("div",xx,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:x[0]||(x[0]=D=>h.$emit("play-pause")),"aria-label":h.playing?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:h.playing?e.unref(Eu):e.unref(Su),"aria-hidden":"true"},null,8,["icon"])],8,Ex),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:x[1]||(x[1]=D=>h.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Cu),"aria-hidden":"true"},null,8,["icon"]),x[8]||(x[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:x[2]||(x[2]=D=>h.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Tu),"aria-hidden":"true"},null,8,["icon"]),x[9]||(x[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Vx,[e.unref(c)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Sx,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:x[3]||(x[3]=D=>h.$emit("toggleMute")),"aria-label":h.muted?"Unmute":"Mute"},[e.createVNode(e.unref(I.IonIcon),{icon:f.value,"aria-hidden":"true"},null,8,["icon"])],8,Cx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:h.muted?0:h.volume,onInput:T,"aria-label":"Volume"},null,40,Nx)]))]),e.createElementVNode("div",_x,[h.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",Tx,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:x[4]||(x[4]=D=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref($u),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",Bx,e.toDisplayString(h.currentQuality),1)],8,Mx),r.value?(e.openBlock(),e.createElementBlock("div",Fx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.qualityLevels,D=>(e.openBlock(),e.createElementBlock("button",{key:D.label,class:e.normalizeClass(["quality-option",{active:D.label===h.currentQuality}]),"data-testid":`btn-video-quality-${D.label}`,"aria-label":`Set quality to ${D.label}`,role:"menuitem",onClick:C=>N(D)},e.toDisplayString(D.label),11,Ix))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(c)&&l?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:x[5]||(x[5]=D=>h.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Du),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:x[6]||(x[6]=D=>h.$emit("toggleFullscreen")),"aria-label":h.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(I.IonIcon),{icon:h.fullscreen?e.unref(pu):e.unref(vu),"aria-hidden":"true"},null,8,["icon"])],8,Rx)])])],2))}}),Dx=Be($x,[["__scopeId","data-v-2ae77c13"]]);function Ux(a={}){var te,ge,Ne;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),c=e.ref(a.muted||!1),l=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),f=e.ref(null),p=e.ref("idle"),v=e.ref(a.playbackUrl||((te=a.media)==null?void 0:te.playback_url)||((ge=a.media)==null?void 0:ge.url)||""),g=e.ref(null),E=e.ref(a.isLive||!1),T=e.ref(null),N=e.ref(null);function w(ee){N.value=ee}if((Ne=a.media)!=null&&Ne.token_expires_at){const ee=new Date(a.media.token_expires_at);g.value=Number.isNaN(ee.getTime())?null:ee}async function h(){var F;const ee=E.value?t.value:n.value;if(ee)try{await ee.play(),o.value=!0,p.value=E.value?"live":"playing",(F=a.onPlay)==null||F.call(a)}catch{f.value="Failed to play video",p.value="error"}}function x(){var F;const ee=E.value?t.value:n.value;ee&&(ee.pause(),o.value=!1,p.value="paused",(F=a.onPause)==null||F.call(a))}function D(){o.value?x():h()}function C(ee){const F=E.value?t.value:n.value;if(!F||E.value)return;const P=Number.isFinite(F.duration)?F.duration:ee;F.currentTime=Math.max(0,Math.min(ee,P)),i.value=F.currentTime}function y(ee=10){const F=n.value;!F||E.value||C(F.currentTime+ee)}function S(ee=10){const F=n.value;!F||E.value||C(F.currentTime-ee)}function A(){const ee=E.value?t.value:n.value;ee&&(ee.muted=!ee.muted,c.value=ee.muted)}function k(ee){const F=E.value?t.value:n.value;if(!F)return;const P=Math.max(0,Math.min(100,ee));F.volume=P/100,s.value=P,P>0&&F.muted&&(F.muted=!1,c.value=!1)}function B(ee){const F=n.value;!F||E.value||(F.playbackRate=ee,u.value=ee)}async function R(){const ee=document.querySelector(".video-player-container");if(ee)try{document.fullscreenElement?(await document.exitFullscreen(),l.value=!1):(await ee.requestFullscreen(),l.value=!0)}catch{}}async function U(){const ee=E.value?t.value:n.value;if(ee)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ee.requestPictureInPicture()}catch{}}async function _(){var F;f.value=null,p.value="loading",(F=a.media)!=null&&F.provider&&a.media.provider!=="local"&&await z();const ee=E.value?t.value:n.value;ee&&(ee.load(),await h())}async function z(){if(!(!N.value||!a.media))try{m.value=!0;const ee=await N.value.get(`/api/v1/video/${a.media.uuid}/playback`);v.value=ee.playback_url,g.value=new Date(ee.token_expires_at);const F=E.value?t.value:n.value;if(F&&F.src!==v.value){const P=!F.paused,fe=F.currentTime;F.src=v.value,E.value||(F.currentTime=fe),P&&await h()}}catch{f.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function H(ee){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ee;return}try{t.value.src=ee}catch{f.value="Live streaming not supported in this browser",p.value="error"}}}function M(){T.value&&(T.value.destroy(),T.value=null)}function $(){var F;const ee=E.value?t.value:n.value;ee&&(i.value=ee.currentTime,r.value=ee.duration,(F=a.onTimeUpdate)==null||F.call(a,ee.currentTime))}const X=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ee=0;ee<d.value.length;ee++){const F=d.value.start(ee),P=d.value.end(ee);if(i.value>=F&&i.value<=P)return P/r.value*100}return 0});function j(){if(!g.value)return!1;const ee=new Date;return g.value.getTime()-ee.getTime()<5*60*1e3}return e.watch([n,t],([ee,F])=>{const P=E.value?F:ee;P&&(P.addEventListener("timeupdate",$),P.addEventListener("loadedmetadata",()=>{r.value=P.duration,p.value="ready"}),P.addEventListener("progress",()=>{d.value=P.buffered}),P.addEventListener("ended",()=>{var fe;o.value=!1,p.value="ended",(fe=a.onEnded)==null||fe.call(a)}),P.addEventListener("error",fe=>{var ne;p.value="error",(ne=a.onError)==null||ne.call(a,"Video playback error")}),P.volume=s.value/100,P.muted=c.value)}),e.onUnmounted(()=>{M();const ee=E.value?t.value:n.value;ee&&ee.removeEventListener("timeupdate",$)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:c,isFullscreen:l,bufferedRanges:d,bufferedPercent:X,playbackRate:u,isLoading:m,error:f,status:p,currentPlaybackUrl:v,tokenExpiresAt:g,play:h,pause:x,togglePlayPause:D,seek:C,skipForward:y,skipBackward:S,toggleMute:A,setVolume:k,setPlaybackRate:B,toggleFullscreen:R,togglePiP:U,retry:_,refreshToken:z,setupLiveStream:H,setApiClient:w,shouldRefreshToken:j}}const Ax=["src","poster","controls","autoplay","muted","loop","preload"],Ox={key:1,ref:"livePlayerEl",class:"live-player"},Lx=["controls","muted"],zx={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},Px={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},jx={key:3,class:"video-error","data-testid":"video-error",role:"alert"},Wx={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},Zx=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(a,{emit:n}){const t=a,o=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:c,duration:l,volume:d,muted:u,isFullscreen:m,bufferedRanges:f,isLoading:p,error:v,status:g,currentPlaybackUrl:E,tokenExpiresAt:T,play:N,pause:w,seek:h,toggleMute:x,setVolume:D,toggleFullscreen:C,togglePlayPause:y,skipForward:S,skipBackward:A,retry:k,refreshToken:B,setApiClient:R,shouldRefreshToken:U,setupLiveStream:_}=Ux({...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 z(){await B()}const H=e.computed(()=>{const ne=["video-player-container"];return t.className&&ne.push(t.className),m.value&&ne.push("fullscreen"),t.isLive&&ne.push("is-live"),s.value&&ne.push("is-playing"),p.value&&ne.push("is-loading"),ne}),M=e.computed(()=>{var ne,Y;if(t.poster)return t.poster;if((ne=t.media)!=null&&ne.poster_url)return t.media.poster_url;if((Y=t.media)!=null&&Y.thumbnail_url)return t.media.thumbnail_url});function $(ne){const Y=ne.target;o("loadedmetadata",{duration:Y.duration,width:Y.videoWidth,height:Y.videoHeight})}function X(ne){const Y=ne.target;c.value=Y.currentTime,o("timeupdate",Y.currentTime)}function j(){s.value=!0,o("play")}function te(){s.value=!1,o("pause")}function ge(){s.value=!1,o("ended")}function Ne(ne){const Y=ne.target;let Me="Failed to load video";if(Y.error)switch(Y.error.code){case Y.error.MEDIA_ERR_ABORTED:Me="Video playback aborted";break;case Y.error.MEDIA_ERR_NETWORK:Me="Network error while loading video";break;case Y.error.MEDIA_ERR_DECODE:Me="Video decoding error";break;case Y.error.MEDIA_ERR_SRC_NOT_SUPPORTED:Me="Video format not supported";break}v.value=Me,o("error",Me)}function ee(ne){const Y=ne.target;f.value=Y.buffered,o("progress",Y.buffered)}function F(){p.value=!0}function P(){p.value=!1}e.watch(()=>t.apiClient,ne=>{ne&&R(ne)},{immediate:!0}),e.watch(()=>t.playbackUrl,ne=>{typeof ne=="string"&&ne.length>0&&(E.value=ne)},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.token_expires_at},ne=>{if(!ne){T.value=null;return}const Y=new Date(ne);T.value=Number.isNaN(Y.getTime())?null:Y},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.playback_url},async(ne,Y)=>{if(t.playbackUrl||!ne||ne===Y)return;const Me=i.value;if(!Me||t.isLive){E.value=ne;return}const ce=!Me.paused,se=Me.currentTime;E.value=ne,await e.nextTick();try{Me.currentTime=se}catch{}ce&&await N()},{immediate:!0});let fe=null;return e.watch(()=>t.isLive,async ne=>{var Me;if(!ne)return;const Y=t.playbackUrl||((Me=t.media)==null?void 0:Me.playback_url)||"";Y&&await _(Y)},{immediate:!0}),e.onMounted(()=>{var ne;(ne=t.media)!=null&&ne.provider&&t.media.provider!=="local"&&(fe=setInterval(()=>{U()&&z()},3e4)),I.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{fe&&clearInterval(fe)}),(ne,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",H.value]),"data-testid":"video-player"},[ne.isLive?(e.openBlock(),e.createElementBlock("div",Ox,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ne.controls&&!ne.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:j,onPause:te,onError:Ne,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Lx),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",zx,[...Y[3]||(Y[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:i,src:e.unref(E),poster:M.value,controls:ne.controls&&!ne.showCustomControls,autoplay:ne.autoplay,muted:e.unref(u),loop:ne.loop,preload:ne.preload,onLoadedmetadata:$,onTimeupdate:X,onPlay:j,onPause:te,onEnded:ge,onError:Ne,onProgress:ee,onWaiting:F,onCanplay:P,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Ax)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",Px,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",jx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ji),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(I.IonButton),{size:"small",onClick:e.unref(k),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(On),slot:"start","aria-hidden":"true"},null,8,["icon"]),Y[4]||(Y[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ne.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(Dx,{key:4,playing:e.unref(s),currentTime:e.unref(c),duration:e.unref(l),buffered:e.unref(f),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ne.isLive,onPlay:e.unref(N),onPause:e.unref(w),onSeek:e.unref(h),onToggleMute:e.unref(x),onSetVolume:e.unref(D),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),ne.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",Wx,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:Y[0]||(Y[0]=(...Me)=>e.unref(A)&&e.unref(A)(...Me))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:Y[1]||(Y[1]=(...Me)=>e.unref(y)&&e.unref(y)(...Me))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:Y[2]||(Y[2]=(...Me)=>e.unref(S)&&e.unref(S)(...Me))},null,32)])):e.createCommentVNode("",!0)],2))}}),wc=Be(Zx,[["__scopeId","data-v-b8db4951"]]),Xx=wa.defineStore("video",()=>{const a=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(a.value.values())),s=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>s.value.filter(_=>_.status==="live")),l=e.computed(()=>r.value.filter(_=>_.processing_status==="processing"));function d(_){a.value.set(_.uuid,_)}function u(_,z){const H=a.value.get(_);H&&a.value.set(_,{...H,...z})}function m(_){a.value.delete(_)}function f(_){return a.value.get(_)}function p(_){n.value.set(_.id,_)}function v(_,z){const H=n.value.get(_);H&&n.value.set(_,{...H,...z})}function g(_,z){const H=n.value.get(_);H&&n.value.set(_,{...H,status:z.status,viewer_count:z.viewer_count,peak_viewers:z.peak_viewers})}function E(_){n.value.delete(_)}function T(_){return n.value.get(_)}function N(_){return s.value.find(z=>z.media_uuid===_)}function w(_){t.value.set(_.id,_)}function h(_,z){const H=t.value.get(_);H&&t.value.set(_,{...H,...z})}function x(_){t.value.delete(_)}function D(_){return t.value.get(_)}function C(_){return Array.from(t.value.values()).filter(z=>z.media_uuid===_)}function y(_){o.value=_}function S(_){o.value&&(o.value={...o.value,..._})}function A(){o.value=null}function k(_){i.value=_}function B(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function R(_){a.value.clear(),_.forEach(z=>{a.value.set(z.uuid,z)})}function U(_){n.value.clear(),_.forEach(z=>{n.value.set(z.id,z)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:c,processingVideos:l,setVideo:d,updateVideo:u,removeVideo:m,getVideo:f,setLiveStream:p,updateLiveStream:v,updateLiveStreamStats:g,removeLiveStream:E,getLiveStream:T,getLiveStreamByMedia:N,addExportJob:w,updateExportJob:h,removeExportJob:x,getExportJob:D,getExportJobsByMedia:C,setEditorState:y,updateEditorState:S,clearEditorState:A,setProcessing:k,clearAll:B,loadVideos:R,loadLiveStreams:U}});let fn=null;function Hx(a){fn=a}const Xo={post:async(a,n)=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${a}`)},delete:async a=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${a}`,{method:"DELETE"})}};function Ho(a,n=null){const t=typeof a.id=="string"&&a.id!==""?a.id:typeof a.stream_id=="string"&&a.stream_id!==""?a.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:a.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:a.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:a.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:a.status??(n==null?void 0:n.status)??"idle",viewer_count:a.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:a.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:a.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:a.low_latency??(n==null?void 0:n.low_latency)??!1},i=a.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(o.playback_url=i);const r=a.started_at??(n==null?void 0:n.started_at);r!==void 0&&(o.started_at=r);const s=a.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(o.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(o.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(o.vod_media_uuid=n.vod_media_uuid),o}function bi(a,n){return a instanceof Error&&a.message?a.message:n}function Gx(a){const n=Xx(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),c=e.ref(!1),l=e.ref(null),d=e.ref(null),u=e.ref(0),m=e.ref(0);let f;const p=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var A;if(!((A=t.value)!=null&&A.playback_url))return null;const S=new URL(t.value.playback_url);return S.searchParams.set("live","true"),o.value&&S.searchParams.set("latency","low"),S.toString()}),g=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="live"}),E=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="idle"}),T=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="ended"});async function N(S={}){s.value=!0,l.value=null;try{const A=await Xo.post("/live",{title:r.value||S.title||"Live Stream",low_latency:S.low_latency??o.value,auto_record:S.auto_record??i.value,...S}),k=Ho(A);return t.value=k,n.setLiveStream(k),D(),k}catch(A){throw l.value=bi(A,"Failed to create stream"),A instanceof Error?A:new Error(l.value)}finally{s.value=!1}}async function w(){if(!t.value)throw new Error("No active stream");c.value=!0,l.value=null;try{const S=await Xo.post(`/live/${t.value.id}/end`),A=Ho(S,t.value);return t.value=A,n.setLiveStream(A),C(),A}catch(S){throw l.value=bi(S,"Failed to end stream"),S instanceof Error?S:new Error(l.value)}finally{c.value=!1}}async function h(){if(t.value)try{const S=await Xo.get(`/live/${t.value.id}`),A=Ho(S,t.value);u.value=A.viewer_count,m.value=A.peak_viewers,t.value=A;const k={status:A.status,viewer_count:A.viewer_count,peak_viewers:A.peak_viewers};A.started_at&&(k.started_at=A.started_at),A.ended_at&&(k.ended_at=A.ended_at),n.updateLiveStreamStats(A.id,k),A.status==="live"&&!d.value&&A.started_at&&(d.value=new Date(A.started_at)),A.status==="ended"&&C()}catch{}}async function x(S){try{const A=await Xo.get(`/live/${S}`),k=Ho(A,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(A){throw l.value=bi(A,"Failed to get stream credentials"),A instanceof Error?A:new Error(l.value)}}function D(S=5e3){C(),f=window.setInterval(()=>{h()},S)}function C(){f!==void 0&&(clearInterval(f),f=void 0)}async function y(){if(!a)return;const S=n.getLiveStreamByMedia(a);S&&(t.value=S,u.value=S.viewer_count,m.value=S.peak_viewers,S.status==="live"&&(D(),S.started_at&&(d.value=new Date(S.started_at))))}return a&&y(),e.onUnmounted(()=>{C()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:c,error:l,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:g,isIdle:E,hasEnded:T,createStream:N,endStream:w,refreshStreamStatus:h,getStreamCredentials:x,startStatusPolling:D,stopStatusPolling:C}}const Jx={class:"stream-status"},Yx={class:"flex items-center justify-between"},Kx={class:"flex items-center gap-3"},qx={key:0,class:"flex items-center"},Qx={key:2,class:"text-sm text-gray-600"},eE={key:0,class:"flex items-center gap-2"},tE={class:"text-sm font-medium text-gray-700"},nE={key:0,class:"text-xs text-gray-500"},oE=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(a){const n=a,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),o=e.computed(()=>{const r="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`${r} ${s[n.status]||s.idle}`}),i=e.computed(()=>{if(!n.duration)return null;const r=Math.floor(n.duration/3600),s=Math.floor(n.duration%3600/60),c=n.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`:`${s}:${c.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",Jx,[e.createElementVNode("div",Yx,[e.createElementVNode("div",Kx,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",qx,[...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(o.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",Qx,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",eE,[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",tE,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",nE," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),aE=Be(oE,[["__scopeId","data-v-1d09c19f"]]),iE={class:"stream-credentials"},rE={class:"space-y-3"},sE={class:"credential-field"},lE={class:"flex gap-2"},cE=["value"],dE={class:"credential-field"},uE={class:"flex gap-2"},mE=["value","type"],pE=["aria-label"],fE={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},hE={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},vE={key:0,class:"mt-2 text-sm text-green-600"},gE=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.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 c(){i.value=!i.value}async function l(d,u){try{await navigator.clipboard.writeText(d),r.value=u,o("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",iE,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",rE,[e.createElementVNode("div",sE,[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",lE,[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,cE),e.createElementVNode("button",{onClick:u[0]||(u[0]=m=>l(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",dE,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",uE,[e.createElementVNode("input",{value:s.value,readonly:"",type:i.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,mE),e.createElementVNode("button",{onClick:c,class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":i.value?"Hide stream key":"Show stream key"},[i.value?(e.openBlock(),e.createElementBlock("svg",hE,[...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",fE,[...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,pE),e.createElementVNode("button",{onClick:u[1]||(u[1]=m=>l(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(()=>[r.value?(e.openBlock(),e.createElementBlock("div",vE,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),yE=Be(gE,[["__scopeId","data-v-306d92f6"]]),wE={class:"live-stream-manager","data-testid":"live-stream-manager"},bE={key:0,class:"stream-setup"},kE={class:"space-y-4"},xE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},EE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},VE=["disabled"],SE={key:0},CE={key:1,class:"flex items-center justify-center"},NE={key:1,class:"stream-active space-y-6"},_E={key:1,class:"video-preview"},TE={key:2,class:"analytics-panel"},ME={class:"grid grid-cols-2 gap-4"},BE={class:"bg-gray-50 p-3 rounded"},FE={class:"text-2xl font-bold text-gray-900"},IE={class:"bg-gray-50 p-3 rounded"},RE={class:"text-2xl font-bold text-gray-900"},$E={class:"stream-controls flex gap-3"},DE=["disabled"],UE={key:0},AE={key:1},OE={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},LE={class:"text-red-600 text-sm"},zE=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(a,{emit:n}){const t=a,o=n;t.httpClient&&Hx(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:c,isCreating:l,isEnding:d,error:u,createStream:m,endStream:f,streamDuration:p,playbackUrl:v,refreshStreamStatus:g}=Gx(t.mediaUuid),E=e.ref(!1);async function T(){var D;try{const C=await m({title:c.value,low_latency:r.value,auto_record:s.value});o("stream-created",C),(D=t.onStreamCreated)==null||D.call(t,C)}catch(C){o("error",C)}}async function N(){var D;try{const C=await f();o("stream-ended",C),(D=t.onStreamEnded)==null||D.call(t,C)}catch(C){o("error",C)}}function w(){i.value=null,c.value="",E.value=!1,u.value=null}async function h(D,C){try{await navigator.clipboard.writeText(D)}catch{}}let x;return e.onMounted(()=>{var D;((D=i.value)==null?void 0:D.status)==="live"&&(x=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{x&&clearInterval(x)}),(D,C)=>(e.openBlock(),e.createElementBlock("div",wE,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",NE,[e.createVNode(aE,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(yE,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:h},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",_E,[C[9]||(C[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(wc,{"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(i).status==="live"?(e.openBlock(),e.createElementBlock("div",TE,[C[12]||(C[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",ME,[e.createElementVNode("div",BE,[e.createElementVNode("div",FE,e.toDisplayString(e.unref(i).viewer_count),1),C[10]||(C[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",IE,[e.createElementVNode("div",RE,e.toDisplayString(e.unref(i).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",$E,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C[3]||(C[3]=y=>E.value=!E.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(E.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:N,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",AE,"Ending...")):(e.openBlock(),e.createElementBlock("span",UE,"End Stream"))],8,DE)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:w,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",bE,[C[8]||(C[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",kE,[e.createElementVNode("div",xE,[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(r)?r.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(r)]])]),e.createElementVNode("div",EE,[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(c)?c.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(c)]])]),e.createElementVNode("button",{onClick:T,disabled:e.unref(l),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(l)?(e.openBlock(),e.createElementBlock("span",CE,[...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",SE,"Create Stream"))],8,VE)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",OE,[e.createElementVNode("p",LE,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),PE=Be(zE,[["__scopeId","data-v-26291f6f"]]),jE={class:"album-tree-node"},WE=["data-album-id","draggable","aria-selected","aria-expanded"],ZE={key:1,class:"album-node__chevron-placeholder"},XE={key:2,"data-testid":"media-count",class:"album-node__count"},HE={key:0,class:"album-tree-node__children",role:"group"},GE=16,JE=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(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.expandedIds.has(t.album.id)),r=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),c=e.computed(()=>t.album.children_count>0),l=e.computed(()=>`${t.depth*GE}px`),d=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.dropTargetId)===t.album.id}),m=e.computed(()=>{var w;return(w=t.dragState)!=null&&w.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),f=e.computed(()=>{const w=["album-node"];return r.value&&w.push("album-node--selected"),s.value&&w.push("album-node--focused"),t.compact&&w.push("album-node--compact"),d.value&&w.push("album-node--dragging"),u.value&&w.push("album-node--drop-target"),m.value&&w.push("album-node--invalid-drop"),w});function p(){o("select",t.album)}function v(w){w.stopPropagation(),o("toggle-expand",t.album.id)}function g(w){t.draggable&&(w.dataTransfer&&(w.dataTransfer.setData("text/plain",t.album.id),w.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function E(w){t.draggable&&(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function T(){o("drag-leave",t.album.id)}function N(w){t.draggable&&(w.preventDefault(),o("drop",t.album.id))}return(w,h)=>{var D;const x=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",jE,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":w.album.id,class:e.normalizeClass(f.value),style:e.normalizeStyle({paddingLeft:l.value}),draggable:w.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":c.value?i.value:void 0,onDragstart:g,onDragover:E,onDragleave:T,onDrop:N},[c.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(I.IonIcon),{icon:i.value?e.unref(du):e.unref(uu)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",ZE)),e.createVNode(e.unref(I.IonIcon),{icon:e.unref(wu),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(w.album.name),1),w.showMediaCount?(e.openBlock(),e.createElementBlock("span",XE,e.toDisplayString(w.album.media_count),1)):e.createCommentVNode("",!0)],46,WE),i.value&&((D=w.album.children)!=null&&D.length)?(e.openBlock(),e.createElementBlock("div",HE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.album.children,C=>(e.openBlock(),e.createBlock(x,{key:C.id,album:C,depth:w.depth+1,"selected-id":w.selectedId,"expanded-ids":w.expandedIds,"focused-id":w.focusedId,draggable:w.draggable,"show-media-count":w.showMediaCount,compact:w.compact,onSelect:h[0]||(h[0]=y=>o("select",y)),onToggleExpand:h[1]||(h[1]=y=>o("toggle-expand",y))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),YE=Be(JE,[["__scopeId","data-v-76be65a6"]]),ja=wa.defineStore("albums",()=>{const a=e.ref([]),n=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const h=new Map;return a.value.forEach(x=>h.set(x.id,x)),h}),s=e.computed(()=>a.value.filter(h=>h.parent_id===null));async function c(h){t.value=!0,o.value=null;try{const x=(h==null?void 0:h.parent_id)??null,D=x?`/api/v1/albums?parent_id=${x}`:"/api/v1/albums?parent_id=null",C=await fetch(D);if(!C.ok)throw new Error("Failed to fetch albums");((await C.json()).data||[]).forEach(A=>{const k=a.value.findIndex(B=>B.id===A.id);k>=0?a.value[k]=A:a.value.push(A)}),x!==null&&i.value.add(x)}catch(x){o.value=x instanceof Error?x.message:"Unknown error"}finally{t.value=!1}}async function l(h){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${h}`);if(!x.ok)throw new Error("Failed to fetch album");const C=(await x.json()).data,y=a.value.findIndex(S=>S.id===C.id);return y>=0?a.value[y]=C:a.value.push(C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function d(h){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${h}/media`);if(!x.ok)throw new Error("Failed to fetch album media");const C=(await x.json()).data||[];return n.value.set(h,C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function u(h,x){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${h}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:x})})).ok)throw new Error("Failed to reorder album media");const C=n.value.get(h)||[],y=x.map(S=>C.find(A=>A.uuid===S)).filter(S=>S!==void 0);n.value.set(h,y)}catch(D){throw o.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function m(h){t.value=!0,o.value=null;try{const x=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(h)});if(!x.ok)throw new Error("Failed to create album");const C=(await x.json()).data;return a.value.push(C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function f(h,x){t.value=!0,o.value=null;try{const D=await fetch(`/api/v1/albums/${h}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x)});if(!D.ok)throw new Error("Failed to update album");const y=(await D.json()).data,S=a.value.findIndex(A=>A.id===y.id);return S>=0&&(a.value[S]=y),y}catch(D){throw o.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function p(h){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${h}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const D=a.value.findIndex(C=>C.id===h);D>=0&&a.value.splice(D,1),n.value.delete(h)}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}function v(h){return a.value.filter(x=>x.parent_id===h)}function g(h){return i.value.has(h)}function E(h){return n.value.get(h)||[]}async function T(h,x){const D=a.value.findIndex(y=>y.id===h);if(D<0)return;const C=a.value[D];a.value[D]={...C,parent_id:x};try{if(!(await fetch(`/api/v1/albums/${h}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:x})})).ok)throw new Error("Failed to move album")}catch(y){throw a.value[D]=C,o.value=y instanceof Error?y.message:"Unknown error",y instanceof Error?y:new Error("Failed to move album")}}function N(h){a.value=h}function w(){a.value=[],n.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:a,albumMedia:n,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:c,fetchAlbum:l,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:f,deleteAlbum:p,getChildrenOf:v,childrenLoaded:g,getAlbumMedia:E,moveAlbum:T,setAlbums:N,reset:w}});function bc(){const a=ja(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=wa.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function c(u){return a.getChildrenOf(u)}function l(u){return a.childrenLoaded(u)}async function d(u,m){await a.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:c,childrenLoaded:l,moveAlbum:d}}function kc(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,f){if(m===f)return!0;const p=new Set,v=[m];for(;v.length>0;){const g=v.shift();if(!g||p.has(g))continue;p.add(g);const E=n.get(g)||[];for(const T of E){if(T===f)return!0;v.push(T)}}return!1}function r(m,f){return m===f?!1:f===null?!0:!i(m,f)}function s(m){o.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function c(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function l(m){o.value.dropTargetId=m}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:f}=o.value;if(!m){c();return}if(!r(m,f)){c();return}try{await t(m,f)}finally{c()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:c,setDropTarget:l,clearDropTarget:d,executeDrop:u}}const KE={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},qE={key:1,"data-testid":"error-state",class:"album-tree__error"},QE={key:2,"data-testid":"empty-state",class:"album-tree__empty"},e4={key:3,class:"album-tree__content",role:"group"},t4=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),c=e.computed(()=>o.compact===!0),{albums:l,rootAlbums:d,loading:u,error:m,fetchAlbums:f,getChildrenOf:p,childrenLoaded:v,moveAlbum:g}=bc(),E=e.shallowRef(new Set(o.expandedIds)),T=e.ref(o.modelValue??null),N=e.ref(null),w=new Map,h=new Map;function x(F){w.clear(),h.clear();for(const P of F){w.set(P.id,P);const fe=P.parent_id??null,ne=h.get(fe)??[];ne.push(P.id),h.set(fe,ne)}}e.watch(l,F=>{x(F)},{immediate:!0});const{dragState:D,canDropOn:C,startDrag:y,endDrag:S,setDropTarget:A,clearDropTarget:k,executeDrop:B}=kc({childrenByParentId:h,onMove:async(F,P)=>{await g(F,P),i("album-moved",{albumId:F,newParentId:P})}});e.watch(()=>o.modelValue,F=>{T.value=F??null}),e.watch(()=>o.expandedIds,F=>{E.value=new Set(F)}),e.onMounted(async()=>{await f({parent_id:null})});const R=e.computed(()=>d.value.map(F=>U(F)));function U(F){if(!E.value.has(F.id))return F;const P=p(F.id);return{...F,children:P.map(fe=>U(fe))}}const _=e.computed(()=>{const F=[];function P(fe){var ne;for(const Y of fe)F.push(Y),E.value.has(Y.id)&&((ne=Y.children)!=null&&ne.length)&&P(Y.children)}return P(R.value),F});function z(F){var ne;if(!_.value.length)return;const P=N.value?_.value.findIndex(Y=>Y.id===N.value):-1,fe=P>=0?_.value[P]:null;switch(F.key){case"ArrowDown":F.preventDefault(),P<_.value.length-1?N.value=_.value[P+1].id:P===-1&&_.value.length>0&&(N.value=_.value[0].id);break;case"ArrowUp":F.preventDefault(),P>0&&(N.value=_.value[P-1].id);break;case"ArrowRight":F.preventDefault(),fe&&(fe.children_count>0&&!E.value.has(fe.id)?H(fe.id):E.value.has(fe.id)&&((ne=fe.children)!=null&&ne.length)&&(N.value=fe.children[0].id));break;case"ArrowLeft":F.preventDefault(),fe&&(E.value.has(fe.id)&&fe.children_count>0?H(fe.id):fe.parent_id&&(N.value=fe.parent_id));break;case"Enter":case" ":F.preventDefault(),fe&&M(fe);break;case"Home":F.preventDefault(),_.value.length>0&&(N.value=_.value[0].id);break;case"End":F.preventDefault(),_.value.length>0&&(N.value=_.value[_.value.length-1].id);break}}async function H(F){E.value.has(F)?(E.value.delete(F),i("album-collapsed",F)):(v(F)||await f({parent_id:F}),E.value.add(F),i("album-expanded",F))}function M(F){T.value=F.id,i("update:modelValue",F.id),i("album-selected",F)}function $(F){o.draggable&&y(F)}function X(F){var fe;if(!o.draggable)return;const P=(fe=D.value)==null?void 0:fe.draggedAlbumId;P&&(A(F),C(P,F))}function j(){o.draggable&&k()}async function te(F){o.draggable&&(A(F),await B())}function ge(F){o.draggable&&(F.preventDefault(),A(null))}async function Ne(F){o.draggable&&(F.preventDefault(),A(null),await B())}function ee(){S()}return n({focusedId:N}),(F,P)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:z,onDragover:ge,onDrop:Ne,onDragend:ee},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",KE,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",qE,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",e4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,fe=>(e.openBlock(),e.createBlock(YE,{key:fe.id,album:fe,depth:0,"selected-id":T.value,"expanded-ids":E.value,"focused-id":N.value,draggable:r.value,"drag-state":r.value?e.unref(D):null,"show-media-count":s.value,compact:c.value,onSelect:M,onToggleExpand:H,onDragStart:$,onDragOver:X,onDragLeave:j,onDrop:te},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",QE,[P[0]||(P[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(F.$slots,"empty-action",{},void 0,!0)]))],32))}}),xc=Be(t4,[["__scopeId","data-v-ae3dea7a"]]),n4=300,o4=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),c=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const l=e.computed(()=>r.value!==null);function d(p){const v=Date.now();if(c.value===p.id&&v-s.value<n4){o("confirm",p);return}s.value=v,c.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&o("confirm",r.value)}function m(){o("close")}function f(){o("close")}return(p,v)=>(e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:f},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-button",onClick:m},{default:e.withCtx(()=>[...v[1]||(v[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(xc,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:m},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!l.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Ec=Be(o4,[["__scopeId","data-v-21676ec1"]]),a4={class:"ion-padding-start text-sm"},i4={class:"ion-padding-start text-sm"},r4={key:1},s4={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},l4={class:"flex items-center justify-between gap-3 pb-3"},c4={class:"text-base font-semibold text-gray-900"},d4={class:"ion-padding-start text-sm"},u4={class:"ion-padding-start text-sm"},m4={class:"flex justify-between pt-2"},p4={key:1},eo=255,to=1e3,f4=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(a,{emit:n}){const t=a,o=n,i=ja(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),c=e.computed(()=>r.value?"Save":"Create"),l=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),m=e.ref(!1),f=e.ref(null),p=e.ref(!1),v=e.ref(!1),g=e.computed(()=>d.value.name?l.value.name.trim()?l.value.name.length>eo?`Name must be ${eo} characters or less`:null:"Name is required":null),E=e.computed(()=>d.value.description&&l.value.description.length>to?`Description must be ${to} characters or less`:null),T=e.computed(()=>{const z=l.value.name.trim().length>0,H=l.value.name.length<=eo,M=l.value.description.length<=to;return z&&H&&M&&!p.value}),N=e.computed(()=>{var z;return((z=u.value)==null?void 0:z.name)??"None (Root)"}),w=e.computed(()=>f.value?f.value.children_count===0&&f.value.media_count===0:!1),h=e.computed(()=>f.value?f.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":f.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${f.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await x()});async function x(){if(t.albumId)try{const z=await i.fetchAlbum(t.albumId);f.value=z,l.value={name:z.name,description:z.description??"",parent_id:z.parent_id},z.parent_id&&(u.value={id:z.parent_id,name:"Parent Album"})}catch(z){o("error",z)}}function D(){d.value.name=!0}function C(){d.value.description=!0}function y(){m.value=!0}function S(z){u.value={id:z.id,name:z.name},l.value.parent_id=z.id,m.value=!1}function A(){m.value=!1}function k(){o("close")}function B(){o("close")}async function R(){if(d.value.name=!0,d.value.description=!0,!(!T.value||p.value)){p.value=!0;try{const z={name:l.value.name.trim(),description:l.value.description.trim(),parent_id:l.value.parent_id};if(r.value&&t.albumId){const H=await i.updateAlbum(t.albumId,z);o("updated",H)}else{const H=await i.createAlbum(z);o("created",H)}o("close")}catch(z){o("error",z)}finally{p.value=!1}}}function U(){w.value&&(v.value=!0)}async function _(z){var M;if((((M=z.detail)==null?void 0:M.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch($){o("error",$)}finally{p.value=!1,v.value=!1}}}return(z,H)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[z.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(I.IonModal),{key:0,"is-open":z.isOpen,class:"album-manager-modal",onDidDismiss:B},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...H[4]||(H[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(R,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[5]||(H[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":H[0]||(H[0]=M=>l.value.name=M),"data-testid":"name-input",maxlength:eo,onIonBlur:D},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",a4,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[6]||(H[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":H[1]||(H[1]=M=>l.value.description=M),"data-testid":"description-input",maxlength:to,onIonBlur:C},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",i4,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...H[7]||(H[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!w.value,title:w.value?void 0:h.value,onClick:U},{default:e.withCtx(()=>[...H[8]||(H[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!T.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",r4,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",s4,[e.createElementVNode("div",l4,[e.createElementVNode("h2",c4,e.toDisplayString(s.value),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...H[9]||(H[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(R,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[10]||(H[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":H[2]||(H[2]=M=>l.value.name=M),"data-testid":"name-input",maxlength:eo,onIonBlur:D},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",d4,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[11]||(H[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":H[3]||(H[3]=M=>l.value.description=M),"data-testid":"description-input",maxlength:to,onIonBlur:C},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",u4,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...H[12]||(H[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.value),1)]),_:1})]),_:1}),e.createElementVNode("div",m4,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!w.value,title:w.value?void 0:h.value,onClick:U},{default:e.withCtx(()=>[...H[13]||(H[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!T.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",p4,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Ec,{"is-open":m.value,"selected-album-id":l.value.parent_id,title:"Select Parent Album",onClose:A,onConfirm:S},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(I.IonAlert),{"is-open":v.value,header:"Delete Album?",message:h.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:_},null,8,["is-open","message"])],64))}}),h4=Be(f4,[["__scopeId","data-v-22083f3a"]]),v4={class:"album-media-grid"},g4={class:"aspect-square"},y4={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},w4={class:"text-gray-500"},b4=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],k4={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},x4={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},E4={class:"aspect-square relative"},V4=["src","alt"],S4={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},C4=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(a,{emit:n}){const t=a,o=n,i=ja(),r=e.ref([]),s=e.ref(!1),c=e.ref(null),l=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),m=e.computed(()=>!u.value&&r.value.length===0),f=e.computed(()=>{const B=t.columns;return["grid","gap-4",`grid-cols-${B.mobile??2}`,`sm:grid-cols-${B.sm??3}`,`md:grid-cols-${B.md??4}`,`lg:grid-cols-${B.lg??5}`,`xl:grid-cols-${B.xl??6}`]}),p=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 B=await i.fetchAlbumMedia(t.albumId);r.value=B}catch{r.value=[]}finally{s.value=!1}}function g(B){return t.selectedItems.includes(B)}function E(B){o("toggle-select",B);const R=g(B.uuid)?t.selectedItems.filter(U=>U!==B.uuid):[...t.selectedItems,B.uuid];o("selection-change",R)}function T(B){if(B.conversions&&typeof B.conversions=="object"){const R=B.conversions.thumb;if(typeof R=="string")return R}return B.original_url}function N(B){c.value=B}function w(){c.value=null}function h(B){o("preview",B)}function x(B){o("edit",B)}function D(B){o("detach",B.uuid)}function C(){o("add")}function y(B,R){t.reorderable&&(l.value=R,B.dataTransfer&&(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",String(R))))}function S(B,R){!t.reorderable||l.value===null||(B.preventDefault(),d.value=R)}function A(B,R){if(!t.reorderable||l.value===null)return;B.preventDefault();const U=l.value;if(U!==R){const _=[...r.value],[z]=_.splice(U,1);_.splice(R,0,z),r.value=_;const H=_.map(M=>M.uuid);o("reorder",H),i.reorderAlbumMedia(t.albumId,H).catch(()=>{v()})}l.value=null,d.value=null}function k(){l.value=null,d.value=null}return(B,R)=>(e.openBlock(),e.createElementBlock("div",v4,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,U=>(e.openBlock(),e.createBlock(e.unref(I.IonCard),{key:U,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",g4,[e.createVNode(e.unref(I.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",y4,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",w4,e.toDisplayString(B.emptyText),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"add-media-btn",onClick:C},{default:e.withCtx(()=>[...R[0]||(R[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(U,_)=>(e.openBlock(),e.createElementBlock("div",{key:U.uuid,"data-media-id":U.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":l.value===_,"ring-2 ring-primary":d.value===_&&l.value!==_}]),draggable:B.reorderable,onDragstart:z=>y(z,_),onDragover:z=>S(z,_),onDrop:z=>A(z,_),onDragend:k,onMouseenter:z=>N(U.uuid),onMouseleave:w},[d.value===_&&l.value!==_&&B.reorderable?(e.openBlock(),e.createElementBlock("div",k4)):e.createCommentVNode("",!0),B.reorderable?(e.openBlock(),e.createElementBlock("div",x4,[e.createVNode(e.unref(I.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),B.selectionMode?(e.openBlock(),e.createBlock(e.unref(I.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(U.uuid),class:"absolute top-2 left-2 z-20",onIonChange:z=>E(U)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",E4,[e.createElementVNode("img",{src:T(U),alt:U.file_name,class:"w-full h-full object-cover"},null,8,V4),B.showActions&&c.value===U.uuid?(e.openBlock(),e.createElementBlock("div",S4,[e.createVNode(e.unref(I.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:z=>h(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:z=>x(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:z=>D(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,b4))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:C},[e.createVNode(e.unref(I.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),R[1]||(R[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),N4=Be(C4,[["__scopeId","data-v-d84b796a"]]);function yr(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),c=e.ref(null),l=e.computed(()=>c.value!==null),d=T=>{if(r.value++,c.value=null,i.value=null,t.value=!1,T!=null&&typeof T=="object"&&!(T instanceof Blob)&&("image"in T||"state"in T||"sessionKey"in T)){const N=T;o.value=N.image??null,s.value=N.state??null}else o.value=T??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,c.value=null,t.value=!1,s.value=null},m=async T=>{try{return t.value=!0,i.value=T,a.onSave&&await a.onSave(T),u(),T}catch(N){const w=N;throw c.value=w,a.onError&&a.onError(w),w}finally{t.value=!1}},f=()=>{a.onCancel&&a.onCancel(),u()},p=T=>{c.value=T,a.onError&&a.onError(T)},v=()=>{c.value=null},g=()=>i.value,E=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:c,hasError:l,hasUnsavedChanges:E,open:d,close:u,handleSave:m,handleCancel:f,handleError:p,clearError:v,getEditedImage:g}}let ki=null;function _4(a){return ki||(ki=yr(a)),ki}function T4(a){return n=>new Promise((t,o)=>{yr({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function wr(a){return a.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const o={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(o.custom_properties=n.customProperties),o})}function Xi(a){return a.map((n,t)=>{const o={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(o.customProperties=n.custom_properties),o})}function br(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),Rn(t)}return{name:"mediables",async upload(t,o){const r=await xt().uploadFile(t,{collection:(o==null?void 0:o.collection)||"default",customProperties:o==null?void 0:o.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,o){await xt().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await xt().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await xt().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await xt().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await xt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return xt().getMediaUrl(t,o)},getThumbnailUrl(t){var o,i;return(o=t.conversion_urls)!=null&&o.thumb?t.conversion_urls.thumb:(i=t.conversion_urls)!=null&&i.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await xt().deleteMedia(t)},async update(t,o){const r=await xt().updateMedia(t,o);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const o={};t.apiBaseUrl!==void 0&&(o.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(o.isAdmin=t.isAdmin),Rn(o)}}}let ia=null;function M4(){return ia||(ia=br()),ia}function B4(){ia=null}const F4={apiBaseUrl:"/media-library-pro"};function Go(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function xi(a){const n={uuid:a.uuid,file_name:a.fileName||a.name,mime_type:`application/${a.extension}`,size:a.size,disk:"public",original_url:a.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return a.name&&(n.name=a.name),a.original_url&&(n.url=a.original_url),a.preview_url&&(n.thumbnail_url=a.preview_url,n.preview_url=a.preview_url),a.custom_properties&&(n.custom_properties=a.custom_properties),n}function kr(a){const n={...F4,...a};return{name:"spatie",async upload(o,i){const r=new FormData;r.append("file",o),i!=null&&i.collection&&r.append("collection",i.collection),i!=null&&i.customProperties&&r.append("custom_properties",JSON.stringify(i.customProperties));const s={Accept:"application/json",...n.headers},c=n.csrfToken||Go();c&&(s["X-CSRF-TOKEN"]=c);const l={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(l.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,l);if(!d.ok){const f=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(f.message||`HTTP ${d.status}`)}const u=await d.json(),m=xi(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Go();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",o.modelType),s.append("model_id",String(o.modelId)),o.collection&&s.append("collection",o.collection);try{const c=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!c.ok)throw new Error(`HTTP ${c.status}`);return(await c.json()).map(xi)}catch{return[]}},getUrl(o,i){var r;if(i){const s=(r=o.conversion_urls)==null?void 0:r[i];if(s)return s}return o.original_url||o.url||""},getThumbnailUrl(o){var i,r;return o.preview_url?o.preview_url:(i=o.conversion_urls)!=null&&i.preview?o.conversion_urls.preview:o.thumbnail_url?o.thumbnail_url:(r=o.conversion_urls)!=null&&r.thumb?o.conversion_urls.thumb:o.original_url||o.url||""},async delete(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Go();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const c=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(c.message||`HTTP ${s.status}`)}},async update(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||Go();s&&(r["X-CSRF-TOKEN"]=s);const c=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!c.ok){const d=await c.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${c.status}`)}const l=await c.json();return xi(l)},configure(o){Object.assign(n,o)}}}let ra=null;function I4(){return ra||(ra=kr()),ra}function R4(){ra=null}function Vc(a,n){switch(a){case"mediables":return br(n);case"spatie":return kr(n);default:throw new Error(`Unknown adapter: ${a}`)}}function ya(a){if(a===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(a)/Math.log(n));return parseFloat((a/Math.pow(n,o)).toFixed(2))+" "+t[o]}function Sc(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function xr(a){return a.type.startsWith("image/")}async function Cc(a){return xr(a)?new Promise(n=>{const t=new Image,o=URL.createObjectURL(a);t.onload=()=>{URL.revokeObjectURL(o),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),n(null)},t.src=o}):null}async function Nc(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${ya(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${ya(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-1)):a.type===i)||t.push({field:"type",message:`File type "${a.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const o=Sc(a.name);n.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if(xr(a)&&(n.maxDimensions||n.minDimensions)){const o=await Cc(a);o&&(n.maxDimensions&&(o.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(o.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const o=await n.customValidator(a);t.push(...o)}return{valid:t.length===0,errors:t}}function Er(a={}){const n=e.ref(a.rules||{});function t(l){n.value=l}async function o(l){return Nc(l,n.value)}async function i(l){const d=new Map;return await Promise.all(l.map(async u=>{const m=await o(u);d.set(u,m)})),d}function r(l,d){return n.value.maxItems?d+l<=n.value.maxItems:!0}const s=e.computed(()=>{const l=[];return n.value.acceptedMimeTypes&&l.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&l.push(...n.value.acceptedExtensions),l.join(",")});function c(l){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?l.startsWith(d.slice(0,-1)):l===d)}return{rules:n,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:c}}function $4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function D4(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function _c(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:c,onUploadError:l,onQueueComplete:d}=a,u=e.ref(new Map),m=e.ref(new Set),f=o?{rules:o}:{},{validateFile:p}=Er(f);async function v(){if(m.value.size>=t)return;const k=Array.from(u.value.entries()).find(([U,_])=>_.status==="pending"&&!m.value.has(U));if(!k){Array.from(u.value.values()).every(_=>_.status==="completed"||_.status==="error")&&u.value.size>0&&(d==null||d());return}const[B,R]=k;await g(B,R)}async function g(k,B){m.value.add(k),B.status="uploading",B.abortController=new AbortController,u.value.set(k,{...B}),r==null||r(B);try{const R={onProgress:_=>{B.progress=_,u.value.set(k,{...B}),s==null||s(B)},signal:B.abortController.signal};i&&(R.collection=i);const U=await n.upload(B.file,R);B.status="completed",B.progress=100,B.media=U.media,u.value.set(k,{...B}),c==null||c(B,U.media)}catch(R){R.name==="AbortError"?u.value.delete(k):(B.status="error",B.error=R.message,u.value.set(k,{...B}),l==null||l(B,R))}finally{m.value.delete(k),delete B.abortController,v()}}async function E(k){var U;const B=Array.from(k),R=[];for(const _ of B){const z=await p(_),H=$4(),M=D4(_),$={id:H,file:_,progress:0,status:z.valid?"pending":"error"};!z.valid&&((U=z.errors[0])!=null&&U.message)&&($.error=z.errors[0].message),M&&($.previewUrl=M),u.value.set(H,$);const X={media:null,clientId:H,name:_.name,order:0,upload:$,errors:z.errors};R.push(X)}for(let _=0;_<t;_++)v();return R}function T(k){const B=u.value.get(k);B&&(B.abortController&&B.abortController.abort(),B.previewUrl&&URL.revokeObjectURL(B.previewUrl),u.value.delete(k),m.value.delete(k),v())}async function N(k){const B=u.value.get(k);!B||B.status!=="error"||(B.status="pending",B.progress=0,delete B.error,u.value.set(k,{...B}),v())}function w(){for(const[k,B]of u.value.entries())(B.status==="completed"||B.status==="error")&&(B.previewUrl&&URL.revokeObjectURL(B.previewUrl),u.value.delete(k))}function h(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),m.value.clear()}function x(k){return u.value.get(k)}const D=e.computed(()=>m.value.size>0),C=e.computed(()=>m.value.size),y=e.computed(()=>Array.from(u.value.values()).filter(k=>k.status==="pending").length),S=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(k=>k.status==="completed"||k.status==="error")),A=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:D,activeCount:C,pendingCount:y,isComplete:S,addFiles:E,cancelUpload:T,retryUpload:N,clearCompleted:w,clearAll:h,getUpload:x,uploadsArray:A}}function Tc(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,c=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),l=e.ref(!1);let d=null;function u(N,w,h){n&&("dataTransfer"in N&&N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(h))),d=N.target,d&&d.classList.add(r),c.value={isDragging:!0,dragIndex:h,dropIndex:h,draggedItem:w},l.value=!0,o==null||o(w,h))}function m(N,w){var h;if(!(!n||!c.value.isDragging)&&(N.preventDefault(),c.value.dropIndex!==w)){const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s);const D=(h=N.target)==null?void 0:h.closest("[data-index]");D==null||D.classList.add(s),c.value.dropIndex=w}}function f(){if(!c.value.isDragging)return;const{dragIndex:N,dropIndex:w,draggedItem:h}=c.value;d&&d.classList.remove(r);const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s),N!==null&&w!==null&&N!==w&&h&&(t==null||t({fromIndex:N,toIndex:w,item:h})),v(),i==null||i()}function p(){d&&d.classList.remove(r);const N=document.querySelector(`.${s}`);N==null||N.classList.remove(s),v(),i==null||i()}function v(){c.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},l.value=!1,d=null}function g(N,w,h){const x=[...N],[D]=x.splice(w,1);return x.splice(h,0,D),x.map((C,y)=>({...C,order:y}))}function E(N,w){return{draggable:n,"data-index":w,onDragstart:h=>u(h,N,w),onDragover:h=>m(h,w),onDragend:()=>f(),onDrop:h=>{h.preventDefault(),f()}}}function T(N){N.key==="Escape"&&c.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",T)}),e.onUnmounted(()=>{document.removeEventListener("keydown",T),p()}),{dragState:c,isDragging:l,startDrag:u,handleDragOver:m,endDrag:f,cancelDrag:p,reorderItems:g,getDragProps:E}}function Wa(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:c,sortable:l=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:f,maxConcurrentUploads:p=3,onChange:v,onUpload:g,onUploadComplete:E,onUploadError:T,onRemove:N,onReorder:w,onError:h,onReadyToSubmitChange:x}=a,D={maxItems:r,maxFileSize:s,acceptedMimeTypes:c,...u},C=f||Vc(m),y=e.ref([]),S=e.ref(!1),A=e.ref([]);function k(oe){if(oe.length===0)return[];const le=oe[0];return"media"in le&&"clientId"in le?oe:Xi(oe)}y.value=k(n);const{acceptString:B,canAddFiles:R}=Er({rules:D}),U=_c({adapter:C,maxConcurrent:p,rules:D,collection:i,onUploadStart:oe=>{g==null||g(oe)},onUploadComplete:(oe,le)=>{const Ee=y.value.findIndex(Se=>Se.clientId===oe.id);Ee!==-1&&(y.value[Ee]={...y.value[Ee],media:le,name:le.name||le.file_name,upload:{...oe,status:"completed"}}),E==null||E(le)},onUploadError:(oe,le)=>{const Ee=y.value.findIndex(Se=>Se.clientId===oe.id);Ee!==-1&&(y.value[Ee]={...y.value[Ee],upload:{...oe,status:"error",error:le.message},errors:[{field:"upload",message:le.message,code:"UPLOAD_ERROR"}]}),T==null||T({file:oe.file,message:le.message})},onQueueComplete:()=>{v==null||v(y.value)}}),{dragState:_,getDragProps:z,reorderItems:H}=Tc({enabled:l&&!d,onReorder:oe=>{y.value=H(y.value,oe.fromIndex,oe.toIndex),w==null||w(y.value),v==null||v(y.value)}}),M=e.computed(()=>U.isUploading.value),$=e.computed(()=>!U.isUploading.value&&U.pendingCount.value===0),X=e.computed(()=>r?y.value.length>=r:!1),j=e.computed(()=>wr(y.value)),te=e.computed(()=>y.value.length),ge=e.computed(()=>r?Math.max(0,r-y.value.length):1/0);e.watch($,oe=>{x==null||x(oe)});function Ne(oe){y.value=k(oe),v==null||v(y.value)}async function ee(oe){if(d)return;const le=Array.from(oe);if(!R(le.length,y.value.length)){const He={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};A.value=[He],h==null||h([He]);return}const Ee=await U.addFiles(le),Se=y.value.length,rt=Ee.map((He,pt)=>({...He,order:Se+pt}));y.value=[...y.value,...rt],v==null||v(y.value)}function F(oe){d||(oe.upload&&(oe.upload.status==="uploading"||oe.upload.status==="pending")&&U.cancelUpload(oe.clientId),y.value=y.value.filter(le=>le.clientId!==oe.clientId),y.value=y.value.map((le,Ee)=>({...le,order:Ee})),N==null||N(oe),v==null||v(y.value))}function P(oe){const le=y.value.find(Ee=>Ee.clientId===oe);le&&F(le)}function fe(){d||(U.clearAll(),y.value=[],v==null||v(y.value))}function ne(oe,le){d||!l||(y.value=H(y.value,oe,le),w==null||w(y.value),v==null||v(y.value))}function Y(oe,le){if(d)return;const Ee=y.value.findIndex(Se=>Se.clientId===oe);Ee!==-1&&(y.value[Ee]={...y.value[Ee],...le},v==null||v(y.value))}function Me(oe){U.cancelUpload(oe),P(oe)}async function ce(oe){await U.retryUpload(oe)}async function se(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const oe={modelType:t,modelId:o,collection:i},le=y.value.filter(Ee=>Ee.media&&!Ee.markedForRemoval).map(Ee=>Ee.media.uuid);S.value=!0;try{await C.attachMany(le,oe),await C.reorder(oe,le)}finally{S.value=!1}}async function ke(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const oe={modelType:t,modelId:o,collection:i};S.value=!0;try{const le=await C.fetchModelMedia(oe);y.value=Xi(le),v==null||v(y.value)}finally{S.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&ke().catch(console.error)}),e.onUnmounted(()=>{U.clearAll()}),{items:y,setItems:Ne,addFiles:ee,removeItem:F,removeItemById:P,clearAll:fe,reorderItems:ne,updateItem:Y,cancelUpload:Me,retryUpload:ce,save:se,load:ke,isLoading:S,isUploading:M,isReadyToSubmit:$,isAtMaxItems:X,errors:A,dragState:_,getDragProps:z,adapter:C,formValues:j,acceptString:B,count:te,remainingSlots:ge}}const U4=["aria-disabled"],A4=["accept","multiple","disabled"],O4={class:"media-dropzone__content"},L4={class:"media-dropzone__title"},z4={class:"media-dropzone__subtitle"},P4=["disabled"],j4={key:0,class:"media-dropzone__helper"},W4=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(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),c=e.computed(()=>{const g=[];return t.maxFileSize&&g.push(`Max size: ${ya(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function l(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function m(g){var T;if(g.preventDefault(),i.value=!1,t.disabled)return;const E=(T=g.dataTransfer)==null?void 0:T.files;E&&E.length>0&&o("files",E)}function f(){var g;t.disabled||(g=r.value)==null||g.click()}function p(g){const E=g.target,T=E.files;T&&T.length>0&&o("files",T),E.value=""}function v(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f())}return(g,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":g.disabled,"aria-label":"Upload files",onClick:f,onKeydown:v,onDragenter:l,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:p},null,40,A4),e.createElementVNode("div",O4,[e.renderSlot(g.$slots,"icon",{},()=>[E[0]||(E[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",L4,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",z4,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(f,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,P4),c.value?(e.openBlock(),e.createElementBlock("p",j4,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])],42,U4))}}),Vr=Be(W4,[["__scopeId","data-v-b1366c1e"]]),Z4=["data-index"],X4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},H4={class:"media-item__thumbnail"},G4=["src","alt"],J4={key:1,class:"media-item__file-icon"},Y4={key:2,class:"media-item__progress-overlay"},K4={class:"media-item__progress-text"},q4={key:3,class:"media-item__processing-overlay"},Q4={key:4,class:"media-item__error-overlay"},e3={class:"media-item__info"},t3=["title"],n3={key:0,class:"media-item__size"},o3={key:1,class:"media-item__error-message"},a3={class:"media-item__actions"},i3=["disabled"],r3=["disabled"],s3=["disabled"],l3=["disabled"],c3=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(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var w,h,x;return((w=t.item.upload)==null?void 0:w.status)==="uploading"||((h=t.item.upload)==null?void 0:h.status)==="pending"||((x=t.item.upload)==null?void 0:x.status)==="queued"}),c=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="processing"}),l=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.progress)||0}),m=e.computed(()=>{var w;return t.item.name||((w=t.item.media)==null?void 0:w.file_name)||"Unknown file"}),f=e.computed(()=>{var C,y;const w=((C=t.item.media)==null?void 0:C.size)||((y=t.item.upload)==null?void 0:y.file.size);if(!w)return"";const h=1024,x=["Bytes","KB","MB","GB"],D=Math.floor(Math.log(w)/Math.log(h));return parseFloat((w/Math.pow(h,D)).toFixed(2))+" "+x[D]}),p=e.computed(()=>{var h,x;const w=((h=t.item.media)==null?void 0:h.mime_type)||((x=t.item.upload)==null?void 0:x.file.type);return w==null?void 0:w.startsWith("image/")}),v=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":c.value,"media-item--error":l.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function g(){t.disabled||o("remove",t.item)}function E(){t.disabled||o("edit",t.item)}function T(){t.disabled||o("retry",t.item)}function N(){t.disabled||o("cancel",t.item)}return(w,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":w.index,onMouseenter:h[0]||(h[0]=x=>i.value=!0),onMouseleave:h[1]||(h[1]=x=>i.value=!1)},[w.sortable&&!w.disabled?(e.openBlock(),e.createElementBlock("div",X4,[...h[2]||(h[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",H4,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,G4)):(e.openBlock(),e.createElementBlock("div",J4,[...h[3]||(h[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",Y4,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",K4,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",q4,[...h[4]||(h[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",Q4,[...h[5]||(h[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",e3,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,t3),f.value?(e.openBlock(),e.createElementBlock("span",n3,e.toDisplayString(f.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",o3,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",a3,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:w.disabled,"aria-label":"Cancel upload",onClick:N},[...h[6]||(h[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,i3)):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:w.disabled,"aria-label":"Retry upload",onClick:T},[...h[7]||(h[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,r3)):e.createCommentVNode("",!0),w.showEdit&&w.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:w.disabled,"aria-label":"Edit",onClick:E},[...h[8]||(h[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,s3)):e.createCommentVNode("",!0),w.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:w.disabled,"aria-label":"Remove",onClick:g},[...h[9]||(h[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,l3)):e.createCommentVNode("",!0)])],42,Z4))}}),Sr=Be(c3,[["__scopeId","data-v-ff81c9ec"]]),d3=["aria-label"],u3=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],m3={key:0,class:"media-collection__footer"},p3={class:"media-collection__count"},f3={key:0},h3={key:0,class:"media-collection__uploading"},v3=["name","value"],g3=["name","value"],y3=["name","value"],w3=["name","value"],b3={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},k3=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(a,{emit:n}){const t=a,o=n,i={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:M=>{o("update:modelValue",M),o("change",M)},onUpload:M=>{o("upload",M)},onUploadComplete:M=>{o("upload-complete",M)},onUploadError:M=>{o("upload-error",M)},onRemove:M=>{o("remove",M)},onReorder:M=>{o("reorder",M)},onError:M=>{o("validation-error",M)},onReadyToSubmitChange:M=>{o("is-ready-to-submit-change",M)}},{items:r,setItems:s,addFiles:c,removeItem:l,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:f,isUploading:p,isAtMaxItems:v,errors:g,dragState:E,getDragProps:T,adapter:N,formValues:w,acceptString:h,count:x,remainingSlots:D}=Wa(i);e.provide("mediaAdapter",N),e.provide("mediaCollection",{items:r,addFiles:c,removeItem:l,reorderItems:d}),e.watch(()=>t.modelValue,M=>{M!==r.value&&s(M)},{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":f.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":E.value.isDragging}));function S(M){c(M)}function A(M){l(M)}function k(M){m(M.clientId)}function B(M){u(M.clientId)}function R(M){}function U(M,$,X){if(!t.sortable||t.disabled)return;const j=T($,X);j.onDragstart&&j.onDragstart(M)}function _(M,$){if(!t.sortable||t.disabled)return;M.preventDefault();const X=r.value[$],j=T(X,$);j.onDragover&&j.onDragover(M)}function z(M,$){const X=T(M,$);X.onDragend&&X.onDragend()}function H(M,$){M.preventDefault();const X=r.value[$],j=T(X,$);j.onDrop&&j.onDrop(M)}return(M,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(y.value)},[e.renderSlot(M.$slots,"dropzone",{addFiles:e.unref(c)},()=>[C.value?(e.openBlock(),e.createBlock(Vr,{key:0,accept:e.unref(h),multiple:M.maxItems!==1,disabled:M.disabled,"max-file-size":M.maxFileSize,"max-items":e.unref(D),onFiles:S},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(x)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(X,j)=>e.renderSlot(M.$slots,"item",{key:X.clientId,item:X,index:j,remove:()=>A(X)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(E).dropIndex===j}]),draggable:M.sortable&&!M.disabled,"data-index":j,onDragstart:te=>U(te,X,j),onDragover:te=>_(te,j),onDragend:te=>z(X,j),onDrop:te=>H(te,j)},[e.createVNode(Sr,{item:X,adapter:e.unref(N),disabled:M.disabled,sortable:M.sortable,"show-remove":!M.readonly,"show-edit":!1,index:j,onRemove:A,onRetry:k,onCancel:B,onEdit:R},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,u3)],!0)),128))],8,d3)):C.value?e.createCommentVNode("",!0):e.renderSlot(M.$slots,"empty",{key:1},()=>[$[0]||($[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(M.$slots,"footer",{count:e.unref(x),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",m3,[e.createElementVNode("span",p3,[e.createTextVNode(e.toDisplayString(e.unref(x))+" "+e.toDisplayString(e.unref(x)===1?"file":"files")+" ",1),M.maxItems?(e.openBlock(),e.createElementBlock("span",f3," / "+e.toDisplayString(M.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",h3," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),M.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}`,type:"hidden",name:`${M.name}[${j}][uuid]`,value:X.uuid},null,8,v3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}-name`,type:"hidden",name:`${M.name}[${j}][name]`,value:X.name},null,8,g3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}-order`,type:"hidden",name:`${M.name}[${j}][order]`,value:X.order},null,8,y3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,j)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${M.name}-${X.uuid}-props`},[X.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${M.name}[${j}][custom_properties]`,value:JSON.stringify(X.custom_properties)},null,8,w3)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",b3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),X=>(e.openBlock(),e.createElementBlock("p",{key:X.code||X.message,class:"media-collection__error"},e.toDisplayString(X.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),x3=Be(k3,[["__scopeId","data-v-10a5bfff"]]);function Cr(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:c,onError:l,onReadyToSubmitChange:d,...u}=a,f={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:C=>{t==null||t(C[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:c,onError:l,onReadyToSubmitChange:d},p=Wa(f),v=e.computed(()=>p.items.value[0]||null),g=e.computed(()=>v.value!==null),E=e.computed(()=>p.formValues.value[0]||null);function T(C){C===null?p.clearAll():p.setItems([C])}async function N(C){const y=v.value;y&&p.removeItem(y),await p.addFiles([C])}function w(){v.value&&p.removeItem(v.value)}async function h(C){const y=v.value;y&&p.removeItem(y),await p.addFiles([C]);const S=p.items.value[0];S&&(o==null||o(y,S))}function x(){var C;(C=v.value)!=null&&C.upload&&p.cancelUpload(v.value.clientId)}async function D(){var C,y;((y=(C=v.value)==null?void 0:C.upload)==null?void 0:y.status)==="error"&&await p.retryUpload(v.value.clientId)}return{item:v,setItem:T,addFile:N,removeItem:w,replaceItem:h,cancelUpload:x,retryUpload:D,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:g,errors:p.errors,adapter:p.adapter,formValue:E,acceptString:p.acceptString}}const E3=["accept","disabled"],V3={class:"media-attachment__preview"},S3=["name","value"],C3=["name","value"],N3=["name","value"],_3=["name","value"],T3={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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r={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=>{o("update:modelValue",k),o("change",k)},onUpload:k=>{o("upload",k)},onUploadComplete:k=>{o("upload-complete",k)},onUploadError:k=>{o("upload-error",k)},onRemove:k=>{o("remove",k)},onReplace:(k,B)=>{o("replace",B)},onError:k=>{o("validation-error",k)},onReadyToSubmitChange:k=>{o("is-ready-to-submit-change",k)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,hasItem:v,errors:g,adapter:E,formValue:T,acceptString:N}=Cr(r);e.provide("mediaAdapter",E),e.watch(()=>t.modelValue,k=>{k!==s.value&&c(k)},{deep:!0});const w=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),h=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":v.value}));function x(k){k.length>0&&l(k[0])}function D(){var k;(k=i.value)==null||k.click()}function C(k){const B=k.target,R=B.files;R&&R.length>0&&u(R[0]),B.value=""}function y(k){d()}function S(k){f()}function A(k){m()}return(k,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(N),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:C},null,40,E3),w.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(l)},()=>[e.createVNode(Vr,{accept:e.unref(N),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:x},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:D},()=>[e.createElementVNode("div",V3,[e.createVNode(Sr,{item:e.unref(s),adapter:e.unref(E),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:y,onRetry:S,onCancel:A},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:D},[...B[0]||(B[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},()=>[B[1]||(B[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),k.generateFormFields&&e.unref(T)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(T).uuid},null,8,S3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(T).name},null,8,C3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(T).order},null,8,N3),e.unref(T).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(T).custom_properties)},null,8,_3)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",T3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),R=>(e.openBlock(),e.createElementBlock("p",{key:R.code||R.message,class:"media-attachment__error"},e.toDisplayString(R.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),B3=Be(M3,[["__scopeId","data-v-26911174"]]),Mc={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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:k=>{i("update:modelValue",k),i("change",k)},onUpload:k=>{i("upload",k)},onUploadComplete:k=>{i("upload-complete",k)},onUploadError:k=>{i("upload-error",k)},onRemove:k=>{i("remove",k)},onReorder:k=>{i("reorder",k)},onError:k=>{i("validation-error",k)},onReadyToSubmitChange:k=>{i("is-ready-to-submit-change",k)}},{items:s,setItems:c,addFiles:l,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:E,isAtMaxItems:T,errors:N,dragState:w,getDragProps:h,adapter:x,formValues:D,acceptString:C}=Wa(r);e.provide("mediaAdapter",x),e.provide("mediaCollection",{items:s,addFiles:l,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,k=>{k!==s.value&&c(k)},{deep:!0});const y=e.computed(()=>({...Mc,...o.labels})),S=e.computed(()=>({accept:C.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||T.value})),A=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:g.value,isReadyToSubmit:E.value,isAtMaxItems:T.value,errors:N.value,addFiles:l,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:f,retryUpload:p,labels:y.value,dropzoneProps:S.value}));return n({items:s,addFiles:l,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:E,isAtMaxItems:T,errors:N,dragState:w,getDragProps:h,adapter:x,formValues:D,acceptString:C}),(k,B)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(A.value)))}}),I3=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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItem:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:y=>{i("update:modelValue",y),i("change",y)},onUpload:y=>{i("upload",y)},onUploadComplete:y=>{i("upload-complete",y)},onUploadError:y=>{i("upload-error",y)},onRemove:y=>{i("remove",y)},onReplace:(y,S)=>{i("replace",S)},onError:y=>{i("validation-error",y)},onReadyToSubmitChange:y=>{i("is-ready-to-submit-change",y)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:E,errors:T,adapter:N,formValue:w,acceptString:h}=Cr(r);e.provide("mediaAdapter",N),e.watch(()=>o.modelValue,y=>{y!==s.value&&c(y)},{deep:!0});const x=e.computed(()=>({...Mc,...o.labels})),D=e.computed(()=>({accept:h.value,multiple:!1,disabled:o.disabled||o.readonly||E.value})),C=e.computed(()=>({item:s.value,hasItem:E.value,isLoading:p.value,isUploading:v.value,isReadyToSubmit:g.value,errors:T.value,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,labels:x.value,dropzoneProps:D.value}));return n({item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:E,errors:T,adapter:N,formValue:w,acceptString:h}),(y,S)=>e.renderSlot(y.$slots,"default",e.normalizeProps(e.guardReactiveProps(C.value)))}}),R3=["name","value"],$3=["name","value"],D3=["name","value"],U3=["name","value"],A3=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(a){const n=a,t=e.computed(()=>n.item?[n.item]:n.items),o=e.computed(()=>wr(t.value));function i(c,l){var u;const d=((u=o.value[c])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${l}]`}function r(c,l){return`${n.name}[${c}][${l}]`}function s(c,l){return n.format==="spatie"?i(c,l):r(c,l)}return(c,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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,R3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,$3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,D3),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,U3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=Ec;exports.AlbumManager=h4;exports.AlbumMediaGrid=N4;exports.AlbumTree=xc;exports.ArrayBufferTarget=er;exports.ImageEditor=nl;exports.ImageEditorModal=ol;exports.LiveStreamManager=PE;exports.ManagedMediaGallery=au;exports.MediaAttachment=B3;exports.MediaCollection=x3;exports.MediaCollectionDropzone=Vr;exports.MediaCollectionItem=Sr;exports.MediaWorkspace=eu;exports.ModelMediaManager=Qm;exports.Muxer=_l;exports.VideoEditor=Zi;exports.VideoEditorDialog=Sb;exports.VideoEditorSimple=Jb;exports.VideoExportPanel=_k;exports.VideoJobClient=gr;exports.VideoPlayer=wc;exports.VideoTimeline=w2;exports.VideoToolsPanel=lk;exports.VideoUploader=hx;exports._sfc_main=F3;exports._sfc_main$1=I3;exports._sfc_main$2=A3;exports.applyTemporaryMediaStoreConfig=el;exports.configureMediaStore=Rn;exports.createAdapter=Vc;exports.createEmptyEditorState=Ld;exports.createImageEditor=T4;exports.createMediablesAdapter=br;exports.createSpatieAdapter=kr;exports.deserializeEditorState=Od;exports.formatFileSize=ya;exports.fromMediaArray=Xi;exports.getFileExtension=Sc;exports.getImageDimensions=Cc;exports.getMediablesAdapter=M4;exports.getSpatieAdapter=I4;exports.isImageFile=xr;exports.normalizeEditorState=Hi;exports.normalizeRecipeForServerRender=rb;exports.recipeHasServerRenderableEdits=ib;exports.recipeHasUnsupportedServerEdits=yc;exports.resetMediablesAdapter=B4;exports.resetSpatieAdapter=R4;exports.restoreMediaStoreConfig=Qs;exports.serializeEditorState=Ks;exports.snapshotMediaStoreConfig=qs;exports.toFormValues=wr;exports.useAdminMediaStore=tl;exports.useAlbumDragDrop=kc;exports.useAlbumStore=ja;exports.useAlbums=bc;exports.useGlobalImageEditor=_4;exports.useImageEditorModal=yr;exports.useMediaAttachment=Cr;exports.useMediaCollection=Wa;exports.useMediaDragSort=Tc;exports.useMediaStore=xt;exports.useMediaUploadQueue=_c;exports.useMediaValidation=Er;exports.validateFile=Nc;
342
- //# sourceMappingURL=index-rcMbx-I6.cjs.map
336
+ `,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class wg{constructor({filters:n=[],callbacks:t={}}){yg(),this._filters=n,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(n){return this._root=Ue("div",{className:"mvfp"}),this._catRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Ue("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=Ue("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=Ue("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Ue("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Ue("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Ue("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(l=>l.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Ue("div",{className:`mvfp-achip${i?" selected":""}`}),s=Ue("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),c=Ue("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:l=>{l.stopPropagation(),this._removeFilter(t)}});c.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(s),r.appendChild(c),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=Ue("div",{className:"mvfp-drawer"});const n=Ue("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Ue("span",{className:"mvfp-drawer-title"},"Filter");const t=Ue("div",{className:"mvfp-drawer-actions"});t.appendChild(Ue("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Ue("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=Ue("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Ue("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(Ue("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=Ue("div",{className:"mvfp-ctl"}),c=Ue("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(c);const l=i.type||"slider";if(l==="slider"||l==="range"){const d=Ue("div",{className:"mvfp-slider-row"}),u=Ue("span",{className:"mvfp-range-val"},Is(r)),m=Ue("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:f=>{var v,g;const p=parseFloat(f.target.value);u.textContent=Is(p),(g=(v=this._cb).onUpdateParam)==null||g.call(v,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(l==="toggle"||l==="checkbox"){const d=Ue("div",{className:"mvfp-toggle-row"}),u=Ue("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(l==="color"){const d=Ue("div",{className:"mvfp-color-row"}),u=Ue("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(l==="select"||l==="dropdown"){const d=Ue("div",{className:"mvfp-select-row"}),u=Ue("select",{className:"mvfp-select",onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const f=Ue("option",{value:m.value},m.label||String(m.value));m.value===r&&(f.selected=!0),u.appendChild(f)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function $s(a){var s,c;bg(a);const n=kg(a.clips),t=[],o=xg(a),i=Eg(a),r={version:"1.0",source:{media_uuid:a.mediaUuid,duration:a.originalDuration,original_width:((s=a.media)==null?void 0:s.width)||1920,original_height:((c=a.media)==null?void 0:c.height)||1080},timeline:n,filters:t,audio:o,output:i,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return a.textOverlays&&(r.textOverlays=a.textOverlays),a.audioTracks&&(r.audioTracks=a.audioTracks.filter(l=>typeof l.source=="string")),r}function bg(a){if(!a.mediaUuid)throw new Error("Media UUID is required");if(!a.clips||a.clips.length===0)throw new Error("At least one clip is required");const n=[...a.clips].sort((t,o)=>t.timelineStart-o.timelineStart);for(let t=1;t<n.length;t++)if(n[t].timelineStart<n[t-1].timelineEnd)throw new Error(`Clips ${n[t-1].id} and ${n[t].id} overlap on timeline`)}function kg(a){return a.map(n=>{const t=n.speed||1,o=typeof n.sourceIn=="number"&&!Number.isNaN(n.sourceIn),i=typeof n.sourceOut=="number"&&!Number.isNaN(n.sourceOut),r=Math.max(0,n.timelineEnd-n.timelineStart),s=n.sourceOffset??n.trimStart??0;let c=Number(o?n.sourceIn:s),l=i?Number(n.sourceOut):Number(s)+r/t;return l>c||(l=c+Math.max(.033,r/Math.max(1e-6,t))),{id:n.id,type:"clip",timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:c,sourceOut:l,speed:t,filters:n.filters?[...n.filters]:[]}})}function xg(a){const n={volume:a.audioVolume,muted:a.audioVolume===0};return a.audioFadeIn>0&&(n.fadeIn=a.audioFadeIn),a.audioFadeOut>0&&(n.fadeOut=a.audioFadeOut),n}function Eg(a){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[a.exportQuality]||n["1080p"],o=(r=a.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:a.exportFormat||"mp4",codec:"h264",quality:a.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function Vg(a,n,t){var ue,ve;const o=typeof a=="string"&&a.trim()!==""?a.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:o,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),c=e.ref([]),l=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),m=e.shallowRef(null),f=new Gl(30),p=e.ref(30),v=e.ref(!1),g=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(C(n),(ue=n.output)!=null&&ue.fps&&(p.value=n.output.fps,f.setFps(p.value))):(h(),n&&((ve=n.output)!=null&&ve.fps&&(p.value=n.output.fps,f.setFps(p.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const E=e.ref(1),T=e.computed(()=>i.selectedClipId?i.clips.find(Z=>Z.id===i.selectedClipId)??null:null);e.watch(T,Z=>{E.value=(Z==null?void 0:Z.speed)??1},{immediate:!0});const N=e.computed(()=>s.value.length>0),w=e.computed(()=>c.value.length>0);function h(){const Z=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=Z,i.totalDuration=Z;const Q=pe(),ae={id:Q,type:"clip",timelineStart:0,timelineEnd:Z,sourceIn:0,sourceOut:Z,sourceMinIn:0,sourceMaxOut:Z,speed:1};i.clips=[ae],i.selectedClipId=Q,l.value=Q,!(t||o.startsWith("temp-"))&&(async()=>{try{const xe=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!xe.ok)throw new Error(`Failed to fetch media: ${xe.status}`);const De=await xe.json(),Qe=typeof De=="object"&&De!==null&&"data"in De?De.data:De;if(!Qe||typeof Qe!="object")throw new Error("Failed to parse media payload");const We=Qe;i.media=We;const ft=typeof We.duration=="number"&&We.duration>0?We.duration:Z;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==Q)return;i.originalDuration=ft,i.totalDuration=ft;const Ze=i.clips[0];Ze.timelineStart=0,Ze.timelineEnd=ft,Ze.sourceIn=0,Ze.sourceOut=ft,Ze.sourceMinIn=0,Ze.sourceMaxOut=ft,H(),d=!0}catch{}})()}function x(Z,Q){if(Z.originalDuration!==1)return;Z.originalDuration=Q,Z.totalDuration===1&&(Z.totalDuration=Q);const ae=Z.clips[0],xe=!n&&Z.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1;for(const De of Z.clips)(De.sourceMaxOut===1||De.sourceMaxOut===void 0)&&(De.sourceMaxOut=Q);xe&&ae!==void 0&&(ae.sourceOut=Q,ae.timelineEnd=Q)}function D(Z){if(!Number.isFinite(Z)||Z<=0||d)return;const Q=i.hasChanges;i.originalDuration=Z,i.totalDuration=Math.max(i.totalDuration,Z),i.media&&(i.media.duration=Z);for(const De of i.clips)De.sourceMaxOut=Z;const ae=i.clips[0];!n&&i.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1&&ae!==void 0&&(ae.sourceOut=Z,ae.timelineEnd=ae.timelineStart+(ae.sourceOut-ae.sourceIn)),H();for(const De of s.value)x(De,Z);for(const De of c.value)x(De,Z);d=!0,e.nextTick(()=>{Q||(i.hasChanges=!1)})}function C(Z){i.clips=Z.timeline.map(Q=>({...Q,sourceMinIn:Q.sourceMinIn??0,sourceMaxOut:Q.sourceMaxOut??Z.source.duration})),i.filters=[],i.audioVolume=Z.audio.volume,i.audioFadeIn=Z.audio.fadeIn||0,i.audioFadeOut=Z.audio.fadeOut||0,i.exportFormat=Z.output.format,i.exportQuality=Z.output.quality,i.originalDuration=Z.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,l.value=i.selectedClipId):(delete i.selectedClipId,l.value=void 0),H()}function y(){s.value.push(JSON.parse(JSON.stringify(i))),c.value=[],i.hasChanges=!0}function S(){if(!N.value)return;const Z=s.value.pop();c.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,Z)}function A(){if(!w.value)return;const Z=c.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,Z)}function k(Z,Q,ae){y();const xe=i.clips.find(Ze=>Ze.id===Z);if(!xe)return;const Qe=1/30,We=xe.sourceMinIn??0,ft=xe.sourceMaxOut??i.originalDuration;if(Q==="start"){const Ze=xe.sourceIn,Ht=Math.max(We,Math.min(ae,xe.sourceOut-Qe));xe.sourceIn=Ht;const Xa=Ht-Ze;xe.timelineStart+=Xa}else{const Ze=Math.max(xe.sourceIn+Qe,Math.min(ae,ft));xe.sourceOut=Ze;const Ht=xe.sourceOut-xe.sourceIn;xe.timelineEnd=xe.timelineStart+Ht}H(),m.value&&m.value.trimClip(Z,xe.sourceIn,xe.sourceOut)}function B(Z){y();const Q=i.clips.find(We=>Z>We.timelineStart&&Z<We.timelineEnd);if(!Q)return;const ae=Z-Q.timelineStart,xe=Q.sourceIn+ae,De={id:pe(),type:"clip",timelineStart:Z,timelineEnd:Q.timelineEnd,sourceIn:xe,sourceOut:Q.sourceOut,speed:Q.speed??1,sourceMinIn:Q.sourceMinIn??0,sourceMaxOut:Q.sourceMaxOut??i.originalDuration,filters:[...Q.filters||[]]};Q.timelineEnd=Z,Q.sourceOut=xe;const Qe=i.clips.indexOf(Q);i.clips.splice(Qe+1,0,De),i.selectedClipId=De.id}function R(){B(i.playheadPosition)}function U(Z){var ae;const Q=Z??i.selectedClipId??l.value??((ae=i.clips[0])==null?void 0:ae.id);Q&&(i.selectedClipId=Q,l.value=Q)}function _(){if(!i.selectedClipId||i.clips.length<=1)return;y();const Z=i.clips.findIndex(Q=>Q.id===i.selectedClipId);if(Z!==-1){i.clips.splice(Z,1);const Q=Math.min(Z,i.clips.length-1);i.selectedClipId=i.clips[Q].id,l.value=i.selectedClipId,H()}}function z(Z,Q){y();const ae=i.clips.find(De=>De.id===Z);if(!ae)return;const xe=Q-ae.timelineStart;ae.timelineStart=Q,ae.timelineEnd+=xe,H(),m.value&&m.value.moveClip(Z,Q)}function H(){if(i.clips.length===0){i.totalDuration=0;return}const Z=i.clips.reduce((Q,ae)=>ae.timelineEnd>Q.timelineEnd?ae:Q);i.totalDuration=Z.timelineEnd}function M(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function $(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function X(Z){i.zoomLevel=Math.max(10,Math.min(600,Math.round(Z)))}function W(){i.isPlaying=!i.isPlaying}function te(Z){i.isPlaying=Z}function ge(Z){i.playheadPosition=Math.max(0,Math.min(Z,i.totalDuration))}function Ne(){const Z=$s(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(Z))}catch{}return Z}function ee(){i.hasChanges=!1}function F(){return confirm("Are you sure you want to reset all changes?")?(y(),h(),i.hasChanges=!1,!0):!1}function P(){return $s(i)}function pe(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ne(Z=1920,Q=1080){if(u.value)try{m.value=new Hl(Z,Q,p.value),await Y()}catch{m.value=null}}async function Y(){if(!(!m.value||g.value)){g.value=!0;try{const Z=P();await m.value.loadFromRecipe(Z);const Q=f.secondsToFrames(i.playheadPosition);m.value.seek(Q)}catch{}finally{g.value=!1}}}function Me(Z){}function ce(Z){return f.secondsToFrames(Z)}function se(Z){return f.framesToSeconds(Z)}function ke(Z){const Q=se(Z);ge(Q),m.value&&m.value.seek(Z)}function oe(){v.value=!v.value}function le(){Y()}function Ee(Z){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.clips.map(Z=>Z.id),()=>{var Q;if(!i.clips.length){delete i.selectedClipId,l.value=void 0;return}if(!i.clips.some(ae=>ae.id===i.selectedClipId)){const ae=l.value&&((Q=i.clips.find(xe=>xe.id===l.value))==null?void 0:Q.id);i.selectedClipId=ae??i.clips[0].id,l.value=i.selectedClipId}},{deep:!0});function Se(Z){const Q=i.selectedClipId?i.clips.find(ae=>ae.id===i.selectedClipId):i.clips[0];Q&&(Q.filters=[...Z],i.hasChanges=!0)}function rt(Z){i.textOverlays=[...Z]}function He(Z){i.audioTracks=[...Z]}e.watch(u,Z=>{Z?ne():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(p,Z=>{f.setFps(Z)});function pt(){if(!i.selectedClipId)return;y();const Z=i.clips.find(xe=>xe.id===i.selectedClipId);if(!Z)return;const Q={...Z,id:pe(),timelineStart:Z.timelineEnd,timelineEnd:Z.timelineEnd+(Z.timelineEnd-Z.timelineStart),filters:[...Z.filters||[]]},ae=i.clips.indexOf(Z);i.clips.splice(ae+1,0,Q),i.selectedClipId=Q.id,i.hasChanges=!0}function K(Z){const Q=Z??800,ae=i.totalDuration;if(ae<=0){i.zoomLevel=50;return}const xe=Q*.8/ae;i.zoomLevel=Math.max(10,Math.min(600,Math.round(xe)))}function de(){const Z=1/p.value;ge(Math.min(i.playheadPosition+Z,i.totalDuration))}function ie(){const Z=1/p.value;ge(Math.max(i.playheadPosition-Z,0))}function he(){ge(0)}function _e(){ge(i.totalDuration)}function J(Z){if(!Number.isFinite(Z)||Z<=0)return;const Q=T.value??i.clips[0];if(!Q){E.value=Z;return}const ae=Q.speed??1;if(ae===Z){E.value=Z;return}y();const xe=Math.max(1/p.value,Q.sourceOut-Q.sourceIn),De=xe/ae,Qe=xe/Z,We=Qe-De;Q.speed=Z,Q.timelineEnd=Q.timelineStart+Qe;const ft=i.clips.findIndex(Ze=>Ze.id===Q.id);if(ft!==-1&&We!==0)for(let Ze=ft+1;Ze<i.clips.length;Ze+=1){const Ht=i.clips[Ze];Ht.timelineStart+=We,Ht.timelineEnd+=We}H(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,E.value=Z}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:T,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:E,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:p,useFrameMode:v,handleTrim:k,handleSplit:B,handleClipSelect:U,splitAtPlayhead:R,deleteSelectedClip:_,duplicateSelectedClip:pt,setFilters:Se,setTextOverlays:rt,setAudioTracks:He,moveClip:z,saveDraft:Ne,clearHasChanges:ee,resetChanges:F,generateRecipe:P,zoomIn:M,zoomOut:$,setZoomLevel:X,fitToWindow:K,togglePlayback:W,setPlaying:te,seekTo:ge,frameForward:de,frameBackward:ie,skipToStart:he,skipToEnd:_e,setPlaybackSpeed:J,updateSourceDuration:D,undo:S,redo:A,canUndo:N,canRedo:w,initializeComposition:ne,syncCompositionWithState:Y,syncWithComposition:Me,convertToFrames:ce,convertToSeconds:se,seekToFrame:ke,toggleFrameMode:oe,onCompositionReady:le,onCompositionError:Ee}}const Sg=[{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}}}],Cg={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function $a(a){return typeof a=="object"&&a!==null}function Ng(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Da(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function _g(a){const n={id:a.id,type:a.type,label:a.label};a.property!==void 0&&(n.property=a.property),a.min!==void 0&&(n.min=a.min),a.max!==void 0&&(n.max=a.max),a.step!==void 0&&(n.step=a.step);const t=Da(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function Jl(a,n,t){const o=ct.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&$a(r))for(const[s,c]of Object.entries(r))i[s]=Da(c)??null;for(const s of n){const c=s.property??s.id;i[c]===void 0&&s.default!==void 0&&(i[c]=s.default)}return i}function Yl(a){const n={};for(const t of a){if(t.type!=="slider")continue;const o=t.property??t.id;n[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function Tg(a,n,t,o){const i=o.map(_g);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:Jl(a,i),paramRanges:Yl(i)}}function Mg(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var c;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,l=>l.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=Da((c=a.defaultParams)==null?void 0:c[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:Jl(a.id,t,a.defaultParams),paramRanges:Yl(t)}}function Bg(a,n){return n.toLowerCase()==="unlisted"?!1:ct.isFilterCompatibleWithMedia(a,"video")}function wi(a){return Cg[a]??a}function so(a){const n=Ng(a,1);return Math.max(0,Math.min(1,n))}function lo(a){if(!$a(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=Da(o)??null;return n}function Fg(a){return!$a(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:lo(a.params),intensity:so(a.intensity)}}function Ig(a){if(!$a(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>Fg(i)).filter(i=>i!==null),o=typeof a.created_at=="string"?a.created_at:new Date().toISOString();return{id:a.id,name:a.name,filters:t,created_at:o}}function Rg(){ct.initializeFilterRegistry();const a=e.ref([]),n=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const R=new Map,U=ct.getRegisteredFilters();for(const _ of U)Bg(_.id,_.category)&&R.set(_.id,Tg(_.id,_.name,_.category,_.controls));for(const _ of Sg)R.has(_.id)||R.set(_.id,Mg(_));return Array.from(R.values())}),c=e.computed(()=>{const R=new Map;for(const U of s.value)R.set(U.id,U);return R}),l=e.computed(()=>a.value.length>0),d=e.computed(()=>{const R={};for(const U of s.value)R[U.category]||(R[U.category]=[]),R[U.category].push(U);return R});function u(R){const U=c.value.get(R);if(U)return U;const _=wi(R);return c.value.get(_)??null}function m(R){const U=c.value.get(R);if(U)return U.id;const _=wi(R),z=c.value.get(_);return z?z.id:null}function f(R){const U=R?u(R):n.value;if(!U)return;const _=U.defaultParams||{},z={id:S(),filterId:U.id,params:{..._},intensity:1};return a.value.push(z),i.value=z.id,n.value=U,Object.keys(r).forEach(H=>delete r[H]),Object.assign(r,z.params),t.value=null,z}function p(R){const U=u(R);if(!U)return;n.value=U;const _=U.defaultParams||k(R);Object.assign(r,_),t.value={id:"preview",filterId:U.id,params:{..._},intensity:1}}function v(R){if(Object.assign(r,R),t.value&&(t.value.params={...r}),i.value){const U=a.value.find(_=>_.id===i.value);U&&(U.params={...r})}}function g(R){const U=a.value.findIndex(_=>_.id===R);U!==-1&&a.value.splice(U,1)}function E(R,U){if(R<0||R>=a.value.length||U<0||U>=a.value.length)return;const[_]=a.value.splice(R,1);a.value.splice(U,0,_)}function T(R,U){const _=a.value.find(z=>z.id===R);_&&(_.intensity=Math.max(0,Math.min(1,U)))}function N(R){const U=a.value.find(_=>_.id===R);U&&(U.intensity=U.intensity>0?0:1)}function w(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(R=>delete r[R])}function h(R){const U={id:A(),name:R,filters:a.value.map(z=>({filterId:z.filterId,params:lo(z.params),intensity:so(z.intensity)})),created_at:new Date().toISOString()};o.value.push(U);const _=o.value.map(z=>({...z}));return localStorage.setItem("video-filter-presets",JSON.stringify(_)),U}function x(R){const U=o.value.find(_=>_.id===R);if(U){w();for(const _ of U.filters){const z=u(_.filterId);z&&a.value.push({id:S(),filterId:z.id,params:{..._.params},intensity:so(_.intensity)})}}}function D(R){const U=o.value.findIndex(_=>_.id===R);U!==-1&&(o.value.splice(U,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function C(){try{const R=localStorage.getItem("video-filter-presets");if(!R)return;const U=JSON.parse(R);if(!Array.isArray(U))return;o.value=U.map(_=>Ig(_)).filter(_=>_!==null)}catch{}}function y(){if(a.value.length===0)return"No filters applied";const R=a.value.map(U=>{const _=B(U.filterId);return(_==null?void 0:_.name)||U.filterId});return R.length===1?R[0]:R.length===2?`${R[0]} + ${R[1]}`:`${R[0]} + ${R.length-1} more`}function S(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function A(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(R){const U=u(R);return U?U.defaultParams||{}:{}}function B(R){return u(R)}return C(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:l,filtersByCategory:d,applyFilter:f,previewFilterEffect:p,updateFilterParams:v,removeFilter:g,reorderFilters:E,updateFilterIntensity:T,toggleFilter:N,clearAllFilters:w,saveFilterPreset:h,loadFilterPreset:x,deleteFilterPreset:D,getFilterSummary:y,setActiveFilters(R){var _;const U=[];for(const z of R){const H=m(z.filterId);if(!H){const M=wi(z.filterId);U.push({...z,filterId:M,params:lo(z.params),intensity:so(z.intensity)});continue}U.push({...z,filterId:H,params:lo(z.params),intensity:so(z.intensity)})}a.value=U,i.value=((_=a.value[0])==null?void 0:_.id)??null,Object.keys(r).forEach(z=>delete r[z]),a.value[0]&&Object.assign(r,lo(a.value[0].params))}}}class $g{constructor(n){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new ut({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new ut({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new ut({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,o,i="400"){const r=new ut({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new ut({source:`local('${t}')`,family:t,weight:o});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,o={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},i=n.fontFamily||"default",r=this.fonts.get(i)||this.fonts.get("default");if(o.font=r,n.position)if(typeof n.position=="string")switch(n.position){case"center":o.position="center";break;case"top":o.x="50%",o.y="10%";break;case"bottom":o.x="50%",o.y="90%";break;case"left":o.x="10%",o.y="50%";break;case"right":o.x="90%",o.y="50%";break}else o.x=n.position.x,o.y=n.position.y;else o.position="center";if(n.startTime!==void 0&&(o.start=we.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;o.stop=we.fromSeconds(c+n.duration)}n.animation&&this.applyAnimation(o,n.animation,n);const s=new Pn(o);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(n,t,o){if(!t)return;const i=o.startTime?Math.round(o.startTime*30):0,r=t.duration||1,s=Math.round(r*30),c=i+s,l=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Ve([i,c],[0,1],{easing:l});break;case"fade-out":n.alpha=new Ve([i,c],[1,0],{easing:l});break;case"rotate":t.rotation&&(n.rotation=new Ve([i,c],[t.rotation.from,t.rotation.to],{easing:l}));break;case"scale":t.scale&&(n.scale=new Ve([i,c],[t.scale.from,t.scale.to],{easing:l}));break;case"slide":t.translate&&(n.translate={x:new Ve([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ve([i,c],[t.translate.fromY,t.translate.toY],{easing:l})});break;case"typewriter":n.alpha=new Ve([i,c],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ve([i,c],[t.rotation.from,t.rotation.to],{easing:l})),t.scale&&(n.scale=new Ve([i,c],[t.scale.from,t.scale.to],{easing:l})),t.translate&&(n.translate={x:new Ve([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ve([i,c],[t.translate.fromY,t.translate.toY],{easing:l})});break}}async updateTextOverlay(n,t){if(!this.textClips.get(n))throw new Error(`Text overlay with id ${n} not found`);await this.removeTextOverlay(n);const i={...t};await this.addTextOverlay(i)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const o=this.composition.tracks;for(const i of o){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const n=Array.from(this.textClips.keys());for(const t of n)await this.removeTextOverlay(t)}getOverlays(){const n=[];return this.textClips.forEach((t,o)=>{const i={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};n.push({id:o,config:i})}),n}async addCaptions(n,t="classic",o){var l,d;const r={classic:So,cascade:Ma,guinea:Ta,solar:Ba,spotlight:Co,whisper:No}[t],s=await this.composition.createTrack("caption"),c=new Ea({transcript:n});if(await s.add(c),await((l=s.generate)==null?void 0:l.call(s,r)),o&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,o)}}}class Dg{constructor(n){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=n}async loadAudioSource(n,t){try{const o=await ln.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,o),o}catch(o){throw o instanceof Error?o:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`;let o;try{if(typeof n.source=="object"&&n.source instanceof ln)o=n.source;else if(typeof n.source=="string")o=await ln.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)o=await ln.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(l){throw l instanceof Error?l:new Error("Failed to create audio source")}const i={source:o,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=we.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;i.stop=we.fromSeconds(l+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new ha(i);let s=this.composition.tracks.find(l=>l.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(r);const c={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,c),t}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,o=n.startTime?Math.round(n.startTime*30):0,i=n.duration,r=[],s=[];if(n.fadeIn){const c=Math.round(n.fadeIn*30);r.push(o,o+c),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const c=o+Math.round(i*30),l=Math.round(n.fadeOut*30);n.fadeIn||(r.push(c-l),s.push(t)),r.push(c),s.push(0)}return new Ve(r,s,{easing:"linear"})}async updateVolume(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));o.clip.volume=i*this.masterVolume,o.config.volume=i}async applyFadeIn(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeIn=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async applyFadeOut(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeOut=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);const o=t.track.clips.indexOf(t.clip);o!==-1&&t.track.clips.splice(o,1),this.audioLayers.delete(n)}async muteTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);t?o.clip.volume=0:o.clip.volume=(o.config.volume??1)*this.masterVolume}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));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(n){return this.audioLayers.get(n)}async clearAllAudioTracks(){const n=Array.from(this.audioLayers.keys());for(const t of n)await this.removeAudioTrack(t)}async syncWithVideo(n,t){for(const o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-n;if(i+r>t){o.config.duration=t-i;const s=new ha({source:o.clip.source,start:we.fromSeconds(i),stop:we.fromSeconds(t),volume:o.clip.volume}),c=o.track.clips.indexOf(o.clip);c!==-1&&(o.track.clips[c]=s,o.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(n=>({id:n.id,name:n.name,config:{...n.config,source:n.config.source&&typeof n.config.source=="object"&&"type"in n.config.source?"[AudioSource]":n.config.source}}))}async importConfiguration(n){for(const{name:t,config:o}of n)await this.addAudioTrack({...o,name:t})}}function Kl(a,n){return function(){return a.apply(n,arguments)}}const{toString:Ug}=Object.prototype,{getPrototypeOf:yr}=Object,{iterator:Ua,toStringTag:ql}=Symbol,Aa=(a=>n=>{const t=Ug.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),It=a=>(a=a.toLowerCase(),n=>Aa(n)===a),Oa=a=>n=>typeof n===a,{isArray:Zn}=Array,wo=Oa("undefined");function _o(a){return a!==null&&!wo(a)&&a.constructor!==null&&!wo(a.constructor)&&wt(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const Ql=It("ArrayBuffer");function Ag(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&Ql(a.buffer),n}const Og=Oa("string"),wt=Oa("function"),ec=Oa("number"),To=a=>a!==null&&typeof a=="object",Lg=a=>a===!0||a===!1,oa=a=>{if(Aa(a)!=="object")return!1;const n=yr(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(ql in a)&&!(Ua in a)},zg=a=>{if(!To(a)||_o(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},Pg=It("Date"),jg=It("File"),Wg=It("Blob"),Zg=It("FileList"),Xg=a=>To(a)&&wt(a.pipe),Hg=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||wt(a.append)&&((n=Aa(a))==="formdata"||n==="object"&&wt(a.toString)&&a.toString()==="[object FormData]"))},Gg=It("URLSearchParams"),[Jg,Yg,Kg,qg]=["ReadableStream","Request","Response","Headers"].map(It),Qg=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Mo(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),Zn(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(_o(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let c;for(o=0;o<s;o++)c=r[o],n.call(null,a[c],c,a)}}function tc(a,n){if(_o(a))return null;n=n.toLowerCase();const t=Object.keys(a);let o=t.length,i;for(;o-- >0;)if(i=t[o],n===i.toLowerCase())return i;return null}const yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,nc=a=>!wo(a)&&a!==yn;function ji(){const{caseless:a}=nc(this)&&this||{},n={},t=(o,i)=>{const r=a&&tc(n,i)||i;oa(n[r])&&oa(o)?n[r]=ji(n[r],o):oa(o)?n[r]=ji({},o):Zn(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&Mo(arguments[o],t);return n}const ey=(a,n,t,{allOwnKeys:o}={})=>(Mo(n,(i,r)=>{t&&wt(i)?a[r]=Kl(i,t):a[r]=i},{allOwnKeys:o}),a),ty=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),ny=(a,n,t,o)=>{a.prototype=Object.create(n.prototype,o),a.prototype.constructor=a,Object.defineProperty(a,"super",{value:n.prototype}),t&&Object.assign(a.prototype,t)},oy=(a,n,t,o)=>{let i,r,s;const c={};if(n=n||{},a==null)return n;do{for(i=Object.getOwnPropertyNames(a),r=i.length;r-- >0;)s=i[r],(!o||o(s,a,n))&&!c[s]&&(n[s]=a[s],c[s]=!0);a=t!==!1&&yr(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},ay=(a,n,t)=>{a=String(a),(t===void 0||t>a.length)&&(t=a.length),t-=n.length;const o=a.indexOf(n,t);return o!==-1&&o===t},iy=a=>{if(!a)return null;if(Zn(a))return a;let n=a.length;if(!ec(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},ry=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&yr(Uint8Array)),sy=(a,n)=>{const o=(a&&a[Ua]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},ly=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},cy=It("HTMLFormElement"),dy=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Ds=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),uy=It("RegExp"),oc=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};Mo(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},my=a=>{oc(a,(n,t)=>{if(wt(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(wt(o)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},py=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return Zn(a)?o(a):o(String(a).split(n)),t},fy=()=>{},hy=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function vy(a){return!!(a&&wt(a.append)&&a[ql]==="FormData"&&a[Ua])}const gy=a=>{const n=new Array(10),t=(o,i)=>{if(To(o)){if(n.indexOf(o)>=0)return;if(_o(o))return o;if(!("toJSON"in o)){n[i]=o;const r=Zn(o)?[]:{};return Mo(o,(s,c)=>{const l=t(s,i+1);!wo(l)&&(r[c]=l)}),n[i]=void 0,r}}return o};return t(a,0)},yy=It("AsyncFunction"),wy=a=>a&&(To(a)||wt(a))&&wt(a.then)&&wt(a.catch),ac=((a,n)=>a?setImmediate:n?((t,o)=>(yn.addEventListener("message",({source:i,data:r})=>{i===yn&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),yn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",wt(yn.postMessage)),by=typeof queueMicrotask<"u"?queueMicrotask.bind(yn):typeof process<"u"&&process.nextTick||ac,ky=a=>a!=null&&wt(a[Ua]),G={isArray:Zn,isArrayBuffer:Ql,isBuffer:_o,isFormData:Hg,isArrayBufferView:Ag,isString:Og,isNumber:ec,isBoolean:Lg,isObject:To,isPlainObject:oa,isEmptyObject:zg,isReadableStream:Jg,isRequest:Yg,isResponse:Kg,isHeaders:qg,isUndefined:wo,isDate:Pg,isFile:jg,isBlob:Wg,isRegExp:uy,isFunction:wt,isStream:Xg,isURLSearchParams:Gg,isTypedArray:ry,isFileList:Zg,forEach:Mo,merge:ji,extend:ey,trim:Qg,stripBOM:ty,inherits:ny,toFlatObject:oy,kindOf:Aa,kindOfTest:It,endsWith:ay,toArray:iy,forEachEntry:sy,matchAll:ly,isHTMLForm:cy,hasOwnProperty:Ds,hasOwnProp:Ds,reduceDescriptors:oc,freezeMethods:my,toObjectSet:py,toCamelCase:dy,noop:fy,toFiniteNumber:hy,findKey:tc,global:yn,isContextDefined:nc,isSpecCompliantForm:vy,toJSONObject:gy,isAsyncFn:yy,isThenable:wy,setImmediate:ac,asap:by,isIterable:ky};function Fe(a,n,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=a,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}G.inherits(Fe,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 ic=Fe.prototype,rc={};["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(a=>{rc[a]={value:a}});Object.defineProperties(Fe,rc);Object.defineProperty(ic,"isAxiosError",{value:!0});Fe.from=(a,n,t,o,i,r)=>{const s=Object.create(ic);return G.toFlatObject(a,s,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),Fe.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const xy=null;function Wi(a){return G.isPlainObject(a)||G.isArray(a)}function sc(a){return G.endsWith(a,"[]")?a.slice(0,-2):a}function Us(a,n,t){return a?a.concat(n).map(function(i,r){return i=sc(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function Ey(a){return G.isArray(a)&&!a.some(Wi)}const Vy=G.toFlatObject(G,{},null,function(n){return/^is[A-Z]/.test(n)});function La(a,n,t){if(!G.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=G.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,E){return!G.isUndefined(E[g])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(n);if(!G.isFunction(i))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(!l&&G.isBlob(v))throw new Fe("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(v)||G.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,g,E){let T=v;if(v&&!E&&typeof v=="object"){if(G.endsWith(g,"{}"))g=o?g:g.slice(0,-2),v=JSON.stringify(v);else if(G.isArray(v)&&Ey(v)||(G.isFileList(v)||G.endsWith(g,"[]"))&&(T=G.toArray(v)))return g=sc(g),T.forEach(function(w,h){!(G.isUndefined(w)||w===null)&&n.append(s===!0?Us([g],h,r):s===null?g:g+"[]",d(w))}),!1}return Wi(v)?!0:(n.append(Us(E,g,r),d(v)),!1)}const m=[],f=Object.assign(Vy,{defaultVisitor:u,convertValue:d,isVisitable:Wi});function p(v,g){if(!G.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(v),G.forEach(v,function(T,N){(!(G.isUndefined(T)||T===null)&&i.call(n,T,G.isString(N)?N.trim():N,g,f))===!0&&p(T,g?g.concat(N):[N])}),m.pop()}}if(!G.isObject(a))throw new TypeError("data must be an object");return p(a),n}function As(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function wr(a,n){this._pairs=[],a&&La(a,this,n)}const lc=wr.prototype;lc.append=function(n,t){this._pairs.push([n,t])};lc.toString=function(n){const t=n?function(o){return n.call(this,o,As)}:As;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Sy(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function cc(a,n,t){if(!n)return a;const o=t&&t.encode||Sy;G.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=G.isURLSearchParams(n)?n.toString():new wr(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class Os{constructor(){this.handlers=[]}use(n,t,o){return this.handlers.push({fulfilled:n,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){G.forEach(this.handlers,function(o){o!==null&&n(o)})}}const dc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cy=typeof URLSearchParams<"u"?URLSearchParams:wr,Ny=typeof FormData<"u"?FormData:null,_y=typeof Blob<"u"?Blob:null,Ty={isBrowser:!0,classes:{URLSearchParams:Cy,FormData:Ny,Blob:_y},protocols:["http","https","file","blob","url","data"]},br=typeof window<"u"&&typeof document<"u",Zi=typeof navigator=="object"&&navigator||void 0,My=br&&(!Zi||["ReactNative","NativeScript","NS"].indexOf(Zi.product)<0),By=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Fy=br&&window.location.href||"http://localhost",Iy=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:br,hasStandardBrowserEnv:My,hasStandardBrowserWebWorkerEnv:By,navigator:Zi,origin:Fy},Symbol.toStringTag,{value:"Module"})),mt={...Iy,...Ty};function Ry(a,n){return La(a,new mt.classes.URLSearchParams,{visitor:function(t,o,i,r){return mt.isNode&&G.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function $y(a){return G.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Dy(a){const n={},t=Object.keys(a);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],n[r]=a[r];return n}function uc(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const c=Number.isFinite(+s),l=r>=t.length;return s=!s&&G.isArray(i)?i.length:s,l?(G.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!c):((!i[s]||!G.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&G.isArray(i[s])&&(i[s]=Dy(i[s])),!c)}if(G.isFormData(a)&&G.isFunction(a.entries)){const t={};return G.forEachEntry(a,(o,i)=>{n($y(o),i,t,0)}),t}return null}function Uy(a,n,t){if(G.isString(a))try{return(n||JSON.parse)(a),G.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const Bo={transitional:dc,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=G.isObject(n);if(r&&G.isHTMLForm(n)&&(n=new FormData(n)),G.isFormData(n))return i?JSON.stringify(uc(n)):n;if(G.isArrayBuffer(n)||G.isBuffer(n)||G.isStream(n)||G.isFile(n)||G.isBlob(n)||G.isReadableStream(n))return n;if(G.isArrayBufferView(n))return n.buffer;if(G.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return Ry(n,this.formSerializer).toString();if((c=G.isFileList(n))||o.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return La(c?{"files[]":n}:n,l&&new l,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Uy(n)):n}],transformResponse:[function(n){const t=this.transitional||Bo.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(G.isResponse(n)||G.isReadableStream(n))return n;if(n&&G.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(c){if(s)throw c.name==="SyntaxError"?Fe.from(c,Fe.ERR_BAD_RESPONSE,this,null,this.response):c}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:mt.classes.FormData,Blob:mt.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],a=>{Bo.headers[a]={}});const Ay=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"]),Oy=a=>{const n={};let t,o,i;return a&&a.split(`
337
+ `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&Ay[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},Ls=Symbol("internals");function eo(a){return a&&String(a).trim().toLowerCase()}function aa(a){return a===!1||a==null?a:G.isArray(a)?a.map(aa):String(a)}function Ly(a){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(a);)n[o[1]]=o[2];return n}const zy=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function bi(a,n,t,o,i){if(G.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!G.isString(n)){if(G.isString(o))return n.indexOf(o)!==-1;if(G.isRegExp(o))return o.test(n)}}function Py(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function jy(a,n){const t=G.toCamelCase(" "+n);["get","set","has"].forEach(o=>{Object.defineProperty(a,o+t,{value:function(i,r,s){return this[o].call(this,n,i,r,s)},configurable:!0})})}let bt=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(c,l,d){const u=eo(l);if(!u)throw new Error("header name must be a non-empty string");const m=G.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||l]=aa(c))}const s=(c,l)=>G.forEach(c,(d,u)=>r(d,u,l));if(G.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(G.isString(n)&&(n=n.trim())&&!zy(n))s(Oy(n),t);else if(G.isObject(n)&&G.isIterable(n)){let c={},l,d;for(const u of n){if(!G.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[d=u[0]]=(l=c[d])?G.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}s(c,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=eo(n),n){const o=G.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return Ly(i);if(G.isFunction(t))return t.call(this,i,o);if(G.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=eo(n),n){const o=G.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||bi(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=eo(s),s){const c=G.findKey(o,s);c&&(!t||bi(o,o[c],c,t))&&(delete o[c],i=!0)}}return G.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!n||bi(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return G.forEach(this,(i,r)=>{const s=G.findKey(o,r);if(s){t[s]=aa(i),delete t[r];return}const c=n?Py(r):String(r).trim();c!==r&&delete t[r],t[c]=aa(i),o[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return G.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&G.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
338
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[Ls]=this[Ls]={accessors:{}}).accessors,i=this.prototype;function r(s){const c=eo(s);o[c]||(jy(i,s),o[c]=!0)}return G.isArray(n)?n.forEach(r):r(n),this}};bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);G.reduceDescriptors(bt.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});G.freezeMethods(bt);function ki(a,n){const t=this||Bo,o=n||t,i=bt.from(o.headers);let r=o.data;return G.forEach(a,function(c){r=c.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function mc(a){return!!(a&&a.__CANCEL__)}function Xn(a,n,t){Fe.call(this,a??"canceled",Fe.ERR_CANCELED,n,t),this.name="CanceledError"}G.inherits(Xn,Fe,{__CANCEL__:!0});function pc(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new Fe("Request failed with status code "+t.status,[Fe.ERR_BAD_REQUEST,Fe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Wy(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function Zy(a,n){a=a||10;const t=new Array(a),o=new Array(a);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(l){const d=Date.now(),u=o[r];s||(s=d),t[i]=l,o[i]=d;let m=r,f=0;for(;m!==i;)f+=t[m++],m=m%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const p=u&&d-u;return p?Math.round(f*1e3/p):void 0}}function Xy(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-m)))},()=>i&&s(i)]}const ga=(a,n,t=3)=>{let o=0;const i=Zy(50,250);return Xy(r=>{const s=r.loaded,c=r.lengthComputable?r.total:void 0,l=s-o,d=i(l),u=s<=c;o=s;const m={loaded:s,total:c,progress:c?s/c:void 0,bytes:l,rate:d||void 0,estimated:d&&c&&u?(c-s)/d:void 0,event:r,lengthComputable:c!=null,[n?"download":"upload"]:!0};a(m)},t)},zs=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},Ps=a=>(...n)=>G.asap(()=>a(...n)),Hy=mt.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,mt.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(mt.origin),mt.navigator&&/(msie|trident)/i.test(mt.navigator.userAgent)):()=>!0,Gy=mt.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];G.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),G.isString(o)&&s.push("path="+o),G.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(a){const n=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Jy(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function Yy(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function fc(a,n,t){let o=!Jy(n);return a&&(o||t==!1)?Yy(a,n):n}const js=a=>a instanceof bt?{...a}:a;function xn(a,n){n=n||{};const t={};function o(d,u,m,f){return G.isPlainObject(d)&&G.isPlainObject(u)?G.merge.call({caseless:f},d,u):G.isPlainObject(u)?G.merge({},u):G.isArray(u)?u.slice():u}function i(d,u,m,f){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d,m,f)}else return o(d,u,m,f)}function r(d,u){if(!G.isUndefined(u))return o(void 0,u)}function s(d,u){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function c(d,u,m){if(m in n)return o(d,u);if(m in a)return o(void 0,d)}const l={url:r,method:r,data:r,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:c,headers:(d,u,m)=>i(js(d),js(u),m,!0)};return G.forEach(Object.keys({...a,...n}),function(u){const m=l[u]||i,f=m(a[u],n[u],u);G.isUndefined(f)&&m!==c||(t[u]=f)}),t}const hc=a=>{const n=xn({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:c}=n;n.headers=s=bt.from(s),n.url=cc(fc(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),c&&s.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(G.isFormData(t)){if(mt.hasStandardBrowserEnv||mt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((l=s.getContentType())!==!1){const[d,...u]=l?l.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(mt.hasStandardBrowserEnv&&(o&&G.isFunction(o)&&(o=o(n)),o||o!==!1&&Hy(n.url))){const d=i&&r&&Gy.read(r);d&&s.set(i,d)}return n},Ky=typeof XMLHttpRequest<"u",qy=Ky&&function(a){return new Promise(function(t,o){const i=hc(a);let r=i.data;const s=bt.from(i.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:d}=i,u,m,f,p,v;function g(){p&&p(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let E=new XMLHttpRequest;E.open(i.method.toUpperCase(),i.url,!0),E.timeout=i.timeout;function T(){if(!E)return;const w=bt.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:w,config:a,request:E};pc(function(C){t(C),g()},function(C){o(C),g()},x),E=null}"onloadend"in E?E.onloadend=T:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(T)},E.onabort=function(){E&&(o(new Fe("Request aborted",Fe.ECONNABORTED,a,E)),E=null)},E.onerror=function(){o(new Fe("Network Error",Fe.ERR_NETWORK,a,E)),E=null},E.ontimeout=function(){let h=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const x=i.transitional||dc;i.timeoutErrorMessage&&(h=i.timeoutErrorMessage),o(new Fe(h,x.clarifyTimeoutError?Fe.ETIMEDOUT:Fe.ECONNABORTED,a,E)),E=null},r===void 0&&s.setContentType(null),"setRequestHeader"in E&&G.forEach(s.toJSON(),function(h,x){E.setRequestHeader(x,h)}),G.isUndefined(i.withCredentials)||(E.withCredentials=!!i.withCredentials),c&&c!=="json"&&(E.responseType=i.responseType),d&&([f,v]=ga(d,!0),E.addEventListener("progress",f)),l&&E.upload&&([m,p]=ga(l),E.upload.addEventListener("progress",m),E.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=w=>{E&&(o(!w||w.type?new Xn(null,a,E):w),E.abort(),E=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const N=Wy(i.url);if(N&&mt.protocols.indexOf(N)===-1){o(new Fe("Unsupported protocol "+N+":",Fe.ERR_BAD_REQUEST,a));return}E.send(r||null)})},Qy=(a,n)=>{const{length:t}=a=a?a.filter(Boolean):[];if(n||t){let o=new AbortController,i;const r=function(d){if(!i){i=!0,c();const u=d instanceof Error?d:this.reason;o.abort(u instanceof Fe?u:new Xn(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Fe(`timeout ${n} of ms exceeded`,Fe.ETIMEDOUT))},n);const c=()=>{a&&(s&&clearTimeout(s),s=null,a.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),a=null)};a.forEach(d=>d.addEventListener("abort",r));const{signal:l}=o;return l.unsubscribe=()=>G.asap(c),l}},ew=function*(a,n){let t=a.byteLength;if(t<n){yield a;return}let o=0,i;for(;o<t;)i=o+n,yield a.slice(o,i),o=i},tw=async function*(a,n){for await(const t of nw(a))yield*ew(t,n)},nw=async function*(a){if(a[Symbol.asyncIterator]){yield*a;return}const n=a.getReader();try{for(;;){const{done:t,value:o}=await n.read();if(t)break;yield o}}finally{await n.cancel()}},Ws=(a,n,t,o)=>{const i=tw(a,n);let r=0,s,c=l=>{s||(s=!0,o&&o(l))};return new ReadableStream({async pull(l){try{const{done:d,value:u}=await i.next();if(d){c(),l.close();return}let m=u.byteLength;if(t){let f=r+=m;t(f)}l.enqueue(new Uint8Array(u))}catch(d){throw c(d),d}},cancel(l){return c(l),i.return()}},{highWaterMark:2})},za=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",vc=za&&typeof ReadableStream=="function",ow=za&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),gc=(a,...n)=>{try{return!!a(...n)}catch{return!1}},aw=vc&&gc(()=>{let a=!1;const n=new Request(mt.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),Zs=64*1024,Xi=vc&&gc(()=>G.isReadableStream(new Response("").body)),ya={stream:Xi&&(a=>a.body)};za&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!ya[n]&&(ya[n]=G.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new Fe(`Response type '${n}' is not supported`,Fe.ERR_NOT_SUPPORT,o)})})})(new Response);const iw=async a=>{if(a==null)return 0;if(G.isBlob(a))return a.size;if(G.isSpecCompliantForm(a))return(await new Request(mt.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(G.isArrayBufferView(a)||G.isArrayBuffer(a))return a.byteLength;if(G.isURLSearchParams(a)&&(a=a+""),G.isString(a))return(await ow(a)).byteLength},rw=async(a,n)=>{const t=G.toFiniteNumber(a.getContentLength());return t??iw(n)},sw=za&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:c,onUploadProgress:l,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:f}=hc(a);d=d?(d+"").toLowerCase():"text";let p=Qy([i,r&&r.toAbortSignal()],s),v;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let E;try{if(l&&aw&&t!=="get"&&t!=="head"&&(E=await rw(u,o))!==0){let x=new Request(n,{method:"POST",body:o,duplex:"half"}),D;if(G.isFormData(o)&&(D=x.headers.get("content-type"))&&u.setContentType(D),x.body){const[C,y]=zs(E,ga(Ps(l)));o=Ws(x.body,Zs,C,y)}}G.isString(m)||(m=m?"include":"omit");const T="credentials"in Request.prototype;v=new Request(n,{...f,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:T?m:void 0});let N=await fetch(v,f);const w=Xi&&(d==="stream"||d==="response");if(Xi&&(c||w&&g)){const x={};["status","statusText","headers"].forEach(S=>{x[S]=N[S]});const D=G.toFiniteNumber(N.headers.get("content-length")),[C,y]=c&&zs(D,ga(Ps(c),!0))||[];N=new Response(Ws(N.body,Zs,C,()=>{y&&y(),g&&g()}),x)}d=d||"text";let h=await ya[G.findKey(ya,d)||"text"](N,a);return!w&&g&&g(),await new Promise((x,D)=>{pc(x,D,{data:h,headers:bt.from(N.headers),status:N.status,statusText:N.statusText,config:a,request:v})})}catch(T){throw g&&g(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Fe("Network Error",Fe.ERR_NETWORK,a,v),{cause:T.cause||T}):Fe.from(T,T&&T.code,a,v)}}),Hi={http:xy,xhr:qy,fetch:sw};G.forEach(Hi,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const Xs=a=>`- ${a}`,lw=a=>G.isFunction(a)||a===null||a===!1,yc={getAdapter:a=>{a=G.isArray(a)?a:[a];const{length:n}=a;let t,o;const i={};for(let r=0;r<n;r++){t=a[r];let s;if(o=t,!lw(t)&&(o=Hi[(s=String(t)).toLowerCase()],o===void 0))throw new Fe(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
339
+ `+r.map(Xs).join(`
340
+ `):" "+Xs(r[0]):"as no adapter specified";throw new Fe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:Hi};function xi(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Xn(null,a)}function Hs(a){return xi(a),a.headers=bt.from(a.headers),a.data=ki.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),yc.getAdapter(a.adapter||Bo.adapter)(a).then(function(o){return xi(a),o.data=ki.call(a,a.transformResponse,o),o.headers=bt.from(o.headers),o},function(o){return mc(o)||(xi(a),o&&o.response&&(o.response.data=ki.call(a,a.transformResponse,o.response),o.response.headers=bt.from(o.response.headers))),Promise.reject(o)})}const wc="1.11.0",Pa={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{Pa[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const Gs={};Pa.transitional=function(n,t,o){function i(r,s){return"[Axios v"+wc+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,c)=>{if(n===!1)throw new Fe(i(s," has been removed"+(t?" in "+t:"")),Fe.ERR_DEPRECATED);return t&&!Gs[s]&&(Gs[s]=!0),n?n(r,s,c):!0}};Pa.spelling=function(n){return(t,o)=>!0};function cw(a,n,t){if(typeof a!="object")throw new Fe("options must be an object",Fe.ERR_BAD_OPTION_VALUE);const o=Object.keys(a);let i=o.length;for(;i-- >0;){const r=o[i],s=n[r];if(s){const c=a[r],l=c===void 0||s(c,r,a);if(l!==!0)throw new Fe("option "+r+" must be "+l,Fe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Fe("Unknown option "+r,Fe.ERR_BAD_OPTION)}}const ia={assertOptions:cw,validators:Pa},Lt=ia.validators;let bn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Os,response:new Os}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
341
+ `+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=xn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&ia.assertOptions(o,{silentJSONParsing:Lt.transitional(Lt.boolean),forcedJSONParsing:Lt.transitional(Lt.boolean),clarifyTimeoutError:Lt.transitional(Lt.boolean)},!1),i!=null&&(G.isFunction(i)?t.paramsSerializer={serialize:i}:ia.assertOptions(i,{encode:Lt.function,serialize:Lt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ia.assertOptions(t,{baseUrl:Lt.spelling("baseURL"),withXsrfToken:Lt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&G.merge(r.common,r[t.method]);r&&G.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=bt.concat(s,r);const c=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(l=l&&g.synchronous,c.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,m=0,f;if(!l){const v=[Hs.bind(this),void 0];for(v.unshift(...c),v.push(...d),f=v.length,u=Promise.resolve(t);m<f;)u=u.then(v[m++],v[m++]);return u}f=c.length;let p=t;for(m=0;m<f;){const v=c[m++],g=c[m++];try{p=v(p)}catch(E){g.call(this,E);break}}try{u=Hs.call(this,p)}catch(v){return Promise.reject(v)}for(m=0,f=d.length;m<f;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=xn(this.defaults,n);const t=fc(n.baseURL,n.url,n.allowAbsoluteUrls);return cc(t,n.params,n.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(n){bn.prototype[n]=function(t,o){return this.request(xn(o||{},{method:n,url:t,data:(o||{}).data}))}});G.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,c){return this.request(xn(c||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}bn.prototype[n]=t(),bn.prototype[n+"Form"]=t(!0)});let dw=class bc{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(c=>{o.subscribe(c),r=c}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,c){o.reason||(o.reason=new Xn(r,s,c),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=o=>{n.abort(o)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new bc(function(i){n=i}),cancel:n}}};function uw(a){return function(t){return a.apply(null,t)}}function mw(a){return G.isObject(a)&&a.isAxiosError===!0}const Gi={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(Gi).forEach(([a,n])=>{Gi[n]=a});function kc(a){const n=new bn(a),t=Kl(bn.prototype.request,n);return G.extend(t,bn.prototype,n,{allOwnKeys:!0}),G.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return kc(xn(a,i))},t}const Je=kc(Bo);Je.Axios=bn;Je.CanceledError=Xn;Je.CancelToken=dw;Je.isCancel=mc;Je.VERSION=wc;Je.toFormData=La;Je.AxiosError=Fe;Je.Cancel=Je.CanceledError;Je.all=function(n){return Promise.all(n)};Je.spread=uw;Je.isAxiosError=mw;Je.mergeConfig=xn;Je.AxiosHeaders=bt;Je.formToJSON=a=>uc(G.isHTMLForm(a)?new FormData(a):a);Je.getAdapter=yc.getAdapter;Je.HttpStatusCode=Gi;Je.default=Je;const{Axios:H3,AxiosError:G3,CanceledError:J3,isCancel:Y3,CancelToken:K3,VERSION:q3,all:Q3,Cancel:eV,isAxiosError:tV,spread:nV,toFormData:oV,AxiosHeaders:aV,HttpStatusCode:iV,formToJSON:rV,getAdapter:sV,mergeConfig:lV}=Je;class kr{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Je.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const o=this.getAuthToken();return o&&(t.headers.Authorization=`Bearer ${o}`),t}),this.api.interceptors.response.use(t=>t,t=>{var o;return(o=t.response)==null||o.status,Promise.reject(t)})}async createJob(n){try{const t=await this.api.post("/video/jobs",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(n){try{const t=await this.api.post("/video/jobs/render",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(n,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,c)=>{const l=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(l),s(d)):d.status==="failed"?(clearInterval(l),c(new Error(d.error_message??"Render job failed"))):Date.now()-r>i&&(clearInterval(l),c(new Error("Render job timed out")))}catch(d){clearInterval(l),c(d)}},o)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{await this.api.delete(`/video/jobs/${n}`),this.unsubscribeFromProgress(n)}catch(t){throw t}}async retryJob(n){try{const t=await this.api.post(`/video/jobs/${n}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(n,t){this.progressCallbacks.set(n,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(n)}unsubscribeFromProgress(n){this.progressCallbacks.delete(n),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const n=this.getAuthToken(),t=`/api/v1/video/jobs/events${n?`?token=${n}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",o=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const o=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(o.progress),(o.status==="completed"||o.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const o of t){const[i,r]=o.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(n){try{return(await this.api.get(`/video/jobs/${n}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(n,t=0){try{const o=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(n){const t=n,o={...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??""},i=t.output_media_id??t.outputMediaId;typeof i=="string"&&i!==""&&(o.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(o.error_message=r);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(o.started_at=s);const c=t.completed_at??t.completedAt;return typeof c=="string"&&c!==""&&(o.completed_at=c),o}}new kr;const pw={key:0,class:"mobile-layout"},fw={class:"mobile-toolbar"},hw={class:"mobile-toolbar-left"},vw=["aria-label"],gw={class:"mobile-toolbar-right"},yw=["disabled"],ww=["disabled"],bw={class:"preview-section"},kw={key:0,class:"mobile-export-overlay"},xw={class:"mobile-export-progress"},Ew={class:"mobile-export-bar"},Vw={class:"mobile-timeline-zoom"},Sw={key:1,class:"desktop-layout"},Cw={class:"desktop-main-row"},Nw={class:"preview-panel"},_w={class:"fit-toggle"},Tw={class:"editor-content"},Mw={class:"editor-tabs"},Bw={class:"tab-header"},Fw=["onClick"],Iw={class:"tab-content-area"},Rw={class:"filter-controls"},$w={class:"text-controls"},Dw={class:"transition-controls"},Uw={class:"audio-controls"},Aw={class:"adjustments-controls"},Ow={key:1,class:"no-filter-selected"},Lw={class:"export-controls"},zw={key:0,"data-testid":"video-export-status-completed"},Pw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},jw={class:"desktop-timeline-row"},Ww={class:"timeline-zoom"},Zw=["value"],Xw={class:"zoom-readout"},Hw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Gw={class:"dev-editor-row"},Jw={class:"dev-editor-field"},Yw={class:"dev-editor-field"},Kw=["disabled"],qw=["disabled"],Qw=["disabled"],eb={class:"dev-editor-row"},tb={class:"dev-editor-field dev-editor-field--wide"},nb=["value"],ob=["disabled"],ab=["disabled"],ib=["disabled"],rb=["disabled"],sb=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:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const b=o.media.uuid??o.media.id;return typeof b=="string"&&b.trim()!==""?b.trim():void 0}),s=e.computed(()=>{const b=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return b!==""?b:r.value??`temp-${Date.now()}`}),c=e.ref(typeof window<"u"?window.innerWidth<768:!1),l=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const b=o.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=o.featureFlags;return V?{filters:typeof V.filters=="boolean"?V.filters:b.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:b.adjustments,text:typeof V.text=="boolean"?V.text:b.text,transitions:typeof V.transitions=="boolean"?V.transitions:b.transitions,audio:typeof V.audio=="boolean"?V.audio:b.audio,export:typeof V.export=="boolean"?V.export:b.export}:b}),m=e.computed(()=>c.value?l.value:d.value),f=e.computed(()=>m.value==="filters"||E.value),p=e.computed(()=>m.value!=="filters"&&!E.value),v=e.ref(null),g=e.ref(null),E=e.ref(!1),T=e.computed(()=>c.value?v.value:g.value);function N(b){return b==="contain"||b==="cover"||b==="none"}function w(b){if(!(b!=null&&b.metadata))return null;const V=b.metadata.fit_mode;return N(V)?V:null}const h=e.shallowRef(null),x=e.ref(null),D=e.ref(w(o.initialRecipe)??"contain"),C=e.ref(null),y=e.ref(null),S=e.ref(null),A=e.ref(!1),k=new Map,B=e.ref([]),R=e.ref([]),U=e.ref([]),_=e.ref([]),z=e.ref(1),H=()=>{c.value=window.innerWidth<768},M=[{id:"filters",label:"Filters",icon:sn},{id:"adjustments",label:"Adjust",icon:Cu},{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:vo}],$=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],X=e.computed(()=>M.filter(b=>u.value[b.id])),W=e.computed(()=>$.filter(b=>u.value[b.id])),te=e.computed(()=>{var b,V;return((b=W.value[0])==null?void 0:b.id)??((V=X.value[0])==null?void 0:V.id)??"filters"});e.watch(u,b=>{b[l.value]||(l.value=te.value),b[d.value]||(d.value=te.value)},{immediate:!0,deep:!0}),e.watch(te,b=>{u.value[l.value]||(l.value=b),u.value[d.value]||(d.value=b)},{immediate:!0}),e.watch(u,b=>{b.export||(l.value==="export"&&(l.value=te.value),d.value==="export"&&(d.value=te.value))},{immediate:!0,deep:!0});const ge=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:Ne,playheadPosition:ee,timelineClips:F,totalDuration:P,hasChanges:pe,isPlaying:ne,selectedClip:Y,zoomLevel:Me,playbackSpeed:ce,handleTrim:se,handleSplit:ke,handleClipSelect:oe,splitAtPlayhead:le,deleteSelectedClip:Ee,duplicateSelectedClip:Se,setZoomLevel:rt,moveClip:He,setFilters:pt,setTextOverlays:K,setAudioTracks:de,saveDraft:ie,clearHasChanges:he,resetChanges:_e,generateRecipe:J,zoomIn:ue,zoomOut:ve,fitToWindow:Z,togglePlayback:Q,setPlaying:ae,seekTo:xe,frameForward:De,frameBackward:Qe,skipToStart:We,skipToEnd:ft,setPlaybackSpeed:Ze,updateSourceDuration:Ht}=Vg(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:Xa,activeFilters:et,selectedFilter:Br,previewFilter:Fo,previewFilterEffect:Fr,applyFilter:Ir,updateFilterParams:$c,removeFilter:Dc,clearAllFilters:Rr,setActiveFilters:Uc}=Rg();function Hn(b){var j,q;const V=((j=Y.value)==null?void 0:j.id)??((q=F.value[0])==null?void 0:q.id);V&&(A.value=!0,typeof b=="object"&&b.id?Ir(b.id):typeof b=="string"&&Ir(b),pt(et.value),h.value?h.value.setClipFilters(V,et.value):k.set(V,[...et.value]),oe(V),A.value=!1,Ut())}function Ac(){var V,j;const b=((V=Y.value)==null?void 0:V.id)??((j=F.value[0])==null?void 0:j.id);b&&oe(b)}function $r(b){const V=et.value.find(j=>j.filterId===b);V&&Dc(V.id)}const Gn=e.computed(()=>Xa.value.map(V=>{var q;const j=[];if(V.controls&&V.controls.length>0)for(const me of V.controls){const re=me.type;if(re==="button"||re==="text"||re==="range")continue;const fe={id:me.property||me.id,label:me.label||me.id,type:re,default:me.default??(re==="toggle"?!1:re==="color"?"#ffffff":0)};re==="slider"&&(fe.min=me.min??0,fe.max=me.max??1,fe.step=me.step??.01),re==="select"&&me.options&&(fe.options=me.options),j.push(fe)}else if(V.paramRanges){const me=Object.entries(V.paramRanges);for(const[re,fe]of me){const Ae=re.replace(/[-_]/g," ").replace(/\b\w/g,At=>At.toUpperCase()),ht=(q=V.defaultParams)==null?void 0:q[re],Yt=(fe.min+fe.max)/2;j.push({id:re,label:Ae,min:fe.min,max:fe.max,step:fe.step??.01,default:typeof ht=="number"?ht:Yt})}}return{id:V.id,name:V.name,category:V.category,params:j}})),Cn=e.ref("0.00"),Nn=e.ref("0.00"),en=e.ref("");e.watch(Gn,b=>{if(b.length===0){en.value="";return}b.some(j=>j.id===en.value)||(en.value=b[0].id)},{immediate:!0});const nt=e.ref(!1),Xe=e.ref(0),Gt=e.ref(!1),je=e.ref(null),Tt=e.ref(null);let Io=null,Ct=!1,Jt=null;const Ha=e.computed(()=>{const b=new Map;return et.value.forEach(V=>b.set(V.filterId,V)),b}),Oc=e.computed(()=>{var b,V;return Ne.value?Ne.value:((b=o.media)==null?void 0:b.thumbnail_url)||((V=o.media)==null?void 0:V.url)}),Rt=e.ref("");e.watch(()=>{var b,V;return{file:(b=o.media)==null?void 0:b.file,url:(V=o.media)==null?void 0:V.url}},(b,V,j)=>{var me,re;const q=Rt.value;j(()=>{q&&q.startsWith("blob:")&&URL.revokeObjectURL(q)}),(me=o.media)!=null&&me.file?Rt.value=URL.createObjectURL(o.media.file):(re=o.media)!=null&&re.url?Rt.value=o.media.url:Rt.value=""},{immediate:!0}),e.onUnmounted(()=>{Rt.value&&Rt.value.startsWith("blob:")&&URL.revokeObjectURL(Rt.value)});const Ga=e.computed(()=>Rt.value),Dr=e.computed(()=>{if(!o.media)return null;const{file:b,...V}=o.media;return{...V,url:Rt.value}}),Ur=e.computed(()=>{var V;const b=(V=o.media)==null?void 0:V.url;return!!(b&&/^https?:/i.test(b))}),Ar=e.computed(()=>et.value),Or=e.computed(()=>ee.value),Lc=e.computed(()=>!!Y.value&&ee.value>0),zc=e.computed(()=>!!Y.value&&F.value.length>1),Ja=e.ref(0),$t=e.computed(()=>{try{const b=P.value??P;return b&&typeof b=="number"&&b>0?b:Ja.value}catch{return Ja.value}}),_n=e.ref(),Ya=e.ref(),Ka=e.ref(),qa=e.ref(),Ro=e.ref(0),cn=e.ref(!1);let gt=null,Dt=null;e.watch($t,b=>{var j;if(cn.value||!b||b<=0)return;const V=Ro.value||((j=_n.value)==null?void 0:j.clientWidth)||0;V>0&&(cn.value=!0,Z(V))}),e.watch(Ro,b=>{if(cn.value||!b||b<=0)return;$t.value>0&&(cn.value=!0,Z(b))});function Tn(b){return Number.isFinite(b)?b.toFixed(2):"0.00"}function Lr(b){const V=Number(b);return Number.isFinite(V)?V:null}function Pc(b){b&&(Cn.value=Tn(b.sourceIn),Nn.value=Tn(b.sourceOut))}e.watch(()=>{var b,V,j;return[(b=Y.value)==null?void 0:b.id,(V=Y.value)==null?void 0:V.sourceIn,(j=Y.value)==null?void 0:j.sourceOut]},()=>{Pc(Y.value)},{immediate:!0});function zr(b){const V=Y.value;if(!V)return;const j=1/30,q=V.sourceMinIn??0,me=V.sourceMaxOut??$t.value,re=V.sourceIn+(ee.value-V.timelineStart);if(b==="start"){const Ae=Math.max(q,Math.min(re,V.sourceOut-j));Cn.value=Tn(Ae);return}const fe=Math.max(V.sourceIn+j,Math.min(re,me));Nn.value=Tn(fe)}function jc(){const b=Y.value;if(!b)return;const V=Lr(Cn.value),j=Lr(Nn.value);if(V===null||j===null)return;const q=1/30,me=b.sourceMinIn??0,re=b.sourceMaxOut??$t.value,fe=Math.max(me,Math.min(V,re-q)),Ae=Math.max(fe+q,Math.min(j,re));se(b.id,"start",fe),se(b.id,"end",Ae),Cn.value=Tn(fe),Nn.value=Tn(Ae),Y.value&&xe(Y.value.timelineStart)}function Wc(){en.value.trim()!==""&&Hn(en.value)}function Zc(){var b;Rr(),pt(et.value),(b=Y.value)!=null&&b.id&&(h.value?h.value.setClipFilters(Y.value.id,et.value):k.set(Y.value.id,[...et.value])),Ut()}function Pr(b,V,j){var me,re;const q=et.value.find(fe=>fe.filterId===b);q?(q.params={...q.params,[V]:j},pt(et.value),h.value&&((me=Y.value)!=null&&me.id)?h.value.setClipFilters(Y.value.id,et.value):(re=Y.value)!=null&&re.id&&k.set(Y.value.id,[...et.value]),Ut(),Ac()):Fo.value&&Fo.value.filterId===b&&(Fo.value.params={...Fo.value.params||{},[V]:j})}function jr(b){xe(b)}function Wr(b){!b||!Number.isFinite(b.timestamp)||xe(b.timestamp)}function Zr(b){ae(b)}function $o(b){!Number.isFinite(b)||b<=0||(Ja.value=b,Ht(b))}function Xc(){var V;const b=Ro.value||((V=_n.value)==null?void 0:V.clientWidth)||800;Z(b)}function Qa(b){cn.value=!0,rt(b)}function Hc(){cn.value=!0,ue()}function Gc(){cn.value=!0,ve()}function Jc(b){const V=b.target,j=Number(V.value);Qa(j)}function Xr(b){const V=Math.min(600,Math.max(10,Me.value+b));Qa(V)}function ei(){Dt==null||Dt(),Dt=null;const b=Ka.value,V=qa.value;if(!c.value||!b||!V)return;const j=()=>{Xr(-20)},q=()=>{Xr(20)};b.addEventListener("click",j),V.addEventListener("click",q),Dt=()=>{b.removeEventListener("click",j),V.removeEventListener("click",q)}}e.watch([c,Ka,qa],()=>{ei()},{flush:"post"});function Hr(b){var V;h.value=b,(V=h.value)!=null&&V.composition&&(C.value=new $g(h.value.composition),y.value=new va(h.value.composition),S.value=new Dg(h.value.composition));try{k.size&&(k.forEach((j,q)=>{h.value.setClipFilters(q,j)}),k.clear(),h.value.composition.computeFrame())}catch{}}function Yc(b){b!=null&&b.id&&Fr(b.id)}function Kc(b){$c(b),Ut()}async function qc(b){if(!C.value)return;const V=await C.value.addTextOverlay(b);B.value.push({id:V,...b})}async function Qc(b,V){if(!C.value)return;await C.value.updateTextOverlay(b,V);const j=B.value.findIndex(q=>q.id===b);j!==-1&&(B.value[j]={...B.value[j],...V})}async function ed(b){C.value&&(await C.value.removeTextOverlay(b),B.value=B.value.filter(V=>V.id!==b))}async function td(b){if(!y.value||_.value.length<2)return;const[V,j]=_.value,q=await y.value.applyTransition(V,j,b);R.value.push({id:q,...b,name:b.type})}function nd(b){if(!y.value)return;const V=R.value[b];V&&(y.value.removeTransition(V.id),R.value.splice(b,1))}function od(b){}async function ad(b){if(!S.value)return;const V=await S.value.addAudioTrack(b);U.value.push({id:V,...b})}async function id(b,V){if(!S.value)return;const j=U.value.findIndex(q=>q.id===b);j!==-1&&(U.value[j]={...U.value[j],...V})}async function rd(b){S.value&&(await S.value.removeAudioTrack(b),U.value=U.value.filter(V=>V.id!==b))}async function sd(b,V){if(!S.value)return;await S.value.updateVolume(b,V);const j=U.value.find(q=>q.id===b);j&&(j.volume=V)}async function ld(b,V){if(!S.value)return;await S.value.muteTrack(b,V);const j=U.value.find(q=>q.id===b);j&&(j.muted=V)}function cd(b){S.value&&(S.value.setMasterVolume(b),z.value=b)}function dd(b){i("thumbnail-selected",b)}function tn(){Io!==null&&(clearInterval(Io),Io=null)}function ud(b,V){return V?{...b,output:{...b.output,format:V.format,quality:V.quality}}:b}function Jn(b){var V;return b.metadata||(b.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),b.metadata.fit_mode=D.value,(V=o.media)!=null&&V.url&&/^https?:/i.test(o.media.url)?b.metadata.source_url=o.media.url:delete b.metadata.source_url,b}function Ge(b,V,j){return Math.min(j,Math.max(V,b))}function ti(b,V){if(typeof b=="number"&&Number.isFinite(b))return b;if(typeof b=="string"){const j=Number(b);if(Number.isFinite(j))return j}return V}function dt(b,V,j){for(const q of V)if(q in b)return ti(b[q],j);return j}function md(b){const V=typeof b.params=="object"&&b.params!==null?b.params:{};switch(b.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Ge(dt(V,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Ge(dt(V,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Ge(dt(V,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Ge(dt(V,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Ge(dt(V,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const q=Ge(dt(V,["brightness"],1)-1,-1,1),me=Ge(dt(V,["contrast"],1),.1,3),re=Ge(dt(V,["saturation"],1),0,3);return[{type:"brightness",value:q},{type:"contrast",value:me},{type:"saturation",value:re}]}default:return[]}}function pd(b){const V=b.timeline[0],j=Array.isArray(V==null?void 0:V.filters)?V.filters:[],q=[];for(const re of j)if(q.push(...md(re)),q.length>=12)break;const me={...b,filters:q.slice(0,12)};if(b.timeline.length===1&&V){const re=Math.max(0,ti(V.sourceIn,0)),fe=ti(V.sourceOut,re);fe>re&&(me.trim={start:re,end:fe})}return me}function fd(b){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[b??""]??[1920,1080]}function hd(b){if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const j=V.value;if(typeof j=="number"&&Number.isFinite(j)&&j>0)return j}return null}async function Gr(b,V,j){var Yt,At,Mn,on;const q=b.timeline[0],me=q?Math.max(0,q.sourceIn):0,re=q?q.sourceOut:void 0,[fe,Ae]=fd((V==null?void 0:V.quality)??((Yt=b.output)==null?void 0:Yt.quality)),ht=((At=b.output)==null?void 0:At.fps)||30;ae(!1),E.value=!0,await e.nextTick();try{const ot=[200,500,1e3];let st=!1;for(const ci of ot){await new Promise($d=>setTimeout($d,ci));const Ao=T.value;if(!(!Ao||typeof Ao.captureFrameAt!="function")&&typeof Ao.ensureReadyForCapture=="function"&&(st=await Ao.ensureReadyForCapture(),st))break}const Ot=T.value;if(!Ot||typeof Ot.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!st)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Yn,isWebCodecsSupported:si}=await Promise.resolve().then(()=>require("./PixiFrameExporter-DKN__2tw.cjs"));if(!si())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Jt=new AbortController;const Uo={width:fe,height:Ae,fps:ht,trimStart:me,signal:Jt.signal};re!==void 0&&(Uo.trimEnd=re),j&&(Uo.onProgress=j);const os=Rt.value;os!==""&&(Uo.sourceUrl=os);const Md=typeof Ot.duration=="number"&&Ot.duration>0?Ot.duration:((Mn=b.source)==null?void 0:Mn.duration)??re??0,Bd=await Yn({captureFrameAt:ci=>Ot.captureFrameAt(ci),duration:{value:Md}},Uo),li=new File([Bd],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),Fd=hd(Ot),Id=((on=b.source)==null?void 0:on.duration)??0,Rd=Math.max(0,(re??Fd??Id)-me);return{file:li,recipe:b,meta:{duration:Rd,width:fe,height:Ae,format:"mp4",sizeBytes:li.size,size_bytes:li.size}}}finally{E.value=!1,Jt=null}}async function vd(b,V){var on;tn(),Ct=!1,Jt=null,Tt.value=null,je.value=null,Gt.value=!1,Xe.value=0;const j=Jn(b??J()),q=ts(j),me=Array.isArray(q.filters)&&q.filters.length>0,re=ai(q);if(!(pe.value||me||re))return he(),i("video-exported",null),null;const Ae=q.timeline[0],ht=Ae?Math.max(0,Ae.sourceIn):0,At=((Ae==null?void 0:Ae.sourceOut)??((on=q.source)==null?void 0:on.duration)??$t.value)-ht,Mn=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&At>o.clientExportThreshold;if(Mn){nt.value=!0;try{return await gd(q),null}catch(ot){const st=ot instanceof Error?ot.message:"Server render failed";throw je.value=st,i("server-render-failed",st),ot}finally{nt.value=!1}}if(o.maxDuration>0&&At>o.maxDuration&&!Mn){const ot=`This video is too long for in-browser export (${Math.round(At)}s). Server rendering is not available. Try a shorter clip.`;return je.value=ot,i("video-exported",null),null}nt.value=!0;try{const ot=await Gr(q,V,st=>{Ct||(Xe.value=st)});return Ct?(je.value="Export canceled.",Xe.value=0,i("video-exported",null),null):(he(),i("recipe-generated",q),i("video-exported",ot),Xe.value=100,Gt.value=!0,ot)}catch(ot){if(Ct)return je.value="Export canceled.",Xe.value=0,i("video-exported",null),null;const st=ot instanceof Error?ot.message:"Local WebGL export failed.";throw je.value=st,new Error(`Video export failed: ${st}`)}finally{nt.value=!1}}function Do(){return new kr(o.serverRenderEndpoint??"/api/v1")}async function gd(b){const V=Do();je.value="Starting server render...",Xe.value=0;const j=await V.createRenderJob({source_media_uuid:s.value,recipe:b});Tt.value=j.id,i("server-render-started",j.id),i("export-started",j.id),je.value="Rendering on server...";const q=await V.pollRenderJob(j.id,(re,fe)=>{Xe.value=re,fe==="processing"&&(je.value=`Server rendering: ${re}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);Xe.value=100,Gt.value=!0,je.value="Server render complete!",he(),i("recipe-generated",b);const me={id:q.id};typeof q.output_media_id=="string"&&q.output_media_id!==""&&(me.output_media_id=q.output_media_id),i("server-render-completed",me)}async function Jr(){if(!nt.value)return;Ct=!0,E.value=!1,Jt&&(Jt.abort(),Jt=null),tn();const b=Tt.value;if(b)try{await Do().cancelJob(b)}catch(V){const j=V instanceof Error?V.message:"Failed to cancel export";je.value=j,nt.value=!1,Tt.value=null;return}nt.value=!1,Xe.value=0,Gt.value=!1,Tt.value=null,je.value="Export canceled."}async function Yr(b){tn(),Ct=!1,Jt=null,Tt.value=null,je.value=null,Gt.value=!1,nt.value=!0,Xe.value=0;try{const V=Jn(ud(J(),b));i("recipe-generated",V);const j=s.value.startsWith("temp-"),q=V.timeline[0],me=Array.isArray(q==null?void 0:q.filters)?q.filters:[],re=!0,fe=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(re)try{const st=await Gr(V,b,si=>{Ct||(Xe.value=si)});if(Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0;return}i("video-exported",st);const Ot=URL.createObjectURL(st.file),Yn=document.createElement("a");Yn.href=Ot,Yn.download=`edited-video-${Date.now()}.mp4`,Yn.click(),setTimeout(()=>URL.revokeObjectURL(Ot),100),nt.value=!1,Xe.value=100,Gt.value=!0;return}catch(st){if(Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0;return}if(j||!fe)throw st;Xe.value=0,je.value="Local filter export failed, falling back to server render."}const Ae={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},ht=(b==null?void 0:b.quality)??V.output.quality,Yt=Ae[ht]??"high",At={...pd(V),export:{format:(b==null?void 0:b.format)??V.output.format,quality:Yt,resolution:ht,framerate:V.output.fps}},on=await Do().createJob({source_media_id:s.value,recipe:At}),ot=typeof on.id=="string"?on.id:null;if(!ot)throw new Error("Export failed: missing job id");Tt.value=ot,i("export-started",ot),_d(ot)}catch(V){if(E.value=!1,Jt=null,Ct){je.value="Export canceled.",nt.value=!1,Xe.value=0,Tt.value=null;return}try{const j=Jn(J()),q=new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),me=URL.createObjectURL(q),re=document.createElement("a");re.href=me,re.download=`video-recipe-${Date.now()}.json`,re.click(),setTimeout(()=>URL.revokeObjectURL(me),100)}finally{nt.value=!1,Xe.value=0,Tt.value=null,je.value=V instanceof Error?V.message:"Export failed"}}}const ni=async b=>{await new Promise(V=>{window.setTimeout(V,b)})},oi=b=>{if(!b||b.width<=0||b.height<=0)return null;try{return b.toDataURL("image/jpeg",.85)}catch{return null}},yd=b=>{if(!b||typeof b!="object")return null;const j=b.pixiCanvas;if(j&&typeof j=="object"&&"value"in j){const q=j.value;return q instanceof HTMLCanvasElement?q:null}return j instanceof HTMLCanvasElement?j:null},wd=b=>{if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const j=V.value;if(typeof j=="number"&&Number.isFinite(j))return j}return null},bd=b=>{if(!b||typeof b!="object")return null;const j=b.videoElement;if(j&&typeof j=="object"&&"value"in j){const q=j.value;return q instanceof HTMLVideoElement?q:null}return j instanceof HTMLVideoElement?j:null},Kr=b=>typeof b.params=="object"&&b.params!==null?b.params:{},kd=b=>{const V=[];for(const j of b){const q=Kr(j),me=j.filterId.trim().toLowerCase();if(me==="brightness"){const fe=(Ge(dt(q,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${fe.toFixed(2)}%)`);continue}if(me==="contrast"){const re=Ge(dt(q,["value","contrast"],1),.1,4);V.push(`contrast(${(re*100).toFixed(2)}%)`);continue}if(me==="saturation"||me==="saturate"){const re=Ge(dt(q,["value","saturation"],1),0,4);V.push(`saturate(${(re*100).toFixed(2)}%)`);continue}if(me==="grayscale"){V.push("grayscale(100%)");continue}if(me==="sepia"){V.push("sepia(100%)");continue}if(me==="blur"||me==="gaussian-blur"||me==="kawase-blur"){const re=Ge(dt(q,["value","blur","radius"],0),0,30);re>.01&&V.push(`blur(${re.toFixed(2)}px)`);continue}if(me==="adjustment"){const re=dt(q,["brightness"],1),fe=dt(q,["contrast"],1),Ae=dt(q,["saturation"],1);Math.abs(re-1)>.01&&V.push(`brightness(${(Ge(re,0,5)*100).toFixed(2)}%)`),Math.abs(fe-1)>.01&&V.push(`contrast(${(Ge(fe,.1,5)*100).toFixed(2)}%)`),Math.abs(Ae-1)>.01&&V.push(`saturate(${(Ge(Ae,0,5)*100).toFixed(2)}%)`);continue}if(me==="cinematic"){V.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(me==="dramatic"){V.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(me==="dreamy"){V.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return V.join(" ")},xd=b=>{const V=b.find(me=>me.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const j=Kr(V),q=dt(j,["noise","value","amount","intensity"],.2);return q<=1?Ge(q,0,1):Ge(q/100,0,1)},Ed=(b,V,j,q)=>{if(q<=0)return;const me=b.getImageData(0,0,V,j),re=255*q;for(let fe=0;fe<me.data.length;fe+=4){const Ae=(Math.random()*2-1)*re;me.data[fe]=Ge(me.data[fe]+Ae,0,255),me.data[fe+1]=Ge(me.data[fe+1]+Ae,0,255),me.data[fe+2]=Ge(me.data[fe+2]+Ae,0,255)}b.putImageData(me,0,0)},qr=async b=>{b.readyState>=2&&b.videoWidth>0&&b.videoHeight>0||await new Promise(V=>{let j=!1,q=0;const me=()=>{j||(j=!0,b.removeEventListener("loadedmetadata",re),b.removeEventListener("loadeddata",re),b.removeEventListener("canplay",re),window.clearTimeout(q),V())},re=()=>{me()};b.addEventListener("loadedmetadata",re),b.addEventListener("loadeddata",re),b.addEventListener("canplay",re),q=window.setTimeout(()=>me(),800),b.play().catch(()=>{})})},Vd=async(b,V)=>{await new Promise(j=>{let q=!1,me=0;const re=()=>{q||(q=!0,b.removeEventListener("seeked",fe),window.clearTimeout(me),j())},fe=()=>{re()};if(Math.abs(b.currentTime-V)<.016){requestAnimationFrame(()=>re());return}b.addEventListener("seeked",fe),me=window.setTimeout(()=>re(),700),b.currentTime=V})},Qr=async(b,V)=>{await qr(b);const j=Math.floor(b.videoWidth),q=Math.floor(b.videoHeight);if(j<=0||q<=0)return null;const me=Number.isFinite(b.duration)&&b.duration>0?b.duration:0,re=me>0?Ge(V,0,me):0;await Vd(b,re);const fe=document.createElement("canvas");fe.width=j,fe.height=q;const Ae=fe.getContext("2d");if(!Ae)return null;const ht=kd(et.value);ht!==""&&(Ae.filter=ht);try{Ae.drawImage(b,0,0,j,q)}catch{return null}const Yt=xd(et.value);return Ed(Ae,j,q,Yt),oi(fe)},Sd=async(b,V)=>{const j=document.createElement("video");j.src=b,j.muted=!0,j.playsInline=!0,j.preload="auto",b.startsWith("blob:")||(j.crossOrigin="anonymous");try{return await qr(j),await Qr(j,V)}catch{return null}finally{j.pause(),j.removeAttribute("src"),j.load()}},Cd=async b=>{const V=T.value,j=oi(yd(V));if(j)return j;if(V!=null&&V.captureFrameAt)for(let re=0;re<4;re+=1){const fe=wd(V);if(fe!==null&&fe<=0&&re<2){await ni(80);continue}const Ae=await Promise.race([V.captureFrameAt(b),ni(450).then(()=>null)]),ht=oi(Ae);if(ht)return ht;await ni(80)}const q=bd(V);if(q){const re=await Qr(q,b);if(re)return re}const me=Ga.value.trim();if(me!==""){const re=await Sd(me,b);if(re)return re}return null},es=b=>b.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function ts(b){const V=es(et.value);if(!ai(b)&&V.length>0&&Array.isArray(b.timeline)&&b.timeline.length>0){const q=b.timeline[0];q&&(b.timeline=[{...q,filters:V},...b.timeline.slice(1)])}return b}const ai=b=>Array.isArray(b.timeline)?b.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,Nd=b=>{if(!b||typeof b!="object")return null;const V=b.posterFrame;if(typeof V!="string")return null;const j=V.trim();return j!==""?j:null};async function ii(){const b=Jn(ts(ie())),V=es(et.value),j=ai(b)||V.length>0,q=Nd(o.initialRecipe);if(j){const me=ee.value>0?ee.value:.1;try{const re=await Cd(me);re?b.posterFrame=re:q&&(b.posterFrame=q)}catch{q&&(b.posterFrame=q)}}else delete b.posterFrame;return he(),i("draft-saved",b),b}function ns(){_e()&&(Rr(),Ut())}async function _d(b){tn();const V=Do();Io=window.setInterval(async()=>{try{if(Ct){tn();return}const j=await V.getJob(b),q=Number(j.progress??0);if(Xe.value=Number.isFinite(q)?q:0,j.status==="completed"||j.status==="failed"||j.status==="cancelled")if(tn(),nt.value=!1,Tt.value=null,j.status==="completed")Xe.value=100,Gt.value=!0,je.value=null;else{const me=j.status==="cancelled"||typeof j.error_message=="string"&&/cancel/i.test(j.error_message);je.value=me?"Export canceled.":typeof j.error_message=="string"&&j.error_message.trim()!==""?j.error_message:"Export failed"}}catch(j){tn(),nt.value=!1,Tt.value=null,je.value=j instanceof Error?j.message:"Failed to check export progress"}},2e3)}function ri(){const b=Jn(J());try{const V=b.timeline??[]}catch{}x.value=b}let dn=null;function Ut(){dn&&clearTimeout(dn),dn=setTimeout(()=>{ri(),dn=null},200)}e.watch(()=>F.value,Ut,{deep:!0}),e.watch(()=>Y.value,b=>{if(A.value||!b)return;const V=(b==null?void 0:b.filters)??[];Uc(V)},{immediate:!0}),e.watch(()=>et.value,b=>{pt(b),Ut()},{deep:!0}),e.watch(()=>B.value,b=>{K(b),Ut()},{deep:!0}),e.watch(()=>U.value,b=>{const V=b.map(j=>({...j,source:typeof j.source=="string"?j.source:void 0}));de(V),Ut()},{deep:!0}),e.watch(()=>ee.value,Ut),n({saveDraft:ii,exportForUpload:vd}),ri(),e.onUnmounted(()=>{tn(),Ct=!0,dn&&(clearTimeout(dn),dn=null),h.value&&(h.value.destroy(),h.value=null),C.value=null,y.value=null,S.value=null});function Td(){gt||!Ya.value||(gt=new wg({filters:Gn.value,callbacks:{onApplyFilter:b=>{Hn(b.id)},onRemoveFilter:b=>{$r(b)},onUpdateParam:(b,V,j)=>{Pr(b,V,j)},onPreviewFilter:b=>{Fr(b.id)}}}),gt.mount(Ya.value),gt.setActiveFilters(Ha.value))}e.watch(Ha,b=>{gt==null||gt.setActiveFilters(b)},{deep:!0}),e.watch(Gn,b=>{gt==null||gt.setFilters(b)});let nn=null;return e.onMounted(()=>{window.addEventListener("resize",H);const b=()=>{!_n.value||nn||(nn=new ResizeObserver(V=>{V[0]&&(Ro.value=Math.round(V[0].contentRect.width))}),nn.observe(_n.value))};b(),nn||e.nextTick(b),c.value&&(ei(),Dt||e.nextTick(ei)),o.media&&ri(),c.value&&e.nextTick(()=>{Td()}),e.nextTick(()=>{const V=document.querySelector(".video-editor");V&&V.getBoundingClientRect();const j=document.querySelector(".mobile-layout");j&&j.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",H),nn==null||nn.disconnect(),nn=null,Dt==null||Dt(),Dt=null,gt==null||gt.destroy(),gt=null}),(b,V)=>{var j,q,me,re;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:c.value}])},[c.value?(e.openBlock(),e.createElementBlock("div",pw,[e.createElementVNode("div",fw,[e.createElementVNode("div",hw,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ne)}]),onClick:V[0]||(V[0]=(...fe)=>e.unref(Q)&&e.unref(Q)(...fe)),"aria-label":e.unref(ne)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ne)?e.unref(ml):e.unref(fl)},null,8,["icon"])],10,vw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:ns,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln)},null,8,["icon"])])]),e.createElementVNode("div",gw,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:ii,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(pe)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(er)},null,8,["icon"]),V[12]||(V[12]=e.createElementVNode("span",null,"Save",-1))],8,yw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[1]||(V[1]=fe=>Yr()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:nt.value||!e.unref(pe)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vo)},null,8,["icon"])],8,ww),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[2]||(V[2]=fe=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Dn)},null,8,["icon"])])])]),e.createElementVNode("div",bw,[e.withDirectives(e.createVNode(ms,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!f.value,class:"preview-host-child",source:Ga.value,"fallback-duration":$t.value,filters:Ar.value,playhead:Or.value,"is-playing":e.unref(ne),"fit-mode":D.value,active:f.value,onPlayPause:e.unref(Q),onFrameUpdate:Wr,onDurationChange:$o},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Bs,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Dr.value,"enable-engine":p.value&&Ur.value,"fit-mode":D.value,onTimeUpdate:jr,onPlayStateChange:Zr,onDurationChange:$o,onEngineReady:Hr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),nt.value?(e.openBlock(),e.createElementBlock("div",kw,[e.createElementVNode("div",xw,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Xe.value)+"%",1),e.createElementVNode("div",Ew,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Xe.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Jr},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:_n,class:"timeline-section"},[e.createElementVNode("div",Vw,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:Ka,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...V[13]||(V[13]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512),e.createElementVNode("button",{ref_key:"mobileZoomInButtonRef",ref:qa,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...V[14]||(V[14]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8M8 4v8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512)]),e.createVNode(Fs,{playhead:e.unref(ee),clips:e.unref(F),"selected-clip-id":((j=e.unref(Y))==null?void 0:j.id)??((q=e.unref(F)[0])==null?void 0:q.id)??null,duration:$t.value,"zoom-level":e.unref(Me),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(xe),onTrim:e.unref(se),onSplit:e.unref(ke),onClipSelect:e.unref(oe),onClipMove:e.unref(He)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])],512),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Ya,class:"controls-section mobile-controls"},null,512)])):(e.openBlock(),e.createElementBlock("div",Sw,[e.createElementVNode("div",Cw,[e.createElementVNode("div",Nw,[e.createElementVNode("div",_w,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[3]||(V[3]=fe=>D.value=fe),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...V[15]||(V[15]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,D.value]])])]),e.withDirectives(e.createVNode(ms,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!f.value,class:"preview-host-child",source:Ga.value,"fallback-duration":$t.value,filters:Ar.value,playhead:Or.value,"is-playing":e.unref(ne),"fit-mode":D.value,active:f.value,onPlayPause:e.unref(Q),onFrameUpdate:Wr,onDurationChange:$o},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Bs,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Dr.value,"enable-engine":p.value&&Ur.value,"fit-mode":D.value,onTimeUpdate:jr,onPlayStateChange:Zr,onDurationChange:$o,onEngineReady:Hr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),b.showThumbnailPicker?(e.openBlock(),e.createBlock(H0,{key:0,"media-uuid":s.value,duration:$t.value,onSelect:dd},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Tw,[e.createElementVNode("div",Mw,[e.createElementVNode("div",Bw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,fe=>(e.openBlock(),e.createElementBlock("button",{key:fe.id,class:e.normalizeClass(["tab-btn",{active:d.value===fe.id}]),onClick:Ae=>d.value=fe.id},e.toDisplayString(fe.label),11,Fw))),128))]),e.createElementVNode("div",Iw,[e.withDirectives(e.createElementVNode("div",Rw,[e.createVNode(a0,{filters:Gn.value,"active-filters":Ha.value,"thumbnail-url":Oc.value,onApplyFilter:Hn,onRemoveFilter:$r,onUpdateParam:Pr,onPreviewFilter:Yc},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",$w,[e.createVNode(f1,{overlays:B.value,onAddOverlay:qc,onUpdateOverlay:Qc,onRemoveOverlay:ed},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",Dw,[e.createVNode(D1,{"selected-clips":_.value,"applied-transitions":R.value,onApplyTransition:td,onRemoveTransition:nd,onPreviewTransition:od},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",Uw,[e.createVNode(gg,{"audio-layers":U.value,"master-volume":z.value,onAddTrack:ad,onUpdateTrack:id,onRemoveTrack:rd,onUpdateVolume:sd,onToggleMute:ld,onUpdateMasterVolume:cd},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Aw,[e.unref(Br)?(e.openBlock(),e.createBlock(g0,{key:0,filter:e.unref(Br),"current-frame":e.unref(Ne),onUpdateParams:Kc},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",Ow,[...V[16]||(V[16]=[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",Lw,[e.createVNode(F0,{"can-export":e.unref(pe),"is-exporting":nt.value,"export-progress":Xe.value,onExport:Yr,onCancelExport:Jr,onSaveDraft:ii,onReset:ns},null,8,["can-export","is-exporting","export-progress"]),Gt.value?(e.openBlock(),e.createElementBlock("div",zw," Export complete ")):e.createCommentVNode("",!0),je.value&&!Gt.value?(e.openBlock(),e.createElementBlock("div",Pw,e.toDisplayString(je.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",jw,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:_n,class:"timeline-container"},[e.createElementVNode("div",Ww,[e.createElementVNode("label",null,[V[17]||(V[17]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(Me),onInput:V[4]||(V[4]=fe=>Jc(fe))},null,40,Zw)]),e.createElementVNode("span",Xw,e.toDisplayString(Math.round(e.unref(Me)))+" px/s",1)]),e.createVNode(Fs,{playhead:e.unref(ee),clips:e.unref(F),"selected-clip-id":((me=e.unref(Y))==null?void 0:me.id)??((re=e.unref(F)[0])==null?void 0:re.id)??null,duration:$t.value,"zoom-level":e.unref(Me),sensitivity:.25,"onUpdate:playhead":e.unref(xe),onTrim:e.unref(se),onSplit:e.unref(ke),onClipSelect:e.unref(oe),onClipMove:e.unref(He)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(wv,{"selected-clip":e.unref(Y),"can-split":Lc.value,"can-delete":zc.value,"is-playing":e.unref(ne),"zoom-level":e.unref(Me),"playback-speed":e.unref(ce),onSplit:e.unref(le),onDelete:e.unref(Ee),onDuplicate:e.unref(Se),onZoomIn:Hc,onZoomOut:Gc,onZoomChange:Qa,onFitToWindow:Xc,onPlayPause:e.unref(Q),onFrameForward:e.unref(De),onFrameBackward:e.unref(Qe),onSkipToStart:e.unref(We),onSkipToEnd:e.unref(ft),onSpeedChange:e.unref(Ze)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),ge.value?(e.openBlock(),e.createElementBlock("div",Hw,[e.createElementVNode("div",Gw,[e.createElementVNode("label",Jw,[V[18]||(V[18]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[5]||(V[5]=fe=>Cn.value=fe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Cn.value]])]),e.createElementVNode("label",Yw,[V[19]||(V[19]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[6]||(V[6]=fe=>Nn.value=fe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Nn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(Y),onClick:V[7]||(V[7]=fe=>zr("start"))}," Start = Playhead ",8,Kw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(Y),onClick:V[8]||(V[8]=fe=>zr("end"))}," End = Playhead ",8,qw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(Y),onClick:jc}," Apply Trim ",8,Qw)]),e.createElementVNode("div",eb,[e.createElementVNode("label",tb,[V[20]||(V[20]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[9]||(V[9]=fe=>en.value=fe),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Gn.value,fe=>(e.openBlock(),e.createElementBlock("option",{key:fe.id,value:fe.id},e.toDisplayString(fe.name),9,nb))),128))],512),[[e.vModelSelect,en.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(Y)||en.value==="",onClick:Wc}," Apply Filter ",8,ob),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(et).length===0,onClick:Zc}," Clear Filters ",8,ab),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(Y),onClick:V[10]||(V[10]=fe=>Hn("noise"))}," QA: Noise ",8,ib),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(Y),onClick:V[11]||(V[11]=fe=>Hn("grayscale"))}," QA: Grayscale ",8,rb)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Ji=Be(sb,[["__scopeId","data-v-6e81b19f"]]),Ft=a=>a===null||typeof a!="object"||Array.isArray(a)?null:a,Oe=a=>{if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const n=Number(a);return Number.isFinite(n)?n:null}return null},lb=(a,n)=>{if(n===null)return;const t=Ft(a.source)??{},o=Oe(t.duration);if(!(o!==null&&o>0&&o<=1&&n>o))return;t.duration=n,a.source=t;const r=Array.isArray(a.timeline)?a.timeline:[];if(r.length===1){const l=Ft(r[0]);if(l!==null){const d=Oe(l.sourceIn)??0,u=Oe(l.sourceOut)??Oe(l.end)??Oe(l.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){l.sourceOut=n;const f=Oe(l.end);f!==null&&f>0&&f<=1&&(l.end=n);const p=Oe(l.timelineEnd);p!==null&&p>0&&p<=1&&(l.timelineEnd=n)}}}const s=Oe(a.trimEnd)??Oe(a.trim_end);s!==null&&s>0&&s<=1&&(a.trimEnd=n);const c=Ft(a.trim);if(c!==null){const l=Oe(c.end);l!==null&&l>0&&l<=1&&(c.end=n,a.trim=c)}},cb=(a,n)=>{if(!a)return!1;const t=Ft(a);if(t===null)return!1;const o=Ft(t.trim),i=Ft(t.source),s=Oe(i==null?void 0:i.duration)??n,c=Array.isArray(a.filters)&&a.filters.length>0;let l=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(l=!0)}let d=!1;const u=Oe(t.trimStart)??Oe(t.trim_start)??Oe(o==null?void 0:o.start),m=Oe(t.trimEnd)??Oe(t.trim_end)??Oe(o==null?void 0:o.end);if(u!==null&&u>0&&(d=!0),m!==null&&s!==void 0&&m<s&&(d=!0),!d&&Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const v=Oe(p.sourceIn),g=Oe(p.sourceOut);v!==null&&v>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let f=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const v=Oe(p.speed);f=v!==null&&v!==1}}return c||l||d||f},xc=a=>{if(!a)return!1;const n=Ft(a);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(a.timeline)&&a.timeline.length>1)},db=(a,n={})=>{var f,p;const t=JSON.parse(JSON.stringify(a)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?Ft(o[0]):null,r=Array.isArray(i==null?void 0:i.filters)?i.filters:[],s=Array.isArray(t.filters)?t.filters:[];if(s.length>0?t.filters=s:t.filters=r,o.length===1&&i!==null){const v=Oe(i.sourceIn),g=Oe(i.sourceOut);v!==null&&t.trimStart===void 0&&(t.trimStart=v),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const c=Ft(t.trim);if(t.trimStart===void 0){const v=Oe(c==null?void 0:c.start);v!==null&&(t.trimStart=v)}if(t.trimEnd===void 0){const v=Oe(c==null?void 0:c.end);v!==null&&(t.trimEnd=v)}const l=Ft(t.source),d=Oe(t.width)??Oe(l==null?void 0:l.original_width)??Oe((f=n.exportMeta)==null?void 0:f.width);d!==null&&(t.width=d);const u=Oe(t.height)??Oe(l==null?void 0:l.original_height)??Oe((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Ft(t.output);return t.fps=Oe(t.fps)??Oe(m==null?void 0:m.fps)??30,lb(t,n.mediaDuration??null),t},ub={key:0},mb=["data-testid"],pb={class:"ve-mobile-header"},fb=["data-testid","disabled"],hb={class:"ve-mobile-title"},vb=["data-testid","disabled"],gb={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},yb={class:"ve-body"},wb=["data-testid"],bb=["aria-label"],kb={class:"ve-header"},xb={class:"ve-title"},Eb=["data-testid","disabled"],Vb={class:"ve-body"},Sb={class:"ve-footer"},Cb=["data-testid","disabled"],Nb=["data-testid","disabled"],_b=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),c=e.computed(()=>o.saveImmediate===!1),l=e.computed(()=>o.closeText),d=e.computed(()=>m.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),m=e.ref(!1),f=e.ref(!1),p=e.ref(null),v=`temp-${Date.now()}`,g=e.computed(()=>{var z;const _=(z=o.featureFlags)==null?void 0:z.export;return typeof _=="boolean"?_:o.workflowMode==="full"}),E=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():v),T=e.computed(()=>{const _={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&(_.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&(_.initialRecipe=o.initialRecipe),o.media!==void 0&&(_.media=o.media),_}),N=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",N)}),e.onUnmounted(()=>{window.removeEventListener("resize",N)}),e.onErrorCaptured(()=>(f.value=!0,!1));const w=_=>{const z=Array.isArray(_.timeline)?_.timeline:[];if(z.length===0)return 0;let H=0;for(const M of z){const $=Number(M.sourceIn),X=Number(M.sourceOut),W=Number(M.speed??1),te=Number.isFinite(W)&&W>0?W:1;if(Number.isFinite($)&&Number.isFinite(X)&&X>$){H+=(X-$)/te;continue}const ge=Number(M.timelineStart),Ne=Number(M.timelineEnd);Number.isFinite(ge)&&Number.isFinite(Ne)&&Ne>ge&&(H+=Ne-ge)}return H},h=(_,z,H)=>{let M=null;const $=new Promise((X,W)=>{M=setTimeout(()=>W(new Error(`${H} timed out after ${z}ms`)),z)});return Promise.race([_,$]).finally(()=>{M!==null&&clearTimeout(M)})},x=()=>{var $;const H=($=o.media)==null?void 0:$.duration;if(typeof H!="number"||!Number.isFinite(H)||H<=0)return 12e3;const M=Math.round(H*1e3);return Math.min(45e3,Math.max(12e3,M))},D=()=>{i("close"),i("update:open",!1)},C=()=>{m.value||D()},y=_=>{i("recipe-generated",_)},S=_=>{i("export-started",_),i("save-started",_)},A=_=>{i("video-exported",_)},k=_=>{i("thumbnail-selected",_)},B=(_,z,H)=>{i("save-recipe",_);const M={recipe:_,exportPayload:z};H!==void 0&&(M.toastDescription=H),i("save-complete",M),D()},R=_=>{m.value||(i("draft-saved",_),B(_,null))},U=async()=>{var _;if(!m.value){if(f.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),D();return}m.value=!0;try{const z=await h(p.value.saveDraft(),x(),"saveDraft");let H=null,M=!1,$;const X=w(z),W=X>0?X:((_=o.media)==null?void 0:_.duration)??0;if(g.value&&W>0&&W<=o.clientExportThreshold&&typeof p.value.exportForUpload=="function"){M=!0;const ge=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{H=await h(p.value.exportForUpload(z),ge,"exportForUpload")}catch{H=null}}if(xc(z)&&H===null){i("save-error",{code:"unsupported-client-export-required",message:"These edits require in-browser export. Shorten the clip or remove text overlays, transitions, or extra clips and try again."});return}M&&H===null&&($="Video edits saved. Final render will happen when you share."),B(z,H,$)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),D()}finally{m.value=!1}}};return n({saveDraft:U}),(_,z)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",ub,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",pb,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,disabled:m.value,onClick:C},e.toDisplayString(l.value),9,fb),e.createElementVNode("h2",hb,e.toDisplayString(_.title),1),c.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-mobile-action ve-mobile-action--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:U},e.toDisplayString(d.value),9,vb)):(e.openBlock(),e.createElementBlock("span",gb))]),e.createElementVNode("section",yb,[e.createVNode(Ji,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":E.value},T.value,{onClose:C,onDraftSaved:R,onExportStarted:S,onRecipeGenerated:y,onThumbnailSelected:k,onVideoExported:A}),null,16,["media-uuid"])])],8,mb)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(C,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":_.title,"aria-modal":"true"},[e.createElementVNode("header",kb,[e.createElementVNode("h2",xb,e.toDisplayString(_.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,disabled:m.value,"aria-label":"Close",onClick:C}," ✕ ",8,Eb)]),e.createElementVNode("section",Vb,[e.createVNode(Ji,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":E.value},T.value,{onClose:C,onDraftSaved:R,onExportStarted:S,onRecipeGenerated:y,onThumbnailSelected:k,onVideoExported:A}),null,16,["media-uuid"])]),e.createElementVNode("footer",Sb,[e.renderSlot(_.$slots,"footer",{close:C,isSaving:m.value,save:U},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,disabled:m.value,onClick:C},e.toDisplayString(l.value),9,Cb),c.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:U},e.toDisplayString(d.value),9,Nb)):e.createCommentVNode("",!0)],!0)])],8,bb)],8,wb))])):e.createCommentVNode("",!0)]))}}),Tb=Be(_b,[["__scopeId","data-v-cdf43562"]]),Mb={class:"video-editor-modal"},Bb={class:"video-preview-container"},Fb=["src"],Ib={class:"video-overlay-controls"},Rb=["aria-label"],$b={class:"time-display"},Db={class:"timeline-container"},Ub={class:"clip-name"},Ab={class:"timeline-time-labels"},Ob={class:"tool-tabs"},Lb=["onClick"],zb={class:"tool-panel"},Pb={key:0,class:"trim-panel"},jb={class:"trim-controls"},Wb={key:1,class:"filters-panel"},Zb={class:"filter-grid"},Xb=["onClick"],Hb={key:2,class:"text-panel"},Gb={key:3,class:"transitions-panel"},Jb={class:"transition-grid"},Yb=["onClick"],Kb={class:"action-buttons"},qb=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),c=e.ref(0),l=e.ref(0),d=e.ref("video-1"),u=e.ref(0),m=e.ref(0),f=e.ref(null),p=e.ref("trim"),v=e.ref(null),g=e.ref(""),E=[{id:"trim",label:"Trim",icon:dl},{id:"filters",label:"Filters",icon:vu},{id:"text",label:"Text",icon:hl},{id:"transitions",label:"Transitions",icon:Vu}],T=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],N=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],w=e.ref();e.onMounted(()=>{var M,$;(M=t.media)!=null&&M.url?r.value=t.media.url:($=t.media)!=null&&$.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var M;(M=t.media)!=null&&M.file&&r.value&&URL.revokeObjectURL(r.value)});function h(){i.value&&(l.value=i.value.duration,m.value=l.value)}function x(){i.value&&(c.value=i.value.currentTime)}function D(){s.value=!1}function C(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function y(M){if(!M||isNaN(M))return"00:00";const $=Math.floor(M/60),X=Math.floor(M%60);return`${$.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`}function S(M){if(!i.value||!w.value)return;const $=w.value.getBoundingClientRect(),te=(M.clientX-$.left)/$.width*l.value;i.value.currentTime=Math.max(0,Math.min(te,l.value))}function A(){u.value=c.value}function k(){m.value=c.value}function B(){u.value=0,m.value=l.value}function R(M){f.value=M;const $=W=>{if(!f.value||!w.value)return;const te=w.value.getBoundingClientRect(),ee=(W.clientX-te.left)/te.width*l.value;f.value==="start"?u.value=Math.max(0,Math.min(ee,m.value-1)):m.value=Math.max(u.value+1,Math.min(ee,l.value))},X=()=>{f.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",X)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",X)}function U(M){if(v.value=M,!i.value)return;const $={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=$[M]||"none"}function _(){}function z(M){}function H(){const M={timeline:[{id:d.value,url:r.value,startTime:0,endTime:l.value,sourceIn:u.value,sourceOut:m.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:m.value-u.value};o("save",M)}return(M,$)=>(e.openBlock(),e.createElementBlock("div",Mb,[e.createElementVNode("div",Bb,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:h,onTimeupdate:x,onEnded:D,controls:""},null,40,Fb),e.createElementVNode("div",Ib,[e.createElementVNode("button",{class:"play-pause-btn",onClick:C,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:s.value?e.unref(_u):e.unref(Fu)},null,8,["icon"])],8,Rb),e.createElementVNode("div",$b,e.toDisplayString(y(c.value))+" / "+e.toDisplayString(y(l.value)),1)])]),e.createElementVNode("div",Db,[e.createElementVNode("div",{class:"timeline-track",onClick:S,ref_key:"timelineTrack",ref:w},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/l.value*100}%`,right:`${100-m.value/l.value*100}%`})},[e.createElementVNode("span",Ub,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${c.value/l.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/l.value*100}%`}),onMousedown:$[0]||($[0]=X=>R("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/l.value*100}%`}),onMousedown:$[1]||($[1]=X=>R("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",Ab,[e.createElementVNode("span",null,e.toDisplayString(y(0)),1),e.createElementVNode("span",null,e.toDisplayString(y(l.value)),1)])]),e.createElementVNode("div",Ob,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["tool-tab",{active:p.value===X.id}]),onClick:W=>p.value=X.id},[e.createVNode(e.unref(I.IonIcon),{icon:X.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(X.label),1)],10,Lb)),64))]),e.createElementVNode("div",zb,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",Pb,[$[7]||($[7]=e.createElementVNode("h3",null,"Trim Video",-1)),$[8]||($[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",jb,[e.createElementVNode("button",{class:"btn-trim",onClick:A},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ss)},null,8,["icon"]),$[4]||($[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ss)},null,8,["icon"]),$[5]||($[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:B},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Dn)},null,8,["icon"]),$[6]||($[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",Wb,[$[9]||($[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",Zb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(T,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["filter-option",{active:v.value===X.id}]),onClick:W=>U(X.id)},e.toDisplayString(X.name),11,Xb)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",Hb,[$[10]||($[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[2]||($[2]=X=>g.value=X),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:_},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",Gb,[$[11]||($[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Jb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(N,X=>e.createElementVNode("button",{key:X.id,class:"transition-option",onClick:W=>(X.id,void 0)},e.toDisplayString(X.name),9,Yb)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Kb,[e.createElementVNode("button",{class:"btn-cancel",onClick:$[3]||($[3]=X=>M.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:H},"SAVE")])]))}}),Qb=Be(qb,[["__scopeId","data-v-b933f33b"]]),e2={class:"time-label"},t2=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(a){const n=a,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),o=e.computed(()=>{const s=[],c=i(n.duration,n.zoom);for(let l=0;l<=n.duration;l+=c){const d=`${l/n.duration*100}%`,u=r(l),m=l%(c*5)===0;s.push({time:l,position:d,label:u,major:m})}return s});function i(s,c){const l=s/(10*c);return l<=1?1:l<=5?5:l<=10?10:l<=30?30:l<=60?60:Math.ceil(l/60)*60}function r(s){const c=Math.floor(s/60),l=Math.floor(s%60);return c===0?`${l}s`:l===0?`${c}m`:`${c}:${l.toString().padStart(2,"0")}`}return(s,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.time,class:"time-mark",style:e.normalizeStyle({left:l.position})},[e.createElementVNode("span",e2,e.toDisplayString(l.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:l.major}])},null,2)],4))),128))],4))}}),n2=Be(t2,[["__scopeId","data-v-0ef9c910"]]),o2=["data-track-index"],a2={class:"track-header"},i2={class:"track-label"},r2={class:"track-controls"},s2=["data-testid","aria-label"],l2=["data-testid","onMousedown","onClick"],c2={class:"clip-content"},d2={class:"clip-name"},u2={key:0,class:"clip-thumbnail"},m2=["src","alt"],p2=["onMousedown","aria-label"],f2=["onMousedown","aria-label"],h2=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),c=e.ref(null),l=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(E){const T=E.timelineEnd-E.timelineStart,N=E.timelineStart/t.duration*100,w=T/t.duration*100;return{left:`${N}%`,width:`${w}%`,backgroundColor:u(E)}}function u(E){const T=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],N=parseInt(E.id.replace(/\D/g,""))%T.length;return T[N]}function m(E){return E.label?E.label:E.url?(E.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${E.id.slice(-4)}`}function f(E){i.value=E.id,o("clip-select",E.id)}function p(){r.value=!r.value}function v(E,T){if(c.value)return;s.value=!0;const N=T.clientX,w=E.timelineStart,h=D=>{if(!s.value)return;const C=D.clientX-N,y=parseFloat(l.value.width),S=C/(t.zoom*100)*(t.duration/y),A=Math.max(0,w+S);o("clip-move",E.id,A)},x=()=>{s.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",x)}function g(E,T,N){c.value=T;const w=N.clientX,h=E.sourceIn,x=E.sourceOut,D=y=>{if(!c.value)return;const S=y.clientX-w,A=parseFloat(l.value.width),k=S/(t.zoom*100)*(t.duration/A);if(c.value==="start"){const B=Math.max(0,h+k);o("clip-trim",E.id,B,x)}else{const B=Math.max(h+1,x+k);o("clip-trim",E.id,h,B)}},C=()=>{c.value=null,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",C)}return(E,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":E.trackIndex},[e.createElementVNode("div",a2,[e.createElementVNode("span",i2,"Track "+e.toDisplayString(E.trackIndex+1),1),e.createElementVNode("div",r2,[E.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${E.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${E.trackIndex+1}`,onClick:p},[e.createVNode(e.unref(I.IonIcon),{icon:r.value?e.unref(Hu):e.unref(Zu)},null,8,["icon"])],8,s2)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(l.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.clips,N=>(e.openBlock(),e.createElementBlock("div",{key:N.id,class:e.normalizeClass(["timeline-clip",{selected:N.id===i.value}]),style:e.normalizeStyle(d(N)),"data-testid":`clip-${N.id}`,onMousedown:w=>v(N,w),onClick:w=>f(N)},[e.createElementVNode("div",c2,[e.createElementVNode("span",d2,e.toDisplayString(m(N)),1),N.thumbnail?(e.openBlock(),e.createElementBlock("div",u2,[e.createElementVNode("img",{src:N.thumbnail,alt:m(N)},null,8,m2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(w=>g(N,"start",w),["stop"]),"aria-label":`Trim start of ${m(N)}`},null,40,p2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(w=>g(N,"end",w),["stop"]),"aria-label":`Trim end of ${m(N)}`},null,40,f2)],46,l2))),128))],4)],8,o2))}}),v2=Be(h2,[["__scopeId","data-v-48e480d2"]]),g2={class:"video-timeline"},y2={class:"timeline-tracks"},w2=["aria-label","aria-valuenow","aria-valuemax"],b2={class:"timeline-controls"},k2={class:"zoom-level"},x2=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),c=e.ref(),l=e.computed(()=>{const w=Math.max(0,...t.clips.map(h=>h.track||0));return Array(w+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(w){return t.clips.filter(h=>(h.track||0)===w)}function m(w){const h=Math.floor(w/60),x=Math.floor(w%60);return`${h}:${x.toString().padStart(2,"0")}`}function f(w,h){o("clip-move",w,h)}function p(w,h,x){o("clip-trim",w,h,x)}function v(w){r.value=w}function g(){i.value=Math.min(i.value*1.2,5)}function E(){i.value=Math.max(i.value/1.2,.5)}function T(){s.value=!0;const w=x=>{if(!s.value||!c.value)return;const D=c.value.getBoundingClientRect(),S=Math.max(0,Math.min(x.clientX-D.left,D.width))/D.width*t.duration;o("seek",S)},h=()=>{s.value=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",h)}function N(w){let h=t.currentTime;switch(w.key){case"ArrowLeft":h=Math.max(0,t.currentTime-1);break;case"ArrowRight":h=Math.min(t.duration,t.currentTime+1);break;case"Home":h=0;break;case"End":h=t.duration;break;default:return}w.preventDefault(),o("seek",h)}return e.onMounted(()=>{c.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(w,h)=>(e.openBlock(),e.createElementBlock("div",g2,[e.createVNode(n2,{duration:w.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",y2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(x,D)=>(e.openBlock(),e.createBlock(v2,{key:`track-${D}`,"data-testid":`track-${D}`,clips:u(D),"track-index":D,zoom:i.value,duration:w.duration,onClipMove:f,onClipTrim:p,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:T,"data-testid":"playhead","aria-label":`Playhead at ${m(w.currentTime)}`,role:"slider","aria-valuenow":w.currentTime,"aria-valuemax":w.duration,tabindex:"0",onKeydown:N},null,44,w2),e.createElementVNode("div",b2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qi)},null,8,["icon"])]),e.createElementVNode("span",k2,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:E},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Au)},null,8,["icon"])])])]))}}),E2=Be(x2,[["__scopeId","data-v-001df415"]]),V2={class:"video-filters-panel"},S2={class:"filter-controls"},C2=["for"],N2={class:"filter-slider-group"},_2=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],T2={class:"filter-value"},M2={class:"filter-actions"},B2={key:0,class:"filter-presets"},F2={class:"preset-list"},I2=["data-testid","aria-label","onClick"],R2=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(a,{emit:n}){const t=n,o=[{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}],i=e.reactive(o.reduce((f,p)=>(f[p.type]=p.default,f),{})),r=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(f,p){switch(f){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function c(f){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(f)}function l(f){if(!c(f))return;const p={id:`filter-${f}`,filterId:f,params:{value:i[f]},intensity:1};t("filter-change",p)}function d(){o.forEach(f=>{i[f.type]=f.default,l(f.type)})}function u(){const f=prompt("Enter preset name:");if(!f)return;const p={id:`custom-${Date.now()}`,name:f,values:{...i}};r.value.push(p)}function m(f){Object.entries(f.values).forEach(([p,v])=>{i[p]=v,l(p)})}return(f,p)=>(e.openBlock(),e.createElementBlock("div",V2,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",S2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,C2),e.createElementVNode("div",N2,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":g=>i[v.type]=g,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":i[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:g=>l(v.type)},null,40,_2),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",T2,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",M2,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:d},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(er)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",B2,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",F2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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:g=>m(v)},e.toDisplayString(v.name),9,I2))),128))])])):e.createCommentVNode("",!0)]))}}),$2=Be(R2,[["__scopeId","data-v-5ad2ac63"]]),D2={class:"video-text-panel"},U2={class:"text-input-group"},A2={class:"text-options"},O2={class:"option-row"},L2={class:"option-row"},z2={class:"option-row"},P2={class:"option-row"},j2={class:"checkbox-label"},W2={class:"option-row"},Z2={class:"text-overlay-list"},X2={key:0,class:"empty-state"},H2=["data-testid"],G2={class:"overlay-preview"},J2={class:"overlay-controls"},Y2=["data-testid","aria-label","onClick"],K2=["data-testid","aria-label","onClick"],q2=["data-testid","aria-label","onClick"],Q2=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const d={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(m=>m.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function c(d){i.text=d.text,i.fontFamily=d.fontFamily||"Arial",i.fontSize=d.fontSize,i.color=d.color,i.backgroundColor=d.backgroundColor||"#000000",i.hasBackground=!!d.backgroundColor,i.animation=d.animation||"none",s(d.id)}function l(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};o.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",D2,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",U2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=m=>i.text=m),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qi)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",A2,[e.createElementVNode("div",O2,[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]=m=>i.fontFamily=m),"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,i.fontFamily]])]),e.createElementVNode("div",L2,[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]=m=>i.fontSize=m),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",z2,[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]=m=>i.color=m),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",P2,[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]=m=>i.backgroundColor=m),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",j2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=m=>i.hasBackground=m),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",W2,[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]=m=>i.animation=m),"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,i.animation]])])]),e.createElementVNode("div",Z2,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",X2," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(m,f)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${f}`},[e.createElementVNode("div",G2,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:m.fontFamily,fontSize:`${Math.min(m.fontSize/4,16)}px`,color:m.color})},e.toDisplayString(m.text),5)]),e.createElementVNode("div",J2,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${f}`,"aria-label":`Edit overlay: ${m.text}`,onClick:p=>c(m)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(wu)},null,8,["icon"])],8,Y2),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${f}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:p=>l(m)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(yu)},null,8,["icon"])],8,K2),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${f}`,"aria-label":`Remove overlay: ${m.text}`,onClick:p=>s(m.id)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(zu)},null,8,["icon"])],8,q2)])],8,H2))),128))])]))}}),ek=Be(Q2,[["__scopeId","data-v-4d240e1e"]]),tk={class:"video-tools-panel"},nk={class:"tool-tabs"},ok=["data-testid","aria-label","aria-selected","onClick"],ak={class:"tool-content"},ik={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},rk={class:"trim-actions"},sk={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},lk={class:"transition-types"},ck=["data-testid","aria-label","onClick"],dk={class:"transition-preview"},uk=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(a){const n=[{id:"trim",name:"Trim",icon:dl},{id:"filters",name:"Filters",icon:sn},{id:"text",name:"Text",icon:hl},{id:"transitions",name:"Transitions",icon:ds}],t=[{id:"fade",name:"Fade",icon:mi},{id:"slide-left",name:"Slide Left",icon:uu},{id:"slide-right",name:"Slide Right",icon:mu},{id:"dissolve",name:"Dissolve",icon:mi},{id:"wipe",name:"Wipe",icon:ds},{id:"zoom",name:"Zoom",icon:mi}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",tk,[e.createElementVNode("div",nk,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:o.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":o.activeTool===r.id,role:"tab",onClick:s=>o.$emit("tool-change",r.id)},[e.createVNode(e.unref(I.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,ok)),64))]),e.createElementVNode("div",ak,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",ik,[i[8]||(i[8]=e.createElementVNode("h3",null,"Trim Video",-1)),i[9]||(i[9]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",rk,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:i[0]||(i[0]=r=>o.$emit("trim-set-start"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ls)},null,8,["icon"]),i[5]||(i[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:i[1]||(i[1]=r=>o.$emit("trim-set-end"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ls)},null,8,["icon"]),i[6]||(i[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:i[2]||(i[2]=r=>o.$emit("trim-clear"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Dn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock($2,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(ek,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",sk,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",lk,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,r=>e.createElementVNode("button",{key:r.id,class:"transition-btn","data-testid":`transition-${r.id}`,"aria-label":`Add ${r.name} transition`,onClick:s=>o.$emit("transition-add",r.id)},[e.createElementVNode("div",dk,[e.createVNode(e.unref(I.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,ck)),64))])])):e.createCommentVNode("",!0)])]))}}),mk=Be(uk,[["__scopeId","data-v-fc135306"]]),pk={class:"video-export-panel"},fk={class:"export-presets"},hk=["value"],vk={key:0,class:"preset-details"},gk={class:"detail-row"},yk={class:"detail-row"},wk={class:"detail-row"},bk={class:"advanced-options"},kk={class:"options-content"},xk={class:"option-group"},Ek={class:"option-group"},Vk={class:"option-group"},Sk=["disabled"],Ck={key:1,class:"export-progress"},Nk={class:"progress-message"},_k={class:"progress-bar"},Tk=["aria-valuenow"],Mk={class:"progress-percentage"},Bk=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===i.value)),c=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 l(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",pk,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",fk,[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]=m=>i.value=m),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,m=>(e.openBlock(),e.createElementBlock("option",{key:m.id,value:m.id},e.toDisplayString(m.name),9,hk))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",vk,[e.createElementVNode("div",gk,[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",yk,[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",wk,[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",bk,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",kk,[e.createElementVNode("div",xk,[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]=m=>r.quality=m),"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,r.quality]])]),e.createElementVNode("div",Ek,[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]=m=>r.bitrate=m),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",Vk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=m=>r.includeAudio=m),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.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:l},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vo)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,Sk),d.isExporting?(e.openBlock(),e.createElementBlock("div",Ck,[e.createElementVNode("div",Nk,e.toDisplayString(c.value),1),e.createElementVNode("div",_k,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${d.exportProgress}%`}),role:"progressbar","aria-valuenow":d.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,Tk)]),e.createElementVNode("div",Mk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),Fk=Be(Bk,[["__scopeId","data-v-5caf8fe6"]]),Ik=["data-testid"],Rk={class:"progress-header"},$k={class:"file-info"},Dk={class:"file-details"},Uk={class:"file-name"},Ak={class:"file-meta"},Ok={class:"file-size"},Lk={key:0,class:"separator"},zk={key:1,class:"upload-speed"},Pk={key:2,class:"separator"},jk={key:3,class:"time-remaining"},Wk={class:"progress-actions"},Zk={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},Xk={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},Hk={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},Gk=["aria-valuenow","aria-label"],Jk={class:"progress-bar"},Yk={class:"progress-percent"},Kk={key:1,class:"error-message","data-testid":"video-upload-error"},qk={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},Qk=["src","alt"],ex={key:0,class:"video-duration"},tx=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(a){const n=a,t=e.computed(()=>({"is-uploading":n.upload.status==="uploading","is-processing":n.upload.status==="processing","is-completed":n.upload.status==="completed","is-error":n.upload.status==="error","is-pending":n.upload.status==="pending"})),o=e.computed(()=>vl),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const f=n.upload.timeRemaining;if(f<60)return`${Math.round(f)}s`;const p=Math.floor(f/60);return p<60?`${p}m ${Math.round(f%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),c=e.computed(()=>{var f;return n.upload.status==="completed"&&((f=n.upload.media)!=null&&f.thumbnail_url)?n.upload.media.thumbnail_url:null}),l=e.computed(()=>{var f;return(f=n.upload.media)==null?void 0:f.duration});function d(f){if(f===0)return"0 B";const p=["B","KB","MB","GB","TB"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function u(f){if(f===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function m(f){const p=Math.floor(f/3600),v=Math.floor(f%3600/60),g=Math.floor(f%60);return p>0?`${p}:${v.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${v}:${g.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${f.upload.id}`},[e.createElementVNode("div",Rk,[e.createElementVNode("div",$k,[e.createVNode(e.unref(I.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",Dk,[e.createElementVNode("h4",Uk,e.toDisplayString(f.upload.filename),1),e.createElementVNode("p",Ak,[e.createElementVNode("span",Ok,e.toDisplayString(d(f.upload.bytesTotal||0)),1),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Lk,"•")):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",zk,e.toDisplayString(u(f.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Pk,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",jk,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Wk,[f.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",Zk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ll)},null,8,["icon"])])):f.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",Xk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(du),"aria-hidden":"true"},null,8,["icon"])])):f.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",Hk,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=v=>f.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Dn),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=v=>f.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=v=>f.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Dn),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":f.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",Jk,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:f.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",Yk,e.toDisplayString(Math.round(r.value))+"%",1)],8,Gk)):e.createCommentVNode("",!0),f.upload.error?(e.openBlock(),e.createElementBlock("div",Kk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Gu)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(f.upload.error),1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",qk,[e.createElementVNode("img",{src:c.value,alt:f.upload.filename},null,8,Qk),l.value?(e.openBlock(),e.createElementBlock("div",ex,e.toDisplayString(m(l.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,Ik))}}),nx=Be(tx,[["__scopeId","data-v-9eacbf91"]]),Ei=4,ox=500,ax=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function ja(a){return typeof a=="object"&&a!==null}function Js(a){return ja(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function ix(a){if(Js(a))return a;if(ja(a)&&Js(a.data))return a.data;throw new Error("Invalid upload response from backend")}function Ys(a){return ja(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function rx(a){if(Ys(a))return a;if(ja(a)&&Ys(a.data))return a.data;throw new Error("Invalid media response from backend")}function Zo(a){return a?{...a}:{}}function Ks(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function sx(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function lx(a){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(a)))}catch{return btoa(a)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function cx(a,n){return[["filename",a.filename],["filetype",a.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([o,i])=>`${o} ${lx(i)}`).join(",")}function Xo(a,n){const t=Math.max(a.bytesTotal,1);a.bytesUploaded=n,a.progress=Math.min(100,n/t*100);const o=Math.max((Date.now()-a.startedAt.getTime())/1e3,.001);a.uploadSpeed=n/o;const i=Math.max(t-n,0);a.timeRemaining=i/Math.max(a.uploadSpeed,1)}function dx(a,n){return a instanceof Error?a:new Error(n)}function ux(a){if(!(a instanceof Error))return!1;const n=a.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function qs(a){const n=Math.max(0,a-1),t=ox*Math.pow(2,n);return Math.min(5e3,t)}function Qs(a){return new Promise(n=>{window.setTimeout(n,a)})}async function el(a,n){for(let t=1;t<=Ei;t+=1)try{const o=await n();if(o.ok||!ax.has(o.status)||t>=Ei)return o;await Qs(qs(t))}catch(o){if(!ux(o)||t>=Ei)throw o;await Qs(qs(t))}throw new Error(`${a} failed after retry attempts`)}function mx(a={}){const n=e.ref(new Map),t=e.ref(new Set),o=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),c=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>{const k=Array.from(n.value.values());return k.length===0?0:k.reduce((R,U)=>R+U.progress,0)/k.length});function d(k){o.value=k}function u(){}async function m(k){var R;const B=k.filter(U=>f(U));if(B.length!==0&&((R=a.onFilesSelected)==null||R.call(a,B),a.autoUpload!==!1))for(const U of B)await p(U)}function f(k){return!(a.maxFileSize&&k.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(k.type))}async function p(k){var U,_,z;const B=A(k);if(n.value.has(B)){const H=n.value.get(B);if((H==null?void 0:H.status)==="uploading")return}const R={id:B,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};n.value.set(R.id,R),t.value.add(R.id);try{R.status="uploading",(U=a.onUploadStart)==null||U.call(a,R);const H=await v(k);a.resumable===!0||H.resumable===!0?await E(R,H):await g(R,H),R.status="processing",R.progress=100;const $=await x(H.media_uuid);R.status="completed",R.media=$,(_=a.onUploadComplete)==null||_.call(a,$)}catch(H){if(R.status!=="cancelled"){const M=dx(H,"Upload failed");R.status="error",R.error=M.message,(z=a.onUploadError)==null||z.call(a,M,R)}}finally{t.value.delete(R.id),i.delete(R.id),r.delete(R.id)}}async function v(k){if(!o.value)throw new Error("API client not configured");const B={collection:a.collection||"videos",filename:k.name,size:k.size,mime_type:k.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},R=await o.value.post("/api/v1/video/upload",B);return ix(R)}async function g(k,B){const R=new XMLHttpRequest,U=Ks(B),_=Zo(B.headers);return new Promise((z,H)=>{R.upload.addEventListener("progress",M=>{var $;M.lengthComputable&&(Xo(k,M.loaded),($=a.onUploadProgress)==null||$.call(a,k))}),R.addEventListener("load",()=>{i.delete(k.id),R.status>=200&&R.status<300?z():H(new Error(`Upload failed with status ${R.status}`))}),R.addEventListener("error",()=>{i.delete(k.id),H(new Error("Upload failed"))}),R.addEventListener("abort",()=>{i.delete(k.id),H(new Error("Upload cancelled"))}),R.open(U,B.upload_url),Object.entries(_).forEach(([M,$])=>{R.setRequestHeader(M,$)}),!Object.keys(_).some(M=>M.toLowerCase()==="content-type")&&k.file.type&&R.setRequestHeader("Content-Type",k.file.type),i.set(k.id,R),R.send(k.file)})}async function E(k,B){var H;if(sx(B)){await T(k,B);return}const R=a.chunkSize||5*1024*1024,U=N(k.file,R),_=new AbortController;r.set(k.id,_);const z=await h(B.upload_id);z&&(U.forEach(M=>{M.end<=z.bytesUploaded&&(M.uploaded=!0)}),Xo(k,z.bytesUploaded));for(const M of U)M.uploaded||(await w(k,B,M,_),Xo(k,M.end),(H=a.onUploadProgress)==null||H.call(a,k))}async function T(k,B){var X;const R=new AbortController;r.set(k.id,R);const U={...Zo(B.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":cx(k,B)},_=await el("Resumable upload initialization",()=>fetch(B.upload_url,{method:"POST",headers:U,signal:R.signal}));if(!_.ok)throw new Error(`Failed to initialize resumable upload: ${_.status}`);const z=_.headers.get("Location");if(!z)throw new Error("Resumable upload endpoint did not return upload location");const H=new URL(z,B.upload_url).toString(),M=a.chunkSize||5*1024*1024;let $=0;for(;$<k.file.size;){const W=Math.min($+M,k.file.size),te=k.file.slice($,W),ge={...Zo(B.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String($),"Content-Type":"application/offset+octet-stream"},Ne=await el("Resumable chunk upload",()=>fetch(H,{method:"PATCH",headers:ge,body:te,signal:R.signal}));if(Ne.status===409){const F=Number(Ne.headers.get("Upload-Offset")??"-1");if(Number.isFinite(F)&&F>=0){$=F;continue}}if(!Ne.ok)throw new Error(`Resumable chunk upload failed: ${Ne.status}`);const ee=Number(Ne.headers.get("Upload-Offset")??String(W));$=Number.isFinite(ee)&&ee>$?ee:W,Xo(k,$),(X=a.onUploadProgress)==null||X.call(a,k)}}function N(k,B){const R=[];let U=0,_=0;for(;U<k.size;){const z=Math.min(U+B,k.size);R.push({start:U,end:z,blob:k.slice(U,z),index:_,uploaded:!1}),U=z,_++}return R}async function w(k,B,R,U){const _={...Zo(B.headers),"Content-Range":`bytes ${R.start}-${R.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},z=await fetch(B.upload_url,{method:Ks(B),headers:_,body:R.blob,signal:U.signal});if(!z.ok)throw new Error(`Chunk upload failed: ${z.status}`);R.uploaded=!0}async function h(k){return null}async function x(k){if(!o.value)throw new Error("API client not configured");const B=60;let R=0;for(;R<B;){const U=await o.value.get(`/api/v1/video/${k}`),_=rx(U),z=String(_.processing_status);if(z==="ready")return _;if(z==="failed"||z==="error")throw new Error("Video processing failed");await new Promise(H=>{window.setTimeout(H,5e3)}),R++}throw new Error("Video processing timeout")}function D(k){const B=n.value.get(k);if(!B)return;const R=i.get(k);R&&(R.abort(),i.delete(k));const U=r.get(k);U&&(U.abort(),r.delete(k)),B.status="cancelled",B.error="Upload cancelled",t.value.delete(k)}async function C(k){const B=n.value.get(k);B&&(B.status="pending",B.error="",B.progress=0,B.bytesUploaded=0,await p(B.file))}function y(k){n.value.delete(k),t.value.delete(k),i.delete(k),r.delete(k)}function S(){Array.from(n.value.entries()).forEach(([k,B])=>{B.status==="completed"&&n.value.delete(k)})}function A(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:c,isUploading:s,totalProgress:l,openFilePicker:u,handleFileSelect:m,validateFile:f,startUpload:p,cancelUpload:D,retryUpload:C,removeUpload:y,clearCompleted:S,setApiClient:d}}const px=["accept","multiple"],fx={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},hx=["onKeydown"],vx={key:1,class:"upload-list","data-testid":"video-upload-list"},gx={class:"drag-content"},yx=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:c,handleFileSelect:l,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:f}=mx({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:h=>o("upload-start",h),onUploadProgress:h=>o("upload-progress",h),onUploadComplete:h=>o("upload-complete",h),onUploadError:(h,x)=>o("upload-error",h,x),onFilesSelected:h=>o("files-selected",h)});t.apiClient&&f(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function E(h){const x=h.target,D=Array.from(x.files||[]);D.length>0&&(l(D),x.value="")}function T(h){var C;h.preventDefault(),r.value=!1;const D=Array.from(((C=h.dataTransfer)==null?void 0:C.files)||[]).filter(y=>y.type.startsWith("video/"));D.length>0&&l(D)}function N(h){var x;h.preventDefault(),(x=h.dataTransfer)!=null&&x.types.includes("Files")&&(r.value=!0)}function w(h){h.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",N),document.addEventListener("dragleave",w),document.addEventListener("drop",h=>h.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",N),document.removeEventListener("dragleave",w),document.removeEventListener("drop",h=>h.preventDefault())}),(h,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(c)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:h.multiple,onChange:E,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,px),!e.unref(c)||v.value?(e.openBlock(),e.createElementBlock("div",fx,[e.renderSlot(h.$slots,"trigger",{open:g},()=>[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:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vl),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(h.label),1),e.createElementVNode("p",null,e.toDisplayString(h.description),1),e.createVNode(e.unref(I.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qi),slot:"start","aria-hidden":"true"},null,8,["icon"]),x[2]||(x[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,hx)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",vx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),D=>(e.openBlock(),e.createBlock(nx,{key:D.id,upload:D,onCancel:C=>e.unref(d)(D.id),onRetry:C=>e.unref(u)(D.id),onRemove:C=>e.unref(m)(D.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:T,onDragover:x[0]||(x[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:x[1]||(x[1]=D=>r.value=!1)},[e.createElementVNode("div",gx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vo),"aria-hidden":"true"},null,8,["icon"]),x[3]||(x[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),wx=Be(yx,[["__scopeId","data-v-ea7587f7"]]),bx=["aria-valuenow","aria-valuemax","aria-label"],kx={class:"progress-bar"},xx={class:"time-display","data-testid":"video-time-display"},Ex={class:"current-time"},Vx={class:"duration"},Sx={class:"control-buttons"},Cx={class:"controls-left"},Nx=["aria-label"],_x={class:"controls-center"},Tx={key:0,class:"volume-controls"},Mx=["aria-label"],Bx=["value"],Fx={class:"controls-right"},Ix={key:0,class:"quality-selector"},Rx=["aria-expanded"],$x={class:"quality-label"},Dx={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},Ux=["data-testid","aria-label","onClick"],Ax=["aria-label"],Ox=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(a,{emit:n}){const t=a,o=n,i=e.ref(!0),r=e.ref(!1),s=e.ref(),c=I.isPlatform("mobile"),l="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),m=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let h=0;h<t.buffered.length;h++){const x=t.buffered.start(h),D=t.buffered.end(h);if(t.currentTime>=x&&t.currentTime<=D)return{width:`${D/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),f=e.computed(()=>t.muted||t.volume===0?Xu:t.volume<33?ju:t.volume<66?Wu:Pu);let p=null;function v(){i.value=!0,g()}function g(){p&&clearTimeout(p),t.playing&&!c&&(p=setTimeout(()=>{i.value=!1},3e3))}function E(h){if(!s.value||t.isLive)return;const x=s.value.getBoundingClientRect(),C=(h.clientX-x.left)/x.width*t.duration;o("seek",Math.max(0,Math.min(C,t.duration)))}function T(h){const x=h.target;o("setVolume",parseInt(x.value))}function N(h){o("selectQuality",h),r.value=!1}function w(h){if(!isFinite(h))return"0:00";const x=Math.floor(h/3600),D=Math.floor(h%3600/60),C=Math.floor(h%60);return x>0?`${x}:${D.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`:`${D}:${C.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),p&&clearTimeout(p)}),(h,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":i.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(h.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(h.duration),"aria-label":h.isLive?"Live stream":"Video progress",tabindex:"0",onClick:E},[e.createElementVNode("div",kx,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(m.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",xx,[e.createElementVNode("span",Ex,e.toDisplayString(w(h.currentTime)),1),x[7]||(x[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Vx,e.toDisplayString(h.isLive?"LIVE":w(h.duration)),1)])],8,bx),e.createElementVNode("div",Sx,[e.createElementVNode("div",Cx,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:x[0]||(x[0]=D=>h.$emit("play-pause")),"aria-label":h.playing?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:h.playing?e.unref(Nu):e.unref(Tu),"aria-hidden":"true"},null,8,["icon"])],8,Nx),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:x[1]||(x[1]=D=>h.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Mu),"aria-hidden":"true"},null,8,["icon"]),x[8]||(x[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:x[2]||(x[2]=D=>h.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Iu),"aria-hidden":"true"},null,8,["icon"]),x[9]||(x[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",_x,[e.unref(c)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Tx,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:x[3]||(x[3]=D=>h.$emit("toggleMute")),"aria-label":h.muted?"Unmute":"Mute"},[e.createVNode(e.unref(I.IonIcon),{icon:f.value,"aria-hidden":"true"},null,8,["icon"])],8,Mx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:h.muted?0:h.volume,onInput:T,"aria-label":"Volume"},null,40,Bx)]))]),e.createElementVNode("div",Fx,[h.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",Ix,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:x[4]||(x[4]=D=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ou),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",$x,e.toDisplayString(h.currentQuality),1)],8,Rx),r.value?(e.openBlock(),e.createElementBlock("div",Dx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.qualityLevels,D=>(e.openBlock(),e.createElementBlock("button",{key:D.label,class:e.normalizeClass(["quality-option",{active:D.label===h.currentQuality}]),"data-testid":`btn-video-quality-${D.label}`,"aria-label":`Set quality to ${D.label}`,role:"menuitem",onClick:C=>N(D)},e.toDisplayString(D.label),11,Ux))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(c)&&l?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:x[5]||(x[5]=D=>h.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Lu),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:x[6]||(x[6]=D=>h.$emit("toggleFullscreen")),"aria-label":h.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(I.IonIcon),{icon:h.fullscreen?e.unref(gu):e.unref(bu),"aria-hidden":"true"},null,8,["icon"])],8,Ax)])])],2))}}),Lx=Be(Ox,[["__scopeId","data-v-2ae77c13"]]);function zx(a={}){var te,ge,Ne;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),c=e.ref(a.muted||!1),l=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),f=e.ref(null),p=e.ref("idle"),v=e.ref(a.playbackUrl||((te=a.media)==null?void 0:te.playback_url)||((ge=a.media)==null?void 0:ge.url)||""),g=e.ref(null),E=e.ref(a.isLive||!1),T=e.ref(null),N=e.ref(null);function w(ee){N.value=ee}if((Ne=a.media)!=null&&Ne.token_expires_at){const ee=new Date(a.media.token_expires_at);g.value=Number.isNaN(ee.getTime())?null:ee}async function h(){var F;const ee=E.value?t.value:n.value;if(ee)try{await ee.play(),o.value=!0,p.value=E.value?"live":"playing",(F=a.onPlay)==null||F.call(a)}catch{f.value="Failed to play video",p.value="error"}}function x(){var F;const ee=E.value?t.value:n.value;ee&&(ee.pause(),o.value=!1,p.value="paused",(F=a.onPause)==null||F.call(a))}function D(){o.value?x():h()}function C(ee){const F=E.value?t.value:n.value;if(!F||E.value)return;const P=Number.isFinite(F.duration)?F.duration:ee;F.currentTime=Math.max(0,Math.min(ee,P)),i.value=F.currentTime}function y(ee=10){const F=n.value;!F||E.value||C(F.currentTime+ee)}function S(ee=10){const F=n.value;!F||E.value||C(F.currentTime-ee)}function A(){const ee=E.value?t.value:n.value;ee&&(ee.muted=!ee.muted,c.value=ee.muted)}function k(ee){const F=E.value?t.value:n.value;if(!F)return;const P=Math.max(0,Math.min(100,ee));F.volume=P/100,s.value=P,P>0&&F.muted&&(F.muted=!1,c.value=!1)}function B(ee){const F=n.value;!F||E.value||(F.playbackRate=ee,u.value=ee)}async function R(){const ee=document.querySelector(".video-player-container");if(ee)try{document.fullscreenElement?(await document.exitFullscreen(),l.value=!1):(await ee.requestFullscreen(),l.value=!0)}catch{}}async function U(){const ee=E.value?t.value:n.value;if(ee)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ee.requestPictureInPicture()}catch{}}async function _(){var F;f.value=null,p.value="loading",(F=a.media)!=null&&F.provider&&a.media.provider!=="local"&&await z();const ee=E.value?t.value:n.value;ee&&(ee.load(),await h())}async function z(){if(!(!N.value||!a.media))try{m.value=!0;const ee=await N.value.get(`/api/v1/video/${a.media.uuid}/playback`);v.value=ee.playback_url,g.value=new Date(ee.token_expires_at);const F=E.value?t.value:n.value;if(F&&F.src!==v.value){const P=!F.paused,pe=F.currentTime;F.src=v.value,E.value||(F.currentTime=pe),P&&await h()}}catch{f.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function H(ee){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ee;return}try{t.value.src=ee}catch{f.value="Live streaming not supported in this browser",p.value="error"}}}function M(){T.value&&(T.value.destroy(),T.value=null)}function $(){var F;const ee=E.value?t.value:n.value;ee&&(i.value=ee.currentTime,r.value=ee.duration,(F=a.onTimeUpdate)==null||F.call(a,ee.currentTime))}const X=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ee=0;ee<d.value.length;ee++){const F=d.value.start(ee),P=d.value.end(ee);if(i.value>=F&&i.value<=P)return P/r.value*100}return 0});function W(){if(!g.value)return!1;const ee=new Date;return g.value.getTime()-ee.getTime()<5*60*1e3}return e.watch([n,t],([ee,F])=>{const P=E.value?F:ee;P&&(P.addEventListener("timeupdate",$),P.addEventListener("loadedmetadata",()=>{r.value=P.duration,p.value="ready"}),P.addEventListener("progress",()=>{d.value=P.buffered}),P.addEventListener("ended",()=>{var pe;o.value=!1,p.value="ended",(pe=a.onEnded)==null||pe.call(a)}),P.addEventListener("error",pe=>{var ne;p.value="error",(ne=a.onError)==null||ne.call(a,"Video playback error")}),P.volume=s.value/100,P.muted=c.value)}),e.onUnmounted(()=>{M();const ee=E.value?t.value:n.value;ee&&ee.removeEventListener("timeupdate",$)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:c,isFullscreen:l,bufferedRanges:d,bufferedPercent:X,playbackRate:u,isLoading:m,error:f,status:p,currentPlaybackUrl:v,tokenExpiresAt:g,play:h,pause:x,togglePlayPause:D,seek:C,skipForward:y,skipBackward:S,toggleMute:A,setVolume:k,setPlaybackRate:B,toggleFullscreen:R,togglePiP:U,retry:_,refreshToken:z,setupLiveStream:H,setApiClient:w,shouldRefreshToken:W}}const Px=["src","poster","controls","autoplay","muted","loop","preload"],jx={key:1,ref:"livePlayerEl",class:"live-player"},Wx=["controls","muted"],Zx={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},Xx={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},Hx={key:3,class:"video-error","data-testid":"video-error",role:"alert"},Gx={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},Jx=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(a,{emit:n}){const t=a,o=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:c,duration:l,volume:d,muted:u,isFullscreen:m,bufferedRanges:f,isLoading:p,error:v,status:g,currentPlaybackUrl:E,tokenExpiresAt:T,play:N,pause:w,seek:h,toggleMute:x,setVolume:D,toggleFullscreen:C,togglePlayPause:y,skipForward:S,skipBackward:A,retry:k,refreshToken:B,setApiClient:R,shouldRefreshToken:U,setupLiveStream:_}=zx({...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 z(){await B()}const H=e.computed(()=>{const ne=["video-player-container"];return t.className&&ne.push(t.className),m.value&&ne.push("fullscreen"),t.isLive&&ne.push("is-live"),s.value&&ne.push("is-playing"),p.value&&ne.push("is-loading"),ne}),M=e.computed(()=>{var ne,Y;if(t.poster)return t.poster;if((ne=t.media)!=null&&ne.poster_url)return t.media.poster_url;if((Y=t.media)!=null&&Y.thumbnail_url)return t.media.thumbnail_url});function $(ne){const Y=ne.target;o("loadedmetadata",{duration:Y.duration,width:Y.videoWidth,height:Y.videoHeight})}function X(ne){const Y=ne.target;c.value=Y.currentTime,o("timeupdate",Y.currentTime)}function W(){s.value=!0,o("play")}function te(){s.value=!1,o("pause")}function ge(){s.value=!1,o("ended")}function Ne(ne){const Y=ne.target;let Me="Failed to load video";if(Y.error)switch(Y.error.code){case Y.error.MEDIA_ERR_ABORTED:Me="Video playback aborted";break;case Y.error.MEDIA_ERR_NETWORK:Me="Network error while loading video";break;case Y.error.MEDIA_ERR_DECODE:Me="Video decoding error";break;case Y.error.MEDIA_ERR_SRC_NOT_SUPPORTED:Me="Video format not supported";break}v.value=Me,o("error",Me)}function ee(ne){const Y=ne.target;f.value=Y.buffered,o("progress",Y.buffered)}function F(){p.value=!0}function P(){p.value=!1}e.watch(()=>t.apiClient,ne=>{ne&&R(ne)},{immediate:!0}),e.watch(()=>t.playbackUrl,ne=>{typeof ne=="string"&&ne.length>0&&(E.value=ne)},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.token_expires_at},ne=>{if(!ne){T.value=null;return}const Y=new Date(ne);T.value=Number.isNaN(Y.getTime())?null:Y},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.playback_url},async(ne,Y)=>{if(t.playbackUrl||!ne||ne===Y)return;const Me=i.value;if(!Me||t.isLive){E.value=ne;return}const ce=!Me.paused,se=Me.currentTime;E.value=ne,await e.nextTick();try{Me.currentTime=se}catch{}ce&&await N()},{immediate:!0});let pe=null;return e.watch(()=>t.isLive,async ne=>{var Me;if(!ne)return;const Y=t.playbackUrl||((Me=t.media)==null?void 0:Me.playback_url)||"";Y&&await _(Y)},{immediate:!0}),e.onMounted(()=>{var ne;(ne=t.media)!=null&&ne.provider&&t.media.provider!=="local"&&(pe=setInterval(()=>{U()&&z()},3e4)),I.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{pe&&clearInterval(pe)}),(ne,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",H.value]),"data-testid":"video-player"},[ne.isLive?(e.openBlock(),e.createElementBlock("div",jx,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ne.controls&&!ne.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:W,onPause:te,onError:Ne,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Wx),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",Zx,[...Y[3]||(Y[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:i,src:e.unref(E),poster:M.value,controls:ne.controls&&!ne.showCustomControls,autoplay:ne.autoplay,muted:e.unref(u),loop:ne.loop,preload:ne.preload,onLoadedmetadata:$,onTimeupdate:X,onPlay:W,onPause:te,onEnded:ge,onError:Ne,onProgress:ee,onWaiting:F,onCanplay:P,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Px)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",Xx,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",Hx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qi),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(I.IonButton),{size:"small",onClick:e.unref(k),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ln),slot:"start","aria-hidden":"true"},null,8,["icon"]),Y[4]||(Y[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ne.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(Lx,{key:4,playing:e.unref(s),currentTime:e.unref(c),duration:e.unref(l),buffered:e.unref(f),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ne.isLive,onPlay:e.unref(N),onPause:e.unref(w),onSeek:e.unref(h),onToggleMute:e.unref(x),onSetVolume:e.unref(D),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),ne.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",Gx,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:Y[0]||(Y[0]=(...Me)=>e.unref(A)&&e.unref(A)(...Me))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:Y[1]||(Y[1]=(...Me)=>e.unref(y)&&e.unref(y)(...Me))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:Y[2]||(Y[2]=(...Me)=>e.unref(S)&&e.unref(S)(...Me))},null,32)])):e.createCommentVNode("",!0)],2))}}),Ec=Be(Jx,[["__scopeId","data-v-b8db4951"]]),Yx=ba.defineStore("video",()=>{const a=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(a.value.values())),s=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>s.value.filter(_=>_.status==="live")),l=e.computed(()=>r.value.filter(_=>_.processing_status==="processing"));function d(_){a.value.set(_.uuid,_)}function u(_,z){const H=a.value.get(_);H&&a.value.set(_,{...H,...z})}function m(_){a.value.delete(_)}function f(_){return a.value.get(_)}function p(_){n.value.set(_.id,_)}function v(_,z){const H=n.value.get(_);H&&n.value.set(_,{...H,...z})}function g(_,z){const H=n.value.get(_);H&&n.value.set(_,{...H,status:z.status,viewer_count:z.viewer_count,peak_viewers:z.peak_viewers})}function E(_){n.value.delete(_)}function T(_){return n.value.get(_)}function N(_){return s.value.find(z=>z.media_uuid===_)}function w(_){t.value.set(_.id,_)}function h(_,z){const H=t.value.get(_);H&&t.value.set(_,{...H,...z})}function x(_){t.value.delete(_)}function D(_){return t.value.get(_)}function C(_){return Array.from(t.value.values()).filter(z=>z.media_uuid===_)}function y(_){o.value=_}function S(_){o.value&&(o.value={...o.value,..._})}function A(){o.value=null}function k(_){i.value=_}function B(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function R(_){a.value.clear(),_.forEach(z=>{a.value.set(z.uuid,z)})}function U(_){n.value.clear(),_.forEach(z=>{n.value.set(z.id,z)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:c,processingVideos:l,setVideo:d,updateVideo:u,removeVideo:m,getVideo:f,setLiveStream:p,updateLiveStream:v,updateLiveStreamStats:g,removeLiveStream:E,getLiveStream:T,getLiveStreamByMedia:N,addExportJob:w,updateExportJob:h,removeExportJob:x,getExportJob:D,getExportJobsByMedia:C,setEditorState:y,updateEditorState:S,clearEditorState:A,setProcessing:k,clearAll:B,loadVideos:R,loadLiveStreams:U}});let hn=null;function Kx(a){hn=a}const Ho={post:async(a,n)=>{if(!hn)throw new Error("HTTP client not configured");return await hn(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!hn)throw new Error("HTTP client not configured");return await hn(`/api/v1/video${a}`)},delete:async a=>{if(!hn)throw new Error("HTTP client not configured");return await hn(`/api/v1/video${a}`,{method:"DELETE"})}};function Go(a,n=null){const t=typeof a.id=="string"&&a.id!==""?a.id:typeof a.stream_id=="string"&&a.stream_id!==""?a.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:a.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:a.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:a.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:a.status??(n==null?void 0:n.status)??"idle",viewer_count:a.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:a.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:a.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:a.low_latency??(n==null?void 0:n.low_latency)??!1},i=a.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(o.playback_url=i);const r=a.started_at??(n==null?void 0:n.started_at);r!==void 0&&(o.started_at=r);const s=a.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(o.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(o.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(o.vod_media_uuid=n.vod_media_uuid),o}function Vi(a,n){return a instanceof Error&&a.message?a.message:n}function qx(a){const n=Yx(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),c=e.ref(!1),l=e.ref(null),d=e.ref(null),u=e.ref(0),m=e.ref(0);let f;const p=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var A;if(!((A=t.value)!=null&&A.playback_url))return null;const S=new URL(t.value.playback_url);return S.searchParams.set("live","true"),o.value&&S.searchParams.set("latency","low"),S.toString()}),g=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="live"}),E=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="idle"}),T=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="ended"});async function N(S={}){s.value=!0,l.value=null;try{const A=await Ho.post("/live",{title:r.value||S.title||"Live Stream",low_latency:S.low_latency??o.value,auto_record:S.auto_record??i.value,...S}),k=Go(A);return t.value=k,n.setLiveStream(k),D(),k}catch(A){throw l.value=Vi(A,"Failed to create stream"),A instanceof Error?A:new Error(l.value)}finally{s.value=!1}}async function w(){if(!t.value)throw new Error("No active stream");c.value=!0,l.value=null;try{const S=await Ho.post(`/live/${t.value.id}/end`),A=Go(S,t.value);return t.value=A,n.setLiveStream(A),C(),A}catch(S){throw l.value=Vi(S,"Failed to end stream"),S instanceof Error?S:new Error(l.value)}finally{c.value=!1}}async function h(){if(t.value)try{const S=await Ho.get(`/live/${t.value.id}`),A=Go(S,t.value);u.value=A.viewer_count,m.value=A.peak_viewers,t.value=A;const k={status:A.status,viewer_count:A.viewer_count,peak_viewers:A.peak_viewers};A.started_at&&(k.started_at=A.started_at),A.ended_at&&(k.ended_at=A.ended_at),n.updateLiveStreamStats(A.id,k),A.status==="live"&&!d.value&&A.started_at&&(d.value=new Date(A.started_at)),A.status==="ended"&&C()}catch{}}async function x(S){try{const A=await Ho.get(`/live/${S}`),k=Go(A,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(A){throw l.value=Vi(A,"Failed to get stream credentials"),A instanceof Error?A:new Error(l.value)}}function D(S=5e3){C(),f=window.setInterval(()=>{h()},S)}function C(){f!==void 0&&(clearInterval(f),f=void 0)}async function y(){if(!a)return;const S=n.getLiveStreamByMedia(a);S&&(t.value=S,u.value=S.viewer_count,m.value=S.peak_viewers,S.status==="live"&&(D(),S.started_at&&(d.value=new Date(S.started_at))))}return a&&y(),e.onUnmounted(()=>{C()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:c,error:l,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:g,isIdle:E,hasEnded:T,createStream:N,endStream:w,refreshStreamStatus:h,getStreamCredentials:x,startStatusPolling:D,stopStatusPolling:C}}const Qx={class:"stream-status"},eE={class:"flex items-center justify-between"},tE={class:"flex items-center gap-3"},nE={key:0,class:"flex items-center"},oE={key:2,class:"text-sm text-gray-600"},aE={key:0,class:"flex items-center gap-2"},iE={class:"text-sm font-medium text-gray-700"},rE={key:0,class:"text-xs text-gray-500"},sE=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(a){const n=a,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),o=e.computed(()=>{const r="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`${r} ${s[n.status]||s.idle}`}),i=e.computed(()=>{if(!n.duration)return null;const r=Math.floor(n.duration/3600),s=Math.floor(n.duration%3600/60),c=n.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`:`${s}:${c.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",Qx,[e.createElementVNode("div",eE,[e.createElementVNode("div",tE,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",nE,[...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(o.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",oE,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",aE,[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",iE,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",rE," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),lE=Be(sE,[["__scopeId","data-v-1d09c19f"]]),cE={class:"stream-credentials"},dE={class:"space-y-3"},uE={class:"credential-field"},mE={class:"flex gap-2"},pE=["value"],fE={class:"credential-field"},hE={class:"flex gap-2"},vE=["value","type"],gE=["aria-label"],yE={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},wE={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},bE={key:0,class:"mt-2 text-sm text-green-600"},kE=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.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 c(){i.value=!i.value}async function l(d,u){try{await navigator.clipboard.writeText(d),r.value=u,o("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",cE,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",dE,[e.createElementVNode("div",uE,[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",mE,[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,pE),e.createElementVNode("button",{onClick:u[0]||(u[0]=m=>l(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",fE,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",hE,[e.createElementVNode("input",{value:s.value,readonly:"",type:i.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,vE),e.createElementVNode("button",{onClick:c,class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":i.value?"Hide stream key":"Show stream key"},[i.value?(e.openBlock(),e.createElementBlock("svg",wE,[...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",yE,[...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,gE),e.createElementVNode("button",{onClick:u[1]||(u[1]=m=>l(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(()=>[r.value?(e.openBlock(),e.createElementBlock("div",bE,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),xE=Be(kE,[["__scopeId","data-v-306d92f6"]]),EE={class:"live-stream-manager","data-testid":"live-stream-manager"},VE={key:0,class:"stream-setup"},SE={class:"space-y-4"},CE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},NE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},_E=["disabled"],TE={key:0},ME={key:1,class:"flex items-center justify-center"},BE={key:1,class:"stream-active space-y-6"},FE={key:1,class:"video-preview"},IE={key:2,class:"analytics-panel"},RE={class:"grid grid-cols-2 gap-4"},$E={class:"bg-gray-50 p-3 rounded"},DE={class:"text-2xl font-bold text-gray-900"},UE={class:"bg-gray-50 p-3 rounded"},AE={class:"text-2xl font-bold text-gray-900"},OE={class:"stream-controls flex gap-3"},LE=["disabled"],zE={key:0},PE={key:1},jE={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},WE={class:"text-red-600 text-sm"},ZE=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(a,{emit:n}){const t=a,o=n;t.httpClient&&Kx(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:c,isCreating:l,isEnding:d,error:u,createStream:m,endStream:f,streamDuration:p,playbackUrl:v,refreshStreamStatus:g}=qx(t.mediaUuid),E=e.ref(!1);async function T(){var D;try{const C=await m({title:c.value,low_latency:r.value,auto_record:s.value});o("stream-created",C),(D=t.onStreamCreated)==null||D.call(t,C)}catch(C){o("error",C)}}async function N(){var D;try{const C=await f();o("stream-ended",C),(D=t.onStreamEnded)==null||D.call(t,C)}catch(C){o("error",C)}}function w(){i.value=null,c.value="",E.value=!1,u.value=null}async function h(D,C){try{await navigator.clipboard.writeText(D)}catch{}}let x;return e.onMounted(()=>{var D;((D=i.value)==null?void 0:D.status)==="live"&&(x=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{x&&clearInterval(x)}),(D,C)=>(e.openBlock(),e.createElementBlock("div",EE,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",BE,[e.createVNode(lE,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(xE,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:h},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",FE,[C[9]||(C[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Ec,{"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(i).status==="live"?(e.openBlock(),e.createElementBlock("div",IE,[C[12]||(C[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",RE,[e.createElementVNode("div",$E,[e.createElementVNode("div",DE,e.toDisplayString(e.unref(i).viewer_count),1),C[10]||(C[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",UE,[e.createElementVNode("div",AE,e.toDisplayString(e.unref(i).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",OE,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C[3]||(C[3]=y=>E.value=!E.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(E.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:N,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",PE,"Ending...")):(e.openBlock(),e.createElementBlock("span",zE,"End Stream"))],8,LE)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:w,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",VE,[C[8]||(C[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",SE,[e.createElementVNode("div",CE,[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(r)?r.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(r)]])]),e.createElementVNode("div",NE,[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(c)?c.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(c)]])]),e.createElementVNode("button",{onClick:T,disabled:e.unref(l),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(l)?(e.openBlock(),e.createElementBlock("span",ME,[...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",TE,"Create Stream"))],8,_E)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",jE,[e.createElementVNode("p",WE,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),XE=Be(ZE,[["__scopeId","data-v-26291f6f"]]),HE={class:"album-tree-node"},GE=["data-album-id","draggable","aria-selected","aria-expanded"],JE={key:1,class:"album-node__chevron-placeholder"},YE={key:2,"data-testid":"media-count",class:"album-node__count"},KE={key:0,class:"album-tree-node__children",role:"group"},qE=16,QE=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(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.expandedIds.has(t.album.id)),r=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),c=e.computed(()=>t.album.children_count>0),l=e.computed(()=>`${t.depth*qE}px`),d=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.dropTargetId)===t.album.id}),m=e.computed(()=>{var w;return(w=t.dragState)!=null&&w.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),f=e.computed(()=>{const w=["album-node"];return r.value&&w.push("album-node--selected"),s.value&&w.push("album-node--focused"),t.compact&&w.push("album-node--compact"),d.value&&w.push("album-node--dragging"),u.value&&w.push("album-node--drop-target"),m.value&&w.push("album-node--invalid-drop"),w});function p(){o("select",t.album)}function v(w){w.stopPropagation(),o("toggle-expand",t.album.id)}function g(w){t.draggable&&(w.dataTransfer&&(w.dataTransfer.setData("text/plain",t.album.id),w.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function E(w){t.draggable&&(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function T(){o("drag-leave",t.album.id)}function N(w){t.draggable&&(w.preventDefault(),o("drop",t.album.id))}return(w,h)=>{var D;const x=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",HE,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":w.album.id,class:e.normalizeClass(f.value),style:e.normalizeStyle({paddingLeft:l.value}),draggable:w.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":c.value?i.value:void 0,onDragstart:g,onDragover:E,onDragleave:T,onDrop:N},[c.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(I.IonIcon),{icon:i.value?e.unref(fu):e.unref(hu)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",JE)),e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Eu),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(w.album.name),1),w.showMediaCount?(e.openBlock(),e.createElementBlock("span",YE,e.toDisplayString(w.album.media_count),1)):e.createCommentVNode("",!0)],46,GE),i.value&&((D=w.album.children)!=null&&D.length)?(e.openBlock(),e.createElementBlock("div",KE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.album.children,C=>(e.openBlock(),e.createBlock(x,{key:C.id,album:C,depth:w.depth+1,"selected-id":w.selectedId,"expanded-ids":w.expandedIds,"focused-id":w.focusedId,draggable:w.draggable,"show-media-count":w.showMediaCount,compact:w.compact,onSelect:h[0]||(h[0]=y=>o("select",y)),onToggleExpand:h[1]||(h[1]=y=>o("toggle-expand",y))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),e4=Be(QE,[["__scopeId","data-v-76be65a6"]]),Wa=ba.defineStore("albums",()=>{const a=e.ref([]),n=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const h=new Map;return a.value.forEach(x=>h.set(x.id,x)),h}),s=e.computed(()=>a.value.filter(h=>h.parent_id===null));async function c(h){t.value=!0,o.value=null;try{const x=(h==null?void 0:h.parent_id)??null,D=x?`/api/v1/albums?parent_id=${x}`:"/api/v1/albums?parent_id=null",C=await fetch(D);if(!C.ok)throw new Error("Failed to fetch albums");((await C.json()).data||[]).forEach(A=>{const k=a.value.findIndex(B=>B.id===A.id);k>=0?a.value[k]=A:a.value.push(A)}),x!==null&&i.value.add(x)}catch(x){o.value=x instanceof Error?x.message:"Unknown error"}finally{t.value=!1}}async function l(h){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${h}`);if(!x.ok)throw new Error("Failed to fetch album");const C=(await x.json()).data,y=a.value.findIndex(S=>S.id===C.id);return y>=0?a.value[y]=C:a.value.push(C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function d(h){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${h}/media`);if(!x.ok)throw new Error("Failed to fetch album media");const C=(await x.json()).data||[];return n.value.set(h,C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function u(h,x){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${h}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:x})})).ok)throw new Error("Failed to reorder album media");const C=n.value.get(h)||[],y=x.map(S=>C.find(A=>A.uuid===S)).filter(S=>S!==void 0);n.value.set(h,y)}catch(D){throw o.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function m(h){t.value=!0,o.value=null;try{const x=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(h)});if(!x.ok)throw new Error("Failed to create album");const C=(await x.json()).data;return a.value.push(C),C}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function f(h,x){t.value=!0,o.value=null;try{const D=await fetch(`/api/v1/albums/${h}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x)});if(!D.ok)throw new Error("Failed to update album");const y=(await D.json()).data,S=a.value.findIndex(A=>A.id===y.id);return S>=0&&(a.value[S]=y),y}catch(D){throw o.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function p(h){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${h}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const D=a.value.findIndex(C=>C.id===h);D>=0&&a.value.splice(D,1),n.value.delete(h)}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}function v(h){return a.value.filter(x=>x.parent_id===h)}function g(h){return i.value.has(h)}function E(h){return n.value.get(h)||[]}async function T(h,x){const D=a.value.findIndex(y=>y.id===h);if(D<0)return;const C=a.value[D];a.value[D]={...C,parent_id:x};try{if(!(await fetch(`/api/v1/albums/${h}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:x})})).ok)throw new Error("Failed to move album")}catch(y){throw a.value[D]=C,o.value=y instanceof Error?y.message:"Unknown error",y instanceof Error?y:new Error("Failed to move album")}}function N(h){a.value=h}function w(){a.value=[],n.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:a,albumMedia:n,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:c,fetchAlbum:l,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:f,deleteAlbum:p,getChildrenOf:v,childrenLoaded:g,getAlbumMedia:E,moveAlbum:T,setAlbums:N,reset:w}});function Vc(){const a=Wa(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=ba.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function c(u){return a.getChildrenOf(u)}function l(u){return a.childrenLoaded(u)}async function d(u,m){await a.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:c,childrenLoaded:l,moveAlbum:d}}function Sc(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,f){if(m===f)return!0;const p=new Set,v=[m];for(;v.length>0;){const g=v.shift();if(!g||p.has(g))continue;p.add(g);const E=n.get(g)||[];for(const T of E){if(T===f)return!0;v.push(T)}}return!1}function r(m,f){return m===f?!1:f===null?!0:!i(m,f)}function s(m){o.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function c(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function l(m){o.value.dropTargetId=m}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:f}=o.value;if(!m){c();return}if(!r(m,f)){c();return}try{await t(m,f)}finally{c()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:c,setDropTarget:l,clearDropTarget:d,executeDrop:u}}const t4={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},n4={key:1,"data-testid":"error-state",class:"album-tree__error"},o4={key:2,"data-testid":"empty-state",class:"album-tree__empty"},a4={key:3,class:"album-tree__content",role:"group"},i4=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),c=e.computed(()=>o.compact===!0),{albums:l,rootAlbums:d,loading:u,error:m,fetchAlbums:f,getChildrenOf:p,childrenLoaded:v,moveAlbum:g}=Vc(),E=e.shallowRef(new Set(o.expandedIds)),T=e.ref(o.modelValue??null),N=e.ref(null),w=new Map,h=new Map;function x(F){w.clear(),h.clear();for(const P of F){w.set(P.id,P);const pe=P.parent_id??null,ne=h.get(pe)??[];ne.push(P.id),h.set(pe,ne)}}e.watch(l,F=>{x(F)},{immediate:!0});const{dragState:D,canDropOn:C,startDrag:y,endDrag:S,setDropTarget:A,clearDropTarget:k,executeDrop:B}=Sc({childrenByParentId:h,onMove:async(F,P)=>{await g(F,P),i("album-moved",{albumId:F,newParentId:P})}});e.watch(()=>o.modelValue,F=>{T.value=F??null}),e.watch(()=>o.expandedIds,F=>{E.value=new Set(F)}),e.onMounted(async()=>{await f({parent_id:null})});const R=e.computed(()=>d.value.map(F=>U(F)));function U(F){if(!E.value.has(F.id))return F;const P=p(F.id);return{...F,children:P.map(pe=>U(pe))}}const _=e.computed(()=>{const F=[];function P(pe){var ne;for(const Y of pe)F.push(Y),E.value.has(Y.id)&&((ne=Y.children)!=null&&ne.length)&&P(Y.children)}return P(R.value),F});function z(F){var ne;if(!_.value.length)return;const P=N.value?_.value.findIndex(Y=>Y.id===N.value):-1,pe=P>=0?_.value[P]:null;switch(F.key){case"ArrowDown":F.preventDefault(),P<_.value.length-1?N.value=_.value[P+1].id:P===-1&&_.value.length>0&&(N.value=_.value[0].id);break;case"ArrowUp":F.preventDefault(),P>0&&(N.value=_.value[P-1].id);break;case"ArrowRight":F.preventDefault(),pe&&(pe.children_count>0&&!E.value.has(pe.id)?H(pe.id):E.value.has(pe.id)&&((ne=pe.children)!=null&&ne.length)&&(N.value=pe.children[0].id));break;case"ArrowLeft":F.preventDefault(),pe&&(E.value.has(pe.id)&&pe.children_count>0?H(pe.id):pe.parent_id&&(N.value=pe.parent_id));break;case"Enter":case" ":F.preventDefault(),pe&&M(pe);break;case"Home":F.preventDefault(),_.value.length>0&&(N.value=_.value[0].id);break;case"End":F.preventDefault(),_.value.length>0&&(N.value=_.value[_.value.length-1].id);break}}async function H(F){E.value.has(F)?(E.value.delete(F),i("album-collapsed",F)):(v(F)||await f({parent_id:F}),E.value.add(F),i("album-expanded",F))}function M(F){T.value=F.id,i("update:modelValue",F.id),i("album-selected",F)}function $(F){o.draggable&&y(F)}function X(F){var pe;if(!o.draggable)return;const P=(pe=D.value)==null?void 0:pe.draggedAlbumId;P&&(A(F),C(P,F))}function W(){o.draggable&&k()}async function te(F){o.draggable&&(A(F),await B())}function ge(F){o.draggable&&(F.preventDefault(),A(null))}async function Ne(F){o.draggable&&(F.preventDefault(),A(null),await B())}function ee(){S()}return n({focusedId:N}),(F,P)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:z,onDragover:ge,onDrop:Ne,onDragend:ee},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",t4,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",n4,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",a4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,pe=>(e.openBlock(),e.createBlock(e4,{key:pe.id,album:pe,depth:0,"selected-id":T.value,"expanded-ids":E.value,"focused-id":N.value,draggable:r.value,"drag-state":r.value?e.unref(D):null,"show-media-count":s.value,compact:c.value,onSelect:M,onToggleExpand:H,onDragStart:$,onDragOver:X,onDragLeave:W,onDrop:te},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",o4,[P[0]||(P[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(F.$slots,"empty-action",{},void 0,!0)]))],32))}}),Cc=Be(i4,[["__scopeId","data-v-ae3dea7a"]]),r4=300,s4=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),c=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const l=e.computed(()=>r.value!==null);function d(p){const v=Date.now();if(c.value===p.id&&v-s.value<r4){o("confirm",p);return}s.value=v,c.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&o("confirm",r.value)}function m(){o("close")}function f(){o("close")}return(p,v)=>(e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:f},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-button",onClick:m},{default:e.withCtx(()=>[...v[1]||(v[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Cc,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:m},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!l.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Nc=Be(s4,[["__scopeId","data-v-21676ec1"]]),l4={class:"ion-padding-start text-sm"},c4={class:"ion-padding-start text-sm"},d4={key:1},u4={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},m4={class:"flex items-center justify-between gap-3 pb-3"},p4={class:"text-base font-semibold text-gray-900"},f4={class:"ion-padding-start text-sm"},h4={class:"ion-padding-start text-sm"},v4={class:"flex justify-between pt-2"},g4={key:1},to=255,no=1e3,y4=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(a,{emit:n}){const t=a,o=n,i=Wa(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),c=e.computed(()=>r.value?"Save":"Create"),l=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),m=e.ref(!1),f=e.ref(null),p=e.ref(!1),v=e.ref(!1),g=e.computed(()=>d.value.name?l.value.name.trim()?l.value.name.length>to?`Name must be ${to} characters or less`:null:"Name is required":null),E=e.computed(()=>d.value.description&&l.value.description.length>no?`Description must be ${no} characters or less`:null),T=e.computed(()=>{const z=l.value.name.trim().length>0,H=l.value.name.length<=to,M=l.value.description.length<=no;return z&&H&&M&&!p.value}),N=e.computed(()=>{var z;return((z=u.value)==null?void 0:z.name)??"None (Root)"}),w=e.computed(()=>f.value?f.value.children_count===0&&f.value.media_count===0:!1),h=e.computed(()=>f.value?f.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":f.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${f.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await x()});async function x(){if(t.albumId)try{const z=await i.fetchAlbum(t.albumId);f.value=z,l.value={name:z.name,description:z.description??"",parent_id:z.parent_id},z.parent_id&&(u.value={id:z.parent_id,name:"Parent Album"})}catch(z){o("error",z)}}function D(){d.value.name=!0}function C(){d.value.description=!0}function y(){m.value=!0}function S(z){u.value={id:z.id,name:z.name},l.value.parent_id=z.id,m.value=!1}function A(){m.value=!1}function k(){o("close")}function B(){o("close")}async function R(){if(d.value.name=!0,d.value.description=!0,!(!T.value||p.value)){p.value=!0;try{const z={name:l.value.name.trim(),description:l.value.description.trim(),parent_id:l.value.parent_id};if(r.value&&t.albumId){const H=await i.updateAlbum(t.albumId,z);o("updated",H)}else{const H=await i.createAlbum(z);o("created",H)}o("close")}catch(z){o("error",z)}finally{p.value=!1}}}function U(){w.value&&(v.value=!0)}async function _(z){var M;if((((M=z.detail)==null?void 0:M.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch($){o("error",$)}finally{p.value=!1,v.value=!1}}}return(z,H)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[z.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(I.IonModal),{key:0,"is-open":z.isOpen,class:"album-manager-modal",onDidDismiss:B},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...H[4]||(H[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(R,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[5]||(H[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":H[0]||(H[0]=M=>l.value.name=M),"data-testid":"name-input",maxlength:to,onIonBlur:D},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",l4,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[6]||(H[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":H[1]||(H[1]=M=>l.value.description=M),"data-testid":"description-input",maxlength:no,onIonBlur:C},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",c4,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...H[7]||(H[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!w.value,title:w.value?void 0:h.value,onClick:U},{default:e.withCtx(()=>[...H[8]||(H[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!T.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",d4,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",u4,[e.createElementVNode("div",m4,[e.createElementVNode("h2",p4,e.toDisplayString(s.value),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...H[9]||(H[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(R,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[10]||(H[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":H[2]||(H[2]=M=>l.value.name=M),"data-testid":"name-input",maxlength:to,onIonBlur:D},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",f4,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...H[11]||(H[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":H[3]||(H[3]=M=>l.value.description=M),"data-testid":"description-input",maxlength:no,onIonBlur:C},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",h4,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...H[12]||(H[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.value),1)]),_:1})]),_:1}),e.createElementVNode("div",v4,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!w.value,title:w.value?void 0:h.value,onClick:U},{default:e.withCtx(()=>[...H[13]||(H[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!T.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",g4,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Nc,{"is-open":m.value,"selected-album-id":l.value.parent_id,title:"Select Parent Album",onClose:A,onConfirm:S},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(I.IonAlert),{"is-open":v.value,header:"Delete Album?",message:h.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:_},null,8,["is-open","message"])],64))}}),w4=Be(y4,[["__scopeId","data-v-22083f3a"]]),b4={class:"album-media-grid"},k4={class:"aspect-square"},x4={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},E4={class:"text-gray-500"},V4=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],S4={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},C4={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},N4={class:"aspect-square relative"},_4=["src","alt"],T4={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},M4=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(a,{emit:n}){const t=a,o=n,i=Wa(),r=e.ref([]),s=e.ref(!1),c=e.ref(null),l=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),m=e.computed(()=>!u.value&&r.value.length===0),f=e.computed(()=>{const B=t.columns;return["grid","gap-4",`grid-cols-${B.mobile??2}`,`sm:grid-cols-${B.sm??3}`,`md:grid-cols-${B.md??4}`,`lg:grid-cols-${B.lg??5}`,`xl:grid-cols-${B.xl??6}`]}),p=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 B=await i.fetchAlbumMedia(t.albumId);r.value=B}catch{r.value=[]}finally{s.value=!1}}function g(B){return t.selectedItems.includes(B)}function E(B){o("toggle-select",B);const R=g(B.uuid)?t.selectedItems.filter(U=>U!==B.uuid):[...t.selectedItems,B.uuid];o("selection-change",R)}function T(B){if(B.conversions&&typeof B.conversions=="object"){const R=B.conversions.thumb;if(typeof R=="string")return R}return B.original_url}function N(B){c.value=B}function w(){c.value=null}function h(B){o("preview",B)}function x(B){o("edit",B)}function D(B){o("detach",B.uuid)}function C(){o("add")}function y(B,R){t.reorderable&&(l.value=R,B.dataTransfer&&(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",String(R))))}function S(B,R){!t.reorderable||l.value===null||(B.preventDefault(),d.value=R)}function A(B,R){if(!t.reorderable||l.value===null)return;B.preventDefault();const U=l.value;if(U!==R){const _=[...r.value],[z]=_.splice(U,1);_.splice(R,0,z),r.value=_;const H=_.map(M=>M.uuid);o("reorder",H),i.reorderAlbumMedia(t.albumId,H).catch(()=>{v()})}l.value=null,d.value=null}function k(){l.value=null,d.value=null}return(B,R)=>(e.openBlock(),e.createElementBlock("div",b4,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,U=>(e.openBlock(),e.createBlock(e.unref(I.IonCard),{key:U,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",k4,[e.createVNode(e.unref(I.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",x4,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",E4,e.toDisplayString(B.emptyText),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"add-media-btn",onClick:C},{default:e.withCtx(()=>[...R[0]||(R[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(U,_)=>(e.openBlock(),e.createElementBlock("div",{key:U.uuid,"data-media-id":U.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":l.value===_,"ring-2 ring-primary":d.value===_&&l.value!==_}]),draggable:B.reorderable,onDragstart:z=>y(z,_),onDragover:z=>S(z,_),onDrop:z=>A(z,_),onDragend:k,onMouseenter:z=>N(U.uuid),onMouseleave:w},[d.value===_&&l.value!==_&&B.reorderable?(e.openBlock(),e.createElementBlock("div",S4)):e.createCommentVNode("",!0),B.reorderable?(e.openBlock(),e.createElementBlock("div",C4,[e.createVNode(e.unref(I.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),B.selectionMode?(e.openBlock(),e.createBlock(e.unref(I.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(U.uuid),class:"absolute top-2 left-2 z-20",onIonChange:z=>E(U)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",N4,[e.createElementVNode("img",{src:T(U),alt:U.file_name,class:"w-full h-full object-cover"},null,8,_4),B.showActions&&c.value===U.uuid?(e.openBlock(),e.createElementBlock("div",T4,[e.createVNode(e.unref(I.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:z=>h(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:z=>x(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:z=>D(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,V4))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:C},[e.createVNode(e.unref(I.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),R[1]||(R[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),B4=Be(M4,[["__scopeId","data-v-d84b796a"]]);function xr(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),c=e.ref(null),l=e.computed(()=>c.value!==null),d=T=>{if(r.value++,c.value=null,i.value=null,t.value=!1,T!=null&&typeof T=="object"&&!(T instanceof Blob)&&("image"in T||"state"in T||"sessionKey"in T)){const N=T;o.value=N.image??null,s.value=N.state??null}else o.value=T??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,c.value=null,t.value=!1,s.value=null},m=async T=>{try{return t.value=!0,i.value=T,a.onSave&&await a.onSave(T),u(),T}catch(N){const w=N;throw c.value=w,a.onError&&a.onError(w),w}finally{t.value=!1}},f=()=>{a.onCancel&&a.onCancel(),u()},p=T=>{c.value=T,a.onError&&a.onError(T)},v=()=>{c.value=null},g=()=>i.value,E=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:c,hasError:l,hasUnsavedChanges:E,open:d,close:u,handleSave:m,handleCancel:f,handleError:p,clearError:v,getEditedImage:g}}let Si=null;function F4(a){return Si||(Si=xr(a)),Si}function I4(a){return n=>new Promise((t,o)=>{xr({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function Er(a){return a.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const o={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(o.custom_properties=n.customProperties),o})}function Yi(a){return a.map((n,t)=>{const o={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(o.customProperties=n.custom_properties),o})}function Vr(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),$n(t)}return{name:"mediables",async upload(t,o){const r=await xt().uploadFile(t,{collection:(o==null?void 0:o.collection)||"default",customProperties:o==null?void 0:o.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,o){await xt().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await xt().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await xt().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await xt().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await xt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return xt().getMediaUrl(t,o)},getThumbnailUrl(t){var o,i;return(o=t.conversion_urls)!=null&&o.thumb?t.conversion_urls.thumb:(i=t.conversion_urls)!=null&&i.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await xt().deleteMedia(t)},async update(t,o){const r=await xt().updateMedia(t,o);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const o={};t.apiBaseUrl!==void 0&&(o.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(o.isAdmin=t.isAdmin),$n(o)}}}let ra=null;function R4(){return ra||(ra=Vr()),ra}function $4(){ra=null}const D4={apiBaseUrl:"/media-library-pro"};function Jo(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function Ci(a){const n={uuid:a.uuid,file_name:a.fileName||a.name,mime_type:`application/${a.extension}`,size:a.size,disk:"public",original_url:a.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return a.name&&(n.name=a.name),a.original_url&&(n.url=a.original_url),a.preview_url&&(n.thumbnail_url=a.preview_url,n.preview_url=a.preview_url),a.custom_properties&&(n.custom_properties=a.custom_properties),n}function Sr(a){const n={...D4,...a};return{name:"spatie",async upload(o,i){const r=new FormData;r.append("file",o),i!=null&&i.collection&&r.append("collection",i.collection),i!=null&&i.customProperties&&r.append("custom_properties",JSON.stringify(i.customProperties));const s={Accept:"application/json",...n.headers},c=n.csrfToken||Jo();c&&(s["X-CSRF-TOKEN"]=c);const l={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(l.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,l);if(!d.ok){const f=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(f.message||`HTTP ${d.status}`)}const u=await d.json(),m=Ci(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Jo();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",o.modelType),s.append("model_id",String(o.modelId)),o.collection&&s.append("collection",o.collection);try{const c=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!c.ok)throw new Error(`HTTP ${c.status}`);return(await c.json()).map(Ci)}catch{return[]}},getUrl(o,i){var r;if(i){const s=(r=o.conversion_urls)==null?void 0:r[i];if(s)return s}return o.original_url||o.url||""},getThumbnailUrl(o){var i,r;return o.preview_url?o.preview_url:(i=o.conversion_urls)!=null&&i.preview?o.conversion_urls.preview:o.thumbnail_url?o.thumbnail_url:(r=o.conversion_urls)!=null&&r.thumb?o.conversion_urls.thumb:o.original_url||o.url||""},async delete(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Jo();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const c=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(c.message||`HTTP ${s.status}`)}},async update(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||Jo();s&&(r["X-CSRF-TOKEN"]=s);const c=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!c.ok){const d=await c.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${c.status}`)}const l=await c.json();return Ci(l)},configure(o){Object.assign(n,o)}}}let sa=null;function U4(){return sa||(sa=Sr()),sa}function A4(){sa=null}function _c(a,n){switch(a){case"mediables":return Vr(n);case"spatie":return Sr(n);default:throw new Error(`Unknown adapter: ${a}`)}}function wa(a){if(a===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(a)/Math.log(n));return parseFloat((a/Math.pow(n,o)).toFixed(2))+" "+t[o]}function Tc(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function Cr(a){return a.type.startsWith("image/")}async function Mc(a){return Cr(a)?new Promise(n=>{const t=new Image,o=URL.createObjectURL(a);t.onload=()=>{URL.revokeObjectURL(o),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),n(null)},t.src=o}):null}async function Bc(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${wa(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${wa(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-1)):a.type===i)||t.push({field:"type",message:`File type "${a.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const o=Tc(a.name);n.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if(Cr(a)&&(n.maxDimensions||n.minDimensions)){const o=await Mc(a);o&&(n.maxDimensions&&(o.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(o.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const o=await n.customValidator(a);t.push(...o)}return{valid:t.length===0,errors:t}}function Nr(a={}){const n=e.ref(a.rules||{});function t(l){n.value=l}async function o(l){return Bc(l,n.value)}async function i(l){const d=new Map;return await Promise.all(l.map(async u=>{const m=await o(u);d.set(u,m)})),d}function r(l,d){return n.value.maxItems?d+l<=n.value.maxItems:!0}const s=e.computed(()=>{const l=[];return n.value.acceptedMimeTypes&&l.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&l.push(...n.value.acceptedExtensions),l.join(",")});function c(l){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?l.startsWith(d.slice(0,-1)):l===d)}return{rules:n,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:c}}function O4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function L4(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function Fc(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:c,onUploadError:l,onQueueComplete:d}=a,u=e.ref(new Map),m=e.ref(new Set),f=o?{rules:o}:{},{validateFile:p}=Nr(f);async function v(){if(m.value.size>=t)return;const k=Array.from(u.value.entries()).find(([U,_])=>_.status==="pending"&&!m.value.has(U));if(!k){Array.from(u.value.values()).every(_=>_.status==="completed"||_.status==="error")&&u.value.size>0&&(d==null||d());return}const[B,R]=k;await g(B,R)}async function g(k,B){m.value.add(k),B.status="uploading",B.abortController=new AbortController,u.value.set(k,{...B}),r==null||r(B);try{const R={onProgress:_=>{B.progress=_,u.value.set(k,{...B}),s==null||s(B)},signal:B.abortController.signal};i&&(R.collection=i);const U=await n.upload(B.file,R);B.status="completed",B.progress=100,B.media=U.media,u.value.set(k,{...B}),c==null||c(B,U.media)}catch(R){R.name==="AbortError"?u.value.delete(k):(B.status="error",B.error=R.message,u.value.set(k,{...B}),l==null||l(B,R))}finally{m.value.delete(k),delete B.abortController,v()}}async function E(k){var U;const B=Array.from(k),R=[];for(const _ of B){const z=await p(_),H=O4(),M=L4(_),$={id:H,file:_,progress:0,status:z.valid?"pending":"error"};!z.valid&&((U=z.errors[0])!=null&&U.message)&&($.error=z.errors[0].message),M&&($.previewUrl=M),u.value.set(H,$);const X={media:null,clientId:H,name:_.name,order:0,upload:$,errors:z.errors};R.push(X)}for(let _=0;_<t;_++)v();return R}function T(k){const B=u.value.get(k);B&&(B.abortController&&B.abortController.abort(),B.previewUrl&&URL.revokeObjectURL(B.previewUrl),u.value.delete(k),m.value.delete(k),v())}async function N(k){const B=u.value.get(k);!B||B.status!=="error"||(B.status="pending",B.progress=0,delete B.error,u.value.set(k,{...B}),v())}function w(){for(const[k,B]of u.value.entries())(B.status==="completed"||B.status==="error")&&(B.previewUrl&&URL.revokeObjectURL(B.previewUrl),u.value.delete(k))}function h(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),m.value.clear()}function x(k){return u.value.get(k)}const D=e.computed(()=>m.value.size>0),C=e.computed(()=>m.value.size),y=e.computed(()=>Array.from(u.value.values()).filter(k=>k.status==="pending").length),S=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(k=>k.status==="completed"||k.status==="error")),A=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:D,activeCount:C,pendingCount:y,isComplete:S,addFiles:E,cancelUpload:T,retryUpload:N,clearCompleted:w,clearAll:h,getUpload:x,uploadsArray:A}}function Ic(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,c=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),l=e.ref(!1);let d=null;function u(N,w,h){n&&("dataTransfer"in N&&N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(h))),d=N.target,d&&d.classList.add(r),c.value={isDragging:!0,dragIndex:h,dropIndex:h,draggedItem:w},l.value=!0,o==null||o(w,h))}function m(N,w){var h;if(!(!n||!c.value.isDragging)&&(N.preventDefault(),c.value.dropIndex!==w)){const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s);const D=(h=N.target)==null?void 0:h.closest("[data-index]");D==null||D.classList.add(s),c.value.dropIndex=w}}function f(){if(!c.value.isDragging)return;const{dragIndex:N,dropIndex:w,draggedItem:h}=c.value;d&&d.classList.remove(r);const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s),N!==null&&w!==null&&N!==w&&h&&(t==null||t({fromIndex:N,toIndex:w,item:h})),v(),i==null||i()}function p(){d&&d.classList.remove(r);const N=document.querySelector(`.${s}`);N==null||N.classList.remove(s),v(),i==null||i()}function v(){c.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},l.value=!1,d=null}function g(N,w,h){const x=[...N],[D]=x.splice(w,1);return x.splice(h,0,D),x.map((C,y)=>({...C,order:y}))}function E(N,w){return{draggable:n,"data-index":w,onDragstart:h=>u(h,N,w),onDragover:h=>m(h,w),onDragend:()=>f(),onDrop:h=>{h.preventDefault(),f()}}}function T(N){N.key==="Escape"&&c.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",T)}),e.onUnmounted(()=>{document.removeEventListener("keydown",T),p()}),{dragState:c,isDragging:l,startDrag:u,handleDragOver:m,endDrag:f,cancelDrag:p,reorderItems:g,getDragProps:E}}function Za(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:c,sortable:l=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:f,maxConcurrentUploads:p=3,onChange:v,onUpload:g,onUploadComplete:E,onUploadError:T,onRemove:N,onReorder:w,onError:h,onReadyToSubmitChange:x}=a,D={maxItems:r,maxFileSize:s,acceptedMimeTypes:c,...u},C=f||_c(m),y=e.ref([]),S=e.ref(!1),A=e.ref([]);function k(oe){if(oe.length===0)return[];const le=oe[0];return"media"in le&&"clientId"in le?oe:Yi(oe)}y.value=k(n);const{acceptString:B,canAddFiles:R}=Nr({rules:D}),U=Fc({adapter:C,maxConcurrent:p,rules:D,collection:i,onUploadStart:oe=>{g==null||g(oe)},onUploadComplete:(oe,le)=>{const Ee=y.value.findIndex(Se=>Se.clientId===oe.id);Ee!==-1&&(y.value[Ee]={...y.value[Ee],media:le,name:le.name||le.file_name,upload:{...oe,status:"completed"}}),E==null||E(le)},onUploadError:(oe,le)=>{const Ee=y.value.findIndex(Se=>Se.clientId===oe.id);Ee!==-1&&(y.value[Ee]={...y.value[Ee],upload:{...oe,status:"error",error:le.message},errors:[{field:"upload",message:le.message,code:"UPLOAD_ERROR"}]}),T==null||T({file:oe.file,message:le.message})},onQueueComplete:()=>{v==null||v(y.value)}}),{dragState:_,getDragProps:z,reorderItems:H}=Ic({enabled:l&&!d,onReorder:oe=>{y.value=H(y.value,oe.fromIndex,oe.toIndex),w==null||w(y.value),v==null||v(y.value)}}),M=e.computed(()=>U.isUploading.value),$=e.computed(()=>!U.isUploading.value&&U.pendingCount.value===0),X=e.computed(()=>r?y.value.length>=r:!1),W=e.computed(()=>Er(y.value)),te=e.computed(()=>y.value.length),ge=e.computed(()=>r?Math.max(0,r-y.value.length):1/0);e.watch($,oe=>{x==null||x(oe)});function Ne(oe){y.value=k(oe),v==null||v(y.value)}async function ee(oe){if(d)return;const le=Array.from(oe);if(!R(le.length,y.value.length)){const He={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};A.value=[He],h==null||h([He]);return}const Ee=await U.addFiles(le),Se=y.value.length,rt=Ee.map((He,pt)=>({...He,order:Se+pt}));y.value=[...y.value,...rt],v==null||v(y.value)}function F(oe){d||(oe.upload&&(oe.upload.status==="uploading"||oe.upload.status==="pending")&&U.cancelUpload(oe.clientId),y.value=y.value.filter(le=>le.clientId!==oe.clientId),y.value=y.value.map((le,Ee)=>({...le,order:Ee})),N==null||N(oe),v==null||v(y.value))}function P(oe){const le=y.value.find(Ee=>Ee.clientId===oe);le&&F(le)}function pe(){d||(U.clearAll(),y.value=[],v==null||v(y.value))}function ne(oe,le){d||!l||(y.value=H(y.value,oe,le),w==null||w(y.value),v==null||v(y.value))}function Y(oe,le){if(d)return;const Ee=y.value.findIndex(Se=>Se.clientId===oe);Ee!==-1&&(y.value[Ee]={...y.value[Ee],...le},v==null||v(y.value))}function Me(oe){U.cancelUpload(oe),P(oe)}async function ce(oe){await U.retryUpload(oe)}async function se(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const oe={modelType:t,modelId:o,collection:i},le=y.value.filter(Ee=>Ee.media&&!Ee.markedForRemoval).map(Ee=>Ee.media.uuid);S.value=!0;try{await C.attachMany(le,oe),await C.reorder(oe,le)}finally{S.value=!1}}async function ke(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const oe={modelType:t,modelId:o,collection:i};S.value=!0;try{const le=await C.fetchModelMedia(oe);y.value=Yi(le),v==null||v(y.value)}finally{S.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&ke().catch(console.error)}),e.onUnmounted(()=>{U.clearAll()}),{items:y,setItems:Ne,addFiles:ee,removeItem:F,removeItemById:P,clearAll:pe,reorderItems:ne,updateItem:Y,cancelUpload:Me,retryUpload:ce,save:se,load:ke,isLoading:S,isUploading:M,isReadyToSubmit:$,isAtMaxItems:X,errors:A,dragState:_,getDragProps:z,adapter:C,formValues:W,acceptString:B,count:te,remainingSlots:ge}}const z4=["aria-disabled"],P4=["accept","multiple","disabled"],j4={class:"media-dropzone__content"},W4={class:"media-dropzone__title"},Z4={class:"media-dropzone__subtitle"},X4=["disabled"],H4={key:0,class:"media-dropzone__helper"},G4=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(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),c=e.computed(()=>{const g=[];return t.maxFileSize&&g.push(`Max size: ${wa(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function l(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function m(g){var T;if(g.preventDefault(),i.value=!1,t.disabled)return;const E=(T=g.dataTransfer)==null?void 0:T.files;E&&E.length>0&&o("files",E)}function f(){var g;t.disabled||(g=r.value)==null||g.click()}function p(g){const E=g.target,T=E.files;T&&T.length>0&&o("files",T),E.value=""}function v(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f())}return(g,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":g.disabled,"aria-label":"Upload files",onClick:f,onKeydown:v,onDragenter:l,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:p},null,40,P4),e.createElementVNode("div",j4,[e.renderSlot(g.$slots,"icon",{},()=>[E[0]||(E[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",W4,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",Z4,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(f,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,X4),c.value?(e.openBlock(),e.createElementBlock("p",H4,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])],42,z4))}}),_r=Be(G4,[["__scopeId","data-v-b1366c1e"]]),J4=["data-index"],Y4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},K4={class:"media-item__thumbnail"},q4=["src","alt"],Q4={key:1,class:"media-item__file-icon"},e3={key:2,class:"media-item__progress-overlay"},t3={class:"media-item__progress-text"},n3={key:3,class:"media-item__processing-overlay"},o3={key:4,class:"media-item__error-overlay"},a3={class:"media-item__info"},i3=["title"],r3={key:0,class:"media-item__size"},s3={key:1,class:"media-item__error-message"},l3={class:"media-item__actions"},c3=["disabled"],d3=["disabled"],u3=["disabled"],m3=["disabled"],p3=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(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var w,h,x;return((w=t.item.upload)==null?void 0:w.status)==="uploading"||((h=t.item.upload)==null?void 0:h.status)==="pending"||((x=t.item.upload)==null?void 0:x.status)==="queued"}),c=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="processing"}),l=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.progress)||0}),m=e.computed(()=>{var w;return t.item.name||((w=t.item.media)==null?void 0:w.file_name)||"Unknown file"}),f=e.computed(()=>{var C,y;const w=((C=t.item.media)==null?void 0:C.size)||((y=t.item.upload)==null?void 0:y.file.size);if(!w)return"";const h=1024,x=["Bytes","KB","MB","GB"],D=Math.floor(Math.log(w)/Math.log(h));return parseFloat((w/Math.pow(h,D)).toFixed(2))+" "+x[D]}),p=e.computed(()=>{var h,x;const w=((h=t.item.media)==null?void 0:h.mime_type)||((x=t.item.upload)==null?void 0:x.file.type);return w==null?void 0:w.startsWith("image/")}),v=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":c.value,"media-item--error":l.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function g(){t.disabled||o("remove",t.item)}function E(){t.disabled||o("edit",t.item)}function T(){t.disabled||o("retry",t.item)}function N(){t.disabled||o("cancel",t.item)}return(w,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":w.index,onMouseenter:h[0]||(h[0]=x=>i.value=!0),onMouseleave:h[1]||(h[1]=x=>i.value=!1)},[w.sortable&&!w.disabled?(e.openBlock(),e.createElementBlock("div",Y4,[...h[2]||(h[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",K4,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,q4)):(e.openBlock(),e.createElementBlock("div",Q4,[...h[3]||(h[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",e3,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",t3,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",n3,[...h[4]||(h[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",o3,[...h[5]||(h[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",a3,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,i3),f.value?(e.openBlock(),e.createElementBlock("span",r3,e.toDisplayString(f.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",s3,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",l3,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:w.disabled,"aria-label":"Cancel upload",onClick:N},[...h[6]||(h[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,c3)):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:w.disabled,"aria-label":"Retry upload",onClick:T},[...h[7]||(h[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,d3)):e.createCommentVNode("",!0),w.showEdit&&w.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:w.disabled,"aria-label":"Edit",onClick:E},[...h[8]||(h[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,u3)):e.createCommentVNode("",!0),w.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:w.disabled,"aria-label":"Remove",onClick:g},[...h[9]||(h[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,m3)):e.createCommentVNode("",!0)])],42,J4))}}),Tr=Be(p3,[["__scopeId","data-v-ff81c9ec"]]),f3=["aria-label"],h3=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],v3={key:0,class:"media-collection__footer"},g3={class:"media-collection__count"},y3={key:0},w3={key:0,class:"media-collection__uploading"},b3=["name","value"],k3=["name","value"],x3=["name","value"],E3=["name","value"],V3={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},S3=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(a,{emit:n}){const t=a,o=n,i={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:M=>{o("update:modelValue",M),o("change",M)},onUpload:M=>{o("upload",M)},onUploadComplete:M=>{o("upload-complete",M)},onUploadError:M=>{o("upload-error",M)},onRemove:M=>{o("remove",M)},onReorder:M=>{o("reorder",M)},onError:M=>{o("validation-error",M)},onReadyToSubmitChange:M=>{o("is-ready-to-submit-change",M)}},{items:r,setItems:s,addFiles:c,removeItem:l,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:f,isUploading:p,isAtMaxItems:v,errors:g,dragState:E,getDragProps:T,adapter:N,formValues:w,acceptString:h,count:x,remainingSlots:D}=Za(i);e.provide("mediaAdapter",N),e.provide("mediaCollection",{items:r,addFiles:c,removeItem:l,reorderItems:d}),e.watch(()=>t.modelValue,M=>{M!==r.value&&s(M)},{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":f.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":E.value.isDragging}));function S(M){c(M)}function A(M){l(M)}function k(M){m(M.clientId)}function B(M){u(M.clientId)}function R(M){}function U(M,$,X){if(!t.sortable||t.disabled)return;const W=T($,X);W.onDragstart&&W.onDragstart(M)}function _(M,$){if(!t.sortable||t.disabled)return;M.preventDefault();const X=r.value[$],W=T(X,$);W.onDragover&&W.onDragover(M)}function z(M,$){const X=T(M,$);X.onDragend&&X.onDragend()}function H(M,$){M.preventDefault();const X=r.value[$],W=T(X,$);W.onDrop&&W.onDrop(M)}return(M,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(y.value)},[e.renderSlot(M.$slots,"dropzone",{addFiles:e.unref(c)},()=>[C.value?(e.openBlock(),e.createBlock(_r,{key:0,accept:e.unref(h),multiple:M.maxItems!==1,disabled:M.disabled,"max-file-size":M.maxFileSize,"max-items":e.unref(D),onFiles:S},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(x)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(X,W)=>e.renderSlot(M.$slots,"item",{key:X.clientId,item:X,index:W,remove:()=>A(X)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(E).dropIndex===W}]),draggable:M.sortable&&!M.disabled,"data-index":W,onDragstart:te=>U(te,X,W),onDragover:te=>_(te,W),onDragend:te=>z(X,W),onDrop:te=>H(te,W)},[e.createVNode(Tr,{item:X,adapter:e.unref(N),disabled:M.disabled,sortable:M.sortable,"show-remove":!M.readonly,"show-edit":!1,index:W,onRemove:A,onRetry:k,onCancel:B,onEdit:R},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,h3)],!0)),128))],8,f3)):C.value?e.createCommentVNode("",!0):e.renderSlot(M.$slots,"empty",{key:1},()=>[$[0]||($[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(M.$slots,"footer",{count:e.unref(x),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",v3,[e.createElementVNode("span",g3,[e.createTextVNode(e.toDisplayString(e.unref(x))+" "+e.toDisplayString(e.unref(x)===1?"file":"files")+" ",1),M.maxItems?(e.openBlock(),e.createElementBlock("span",y3," / "+e.toDisplayString(M.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",w3," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),M.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}`,type:"hidden",name:`${M.name}[${W}][uuid]`,value:X.uuid},null,8,b3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}-name`,type:"hidden",name:`${M.name}[${W}][name]`,value:X.name},null,8,k3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${X.uuid}-order`,type:"hidden",name:`${M.name}[${W}][order]`,value:X.order},null,8,x3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(X,W)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${M.name}-${X.uuid}-props`},[X.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${M.name}[${W}][custom_properties]`,value:JSON.stringify(X.custom_properties)},null,8,E3)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",V3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),X=>(e.openBlock(),e.createElementBlock("p",{key:X.code||X.message,class:"media-collection__error"},e.toDisplayString(X.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),C3=Be(S3,[["__scopeId","data-v-10a5bfff"]]);function Mr(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:c,onError:l,onReadyToSubmitChange:d,...u}=a,f={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:C=>{t==null||t(C[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:c,onError:l,onReadyToSubmitChange:d},p=Za(f),v=e.computed(()=>p.items.value[0]||null),g=e.computed(()=>v.value!==null),E=e.computed(()=>p.formValues.value[0]||null);function T(C){C===null?p.clearAll():p.setItems([C])}async function N(C){const y=v.value;y&&p.removeItem(y),await p.addFiles([C])}function w(){v.value&&p.removeItem(v.value)}async function h(C){const y=v.value;y&&p.removeItem(y),await p.addFiles([C]);const S=p.items.value[0];S&&(o==null||o(y,S))}function x(){var C;(C=v.value)!=null&&C.upload&&p.cancelUpload(v.value.clientId)}async function D(){var C,y;((y=(C=v.value)==null?void 0:C.upload)==null?void 0:y.status)==="error"&&await p.retryUpload(v.value.clientId)}return{item:v,setItem:T,addFile:N,removeItem:w,replaceItem:h,cancelUpload:x,retryUpload:D,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:g,errors:p.errors,adapter:p.adapter,formValue:E,acceptString:p.acceptString}}const N3=["accept","disabled"],_3={class:"media-attachment__preview"},T3=["name","value"],M3=["name","value"],B3=["name","value"],F3=["name","value"],I3={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},R3=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r={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=>{o("update:modelValue",k),o("change",k)},onUpload:k=>{o("upload",k)},onUploadComplete:k=>{o("upload-complete",k)},onUploadError:k=>{o("upload-error",k)},onRemove:k=>{o("remove",k)},onReplace:(k,B)=>{o("replace",B)},onError:k=>{o("validation-error",k)},onReadyToSubmitChange:k=>{o("is-ready-to-submit-change",k)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,hasItem:v,errors:g,adapter:E,formValue:T,acceptString:N}=Mr(r);e.provide("mediaAdapter",E),e.watch(()=>t.modelValue,k=>{k!==s.value&&c(k)},{deep:!0});const w=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),h=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":v.value}));function x(k){k.length>0&&l(k[0])}function D(){var k;(k=i.value)==null||k.click()}function C(k){const B=k.target,R=B.files;R&&R.length>0&&u(R[0]),B.value=""}function y(k){d()}function S(k){f()}function A(k){m()}return(k,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(N),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:C},null,40,N3),w.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(l)},()=>[e.createVNode(_r,{accept:e.unref(N),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:x},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:D},()=>[e.createElementVNode("div",_3,[e.createVNode(Tr,{item:e.unref(s),adapter:e.unref(E),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:y,onRetry:S,onCancel:A},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:D},[...B[0]||(B[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},()=>[B[1]||(B[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),k.generateFormFields&&e.unref(T)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(T).uuid},null,8,T3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(T).name},null,8,M3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(T).order},null,8,B3),e.unref(T).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(T).custom_properties)},null,8,F3)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",I3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),R=>(e.openBlock(),e.createElementBlock("p",{key:R.code||R.message,class:"media-attachment__error"},e.toDisplayString(R.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),$3=Be(R3,[["__scopeId","data-v-26911174"]]),Rc={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"}},D3=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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:k=>{i("update:modelValue",k),i("change",k)},onUpload:k=>{i("upload",k)},onUploadComplete:k=>{i("upload-complete",k)},onUploadError:k=>{i("upload-error",k)},onRemove:k=>{i("remove",k)},onReorder:k=>{i("reorder",k)},onError:k=>{i("validation-error",k)},onReadyToSubmitChange:k=>{i("is-ready-to-submit-change",k)}},{items:s,setItems:c,addFiles:l,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:E,isAtMaxItems:T,errors:N,dragState:w,getDragProps:h,adapter:x,formValues:D,acceptString:C}=Za(r);e.provide("mediaAdapter",x),e.provide("mediaCollection",{items:s,addFiles:l,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,k=>{k!==s.value&&c(k)},{deep:!0});const y=e.computed(()=>({...Rc,...o.labels})),S=e.computed(()=>({accept:C.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||T.value})),A=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:g.value,isReadyToSubmit:E.value,isAtMaxItems:T.value,errors:N.value,addFiles:l,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:f,retryUpload:p,labels:y.value,dropzoneProps:S.value}));return n({items:s,addFiles:l,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:E,isAtMaxItems:T,errors:N,dragState:w,getDragProps:h,adapter:x,formValues:D,acceptString:C}),(k,B)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(A.value)))}}),U3=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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItem:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:y=>{i("update:modelValue",y),i("change",y)},onUpload:y=>{i("upload",y)},onUploadComplete:y=>{i("upload-complete",y)},onUploadError:y=>{i("upload-error",y)},onRemove:y=>{i("remove",y)},onReplace:(y,S)=>{i("replace",S)},onError:y=>{i("validation-error",y)},onReadyToSubmitChange:y=>{i("is-ready-to-submit-change",y)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:E,errors:T,adapter:N,formValue:w,acceptString:h}=Mr(r);e.provide("mediaAdapter",N),e.watch(()=>o.modelValue,y=>{y!==s.value&&c(y)},{deep:!0});const x=e.computed(()=>({...Rc,...o.labels})),D=e.computed(()=>({accept:h.value,multiple:!1,disabled:o.disabled||o.readonly||E.value})),C=e.computed(()=>({item:s.value,hasItem:E.value,isLoading:p.value,isUploading:v.value,isReadyToSubmit:g.value,errors:T.value,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,labels:x.value,dropzoneProps:D.value}));return n({item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:E,errors:T,adapter:N,formValue:w,acceptString:h}),(y,S)=>e.renderSlot(y.$slots,"default",e.normalizeProps(e.guardReactiveProps(C.value)))}}),A3=["name","value"],O3=["name","value"],L3=["name","value"],z3=["name","value"],P3=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(a){const n=a,t=e.computed(()=>n.item?[n.item]:n.items),o=e.computed(()=>Er(t.value));function i(c,l){var u;const d=((u=o.value[c])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${l}]`}function r(c,l){return`${n.name}[${c}][${l}]`}function s(c,l){return n.format==="spatie"?i(c,l):r(c,l)}return(c,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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,A3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,O3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,L3),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,z3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=Nc;exports.AlbumManager=w4;exports.AlbumMediaGrid=B4;exports.AlbumTree=Cc;exports.ArrayBufferTarget=ar;exports.ImageEditor=rl;exports.ImageEditorModal=sl;exports.LiveStreamManager=XE;exports.ManagedMediaGallery=lu;exports.MediaAttachment=$3;exports.MediaCollection=C3;exports.MediaCollectionDropzone=_r;exports.MediaCollectionItem=Tr;exports.MediaWorkspace=au;exports.ModelMediaManager=op;exports.Muxer=Fl;exports.VideoEditor=Ji;exports.VideoEditorDialog=Tb;exports.VideoEditorSimple=Qb;exports.VideoExportPanel=Fk;exports.VideoJobClient=kr;exports.VideoPlayer=Ec;exports.VideoTimeline=E2;exports.VideoToolsPanel=mk;exports.VideoUploader=wx;exports._sfc_main=D3;exports._sfc_main$1=U3;exports._sfc_main$2=P3;exports.applyTemporaryMediaStoreConfig=al;exports.configureMediaStore=$n;exports.createAdapter=_c;exports.createEmptyEditorState=Wd;exports.createImageEditor=I4;exports.createMediablesAdapter=Vr;exports.createSpatieAdapter=Sr;exports.deserializeEditorState=jd;exports.formatFileSize=wa;exports.fromMediaArray=Yi;exports.getFileExtension=Tc;exports.getImageDimensions=Mc;exports.getMediablesAdapter=R4;exports.getSpatieAdapter=U4;exports.isImageFile=Cr;exports.normalizeEditorState=Ki;exports.normalizeRecipeForServerRender=db;exports.recipeHasServerRenderableEdits=cb;exports.recipeHasUnsupportedServerEdits=xc;exports.resetMediablesAdapter=$4;exports.resetSpatieAdapter=A4;exports.restoreMediaStoreConfig=ol;exports.serializeEditorState=tl;exports.snapshotMediaStoreConfig=nl;exports.toFormValues=Er;exports.useAdminMediaStore=il;exports.useAlbumDragDrop=Sc;exports.useAlbumStore=Wa;exports.useAlbums=Vc;exports.useGlobalImageEditor=F4;exports.useImageEditorModal=xr;exports.useMediaAttachment=Mr;exports.useMediaCollection=Za;exports.useMediaDragSort=Ic;exports.useMediaStore=xt;exports.useMediaUploadQueue=Fc;exports.useMediaValidation=Nr;exports.validateFile=Bc;
342
+ //# sourceMappingURL=index-DCljToZr.cjs.map