@codingfactory/mediables-vue 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-dBsAo3iz.cjs → PixiFrameExporter-BKFYai9I.cjs} +2 -2
- package/dist/{PixiFrameExporter-dBsAo3iz.cjs.map → PixiFrameExporter-BKFYai9I.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-Cz7dg92v.js → PixiFrameExporter-w_UZwFZG.js} +2 -2
- package/dist/{PixiFrameExporter-Cz7dg92v.js.map → PixiFrameExporter-w_UZwFZG.js.map} +1 -1
- package/dist/components/video/VideoEditorDialog.vue.d.ts +2 -2
- package/dist/editor-DAx1zj7y.cjs +42 -0
- package/dist/editor-DAx1zj7y.cjs.map +1 -0
- package/dist/{editor-CfH1RN8F.js → editor-DJXRx8vN.js} +1219 -913
- package/dist/editor-DJXRx8vN.js.map +1 -0
- package/dist/index-BSiVRjOF.cjs +342 -0
- package/dist/index-BSiVRjOF.cjs.map +1 -0
- package/dist/{index-DDmYo-6o.js → index-j6fnH8-G.js} +7277 -6673
- package/dist/index-j6fnH8-G.js.map +1 -0
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/editor-BPW3mi6G.cjs +0 -42
- package/dist/editor-BPW3mi6G.cjs.map +0 -1
- package/dist/editor-CfH1RN8F.js.map +0 -1
- package/dist/index-DDmYo-6o.js.map +0 -1
- package/dist/index-Du0vZ5BO.cjs +0 -39
- package/dist/index-Du0vZ5BO.cjs.map +0 -1
package/dist/index-Du0vZ5BO.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";var hd=Object.defineProperty;var vd=(a,n,t)=>n in a?hd(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var A=(a,n,t)=>vd(a,typeof n!="symbol"?n+"":n,t);const fa=require("pinia"),e=require("vue"),Oe=require("pixi.js"),ot=require("./editor-BPW3mi6G.cjs"),F=require("@ionic/vue"),gd=require("pixi-filters");function yd(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 Xe=yd(Oe);let kt={apiBaseUrl:"/api/v1",isAdmin:!1};function Mn(a){kt={...kt,...a}}function Qs(){return{...kt}}function el(a){kt={...a}}function tl(a){const n=Qs();return Mn(a),()=>{el(n)}}const wd=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()},wt=fa.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),f=e.ref(new Map),p=e.ref(new Map),h=e.ref(new Set),g=e.ref(new Map),w=e.ref({}),E=5*60*1e3,M=e.computed(()=>{if(kt.apiScope)return kt.apiScope;if(kt.isAdmin)return"admin"}),V=e.computed(()=>M.value==="admin");function y(){return kt.httpClient||wd}function m(ee){const ue=kt.apiBaseUrl||"/api/v1",ge=M.value?`/${M.value}`:"";return`${ue}${ge}${ee}`}function b(ee,ue){return`${M.value??"default"}-${ee}-${JSON.stringify(ue)}`}function R(ee){return Date.now()-ee<E}function N(){g.value.clear(),w.value={}}function v(ee){if(!ee||!ee.data)return;const ue={};ee.data.forEach(ge=>{const xe=`${ge.file_name}-${ge.collection_name||"default"}`,ne=ue[xe];(!ne||Object.keys(ge.generated_conversions||{}).length>Object.keys(ne.generated_conversions||{}).length)&&(ue[xe]=ge)}),a.value=Object.values(ue),ee.meta&&(i.value=ee.meta.current_page,r.value=Math.ceil(ee.meta.total/ee.meta.per_page))}async function C(ee=1,ue={}){const ge=b(ee,ue),xe=g.value.get(ge);if(xe&&R(xe.timestamp)){const ne=xe.data;return v(ne),ne}t.value=!0,o.value=null;try{const ne=new URLSearchParams;ne.append("page",ee.toString()),ne.append("per_page",s.value.toString()),V.value&&ne.append("linked","1");for(const Je in ue)if(Object.prototype.hasOwnProperty.call(ue,Je)){const lt=ue[Je];lt!=null&<!==""&&ne.append(Je,String(lt))}const he=await y()(m(`/media?${ne}`));return g.value.set(ge,{data:he,timestamp:Date.now()}),v(he),he}catch(ne){throw o.value=ne instanceof Error?ne.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function O(ee,ue){t.value=!0,o.value=null;const ge=`${ee.name}-${Date.now()}`,xe={file:ee,progress:0,status:"uploading"};f.value.set(ge,xe);try{const ne=new FormData;ne.append("file",ee),ne.append("collection",ue.collection),ue.ownerUuid&&(ne.append("owner_uuid",ue.ownerUuid),ne.append("owner_type",ue.ownerType||"")),ue.usageUuid&&(ne.append("usage_uuid",ue.usageUuid),ne.append("usage_type",ue.usageType||""),ne.append("usage_purpose",ue.usagePurpose||"")),ue.customProperties&&ne.append("custom_properties",JSON.stringify(ue.customProperties));const he=await y()(m("/media"),{method:"POST",body:ne});return xe.status="completed",xe.progress=100,xe.media=he==null?void 0:he.data,i.value===1&&(he!=null&&he.data)&&(a.value=[he.data,...a.value]),N(),(he==null?void 0:he.data)||null}catch(ne){throw xe.status="error",xe.error=ne instanceof Error?ne.message:"Upload failed",o.value=xe.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{f.value.delete(ge)},5e3)}}async function x(ee){t.value=!0,o.value=null;const ue=a.value.findIndex(xe=>xe.uuid===ee);let ge;ue!==-1&&(ge=a.value.splice(ue,1)[0]);try{return await y()(m(`/media/${ee}`),{method:"DELETE"}),h.value.delete(ee),N(),!0}catch(xe){throw ge&&ue!==-1&&a.value.splice(ue,0,ge),o.value=xe instanceof Error?xe.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function _(ee,ue){t.value=!0,o.value=null;try{const xe=await y()(m(`/media/${ee}`),{method:"PATCH",body:ue,data:ue});if(xe!=null&&xe.data){const ne=a.value.findIndex(ke=>ke.uuid===ee);return ne!==-1&&(a.value[ne]={...a.value[ne],...xe.data}),N(),xe.data}return null}catch(ge){throw o.value=ge instanceof Error?ge.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function I(){t.value=!0,o.value=null;try{const ue=await y()(m("/media/collections"));return n.value=(ue==null?void 0:ue.data)||[],n.value}catch(ee){throw o.value=ee instanceof Error?ee.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function U(ee,ue,ge="images",xe){d.value=!0,u.value=null;try{const ne=new URLSearchParams;ne.append("collection",ge),xe&&ne.append("search",xe);const he=await y()(m(`/media/model/${ee}/${ue}?${ne}`));return he!=null&&he.data?(l.value=he.data,he.data):[]}catch(ne){throw u.value=ne instanceof Error?ne.message:"Failed to fetch model media",l.value=[],new Error(u.value)}finally{d.value=!1}}async function $(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...l.value];try{const he=await y()(m(`/media/model/${ee}/${ue}/attach`),{method:"POST",body:{media_uuids:ge,collection:xe}});return await U(ee,ue,xe),(he==null?void 0:he.data)||[]}catch(ke){throw l.value=ne,u.value=ke instanceof Error?ke.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function j(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...l.value];l.value=l.value.filter(ke=>ke.uuid!==ge);try{return await y()(m(`/media/model/${ee}/${ue}/detach`),{method:"POST",body:{media_uuid:ge,collection:xe}}),!0}catch(ke){throw l.value=ne,u.value=ke instanceof Error?ke.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function P(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...l.value],ke=new Map(l.value.map(he=>[he.uuid,he]));l.value=ge.map(he=>ke.get(he)).filter(he=>he!==void 0);try{return await y()(m(`/media/model/${ee}/${ue}/reorder`),{method:"POST",body:{media_uuids:ge,collection:xe}}),!0}catch(he){throw l.value=ne,u.value=he instanceof Error?he.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function T(ee,ue,ge={}){const xe=y(),ne=kt.apiBaseUrl||"/api/v1",ke={image_data:ue.imageData,filters:ue.metadata.filters,crop_data:ue.metadata.cropRect,save_as_new:!0,as_variant:ge.asVariant===!0};return ge.name!==void 0&&(ke.name=ge.name),(await xe(`${ne}/editor/${ee}/save`,{method:"POST",body:ke})).media}function L(ee,ue,ge){c.value=ge!==void 0?{type:ee,uuid:ue,collection:ge}:{type:ee,uuid:ue},w.value[`${ee}-${ue}`]={timestamp:Date.now()}}function G(){c.value={type:null,uuid:null},l.value=[],u.value=null}async function Z(){if(!c.value.type||!c.value.uuid)return;const ee=await U(c.value.type,c.value.uuid,c.value.collection||"images");l.value=ee||[]}function ce(){a.value.forEach(ee=>h.value.add(ee.uuid))}function _e(){h.value.clear()}function Re(ee){h.value.has(ee)?h.value.delete(ee):h.value.add(ee)}function ae(ee){return h.value.has(ee)}function B(){return Array.from(f.value.values()).some(ee=>ee.status==="uploading")}function z(ee){return f.value.get(ee)||p.value.get(ee)}function de(){return[...Array.from(f.value.values()),...Array.from(p.value.values())]}async function ie(){const ee=Array.from(h.value);let ue=0;for(const ge of ee)try{await x(ge),ue++}catch{}return _e(),ue}function K(ee,ue){var ge;return ue&&((ge=ee.conversion_urls)!=null&&ge[ue])?ee.conversion_urls[ue]||"":ee.original_url||ee.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:V,modelContext:c,modelMedia:l,isLoadingModelMedia:d,modelMediaError:u,selectedItems:h,uploadProgress:f,uploadQueue:p,cachedResponses:w,fetchMedia:C,uploadFile:O,deleteMedia:x,updateMedia:_,clearCache:N,fetchCollections:I,fetchModelMedia:U,attachMedia:$,detachMedia:j,reorderMedia:P,saveEditedImage:T,setModelContext:L,clearModelContext:G,refreshModelMedia:Z,selectAllItems:ce,clearSelection:_e,toggleSelection:Re,isSelected:ae,deleteSelectedItems:ie,hasActiveUploads:B,getUploadProgress:z,getAllUploadProgress:de,getMediaUrl:K}}),nl=()=>((kt.apiScope!=="admin"||kt.isAdmin!==!0)&&Mn({...kt,apiScope:"admin",isAdmin:!0}),wt());function bd(a,n){try{let t=ot.getFilter(a);if(t||(ot.registerCorePixiFilters(),t=ot.getFilter(a)),!t){try{const r=ot.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const kd=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function c(){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 f=r.getState(),p=f.crop,h=f.activeFilters,g=f.filterValues,w=r._renderer.sprite,E={width:Math.round((w==null?void 0:w.width)??0),height:Math.round((w==null?void 0:w.height)??0)},M={imageData:u,dimensions:E,metadata:{hasCrop:(p==null?void 0:p.rect)!=null,cropRect:(p==null?void 0:p.rect)??null,filters:h?Array.from(h):[],filterValues:g??{},aspectRatio:(p==null?void 0:p.aspect)??"free",dimensions:E}};o("save",M)}function l(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Xe,ot.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 ot.VanillaImageEditor(i.value,u),r.setFilterRegistry({getAllFilters:ot.getAllFilters,getFilter:ot.getFilter,getFiltersByCategory:ot.getFiltersByCategory}),r.save=function(){c()},r.on("cancel",l),t.initialImage&&r.loadImage(t.initialImage)}return e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const f=u[0];f&&f.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)}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(u,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Ne=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},ol=Ne(kd,[["__scopeId","data-v-dd5088f5"]]),xd={class:"editor-modal-panel"},Ed={class:"editor-fill"},Vd=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},acceptedFormats:{default:"image/jpeg,image/png,image/webp,image/gif"},maxFileSize:{default:10},onSave:{},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(null),c=e.ref(!1),l=e.ref(null),d=V=>new Promise((y,m)=>{const b=new FileReader;b.onload=R=>{var v;const N=(v=R.target)==null?void 0:v.result;typeof N=="string"?y(N):m(new Error("Failed to read file"))},b.onerror=()=>m(new Error("Failed to read file")),b.readAsDataURL(V)}),u=V=>{o("error",V)},f=async()=>{if(t.initialImage instanceof File)try{const V=await d(t.initialImage);s.value=V}catch(V){u(V)}else typeof t.initialImage=="string"&&(s.value=t.initialImage)},p=()=>{e.nextTick(()=>{if(i.value){const V=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");V&&V.focus()}})};e.watch(()=>t.modelValue,V=>{r.value=V,V&&(l.value=document.activeElement,t.initialImage&&f(),p())},{immediate:!0}),e.watch(()=>t.initialImage,V=>{V&&r.value&&f()});const h=async V=>{try{c.value=!0,t.onSave&&await t.onSave(V),o("save",V)}catch(y){u(y)}finally{c.value=!1}},g=()=>{o("cancel"),E()},w=()=>{c.value||E()},E=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null),setTimeout(()=>{s.value=null},300)},M=V=>{if(V.key==="Escape"&&r.value&&!c.value){E();return}if(V.key==="Tab"&&r.value&&i.value){const y=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(y.length===0)return;const m=y[0],b=y[y.length-1];V.shiftKey&&document.activeElement===m?(V.preventDefault(),b.focus()):!V.shiftKey&&document.activeElement===b&&(V.preventDefault(),m.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",M)}),t.modelValue&&t.initialImage&&f(),(V,y)=>(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(w,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:w}),e.createElementVNode("div",xd,[e.createElementVNode("div",Ed,[e.createVNode(ol,{"initial-image":s.value??V.initialImage,theme:V.theme,"crop-shape":V.cropShape,preset:V.preset,"primary-color":V.primaryColor,"secondary-color":V.secondaryColor,"save-button-color":V.saveButtonColor,"download-button-color":V.downloadButtonColor,onSave:h,onCancel:g,onError:u},null,8,["initial-image","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),al=Ne(Vd,[["__scopeId","data-v-e19beb15"]]),Sd={class:"media-workspace"},Cd={class:"media-workspace-toolbar"},Nd={class:"media-workspace-label"},Td=["value"],_d={class:"media-workspace-grid"},Md=["onClick"],Bd=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var f;const t=a,o=n,i=wt(),r=e.ref(t.initialScopeId??((f=t.subScopes[0])==null?void 0:f.id)??""),s=e.computed(()=>t.subScopes),c=e.computed(()=>s.value.find(p=>p.id===r.value));let l=null;function d(){l&&(l(),l=null),t.apiScope&&(l=tl({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var h;const p={};(h=c.value)!=null&&h.collection&&(p.collection=c.value.collection),await i.fetchMedia(1,p),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(h=>h.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,p=>{p&&(o("scope-change",p),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{l&&(l(),l=null)}),(p,h)=>(e.openBlock(),e.createElementBlock("div",Sd,[e.createElementVNode("div",Cd,[e.createElementVNode("label",Nd,[h[2]||(h[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[0]||(h[0]=g=>r.value=g),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,g=>(e.openBlock(),e.createElementBlock("option",{key:g.id,value:g.id},e.toDisplayString(g.label),9,Td))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:h[1]||(h[1]=g=>o("upload"))}," Upload ")]),e.createElementVNode("div",_d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,g=>(e.openBlock(),e.createElementBlock("button",{key:g.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:w=>o("preview",g)},e.toDisplayString(g.file_name),9,Md))),128))])]))}}),Id=Ne(Bd,[["__scopeId","data-v-895f26fe"]]),Fd={class:"managed-media-gallery"},Rd={class:"gallery-grid"},$d=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",Fd,[e.createElementVNode("div",Rd,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Dd=Ne($d,[["__scopeId","data-v-a60fdcd7"]]),Ud="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>",Di="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>",Od="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>",Ui="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>",Ld="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>",Ad="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>",Jn="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>",zd="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>",il="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z'/></svg>",rl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",qr="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>",Pd="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>",Wd="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>",Qr="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>",so="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>",es="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>",jd="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>",nn="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>",Zd="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>",Wn="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>",Xd="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>",Hd="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>",ts="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>",sl="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>",ha="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>",Gd="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>",Jd="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>",Yd="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>",Yn="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>",ns="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M80 464V68.14a8 8 0 014-6.9C91.81 56.66 112.92 48 160 48c64 0 145 48 192 48a199.53 199.53 0 0077.23-15.77 2 2 0 012.77 1.85v219.36a4 4 0 01-2.39 3.65C421.37 308.7 392.33 320 352 320c-48 0-128-32-192-32s-80 16-80 16' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",qa="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Kd="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>",qd="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>",Qa="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>",Qd="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>",eu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' 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>",tu="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>",nu="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>",ll="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 192v128M304 192v128' 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'><path stroke-linecap='round' stroke-linejoin='round' d='M176 96h16v320h-16zM320 96h16v320h-16z' 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='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>",iu="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>",ru="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>",su="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>",lu="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>",cu="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>",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'/></svg>",uu="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>",mu="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>",mo="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>",pu="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>",fu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",os="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>",dl="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>",hu="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>",ei="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>",tn="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>",jn="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>",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' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302' 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 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>",gu="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>",yu="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>",wu="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>",bu="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>",ku="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>",Eu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-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>",Vu="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>",Ro="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 is=()=>{};function Su(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 Cu(a,n={}){let t,o,i=is;const r=l=>{clearTimeout(l),i(),i=is};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((f,p)=>{i=n.rejectOnCancel?p:f,s=l,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,f(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,f(l())},d)})}}function Nu(a,n=200,t={}){return Su(Cu(n,t),a)}const Zn=new Map;function Tu(a){const n=e.getCurrentScope();function t(c){var l;const d=Zn.get(a)||new Set;d.add(c),Zn.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=Zn.get(a);l&&(l.delete(c),l.size||r())}function r(){Zn.delete(a)}function s(c,l){var d;(d=Zn.get(a))==null||d.forEach(u=>u(c,l))}return{on:t,once:o,off:i,emit:s,reset:r}}function _u(){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 Mu(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=Tu("media-selection"),r=_u(),s=e.computed(()=>a.value.filter(b=>n.value.has(b.uuid))),c=e.computed(()=>n.value.size);e.watch(n,b=>{i.emit({type:"selection:changed",count:b.size,selectedIds:Array.from(b)})},{deep:!0});const l=e.computed(()=>a.value.length>0&&a.value.every(b=>n.value.has(b.uuid))),d=e.computed(()=>a.value.some(b=>n.value.has(b.uuid)));function u(b){return n.value.has(b)}function f(b){n.value.has(b)?(n.value.delete(b),t.value===b&&(t.value=null,o.value=-1)):(n.value.add(b),t.value=b,o.value=a.value.findIndex(R=>R.uuid===b),n.value.size===1&&r.selection())}function p(b){n.value.add(b),t.value=b,o.value=a.value.findIndex(R=>R.uuid===b)}function h(b){n.value.delete(b),t.value===b&&(t.value=null,o.value=-1)}function g(){a.value.forEach(b=>n.value.add(b.uuid))}function w(){n.value.clear(),t.value=null,o.value=-1}function E(){l.value?w():g()}function M(b,R){const N=a.value.findIndex(v=>v.uuid===b);if(N!==-1)if(R!=null&&R.shiftKey&&o.value!==-1){const v=Math.min(o.value,N),C=Math.max(o.value,N);for(let O=v;O<=C;O++)n.value.add(a.value[O].uuid)}else f(b)}function V(){if(a.value.length===0)return;let b=o.value+1;b>=a.value.length&&(b=0),w(),p(a.value[b].uuid)}function y(){if(a.value.length===0)return;let b=o.value-1;b<0&&(b=a.value.length-1),w(),p(a.value[b].uuid)}function m(b){switch(b.key){case"ArrowDown":b.preventDefault(),V();break;case"ArrowUp":b.preventDefault(),y();break;case"a":(b.ctrlKey||b.metaKey)&&(b.preventDefault(),g());break;case"Escape":b.preventDefault(),w();break;case" ":t.value&&(b.preventDefault(),f(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:f,select:p,deselect:h,selectAll:g,clear:w,toggleAll:E,rangeSelect:M,selectNext:V,selectPrevious:y,handleKeydown:m,selectionBus:i}}const Bu={class:"flex items-center justify-between w-full px-4"},Iu={class:"p-4"},Fu={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Ru={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},$u=["value"],Du={class:"flex gap-2 mt-4"},Uu={class:"flex justify-end mb-4"},Ou={key:1,class:"flex justify-center items-center h-64"},Lu={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Au={class:"text-sm text-theme-secondary"},zu={key:0},Pu={class:"mb-4"},Wu={class:"mb-4"},ju={class:"flex gap-2"},Zu={class:"flex items-center justify-between px-4 py-2"},Xu={class:"text-sm text-theme-secondary"},Hu={key:0},Gu={key:0},Ju={key:1},Yu={class:"flex gap-2"},Ku=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)),f=e.ref(!1),p=e.ref({}),h=e.ref(["images","documents","videos"]),g=e.ref(1),w=e.ref(!0),E=e.ref(!1),M=nl(),V=Mu(l);function y(B){var ge;const z=B.conversion_urls||{},de=B.proxy_url||B.original_url||B.url||"",ie=z.thumb||z.preview||B.preview_url||B.thumbnail_url||de,K=B.custom_properties||{},ee=K.width,ue=K.height;return{...B,uuid:B.uuid,name:B.name||B.file_name,file_name:B.file_name,filename:B.file_name,mime_type:B.mime_type,size:B.size,collection_name:B.collection_name||"images",disk:B.disk,original_url:de,url:de,thumbnail_url:ie,conversions:B.conversions||{},conversion_urls:z,generated_conversions:B.generated_conversions||{},custom_properties:K,caption:B.caption||null,alt_text:B.alt_text||null,created_at:B.created_at,updated_at:B.updated_at,is_image:((ge=B.mime_type)==null?void 0:ge.startsWith("image/"))||!1,...typeof ee=="number"?{width:ee}:{},...typeof ue=="number"?{height:ue}:{},...B.formatted_size!==void 0?{formatted_size:B.formatted_size}:{}}}e.watch(()=>t.selectedItems,B=>{u.value=new Set(B),V.clear(),B.forEach(z=>V.select(z))});const m=e.computed(()=>{var z;let B=l.value;return(z=p.value.types)!=null&&z.length&&(B=B.filter(de=>{var K,ee;const ie=(K=de.mime_type)==null?void 0:K.split("/")[0];return(ee=p.value.types)==null?void 0:ee.includes(ie)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&(B=B.filter(de=>{const ie=de.size/1048576;return!(p.value.sizeMin!==void 0&&ie<p.value.sizeMin||p.value.sizeMax!==void 0&&ie>p.value.sizeMax)})),B}),b=e.computed(()=>{var z;let B=0;return p.value.search&&B++,p.value.collection&&B++,(p.value.dateFrom||p.value.dateTo)&&B++,(z=p.value.types)!=null&&z.length&&(B+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&B++,B}),R=e.computed(()=>{const B=V.selectedCount.value;return B===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${B} ${B===1?"Item":"Items"}`:"Item"}`}),N=e.computed(()=>{const B=V.selectedCount.value;return!!(B===0||t.selectionMode==="single"&&B>1||t.maxSelection&&B>t.maxSelection)}),v=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 C(B=!0){B?(c.value=!0,l.value=[],g.value=1,w.value=!0):E.value=!0;try{const z={collection:p.value.collection||t.collection,per_page:24};switch((s.value||p.value.search)&&(z.search=s.value||p.value.search||""),p.value.dateFrom&&(z.from_date=p.value.dateFrom),p.value.dateTo&&(z.to_date=p.value.dateTo),i.value){case"recent":await M.fetchMedia(g.value,z),B?l.value=M.items.map(de=>y(de)):l.value=[...l.value,...M.items.map(de=>y(de))],w.value=M.currentPage<M.totalPages;break;case"model":if(t.modelType&&t.modelId){const de=await M.fetchModelMedia(t.modelType,t.modelId,z.collection,z.search);l.value=de?de.map(ie=>y(ie)):[],w.value=!1}break;case"library":await M.fetchMedia(g.value,z),B?l.value=M.items.map(de=>y(de)):l.value=[...l.value,...M.items.map(de=>y(de))],w.value=M.currentPage<M.totalPages;break}}catch{}finally{c.value=!1,E.value=!1}}async function O(B){if(!w.value||E.value){B!=null&&B.target&&B.target.complete();return}g.value++,await C(!1),B!=null&&B.target&&(B.target.complete(),w.value||(B.target.disabled=!0))}function x(B){return B==="recent"||B==="model"||B==="library"}function _(B){i.value=B,C()}function I(B){typeof B=="string"&&x(B)&&_(B)}async function U(B){t.selectionMode==="single"?(V.clear(),V.select(B.uuid)):(V.toggle(B.uuid),t.maxSelection&&V.selectedCount.value>t.maxSelection&&(V.deselect(B.uuid),await(await F.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function $(){o("confirm",V.selectedItems.value)}function j(){o("close")}function P(B){}const T=e.ref(null),L=e.ref(!1);function G(B){T.value=B,L.value=!0}function Z(B){const z=l.value.findIndex(ie=>ie.uuid===B.uuid);z!==-1&&(l.value[z]=B);const de={};B.alt_text!==void 0&&(de.alt_text=B.alt_text),B.caption!==void 0&&(de.caption=B.caption),B.custom_properties!==void 0&&(de.custom_properties=B.custom_properties),M.updateMedia(B.uuid,de)}function ce(){C()}function _e(){p.value={},s.value="",C()}const Re=Nu(()=>{C(!0)},300);e.watch(s,()=>{t.isOpen&&Re()});async function ae(B){try{await(await F.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 M.deleteMedia(B),await C()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,B=>{B&&C()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(B=>V.select(B))}),(B,z)=>{const de=e.resolveComponent("AdminMediaGrid"),ie=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(F.IonModal),{"is-open":B.isOpen,onDidDismiss:j,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(F.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{onClick:j},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(F.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(v.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Bu,[e.createVNode(e.unref(F.IonSegment),{value:i.value,onIonChange:z[0]||(z[0]=K=>I(K.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[15]||(z[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(F.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[16]||(z[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[17]||(z[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(F.IonButton),{fill:"clear",size:"small",onClick:z[1]||(z[1]=K=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[b.value>0?(e.openBlock(),e.createBlock(e.unref(F.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(b.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(F.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Iu,[f.value?(e.openBlock(),e.createElementBlock("div",Fu,[e.createElementVNode("div",Ru,[e.createElementVNode("div",null,[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[18]||(z[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":z[2]||(z[2]=K=>p.value.collection=K),class:"w-full p-2 border rounded"},[z[19]||(z[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,K=>(e.openBlock(),e.createElementBlock("option",{key:K,value:K},e.toDisplayString(K),9,$u))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[20]||(z[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[3]||(z[3]=K=>p.value.dateFrom=K),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[21]||(z[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[4]||(z[4]=K=>p.value.dateTo=K),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",Du,[e.createVNode(e.unref(F.IonButton),{size:"small",onClick:ce},{default:e.withCtx(()=>[...z[22]||(z[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(F.IonButton),{size:"small",fill:"clear",onClick:_e},{default:e.withCtx(()=>[...z[23]||(z[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":z[5]||(z[5]=K=>s.value=K),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Uu,[e.createVNode(e.unref(F.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:z[6]||(z[6]=K=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(F.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:z[7]||(z[7]=K=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),c.value?(e.openBlock(),e.createElementBlock("div",Ou,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"})])):m.value.length===0?(e.openBlock(),e.createElementBlock("div",Lu,[e.createVNode(e.unref(F.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),z[24]||(z[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Au,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(de,{key:3,"media-items":m.value,"selected-items":e.unref(V).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:U,onPreview:P,onEdit:G,onDelete:ae},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(F.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(K,ee)=>(e.openBlock(),e.createBlock(ie,{key:K.uuid,media:K,selected:e.unref(V).isSelected(K.uuid),"selection-mode":!0,index:ee,onToggleSelect:U,onPreview:P,onEdit:G,onDelete:ae},null,8,["media","selected","index"]))),128))]),_:1})),!c.value&&m.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(F.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:z[8]||(z[8]=K=>O(K))},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(F.IonModal),{"is-open":L.value,onDidDismiss:z[14]||(z[14]=K=>L.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(F.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{onClick:z[9]||(z[9]=K=>L.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(F.IonTitle),null,{default:e.withCtx(()=>[...z[25]||(z[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(F.IonContent),{class:"p-4"},{default:e.withCtx(()=>[T.value?(e.openBlock(),e.createElementBlock("div",zu,[e.createElementVNode("div",Pu,[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[26]||(z[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[10]||(z[10]=K=>T.value.caption=K),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,T.value.caption]])]),e.createElementVNode("div",Wu,[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...z[27]||(z[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[11]||(z[11]=K=>T.value.alt_text=K),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,T.value.alt_text]])]),e.createElementVNode("div",ju,[e.createVNode(e.unref(F.IonButton),{onClick:z[12]||(z[12]=K=>Z(T.value))},{default:e.withCtx(()=>[...z[28]||(z[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(F.IonButton),{fill:"clear",onClick:z[13]||(z[13]=K=>L.value=!1)},{default:e.withCtx(()=>[...z[29]||(z[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(F.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Zu,[e.createElementVNode("div",Xu,[e.unref(V).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Hu,[e.createTextVNode(e.toDisplayString(e.unref(V).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Gu," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Ju," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Yu,[e.createVNode(e.unref(F.IonButton),{fill:"clear",onClick:j},{default:e.withCtx(()=>[...z[30]||(z[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(F.IonButton),{disabled:N.value,onClick:$},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(R.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),qu=Ne(Ku,[["__scopeId","data-v-9a8c0954"]]),Qu={key:1,class:"flex flex-col items-center justify-center py-16"},em=["draggable","onDragstart","onDragover","onDrop"],tm={key:0,class:"absolute top-2 left-2 z-20"},nm=["checked","onChange"],om={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},am=["data-media-id"],im={key:0,class:"w-full h-full flex items-center justify-center"},rm=["src","alt","onError","onLoad"],sm={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},lm={class:"text-center"},cm={class:"text-4xl text-gray-400 mb-2"},dm={class:"text-sm font-medium text-gray-500"},um={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},mm=["onClick"],pm=["onClick"],fm=["onClick"],hm={class:"p-3"},vm={class:"text-sm font-medium truncate mb-1"},gm={class:"text-xs text-gray-600 dark:text-gray-400"},ym={key:0},wm={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},bm=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=N=>t.selectedItems.some(v=>v.uuid===N.uuid),d=e.computed(()=>{const N=t.columns,v=["grid","gap-4"];switch(N.mobile){case 1:v.push("grid-cols-1");break;case 2:v.push("grid-cols-2");break;case 3:v.push("grid-cols-3");break;case 4:v.push("grid-cols-4");break;default:v.push("grid-cols-2");break}switch(N.sm){case 1:v.push("sm:grid-cols-1");break;case 2:v.push("sm:grid-cols-2");break;case 3:v.push("sm:grid-cols-3");break;case 4:v.push("sm:grid-cols-4");break;case 5:v.push("sm:grid-cols-5");break;default:v.push("sm:grid-cols-3");break}switch(N.md){case 2:v.push("md:grid-cols-2");break;case 3:v.push("md:grid-cols-3");break;case 4:v.push("md:grid-cols-4");break;case 5:v.push("md:grid-cols-5");break;case 6:v.push("md:grid-cols-6");break;default:v.push("md:grid-cols-4");break}switch(N.lg){case 3:v.push("lg:grid-cols-3");break;case 4:v.push("lg:grid-cols-4");break;case 5:v.push("lg:grid-cols-5");break;case 6:v.push("lg:grid-cols-6");break;case 7:v.push("lg:grid-cols-7");break;default:v.push("lg:grid-cols-5");break}switch(N.xl){case 4:v.push("xl:grid-cols-4");break;case 5:v.push("xl:grid-cols-5");break;case 6:v.push("xl:grid-cols-6");break;case 7:v.push("xl:grid-cols-7");break;case 8:v.push("xl:grid-cols-8");break;default:v.push("xl:grid-cols-6");break}return v.join(" ")});function u(N,v,C){t.reorderable&&(i.value=v,N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/html","")))}function f(N,v){t.reorderable&&(N.preventDefault(),r.value=v)}function p(){r.value=null}function h(N,v){if(!t.reorderable||!i.value)return;N.preventDefault();const C=[...t.mediaItems],O=C.findIndex(x=>{var _;return x.uuid===((_=i.value)==null?void 0:_.uuid)});if(O!==-1&&O!==v&&i.value){const[x]=C.splice(O,1);C.splice(v,0,x),o("reorder",C)}i.value=null,r.value=null}function g(N){return N<1024?N+" B":N<1024*1024?(N/1024).toFixed(1)+" KB":(N/(1024*1024)).toFixed(1)+" MB"}function w(N){var C;return N.thumbnail_url||((C=N.conversion_urls)==null?void 0:C.thumb)||N.original_url||N.url||""}function E(N){var O,x,_;const v=((O=N.mime_type)==null?void 0:O.startsWith("image/"))||!1,C=!!(N.thumbnail_url||(x=N.conversion_urls)!=null&&x.thumb||(_=N.conversion_urls)!=null&&_.preview||N.original_url||N.url);return v&&C}function M(N){var v;return((v=N.split(".").pop())==null?void 0:v.toUpperCase())||""}function V(N){var C;const v=((C=N.mime_type)==null?void 0:C.toLowerCase())||"";return v.startsWith("image/")?"image":v.startsWith("video/")?"videocam":v.startsWith("audio/")?"musical-notes":v.includes("pdf")?"document-text":v.includes("zip")||v.includes("rar")?"archive":v.includes("sheet")||v.includes("excel")?"grid":v.includes("document")||v.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(c.value=new IntersectionObserver(N=>{N.forEach(v=>{var C;if(v.isIntersecting){const O=v.target.getAttribute("data-media-id");O&&(s.value.add(O),(C=c.value)==null||C.unobserve(v.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{c.value&&c.value.disconnect()});function y(N){return!0}function m(){c.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(v=>{var O;const C=v.getAttribute("data-media-id");C&&!s.value.has(C)&&((O=c.value)==null||O.observe(v))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),m()},{immediate:!0,deep:!0});function b(N,v){const C=N.target;delete C.dataset.fallbackIndex}function R(N,v){const C=N.target,O=C.closest("[data-media-id]"),x=[v.original_url,v.url,v.thumbnail_url,"preview_url"in v?v.preview_url:void 0].filter(_=>_&&_.trim()!==""&&_!==C.src);if(x.length>0&&C.dataset.fallbackIndex){const _=parseInt(C.dataset.fallbackIndex);if(_<x.length){C.dataset.fallbackIndex=(_+1).toString(),C.src=x[_]||"";return}}else if(x.length>0){C.dataset.fallbackIndex="1",C.src=x[0]||"";return}if(C.style.display="none",O&&!O.querySelector(".media-fallback-icon")){const I=document.createElement("div");I.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",I.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${V(v)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${M(v.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,O.appendChild(I)}}return(N,v)=>N.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,C=>e.createElementVNode("div",{key:`skeleton-${C}`,class:"relative"},[...v[1]||(v[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)):!N.mediaItems||!N.mediaItems.length?(e.openBlock(),e.createElementBlock("div",Qu,[v[2]||(v[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)),v[3]||(v[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),v[4]||(v[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:v[0]||(v[0]=C=>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(N.mediaItems,(C,O)=>(e.openBlock(),e.createElementBlock("div",{key:C.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===O}]),draggable:N.reorderable,onDragstart:x=>u(x,C),onDragover:x=>f(x,O),onDragleave:p,onDrop:x=>h(x,O)},[N.selectionMode?(e.openBlock(),e.createElementBlock("div",tm,[e.createElementVNode("input",{type:"checkbox",checked:l(C),onChange:x=>o("toggleSelect",C),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,nm)])):e.createCommentVNode("",!0),N.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",N.selectionMode?"left-10":"left-2"])},[e.renderSlot(N.$slots,"badge",{media:C,index:O},void 0,!0)],2)):e.createCommentVNode("",!0),N.reorderable?(e.openBlock(),e.createElementBlock("div",om,[...v[5]||(v[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(C)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":C.uuid},[E(C)&&!y(C.uuid)?(e.openBlock(),e.createElementBlock("div",im,[...v[6]||(v[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(C)&&y(C.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:w(C),alt:C.alt_text||C.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:x=>R(x,C),onLoad:x=>b(x)},null,40,rm)):(e.openBlock(),e.createElementBlock("div",sm,[e.createElementVNode("div",lm,[e.createElementVNode("div",cm,e.toDisplayString(V(C)),1),e.createElementVNode("p",dm,e.toDisplayString(M(C.file_name)),1)])])),e.createElementVNode("div",um,[e.createElementVNode("button",{onClick:x=>o("preview",C),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...v[7]||(v[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,mm),N.showEditButton&&E(C)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x=>o("edit",C),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...v[8]||(v[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,pm)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:x=>o("delete",C.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...v[9]||(v[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,fm)])],8,am),e.createElementVNode("div",hm,[e.createElementVNode("h4",vm,e.toDisplayString(C.file_name),1),e.createElementVNode("p",gm,[e.createTextVNode(e.toDisplayString(g(C.size))+" ",1),C.width&&C.height?(e.openBlock(),e.createElementBlock("span",ym," • "+e.toDisplayString(C.width)+"x"+e.toDisplayString(C.height),1)):e.createCommentVNode("",!0)]),C.caption?(e.openBlock(),e.createElementBlock("p",wm,e.toDisplayString(C.caption),1)):e.createCommentVNode("",!0)])],2)],42,em))),128))],2))}}),km=Ne(bm,[["__scopeId","data-v-f0c343b7"]]),xm={class:"model-media-manager"},Em=["accept","multiple"],Vm={class:"flex items-center justify-between mb-4"},Sm={key:0,class:"text-lg font-medium"},Cm={class:"flex gap-2"},Nm={key:0,class:"flex items-center justify-center py-8"},Tm={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"},_m={class:"text-gray-600 dark:text-gray-400"},Mm={class:"flex gap-2 mt-4"},Bm={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Im=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=wt(),r=e.ref(!1),s=e.ref(!1),c=e.ref(!1),l=e.ref(!1),d=e.ref(null),u=e.ref(null),f=e.ref(null),p=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),h=e.computed(()=>i.modelMedia.map(P=>P.uuid)),g=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")}),w=e.computed(()=>{if(d.value)return b(d.value)??void 0});function E(){Mn({isAdmin:t.mode==="admin"})}async function M(P){await(await F.toastController.create({message:P,duration:3e3,color:"danger",position:"bottom"})).present()}async function V(){if(!s.value)if(s.value=!0,E(),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(P){const T=P instanceof Error?P.message:"Failed to fetch media";o("error",{operation:"fetch",message:T,details:P})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,P=>{s.value&&o("update:media",P)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,V()}),e.watch(()=>t.mode,()=>{E()}),e.onMounted(()=>{V()}),e.onUnmounted(()=>{i.clearModelContext()});function y(){return i.modelMedia.length>0}function m(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function b(P){var L,G,Z;if(!((L=P.mime_type)!=null&&L.startsWith("image/")))return null;const T=P.original_url||P.url||((G=P.conversion_urls)==null?void 0:G.preview)||((Z=P.conversion_urls)==null?void 0:Z.thumb)||P.thumbnail_url;return T&&T.trim()!==""?T:null}function R(){c.value=!0}function N(){var P;(P=f.value)==null||P.click()}function v(){c.value=!1}function C(P){!t.allowEdit||!b(P)||(d.value=P,l.value=!0)}function O(){l.value=!1,d.value=null}async function x(P){if(!d.value)throw new Error("No media selected for editing");const T=d.value,L=t.editMode==="variant";try{u.value=null;const G=await i.saveEditedImage(T.uuid,P,{asVariant:L,name:T.file_name});L||await i.detachMedia(t.mediableType,t.mediableId,T.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[G.uuid],t.collection),o("edit-complete",{originalMedia:T,editedMedia:G,mode:t.editMode}),l.value=!1,d.value=null}catch(G){const Z=G instanceof Error?G.message:"Failed to save edited image";throw u.value=Z,await M(Z),G}}function _(P){if(u.value===P.message){u.value=null;return}M(P.message)}async function I(P){const T=P.target,L=T.files;if(!(!L||L.length===0)){for(let G=0;G<L.length;G++){const Z=L[G];if(p.value!==void 0&&p.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(Z.type)){o("error",{operation:"upload",message:`File type ${Z.type} is not accepted`,details:{file:Z.name}});continue}if(t.maxFileSize!==void 0&&Z.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:Z.name,size:Z.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:Z});try{const ce=await i.uploadFile(Z,{collection:t.collection});ce!=null&&ce.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[ce.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:Z}),o("attach",[ce]))}catch(ce){const _e=ce instanceof Error?ce.message:"Upload failed";o("error",{operation:"upload",message:_e,details:ce}),o("upload-progress",{status:"error",progress:0,file:Z,error:_e})}}T.value=""}}async function U(P){const T=P.map(L=>L.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,T,t.collection),o("reorder",i.modelMedia)}catch(L){const G=L instanceof Error?L.message:"Failed to reorder media";o("error",{operation:"reorder",message:G,details:L}),await M(G)}}async function $(P){const T=i.modelMedia.find(L=>L.uuid===P);try{await i.detachMedia(t.mediableType,t.mediableId,P,t.collection),T&&o("detach",T)}catch(L){const G=L instanceof Error?L.message:"Failed to detach media";o("error",{operation:"detach",message:G,details:L}),await M(G)}}async function j(P){c.value=!1;const T=P.map(Z=>Z.uuid),L=new Set(h.value);let G=Array.from(new Set(T)).filter(Z=>!L.has(Z));if(p.value!==void 0&&G.length>p.value&&(G=G.slice(0,p.value)),G.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,G,t.collection);const Z=i.modelMedia.filter(ce=>G.includes(ce.uuid));o("attach",Z)}catch(Z){const ce=Z instanceof Error?Z.message:"Failed to attach media";o("error",{operation:"attach",message:ce,details:Z})}}return(P,T)=>(e.openBlock(),e.createElementBlock("div",xm,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:f,type:"file",accept:g.value,multiple:p.value===void 0||p.value>1,class:"hidden","data-testid":"upload-input",onChange:I},null,40,Em),e.createElementVNode("div",Vm,[P.title?(e.openBlock(),e.createElementBlock("h3",Sm,e.toDisplayString(P.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Cm,[P.allowBrowse?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:0,fill:"outline",size:"small",disabled:m(),"data-testid":"browse-button",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"start",icon:e.unref(Qa)},null,8,["icon"]),T[1]||(T[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),P.allowUpload?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:1,fill:"solid",size:"small",disabled:m(),"data-testid":"upload-button",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"start",icon:e.unref(es)},null,8,["icon"]),T[2]||(T[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Nm,[e.createVNode(e.unref(F.IonSpinner),{"data-testid":"spinner"})])):y()?(e.openBlock(),e.createBlock(km,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!P.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!P.allowEdit,"selection-mode":!1,onReorder:U,onDelete:$,onEdit:C},e.createSlots({_:2},[P.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:L})=>[L===0?(e.openBlock(),e.createElementBlock("div",Bm," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Tm,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Qa),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",_m,e.toDisplayString(P.emptyText),1),e.createElementVNode("div",Mm,[P.allowBrowse?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"start",icon:e.unref(Qa)},null,8,["icon"]),T[3]||(T[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),P.allowUpload?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"start",icon:e.unref(es)},null,8,["icon"]),T[4]||(T[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(qu,e.mergeProps({"is-open":c.value,"selected-items":h.value,collection:P.collection},p.value!==null&&p.value!==void 0?{maxSelection:p.value}:{},{onConfirm:j,onClose:v}),null,16,["is-open","selected-items","collection"]),e.createVNode(al,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":T[0]||(T[0]=L=>l.value=L)},w.value?{initialImage:w.value}:{},{"on-save":x,onCancel:O,onError:_}),null,16,["modelValue"])]))}}),Fm=Ne(Im,[["__scopeId","data-v-71504dc3"]]),Rm=["src"],$m={class:"preview-controls"},Dm=["aria-label"],Um={class:"time-display"},Om={class:"current-time"},Lm={class:"total-time"},Am={key:0,class:"fps-display"},zm={key:0,class:"loading-overlay"},Pm={key:1,class:"error-overlay"},Wm=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Xe,r=a,s=t,c=e.ref(),l=e.ref(),d=e.ref(),u=e.ref(!0),f=e.ref(),p=e.ref(0),h=e.ref(0),g=e.ref(!1);let w,E,M=null,V=null,y=null,m=[],b="",R=null,N=0,v=0,C=0,O=0,x=!1,_=0,I=0,U,$=null,j=!1;const P=e.computed(()=>r.source&&typeof r.source=="string"?r.source:"");async function T(){var me,W;if(l.value&&!w&&!(!d.value||d.value.readyState<3))try{let Y=((me=c.value)==null?void 0:me.clientWidth)||800,te=((W=c.value)==null?void 0:W.clientHeight)||450;if((Y<=0||te<=0)&&(Y=d.value.videoWidth||800,te=d.value.videoHeight||450),w=new Xe.Application,await w.init({width:Y,height:te,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),l.value.appendChild(w.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!w&&T()},100),w&&(w.destroy(!0),w=null);return}N=d.value.videoWidth,v=d.value.videoHeight,V=document.createElement("canvas"),V.width=N,V.height=v,y=V.getContext("2d"),y.drawImage(d.value,0,0,N,v);const oe=Xe.Texture.from(V);M=oe.source,E=new Xe.Sprite(oe),E.visible=!0,E.alpha=1,he(),w.stage.addChild(E),w.renderer&&!w.renderer.destroyed&&w.render()}ce(),r.targetFps<60?L():w.ticker.add(G),g.value=!0,"ResizeObserver"in window&&(R=new ResizeObserver(oe=>{x||(x=!0,requestAnimationFrame(()=>{x=!1;const pe=oe[oe.length-1],{width:we,height:Be}=pe.contentRect;if(we<=0||Be<=0)return;const De=Math.round(we),H=Math.round(Be);De===C&&H===O||(C=De,O=H,he())}))}),R.observe(c.value)),r.filters&&r.filters.length>0&&ce(),r.showFps&&ge()}catch{f.value="Failed to initialize video preview"}}function L(){const me=1e3/r.targetFps;let W=performance.now();function Y(){if(j||!w)return;const te=performance.now(),oe=te-W;oe>=me&&(G(),W=te-oe%me),$=requestAnimationFrame(Y)}$=requestAnimationFrame(Y)}function G(){if(!(!w||!E||j)&&r.active)try{y&&V&&M&&d.value&&(d.value.readyState>=2&&(y.drawImage(d.value,0,0,V.width,V.height),M.update()),d.value.paused||s("frame-update",ae())),r.showFps&&I++,w.renderer&&!w.renderer.destroyed&&w.render()}catch{j=!0}}function Z(){for(const me of m)try{me.destroy()}catch{}m=[]}function ce(){if(E){if(!r.filters||r.filters.length===0){E.filters=null,Z();return}Z(),r.filters.forEach(me=>{const W=_e(me);W&&m.push(W)}),E.filters=m.length>0?m:null,b=JSON.stringify(r.filters),w&&w.render()}}function _e(me){const W=me.filterId,Y=me.params||{},te=ot.getFilter(W);if(te&&!ot.isFilterCompatibleWithMedia(W,"video"))return null;if(te&&te.createFilter)try{return te.createFilter(Y)}catch{}const oe=(pe,we,Be)=>Math.min(Be,Math.max(we,pe));switch(W){case"brightness":{const pe=new o,we=oe(typeof Y.brightness=="number"?Y.brightness:typeof Y.value=="number"?Y.value:1,0,5);return pe.brightness(we,!0),pe}case"contrast":{const pe=new o,we=oe(typeof Y.contrast=="number"?Y.contrast:typeof Y.value=="number"?Y.value:1,0,5);return pe.contrast(we,!0),pe}case"saturation":{const pe=new o,we=oe(typeof Y.saturation=="number"?Y.saturation:typeof Y.value=="number"?Y.value:1,0,5);return pe.saturate(we,!0),pe}case"hue":{const pe=new o,we=oe(typeof Y.value=="number"?Y.value:0,-180,180);return pe.hue(we,!0),pe}case"gaussian-blur":case"blur":{const pe=oe(typeof Y.blur=="number"?Y.blur:typeof Y.value=="number"?Y.value:2,0,10);return new i(pe)}case"grayscale":{const pe=new o;return pe.desaturate(),pe}case"sepia":case"color-matrix":{const pe=new o;return pe.sepia(!0),pe}case"vignette":{const pe=typeof Y.value=="number"?Y.value:.3;return Re(oe(pe,0,1))}default:return null}}function Re(me){const W=`
|
|
7
|
-
precision mediump float;
|
|
8
|
-
varying vec2 vTextureCoord;
|
|
9
|
-
uniform sampler2D uSampler;
|
|
10
|
-
uniform float strength;
|
|
11
|
-
void main(void){
|
|
12
|
-
vec2 uv = vTextureCoord - 0.5;
|
|
13
|
-
float dist = length(uv) * 2.0;
|
|
14
|
-
float vignette = smoothstep(1.0, 1.0 - strength, dist);
|
|
15
|
-
vec4 color = texture2D(uSampler, vTextureCoord);
|
|
16
|
-
gl_FragColor = vec4(color.rgb * (1.0 - vignette), color.a);
|
|
17
|
-
}
|
|
18
|
-
`;return new Xe.Filter(void 0,W,{strength:me})}function ae(){var W;return!w||!E?null:{dataUrl:w.canvas.toDataURL("image/jpeg",.8),timestamp:((W=d.value)==null?void 0:W.currentTime)||0,width:N||0,height:v||0}}function B(){var me;p.value=((me=d.value)==null?void 0:me.duration)||0,s("duration-change",p.value)}function z(){u.value=!1,f.value=void 0}function de(){u.value&&(u.value=!1),!g.value&&r.active?T():g.value}function ie(){var W,Y,te;const me=((W=d.value)==null?void 0:W.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:me,width:((Y=d.value)==null?void 0:Y.videoWidth)||0,height:((te=d.value)==null?void 0:te.videoHeight)||0})}function K(){s("play-pause")}function ee(me){var Y;const W=me.target;if(W!=null&&W.error)switch(W.error.code){case W.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case W.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case W.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case W.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${(Y=W.src)==null?void 0:Y.substring(0,100)}`;break;default:f.value="Failed to load video"}else f.value="Failed to load video";s("error",f.value),u.value=!1}function ue(me){d.value&&(d.value.currentTime=Math.max(0,Math.min(me,p.value)))}function ge(){U=window.setInterval(()=>{const me=performance.now(),W=me-_;h.value=Math.round(I*1e3/W),I=0,_=me},1e3)}function xe(me){const W=Math.floor(me/60),Y=Math.floor(me%60);return`${W.toString().padStart(2,"0")}:${Y.toString().padStart(2,"0")}`}function ne(){f.value=void 0,u.value=!0,d.value&&d.value.load()}function ke(){w&&(x||(x=!0,requestAnimationFrame(()=>{x=!1,he()})))}function he(){if(!w||!E||!N||!v||!c.value)return;const me=Math.round(c.value.clientWidth),W=Math.round(c.value.clientHeight);if(me<=0||W<=0)return;w.renderer.resize(me,W);const Y=w.screen.width/N,te=w.screen.height/v;let oe=1;switch(r.fitMode){case"cover":oe=Math.max(Y,te);break;case"none":oe=1;break;case"contain":default:oe=Math.min(Y,te);break}E.scale.set(oe),E.anchor.set(.5),E.position.set(w.screen.width/2,w.screen.height/2),E.visible=!0,E.alpha=1,w.renderer&&!w.renderer.destroyed&&w.render()}e.watch(()=>r.filters,()=>{g.value&&ce()},{deep:!0}),e.watch(()=>r.active,async me=>{if(me&&!w&&d.value&&d.value.readyState>=2){await T();return}w&&(me&&(await e.nextTick(),c.value&&c.value.getBoundingClientRect(),E&&y&&V&&M&&(d.value&&d.value.readyState>=2&&(y.drawImage(d.value,0,0,V.width,V.height),M.update()),he(),w.renderer&&!w.renderer.destroyed&&w.render())),r.targetFps>=60&&w.ticker&&(me?w.ticker.start():w.ticker.stop()))}),e.watch(P,me=>{me?(u.value=!0,f.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0});async function Je(){if(d.value){try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}f.value="Unable to start preview playback",s("error",f.value)}}e.watch(()=>r.isPlaying,me=>{d.value&&(me?Je():d.value.pause())}),e.watch(()=>r.playhead,me=>{d.value&&Math.abs(d.value.currentTime-me)>.5&&ue(me)}),e.watch(()=>r.fitMode,()=>{he()}),e.onMounted(()=>{j=!1,e.nextTick(()=>{c.value&&c.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",ke),_=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!g.value&&T()})}),e.onUnmounted(()=>{if(j=!0,$&&(cancelAnimationFrame($),$=null),window.removeEventListener("resize",ke),R&&(R.disconnect(),R=null),U&&clearInterval(U),w&&w.ticker&&(w.ticker.stop(),w.ticker.remove(G)),w){try{w.destroy(!0,{children:!0,texture:!0})}catch{}w=null}m.forEach(me=>{try{me.destroy()}catch{}}),m=[],E=null,M=null,V=null,y=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function lt(me){if(!await mt()||!d.value||!y||!V||!M)return null;const Y=d.value,te=Number.isFinite(p.value)&&p.value>0?p.value:Number.isFinite(Y.duration)&&Y.duration>0?Y.duration:0,oe=Math.max(0,Math.min(me,te));await new Promise(pe=>{let we=!1,Be=0;const De=()=>{we||(we=!0,Y.removeEventListener("seeked",H),window.clearTimeout(Be),pe())},H=()=>{De()},re=Number.isFinite(Y.currentTime)?Y.currentTime:0;if(Math.abs(re-oe)<.016){requestAnimationFrame(()=>De());return}Y.addEventListener("seeked",H),Be=window.setTimeout(()=>De(),700),Y.currentTime=oe});try{y.drawImage(Y,0,0,V.width,V.height),M.update(),w.render()}catch{return null}return w.canvas}async function mt(){if(!d.value)return!1;if(!w){if(!(d.value.readyState>=2))return!1;await T()}if(!w||!E||!y||!V||!M)return!1;if(r.filters&&r.filters.length>0){const me=E.filters,W=Array.isArray(me)?me.length:0,te=JSON.stringify(r.filters)!==b;(W===0||W!==r.filters.length||te)&&ce()}return await e.nextTick(),await new Promise(me=>{requestAnimationFrame(()=>me())}),!0}return n({captureFrameAt:lt,ensureReadyForCapture:mt,duration:p,pixiCanvas:e.computed(()=>w?w.canvas:null),videoElement:e.computed(()=>d.value??null)}),(me,W)=>(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:P.value,onLoadedmetadata:B,onLoadeddata:z,onCanplay:de,onTimeupdate:ie,onEnded:K,onError:ee,style:e.normalizeStyle({display:g.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:me.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,Rm),e.createElementVNode("div",$m,[e.createElementVNode("button",{class:"play-button",onClick:W[0]||(W[0]=Y=>me.$emit("play-pause")),"aria-label":me.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(F.IonIcon),{icon:me.isPlaying?e.unref(ll):e.unref(cl)},null,8,["icon"])],8,Dm),e.createElementVNode("div",Um,[e.createElementVNode("span",Om,e.toDisplayString(xe(me.playhead)),1),W[1]||(W[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Lm,e.toDisplayString(xe(p.value)),1)]),me.showFps?(e.openBlock(),e.createElementBlock("div",Am,e.toDisplayString(h.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",zm,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"}),W[2]||(W[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",Pm,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Ui)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:ne},"Retry")])):e.createCommentVNode("",!0)],512))}}),rs=Ne(Wm,[["__scopeId","data-v-1565c38d"]]);var Oi=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},D=(a,n,t)=>(Oi(a,n,"read from private field"),t?t.call(a):n.get(a)),Me=(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)},et=(a,n,t,o)=>(Oi(a,n,"write to private field"),n.set(a,t),t),jm=(a,n,t,o)=>({set _(i){et(a,n,i)},get _(){return D(a,n,o)}}),Fe=(a,n,t)=>(Oi(a,n,"access private method"),t),$e=new Uint8Array(8),Pt=new DataView($e.buffer),Ke=a=>[(a%256+256)%256],Ue=a=>(Pt.setUint16(0,a,!1),[$e[0],$e[1]]),Zm=a=>(Pt.setInt16(0,a,!1),[$e[0],$e[1]]),pl=a=>(Pt.setUint32(0,a,!1),[$e[1],$e[2],$e[3]]),ye=a=>(Pt.setUint32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),Xm=a=>(Pt.setInt32(0,a,!1),[$e[0],$e[1],$e[2],$e[3]]),vn=a=>(Pt.setUint32(0,Math.floor(a/2**32),!1),Pt.setUint32(4,a,!1),[$e[0],$e[1],$e[2],$e[3],$e[4],$e[5],$e[6],$e[7]]),Li=a=>(Pt.setInt16(0,2**8*a,!1),[$e[0],$e[1]]),Lt=a=>(Pt.setInt32(0,2**16*a,!1),[$e[0],$e[1],$e[2],$e[3]]),ti=a=>(Pt.setInt32(0,2**30*a,!1),[$e[0],$e[1],$e[2],$e[3]]),St=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},na=a=>a&&a[a.length-1],Ai=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},zt=(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=>[Lt(a[0]),Lt(a[1]),ti(a[2]),Lt(a[3]),Lt(a[4]),ti(a[5]),Lt(a[6]),Lt(a[7]),ti(a[8])],to=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(to):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,to(t)])),Bn=a=>a>=0&&a<2**32,Ge=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),ze=(a,n,t,o,i)=>Ge(a,[Ke(n),pl(t),o??[]],i),Hm=a=>{let n=512;return a.fragmented?Ge("ftyp",[St("iso5"),ye(n),St("iso5"),St("iso6"),St("mp41")]):Ge("ftyp",[St("isom"),ye(n),St("isom"),a.holdsAvc?St("avc1"):[],St("mp41")])},fi=a=>({type:"mdat",largeSize:a}),Gm=a=>({type:"free",size:a}),jo=(a,n,t=!1)=>Ge("moov",null,[Jm(n,a),...a.map(o=>Ym(o,n)),t?Np(a):null]),Jm=(a,n)=>{let t=zt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const c=Ai(s.samples);return c.presentationTimestamp+c.duration})),gi),o=Math.max(...n.map(s=>s.id))+1,i=!Bn(a)||!Bn(t),r=i?vn:ye;return ze("mvhd",+i,0,[r(a),r(a),ye(gi),r(t),Lt(1),Li(1),Array(10).fill(0),vl(hl),Array(24).fill(0),ye(o)])},Ym=(a,n)=>Ge("trak",null,[Km(a,n),qm(a,n)]),Km=(a,n)=>{let t=Ai(a.samples),o=zt(t?t.presentationTimestamp+t.duration:0,gi),i=!Bn(n)||!Bn(o),r=i?vn:ye,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?fl(a.info.rotation):a.info.rotation:s=hl,ze("tkhd",+i,3,[r(n),r(n),ye(a.id),ye(0),r(o),Array(8).fill(0),Ue(0),Ue(0),Li(a.info.type==="audio"?1:0),Ue(0),vl(s),Lt(a.info.type==="video"?a.info.width:0),Lt(a.info.type==="video"?a.info.height:0)])},qm=(a,n)=>Ge("mdia",null,[Qm(a,n),ep(a.info.type==="video"?"vide":"soun"),tp(a)]),Qm=(a,n)=>{let t=Ai(a.samples),o=zt(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Bn(n)||!Bn(o),r=i?vn:ye;return ze("mdhd",+i,0,[r(n),r(n),ye(a.timescale),r(o),Ue(21956),Ue(0)])},ep=a=>ze("hdlr",0,0,[St("mhlr"),St(a),ye(0),ye(0),ye(0),St("mp4-muxer-hdlr",!0)]),tp=a=>Ge("minf",null,[a.info.type==="video"?np():op(),ap(),sp(a)]),np=()=>ze("vmhd",0,1,[Ue(0),Ue(0),Ue(0),Ue(0)]),op=()=>ze("smhd",0,0,[Ue(0),Ue(0)]),ap=()=>Ge("dinf",null,[ip()]),ip=()=>ze("dref",0,0,[ye(1)],[rp()]),rp=()=>ze("url ",0,1),sp=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Ge("stbl",null,[lp(a),kp(a),xp(a),Ep(a),Vp(a),Sp(a),n?Cp(a):null])},lp=a=>ze("stsd",0,0,[ye(1)],[a.info.type==="video"?cp(Up[a.info.codec],a):yp(Lp[a.info.codec],a)]),cp=(a,n)=>Ge(a,[Array(6).fill(0),Ue(1),Ue(0),Ue(0),Array(12).fill(0),Ue(n.info.width),Ue(n.info.height),ye(4718592),ye(4718592),ye(0),Ue(1),Array(32).fill(0),Ue(24),Zm(65535)],[Op[n.info.codec](n),n.info.decoderConfig.colorSpace?pp(n):null]),dp={bt709:1,bt470bg:5,smpte170m:6},up={bt709:1,smpte170m:6,"iec61966-2-1":13},mp={rgb:0,bt709:1,bt470bg:5,smpte170m:6},pp=a=>Ge("colr",[St("nclx"),Ue(dp[a.info.decoderConfig.colorSpace.primaries]),Ue(up[a.info.decoderConfig.colorSpace.transfer]),Ue(mp[a.info.decoderConfig.colorSpace.matrix]),Ke((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),fp=a=>a.info.decoderConfig&&Ge("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),hp=a=>a.info.decoderConfig&&Ge("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),vp=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 ze("vpcC",1,0,[Ke(o),Ke(i),Ke(c),Ke(2),Ke(2),Ke(2),Ue(0)])},gp=()=>{let t=(1<<7)+1;return Ge("av1C",[t,0,0,0])},yp=(a,n)=>Ge(a,[Array(6).fill(0),Ue(1),Ue(0),Ue(0),ye(0),Ue(n.info.numberOfChannels),Ue(16),Ue(0),Ue(0),Lt(n.info.sampleRate)],[Ap[n.info.codec](n)]),wp=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return ze("esds",0,0,[ye(58753152),Ke(32+n.byteLength),Ue(1),Ke(0),ye(75530368),Ke(18+n.byteLength),Ke(64),Ke(21),pl(0),ye(130071),ye(130071),ye(92307584),Ke(n.byteLength),...n,ye(109084800),Ke(1),Ke(2)])},bp=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 Ge("dOps",[Ke(0),Ke(a.info.numberOfChannels),Ue(n),ye(a.info.sampleRate),Li(t),Ke(0)])},kp=a=>ze("stts",0,0,[ye(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[ye(n.sampleCount),ye(n.sampleDelta)])]),xp=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return ze("stss",0,0,[ye(n.length),n.map(([t])=>ye(t+1))])},Ep=a=>ze("stsc",0,0,[ye(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[ye(n.firstChunk),ye(n.samplesPerChunk),ye(1)])]),Vp=a=>ze("stsz",0,0,[ye(0),ye(a.samples.length),a.samples.map(n=>ye(n.size))]),Sp=a=>a.finalizedChunks.length>0&&na(a.finalizedChunks).offset>=2**32?ze("co64",0,0,[ye(a.finalizedChunks.length),a.finalizedChunks.map(n=>vn(n.offset))]):ze("stco",0,0,[ye(a.finalizedChunks.length),a.finalizedChunks.map(n=>ye(n.offset))]),Cp=a=>ze("ctts",0,0,[ye(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[ye(n.sampleCount),ye(n.sampleCompositionTimeOffset)])]),Np=a=>Ge("mvex",null,a.map(Tp)),Tp=a=>ze("trex",0,0,[ye(a.id),ye(1),ye(0),ye(0),ye(0)]),ss=(a,n)=>Ge("moof",null,[_p(a),...n.map(Mp)]),_p=a=>ze("mfhd",0,0,[ye(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},Mp=a=>Ge("traf",null,[Bp(a),Ip(a),Fp(a)]),Bp=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 ze("tfhd",0,n,[ye(a.id),ye(o.duration),ye(o.size),ye(o.flags)])},Ip=a=>ze("tfdt",1,0,[vn(zt(a.currentChunk.startTimestamp,a.timescale))]),Fp=a=>{let n=a.currentChunk.samples.map(w=>w.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(w=>w.size),o=a.currentChunk.samples.map(gl),i=a.currentChunk.samples.map(w=>zt(w.presentationTimestamp-w.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,f=s.size>1,p=!d&&c.size>1,h=l.size>1||[...l].some(w=>w!==0),g=0;return g|=1,g|=4*+d,g|=256*+u,g|=512*+f,g|=1024*+p,g|=2048*+h,ze("trun",1,g,[ye(a.currentChunk.samples.length),ye(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?ye(o[0]):[],a.currentChunk.samples.map((w,E)=>[u?ye(n[E]):[],f?ye(t[E]):[],p?ye(o[E]):[],h?Xm(i[E]):[]])])},Rp=a=>Ge("mfra",null,[...a.map($p),Dp()]),$p=(a,n)=>ze("tfra",1,0,[ye(a.id),ye(63),ye(a.finalizedChunks.length),a.finalizedChunks.map(o=>[vn(zt(o.startTimestamp,a.timescale)),vn(o.moofOffset),ye(n+1),ye(1),ye(1)])]),Dp=()=>ze("mfro",0,0,[ye(0)]),Up={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Op={avc:fp,hevc:hp,vp9:vp,av1:gp},Lp={aac:"mp4a",opus:"Opus"},Ap={aac:wp,opus:bp},va=class{},zi=class extends va{constructor(){super(...arguments),this.buffer=null}},yl=class extends va{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.")}},zp=class extends va{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")}},rn,Cn,wl=class{constructor(){this.pos=0,Me(this,rn,new Uint8Array(8)),Me(this,Cn,new DataView(D(this,rn).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){D(this,Cn).setUint32(0,a,!1),this.write(D(this,rn).subarray(0,4))}writeU64(a){D(this,Cn).setUint32(0,Math.floor(a/2**32),!1),D(this,Cn).setUint32(4,a,!1),this.write(D(this,rn).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)D(this,Cn).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(D(this,rn));a.length%8!==0&&this.write(D(this,rn).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}}};rn=new WeakMap;Cn=new WeakMap;var Zo,fn,lo,Kn,Xo,hi,Pp=class extends wl{constructor(a){super(),Me(this,Xo),Me(this,Zo,void 0),Me(this,fn,new ArrayBuffer(2**16)),Me(this,lo,new Uint8Array(D(this,fn))),Me(this,Kn,0),et(this,Zo,a)}write(a){Fe(this,Xo,hi).call(this,this.pos+a.byteLength),D(this,lo).set(a,this.pos),this.pos+=a.byteLength,et(this,Kn,Math.max(D(this,Kn),this.pos))}finalize(){Fe(this,Xo,hi).call(this,this.pos),D(this,Zo).buffer=D(this,fn).slice(0,Math.max(D(this,Kn),this.pos))}};Zo=new WeakMap;fn=new WeakMap;lo=new WeakMap;Kn=new WeakMap;Xo=new WeakSet;hi=function(a){let n=D(this,fn).byteLength;for(;n<a;)n*=2;if(n===D(this,fn).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(D(this,lo),0),et(this,fn,t),et(this,lo,o)};var Wp=2**24,jp=2,no,sn,qn,Gt,xt,oa,vi,Pi,bl,Wi,kl,oo,aa,ji=class extends wl{constructor(a){var n,t;super(),Me(this,oa),Me(this,Pi),Me(this,Wi),Me(this,oo),Me(this,no,void 0),Me(this,sn,[]),Me(this,qn,void 0),Me(this,Gt,void 0),Me(this,xt,[]),et(this,no,a),et(this,qn,((n=a.options)==null?void 0:n.chunked)??!1),et(this,Gt,((t=a.options)==null?void 0:t.chunkSize)??Wp)}write(a){D(this,sn).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(D(this,sn).length===0)return;let a=[],n=[...D(this,sn)].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 D(this,sn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);D(this,qn)?(Fe(this,oa,vi).call(this,i.data,i.start),Fe(this,oo,aa).call(this)):(o=(t=D(this,no).options).onData)==null||o.call(t,i.data,i.start)}D(this,sn).length=0}finalize(){D(this,qn)&&Fe(this,oo,aa).call(this,!0)}};no=new WeakMap;sn=new WeakMap;qn=new WeakMap;Gt=new WeakMap;xt=new WeakMap;oa=new WeakSet;vi=function(a,n){let t=D(this,xt).findIndex(c=>c.start<=n&&n<c.start+D(this,Gt));t===-1&&(t=Fe(this,Wi,kl).call(this,n));let o=D(this,xt)[t],i=n-o.start,r=a.subarray(0,Math.min(D(this,Gt)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Fe(this,Pi,bl).call(this,o,s),o.written[0].start===0&&o.written[0].end===D(this,Gt)&&(o.shouldFlush=!0),D(this,xt).length>jp){for(let c=0;c<D(this,xt).length-1;c++)D(this,xt)[c].shouldFlush=!0;Fe(this,oo,aa).call(this)}r.byteLength<a.byteLength&&Fe(this,oa,vi).call(this,a.subarray(r.byteLength),n+r.byteLength)};Pi=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)};Wi=new WeakSet;kl=function(a){let t={start:Math.floor(a/D(this,Gt))*D(this,Gt),data:new Uint8Array(D(this,Gt)),written:[],shouldFlush:!1};return D(this,xt).push(t),D(this,xt).sort((o,i)=>o.start-i.start),D(this,xt).indexOf(t)};oo=new WeakSet;aa=function(a=!1){var n,t;for(let o=0;o<D(this,xt).length;o++){let i=D(this,xt)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=D(this,no).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);D(this,xt).splice(o--,1)}}};var Zp=class extends ji{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}))}},gi=1e3,Xp=["avc","hevc","vp9","av1"],Hp=["aac","opus"],Gp=2082844800,Jp=["strict","offset","cross-track-offset"],Ve,Ce,ia,bt,nt,Qe,Nn,Tn,Zi,ln,cn,ao,yi,xl,wi,El,Xi,Vl,bi,Sl,Hi,Cl,Ho,ki,Ot,Ht,Gi,Nl,io,ra,sa,Ji,In,po,Go,xi,Tl=class{constructor(a){if(Me(this,yi),Me(this,wi),Me(this,Xi),Me(this,bi),Me(this,Hi),Me(this,Ho),Me(this,Ot),Me(this,Gi),Me(this,io),Me(this,sa),Me(this,In),Me(this,Go),Me(this,Ve,void 0),Me(this,Ce,void 0),Me(this,ia,void 0),Me(this,bt,void 0),Me(this,nt,null),Me(this,Qe,null),Me(this,Nn,Math.floor(Date.now()/1e3)+Gp),Me(this,Tn,[]),Me(this,Zi,1),Me(this,ln,[]),Me(this,cn,[]),Me(this,ao,!1),Fe(this,yi,xl).call(this,a),a.video=to(a.video),a.audio=to(a.audio),a.fastStart=to(a.fastStart),this.target=a.target,et(this,Ve,{firstTimestampBehavior:"strict",...a}),a.target instanceof zi)et(this,Ce,new Pp(a.target));else if(a.target instanceof yl)et(this,Ce,new ji(a.target));else if(a.target instanceof zp)et(this,Ce,new Zp(a.target));else throw new Error(`Invalid target: ${a.target}`);Fe(this,bi,Sl).call(this),Fe(this,wi,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(Fe(this,Go,xi).call(this),!D(this,Ve).video)throw new Error("No video track declared.");if(typeof D(this,Ve).fastStart=="object"&&D(this,nt).samples.length===D(this,Ve).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${D(this,Ve).fastStart.expectedVideoChunks}).`);let s=Fe(this,Ho,ki).call(this,D(this,nt),a,n,t,o,i,r);if(D(this,Ve).fastStart==="fragmented"&&D(this,Qe)){for(;D(this,cn).length>0&&D(this,cn)[0].decodeTimestamp<=s.decodeTimestamp;){let c=D(this,cn).shift();Fe(this,Ot,Ht).call(this,D(this,Qe),c)}s.decodeTimestamp<=D(this,Qe).lastDecodeTimestamp?Fe(this,Ot,Ht).call(this,D(this,nt),s):D(this,ln).push(s)}else Fe(this,Ot,Ht).call(this,D(this,nt),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(Fe(this,Go,xi).call(this),!D(this,Ve).audio)throw new Error("No audio track declared.");if(typeof D(this,Ve).fastStart=="object"&&D(this,Qe).samples.length===D(this,Ve).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${D(this,Ve).fastStart.expectedAudioChunks}).`);let r=Fe(this,Ho,ki).call(this,D(this,Qe),a,n,t,o,i);if(D(this,Ve).fastStart==="fragmented"&&D(this,nt)){for(;D(this,ln).length>0&&D(this,ln)[0].decodeTimestamp<=r.decodeTimestamp;){let s=D(this,ln).shift();Fe(this,Ot,Ht).call(this,D(this,nt),s)}r.decodeTimestamp<=D(this,nt).lastDecodeTimestamp?Fe(this,Ot,Ht).call(this,D(this,Qe),r):D(this,cn).push(r)}else Fe(this,Ot,Ht).call(this,D(this,Qe),r)}finalize(){if(D(this,ao))throw new Error("Cannot finalize a muxer more than once.");if(D(this,Ve).fastStart==="fragmented"){for(let n of D(this,ln))Fe(this,Ot,Ht).call(this,D(this,nt),n);for(let n of D(this,cn))Fe(this,Ot,Ht).call(this,D(this,Qe),n);Fe(this,sa,Ji).call(this,!1)}else D(this,nt)&&Fe(this,io,ra).call(this,D(this,nt)),D(this,Qe)&&Fe(this,io,ra).call(this,D(this,Qe));let a=[D(this,nt),D(this,Qe)].filter(Boolean);if(D(this,Ve).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=jo(a,D(this,Nn)),r=D(this,Ce).measureBox(i);n=D(this,Ce).measureBox(D(this,bt));let s=D(this,Ce).pos+r+n;for(let c of D(this,Tn)){c.offset=s;for(let{data:l}of c.samples)s+=l.byteLength,n+=l.byteLength}if(s<2**32)break;n>=2**32&&(D(this,bt).largeSize=!0)}let t=jo(a,D(this,Nn));D(this,Ce).writeBox(t),D(this,bt).size=n,D(this,Ce).writeBox(D(this,bt));for(let o of D(this,Tn))for(let i of o.samples)D(this,Ce).write(i.data),i.data=null}else if(D(this,Ve).fastStart==="fragmented"){let n=D(this,Ce).pos,t=Rp(a);D(this,Ce).writeBox(t);let o=D(this,Ce).pos-n;D(this,Ce).seek(D(this,Ce).pos-4),D(this,Ce).writeU32(o)}else{let n=D(this,Ce).offsets.get(D(this,bt)),t=D(this,Ce).pos-n;D(this,bt).size=t,D(this,bt).largeSize=t>=2**32,D(this,Ce).patchBox(D(this,bt));let o=jo(a,D(this,Nn));if(typeof D(this,Ve).fastStart=="object"){D(this,Ce).seek(D(this,ia)),D(this,Ce).writeBox(o);let i=n-D(this,Ce).pos;D(this,Ce).writeBox(Gm(i))}else D(this,Ce).writeBox(o)}Fe(this,In,po).call(this),D(this,Ce).finalize(),et(this,ao,!0)}};Ve=new WeakMap;Ce=new WeakMap;ia=new WeakMap;bt=new WeakMap;nt=new WeakMap;Qe=new WeakMap;Nn=new WeakMap;Tn=new WeakMap;Zi=new WeakMap;ln=new WeakMap;cn=new WeakMap;ao=new WeakMap;yi=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 va))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!Xp.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(!Hp.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&&!Jp.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.")};wi=new WeakSet;El=function(){var a;if(D(this,Ce).writeBox(Hm({holdsAvc:((a=D(this,Ve).video)==null?void 0:a.codec)==="avc",fragmented:D(this,Ve).fastStart==="fragmented"})),et(this,ia,D(this,Ce).pos),D(this,Ve).fastStart==="in-memory")et(this,bt,fi(!1));else if(D(this,Ve).fastStart!=="fragmented"){if(typeof D(this,Ve).fastStart=="object"){let n=Fe(this,Xi,Vl).call(this);D(this,Ce).seek(D(this,Ce).pos+n)}et(this,bt,fi(!0)),D(this,Ce).writeBox(D(this,bt))}Fe(this,In,po).call(this)};Xi=new WeakSet;Vl=function(){if(typeof D(this,Ve).fastStart!="object")return;let a=0,n=[D(this,Ve).fastStart.expectedVideoChunks,D(this,Ve).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};bi=new WeakSet;Sl=function(){if(D(this,Ve).video&&et(this,nt,{id:1,info:{type:"video",codec:D(this,Ve).video.codec,width:D(this,Ve).video.width,height:D(this,Ve).video.height,rotation:D(this,Ve).video.rotation??0,decoderConfig:null},timescale:D(this,Ve).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),D(this,Ve).audio&&(et(this,Qe,{id:D(this,Ve).video?2:1,info:{type:"audio",codec:D(this,Ve).audio.codec,numberOfChannels:D(this,Ve).audio.numberOfChannels,sampleRate:D(this,Ve).audio.sampleRate,decoderConfig:null},timescale:D(this,Ve).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),D(this,Ve).audio.codec==="aac")){let a=Fe(this,Hi,Cl).call(this,2,D(this,Ve).audio.sampleRate,D(this,Ve).audio.numberOfChannels);D(this,Qe).info.decoderConfig={codec:D(this,Ve).audio.codec,description:a,numberOfChannels:D(this,Ve).audio.numberOfChannels,sampleRate:D(this,Ve).audio.sampleRate}}};Hi=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};Ho=new WeakSet;ki=function(a,n,t,o,i,r,s){let c=o/1e6,l=(o-(s??0))/1e6,d=i/1e6,u=Fe(this,Gi,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:zt(d,a.timescale)}};Ot=new WeakSet;Ht=function(a,n){D(this,Ve).fastStart!=="fragmented"&&a.samples.push(n);const t=zt(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=zt(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,D(this,Ve).fastStart!=="fragmented"){let s=na(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=na(a.compositionTimeOffsetTable);c.sampleCompositionTimeOffset===t?c.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,D(this,Ve).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:zt(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(D(this,Ve).fastStart==="fragmented"){let r=D(this,nt)??D(this,Qe);const s=D(this,Ve).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,Fe(this,sa,Ji).call(this))}else o=i>=.5}o&&(a.currentChunk&&Fe(this,io,ra).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};Gi=new WeakSet;Nl=function(a,n,t){var s,c;const o=D(this,Ve).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
|
-
|
|
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(D(this,Ve).firstTimestampBehavior==="offset"||D(this,Ve).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let l;D(this,Ve).firstTimestampBehavior==="offset"?l=t.firstDecodeTimestamp:l=Math.min(((s=D(this,nt))==null?void 0:s.firstDecodeTimestamp)??1/0,((c=D(this,Qe))==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}};io=new WeakSet;ra=function(a){if(D(this,Ve).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),D(this,Tn).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||na(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),D(this,Ve).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=D(this,Ce).pos;for(let n of a.currentChunk.samples)D(this,Ce).write(n.data),n.data=null;Fe(this,In,po).call(this)}};sa=new WeakSet;Ji=function(a=!0){if(D(this,Ve).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[D(this,nt),D(this,Qe)].filter(c=>c&&c.currentChunk);if(n.length===0)return;let t=jm(this,Zi)._++;if(t===1){let c=jo(n,D(this,Nn),!0);D(this,Ce).writeBox(c)}let o=D(this,Ce).pos,i=ss(t,n);D(this,Ce).writeBox(i);{let c=fi(!1),l=0;for(let u of n)for(let f of u.currentChunk.samples)l+=f.size;let d=D(this,Ce).measureBox(c)+l;d>=2**32&&(c.largeSize=!0,d=D(this,Ce).measureBox(c)+l),c.size=d,D(this,Ce).writeBox(c)}for(let c of n){c.currentChunk.offset=D(this,Ce).pos,c.currentChunk.moofOffset=o;for(let l of c.currentChunk.samples)D(this,Ce).write(l.data),l.data=null}let r=D(this,Ce).pos;D(this,Ce).seek(D(this,Ce).offsets.get(i));let s=ss(t,n);D(this,Ce).writeBox(s),D(this,Ce).seek(r);for(let c of n)c.finalizedChunks.push(c.currentChunk),D(this,Tn).push(c.currentChunk),c.currentChunk=null;a&&Fe(this,In,po).call(this)};In=new WeakSet;po=function(){D(this,Ce)instanceof ji&&D(this,Ce).flush()};Go=new WeakSet;xi=function(){if(D(this,ao))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const co=30;class Fn extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);A(this,"message");A(this,"code");this.code=o,this.message=t}}class Jt extends Fn{}class He extends Fn{}class la extends Fn{}class ls extends Fn{}function Yp(a,n=co){if(n<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function _n(a,n=co){if(n<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class ve{constructor(n=0){A(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return Yp(this.millis/1e3)}set frames(n){this.millis=_n(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=_n(n);return this.millis=this.millis+t,this}add(n){return new ve(n.millis+this.millis)}subtract(n){return new ve(this.millis-n.millis)}static fromSeconds(n){const t=new ve;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new ve;return o.millis=_n(n,t),o}copy(){return new ve(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new ve(n)}}function cs(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function Jo(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function Kp(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function ds(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function qp(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 Qp(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,f=Math.floor(u),p=Math.ceil(u);if(p>=s.length)c[d]=s[f];else{const h=u-f;c[d]=s[f]*(1-h)+s[p]*h}}}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(tf)}function tf(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function nf(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 us(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 ms(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 $o{constructor(n){A(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 ve}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new ve}}var Ei=(a=>(a.en="en",a.de="de",a))(Ei||{});class ps{constructor(n,t,o,i){A(this,"id",crypto.randomUUID());A(this,"text");A(this,"start");A(this,"stop");A(this,"confidence");this.text=n,this.start=new ve(t),this.stop=new ve(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class un{constructor(n=[],t=Ei.en){A(this,"id",crypto.randomUUID());A(this,"language",Ei.en);A(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>=Jo(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=Jo(...t)?(yield r,r=void 0):o&&r.text.length>=Jo(...o)&&(yield r,r=void 0)),r?r.words.push(c):r=new $o([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=ms(i.start.seconds),s=ms(i.stop.seconds);o+=`${t}
|
|
22
|
-
`+us(r)+" --> "+us(s)+`
|
|
23
|
-
${i.text}
|
|
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 ps(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new un([new $o(i)]);return new un([new $o(i)])}copy(){return un.fromJSON(this.toJSON())}static fromJSON(n){const t=new un;for(const o of n){const i=new $o;for(const r of o)i.words.push(new ps(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 Jt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return un.fromJSON(await o.json())}}function Yo(a,n,t){return a+(n-a)*t}function of(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,f=Math.round(Yo(r,l,t)),p=Math.round(Yo(s,d,t)),h=Math.round(Yo(c,u,t));return`#${((1<<24)+(f<<16)+(p<<8)+h).toString(16).slice(1)}`}const af={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 Ee{constructor(n,t,o={}){A(this,"input");A(this,"output");A(this,"options");if(n.length!==t.length)throw new He({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>_n(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=af[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return Yo(o,i,r);if(typeof o=="string"&&typeof i=="string")return of(o,i,r);if(this.output.length==1)return this.output[0];throw new He({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(_n(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ee([],[]);return Object.assign(t,n),t}}class Ct{constructor(){A(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 fe(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function fo(a){return class extends a{constructor(){super(...arguments);A(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 Yi(a,n,t=0){if(!(a instanceof Oe.Container||a instanceof Oe.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Ee&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&Yi(i,n,t+1))}}var rf=Object.defineProperty,ga=(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&&rf(n,t,i),i};const ho=class _l extends fo(Ct){constructor(t={}){super();A(this,"_name");A(this,"_start",new ve);A(this,"_stop",ve.fromSeconds(16));A(this,"type","base");A(this,"source");A(this,"view",new Oe.Container);A(this,"createdAt",new Date);A(this,"disabled",!1);A(this,"state","IDLE");A(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",ve.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=ve.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new He({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new He({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),Yi(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 _l.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};ga([fe()],ho.prototype,"_name");ga([fe(ve)],ho.prototype,"_start");ga([fe(ve)],ho.prototype,"_stop");ga([fe()],ho.prototype,"disabled");let vo=ho;var sf=Object.defineProperty,yn=(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&&sf(n,t,i),i};class Wt extends fo(Ct){constructor(){super(...arguments);A(this,"state","IDLE");A(this,"metadata");A(this,"objectURL");A(this,"duration",ve.fromSeconds(16));A(this,"added",!1);A(this,"type","base");A(this,"name","");A(this,"mimeType");A(this,"externalURL");A(this,"external",!1);A(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 He({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Ni(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 Jt({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=Ni(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();nf(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}yn([fe()],Wt.prototype,"objectURL");yn([fe()],Wt.prototype,"duration");yn([fe()],Wt.prototype,"type");yn([fe()],Wt.prototype,"name");yn([fe()],Wt.prototype,"mimeType");yn([fe()],Wt.prototype,"externalURL");yn([fe()],Wt.prototype,"external");const fs="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function lf(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 hs(a){if(!a||!a.body)return fs;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 fs;const s=new XMLSerializer,c=i?s.serializeToString(i):"",l=s.serializeToString(r),d=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${c}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${l}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+lf(d)}class vs extends Wt{constructor(){super();A(this,"type","html");A(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=hs(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=hs(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 cf(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 f=0;f<s.length;f+=o){let p=0;const h=Math.min(f+o,s.length);for(let g=f;g<h;g++)p+=s[g]*s[g];p=Math.sqrt(p/(h-f)),p<t?(u+=o,d===null&&(d=f)):(d!==null&&u>=l&&r.push({start:ve.fromSeconds(d/c),stop:ve.fromSeconds(f/c)}),d=null,u=0)}return d!==null&&u>=l&&r.push({start:ve.fromSeconds(d/c),stop:ve.fromSeconds(s.length/c)}),r}const ni=3e3;class on extends Wt{constructor(){super(...arguments);A(this,"type","audio");A(this,"decoding",!1);A(this,"_silences");A(this,"transcript");A(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 f=0;f<c;f+=l){let p=0;for(let h=f;h<f+s;h++)p+=Math.abs(d[f]);u.push(Math.log1p(p/s*100))}return u.map(f=>Math.round(f/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,ni,!0),c=s.getChannelData(0),l=Math.floor(Math.max(o*ni/1e3,0)),d=i?Math.floor(Math.min(i*ni/1e3,s.length)):s.length,u=Math.floor((d-l)/t),f=new Float32Array(t);for(let p=0;p<t;p++){const h=l+p*u,g=h+u;let w=-1/0;for(let E=h;E<g;E++){const M=c[E];M>w&&(w=M)}f[p]=r?Math.log2(1+w):w}return f}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=cf(r,t),i.close(),this._silences}}class Vi extends Wt{constructor(){super(...arguments);A(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 mn extends on{constructor(){super(...arguments);A(this,"type","video");A(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Jt({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=Ni(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 He({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 ve(n[0]),new ve(n[1])]}}var uf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,Rn=(a,n,t,o)=>{for(var i=o>1?void 0:o?mf(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 wn=class Ml extends vo{constructor(t={}){super();A(this,"source",new on);A(this,"_offset",new ve);A(this,"playing",!1);A(this,"duration",new ve);A(this,"range",[new ve,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=ve.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=ve.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",ve.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 ls({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=ve.fromFrames(t)),typeof o=="number"&&(o=ve.fromFrames(o)),t.millis>=o.millis)throw new He({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=ve.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new He({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new ls({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),Yi(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 He({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=>gs(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(!gs(s,c.range))continue;const l=new ve(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}};Rn([fe(ve)],wn.prototype,"_offset",2);Rn([fe(ve)],wn.prototype,"duration",2);Rn([fe(df)],wn.prototype,"range",2);Rn([fe(un)],wn.prototype,"transcript",1);Rn([fe()],wn.prototype,"muted",1);Rn([fe()],wn.prototype,"volume",1);let ya=wn;function gs(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 Do{static fromJSON(n){return typeof n=="object"?Ee.fromJSON(n):n}}class oi{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ee.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ee.fromJSON(n.y)),n}}let pf=class{constructor(a){A(this,"target");A(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 Ee(i,r,{easing:o})}};function ff(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new He({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new ve(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 hf extends pf{}var vf=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,en=(a,n,t,o)=>{for(var i=o>1?void 0:o?gf(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&&vf(n,t,i),i};function wa(a){class n extends a{constructor(){super(...arguments);A(this,"filters");A(this,"_height");A(this,"_width");A(this,"_position",{x:this.view.position.x,y:this.view.position.y});A(this,"_scale");A(this,"rotation",this.view.angle);A(this,"alpha",1);A(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 Ee||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 Oe.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 Oe.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 ff(new hf(this))}}return en([fe(Do)],n.prototype,"_height",2),en([fe(Do)],n.prototype,"_width",2),en([fe(oi)],n.prototype,"_position",2),en([fe(oi)],n.prototype,"_scale",2),en([fe(Do)],n.prototype,"rotation",2),en([fe(Do)],n.prototype,"alpha",2),en([fe(oi)],n.prototype,"translate",2),en([fe()],n.prototype,"anchor",1),n}function ba(a,n,t){const o=t.value;return t.value=function(...i){var f,p,h,g;const r=i[0].subtract(this.start),s={width:((p=(f=this.track)==null?void 0:f.composition)==null?void 0:p.width)??1920,height:((g=(h=this.track)==null?void 0:h.composition)==null?void 0:g.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 w;typeof this._scale.x=="number"?w=this._scale.x:typeof this._scale.x=="function"?w=this._scale.x.bind(this)(r):w=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)&&(w*=this.view.scale._x,E*=this.view.scale._y),this.view.scale.set(w,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 yf=Object.defineProperty,wf=Object.getOwnPropertyDescriptor,bf=(a,n,t,o)=>{for(var i=wf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&yf(n,t,i),i};const Bl=class Il extends wa(vo){constructor(t,o={}){super();A(this,"type","image");A(this,"element",new Image);A(this,"source",new Vi);A(this,"sprite",new Oe.Sprite);this.view.addChild(this.sprite),t instanceof Vi&&(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=Oe.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Jt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Il.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};bf([ba],Bl.prototype,"update");let kf=Bl;const Uo={"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 xf=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&&xf(n,t,i),i};const go=class Si extends fo(Ct){constructor(t){super();A(this,"loaded",!1);A(this,"family");A(this,"weight");A(this,"source");A(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=Si.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(Uo).map(t=>({family:t,variants:Uo[t].weights.map(o=>({family:t,source:`url(${Uo[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new Si({family:t,source:`url(${Uo[t].url})`,weight:o})}};ka([fe()],go.prototype,"family");ka([fe()],go.prototype,"weight");ka([fe()],go.prototype,"source");ka([fe()],go.prototype,"style");let rt=go;const At=4,Fl={center:.5,justify:.5,left:0,right:1},Rl={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Ef=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,vt=(a,n,t,o)=>{for(var i=Vf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ef(n,t,i),i};const ut=class $l extends wa(vo){constructor(t){super();A(this,"type","text");A(this,"_text","");A(this,"_textCase");A(this,"_anchor",{x:0,y:0});A(this,"_font",new rt);A(this,"style",new Oe.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 Oe.Text({text:this.transformedText,style:this.style,resolution:At,scale:At});this.view.addChild(o)}this.view.children[0]instanceof Oe.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*At}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/At):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Fl[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 Oe.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 Oe.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 Oe.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 Oe.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)*At;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};vt([fe()],ut.prototype,"text");vt([fe(rt)],ut.prototype,"font");vt([fe()],ut.prototype,"maxWidth");vt([fe()],ut.prototype,"textAlign");vt([fe()],ut.prototype,"padding");vt([fe()],ut.prototype,"textBaseline");vt([fe()],ut.prototype,"fillStyle");vt([fe()],ut.prototype,"anchor");vt([fe()],ut.prototype,"stroke");vt([fe()],ut.prototype,"textCase");vt([fe()],ut.prototype,"shadow");vt([fe()],ut.prototype,"fontSize");vt([fe()],ut.prototype,"leading");vt([ba],ut.prototype,"update");let $n=ut;function ai(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Sf={get(a,n){const t=a[n];return typeof t=="number"?t*At:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*At):t}};function Cf(a){return new Proxy(a,Sf)}class Nf{constructor(){A(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 ys{constructor(){A(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 Tf{static fromJSON(n){return n.map(t=>(t.font&&(t.font=rt.fromJSON(t.font)),t))}}var _f=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,Dn=(a,n,t,o)=>{for(var i=o>1?void 0:o?Mf(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&&_f(n,t,i),i};const bn=class Dl extends $n{constructor(t){super();A(this,"type","complex_text");A(this,"_maxWidth");A(this,"_textAlign","left");A(this,"_textBaseline","top");A(this,"model",new Oe.Container);A(this,"segments",[]);A(this,"metrics",new ys);A(this,"background");A(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=Fl[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:ai(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:ai(o.substring(t[c].start,t[c].stop))}),!((t[c].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:ai(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 ys;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 f=Cf(Oe.CanvasTextMetrics.measureText(l.tokens[u],d)),p=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+f.lineWidths[0],h=this.maxWidth??Number.POSITIVE_INFINITY,g=(s=l.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(p>h||g||!i.lines.length)&&i.lines.push(new Nf),this.model.addChild(new Oe.Text({text:l.tokens[u],style:d,resolution:At,scale:At})),(c=i.lines.at(-1))==null||c.tokens.push({metrics:f,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 Oe.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)*At;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Dn([fe()],bn.prototype,"background",2);Dn([fe(Tf)],bn.prototype,"styles",2);Dn([fe()],bn.prototype,"text",1);Dn([fe()],bn.prototype,"maxWidth",1);Dn([fe()],bn.prototype,"textAlign",1);Dn([fe()],bn.prototype,"textBaseline",1);let xa=bn;const Ul="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Bf=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),ws=typeof self<"u"&&self.Blob&&new Blob([Bf(Ul)],{type:"text/javascript;charset=utf-8"});function If(a){let n;try{if(n=ws&&(self.URL||self.webkitURL).createObjectURL(ws),!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 Ff{constructor(){A(this,"frames",[]);A(this,"state","active");A(this,"onenqueue");A(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 Rf(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 $f=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,Uf=(a,n,t,o)=>{for(var i=Df(n,t),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 Ol=class Ll extends wa(ya){constructor(t,o={}){super();A(this,"source",new mn);A(this,"type","video");A(this,"worker");A(this,"buffer");A(this,"canvas",document.createElement("canvas"));A(this,"context",this.canvas.getContext("2d"));A(this,"element",document.createElement("video"));A(this,"textrues",{html5:Oe.Texture.from(this.element),canvas:Oe.Texture.from(this.canvas)});A(this,"sprite",new Oe.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 mn&&(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 Jt({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(ve.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=Ll.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 Ff,this.worker=new If,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)??co}),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}};Uf([ba,Rf],Ol.prototype,"update");let Ci=Ol;class ca extends ya{constructor(t,o={}){super();A(this,"type","audio");A(this,"source",new on);A(this,"element",new Audio);t instanceof on&&(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 Jt({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=ca.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const Of={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 Ni(a){if(!Object.keys(Of.MIXED).includes(a??""))throw new He({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var Lf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,zf=(a,n,t,o)=>{for(var i=Af(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 Pf=class Al extends wa(vo){constructor(t,o={}){super();A(this,"type","html");A(this,"source",new vs);A(this,"element",new Image);A(this,"canvas",document.createElement("canvas"));A(this,"context",this.canvas.getContext("2d"));A(this,"sprite",new Oe.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof vs&&(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=Oe.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Jt({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 Jt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Jt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Al.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};zf([ba],Pf.prototype,"update");const zl=["DEFAULT","STACK"];class bs{constructor(){A(this,"mode",zl[0]);A(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=Es(n,t.clips[i]),!!o);i++)xs(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(ks))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(ks);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!Es(n,t.clips[o]))break;xs(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class Wf{constructor(){A(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 ve(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 ve(r))}o=i.stop.millis+1}}offset(){}}function ks(a,n){return a.start.millis-n.start.millis}function xs(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 Es(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 Un extends fo(Ct){constructor(){super(...arguments);A(this,"_disabled",!1);A(this,"view",new Oe.Container);A(this,"clips",[]);A(this,"pointer",0);A(this,"composition");A(this,"type","base");A(this,"strategy",new bs)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&ri(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 Wf,this.strategy.update(new vo,this)):this.strategy=new bs,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,Kp(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(ve.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(ri(this.clipRef)&&(!ii(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!ii(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(ii(o,l)&&!l.disabled)return this.pointer=c,ri(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 ve}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new ve}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 ii(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function ri(a){return a?!!a.view.parent:!1}class jf{static fromType(n){switch(n.type){case"video":return new Zf;case"audio":return new Hf;case"html":return new Gf;case"image":return new Xf;case"text":return new Vs;case"complex_text":return new Vs;case"caption":return new Yf;default:return new Un}}}class Pl extends Un{constructor(){super(...arguments);A(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 Zf extends Pl{constructor(){super(...arguments);A(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class Xf extends Un{constructor(){super(...arguments);A(this,"type","image")}}class Hf extends Pl{constructor(){super(...arguments);A(this,"type","audio")}}class Vs extends Un{constructor(){super(...arguments);A(this,"type","text")}}class Gf extends Un{constructor(){super(...arguments);A(this,"type","html")}}var Jf=Object.defineProperty,Ki=(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&&Jf(n,t,i),i};class yo extends Ct{constructor(t={}){super();A(this,"generatorOptions");A(this,"type","CLASSIC");A(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 He({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 ve,i=await rt.fromFamily({family:"Figtree",weight:"700"}).load();for(const l of t.clip.transcript.iter(this.generatorOptions))await t.add(new $n({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 Ee([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ee([0,4],[0,1],{easing:"easeOut"})}))}}Ki([fe()],yo.prototype,"generatorOptions");Ki([fe()],yo.prototype,"type");Ki([fe()],yo.prototype,"position");class Yf extends Un{constructor(){super(...arguments);A(this,"clip");A(this,"type","caption");A(this,"preset",new yo)}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 Kf=Object.defineProperty,Ea=(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&&Kf(n,t,i),i};class wo extends Ct{constructor(t={}){super();A(this,"generatorOptions");A(this,"type","SPOTLIGHT");A(this,"color");A(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 He({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 ve,i=await rt.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(f=>f.text);await t.add(new xa({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)}))}}}Ea([fe()],wo.prototype,"generatorOptions");Ea([fe()],wo.prototype,"type");Ea([fe()],wo.prototype,"color");Ea([fe()],wo.prototype,"position");var qf=Object.defineProperty,qi=(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&&qf(n,t,i),i};class Va extends Ct{constructor(t={}){super();A(this,"type","GUINEA");A(this,"colors");A(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,f;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new He({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 ve,i=await rt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const p of t.clip.transcript.iter({length:[18]})){const{segments:h,words:g}=this.splitSequence(p);for(let w=0;w<p.words.length;w++){const E=(d=(l=g[w])==null?void 0:l.at(0))==null?void 0:d.start,M=(f=(u=g[w])==null?void 0:u.at(-1))==null?void 0:f.stop;!E||!M||await t.add(new xa({text:h.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:M.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:Jo(0,2),start:h.slice(0,w).join(" ").length,stop:h.slice(0,w+1).join(" ").length+w*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=[...cs(o,r).map(l=>l.trim())],c=cs(t.words,s[0].split(/ /).length);return{segments:s,words:c}}}qi([fe()],Va.prototype,"type");qi([fe()],Va.prototype,"colors");qi([fe()],Va.prototype,"position");var Qf=Object.defineProperty,Qi=(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&&Qf(n,t,i),i};class Sa extends Ct{constructor(t={}){super();A(this,"generatorOptions");A(this,"type","CASCADE");A(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 He({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 ve,i=await rt.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(f=>f.text).slice(0,d+1).join(" ");await t.add(new $n({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)}))}}}Qi([fe()],Sa.prototype,"generatorOptions");Qi([fe()],Sa.prototype,"type");Qi([fe()],Sa.prototype,"position");var eh=Object.defineProperty,er=(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 Ca extends Ct{constructor(t={}){super();A(this,"generatorOptions");A(this,"type","SOLAR");A(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 He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await rt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((l=t.clip)==null?void 0:l.offset)??new ve,r=new gd.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new $n({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 Ee([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ee([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}er([fe()],Ca.prototype,"generatorOptions");er([fe()],Ca.prototype,"type");er([fe()],Ca.prototype,"position");var th=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&&th(n,t,i),i};class bo extends Ct{constructor(t={}){super();A(this,"generatorOptions");A(this,"type","WHISPER");A(this,"color");A(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 He({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 ve,i=await rt.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(f=>f.text);await t.add(new xa({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}))}}}Na([fe()],bo.prototype,"generatorOptions");Na([fe()],bo.prototype,"type");Na([fe()],bo.prototype,"color");Na([fe()],bo.prototype,"position");var nh=Object.defineProperty,Ta=(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 _a extends Ct{constructor(t={}){super();A(this,"type","VERDANT");A(this,"generatorOptions");A(this,"color");A(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 He({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 ve,i=await rt.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(f=>f.text);await t.add(new xa({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}]}))}}}Ta([fe()],_a.prototype,"type");Ta([fe()],_a.prototype,"generatorOptions");Ta([fe()],_a.prototype,"color");Ta([fe()],_a.prototype,"position");class oh extends fo(Ct){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();A(this,"_duration",new ve);A(this,"renderer");A(this,"stage",new Oe.Container);A(this,"settings");A(this,"tracks",[]);A(this,"frame",0);A(this,"fixedDuration");A(this,"state","IDLE");A(this,"fps",co);A(this,"canvas");A(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)),Oe.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Fn({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 ve?this.fixedDuration=t:this.fixedDuration=ve.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=jf.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 ds(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;ds(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(ve.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 Fn({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(ve.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(ve.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(ya)){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 f=await c.source.decode(t,o),p=f.numberOfChannels-1;for(let h=0;h<t;h++){const g=r.getChannelData(h),w=f.getChannelData(h>p?p:h);for(let E=0;E<g.length-1;E++)E<l+d||E>l+u||E-l<0||(g[E]+=(w[E-l]??0)*c.volume,g[E]>1&&(g[E]=1),g[E]<-1&&(g[E]=-1));r.getChannelData(h).set(g)}}catch{}}return r}time(t){const o=_n(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/co;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 ah(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 Ti=[8e3,12e3,16e3,24e3,48e3],ih="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",rh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class sh{constructor(n){A(this,"output");A(this,"error");A(this,"config");A(this,"encoder");A(this,"opus");A(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(rh),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Ti.includes(i))throw new la({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Ti.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?ih:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:ah(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 la({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 f=4e3,p=this.opus._malloc(f),h=this.opus._opus_encode(this.encoder,u,s,p,f);if(h>0){const g=new Uint8Array(this.opus.HEAPU8.subarray(p,p+h));this.output({data:g,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(p),c+=s,o+=l}}}function lh(a){const n=Ti;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class ch{constructor(n,t){A(this,"canvas");A(this,"muxer");A(this,"videoEncoder");A(this,"frame",0);A(this,"sampleRate");A(this,"numberOfChannels");A(this,"videoBitrate");A(this,"gpuBatchSize");A(this,"fps");A(this,"height");A(this,"width");A(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=lh((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 Tl({target:new zi,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 la({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=Qp(n,this.sampleRate,this.numberOfChannels),o=new sh({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:qp(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 la({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 _t(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 Oo(a){return a>5?a/100:a}function Mt(a,n,t){return Math.min(t,Math.max(n,a))}function pt(){return new Xe.ColorMatrixFilter}function uh(a,n){switch(a){case"brightness":{const t=pt(),o=_t(n.value??n.brightness,1);return t.brightness(Mt(Oo(o),0,5),!1),t}case"contrast":{const t=pt(),o=_t(n.value??n.contrast,1);return t.contrast(Mt(Oo(o),0,5),!1),t}case"saturation":{const t=pt(),o=_t(n.value??n.saturation,1);return t.saturate(Mt(Oo(o),0,5),!1),t}case"hue":{const t=pt(),o=_t(n.degrees??n.value,0);return t.hue(Mt(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=_t(n.radius??n.blur??n.value,t);return new Xe.BlurFilter({strength:Mt(o,0,32),quality:4})}case"grayscale":{const t=pt(),o=Mt(_t(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Mt(_t(n.amount,100),0,100)<=0)return null;const o=pt();return o.sepia(!1),o}case"invert":{if(Mt(_t(n.amount,100),0,100)<=0)return null;const o=pt();return o.negative(!1),o}case"warmth":{const t=pt(),o=Mt(_t(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=pt(),o=Mt(_t(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=pt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=pt(),o=Mt(Oo(_t(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=pt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=pt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=pt();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=Xe);class Wl{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 oh({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,f;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||(f=c==null?void 0:c.renderer)!=null&&f.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=mn.from)==null?void 0:o.call(mn,r,{crossOrigin:"anonymous"}))??await mn.from(r),c=new Ci(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 p=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),h=n.sourceOut!==void 0?Math.max(p+1,Math.floor(n.sourceOut*this.fps)):null;l=p,d=h;try{if(c.offset=c.offset||{frames:0},c.offset.frames=p,h!==null){const g=Math.max(1,h-p);c.duration=c.duration||{frames:g},c.duration.frames=g}}catch{}}const u=await this.composition.add(c);if(d!==null&&l>=0)try{const p=Math.max(1,d-l);u.offset=u.offset||{frames:0},u.offset.frames=l,u.duration=u.duration||{frames:p},u.duration.frames=p}catch{}const f=Math.floor(n.timelineStart*this.fps);f>0&&u.offsetBy(f),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(p=>requestAnimationFrame(p)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=rt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new $n({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 Ee([s,c],[n.animation.rotation.from,n.animation.rotation.to],{easing:l}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Ee([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 f=null;if(u&&u.signature===d)f=u.instance;else{if(u)try{u.instance.destroy()}catch{}f=this.createPixiFilter(l),f?i.set(l.id,{instance:f,signature:d}):i.delete(l.id)}f&&s.push(f)}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(ot.getFilter(n.filterId)&&!ot.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=bd(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,f,p,h,g;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)??((p=(f=this.composition)==null?void 0:f.renderer)==null?void 0:p.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(h=n.onProgress)==null||h.call(n,0);const i=new ch(o,{fps:t});await i.init();const r=await i.export();return(g=n.onProgress)==null||g.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),f=this.fitMode==="contain"?d:u;n.scale=f}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 mh=["src"],ph={class:"preview-controls"},fh=["aria-label"],hh={class:"time-display"},vh={class:"current-time"},gh={class:"total-time"},yh={key:2,class:"loading-overlay"},wh={key:3,class:"error-overlay"},bh=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),f=e.ref(0),p=e.ref(0);let h=null;const g=e.computed(()=>!!t.enableEngine&&!!t.recipe),w=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),E=e.computed(()=>{var x,_;return(x=t.media)!=null&&x.url?t.media.url:(((_=t.media)==null?void 0:_.file)instanceof File,"")});async function M(){var x,_,I;if(!(!r.value||!t.recipe))try{c.value=!0,l.value="Initializing video engine...";const U=((x=t.recipe.source)==null?void 0:x.original_width)||1920,$=((_=t.recipe.source)==null?void 0:_.original_height)||1080,j=((I=t.recipe.output)==null?void 0:I.fps)||30;h=new Wl(U,$,j,{fitMode:t.fitMode}),h.attachPlayer(r.value),l.value="Loading composition...",await h.loadFromRecipe(t.recipe),p.value=h.durationInSeconds,o("duration-change",p.value),V(),c.value=!1,o("engine-ready",h),t.autoPlay&&(h.play(),u.value=!0)}catch(U){const $=U instanceof Error?U.message:String(U);d.value=`Failed to initialize: ${$}`,c.value=!1}}function V(){if(!h)return;const x=setInterval(()=>{h&&u.value&&(f.value=h.currentTimeInSeconds,o("time-update",f.value))},100);O.value=x}function y(){g.value&&h?(u.value?h.pause():h.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 m(x){const _=Math.floor(x/60),I=Math.floor(x%60);return`${_}:${I.toString().padStart(2,"0")}`}function b(){d.value=null,g.value&&M()}function R(){!g.value&&s.value&&(p.value=s.value.duration,o("duration-change",p.value))}function N(){!g.value&&s.value&&(f.value=s.value.currentTime,o("time-update",f.value))}function v(){u.value=!1,o("play-state-change",!1)}function C(x){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{g.value&&t.recipe&&M()}),e.onUnmounted(()=>{h&&(h.destroy(),h=null),O.value&&(clearInterval(O.value),O.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async x=>{if(g.value&&x)if(h)try{await h.loadFromRecipe(x),p.value=h.durationInSeconds,o("duration-change",p.value)}catch{}else await M()}),e.watch(()=>t.enableEngine,async x=>{x?await M():h&&(O.value&&(clearInterval(O.value),O.value=null),h.destroy(),h=null)}),e.watch(()=>t.fitMode,async x=>{if(!(!g.value||!h))try{h.setFitMode(x||"contain")}catch{}});const O=e.ref(null);return(x,_)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[g.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:R,onTimeupdate:N,onEnded:v,onError:C,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:w.value}),playsinline:"",controls:""},null,44,mh)),e.createElementVNode("div",ph,[e.createElementVNode("button",{class:"play-button",onClick:y,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(F.IonIcon),{icon:u.value?e.unref(ll):e.unref(cl)},null,8,["icon"])],8,fh),e.createElementVNode("div",hh,[e.createElementVNode("span",vh,e.toDisplayString(m(f.value)),1),_[0]||(_[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",gh,e.toDisplayString(m(p.value)),1)])]),c.value?(e.openBlock(),e.createElementBlock("div",yh,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(l.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",wh,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Ui)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:b},"Retry")])):e.createCommentVNode("",!0)],512))}}),Ss=Ne(bh,[["__scopeId","data-v-7e604791"]]),kh=["aria-label"],xh=["aria-label"],Eh={class:"clip-content"},Vh={key:0,class:"clip-thumbnail"},Sh=["src","alt"],Ch={class:"clip-waveform"},Nh={class:"clip-info"},Th={class:"clip-label"},_h={class:"clip-duration"},Mh={key:1,class:"filter-indicators"},Bh={key:2,class:"speed-indicator"},Ih={key:0,class:"selection-overlay"},Fh=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 C=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${C}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),f=e.computed(()=>{const v=t.clip.timelineEnd-t.clip.timelineStart;return g(v)}),p=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),h=e.computed(()=>t.clip.filters||[]);function g(v){if(v<1)return`${Math.round(v*30)}f`;if(v<60)return`${v.toFixed(1)}s`;{const C=Math.floor(v/60),O=Math.floor(v%60);return`${C}:${O.toString().padStart(2,"0")}`}}function w(v){return!v||typeof v!="string"?os:v.includes("color")||v.includes("brightness")?nn:v.includes("blur")?Yd:v.includes("style")?Jn:v.includes("effect")?tn:os}function E(){r.value||o("select")}function M(v){v.button===0&&(m("move",v.clientX),v.preventDefault())}function V(v){if(v.touches.length!==1)return;const C=v.touches[0];m("move",C.clientX),v.preventDefault()}function y(v,C){const O="touches"in C?C.touches[0].clientX:C.clientX;s.value=v==="start"?"trim-start":"trim-end",m(s.value,O),C.preventDefault(),C.stopPropagation()}function m(v,C){r.value=!0,s.value=v,c.value=C,v==="move"?l.value=t.clip.timelineStart:v==="trim-start"?l.value=t.clip.sourceIn:v==="trim-end"&&(l.value=t.clip.sourceOut),document.addEventListener("mousemove",b),document.addEventListener("mouseup",R),document.addEventListener("touchmove",b),document.addEventListener("touchend",R),t.selected||o("select")}function b(v){if(!r.value||!s.value)return;const C="touches"in v?v.touches[0].clientX:v.clientX,x=C-c.value;s.value==="move"?(o("drag",x),o("drag-abs",C)):s.value==="trim-start"?(o("trim-start",x),o("trim-start-abs",C)):s.value==="trim-end"&&(o("trim-end",x),o("trim-end-abs",C))}function R(){r.value=!1,s.value=null,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",R),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",R)}function N(){if(!i.value)return;const v=i.value,C=v.getContext("2d");if(!C)return;v.width=v.clientWidth*window.devicePixelRatio,v.height=v.clientHeight*window.devicePixelRatio,C.scale(window.devicePixelRatio,window.devicePixelRatio),C.strokeStyle="rgba(255, 255, 255, 0.3)",C.lineWidth=1,C.beginPath();const O=v.clientWidth,x=v.clientHeight,_=x/2;C.moveTo(0,_),C.lineTo(O,_);for(let I=0;I<O;I+=4){const U=Math.sin(I*.05)*(x*.3);C.moveTo(I,_-U),C.lineTo(I,_+U)}C.stroke()}return e.onMounted(()=>{N(),window.addEventListener("resize",N)}),e.onUnmounted(()=>{R(),window.removeEventListener("resize",N)}),(v,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:v.selected,mobile:v.isMobile,"has-filters":p.value}]),style:e.normalizeStyle(d.value),onClick:E,onMousedown:M,onTouchstart:V},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:C[0]||(C[0]=e.withModifiers(O=>y("start",O),["stop"])),onTouchstart:C[1]||(C[1]=e.withModifiers(O=>y("start",O),["stop"])),"aria-label":`Trim start of ${v.clip.label||"clip"}`},[...C[4]||(C[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,kh),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:C[2]||(C[2]=e.withModifiers(O=>y("end",O),["stop"])),onTouchstart:C[3]||(C[3]=e.withModifiers(O=>y("end",O),["stop"])),"aria-label":`Trim end of ${v.clip.label||"clip"}`},[...C[5]||(C[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,xh),e.createElementVNode("div",Eh,[v.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Vh,[e.createElementVNode("img",{src:v.clip.thumbnail,alt:v.clip.label||"Video clip"},null,8,Sh)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ch,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",Nh,[e.createElementVNode("span",Th,e.toDisplayString(u.value),1),e.createElementVNode("span",_h,e.toDisplayString(f.value),1)]),p.value?(e.openBlock(),e.createElementBlock("div",Mh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,O=>(e.openBlock(),e.createBlock(e.unref(F.IonIcon),{key:O.id||O.filterId,icon:w(O.filterId||O.id),title:`Filter: ${O.filterId||O.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),v.clip.speed&&v.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Bh,e.toDisplayString(v.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),v.selected?(e.openBlock(),e.createElementBlock("div",Ih)):e.createCommentVNode("",!0)],38))}}),Rh=Ne(Fh,[["__scopeId","data-v-943b6167"]]);class jl{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Ci(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 mn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=ve.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,c;i instanceof Ci&&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 $h={class:"time-markers"},Dh=["aria-label","title"],Uh={key:0,class:"timeline-scrollbar"},Oh=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),f=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,W=>{W!==void 0&&(s.value=W)});const p=new jl(t.fps),h=e.ref(!1),g=e.ref(null),w=e.ref(0),E=e.ref(0),M=e.ref(0),V=e.ref(0),y=e.ref(0),m=e.ref(!1),b=e.ref(0),R=e.ref(t.zoomLevel),N=e.computed(()=>t.zoomLevel);function v(W){const Y=t.clips.find(oe=>oe.id===W);if(!Y)return null;const te=t.clips.filter(oe=>oe.id!==W&&oe.timelineStart>=Y.timelineEnd-1e-9).map(oe=>oe.timelineStart);return te.length?Math.min(...te):null}function C(W){const Y=W.sourceMaxOut??t.duration,te=W.timelineStart+(Y-W.sourceIn),oe=v(W.id),pe=oe!=null?Math.max(W.timelineStart,oe):1/0;return Math.min(te,pe)}function O(W){const Y=W.sourceMinIn??0,oe=(W.sourceMaxOut??t.duration)-Y,pe=W.sourceIn-Y;return{left:`${(W.timelineStart-pe)*N.value-l.value}px`,width:`${oe*N.value}px`,top:"0px",height:"80px",opacity:f.value===W.id?.25:.15}}const x=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),_=e.computed(()=>p.secondsToFrames(t.duration)),I=e.computed(()=>t.useFrameMode?_.value*x.value:t.duration*N.value),U=e.computed(()=>{var W;return u.value||((W=r.value)==null?void 0:W.clientWidth)||800}),$=e.computed(()=>I.value>U.value),j=e.computed(()=>Math.max(0,I.value-U.value)),P=e.computed(()=>l.value>0),T=e.computed(()=>l.value<j.value),L=e.computed(()=>t.useFrameMode?p.secondsToFrames(t.playhead)*x.value-l.value:t.playhead*N.value-l.value),G=e.computed(()=>{const W=Math.max(50,U.value/I.value*U.value),Y=l.value/j.value*(U.value-W);return{width:`${W}px`,left:`${Y}px`}}),Z=e.computed(()=>{const W=[],Y=ce();for(let te=0;te<=t.duration;te+=Y){const oe=te*N.value-l.value;oe>=-50&&oe<=U.value+50&&W.push({position:oe,label:_e(te),time:te})}return W});function ce(){const Y=80/N.value;return Y<=1?1:Y<=5?5:Y<=10?10:Y<=30?30:Y<=60?60:Math.ceil(Y/60)*60}function _e(W){if(t.useFrameMode)return`F${p.secondsToFrames(W)}`;{const Y=Math.floor(W/60),te=Math.floor(W%60),oe=Math.floor(W%1*t.fps);return N.value>100?`${Y}:${te.toString().padStart(2,"0")}:${oe.toString().padStart(2,"0")}`:`${Y}:${te.toString().padStart(2,"0")}`}}function Re(W){const Y=r.value.getBoundingClientRect();let oe=(W.clientX-Y.left+l.value)/N.value;const pe=t.clips.find(we=>oe>=we.timelineStart&&oe<=we.timelineEnd);if(pe)oe=Math.max(pe.timelineStart,Math.min(pe.timelineEnd,oe));else if(t.selectedClipId){const we=t.clips.find(Be=>Be.id===t.selectedClipId);if(we){const Be=Math.abs(oe-we.timelineStart),De=Math.abs(oe-we.timelineEnd);oe=Be<De?we.timelineStart:we.timelineEnd}}else oe=Math.max(0,Math.min(oe,t.duration));i("update:playhead",oe)}function ae(W){if(!$.value)return;const Y=Math.abs(W.deltaX)>Math.abs(W.deltaY)?W.deltaX:W.deltaY;Y!==0&&(W.preventDefault(),l.value=Math.max(0,Math.min(j.value,l.value+Y)))}function B(W){if(W.touches.length===2){m.value=!0;const Y=W.touches[0],te=W.touches[1];b.value=Math.hypot(te.clientX-Y.clientX,te.clientY-Y.clientY),R.value=t.zoomLevel}else W.touches.length===1&&(M.value=W.touches[0].clientX,V.value=W.touches[0].clientY,y.value=M.value)}function z(W){if(m.value&&W.touches.length===2){const Y=W.touches[0],te=W.touches[1],pe=Math.hypot(te.clientX-Y.clientX,te.clientY-Y.clientY)/b.value;Math.max(10,Math.min(200,R.value*pe)),i("update:playhead",t.playhead)}else if(W.touches.length===1&&!m.value){const Y=W.touches[0],te=y.value-Y.clientX;Math.abs(te)>Math.abs(Y.clientY-V.value)&&(W.preventDefault(),l.value=Math.max(0,Math.min(I.value-U.value,l.value+te)),y.value=Y.clientX)}}function de(){m.value=!1}function ie(W){const Y=W.target;if(Y.closest(".playhead-handle"))return;const te=W.button===1,oe=!!Y.closest(".video-track");(te||!oe&&$.value)&&K(W)}function K(W){h.value=!0,g.value="pan",w.value=W.clientX,E.value=l.value,document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe)}function ee(W){W.preventDefault(),W.stopPropagation(),h.value=!0,g.value="playhead";const Y="touches"in W?W.touches[0].clientX:W.clientX;w.value=Y,E.value=t.playhead,"touches"in W?(document.addEventListener("touchmove",ge),document.addEventListener("touchend",xe)):(document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe))}function ue(W){W.preventDefault(),W.stopPropagation(),h.value=!0,g.value="scrollbar";const Y="touches"in W?W.touches[0].clientX:W.clientX;w.value=Y,E.value=l.value,"touches"in W?(document.addEventListener("touchmove",ge),document.addEventListener("touchend",xe)):(document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe))}function ge(W){if(!h.value)return;const te=("touches"in W?W.touches[0].clientX:W.clientX)-w.value;if(g.value==="playhead"){const oe=te/N.value;let pe=E.value+oe;if(t.selectedClipId){const we=t.clips.find(Be=>Be.id===t.selectedClipId);we?pe=Math.max(we.timelineStart,Math.min(we.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}else{const we=t.clips.find(Be=>t.playhead>=Be.timelineStart&&t.playhead<=Be.timelineEnd);we?pe=Math.max(we.timelineStart,Math.min(we.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}i("update:playhead",pe)}else if(g.value==="scrollbar"){const oe=te/U.value*I.value;l.value=Math.max(0,Math.min(j.value,E.value+oe))}else if(g.value==="pan"){const oe=E.value-te;l.value=Math.max(0,Math.min(j.value,oe))}}function xe(){h.value=!1,g.value=null,document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",xe),document.removeEventListener("touchmove",ge),document.removeEventListener("touchend",xe)}function ne(W){s.value=s.value===W?null:W,i("clip-select",s.value)}function ke(W,Y){const te=t.clips.find(pe=>pe.id===W);if(!te||Math.abs(Y)<2)return;const oe=Y/N.value*t.sensitivity;if(t.useFrameMode){const pe=p.secondsToFrames(te.sourceIn),we=p.secondsToFrames(oe),Be=Math.max(0,pe+we),De=p.framesToSeconds(Be);i("trim",W,"start",De)}else{const pe=Math.max(0,te.sourceIn+oe);i("trim",W,"start",pe)}}function he(W,Y){const te=t.clips.find(be=>be.id===W);if(!te||!r.value)return;const oe=r.value.getBoundingClientRect(),pe=Y-oe.left,we=80;if(pe<we)l.value=Math.max(0,l.value-8);else if(pe>oe.width-we){const be=Math.max(0,I.value-U.value);l.value=Math.min(be,l.value+8)}const Be=pe+l.value,De=1/t.fps;let H=Be/N.value;H=Math.max(0,Math.min(H,te.timelineEnd-De));let re=te.sourceIn+(H-te.timelineStart);re=Math.round(re*t.fps)/t.fps,i("trim",W,"start",re)}function Je(W,Y){const te=t.clips.find(Se=>Se.id===W);if(!te||!r.value)return;const oe=r.value.getBoundingClientRect(),pe=Y-oe.left,we=80;if(pe<we)l.value=Math.max(0,l.value-8);else if(pe>oe.width-we){const Se=Math.max(0,I.value-U.value);l.value=Math.min(Se,l.value+8)}const Be=pe+l.value,De=1/t.fps,H=C(te);let re=Be/N.value;re=Math.max(te.timelineStart+De,Math.min(re,H));let be=te.sourceIn+(re-te.timelineStart);be=Math.round(be*t.fps)/t.fps,i("trim",W,"end",be)}function lt(W,Y){const te=t.clips.find(H=>H.id===W);if(!te||!r.value)return;const oe=r.value.getBoundingClientRect(),we=Y-oe.left+l.value,Be=te.timelineEnd-te.timelineStart;let De=we/N.value;De=Math.max(0,Math.min(De,t.duration-Be)),De=Math.round(De*t.fps)/t.fps,i("clip-move",W,De)}function mt(W,Y){const te=t.clips.find(we=>we.id===W);if(!te||Math.abs(Y)<2)return;const oe=Y/N.value*t.sensitivity,pe=we=>Math.max(0,Math.round(we*t.fps)/t.fps);if(t.useFrameMode){const we=p.secondsToFrames(te.sourceOut),Be=p.secondsToFrames(oe),De=C(te),H=te.sourceIn+(De-te.timelineStart),re=p.secondsToFrames(H),be=Math.min(re,we+Be),Se=p.framesToSeconds(be);i("trim",W,"end",Se)}else{const we=C(te),Be=te.sourceIn+(we-te.timelineStart),De=Math.min(Be,te.sourceOut+oe),H=pe(De);i("trim",W,"end",H)}}function me(W,Y){const te=t.clips.find(we=>we.id===W);if(!te||Math.abs(Y)<2)return;const oe=Y/N.value*t.sensitivity,pe=we=>Math.max(0,Math.round(we*t.fps)/t.fps);if(t.useFrameMode){const we=p.secondsToFrames(te.timelineStart),Be=p.secondsToFrames(oe),De=Math.max(0,we+Be),H=p.framesToSeconds(De);i("clip-move",W,H)}else{const we=Math.max(0,te.timelineStart+oe),Be=pe(we);i("clip-move",W,Be)}}return e.watch(()=>t.playhead,W=>{const Y=W*N.value;Y<l.value+50?l.value=Math.max(0,Y-50):Y>l.value+U.value-50&&(l.value=Math.min(j.value,Y-U.value+50))}),e.onMounted(()=>{const W=new ResizeObserver(Y=>{Y[0]&&(u.value=Math.round(Y[0].contentRect.width))});r.value&&W.observe(r.value),e.onUnmounted(()=>W.disconnect())}),e.onUnmounted(()=>{xe()}),e.watch([I,U],()=>{l.value>j.value&&(l.value=j.value)}),(W,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:o.value}]),ref_key:"timelineRef",ref:r,onWheel:ae},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Re},[e.createElementVNode("div",$h,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.value,te=>(e.openBlock(),e.createElementBlock("span",{key:te.position,class:"time-marker",style:e.normalizeStyle({left:`${te.position}px`})},e.toDisplayString(te.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":$.value,"is-panning":h.value&&g.value==="pan","overflow-left":P.value,"overflow-right":T.value}]),onTouchstart:B,onTouchmove:z,onTouchend:de,onMousedown:ie},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.clips,te=>(e.openBlock(),e.createElementBlock("div",{key:`${te.id}-extent`,class:"clip-extent",style:e.normalizeStyle(O(te)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.clips,te=>(e.openBlock(),e.createBlock(Rh,{key:te.id,clip:te,scale:N.value,"scroll-offset":l.value,selected:f.value===te.id,"is-mobile":o.value,onSelect:oe=>ne(te.id),onTrimStart:oe=>ke(te.id,oe),onTrimEnd:oe=>mt(te.id,oe),onDrag:oe=>me(te.id,oe),onTrimStartAbs:oe=>he(te.id,oe),onTrimEndAbs:oe=>Je(te.id,oe),onDragAbs:oe=>lt(te.id,oe)},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:`${L.value}px`}),onMousedown:ee,onTouchstart:ee},[...Y[1]||(Y[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:`${L.value}px`})},null,4)):e.createCommentVNode("",!0),o.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:Y[0]||(Y[0]=te=>W.$emit("toggle-frame-mode")),"aria-label":W.useFrameMode?"Switch to time mode":"Switch to frame mode",title:W.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(W.useFrameMode?"F":"T"),9,Dh))],34),$.value?(e.openBlock(),e.createElementBlock("div",Uh,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(G.value),onMousedown:ue,onTouchstart:ue},null,36)])):e.createCommentVNode("",!0)],34))}}),Cs=Ne(Oh,[["__scopeId","data-v-6fa3968c"]]),Lh={class:"control-group zoom-controls"},Ah={class:"zoom-slider"},zh=["value"],Ph={class:"control-group playback-controls"},Wh=["aria-label"],jh={key:0,class:"control-group speed-control"},Zh=["value"],Xh=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 f=u.target;t("zoom-change",Number(f.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 f=u.target;t("speed-change",Number(f.value))}return(u,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",Lh,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:f[0]||(f[0]=p=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(pu)},null,8,["icon"])]),e.createElementVNode("div",Ah,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:o,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,zh)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:f[1]||(f[1]=p=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Ud)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Jd)},null,8,["icon"]),f[3]||(f[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",Ph,[e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to start"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(uu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ru)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:f[2]||(f[2]=p=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(F.IonIcon),{icon:u.isPlaying?e.unref(ou):e.unref(du)},null,8,["icon"])],8,Wh),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(cu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to end"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(mu)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",jh,[f[5]||(f[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...f[4]||(f[4]=[e.createStaticVNode('<option value="0.25" data-v-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,Zh)]))],2))}}),Hh=Ne(Xh,[["__scopeId","data-v-7bf65ab9"]]),Gh={class:"video-filter-carousel-container"},Jh={key:0,class:"category-section"},Yh={class:"category-carousel-wrapper"},Kh=["disabled"],qh=["onClick","data-testid","aria-label"],Qh={class:"category-name"},e0=["disabled"],t0={class:"filter-section"},n0={class:"filter-carousel-wrapper"},o0=["disabled"],a0=["onClick","onKeydown","data-testid","aria-label"],i0=["onClick"],r0={class:"filter-preview"},s0={class:"filter-placeholder"},l0={class:"filter-name"},c0=["disabled"],d0={class:"carousel-pagination"},u0=["onClick"],m0={key:1,class:"filter-adjustments"},p0={class:"adjustment-header"},f0={class:"adjustment-actions"},h0={key:0},v0={key:0,class:"slider-control"},g0={class:"control-label"},y0={class:"slider-wrapper"},w0={class:"slider-value"},b0={key:1,class:"color-control"},k0={class:"control-label"},x0={class:"color-wrapper"},E0=["value","onInput","disabled"],V0={class:"color-value"},S0={key:2,class:"toggle-control"},C0={class:"control-label"},N0={key:3,class:"select-control"},T0={class:"control-label"},_0=["value","onChange","disabled"],M0=["value"],B0={key:1,class:"no-params"},I0=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0}},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(),f={all:tn,adjust:Wn,color:nn,blur:Ro,light:jn,effects:qa,stylize:Jn,advanced:tn,distortion:Yn,transform:Yn};function p(T){return T.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function h(T){return T.replace(/[-_]/g," ").replace(/\b\w/g,L=>L.toUpperCase())}function g(T){return f[T.toLowerCase()]??tn}const w=e.computed(()=>{const T=Array.from(new Set(t.filters.map(L=>L.category).filter(L=>typeof L=="string"&&L.length>0))).sort((L,G)=>L.localeCompare(G));return[{id:"all",name:"All",icon:tn},...T.map(L=>({id:L,name:h(L),icon:g(L)}))]}),E=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(T=>T.category===i.value));e.watch(w,T=>{new Set(T.map(Z=>Z.id)).has(i.value)||(i.value="all");const G=Math.max(0,T.length-3);s.value>G&&(s.value=G)},{immediate:!0});function M(T){var L;return((L=t.activeFilters)==null?void 0:L.has(T))||!1}function V(T){if(r.value=T,!M(T.id)&&(o("apply-filter",T),T.params&&T.params.length>0)){const L=new Map;T.params.forEach(G=>{L.set(G.id,G.default)}),l.value.set(T.id,L)}o("preview-filter",T)}function y(T){var L;o("remove-filter",T),l.value.delete(T),((L=r.value)==null?void 0:L.id)===T&&(r.value=null)}function m(T){if(typeof T=="number"&&Number.isFinite(T))return T;if(typeof T=="string"){const L=Number(T);return Number.isFinite(L)?L:null}return null}function b(T,L){var B;const G=t.filters.find(z=>z.id===T),Z=G==null?void 0:G.params.find(z=>z.id===L),ce=(Z==null?void 0:Z.default)??0,_e=z=>typeof ce=="number"?m(z)??ce:typeof ce=="boolean"?typeof z=="boolean"?z:ce:typeof z=="string"?z:ce,Re=(B=t.activeFilters)==null?void 0:B.get(T);if(Re&&Re.params){const z=Re.params[L];if(z!=null)return _e(z)}const ae=l.value.get(T);if(ae){const z=ae.get(L);if(z!=null)return _e(z)}return ce}function R(T,L,G){var Z;l.value.has(T)||l.value.set(T,new Map),(Z=l.value.get(T))==null||Z.set(L,G),o("update-param",T,L,G)}function N(T){if(typeof T=="boolean")return T?"On":"Off";if(typeof T=="string"){const G=m(T);return G===null?"0":Number.isInteger(G)?G.toString():G.toFixed(2)}const L=m(T);return L===null?"0":Number.isInteger(L)?L.toString():L.toFixed(2)}function v(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const T=new Map;r.value.params.forEach(L=>{T.set(L.id,L.default)}),l.value.set(r.value.id,T)}}function C(T){const L=t.filters.find(G=>G.id===T);L&&L.params&&L.params.forEach(G=>{R(T,G.id,G.default)})}function O(T){return{basic:Wn,color:nn,blur:Ro,light:jn,effects:qa,stylize:Jn,adjustment:Wn,"color-matrix":nn,glow:tn,distortion:Yn}[T]||tn}function x(T){return{adjustment:Wn,brightness:jn,contrast:Wn,saturation:nn,blur:Ro,"gaussian-blur":Ro,"color-matrix":nn,grayscale:Jn,sepia:Jn,vignette:Yn,glow:tn,glitch:qa,godray:jn,lightmap:jn}[T.id]||O(T.category)}function _(){s.value>0&&(s.value--,P(d.value,s.value))}function I(){s.value<w.value.length-3&&(s.value++,P(d.value,s.value))}function U(){c.value>0&&(c.value--,P(u.value,c.value))}function $(){c.value<E.value.length-4&&(c.value++,P(u.value,c.value))}function j(T){c.value=T*4,P(u.value,c.value)}function P(T,L){var G;if(T){const Z=((G=T.querySelector(".category-chip, .filter-card"))==null?void 0:G.clientWidth)||100;T.scrollTo({left:L*(Z+8),behavior:"smooth"})}}return(T,L)=>{var G;return e.openBlock(),e.createElementBlock("div",Gh,[T.showCategories?(e.openBlock(),e.createElementBlock("div",Jh,[e.createElementVNode("div",Yh,[e.createElementVNode("button",{onClick:_,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(qr)},null,8,["icon"])],8,Kh),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,Z=>(e.openBlock(),e.createElementBlock("button",{key:Z.id,onClick:ce=>i.value=Z.id,class:e.normalizeClass(["category-chip",{active:i.value===Z.id}]),"data-testid":`btn-filter-category-${p(Z.id)}`,"aria-label":`Filter category ${Z.name}`},[e.createVNode(e.unref(F.IonIcon),{icon:Z.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",Qh,e.toDisplayString(Z.name),1)],10,qh))),128))],512),e.createElementVNode("button",{onClick:I,class:"carousel-nav carousel-nav-right",disabled:s.value>=w.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Qr)},null,8,["icon"])],8,e0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",t0,[e.createElementVNode("div",n0,[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(F.IonIcon),{icon:e.unref(qr)},null,8,["icon"])],8,o0),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,Z=>{var ce;return e.openBlock(),e.createElementBlock("div",{key:Z.id,class:e.normalizeClass(["filter-card",{active:M(Z.id),selected:((ce=r.value)==null?void 0:ce.id)===Z.id}]),onClick:_e=>V(Z),onKeydown:[e.withKeys(_e=>V(Z),["enter"]),e.withKeys(e.withModifiers(_e=>V(Z),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${p(Z.id)}`,"aria-label":`Select filter ${Z.name}`},[M(Z.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(_e=>y(Z.id),["stop"])},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(il)},null,8,["icon"])],8,i0)):e.createCommentVNode("",!0),e.createElementVNode("div",r0,[e.createElementVNode("div",s0,[e.createVNode(e.unref(F.IonIcon),{icon:x(Z),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",l0,e.toDisplayString(Z.name),1)],42,a0)}),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(F.IonIcon),{icon:e.unref(Qr)},null,8,["icon"])],8,c0)]),e.createElementVNode("div",d0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(E.value.length/4),(Z,ce)=>(e.openBlock(),e.createElementBlock("span",{key:ce,class:e.normalizeClass(["pagination-dot",{active:Math.floor(c.value/4)===ce}]),onClick:_e=>j(ce)},null,10,u0))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",m0,[e.createElementVNode("div",p0,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",f0,[M(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:v,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),M(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:L[0]||(L[0]=Z=>y(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),M(r.value.id)&&((G=r.value.params)==null?void 0:G.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:L[1]||(L[1]=Z=>C(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",h0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,Z=>(e.openBlock(),e.createElementBlock("div",{key:Z.id,class:"adjustment-control"},[!Z.type||Z.type==="slider"?(e.openBlock(),e.createElementBlock("div",v0,[e.createElementVNode("label",g0,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("div",y0,[e.createVNode(e.unref(F.IonRange),{value:b(r.value.id,Z.id),onIonChange:ce=>R(r.value.id,Z.id,ce.detail.value),min:Z.min,max:Z.max,step:Z.step||.01,color:"primary",class:"compact-slider",disabled:!M(r.value.id),"data-testid":`range-filter-${p(r.value.id)}-${p(Z.id)}`,"aria-label":`Adjust ${Z.label||Z.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",w0,e.toDisplayString(N(b(r.value.id,Z.id))),1)])])):Z.type==="color"?(e.openBlock(),e.createElementBlock("div",b0,[e.createElementVNode("label",k0,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("div",x0,[e.createElementVNode("input",{type:"color",value:b(r.value.id,Z.id),onInput:ce=>R(r.value.id,Z.id,ce.target.value),disabled:!M(r.value.id),class:"color-input"},null,40,E0),e.createElementVNode("span",V0,e.toDisplayString(b(r.value.id,Z.id)),1)])])):Z.type==="toggle"?(e.openBlock(),e.createElementBlock("div",S0,[e.createElementVNode("label",C0,e.toDisplayString(Z.label||Z.id),1),e.createVNode(e.unref(F.IonToggle),{checked:!!b(r.value.id,Z.id),onIonChange:ce=>R(r.value.id,Z.id,ce.detail.checked),disabled:!M(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):Z.type==="select"?(e.openBlock(),e.createElementBlock("div",N0,[e.createElementVNode("label",T0,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("select",{value:b(r.value.id,Z.id),onChange:ce=>R(r.value.id,Z.id,ce.target.value),disabled:!M(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.options,ce=>(e.openBlock(),e.createElementBlock("option",{key:String(ce.value),value:ce.value},e.toDisplayString(ce.label),9,M0))),128))],40,_0)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",B0," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)])}}}),Ns=Ne(I0,[["__scopeId","data-v-3144d0bd"]]);class F0{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"},$0={class:"preview-title"},D0={class:"filter-controls"},U0={class:"control-input"},O0=["value","onInput","min","max","step"],L0={class:"param-value"},A0={class:"preview-container"},z0={key:0,class:"filter-presets"},P0=["onClick"],W0={class:"preview-actions"},j0=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 f=e.computed(()=>{var v;return((v=t.filter)==null?void 0:v.paramRanges)||{}}),p=e.computed(()=>h.value.length>0),h=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function g(){var v;if(i.value){t.useVideoEngine&&t.composition&&(u=new F0(t.composition));try{if(c=new Xe.Application,await c.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(v=t.currentFrame)!=null&&v.dataUrl){const C=await Xe.Assets.load(t.currentFrame.dataUrl);l=new Xe.Sprite(C);const O=Math.min(c.screen.width/l.texture.width,c.screen.height/l.texture.height);l.scale.set(O),l.anchor.set(.5),l.position.set(c.screen.width/2,c.screen.height/2),c.stage.addChild(l)}w()}catch{}}}function w(){if(!(!l||!t.filter))if(t.useVideoEngine&&u){const v={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([v]).then(()=>{}).catch(C=>{}),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(v,C){switch(v){case"brightness":{const O=new Xe.ColorMatrixFilter,x=1+(C.value??0);return typeof O.brightness=="function"&&O.brightness(x,!1),O}case"contrast":{const O=new Xe.ColorMatrixFilter,x=C.value??1;return typeof O.contrast=="function"&&O.contrast(x,!1),O}case"saturation":{const O=new Xe.ColorMatrixFilter,x=C.value??1;return typeof O.saturate=="function"&&O.saturate(x,!1),O}case"hue":{const O=new Xe.ColorMatrixFilter,x=C.value??0;return typeof O.hue=="function"&&O.hue(x,!1),O}case"gaussian-blur":{const O=C.value??5;return new Xe.BlurFilter({strength:O,quality:4})}case"sepia":{const O=new Xe.ColorMatrixFilter;return typeof O.sepia=="function"&&O.sepia(!1),O}case"grayscale":{const O=new Xe.ColorMatrixFilter;return typeof O.desaturate=="function"&&O.desaturate(),O}default:return null}}function M(v,C){const O=C.target,x=Number.parseFloat(O.value),_=Number.isFinite(x)?x:0;s.value={...s.value,[v]:_},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),w()}function V(v){return v.charAt(0).toUpperCase()+v.slice(1).replace(/_/g," ")}function y(v,C){var x;const O=typeof v=="number"?v:Number(v);return Number.isFinite(O)?C==="hue"||C==="angle"?`${O}°`:C==="value"&&((x=t.filter)==null?void 0:x.id)==="brightness"?`${Math.round((1+O)*100)}%`:Number.isInteger(O)?O.toString():O.toFixed(2):"0"}function m(){var v;s.value=((v=t.filter)==null?void 0:v.defaultParams)||{},o("update-params",s.value),w()}function b(v){s.value={...v.params},o("update-params",s.value),w()}function R(v){return JSON.stringify(v.params)===JSON.stringify(s.value)}function N(){o("apply")}return e.watch(()=>t.filter,v=>{v&&(s.value={...v.defaultParams},w())}),e.watch(()=>t.currentFrame,async v=>{if(v!=null&&v.dataUrl&&l){const C=await Xe.Assets.load(v.dataUrl);l.texture=C}}),e.watch(r,w),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),g()}),e.onUnmounted(()=>{c&&c.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(v,C)=>{var O;return e.openBlock(),e.createElementBlock("div",R0,[e.createElementVNode("h4",$0,e.toDisplayString((O=v.filter)==null?void 0:O.name)+" Settings",1),e.createElementVNode("div",D0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(x,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(V(_)),1),e.createElementVNode("div",U0,[e.createElementVNode("input",{type:"range",value:s.value[_],onInput:I=>M(_,I),min:x.min,max:x.max,step:x.step,class:"param-slider"},null,40,O0),e.createElementVNode("span",L0,e.toDisplayString(y(s.value[_],_)),1)])]))),128))]),e.createElementVNode("div",A0,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:C[0]||(C[0]=x=>r.value=!0),onMouseup:C[1]||(C[1]=x=>r.value=!1),onTouchstart:C[2]||(C[2]=x=>r.value=!0),onTouchend:C[3]||(C[3]=x=>r.value=!1)},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Yn)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),p.value?(e.openBlock(),e.createElementBlock("div",z0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.name,class:e.normalizeClass(["preset-button",{active:R(x)}]),onClick:_=>b(x)},e.toDisplayString(x.name),11,P0))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",W0,[e.createElementVNode("button",{class:"action-button",onClick:m},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(mo)},null,8,["icon"]),C[5]||(C[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:N},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),C[6]||(C[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Ts=Ne(j0,[["__scopeId","data-v-3de3dd04"]]),Z0={class:"export-settings"},X0={class:"setting-group"},H0={class:"setting-group"},G0={class:"estimated-size"},J0={key:0,class:"export-progress"},Y0={class:"progress-header"},K0={class:"progress-percentage"},q0={class:"progress-time"},Q0={class:"action-buttons"},ev=["disabled"],tv=["disabled"],nv=["disabled"],ov={class:"export-options"},av=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 f=null;const p=e.computed(()=>{const m=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return m<1e3?`~${Math.round(m)} MB`:`~${(m/1e3).toFixed(1)} GB`});function h(){t.isExporting?(o("cancel-export"),E()):g()}function g(){const V={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:c.value};o("export",V),w()}function w(){l.value=Date.now(),d.value=0,f=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-l.value)/1e3),t.exportProgress>0){const V=d.value/t.exportProgress*100;u.value=Math.max(0,V-d.value)}},1e3)}function E(){f&&(clearInterval(f),f=null)}function M(V){const y=Math.floor(V/60),m=Math.floor(V%60);return`${y}:${m.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,V=>{V||E()}),e.onUnmounted(()=>{E()}),(V,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:V.isMobile}])},[e.createElementVNode("div",Z0,[y[10]||(y[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",X0,[y[7]||(y[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[0]||(y[0]=m=>i.value=m),class:"setting-select"},[...y[6]||(y[6]=[e.createStaticVNode('<option value="360p" data-v-e1338d5e>360p (Low)</option><option value="480p" data-v-e1338d5e>480p (SD)</option><option value="720p" data-v-e1338d5e>720p (HD)</option><option value="1080p" data-v-e1338d5e>1080p (Full HD)</option><option value="1440p" data-v-e1338d5e>1440p (2K)</option><option value="2160p" data-v-e1338d5e>2160p (4K)</option>',6)])],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("div",H0,[y[9]||(y[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[1]||(y[1]=m=>r.value=m),class:"setting-select"},[...y[8]||(y[8]=[e.createElementVNode("option",{value:"mp4"},"MP4 (Most Compatible)",-1),e.createElementVNode("option",{value:"webm"},"WebM (Web Optimized)",-1),e.createElementVNode("option",{value:"mov"},"MOV (Apple)",-1)])],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",G0,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Qd)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(p.value),1)])]),V.isExporting?(e.openBlock(),e.createElementBlock("div",J0,[e.createElementVNode("div",Y0,[y[11]||(y[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",K0,e.toDisplayString(V.exportProgress??0)+"%",1)]),e.createVNode(e.unref(F.IonProgressBar),{value:(V.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",q0,[e.createElementVNode("span",null,e.toDisplayString(M(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(M(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Q0,[e.createElementVNode("button",{class:"control-button secondary",onClick:y[2]||(y[2]=m=>V.$emit("save-draft")),disabled:!V.canExport||V.isExporting},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(dl)},null,8,["icon"]),y[12]||(y[12]=e.createTextVNode(" Save Draft ",-1))],8,ev),e.createElementVNode("button",{class:"control-button secondary",onClick:y[3]||(y[3]=m=>V.$emit("reset")),disabled:V.isExporting},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(mo)},null,8,["icon"]),y[13]||(y[13]=e.createTextVNode(" Reset ",-1))],8,tv),e.createElementVNode("button",{class:"control-button primary",onClick:h,disabled:!V.canExport&&!V.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(F.IonIcon),{icon:V.isExporting?e.unref(so):e.unref(ha)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(V.isExporting?"Cancel":"Export Video"),1)],8,nv)]),e.createElementVNode("div",ov,[e.createVNode(e.unref(F.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":y[4]||(y[4]=m=>s.value=m)},null,8,["modelValue"]),e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...y[14]||(y[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(F.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonCheckbox),{modelValue:c.value,"onUpdate:modelValue":y[5]||(y[5]=m=>c.value=m)},null,8,["modelValue"]),e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...y[15]||(y[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),_s=Ne(av,[["__scopeId","data-v-e1338d5e"]]),iv={class:"thumbnail-picker"},rv={class:"thumbnail-grid"},sv=["onClick"],lv=["src","alt"],cv={key:1,class:"thumbnail-placeholder"},dv={class:"thumbnail-time"},uv={class:"custom-selector"},mv={class:"time-input-group"},pv=["max"],fv={class:"time-value"},hv=["disabled"],vv={class:"picker-actions"},gv=["disabled"],yv=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 M=[];if(t.duration<=10)for(let y=0;y<Math.min(9,t.duration);y++)M.push(y);else{const y=t.duration/10;for(let m=1;m<=9;m++)M.push(y*m)}return M}async function d(M){try{const V=document.createElement("video");return V.crossOrigin="anonymous",V.src=await u(),new Promise(y=>{V.addEventListener("loadedmetadata",()=>{V.currentTime=M}),V.addEventListener("seeked",()=>{const m=document.createElement("canvas");m.width=V.videoWidth,m.height=V.videoHeight;const b=m.getContext("2d");b?(b.drawImage(V,0,0),y(m.toDataURL("image/jpeg",.8))):y(null),V.remove()}),V.addEventListener("error",()=>{y(null),V.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function f(){const M=l();i.value=M.map(y=>({time:y,loading:!0}));const V=3;for(let y=0;y<i.value.length;y+=V){const m=i.value.slice(y,y+V);await Promise.all(m.map(async b=>{const R=await d(b.time);R&&(b.dataUrl=R),b.loading=!1}))}}function p(M){r.value=M,s.value=i.value[M].time}function h(){r.value=-1}async function g(){c.value=!0;try{const M=await d(s.value);if(M){const V=i.value.findIndex(y=>Math.abs(y.time-s.value)<.1);V>=0?(i.value[V].dataUrl=M,r.value=V):(i.value.push({time:s.value,dataUrl:M}),r.value=i.value.length-1,i.value.sort((y,m)=>y.time-m.time),r.value=i.value.findIndex(y=>y.time===s.value))}}finally{c.value=!1}}function w(){const M=r.value>=0?i.value[r.value].time:s.value;o("select",M)}function E(M){const V=Math.floor(M/60),y=Math.floor(M%60),m=Math.floor(M%1*100);return V>0?`${V}:${y.toString().padStart(2,"0")}.${m.toString().padStart(2,"0")}`:`${y}.${m.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),(M,V)=>(e.openBlock(),e.createElementBlock("div",iv,[V[5]||(V[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",rv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(y,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:e.normalizeClass(["thumbnail-item",{selected:r.value===m}]),onClick:b=>p(m)},[y.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.dataUrl,alt:`Frame at ${E(y.time)}`},null,8,lv)):(e.openBlock(),e.createElementBlock("div",cv,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",dv,e.toDisplayString(E(y.time)),1)],10,sv))),128))]),e.createElementVNode("div",uv,[V[3]||(V[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",mv,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":V[0]||(V[0]=y=>s.value=y),min:0,max:M.duration,step:.1,onInput:h,class:"time-slider"},null,40,pv),[[e.vModelText,s.value]]),e.createElementVNode("span",fv,e.toDisplayString(E(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:g,disabled:c.value},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(zd)},null,8,["icon"]),V[2]||(V[2]=e.createTextVNode(" Capture Frame ",-1))],8,hv)]),e.createElementVNode("div",vv,[e.createElementVNode("button",{class:"action-button",onClick:V[1]||(V[1]=y=>M.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:w,disabled:r.value===-1},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),V[4]||(V[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,gv)])]))}}),wv=Ne(yv,[["__scopeId","data-v-336c322c"]]),bv={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},kv={class:"mb-4"},xv={class:"space-y-2 max-h-64 overflow-y-auto"},Ev={class:"flex items-center justify-between"},Vv={class:"flex-1"},Sv={class:"font-medium text-gray-900 dark:text-white"},Cv={class:"text-sm text-gray-500 dark:text-gray-400"},Nv={class:"flex items-center space-x-2"},Tv=["onClick"],_v=["onClick"],Mv={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Bv={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Iv={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Fv={class:"space-y-4"},Rv={class:"grid grid-cols-2 gap-4"},$v={class:"grid grid-cols-2 gap-4"},Dv={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Uv={class:"grid grid-cols-2 gap-3"},Ov={class:"flex justify-end space-x-3 mt-6"},Lv=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(p){Object.assign(s,p),i.value=p}function l(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const p={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(p.animation={type:s.animationType},s.animationDuration!==void 0&&(p.animation.duration=s.animationDuration),s.animationEasing&&(p.animation.easing=s.animationEasing),p.animation))switch(s.animationType){case"rotate":p.animation.rotation={from:0,to:360};break;case"scale":p.animation.scale={from:.5,to:1};break;case"slide":p.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,p):t("add-overlay",p),l()}function u(p){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",p)}function f(p){const h=Math.floor(p/60),g=Math.floor(p%60);return`${h}:${g.toString().padStart(2,"0")}`}return(p,h)=>(e.openBlock(),e.createElementBlock("div",bv,[e.createElementVNode("div",kv,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=g=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...h[10]||(h[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",xv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.overlays,g=>(e.openBlock(),e.createElementBlock("div",{key:g.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"},[e.createElementVNode("div",Ev,[e.createElementVNode("div",Vv,[e.createElementVNode("div",Sv,e.toDisplayString(g.text.substring(0,30))+e.toDisplayString(g.text.length>30?"...":""),1),e.createElementVNode("div",Cv,e.toDisplayString(f(g.startTime??0))+" - "+e.toDisplayString(f((g.startTime||0)+(g.duration||5))),1)]),e.createElementVNode("div",Nv,[e.createElementVNode("button",{onClick:w=>c(g),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...h[12]||(h[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,Tv),e.createElementVNode("button",{onClick:w=>u(g.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[13]||(h[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,_v)])])]))),128)),p.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Mv," 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",Bv,[e.createElementVNode("h4",Iv,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Fv,[e.createElementVNode("div",null,[h[14]||(h[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":h[1]||(h[1]=g=>s.text=g),rows:"3",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter your text..."},null,512),[[e.vModelText,s.text]])]),e.createElementVNode("div",Rv,[e.createElementVNode("div",null,[h[15]||(h[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[2]||(h[2]=g=>s.fontSize=g),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[16]||(h[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[3]||(h[3]=g=>s.color=g),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[h[18]||(h[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[4]||(h[4]=g=>s.position=g),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[17]||(h[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",$v,[e.createElementVNode("div",null,[h[19]||(h[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=g=>s.startTime=g),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[20]||(h[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[6]||(h[6]=g=>s.duration=g),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[h[22]||(h[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[7]||(h[7]=g=>s.animationType=g),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[21]||(h[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",Dv,[h[26]||(h[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Uv,[e.createElementVNode("div",null,[h[23]||(h[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[8]||(h[8]=g=>s.animationDuration=g),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[9]||(h[9]=g=>s.animationEasing=g),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...h[24]||(h[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ov,[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)]))}}),Ms=Ne(Lv,[["__scopeId","data-v-f86e688c"]]),ro=class ro{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 Ee([o,i],[1,0],{easing:r}),t.alpha=new Ee([o,i],[0,1],{easing:r}),t.start=ve.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 Ee([o,i],[1,0],{easing:r}),t.alpha=new Ee([o,i],[0,1],{easing:r}),t.start=ve.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 Ee([i,r],[0,-1920],{easing:s}),l.x=new Ee([i,r],[1920,0],{easing:s});break;case"wipe-right":c.x=new Ee([i,r],[0,1920],{easing:s}),l.x=new Ee([i,r],[-1920,0],{easing:s});break;case"wipe-up":c.y=new Ee([i,r],[0,-1080],{easing:s}),l.y=new Ee([i,r],[1080,0],{easing:s});break;case"wipe-down":c.y=new Ee([i,r],[0,1080],{easing:s}),l.y=new Ee([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=ve.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 Ee([i,r],[0,-1920],{easing:s}),l.x=new Ee([i,r],[1920,0],{easing:s});break;case"slide-right":c.x=new Ee([i,r],[0,1920],{easing:s}),l.x=new Ee([i,r],[-1920,0],{easing:s});break;case"slide-up":c.y=new Ee([i,r],[0,-1080],{easing:s}),l.y=new Ee([i,r],[1080,0],{easing:s});break;case"slide-down":c.y=new Ee([i,r],[0,1080],{easing:s}),l.y=new Ee([i,r],[-1080,0],{easing:s});break}n.translate=c,t.translate=l,t.start=ve.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 Ee([i,r],[1,2],{easing:s}),n.alpha=new Ee([i,r],[1,0],{easing:s}),t.scale=new Ee([i,r],[.5,1],{easing:s}),t.alpha=new Ee([i,r],[0,1],{easing:s})):(n.scale=new Ee([i,r],[1,.5],{easing:s}),n.alpha=new Ee([i,r],[1,0],{easing:s}),t.scale=new Ee([i,r],[2,1],{easing:s}),t.alpha=new Ee([i,r],[0,1],{easing:s})),t.start=ve.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 Vi.fromColor(l),u=new kf(d,{start:ve.fromFrames(i),stop:ve.fromFrames(r)});n.alpha=new Ee([i,c],[1,0],{easing:s}),u.alpha=new Ee([i,c,r],[0,1,0],{easing:s}),t.alpha=new Ee([c,r],[0,1],{easing:s}),await this.composition.add(u),t.start=ve.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[...ro.TRANSITIONS]}static previewTransition(n){return ro.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};ro.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 da=ro;const Av={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},zv={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Pv=["onClick"],Wv={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"},jv={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Zv={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},Xv={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},Hv={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"},Gv={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"},Jv={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"},Yv={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},Kv={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},qv={class:"space-y-3"},Qv={class:"flex items-center space-x-2"},e1=["disabled"],t1=["disabled"],n1={key:1,class:"mt-4"},o1={class:"space-y-2 max-h-32 overflow-y-auto"},a1={class:"text-sm text-gray-700 dark:text-gray-300"},i1=["onClick"],r1=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(da.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(g){r.value=g}function u(){if(!r.value||!l.value)return;const g={type:r.value.type,duration:s.value,easing:c.value};o("apply-transition",g),r.value=null}function f(){if(!r.value)return;const g={type:r.value.type,duration:s.value,easing:c.value};o("preview-transition",g)}function p(g){o("remove-transition",g)}function h(g){return["fade","wipe","slide","zoom"].some(w=>g.includes(w))}return(g,w)=>(e.openBlock(),e.createElementBlock("div",Av,[w[9]||(w[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",zv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,E=>{var M;return e.openBlock(),e.createElementBlock("div",{key:E.type,onClick:V=>d(E),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((M=r.value)==null?void 0:M.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",Wv,[h(E.type)?(e.openBlock(),e.createElementBlock("svg",jv,[E.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Zv)):E.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",Xv)):E.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",Hv)):E.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",Gv)):(e.openBlock(),e.createElementBlock("path",Jv))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Yv,e.toDisplayString(E.name),1)],10,Pv)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",Kv,[w[6]||(w[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",qv,[e.createElementVNode("div",null,[w[3]||(w[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",Qv,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":w[0]||(w[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":w[1]||(w[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,[w[5]||(w[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":w[2]||(w[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"},[...w[4]||(w[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,e1),e.createElementVNode("button",{onClick:f,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,t1)])])):e.createCommentVNode("",!0),g.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",n1,[w[8]||(w[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",o1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.appliedTransitions,(E,M)=>(e.openBlock(),e.createElementBlock("div",{key:M,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",a1,e.toDisplayString(E.name)+" ("+e.toDisplayString(E.duration)+"s) ",1),e.createElementVNode("button",{onClick:V=>p(M),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...w[7]||(w[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,i1)]))),128))])])):e.createCommentVNode("",!0),w[10]||(w[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))]))}}),Bs=Ne(r1,[["__scopeId","data-v-5ef1b100"]]),s1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},l1={class:"mb-4"},c1={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"},m1={class:"flex items-center space-x-2"},p1={class:"space-y-3 max-h-64 overflow-y-auto"},f1={class:"flex items-center justify-between mb-2"},h1={class:"font-medium text-gray-900 dark:text-white"},v1={class:"flex items-center space-x-2"},g1=["onClick","title"],y1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},w1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},b1=["onClick"],k1=["onClick"],x1={class:"flex items-center space-x-2"},E1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},V1=["value","onInput","disabled"],S1={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},C1={key:0,class:"ml-2"},N1={key:1,class:"ml-2"},T1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},_1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},M1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},B1={class:"space-y-4"},I1={class:"space-y-2"},F1={class:"flex items-center"},R1={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},$1={class:"grid grid-cols-2 gap-4"},D1={class:"grid grid-cols-2 gap-4"},U1={class:"flex items-center"},O1={class:"flex justify-end space-x-3 mt-6"},L1=["disabled"],A1=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(y){const m=y.target;m.files&&m.files[0]&&(l.sourceFile=m.files[0],l.name=l.name||m.files[0].name.replace(/\.[^/.]+$/,""))}function f(y){Object.assign(l,y),r.value=y}function p(){i.value=!1,r.value=null,Object.assign(l,c())}function h(){if(!d.value)return;const y={source:l.sourceFile??l.sourceUrl??"",name:l.name,volume:l.volume,startTime:l.startTime,loop:l.loop};l.duration!==void 0&&(y.duration=l.duration),l.fadeIn>0&&(y.fadeIn=l.fadeIn),l.fadeOut>0&&(y.fadeOut=l.fadeOut),r.value?o("update-track",r.value.id,y):o("add-track",y),p()}function g(y){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",y)}function w(y,m){const b=m.target,R=parseFloat(b.value);o("update-volume",y.id,R)}function E(y){o("toggle-mute",y.id,!y.muted)}function M(){o("update-master-volume",s.value)}function V(y){const m=Math.floor(y/60),b=Math.floor(y%60);return`${m}:${b.toString().padStart(2,"0")}`}return(y,m)=>(e.openBlock(),e.createElementBlock("div",s1,[e.createElementVNode("div",l1,[m[11]||(m[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:m[0]||(m[0]=b=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...m[10]||(m[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",c1,[e.createElementVNode("div",d1,[m[12]||(m[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",m1,[m[13]||(m[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":m[1]||(m[1]=b=>s.value=b),onInput:M,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),m[14]||(m[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",p1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.audioLayers,b=>(e.openBlock(),e.createElementBlock("div",{key:b.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",f1,[e.createElementVNode("div",h1,e.toDisplayString(b.name),1),e.createElementVNode("div",v1,[e.createElementVNode("button",{onClick:R=>E(b),class:e.normalizeClass(["p-1 rounded",b.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:b.muted?"Unmute":"Mute"},[b.muted?(e.openBlock(),e.createElementBlock("svg",w1,[...m[16]||(m[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",y1,[...m[15]||(m[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,g1),e.createElementVNode("button",{onClick:R=>f(b),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...m[17]||(m[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,b1),e.createElementVNode("button",{onClick:R=>g(b.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...m[18]||(m[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",x1,[e.createElementVNode("span",E1,e.toDisplayString(Math.round((b.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:b.volume||1,onInput:R=>w(b,R),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:b.muted},null,40,V1)]),e.createElementVNode("div",S1,[e.createTextVNode(e.toDisplayString(V(b.startTime||0))+" - "+e.toDisplayString(V((b.startTime||0)+(b.duration||0)))+" ",1),b.fadeIn?(e.openBlock(),e.createElementBlock("span",C1,"Fade In: "+e.toDisplayString(b.fadeIn)+"s",1)):e.createCommentVNode("",!0),b.fadeOut?(e.openBlock(),e.createElementBlock("span",N1,"Fade Out: "+e.toDisplayString(b.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),y.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",T1," 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(p,["self"])},[e.createElementVNode("div",_1,[e.createElementVNode("h4",M1,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",B1,[e.createElementVNode("div",null,[m[20]||(m[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",I1,[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",F1,[m[19]||(m[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":m[2]||(m[2]=b=>l.sourceUrl=b),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,[m[21]||(m[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":m[3]||(m[3]=b=>l.name=b),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",R1," Volume: "+e.toDisplayString(Math.round(l.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":m[4]||(m[4]=b=>l.volume=b),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",$1,[e.createElementVNode("div",null,[m[22]||(m[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":m[5]||(m[5]=b=>l.startTime=b),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,[m[23]||(m[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":m[6]||(m[6]=b=>l.duration=b),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",D1,[e.createElementVNode("div",null,[m[24]||(m[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":m[7]||(m[7]=b=>l.fadeIn=b),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,[m[25]||(m[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":m[8]||(m[8]=b=>l.fadeOut=b),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",U1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":m[9]||(m[9]=b=>l.loop=b),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]]),m[26]||(m[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",O1,[e.createElementVNode("button",{onClick:p,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:h,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(r.value?"Save":"Add"),11,L1)])])])):e.createCommentVNode("",!0)]))}}),Is=Ne(A1,[["__scopeId","data-v-593719ac"]]);function Fs(a){var s,c;z1(a);const n=P1(a.clips),t=[],o=W1(a),i=j1(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 z1(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 P1(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 W1(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 j1(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 Z1(a,n,t){var Be,De;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),f=e.shallowRef(null),p=new jl(30),h=e.ref(30),g=e.ref(!1),w=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(N(n),(Be=n.output)!=null&&Be.fps&&(h.value=n.output.fps,p.setFps(h.value))):(m(),n&&((De=n.output)!=null&&De.fps&&(h.value=n.output.fps,p.setFps(h.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),M=e.computed(()=>i.selectedClipId?i.clips.find(H=>H.id===i.selectedClipId)??null:null);e.watch(M,H=>{E.value=(H==null?void 0:H.speed)??1},{immediate:!0});const V=e.computed(()=>s.value.length>0),y=e.computed(()=>c.value.length>0);function m(){const H=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=H,i.totalDuration=H;const re=de(),be={id:re,type:"clip",timelineStart:0,timelineEnd:H,sourceIn:0,sourceOut:H,sourceMinIn:0,sourceMaxOut:H,speed:1};i.clips=[be],i.selectedClipId=re,l.value=re,!(t||o.startsWith("temp-"))&&(async()=>{try{const Se=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!Se.ok)throw new Error(`Failed to fetch media: ${Se.status}`);const Le=await Se.json(),gt=typeof Le=="object"&&Le!==null&&"data"in Le?Le.data:Le;if(!gt||typeof gt!="object")throw new Error("Failed to parse media payload");const ct=gt;i.media=ct;const Et=typeof ct.duration=="number"&&ct.duration>0?ct.duration:H;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==re)return;i.originalDuration=Et,i.totalDuration=Et;const Ze=i.clips[0];Ze.timelineStart=0,Ze.timelineEnd=Et,Ze.sourceIn=0,Ze.sourceOut=Et,Ze.sourceMinIn=0,Ze.sourceMaxOut=Et,P(),d=!0}catch{}})()}function b(H,re){if(H.originalDuration!==1)return;H.originalDuration=re,H.totalDuration===1&&(H.totalDuration=re);const be=H.clips[0],Se=!n&&H.clips.length===1&&be!==void 0&&be.timelineStart===0&&be.timelineEnd===1&&be.sourceIn===0&&be.sourceOut===1;for(const Le of H.clips)(Le.sourceMaxOut===1||Le.sourceMaxOut===void 0)&&(Le.sourceMaxOut=re);Se&&be!==void 0&&(be.sourceOut=re,be.timelineEnd=re)}function R(H){if(!Number.isFinite(H)||H<=0||d)return;const re=i.hasChanges;i.originalDuration=H,i.totalDuration=Math.max(i.totalDuration,H),i.media&&(i.media.duration=H);for(const Le of i.clips)Le.sourceMaxOut=H;const be=i.clips[0];!n&&i.clips.length===1&&be!==void 0&&be.timelineStart===0&&be.timelineEnd===1&&be.sourceIn===0&&be.sourceOut===1&&be!==void 0&&(be.sourceOut=H,be.timelineEnd=be.timelineStart+(be.sourceOut-be.sourceIn)),P();for(const Le of s.value)b(Le,H);for(const Le of c.value)b(Le,H);d=!0,e.nextTick(()=>{re||(i.hasChanges=!1)})}function N(H){i.clips=H.timeline.map(re=>({...re,sourceMinIn:re.sourceMinIn??0,sourceMaxOut:re.sourceMaxOut??H.source.duration})),i.filters=[],i.audioVolume=H.audio.volume,i.audioFadeIn=H.audio.fadeIn||0,i.audioFadeOut=H.audio.fadeOut||0,i.exportFormat=H.output.format,i.exportQuality=H.output.quality,i.originalDuration=H.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,l.value=i.selectedClipId):(delete i.selectedClipId,l.value=void 0),P()}function v(){s.value.push(JSON.parse(JSON.stringify(i))),c.value=[],i.hasChanges=!0}function C(){if(!V.value)return;const H=s.value.pop();c.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function O(){if(!y.value)return;const H=c.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function x(H,re,be){v();const Se=i.clips.find(Ze=>Ze.id===H);if(!Se)return;const gt=1/30,ct=Se.sourceMinIn??0,Et=Se.sourceMaxOut??i.originalDuration;if(re==="start"){const Ze=Se.sourceIn,jt=Math.max(ct,Math.min(be,Se.sourceOut-gt));Se.sourceIn=jt;const za=jt-Ze;Se.timelineStart+=za}else{const Ze=Math.max(Se.sourceIn+gt,Math.min(be,Et));Se.sourceOut=Ze;const jt=Se.sourceOut-Se.sourceIn;Se.timelineEnd=Se.timelineStart+jt}P(),f.value&&f.value.trimClip(H,Se.sourceIn,Se.sourceOut)}function _(H){v();const re=i.clips.find(ct=>H>ct.timelineStart&&H<ct.timelineEnd);if(!re)return;const be=H-re.timelineStart,Se=re.sourceIn+be,Le={id:de(),type:"clip",timelineStart:H,timelineEnd:re.timelineEnd,sourceIn:Se,sourceOut:re.sourceOut,speed:re.speed??1,sourceMinIn:re.sourceMinIn??0,sourceMaxOut:re.sourceMaxOut??i.originalDuration,filters:[...re.filters||[]]};re.timelineEnd=H,re.sourceOut=Se;const gt=i.clips.indexOf(re);i.clips.splice(gt+1,0,Le),i.selectedClipId=Le.id}function I(){_(i.playheadPosition)}function U(H){var be;const re=H??i.selectedClipId??l.value??((be=i.clips[0])==null?void 0:be.id);re&&(i.selectedClipId=re,l.value=re)}function $(){if(!i.selectedClipId||i.clips.length<=1)return;v();const H=i.clips.findIndex(re=>re.id===i.selectedClipId);if(H!==-1){i.clips.splice(H,1);const re=Math.min(H,i.clips.length-1);i.selectedClipId=i.clips[re].id,l.value=i.selectedClipId,P()}}function j(H,re){v();const be=i.clips.find(Le=>Le.id===H);if(!be)return;const Se=re-be.timelineStart;be.timelineStart=re,be.timelineEnd+=Se,P(),f.value&&f.value.moveClip(H,re)}function P(){if(i.clips.length===0){i.totalDuration=0;return}const H=i.clips.reduce((re,be)=>be.timelineEnd>re.timelineEnd?be:re);i.totalDuration=H.timelineEnd}function T(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function L(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function G(H){i.zoomLevel=Math.max(10,Math.min(600,Math.round(H)))}function Z(){i.isPlaying=!i.isPlaying}function ce(H){i.isPlaying=H}function _e(H){i.playheadPosition=Math.max(0,Math.min(H,i.totalDuration))}function Re(){const H=Fs(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(H))}catch{}return H}function ae(){i.hasChanges=!1}function B(){return confirm("Are you sure you want to reset all changes?")?(v(),m(),i.hasChanges=!1,!0):!1}function z(){return Fs(i)}function de(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ie(H=1920,re=1080){if(u.value)try{f.value=new Wl(H,re,h.value),await K()}catch{f.value=null}}async function K(){if(!(!f.value||w.value)){w.value=!0;try{const H=z();await f.value.loadFromRecipe(H);const re=p.secondsToFrames(i.playheadPosition);f.value.seek(re)}catch{}finally{w.value=!1}}}function ee(H){}function ue(H){return p.secondsToFrames(H)}function ge(H){return p.framesToSeconds(H)}function xe(H){const re=ge(H);_e(re),f.value&&f.value.seek(H)}function ne(){g.value=!g.value}function ke(){K()}function he(H){u.value=!1,f.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&f.value&&K()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&f.value&&K()},{deep:!0}),e.watch(()=>i.clips.map(H=>H.id),()=>{var re;if(!i.clips.length){delete i.selectedClipId,l.value=void 0;return}if(!i.clips.some(be=>be.id===i.selectedClipId)){const be=l.value&&((re=i.clips.find(Se=>Se.id===l.value))==null?void 0:re.id);i.selectedClipId=be??i.clips[0].id,l.value=i.selectedClipId}},{deep:!0});function Je(H){const re=i.selectedClipId?i.clips.find(be=>be.id===i.selectedClipId):i.clips[0];re&&(re.filters=[...H],i.hasChanges=!0)}function lt(H){i.textOverlays=[...H]}function mt(H){i.audioTracks=[...H]}e.watch(u,H=>{H?ie():f.value&&(f.value.destroy(),f.value=null)}),e.watch(g,()=>{}),e.watch(h,H=>{p.setFps(H)});function me(){if(!i.selectedClipId)return;v();const H=i.clips.find(Se=>Se.id===i.selectedClipId);if(!H)return;const re={...H,id:de(),timelineStart:H.timelineEnd,timelineEnd:H.timelineEnd+(H.timelineEnd-H.timelineStart),filters:[...H.filters||[]]},be=i.clips.indexOf(H);i.clips.splice(be+1,0,re),i.selectedClipId=re.id,i.hasChanges=!0}function W(H){const re=H??800,be=i.totalDuration;if(be<=0){i.zoomLevel=50;return}const Se=re*.8/be;i.zoomLevel=Math.max(10,Math.min(600,Math.round(Se)))}function Y(){const H=1/h.value;_e(Math.min(i.playheadPosition+H,i.totalDuration))}function te(){const H=1/h.value;_e(Math.max(i.playheadPosition-H,0))}function oe(){_e(0)}function pe(){_e(i.totalDuration)}function we(H){if(!Number.isFinite(H)||H<=0)return;const re=M.value??i.clips[0];if(!re){E.value=H;return}const be=re.speed??1;if(be===H){E.value=H;return}v();const Se=Math.max(1/h.value,re.sourceOut-re.sourceIn),Le=Se/be,gt=Se/H,ct=gt-Le;re.speed=H,re.timelineEnd=re.timelineStart+gt;const Et=i.clips.findIndex(Ze=>Ze.id===re.id);if(Et!==-1&&ct!==0)for(let Ze=Et+1;Ze<i.clips.length;Ze+=1){const jt=i.clips[Ze];jt.timelineStart+=ct,jt.timelineEnd+=ct}P(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,E.value=H}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:M,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:E,useVideoEngine:u,compositionAdapter:e.computed(()=>f.value),fps:h,useFrameMode:g,handleTrim:x,handleSplit:_,handleClipSelect:U,splitAtPlayhead:I,deleteSelectedClip:$,duplicateSelectedClip:me,setFilters:Je,setTextOverlays:lt,setAudioTracks:mt,moveClip:j,saveDraft:Re,clearHasChanges:ae,resetChanges:B,generateRecipe:z,zoomIn:T,zoomOut:L,setZoomLevel:G,fitToWindow:W,togglePlayback:Z,setPlaying:ce,seekTo:_e,frameForward:Y,frameBackward:te,skipToStart:oe,skipToEnd:pe,setPlaybackSpeed:we,updateSourceDuration:R,undo:C,redo:O,canUndo:V,canRedo:y,initializeComposition:ie,syncCompositionWithState:K,syncWithComposition:ee,convertToFrames:ue,convertToSeconds:ge,seekToFrame:xe,toggleFrameMode:ne,onCompositionReady:ke,onCompositionError:he}}const X1=[{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}}}],H1={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Ma(a){return typeof a=="object"&&a!==null}function G1(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 Ba(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function J1(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=Ba(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=ot.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&Ma(r))for(const[s,c]of Object.entries(r))i[s]=Ba(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 Y1(a,n,t,o){const i=o.map(J1);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:Zl(a,i),paramRanges:Xl(i)}}function K1(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=Ba((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 q1(a,n){return n.toLowerCase()==="unlisted"?!1:ot.isFilterCompatibleWithMedia(a,"video")}function si(a){return H1[a]??a}function Qn(a){const n=G1(a,1);return Math.max(0,Math.min(1,n))}function eo(a){if(!Ma(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=Ba(o)??null;return n}function Q1(a){return!Ma(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:eo(a.params),intensity:Qn(a.intensity)}}function eg(a){if(!Ma(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>Q1(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 tg(){ot.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 I=new Map,U=ot.getRegisteredFilters();for(const $ of U)q1($.id,$.category)&&I.set($.id,Y1($.id,$.name,$.category,$.controls));for(const $ of X1)I.has($.id)||I.set($.id,K1($));return Array.from(I.values())}),c=e.computed(()=>{const I=new Map;for(const U of s.value)I.set(U.id,U);return I}),l=e.computed(()=>a.value.length>0),d=e.computed(()=>{const I={};for(const U of s.value)I[U.category]||(I[U.category]=[]),I[U.category].push(U);return I});function u(I){const U=c.value.get(I);if(U)return U;const $=si(I);return c.value.get($)??null}function f(I){const U=c.value.get(I);if(U)return U.id;const $=si(I),j=c.value.get($);return j?j.id:null}function p(I){const U=I?u(I):n.value;if(!U)return;const $=U.defaultParams||{},j={id:C(),filterId:U.id,params:{...$},intensity:1};return a.value.push(j),i.value=j.id,n.value=U,Object.keys(r).forEach(P=>delete r[P]),Object.assign(r,j.params),t.value=null,j}function h(I){const U=u(I);if(!U)return;n.value=U;const $=U.defaultParams||x(I);Object.assign(r,$),t.value={id:"preview",filterId:U.id,params:{...$},intensity:1}}function g(I){if(Object.assign(r,I),t.value&&(t.value.params={...r}),i.value){const U=a.value.find($=>$.id===i.value);U&&(U.params={...r})}}function w(I){const U=a.value.findIndex($=>$.id===I);U!==-1&&a.value.splice(U,1)}function E(I,U){if(I<0||I>=a.value.length||U<0||U>=a.value.length)return;const[$]=a.value.splice(I,1);a.value.splice(U,0,$)}function M(I,U){const $=a.value.find(j=>j.id===I);$&&($.intensity=Math.max(0,Math.min(1,U)))}function V(I){const U=a.value.find($=>$.id===I);U&&(U.intensity=U.intensity>0?0:1)}function y(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(I=>delete r[I])}function m(I){const U={id:O(),name:I,filters:a.value.map(j=>({filterId:j.filterId,params:eo(j.params),intensity:Qn(j.intensity)})),created_at:new Date().toISOString()};o.value.push(U);const $=o.value.map(j=>({...j}));return localStorage.setItem("video-filter-presets",JSON.stringify($)),U}function b(I){const U=o.value.find($=>$.id===I);if(U){y();for(const $ of U.filters){const j=u($.filterId);j&&a.value.push({id:C(),filterId:j.id,params:{...$.params},intensity:Qn($.intensity)})}}}function R(I){const U=o.value.findIndex($=>$.id===I);U!==-1&&(o.value.splice(U,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function N(){try{const I=localStorage.getItem("video-filter-presets");if(!I)return;const U=JSON.parse(I);if(!Array.isArray(U))return;o.value=U.map($=>eg($)).filter($=>$!==null)}catch{}}function v(){if(a.value.length===0)return"No filters applied";const I=a.value.map(U=>{const $=_(U.filterId);return($==null?void 0:$.name)||U.filterId});return I.length===1?I[0]:I.length===2?`${I[0]} + ${I[1]}`:`${I[0]} + ${I.length-1} more`}function C(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function O(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function x(I){const U=u(I);return U?U.defaultParams||{}:{}}function _(I){return u(I)}return N(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:l,filtersByCategory:d,applyFilter:p,previewFilterEffect:h,updateFilterParams:g,removeFilter:w,reorderFilters:E,updateFilterIntensity:M,toggleFilter:V,clearAllFilters:y,saveFilterPreset:m,loadFilterPreset:b,deleteFilterPreset:R,getFilterSummary:v,setActiveFilters(I){var $;const U=[];for(const j of I){const P=f(j.filterId);if(!P){const T=si(j.filterId);U.push({...j,filterId:T,params:eo(j.params),intensity:Qn(j.intensity)});continue}U.push({...j,filterId:P,params:eo(j.params),intensity:Qn(j.intensity)})}a.value=U,i.value=(($=a.value[0])==null?void 0:$.id)??null,Object.keys(r).forEach(j=>delete r[j]),a.value[0]&&Object.assign(r,eo(a.value[0].params))}}}class ng{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 rt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new rt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new rt({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 rt({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new rt({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=ve.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;o.stop=ve.fromSeconds(c+n.duration)}n.animation&&this.applyAnimation(o,n.animation,n);const s=new $n(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 Ee([i,c],[0,1],{easing:l});break;case"fade-out":n.alpha=new Ee([i,c],[1,0],{easing:l});break;case"rotate":t.rotation&&(n.rotation=new Ee([i,c],[t.rotation.from,t.rotation.to],{easing:l}));break;case"scale":t.scale&&(n.scale=new Ee([i,c],[t.scale.from,t.scale.to],{easing:l}));break;case"slide":t.translate&&(n.translate={x:new Ee([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ee([i,c],[t.translate.fromY,t.translate.toY],{easing:l})});break;case"typewriter":n.alpha=new Ee([i,c],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ee([i,c],[t.rotation.from,t.rotation.to],{easing:l})),t.scale&&(n.scale=new Ee([i,c],[t.scale.from,t.scale.to],{easing:l})),t.translate&&(n.translate={x:new Ee([i,c],[t.translate.fromX,t.translate.toX],{easing:l}),y:new Ee([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:yo,cascade:Sa,guinea:Va,solar:Ca,spotlight:wo,whisper:bo}[t],s=await this.composition.createTrack("caption"),c=new ya({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 og{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 on.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 on)o=n.source;else if(typeof n.source=="string")o=await on.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)o=await on.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=ve.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;i.stop=ve.fromSeconds(l+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new ca(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 Ee(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 ca({source:o.clip.source,start:ve.fromSeconds(i),stop:ve.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:ag}=Object.prototype,{getPrototypeOf:tr}=Object,{iterator:Ia,toStringTag:Gl}=Symbol,Fa=(a=>n=>{const t=ag.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Bt=a=>(a=a.toLowerCase(),n=>Fa(n)===a),Ra=a=>n=>typeof n===a,{isArray:On}=Array,uo=Ra("undefined");function ko(a){return a!==null&&!uo(a)&&a.constructor!==null&&!uo(a.constructor)&&ft(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const Jl=Bt("ArrayBuffer");function ig(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&Jl(a.buffer),n}const rg=Ra("string"),ft=Ra("function"),Yl=Ra("number"),xo=a=>a!==null&&typeof a=="object",sg=a=>a===!0||a===!1,Ko=a=>{if(Fa(a)!=="object")return!1;const n=tr(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Gl in a)&&!(Ia in a)},lg=a=>{if(!xo(a)||ko(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},cg=Bt("Date"),dg=Bt("File"),ug=Bt("Blob"),mg=Bt("FileList"),pg=a=>xo(a)&&ft(a.pipe),fg=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||ft(a.append)&&((n=Fa(a))==="formdata"||n==="object"&&ft(a.toString)&&a.toString()==="[object FormData]"))},hg=Bt("URLSearchParams"),[vg,gg,yg,wg]=["ReadableStream","Request","Response","Headers"].map(Bt),bg=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Eo(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),On(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(ko(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(ko(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 pn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ql=a=>!uo(a)&&a!==pn;function _i(){const{caseless:a}=ql(this)&&this||{},n={},t=(o,i)=>{const r=a&&Kl(n,i)||i;Ko(n[r])&&Ko(o)?n[r]=_i(n[r],o):Ko(o)?n[r]=_i({},o):On(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&Eo(arguments[o],t);return n}const kg=(a,n,t,{allOwnKeys:o}={})=>(Eo(n,(i,r)=>{t&&ft(i)?a[r]=Hl(i,t):a[r]=i},{allOwnKeys:o}),a),xg=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),Eg=(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)},Vg=(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&&tr(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},Sg=(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},Cg=a=>{if(!a)return null;if(On(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},Ng=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&tr(Uint8Array)),Tg=(a,n)=>{const o=(a&&a[Ia]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},_g=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},Mg=Bt("HTMLFormElement"),Bg=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Rs=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),Ig=Bt("RegExp"),Ql=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};Eo(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},Fg=a=>{Ql(a,(n,t)=>{if(ft(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(ft(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+"'")})}})},Rg=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return On(a)?o(a):o(String(a).split(n)),t},$g=()=>{},Dg=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function Ug(a){return!!(a&&ft(a.append)&&a[Gl]==="FormData"&&a[Ia])}const Og=a=>{const n=new Array(10),t=(o,i)=>{if(xo(o)){if(n.indexOf(o)>=0)return;if(ko(o))return o;if(!("toJSON"in o)){n[i]=o;const r=On(o)?[]:{};return Eo(o,(s,c)=>{const l=t(s,i+1);!uo(l)&&(r[c]=l)}),n[i]=void 0,r}}return o};return t(a,0)},Lg=Bt("AsyncFunction"),Ag=a=>a&&(xo(a)||ft(a))&&ft(a.then)&&ft(a.catch),ec=((a,n)=>a?setImmediate:n?((t,o)=>(pn.addEventListener("message",({source:i,data:r})=>{i===pn&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),pn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ft(pn.postMessage)),zg=typeof queueMicrotask<"u"?queueMicrotask.bind(pn):typeof process<"u"&&process.nextTick||ec,Pg=a=>a!=null&&ft(a[Ia]),J={isArray:On,isArrayBuffer:Jl,isBuffer:ko,isFormData:fg,isArrayBufferView:ig,isString:rg,isNumber:Yl,isBoolean:sg,isObject:xo,isPlainObject:Ko,isEmptyObject:lg,isReadableStream:vg,isRequest:gg,isResponse:yg,isHeaders:wg,isUndefined:uo,isDate:cg,isFile:dg,isBlob:ug,isRegExp:Ig,isFunction:ft,isStream:pg,isURLSearchParams:hg,isTypedArray:Ng,isFileList:mg,forEach:Eo,merge:_i,extend:kg,trim:bg,stripBOM:xg,inherits:Eg,toFlatObject:Vg,kindOf:Fa,kindOfTest:Bt,endsWith:Sg,toArray:Cg,forEachEntry:Tg,matchAll:_g,isHTMLForm:Mg,hasOwnProperty:Rs,hasOwnProp:Rs,reduceDescriptors:Ql,freezeMethods:Fg,toObjectSet:Rg,toCamelCase:Bg,noop:$g,toFiniteNumber:Dg,findKey:Kl,global:pn,isContextDefined:ql,isSpecCompliantForm:Ug,toJSONObject:Og,isAsyncFn:Lg,isThenable:Ag,setImmediate:ec,asap:zg,isIterable:Pg};function Te(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)}J.inherits(Te,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:J.toJSONObject(this.config),code:this.code,status:this.status}}});const tc=Te.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(Te,nc);Object.defineProperty(tc,"isAxiosError",{value:!0});Te.from=(a,n,t,o,i,r)=>{const s=Object.create(tc);return J.toFlatObject(a,s,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),Te.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const Wg=null;function Mi(a){return J.isPlainObject(a)||J.isArray(a)}function oc(a){return J.endsWith(a,"[]")?a.slice(0,-2):a}function $s(a,n,t){return a?a.concat(n).map(function(i,r){return i=oc(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function jg(a){return J.isArray(a)&&!a.some(Mi)}const Zg=J.toFlatObject(J,{},null,function(n){return/^is[A-Z]/.test(n)});function $a(a,n,t){if(!J.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=J.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,E){return!J.isUndefined(E[w])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&J.isSpecCompliantForm(n);if(!J.isFunction(i))throw new TypeError("visitor must be a function");function d(g){if(g===null)return"";if(J.isDate(g))return g.toISOString();if(J.isBoolean(g))return g.toString();if(!l&&J.isBlob(g))throw new Te("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(g)||J.isTypedArray(g)?l&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,w,E){let M=g;if(g&&!E&&typeof g=="object"){if(J.endsWith(w,"{}"))w=o?w:w.slice(0,-2),g=JSON.stringify(g);else if(J.isArray(g)&&jg(g)||(J.isFileList(g)||J.endsWith(w,"[]"))&&(M=J.toArray(g)))return w=oc(w),M.forEach(function(y,m){!(J.isUndefined(y)||y===null)&&n.append(s===!0?$s([w],m,r):s===null?w:w+"[]",d(y))}),!1}return Mi(g)?!0:(n.append($s(E,w,r),d(g)),!1)}const f=[],p=Object.assign(Zg,{defaultVisitor:u,convertValue:d,isVisitable:Mi});function h(g,w){if(!J.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(g),J.forEach(g,function(M,V){(!(J.isUndefined(M)||M===null)&&i.call(n,M,J.isString(V)?V.trim():V,w,p))===!0&&h(M,w?w.concat(V):[V])}),f.pop()}}if(!J.isObject(a))throw new TypeError("data must be an object");return h(a),n}function Ds(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function nr(a,n){this._pairs=[],a&&$a(a,this,n)}const ac=nr.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,Ds)}:Ds;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Xg(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||Xg;J.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=J.isURLSearchParams(n)?n.toString():new nr(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class Us{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){J.forEach(this.handlers,function(o){o!==null&&n(o)})}}const rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Hg=typeof URLSearchParams<"u"?URLSearchParams:nr,Gg=typeof FormData<"u"?FormData:null,Jg=typeof Blob<"u"?Blob:null,Yg={isBrowser:!0,classes:{URLSearchParams:Hg,FormData:Gg,Blob:Jg},protocols:["http","https","file","blob","url","data"]},or=typeof window<"u"&&typeof document<"u",Bi=typeof navigator=="object"&&navigator||void 0,Kg=or&&(!Bi||["ReactNative","NativeScript","NS"].indexOf(Bi.product)<0),qg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Qg=or&&window.location.href||"http://localhost",ey=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:or,hasStandardBrowserEnv:Kg,hasStandardBrowserWebWorkerEnv:qg,navigator:Bi,origin:Qg},Symbol.toStringTag,{value:"Module"})),st={...ey,...Yg};function ty(a,n){return $a(a,new st.classes.URLSearchParams,{visitor:function(t,o,i,r){return st.isNode&&J.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function ny(a){return J.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function oy(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&&J.isArray(i)?i.length:s,l?(J.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!c):((!i[s]||!J.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&J.isArray(i[s])&&(i[s]=oy(i[s])),!c)}if(J.isFormData(a)&&J.isFunction(a.entries)){const t={};return J.forEachEntry(a,(o,i)=>{n(ny(o),i,t,0)}),t}return null}function ay(a,n,t){if(J.isString(a))try{return(n||JSON.parse)(a),J.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const Vo={transitional:rc,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=J.isObject(n);if(r&&J.isHTMLForm(n)&&(n=new FormData(n)),J.isFormData(n))return i?JSON.stringify(sc(n)):n;if(J.isArrayBuffer(n)||J.isBuffer(n)||J.isStream(n)||J.isFile(n)||J.isBlob(n)||J.isReadableStream(n))return n;if(J.isArrayBufferView(n))return n.buffer;if(J.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 ty(n,this.formSerializer).toString();if((c=J.isFileList(n))||o.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $a(c?{"files[]":n}:n,l&&new l,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),ay(n)):n}],transformResponse:[function(n){const t=this.transitional||Vo.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(J.isResponse(n)||J.isReadableStream(n))return n;if(n&&J.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"?Te.from(c,Te.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:st.classes.FormData,Blob:st.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],a=>{Vo.headers[a]={}});const iy=J.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"]),ry=a=>{const n={};let t,o,i;return a&&a.split(`
|
|
34
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&iy[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},Os=Symbol("internals");function Xn(a){return a&&String(a).trim().toLowerCase()}function qo(a){return a===!1||a==null?a:J.isArray(a)?a.map(qo):String(a)}function sy(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 ly=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function li(a,n,t,o,i){if(J.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!J.isString(n)){if(J.isString(o))return n.indexOf(o)!==-1;if(J.isRegExp(o))return o.test(n)}}function cy(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function dy(a,n){const t=J.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 ht=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(c,l,d){const u=Xn(l);if(!u)throw new Error("header name must be a non-empty string");const f=J.findKey(i,u);(!f||i[f]===void 0||d===!0||d===void 0&&i[f]!==!1)&&(i[f||l]=qo(c))}const s=(c,l)=>J.forEach(c,(d,u)=>r(d,u,l));if(J.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(J.isString(n)&&(n=n.trim())&&!ly(n))s(ry(n),t);else if(J.isObject(n)&&J.isIterable(n)){let c={},l,d;for(const u of n){if(!J.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[d=u[0]]=(l=c[d])?J.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=Xn(n),n){const o=J.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return sy(i);if(J.isFunction(t))return t.call(this,i,o);if(J.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=Xn(n),n){const o=J.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||li(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=Xn(s),s){const c=J.findKey(o,s);c&&(!t||li(o,o[c],c,t))&&(delete o[c],i=!0)}}return J.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||li(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return J.forEach(this,(i,r)=>{const s=J.findKey(o,r);if(s){t[s]=qo(i),delete t[r];return}const c=n?cy(r):String(r).trim();c!==r&&delete t[r],t[c]=qo(i),o[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return J.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&J.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(`
|
|
35
|
-
`)}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[Os]=this[Os]={accessors:{}}).accessors,i=this.prototype;function r(s){const c=Xn(s);o[c]||(dy(i,s),o[c]=!0)}return J.isArray(n)?n.forEach(r):r(n),this}};ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);J.reduceDescriptors(ht.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});J.freezeMethods(ht);function ci(a,n){const t=this||Vo,o=n||t,i=ht.from(o.headers);let r=o.data;return J.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 Ln(a,n,t){Te.call(this,a??"canceled",Te.ERR_CANCELED,n,t),this.name="CanceledError"}J.inherits(Ln,Te,{__CANCEL__:!0});function cc(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new Te("Request failed with status code "+t.status,[Te.ERR_BAD_REQUEST,Te.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function uy(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function my(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 f=r,p=0;for(;f!==i;)p+=t[f++],f=f%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const h=u&&d-u;return h?Math.round(p*1e3/h):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(),f=u-t;f>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-f)))},()=>i&&s(i)]}const ua=(a,n,t=3)=>{let o=0;const i=my(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 f={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(f)},t)},Ls=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},As=a=>(...n)=>J.asap(()=>a(...n)),fy=st.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,st.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(st.origin),st.navigator&&/(msie|trident)/i.test(st.navigator.userAgent)):()=>!0,hy=st.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];J.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),J.isString(o)&&s.push("path="+o),J.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 vy(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function gy(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function dc(a,n,t){let o=!vy(n);return a&&(o||t==!1)?gy(a,n):n}const zs=a=>a instanceof ht?{...a}:a;function gn(a,n){n=n||{};const t={};function o(d,u,f,p){return J.isPlainObject(d)&&J.isPlainObject(u)?J.merge.call({caseless:p},d,u):J.isPlainObject(u)?J.merge({},u):J.isArray(u)?u.slice():u}function i(d,u,f,p){if(J.isUndefined(u)){if(!J.isUndefined(d))return o(void 0,d,f,p)}else return o(d,u,f,p)}function r(d,u){if(!J.isUndefined(u))return o(void 0,u)}function s(d,u){if(J.isUndefined(u)){if(!J.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function c(d,u,f){if(f in n)return o(d,u);if(f 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,f)=>i(zs(d),zs(u),f,!0)};return J.forEach(Object.keys({...a,...n}),function(u){const f=l[u]||i,p=f(a[u],n[u],u);J.isUndefined(p)&&f!==c||(t[u]=p)}),t}const uc=a=>{const n=gn({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:c}=n;n.headers=s=ht.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(J.isFormData(t)){if(st.hasStandardBrowserEnv||st.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((l=s.getContentType())!==!1){const[d,...u]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(st.hasStandardBrowserEnv&&(o&&J.isFunction(o)&&(o=o(n)),o||o!==!1&&fy(n.url))){const d=i&&r&&hy.read(r);d&&s.set(i,d)}return n},yy=typeof XMLHttpRequest<"u",wy=yy&&function(a){return new Promise(function(t,o){const i=uc(a);let r=i.data;const s=ht.from(i.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:d}=i,u,f,p,h,g;function w(){h&&h(),g&&g(),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 M(){if(!E)return;const y=ht.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),b={data:!c||c==="text"||c==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:y,config:a,request:E};cc(function(N){t(N),w()},function(N){o(N),w()},b),E=null}"onloadend"in E?E.onloadend=M:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(M)},E.onabort=function(){E&&(o(new Te("Request aborted",Te.ECONNABORTED,a,E)),E=null)},E.onerror=function(){o(new Te("Network Error",Te.ERR_NETWORK,a,E)),E=null},E.ontimeout=function(){let m=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const b=i.transitional||rc;i.timeoutErrorMessage&&(m=i.timeoutErrorMessage),o(new Te(m,b.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,a,E)),E=null},r===void 0&&s.setContentType(null),"setRequestHeader"in E&&J.forEach(s.toJSON(),function(m,b){E.setRequestHeader(b,m)}),J.isUndefined(i.withCredentials)||(E.withCredentials=!!i.withCredentials),c&&c!=="json"&&(E.responseType=i.responseType),d&&([p,g]=ua(d,!0),E.addEventListener("progress",p)),l&&E.upload&&([f,h]=ua(l),E.upload.addEventListener("progress",f),E.upload.addEventListener("loadend",h)),(i.cancelToken||i.signal)&&(u=y=>{E&&(o(!y||y.type?new Ln(null,a,E):y),E.abort(),E=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const V=uy(i.url);if(V&&st.protocols.indexOf(V)===-1){o(new Te("Unsupported protocol "+V+":",Te.ERR_BAD_REQUEST,a));return}E.send(r||null)})},by=(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 Te?u:new Ln(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Te(`timeout ${n} of ms exceeded`,Te.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=()=>J.asap(c),l}},ky=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},xy=async function*(a,n){for await(const t of Ey(a))yield*ky(t,n)},Ey=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()}},Ps=(a,n,t,o)=>{const i=xy(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 f=u.byteLength;if(t){let p=r+=f;t(p)}l.enqueue(new Uint8Array(u))}catch(d){throw c(d),d}},cancel(l){return c(l),i.return()}},{highWaterMark:2})},Da=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",mc=Da&&typeof ReadableStream=="function",Vy=Da&&(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}},Sy=mc&&pc(()=>{let a=!1;const n=new Request(st.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),Ws=64*1024,Ii=mc&&pc(()=>J.isReadableStream(new Response("").body)),ma={stream:Ii&&(a=>a.body)};Da&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!ma[n]&&(ma[n]=J.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new Te(`Response type '${n}' is not supported`,Te.ERR_NOT_SUPPORT,o)})})})(new Response);const Cy=async a=>{if(a==null)return 0;if(J.isBlob(a))return a.size;if(J.isSpecCompliantForm(a))return(await new Request(st.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(J.isArrayBufferView(a)||J.isArrayBuffer(a))return a.byteLength;if(J.isURLSearchParams(a)&&(a=a+""),J.isString(a))return(await Vy(a)).byteLength},Ny=async(a,n)=>{const t=J.toFiniteNumber(a.getContentLength());return t??Cy(n)},Ty=Da&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:c,onUploadProgress:l,responseType:d,headers:u,withCredentials:f="same-origin",fetchOptions:p}=uc(a);d=d?(d+"").toLowerCase():"text";let h=by([i,r&&r.toAbortSignal()],s),g;const w=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let E;try{if(l&&Sy&&t!=="get"&&t!=="head"&&(E=await Ny(u,o))!==0){let b=new Request(n,{method:"POST",body:o,duplex:"half"}),R;if(J.isFormData(o)&&(R=b.headers.get("content-type"))&&u.setContentType(R),b.body){const[N,v]=Ls(E,ua(As(l)));o=Ps(b.body,Ws,N,v)}}J.isString(f)||(f=f?"include":"omit");const M="credentials"in Request.prototype;g=new Request(n,{...p,signal:h,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:M?f:void 0});let V=await fetch(g,p);const y=Ii&&(d==="stream"||d==="response");if(Ii&&(c||y&&w)){const b={};["status","statusText","headers"].forEach(C=>{b[C]=V[C]});const R=J.toFiniteNumber(V.headers.get("content-length")),[N,v]=c&&Ls(R,ua(As(c),!0))||[];V=new Response(Ps(V.body,Ws,N,()=>{v&&v(),w&&w()}),b)}d=d||"text";let m=await ma[J.findKey(ma,d)||"text"](V,a);return!y&&w&&w(),await new Promise((b,R)=>{cc(b,R,{data:m,headers:ht.from(V.headers),status:V.status,statusText:V.statusText,config:a,request:g})})}catch(M){throw w&&w(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,a,g),{cause:M.cause||M}):Te.from(M,M&&M.code,a,g)}}),Fi={http:Wg,xhr:wy,fetch:Ty};J.forEach(Fi,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const js=a=>`- ${a}`,_y=a=>J.isFunction(a)||a===null||a===!1,fc={getAdapter:a=>{a=J.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,!_y(t)&&(o=Fi[(s=String(t)).toLowerCase()],o===void 0))throw new Te(`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 :
|
|
36
|
-
`+r.map(js).join(`
|
|
37
|
-
`):" "+js(r[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:Fi};function di(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Ln(null,a)}function Zs(a){return di(a),a.headers=ht.from(a.headers),a.data=ci.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),fc.getAdapter(a.adapter||Vo.adapter)(a).then(function(o){return di(a),o.data=ci.call(a,a.transformResponse,o),o.headers=ht.from(o.headers),o},function(o){return lc(o)||(di(a),o&&o.response&&(o.response.data=ci.call(a,a.transformResponse,o.response),o.response.headers=ht.from(o.response.headers))),Promise.reject(o)})}const hc="1.11.0",Ua={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{Ua[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const Xs={};Ua.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 Te(i(s," has been removed"+(t?" in "+t:"")),Te.ERR_DEPRECATED);return t&&!Xs[s]&&(Xs[s]=!0),n?n(r,s,c):!0}};Ua.spelling=function(n){return(t,o)=>!0};function My(a,n,t){if(typeof a!="object")throw new Te("options must be an object",Te.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 Te("option "+r+" must be "+l,Te.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Te("Unknown option "+r,Te.ERR_BAD_OPTION)}}const Qo={assertOptions:My,validators:Ua},Ut=Qo.validators;let hn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Us,response:new Us}}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+=`
|
|
38
|
-
`+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=gn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&Qo.assertOptions(o,{silentJSONParsing:Ut.transitional(Ut.boolean),forcedJSONParsing:Ut.transitional(Ut.boolean),clarifyTimeoutError:Ut.transitional(Ut.boolean)},!1),i!=null&&(J.isFunction(i)?t.paramsSerializer={serialize:i}:Qo.assertOptions(i,{encode:Ut.function,serialize:Ut.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Qo.assertOptions(t,{baseUrl:Ut.spelling("baseURL"),withXsrfToken:Ut.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&J.merge(r.common,r[t.method]);r&&J.forEach(["delete","get","head","post","put","patch","common"],g=>{delete r[g]}),t.headers=ht.concat(s,r);const c=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(t)===!1||(l=l&&w.synchronous,c.unshift(w.fulfilled,w.rejected))});const d=[];this.interceptors.response.forEach(function(w){d.push(w.fulfilled,w.rejected)});let u,f=0,p;if(!l){const g=[Zs.bind(this),void 0];for(g.unshift(...c),g.push(...d),p=g.length,u=Promise.resolve(t);f<p;)u=u.then(g[f++],g[f++]);return u}p=c.length;let h=t;for(f=0;f<p;){const g=c[f++],w=c[f++];try{h=g(h)}catch(E){w.call(this,E);break}}try{u=Zs.call(this,h)}catch(g){return Promise.reject(g)}for(f=0,p=d.length;f<p;)u=u.then(d[f++],d[f++]);return u}getUri(n){n=gn(this.defaults,n);const t=dc(n.baseURL,n.url,n.allowAbsoluteUrls);return ic(t,n.params,n.paramsSerializer)}};J.forEach(["delete","get","head","options"],function(n){hn.prototype[n]=function(t,o){return this.request(gn(o||{},{method:n,url:t,data:(o||{}).data}))}});J.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,c){return this.request(gn(c||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}hn.prototype[n]=t(),hn.prototype[n+"Form"]=t(!0)});let By=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 Ln(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 Iy(a){return function(t){return a.apply(null,t)}}function Fy(a){return J.isObject(a)&&a.isAxiosError===!0}const Ri={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(Ri).forEach(([a,n])=>{Ri[n]=a});function gc(a){const n=new hn(a),t=Hl(hn.prototype.request,n);return J.extend(t,hn.prototype,n,{allOwnKeys:!0}),J.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return gc(gn(a,i))},t}const je=gc(Vo);je.Axios=hn;je.CanceledError=Ln;je.CancelToken=By;je.isCancel=lc;je.VERSION=hc;je.toFormData=$a;je.AxiosError=Te;je.Cancel=je.CanceledError;je.all=function(n){return Promise.all(n)};je.spread=Iy;je.isAxiosError=Fy;je.mergeConfig=gn;je.AxiosHeaders=ht;je.formToJSON=a=>sc(J.isHTMLForm(a)?new FormData(a):a);je.getAdapter=fc.getAdapter;je.HttpStatusCode=Ri;je.default=je;const{Axios:Q4,AxiosError:e3,CanceledError:t3,isCancel:n3,CancelToken:o3,VERSION:a3,all:i3,Cancel:r3,isAxiosError:s3,spread:l3,toFormData:c3,AxiosHeaders:d3,HttpStatusCode:u3,formToJSON:m3,getAdapter:p3,mergeConfig:f3}=je;class ar{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 ar;const Ry={key:0,class:"mobile-layout"},$y={class:"preview-section"},Dy={class:"controls-section"},Uy={class:"tab-nav"},Oy=["onClick"],Ly={class:"tab-content"},Ay={class:"filters-panel"},zy={class:"adjustments-panel"},Py={class:"text-panel"},Wy={class:"transitions-panel"},jy={class:"audio-panel"},Zy={class:"export-panel"},Xy={key:0,"data-testid":"video-export-status-completed"},Hy={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Gy={key:1,class:"desktop-layout"},Jy={class:"desktop-main-row"},Yy={class:"preview-panel"},Ky={class:"fit-toggle"},qy={class:"editor-content"},Qy={class:"editor-tabs"},ew={class:"tab-header"},tw=["onClick"],nw={class:"tab-content-area"},ow={class:"filter-controls"},aw={class:"text-controls"},iw={class:"transition-controls"},rw={class:"audio-controls"},sw={class:"adjustments-controls"},lw={key:1,class:"no-filter-selected"},cw={class:"export-controls"},dw={key:0,"data-testid":"video-export-status-completed"},uw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},mw={class:"desktop-timeline-row"},pw={class:"timeline-zoom"},fw=["value"],hw={class:"zoom-readout"},vw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},gw={class:"dev-editor-row"},yw={class:"dev-editor-field"},ww={class:"dev-editor-field"},bw=["disabled"],kw=["disabled"],xw=["disabled"],Ew={class:"dev-editor-row"},Vw={class:"dev-editor-field dev-editor-field--wide"},Sw=["value"],Cw=["disabled"],Nw=["disabled"],Tw=["disabled"],_w=["disabled"],Mw=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"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const k=o.media.uuid??o.media.id;return typeof k=="string"&&k.trim()!==""?k.trim():void 0}),s=e.computed(()=>{const k=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return k!==""?k: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 k=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},S=o.featureFlags;return S?{filters:typeof S.filters=="boolean"?S.filters:k.filters,adjustments:typeof S.adjustments=="boolean"?S.adjustments:k.adjustments,text:typeof S.text=="boolean"?S.text:k.text,transitions:typeof S.transitions=="boolean"?S.transitions:k.transitions,audio:typeof S.audio=="boolean"?S.audio:k.audio,export:typeof S.export=="boolean"?S.export:k.export}:k}),f=e.computed(()=>c.value?l.value:d.value),p=e.computed(()=>f.value==="filters"||E.value),h=e.computed(()=>f.value!=="filters"&&!E.value),g=e.ref(null),w=e.ref(null),E=e.ref(!1),M=e.computed(()=>c.value?g.value:w.value);function V(k){return k==="contain"||k==="cover"||k==="none"}function y(k){if(!(k!=null&&k.metadata))return null;const S=k.metadata.fit_mode;return V(S)?S:null}const m=e.shallowRef(null),b=e.ref(null),R=e.ref(y(o.initialRecipe)??"contain"),N=e.ref(null),v=e.ref(null),C=e.ref(null),O=e.ref(!1),x=new Map,_=e.ref([]),I=e.ref([]),U=e.ref([]),$=e.ref([]),j=e.ref(1),P=()=>{c.value=window.innerWidth<768},T=[{id:"filters",label:"Filters",icon:nn},{id:"adjustments",label:"Adjust",icon:eu},{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:ha}],L=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],G=e.computed(()=>T.filter(k=>u.value[k.id])),Z=e.computed(()=>L.filter(k=>u.value[k.id])),ce=e.computed(()=>{var k,S;return((k=Z.value[0])==null?void 0:k.id)??((S=G.value[0])==null?void 0:S.id)??"filters"});e.watch(u,k=>{k[l.value]||(l.value=ce.value),k[d.value]||(d.value=ce.value)},{immediate:!0,deep:!0}),e.watch(ce,k=>{u.value[l.value]||(l.value=k),u.value[d.value]||(d.value=k)},{immediate:!0}),e.watch(u,k=>{k.export||(l.value==="export"&&(l.value=ce.value),d.value==="export"&&(d.value=ce.value))},{immediate:!0,deep:!0});const _e=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:Re,playheadPosition:ae,timelineClips:B,totalDuration:z,hasChanges:de,isPlaying:ie,selectedClip:K,zoomLevel:ee,playbackSpeed:ue,handleTrim:ge,handleSplit:xe,handleClipSelect:ne,splitAtPlayhead:ke,deleteSelectedClip:he,duplicateSelectedClip:Je,setZoomLevel:lt,moveClip:mt,setFilters:me,setTextOverlays:W,setAudioTracks:Y,saveDraft:te,clearHasChanges:oe,resetChanges:pe,generateRecipe:we,zoomIn:Be,zoomOut:De,fitToWindow:H,togglePlayback:re,setPlaying:be,seekTo:Se,frameForward:Le,frameBackward:gt,skipToStart:ct,skipToEnd:Et,setPlaybackSpeed:Ze,updateSourceDuration:jt}=Z1(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:za,activeFilters:Ye,selectedFilter:So,previewFilter:Co,previewFilterEffect:Bc,applyFilter:pr,updateFilterParams:Ic,removeFilter:Fc,clearAllFilters:fr,setActiveFilters:Rc}=tg();function An(k){var X,q;const S=((X=K.value)==null?void 0:X.id)??((q=B.value[0])==null?void 0:q.id);S&&(O.value=!0,typeof k=="object"&&k.id?pr(k.id):typeof k=="string"&&pr(k),me(Ye.value),m.value?m.value.setClipFilters(S,Ye.value):x.set(S,[...Ye.value]),ne(S),O.value=!1,Ft())}function $c(){var S,X;const k=((S=K.value)==null?void 0:S.id)??((X=B.value[0])==null?void 0:X.id);k&&ne(k)}function hr(k){const S=Ye.value.find(X=>X.filterId===k);S&&Fc(S.id)}const No=e.computed(()=>za.value.map(S=>{var q;const X=[];if(S.controls&&S.controls.length>0)for(const se of S.controls){const Q=se.type;if(Q==="button"||Q==="text"||Q==="range")continue;const le={id:se.property||se.id,label:se.label||se.id,type:Q,default:se.default??(Q==="toggle"?!1:Q==="color"?"#ffffff":0)};Q==="slider"&&(le.min=se.min??0,le.max=se.max??1,le.step=se.step??.01),Q==="select"&&se.options&&(le.options=se.options),X.push(le)}else if(S.paramRanges){const se=Object.entries(S.paramRanges);for(const[Q,le]of se){const Ie=Q.replace(/[-_]/g," ").replace(/\b\w/g,Rt=>Rt.toUpperCase()),dt=(q=S.defaultParams)==null?void 0:q[Q],Xt=(le.min+le.max)/2;X.push({id:Q,label:Ie,min:le.min,max:le.max,step:le.step??.01,default:typeof dt=="number"?dt:Xt})}}return{id:S.id,name:S.name,category:S.category,params:X}})),kn=e.ref("0.00"),xn=e.ref("0.00"),Yt=e.ref("");e.watch(No,k=>{if(k.length===0){Yt.value="";return}k.some(X=>X.id===Yt.value)||(Yt.value=k[0].id)},{immediate:!0});const tt=e.ref(!1),Pe=e.ref(0),Nt=e.ref(!1),Ae=e.ref(null),Tt=e.ref(null);let To=null,Vt=!1,Zt=null;const vr=e.computed(()=>{const k=new Map;return Ye.value.forEach(S=>k.set(S.filterId,S)),k}),gr=e.computed(()=>{var k,S;return Re.value?Re.value:((k=o.media)==null?void 0:k.thumbnail_url)||((S=o.media)==null?void 0:S.url)}),It=e.ref("");e.watch(()=>{var k,S;return{file:(k=o.media)==null?void 0:k.file,url:(S=o.media)==null?void 0:S.url}},(k,S,X)=>{var se,Q;const q=It.value;X(()=>{q&&q.startsWith("blob:")&&URL.revokeObjectURL(q)}),(se=o.media)!=null&&se.file?It.value=URL.createObjectURL(o.media.file):(Q=o.media)!=null&&Q.url?It.value=o.media.url:It.value=""},{immediate:!0}),e.onUnmounted(()=>{It.value&&It.value.startsWith("blob:")&&URL.revokeObjectURL(It.value)});const Pa=e.computed(()=>It.value),yr=e.computed(()=>{if(!o.media)return null;const{file:k,...S}=o.media;return{...S,url:It.value}}),wr=e.computed(()=>{var S;const k=(S=o.media)==null?void 0:S.url;return!!(k&&/^https?:/i.test(k))}),br=e.computed(()=>Ye.value),kr=e.computed(()=>ae.value),Dc=e.computed(()=>!!K.value&&ae.value>0),Uc=e.computed(()=>!!K.value&&B.value.length>1),Wa=e.ref(0),Kt=e.computed(()=>{try{const k=z.value??z;return k&&typeof k=="number"&&k>0?k:Wa.value}catch{return Wa.value}}),En=e.ref(),_o=e.ref(0),Mo=e.ref(!1);e.watch(Kt,k=>{var X;if(Mo.value||!k||k<=0)return;const S=_o.value||((X=En.value)==null?void 0:X.clientWidth)||0;S>0&&(Mo.value=!0,H(S))}),e.watch(_o,k=>{if(Mo.value||!k||k<=0)return;Kt.value>0&&(Mo.value=!0,H(k))});function Vn(k){return Number.isFinite(k)?k.toFixed(2):"0.00"}function xr(k){const S=Number(k);return Number.isFinite(S)?S:null}function Oc(k){k&&(kn.value=Vn(k.sourceIn),xn.value=Vn(k.sourceOut))}e.watch(()=>{var k,S,X;return[(k=K.value)==null?void 0:k.id,(S=K.value)==null?void 0:S.sourceIn,(X=K.value)==null?void 0:X.sourceOut]},()=>{Oc(K.value)},{immediate:!0});function Er(k){const S=K.value;if(!S)return;const X=1/30,q=S.sourceMinIn??0,se=S.sourceMaxOut??Kt.value,Q=S.sourceIn+(ae.value-S.timelineStart);if(k==="start"){const Ie=Math.max(q,Math.min(Q,S.sourceOut-X));kn.value=Vn(Ie);return}const le=Math.max(S.sourceIn+X,Math.min(Q,se));xn.value=Vn(le)}function Lc(){const k=K.value;if(!k)return;const S=xr(kn.value),X=xr(xn.value);if(S===null||X===null)return;const q=1/30,se=k.sourceMinIn??0,Q=k.sourceMaxOut??Kt.value,le=Math.max(se,Math.min(S,Q-q)),Ie=Math.max(le+q,Math.min(X,Q));ge(k.id,"start",le),ge(k.id,"end",Ie),kn.value=Vn(le),xn.value=Vn(Ie),K.value&&Se(K.value.timelineStart)}function Ac(){Yt.value.trim()!==""&&An(Yt.value)}function zc(){var k;fr(),me(Ye.value),(k=K.value)!=null&&k.id&&(m.value?m.value.setClipFilters(K.value.id,Ye.value):x.set(K.value.id,[...Ye.value])),Ft()}function Vr(k,S,X){var se,Q;const q=Ye.value.find(le=>le.filterId===k);q?(q.params={...q.params,[S]:X},me(Ye.value),m.value&&((se=K.value)!=null&&se.id)?m.value.setClipFilters(K.value.id,Ye.value):(Q=K.value)!=null&&Q.id&&x.set(K.value.id,[...Ye.value]),Ft(),$c()):Co.value&&Co.value.filterId===k&&(Co.value.params={...Co.value.params||{},[S]:X})}function Sr(k){Se(k)}function Cr(k){be(k)}function Bo(k){!Number.isFinite(k)||k<=0||(Wa.value=k,jt(k))}function Pc(){var S;const k=_o.value||((S=En.value)==null?void 0:S.clientWidth)||800;H(k)}function Wc(k){const S=k.target,X=Number(S.value);lt(X)}function Nr(k){var S;m.value=k,(S=m.value)!=null&&S.composition&&(N.value=new ng(m.value.composition),v.value=new da(m.value.composition),C.value=new og(m.value.composition));try{x.size&&(x.forEach((X,q)=>{m.value.setClipFilters(q,X)}),x.clear(),m.value.composition.computeFrame())}catch{}}function Tr(k){k!=null&&k.id&&Bc(k.id)}function _r(k){Ic(k),Ft()}async function Mr(k){if(!N.value)return;const S=await N.value.addTextOverlay(k);_.value.push({id:S,...k})}async function Br(k,S){if(!N.value)return;await N.value.updateTextOverlay(k,S);const X=_.value.findIndex(q=>q.id===k);X!==-1&&(_.value[X]={..._.value[X],...S})}async function Ir(k){N.value&&(await N.value.removeTextOverlay(k),_.value=_.value.filter(S=>S.id!==k))}async function Fr(k){if(!v.value||$.value.length<2)return;const[S,X]=$.value,q=await v.value.applyTransition(S,X,k);I.value.push({id:q,...k,name:k.type})}function Rr(k){if(!v.value)return;const S=I.value[k];S&&(v.value.removeTransition(S.id),I.value.splice(k,1))}function $r(k){}async function Dr(k){if(!C.value)return;const S=await C.value.addAudioTrack(k);U.value.push({id:S,...k})}async function Ur(k,S){if(!C.value)return;const X=U.value.findIndex(q=>q.id===k);X!==-1&&(U.value[X]={...U.value[X],...S})}async function Or(k){C.value&&(await C.value.removeAudioTrack(k),U.value=U.value.filter(S=>S.id!==k))}async function Lr(k,S){if(!C.value)return;await C.value.updateVolume(k,S);const X=U.value.find(q=>q.id===k);X&&(X.volume=S)}async function Ar(k,S){if(!C.value)return;await C.value.muteTrack(k,S);const X=U.value.find(q=>q.id===k);X&&(X.muted=S)}function zr(k){C.value&&(C.value.setMasterVolume(k),j.value=k)}function jc(k){i("thumbnail-selected",k)}function qt(){To!==null&&(clearInterval(To),To=null)}function Zc(k,S){return S?{...k,output:{...k.output,format:S.format,quality:S.quality}}:k}function zn(k){var S;return k.metadata||(k.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),k.metadata.fit_mode=R.value,(S=o.media)!=null&&S.url&&/^https?:/i.test(o.media.url)?k.metadata.source_url=o.media.url:delete k.metadata.source_url,k}function We(k,S,X){return Math.min(X,Math.max(S,k))}function ja(k,S){if(typeof k=="number"&&Number.isFinite(k))return k;if(typeof k=="string"){const X=Number(k);if(Number.isFinite(X))return X}return S}function at(k,S,X){for(const q of S)if(q in k)return ja(k[q],X);return X}function Xc(k){const S=typeof k.params=="object"&&k.params!==null?k.params:{};switch(k.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:We(at(S,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:We(at(S,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:We(at(S,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:We(at(S,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:We(at(S,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const q=We(at(S,["brightness"],1)-1,-1,1),se=We(at(S,["contrast"],1),.1,3),Q=We(at(S,["saturation"],1),0,3);return[{type:"brightness",value:q},{type:"contrast",value:se},{type:"saturation",value:Q}]}default:return[]}}function Hc(k){const S=k.timeline[0],X=Array.isArray(S==null?void 0:S.filters)?S.filters:[],q=[];for(const Q of X)if(q.push(...Xc(Q)),q.length>=12)break;const se={...k,filters:q.slice(0,12)};if(k.timeline.length===1&&S){const Q=Math.max(0,ja(S.sourceIn,0)),le=ja(S.sourceOut,Q);le>Q&&(se.trim={start:Q,end:le})}return se}function Gc(k){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[k??""]??[1920,1080]}function Jc(k){if(!k||typeof k!="object")return null;const S=k.duration;if(typeof S=="number"&&Number.isFinite(S)&&S>0)return S;if(S&&typeof S=="object"&&"value"in S){const X=S.value;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X}return null}async function Pr(k,S,X){var Xt,Rt,$t,Dt;const q=k.timeline[0],se=q?Math.max(0,q.sourceIn):0,Q=q?q.sourceOut:void 0,[le,Ie]=Gc((S==null?void 0:S.quality)??((Xt=k.output)==null?void 0:Xt.quality)),dt=((Rt=k.output)==null?void 0:Rt.fps)||30;be(!1),E.value=!0,await e.nextTick();try{const qe=[200,500,1e3];let it=!1;for(const Ka of qe){await new Promise(fd=>setTimeout(fd,Ka));const Fo=M.value;if(!(!Fo||typeof Fo.captureFrameAt!="function")&&typeof Fo.ensureReadyForCapture=="function"&&(it=await Fo.ensureReadyForCapture(),it))break}const yt=M.value;if(!yt||typeof yt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!it)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Io,isWebCodecsSupported:Pn}=await Promise.resolve().then(()=>require("./PixiFrameExporter-dBsAo3iz.cjs"));if(!Pn())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Zt=new AbortController;const Sn={width:le,height:Ie,fps:dt,trimStart:se,signal:Zt.signal};Q!==void 0&&(Sn.trimEnd=Q),X&&(Sn.onProgress=X);const Kr=It.value;Kr!==""&&(Sn.sourceUrl=Kr);const cd=typeof yt.duration=="number"&&yt.duration>0?yt.duration:(($t=k.source)==null?void 0:$t.duration)??Q??0,dd=await Io({captureFrameAt:Ka=>yt.captureFrameAt(Ka),duration:{value:cd}},Sn),Ya=new File([dd],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),ud=Jc(yt),md=((Dt=k.source)==null?void 0:Dt.duration)??0,pd=Math.max(0,(Q??ud??md)-se);return{file:Ya,recipe:k,meta:{duration:pd,width:le,height:Ie,format:"mp4",sizeBytes:Ya.size,size_bytes:Ya.size}}}finally{E.value=!1,Zt=null}}async function Yc(k,S){var Dt;qt(),Vt=!1,Zt=null,Tt.value=null,Ae.value=null,Nt.value=!1,Pe.value=0;const X=zn(k??we()),q=Jr(X),se=Array.isArray(q.filters)&&q.filters.length>0,Q=Ha(q);if(!(de.value||se||Q))return oe(),i("video-exported",null),null;const Ie=q.timeline[0],dt=Ie?Math.max(0,Ie.sourceIn):0,Rt=((Ie==null?void 0:Ie.sourceOut)??((Dt=q.source)==null?void 0:Dt.duration)??Kt.value)-dt,$t=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&Rt>o.clientExportThreshold;if($t){tt.value=!0;try{return await Kc(q),null}catch(qe){const it=qe instanceof Error?qe.message:"Server render failed";throw Ae.value=it,i("server-render-failed",it),qe}finally{tt.value=!1}}if(o.maxDuration>0&&Rt>o.maxDuration&&!$t){const qe=`This video is too long for in-browser export (${Math.round(Rt)}s). Server rendering is not available. Try a shorter clip.`;return Ae.value=qe,i("video-exported",null),null}tt.value=!0;try{const qe=await Pr(q,S,it=>{Vt||(Pe.value=it)});return Vt?(Ae.value="Export canceled.",Pe.value=0,i("video-exported",null),null):(oe(),i("recipe-generated",q),i("video-exported",qe),Pe.value=100,Nt.value=!0,qe)}catch(qe){if(Vt)return Ae.value="Export canceled.",Pe.value=0,i("video-exported",null),null;const it=qe instanceof Error?qe.message:"Local WebGL export failed.";throw Ae.value=it,new Error(`Video export failed: ${it}`)}finally{tt.value=!1}}async function Kc(k){const S=new ar(o.serverRenderEndpoint??"/api/v1");Ae.value="Starting server render...",Pe.value=0;const X=await S.createRenderJob({source_media_uuid:s.value,recipe:k});Tt.value=X.id,i("server-render-started",X.id),i("export-started",X.id),Ae.value="Rendering on server...";const q=await S.pollRenderJob(X.id,(Q,le)=>{Pe.value=Q,le==="processing"&&(Ae.value=`Server rendering: ${Q}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);Pe.value=100,Nt.value=!0,Ae.value="Server render complete!",oe(),i("recipe-generated",k);const se={id:q.id};typeof q.output_media_id=="string"&&q.output_media_id!==""&&(se.output_media_id=q.output_media_id),i("server-render-completed",se)}async function Wr(){if(!tt.value)return;Vt=!0,E.value=!1,Zt&&(Zt.abort(),Zt=null),qt();const k=Tt.value;if(k)try{const S=await fetch(`/api/v1/video/jobs/${k}`,{method:"DELETE"});if(!S.ok)throw new Error(`Cancel failed: ${S.status} ${S.statusText}`)}catch(S){const X=S instanceof Error?S.message:"Failed to cancel export";Ae.value=X,tt.value=!1,Tt.value=null;return}tt.value=!1,Pe.value=0,Nt.value=!1,Tt.value=null,Ae.value="Export canceled."}async function jr(k){qt(),Vt=!1,Zt=null,Tt.value=null,Ae.value=null,Nt.value=!1,tt.value=!0,Pe.value=0;try{const S=zn(Zc(we(),k));i("recipe-generated",S);const X=s.value.startsWith("temp-"),q=S.timeline[0],se=Array.isArray(q==null?void 0:q.filters)?q.filters:[],Q=!0,le=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(Q)try{const yt=await Pr(S,k,Sn=>{Vt||(Pe.value=Sn)});if(Vt){Ae.value="Export canceled.",tt.value=!1,Pe.value=0;return}i("video-exported",yt);const Io=URL.createObjectURL(yt.file),Pn=document.createElement("a");Pn.href=Io,Pn.download=`edited-video-${Date.now()}.mp4`,Pn.click(),setTimeout(()=>URL.revokeObjectURL(Io),100),tt.value=!1,Pe.value=100,Nt.value=!0;return}catch(yt){if(Vt){Ae.value="Export canceled.",tt.value=!1,Pe.value=0;return}if(X||!le)throw yt;Pe.value=0,Ae.value="Local filter export failed, falling back to server render."}const Ie={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},dt=(k==null?void 0:k.quality)??S.output.quality,Xt=Ie[dt]??"high",Rt={...Hc(S),export:{format:(k==null?void 0:k.format)??S.output.format,quality:Xt,resolution:dt,framerate:S.output.fps}},$t=await fetch("/api/v1/video/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_media_id:s.value,recipe:Rt})});if(!$t.ok)throw new Error(`Export failed: ${$t.status} ${$t.statusText}`);const Dt=await $t.json(),qe=(Dt==null?void 0:Dt.data)??Dt,it=typeof(qe==null?void 0:qe.id)=="string"?qe.id:null;if(!it)throw new Error("Export failed: missing job id");Tt.value=it,i("export-started",it),ld(it)}catch(S){if(E.value=!1,Zt=null,Vt){Ae.value="Export canceled.",tt.value=!1,Pe.value=0,Tt.value=null;return}try{const X=zn(we()),q=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),se=URL.createObjectURL(q),Q=document.createElement("a");Q.href=se,Q.download=`video-recipe-${Date.now()}.json`,Q.click(),setTimeout(()=>URL.revokeObjectURL(se),100)}finally{tt.value=!1,Pe.value=0,Tt.value=null,Ae.value=S instanceof Error?S.message:"Export failed"}}}const Za=async k=>{await new Promise(S=>{window.setTimeout(S,k)})},Xa=k=>{if(!k||k.width<=0||k.height<=0)return null;try{return k.toDataURL("image/jpeg",.85)}catch{return null}},qc=k=>{if(!k||typeof k!="object")return null;const X=k.pixiCanvas;if(X&&typeof X=="object"&&"value"in X){const q=X.value;return q instanceof HTMLCanvasElement?q:null}return X instanceof HTMLCanvasElement?X:null},Qc=k=>{if(!k||typeof k!="object")return null;const S=k.duration;if(typeof S=="number"&&Number.isFinite(S))return S;if(S&&typeof S=="object"&&"value"in S){const X=S.value;if(typeof X=="number"&&Number.isFinite(X))return X}return null},ed=k=>{if(!k||typeof k!="object")return null;const X=k.videoElement;if(X&&typeof X=="object"&&"value"in X){const q=X.value;return q instanceof HTMLVideoElement?q:null}return X instanceof HTMLVideoElement?X:null},Zr=k=>typeof k.params=="object"&&k.params!==null?k.params:{},td=k=>{const S=[];for(const X of k){const q=Zr(X),se=X.filterId.trim().toLowerCase();if(se==="brightness"){const le=(We(at(q,["value","brightness"],0),-1,1)+1)*100;S.push(`brightness(${le.toFixed(2)}%)`);continue}if(se==="contrast"){const Q=We(at(q,["value","contrast"],1),.1,4);S.push(`contrast(${(Q*100).toFixed(2)}%)`);continue}if(se==="saturation"||se==="saturate"){const Q=We(at(q,["value","saturation"],1),0,4);S.push(`saturate(${(Q*100).toFixed(2)}%)`);continue}if(se==="grayscale"){S.push("grayscale(100%)");continue}if(se==="sepia"){S.push("sepia(100%)");continue}if(se==="blur"||se==="gaussian-blur"||se==="kawase-blur"){const Q=We(at(q,["value","blur","radius"],0),0,30);Q>.01&&S.push(`blur(${Q.toFixed(2)}px)`);continue}if(se==="adjustment"){const Q=at(q,["brightness"],1),le=at(q,["contrast"],1),Ie=at(q,["saturation"],1);Math.abs(Q-1)>.01&&S.push(`brightness(${(We(Q,0,5)*100).toFixed(2)}%)`),Math.abs(le-1)>.01&&S.push(`contrast(${(We(le,.1,5)*100).toFixed(2)}%)`),Math.abs(Ie-1)>.01&&S.push(`saturate(${(We(Ie,0,5)*100).toFixed(2)}%)`);continue}if(se==="cinematic"){S.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(se==="dramatic"){S.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(se==="dreamy"){S.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return S.join(" ")},nd=k=>{const S=k.find(se=>se.filterId.trim().toLowerCase()==="noise");if(!S)return 0;const X=Zr(S),q=at(X,["noise","value","amount","intensity"],.2);return q<=1?We(q,0,1):We(q/100,0,1)},od=(k,S,X,q)=>{if(q<=0)return;const se=k.getImageData(0,0,S,X),Q=255*q;for(let le=0;le<se.data.length;le+=4){const Ie=(Math.random()*2-1)*Q;se.data[le]=We(se.data[le]+Ie,0,255),se.data[le+1]=We(se.data[le+1]+Ie,0,255),se.data[le+2]=We(se.data[le+2]+Ie,0,255)}k.putImageData(se,0,0)},Xr=async k=>{k.readyState>=2&&k.videoWidth>0&&k.videoHeight>0||await new Promise(S=>{let X=!1,q=0;const se=()=>{X||(X=!0,k.removeEventListener("loadedmetadata",Q),k.removeEventListener("loadeddata",Q),k.removeEventListener("canplay",Q),window.clearTimeout(q),S())},Q=()=>{se()};k.addEventListener("loadedmetadata",Q),k.addEventListener("loadeddata",Q),k.addEventListener("canplay",Q),q=window.setTimeout(()=>se(),800),k.play().catch(()=>{})})},ad=async(k,S)=>{await new Promise(X=>{let q=!1,se=0;const Q=()=>{q||(q=!0,k.removeEventListener("seeked",le),window.clearTimeout(se),X())},le=()=>{Q()};if(Math.abs(k.currentTime-S)<.016){requestAnimationFrame(()=>Q());return}k.addEventListener("seeked",le),se=window.setTimeout(()=>Q(),700),k.currentTime=S})},Hr=async(k,S)=>{await Xr(k);const X=Math.floor(k.videoWidth),q=Math.floor(k.videoHeight);if(X<=0||q<=0)return null;const se=Number.isFinite(k.duration)&&k.duration>0?k.duration:0,Q=se>0?We(S,0,se):0;await ad(k,Q);const le=document.createElement("canvas");le.width=X,le.height=q;const Ie=le.getContext("2d");if(!Ie)return null;const dt=td(Ye.value);dt!==""&&(Ie.filter=dt);try{Ie.drawImage(k,0,0,X,q)}catch{return null}const Xt=nd(Ye.value);return od(Ie,X,q,Xt),Xa(le)},id=async(k,S)=>{const X=document.createElement("video");X.src=k,X.muted=!0,X.playsInline=!0,X.preload="auto",k.startsWith("blob:")||(X.crossOrigin="anonymous");try{return await Xr(X),await Hr(X,S)}catch{return null}finally{X.pause(),X.removeAttribute("src"),X.load()}},rd=async k=>{const S=M.value,X=Xa(qc(S));if(X)return X;if(S!=null&&S.captureFrameAt)for(let Q=0;Q<4;Q+=1){const le=Qc(S);if(le!==null&&le<=0&&Q<2){await Za(80);continue}const Ie=await Promise.race([S.captureFrameAt(k),Za(450).then(()=>null)]),dt=Xa(Ie);if(dt)return dt;await Za(80)}const q=ed(S);if(q){const Q=await Hr(q,k);if(Q)return Q}const se=Pa.value.trim();if(se!==""){const Q=await id(se,k);if(Q)return Q}return null},Gr=k=>k.map(S=>({...S,params:S.params&&typeof S.params=="object"?{...S.params}:S.params}));function Jr(k){const S=Gr(Ye.value);if(!Ha(k)&&S.length>0&&Array.isArray(k.timeline)&&k.timeline.length>0){const q=k.timeline[0];q&&(k.timeline=[{...q,filters:S},...k.timeline.slice(1)])}return k}const Ha=k=>Array.isArray(k.timeline)?k.timeline.some(S=>Array.isArray(S.filters)&&S.filters.length>0):!1,sd=k=>{if(!k||typeof k!="object")return null;const S=k.posterFrame;if(typeof S!="string")return null;const X=S.trim();return X!==""?X:null};async function Ga(){const k=zn(Jr(te())),S=Gr(Ye.value),X=Ha(k)||S.length>0,q=sd(o.initialRecipe);if(X){const se=ae.value>0?ae.value:.1;try{const Q=await rd(se);Q?k.posterFrame=Q:q&&(k.posterFrame=q)}catch{q&&(k.posterFrame=q)}}else delete k.posterFrame;return oe(),i("draft-saved",k),k}function Yr(){pe()&&(fr(),Ft())}async function ld(k){qt(),To=window.setInterval(async()=>{var S,X;try{if(Vt){qt();return}const q=await fetch(`/api/v1/video/jobs/${k}`);if(!q.ok)throw new Error(`Status poll failed: ${q.status} ${q.statusText}`);const se=await q.json(),Q=(se==null?void 0:se.data)??se,le=Number((Q==null?void 0:Q.progress)??0);if(Pe.value=Number.isFinite(le)?le:0,Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(qt(),tt.value=!1,Tt.value=null,Q.status==="completed"){const Ie=((S=Q==null?void 0:Q.output_media)==null?void 0:S.url)??(Q==null?void 0:Q.output_url);Pe.value=100,Nt.value=!0,Ae.value=null}else{const Ie=!!((X=Q==null?void 0:Q.meta)!=null&&X.is_cancelled)||Q.status==="cancelled"||typeof(Q==null?void 0:Q.error_message)=="string"&&/cancel/i.test(Q.error_message);Ae.value=Ie?"Export canceled.":typeof(Q==null?void 0:Q.error_message)=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed"}}catch(q){qt(),tt.value=!1,Tt.value=null,Ae.value=q instanceof Error?q.message:"Failed to check export progress"}},2e3)}function Ja(){const k=zn(we());try{const S=k.timeline??[]}catch{}b.value=k}let an=null;function Ft(){an&&clearTimeout(an),an=setTimeout(()=>{Ja(),an=null},200)}e.watch(()=>B.value,Ft,{deep:!0}),e.watch(()=>K.value,k=>{if(O.value||!k)return;const S=(k==null?void 0:k.filters)??[];Rc(S)},{immediate:!0}),e.watch(()=>Ye.value,k=>{me(k),Ft()},{deep:!0}),e.watch(()=>_.value,k=>{W(k),Ft()},{deep:!0}),e.watch(()=>U.value,k=>{const S=k.map(X=>({...X,source:typeof X.source=="string"?X.source:void 0}));Y(S),Ft()},{deep:!0}),e.watch(()=>ae.value,Ft),n({saveDraft:Ga,exportForUpload:Yc}),Ja(),e.onUnmounted(()=>{qt(),Vt=!0,an&&(clearTimeout(an),an=null),m.value&&(m.value.destroy(),m.value=null),N.value=null,v.value=null,C.value=null});let Qt=null;return e.onMounted(()=>{window.addEventListener("resize",P);const k=()=>{!En.value||Qt||(Qt=new ResizeObserver(S=>{S[0]&&(_o.value=Math.round(S[0].contentRect.width))}),Qt.observe(En.value))};k(),Qt||e.nextTick(k),o.media&&Ja(),e.nextTick(()=>{const S=document.querySelector(".video-editor");S&&S.getBoundingClientRect();const X=document.querySelector(".mobile-layout");X&&X.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",P),Qt==null||Qt.disconnect(),Qt=null}),(k,S)=>{var X,q,se,Q;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:c.value}])},[c.value?(e.openBlock(),e.createElementBlock("div",Ry,[e.createElementVNode("div",$y,[e.withDirectives(e.createVNode(rs,{ref_key:"pixiPreviewMobileRef",ref:g,"aria-hidden":!p.value,class:"preview-host-child",source:Pa.value,filters:br.value,playhead:kr.value,"is-playing":e.unref(ie),"fit-mode":R.value,active:p.value,onPlayPause:e.unref(re),onDurationChange:Bo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Ss,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:b.value,media:yr.value,"enable-engine":h.value&&wr.value,"fit-mode":R.value,onTimeUpdate:Sr,onPlayStateChange:Cr,onDurationChange:Bo,onEngineReady:Nr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]])]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:En,class:"timeline-section"},[e.createVNode(Cs,{playhead:e.unref(ae),clips:e.unref(B),"selected-clip-id":((X=e.unref(K))==null?void 0:X.id)??((q=e.unref(B)[0])==null?void 0:q.id)??null,duration:Kt.value,"zoom-level":e.unref(ee),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Se),onTrim:e.unref(ge),onSplit:e.unref(xe),onClipSelect:e.unref(ne),onClipMove:e.unref(mt)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])],512),e.createElementVNode("div",Dy,[e.createElementVNode("div",Uy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,le=>(e.openBlock(),e.createElementBlock("button",{key:le.id,class:e.normalizeClass(["tab-button",{active:l.value===le.id}]),onClick:Ie=>l.value=le.id},[e.createVNode(e.unref(F.IonIcon),{icon:le.icon},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(le.label),1)],10,Oy))),128))]),e.createElementVNode("div",Ly,[e.withDirectives(e.createElementVNode("div",Ay,[e.createVNode(Ns,{filters:No.value,"active-filters":vr.value,"thumbnail-url":gr.value,onApplyFilter:An,onRemoveFilter:hr,onUpdateParam:Vr,onPreviewFilter:Tr},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,l.value==="filters"]]),e.withDirectives(e.createElementVNode("div",zy,[e.unref(So)?(e.openBlock(),e.createBlock(Ts,{key:0,filter:e.unref(So),"current-frame":e.unref(Re),onUpdateParams:_r},null,8,["filter","current-frame"])):e.createCommentVNode("",!0)],512),[[e.vShow,l.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",Py,[e.createVNode(Ms,{overlays:_.value,onAddOverlay:Mr,onUpdateOverlay:Br,onRemoveOverlay:Ir},null,8,["overlays"])],512),[[e.vShow,l.value==="text"]]),e.withDirectives(e.createElementVNode("div",Wy,[e.createVNode(Bs,{"selected-clips":$.value,"applied-transitions":I.value,onApplyTransition:Fr,onRemoveTransition:Rr,onPreviewTransition:$r},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,l.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",jy,[e.createVNode(Is,{"audio-layers":U.value,"master-volume":j.value,onAddTrack:Dr,onUpdateTrack:Ur,onRemoveTrack:Or,onUpdateVolume:Lr,onToggleMute:Ar,onUpdateMasterVolume:zr},null,8,["audio-layers","master-volume"])],512),[[e.vShow,l.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Zy,[e.createVNode(_s,{"can-export":e.unref(de),"is-exporting":tt.value,"export-progress":Pe.value,onExport:jr,onCancelExport:Wr,onSaveDraft:Ga,onReset:Yr},null,8,["can-export","is-exporting","export-progress"]),Nt.value?(e.openBlock(),e.createElementBlock("div",Xy," Export complete ")):e.createCommentVNode("",!0),Ae.value&&!Nt.value?(e.openBlock(),e.createElementBlock("div",Hy,e.toDisplayString(Ae.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,l.value==="export"]])])])])):(e.openBlock(),e.createElementBlock("div",Gy,[e.createElementVNode("div",Jy,[e.createElementVNode("div",Yy,[e.createElementVNode("div",Ky,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":S[0]||(S[0]=le=>R.value=le),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...S[9]||(S[9]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,R.value]])])]),e.withDirectives(e.createVNode(rs,{ref_key:"pixiPreviewDesktopRef",ref:w,"aria-hidden":!p.value,class:"preview-host-child",source:Pa.value,filters:br.value,playhead:kr.value,"is-playing":e.unref(ie),"fit-mode":R.value,active:p.value,onPlayPause:e.unref(re),onDurationChange:Bo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Ss,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:b.value,media:yr.value,"enable-engine":h.value&&wr.value,"fit-mode":R.value,onTimeUpdate:Sr,onPlayStateChange:Cr,onDurationChange:Bo,onEngineReady:Nr},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]]),k.showThumbnailPicker?(e.openBlock(),e.createBlock(wv,{key:0,"media-uuid":s.value,duration:Kt.value,onSelect:jc},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",qy,[e.createElementVNode("div",Qy,[e.createElementVNode("div",ew,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.value,le=>(e.openBlock(),e.createElementBlock("button",{key:le.id,class:e.normalizeClass(["tab-btn",{active:d.value===le.id}]),onClick:Ie=>d.value=le.id},e.toDisplayString(le.label),11,tw))),128))]),e.createElementVNode("div",nw,[e.withDirectives(e.createElementVNode("div",ow,[e.createVNode(Ns,{filters:No.value,"active-filters":vr.value,"thumbnail-url":gr.value,onApplyFilter:An,onRemoveFilter:hr,onUpdateParam:Vr,onPreviewFilter:Tr},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",aw,[e.createVNode(Ms,{overlays:_.value,onAddOverlay:Mr,onUpdateOverlay:Br,onRemoveOverlay:Ir},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",iw,[e.createVNode(Bs,{"selected-clips":$.value,"applied-transitions":I.value,onApplyTransition:Fr,onRemoveTransition:Rr,onPreviewTransition:$r},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",rw,[e.createVNode(Is,{"audio-layers":U.value,"master-volume":j.value,onAddTrack:Dr,onUpdateTrack:Ur,onRemoveTrack:Or,onUpdateVolume:Lr,onToggleMute:Ar,onUpdateMasterVolume:zr},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",sw,[e.unref(So)?(e.openBlock(),e.createBlock(Ts,{key:0,filter:e.unref(So),"current-frame":e.unref(Re),onUpdateParams:_r},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",lw,[...S[10]||(S[10]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",cw,[e.createVNode(_s,{"can-export":e.unref(de),"is-exporting":tt.value,"export-progress":Pe.value,onExport:jr,onCancelExport:Wr,onSaveDraft:Ga,onReset:Yr},null,8,["can-export","is-exporting","export-progress"]),Nt.value?(e.openBlock(),e.createElementBlock("div",dw," Export complete ")):e.createCommentVNode("",!0),Ae.value&&!Nt.value?(e.openBlock(),e.createElementBlock("div",uw,e.toDisplayString(Ae.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",mw,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:En,class:"timeline-container"},[e.createElementVNode("div",pw,[e.createElementVNode("label",null,[S[11]||(S[11]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ee),onInput:S[1]||(S[1]=le=>Wc(le))},null,40,fw)]),e.createElementVNode("span",hw,e.toDisplayString(Math.round(e.unref(ee)))+" px/s",1)]),e.createVNode(Cs,{playhead:e.unref(ae),clips:e.unref(B),"selected-clip-id":((se=e.unref(K))==null?void 0:se.id)??((Q=e.unref(B)[0])==null?void 0:Q.id)??null,duration:Kt.value,"zoom-level":e.unref(ee),sensitivity:.25,"onUpdate:playhead":e.unref(Se),onTrim:e.unref(ge),onSplit:e.unref(xe),onClipSelect:e.unref(ne),onClipMove:e.unref(mt)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(Hh,{"selected-clip":e.unref(K),"can-split":Dc.value,"can-delete":Uc.value,"is-playing":e.unref(ie),"zoom-level":e.unref(ee),"playback-speed":e.unref(ue),onSplit:e.unref(ke),onDelete:e.unref(he),onDuplicate:e.unref(Je),onZoomIn:e.unref(Be),onZoomOut:e.unref(De),onZoomChange:e.unref(lt),onFitToWindow:Pc,onPlayPause:e.unref(re),onFrameForward:e.unref(Le),onFrameBackward:e.unref(gt),onSkipToStart:e.unref(ct),onSkipToEnd:e.unref(Et),onSpeedChange:e.unref(Ze)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),_e.value?(e.openBlock(),e.createElementBlock("div",vw,[e.createElementVNode("div",gw,[e.createElementVNode("label",yw,[S[12]||(S[12]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":S[2]||(S[2]=le=>kn.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,kn.value]])]),e.createElementVNode("label",ww,[S[13]||(S[13]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":S[3]||(S[3]=le=>xn.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,xn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(K),onClick:S[4]||(S[4]=le=>Er("start"))}," Start = Playhead ",8,bw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(K),onClick:S[5]||(S[5]=le=>Er("end"))}," End = Playhead ",8,kw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(K),onClick:Lc}," Apply Trim ",8,xw)]),e.createElementVNode("div",Ew,[e.createElementVNode("label",Vw,[S[14]||(S[14]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":S[6]||(S[6]=le=>Yt.value=le),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(No.value,le=>(e.openBlock(),e.createElementBlock("option",{key:le.id,value:le.id},e.toDisplayString(le.name),9,Sw))),128))],512),[[e.vModelSelect,Yt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(K)||Yt.value==="",onClick:Ac}," Apply Filter ",8,Cw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Ye).length===0,onClick:zc}," Clear Filters ",8,Nw),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(K),onClick:S[7]||(S[7]=le=>An("noise"))}," QA: Noise ",8,Tw),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(K),onClick:S[8]||(S[8]=le=>An("grayscale"))}," QA: Grayscale ",8,_w)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),yc=Ne(Mw,[["__scopeId","data-v-f3a82229"]]),Bw=["aria-label"],Iw={class:"ve-header"},Fw={class:"ve-title"},Rw={class:"ve-body"},$w={class:"ve-footer"},Dw=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.open??!0),r=e.computed(()=>{var c;return t.mediaUuid||((c=t.media)==null?void 0:c.id)||`temp-${Date.now()}`});function s(){o("close"),o("update:open",!1)}return(c,l)=>i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-overlay",onClick:e.withModifiers(s,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":c.title,"aria-modal":"true"},[e.createElementVNode("header",Iw,[e.createElementVNode("h2",Fw,e.toDisplayString(c.title),1),e.createElementVNode("button",{class:"ve-close",onClick:s,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",Rw,[e.createVNode(yc,e.mergeProps({"media-uuid":r.value},{...c.initialRecipe?{initialRecipe:c.initialRecipe}:{},...c.media?{media:c.media}:{}},{"show-thumbnail-picker":c.showThumbnailPicker??!1,onRecipeGenerated:l[0]||(l[0]=d=>c.$emit("recipe-generated",d)),onExportStarted:l[1]||(l[1]=d=>c.$emit("export-started",d)),onDraftSaved:l[2]||(l[2]=d=>c.$emit("draft-saved",d)),onThumbnailSelected:l[3]||(l[3]=d=>c.$emit("thumbnail-selected",d))}),null,16,["media-uuid","show-thumbnail-picker"])]),e.createElementVNode("footer",$w,[e.renderSlot(c.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:s},"Cancel")],!0)])],8,Bw)])):e.createCommentVNode("",!0)}}),Uw=Ne(Dw,[["__scopeId","data-v-710e8e26"]]),Ow={class:"video-editor-modal"},Lw={class:"video-preview-container"},Aw=["src"],zw={class:"video-overlay-controls"},Pw=["aria-label"],Ww={class:"time-display"},jw={class:"timeline-container"},Zw={class:"clip-name"},Xw={class:"timeline-time-labels"},Hw={class:"tool-tabs"},Gw=["onClick"],Jw={class:"tool-panel"},Yw={key:0,class:"trim-panel"},Kw={class:"trim-controls"},qw={key:1,class:"filters-panel"},Qw={class:"filter-grid"},e2=["onClick"],t2={key:2,class:"text-panel"},n2={key:3,class:"transitions-panel"},o2={class:"transition-grid"},a2=["onClick"],i2={class:"action-buttons"},r2=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),f=e.ref(0),p=e.ref(null),h=e.ref("trim"),g=e.ref(null),w=e.ref(""),E=[{id:"trim",label:"Trim",icon:sl},{id:"filters",label:"Filters",icon:jd},{id:"text",label:"Text",icon:ul},{id:"transitions",label:"Transitions",icon:qd}],M=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],V=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],y=e.ref();e.onMounted(()=>{var T,L;(T=t.media)!=null&&T.url?r.value=t.media.url:(L=t.media)!=null&&L.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var T;(T=t.media)!=null&&T.file&&r.value&&URL.revokeObjectURL(r.value)});function m(){i.value&&(l.value=i.value.duration,f.value=l.value)}function b(){i.value&&(c.value=i.value.currentTime)}function R(){s.value=!1}function N(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function v(T){if(!T||isNaN(T))return"00:00";const L=Math.floor(T/60),G=Math.floor(T%60);return`${L.toString().padStart(2,"0")}:${G.toString().padStart(2,"0")}`}function C(T){if(!i.value||!y.value)return;const L=y.value.getBoundingClientRect(),ce=(T.clientX-L.left)/L.width*l.value;i.value.currentTime=Math.max(0,Math.min(ce,l.value))}function O(){u.value=c.value}function x(){f.value=c.value}function _(){u.value=0,f.value=l.value}function I(T){p.value=T;const L=Z=>{if(!p.value||!y.value)return;const ce=y.value.getBoundingClientRect(),ae=(Z.clientX-ce.left)/ce.width*l.value;p.value==="start"?u.value=Math.max(0,Math.min(ae,f.value-1)):f.value=Math.max(u.value+1,Math.min(ae,l.value))},G=()=>{p.value=null,document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",G)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",G)}function U(T){if(g.value=T,!i.value)return;const L={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=L[T]||"none"}function $(){}function j(T){}function P(){const T={timeline:[{id:d.value,url:r.value,startTime:0,endTime:l.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:g.value?[{type:g.value}]:[],textOverlays:w.value?[{content:w.value}]:[],duration:f.value-u.value};o("save",T)}return(T,L)=>(e.openBlock(),e.createElementBlock("div",Ow,[e.createElementVNode("div",Lw,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:m,onTimeupdate:b,onEnded:R,controls:""},null,40,Aw),e.createElementVNode("div",zw,[e.createElementVNode("button",{class:"play-pause-btn",onClick:N,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(F.IonIcon),{icon:s.value?e.unref(nu):e.unref(su)},null,8,["icon"])],8,Pw),e.createElementVNode("div",Ww,e.toDisplayString(v(c.value))+" / "+e.toDisplayString(v(l.value)),1)])]),e.createElementVNode("div",jw,[e.createElementVNode("div",{class:"timeline-track",onClick:C,ref_key:"timelineTrack",ref:y},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/l.value*100}%`,right:`${100-f.value/l.value*100}%`})},[e.createElementVNode("span",Zw,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${c.value/l.value*100}%`})},null,4),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/l.value*100}%`}),onMousedown:L[0]||(L[0]=G=>I("start"))},null,36)):e.createCommentVNode("",!0),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${f.value/l.value*100}%`}),onMousedown:L[1]||(L[1]=G=>I("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",Xw,[e.createElementVNode("span",null,e.toDisplayString(v(0)),1),e.createElementVNode("span",null,e.toDisplayString(v(l.value)),1)])]),e.createElementVNode("div",Hw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["tool-tab",{active:h.value===G.id}]),onClick:Z=>h.value=G.id},[e.createVNode(e.unref(F.IonIcon),{icon:G.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(G.label),1)],10,Gw)),64))]),e.createElementVNode("div",Jw,[h.value==="trim"?(e.openBlock(),e.createElementBlock("div",Yw,[L[7]||(L[7]=e.createElementVNode("h3",null,"Trim Video",-1)),L[8]||(L[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",Kw,[e.createElementVNode("button",{class:"btn-trim",onClick:O},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ts)},null,8,["icon"]),L[4]||(L[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:x},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ts)},null,8,["icon"]),L[5]||(L[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:_},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(so)},null,8,["icon"]),L[6]||(L[6]=e.createTextVNode(" Clear ",-1))])])])):h.value==="filters"?(e.openBlock(),e.createElementBlock("div",qw,[L[9]||(L[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",Qw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(M,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["filter-option",{active:g.value===G.id}]),onClick:Z=>U(G.id)},e.toDisplayString(G.name),11,e2)),64))])])):h.value==="text"?(e.openBlock(),e.createElementBlock("div",t2,[L[10]||(L[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[2]||(L[2]=G=>w.value=G),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,w.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:$},"Add Text")])):h.value==="transitions"?(e.openBlock(),e.createElementBlock("div",n2,[L[11]||(L[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",o2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(V,G=>e.createElementVNode("button",{key:G.id,class:"transition-option",onClick:Z=>(G.id,void 0)},e.toDisplayString(G.name),9,a2)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",i2,[e.createElementVNode("button",{class:"btn-cancel",onClick:L[3]||(L[3]=G=>T.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:P},"SAVE")])]))}}),s2=Ne(r2,[["__scopeId","data-v-b933f33b"]]),l2={class:"time-label"},c2=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),f=l%(c*5)===0;s.push({time:l,position:d,label:u,major:f})}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",l2,e.toDisplayString(l.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:l.major}])},null,2)],4))),128))],4))}}),d2=Ne(c2,[["__scopeId","data-v-0ef9c910"]]),u2=["data-track-index"],m2={class:"track-header"},p2={class:"track-label"},f2={class:"track-controls"},h2=["data-testid","aria-label"],v2=["data-testid","onMousedown","onClick"],g2={class:"clip-content"},y2={class:"clip-name"},w2={key:0,class:"clip-thumbnail"},b2=["src","alt"],k2=["onMousedown","aria-label"],x2=["onMousedown","aria-label"],E2=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 M=E.timelineEnd-E.timelineStart,V=E.timelineStart/t.duration*100,y=M/t.duration*100;return{left:`${V}%`,width:`${y}%`,backgroundColor:u(E)}}function u(E){const M=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],V=parseInt(E.id.replace(/\D/g,""))%M.length;return M[V]}function f(E){return E.label?E.label:E.url?(E.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${E.id.slice(-4)}`}function p(E){i.value=E.id,o("clip-select",E.id)}function h(){r.value=!r.value}function g(E,M){if(c.value)return;s.value=!0;const V=M.clientX,y=E.timelineStart,m=R=>{if(!s.value)return;const N=R.clientX-V,v=parseFloat(l.value.width),C=N/(t.zoom*100)*(t.duration/v),O=Math.max(0,y+C);o("clip-move",E.id,O)},b=()=>{s.value=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",b)}function w(E,M,V){c.value=M;const y=V.clientX,m=E.sourceIn,b=E.sourceOut,R=v=>{if(!c.value)return;const C=v.clientX-y,O=parseFloat(l.value.width),x=C/(t.zoom*100)*(t.duration/O);if(c.value==="start"){const _=Math.max(0,m+x);o("clip-trim",E.id,_,b)}else{const _=Math.max(m+1,b+x);o("clip-trim",E.id,m,_)}},N=()=>{c.value=null,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",N)}return(E,M)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":E.trackIndex},[e.createElementVNode("div",m2,[e.createElementVNode("span",p2,"Track "+e.toDisplayString(E.trackIndex+1),1),e.createElementVNode("div",f2,[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:h},[e.createVNode(e.unref(F.IonIcon),{icon:r.value?e.unref(Eu):e.unref(ku)},null,8,["icon"])],8,h2)):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,V=>(e.openBlock(),e.createElementBlock("div",{key:V.id,class:e.normalizeClass(["timeline-clip",{selected:V.id===i.value}]),style:e.normalizeStyle(d(V)),"data-testid":`clip-${V.id}`,onMousedown:y=>g(V,y),onClick:y=>p(V)},[e.createElementVNode("div",g2,[e.createElementVNode("span",y2,e.toDisplayString(f(V)),1),V.thumbnail?(e.openBlock(),e.createElementBlock("div",w2,[e.createElementVNode("img",{src:V.thumbnail,alt:f(V)},null,8,b2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(y=>w(V,"start",y),["stop"]),"aria-label":`Trim start of ${f(V)}`},null,40,k2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(y=>w(V,"end",y),["stop"]),"aria-label":`Trim end of ${f(V)}`},null,40,x2)],46,v2))),128))],4)],8,u2))}}),V2=Ne(E2,[["__scopeId","data-v-48e480d2"]]),S2={class:"video-timeline"},C2={class:"timeline-tracks"},N2=["aria-label","aria-valuenow","aria-valuemax"],T2={class:"timeline-controls"},_2={class:"zoom-level"},M2=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 y=Math.max(0,...t.clips.map(m=>m.track||0));return Array(y+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(y){return t.clips.filter(m=>(m.track||0)===y)}function f(y){const m=Math.floor(y/60),b=Math.floor(y%60);return`${m}:${b.toString().padStart(2,"0")}`}function p(y,m){o("clip-move",y,m)}function h(y,m,b){o("clip-trim",y,m,b)}function g(y){r.value=y}function w(){i.value=Math.min(i.value*1.2,5)}function E(){i.value=Math.max(i.value/1.2,.5)}function M(){s.value=!0;const y=b=>{if(!s.value||!c.value)return;const R=c.value.getBoundingClientRect(),C=Math.max(0,Math.min(b.clientX-R.left,R.width))/R.width*t.duration;o("seek",C)},m=()=>{s.value=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",m)}function V(y){let m=t.currentTime;switch(y.key){case"ArrowLeft":m=Math.max(0,t.currentTime-1);break;case"ArrowRight":m=Math.min(t.duration,t.currentTime+1);break;case"Home":m=0;break;case"End":m=t.duration;break;default:return}y.preventDefault(),o("seek",m)}return e.onMounted(()=>{c.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(y,m)=>(e.openBlock(),e.createElementBlock("div",S2,[e.createVNode(d2,{duration:y.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",C2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(b,R)=>(e.openBlock(),e.createBlock(V2,{key:`track-${R}`,"data-testid":`track-${R}`,clips:u(R),"track-index":R,zoom:i.value,duration:y.duration,onClipMove:p,onClipTrim:h,onClipSelect:g},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:M,"data-testid":"playhead","aria-label":`Playhead at ${f(y.currentTime)}`,role:"slider","aria-valuenow":y.currentTime,"aria-valuemax":y.duration,tabindex:"0",onKeydown:V},null,44,N2),e.createElementVNode("div",T2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:w},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Di)},null,8,["icon"])]),e.createElementVNode("span",_2,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(F.IonIcon),{icon:e.unref(fu)},null,8,["icon"])])])]))}}),B2=Ne(M2,[["__scopeId","data-v-001df415"]]),I2={class:"video-filters-panel"},F2={class:"filter-controls"},R2=["for"],$2={class:"filter-slider-group"},D2=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],U2={class:"filter-value"},O2={class:"filter-actions"},L2={key:0,class:"filter-presets"},A2={class:"preset-list"},z2=["data-testid","aria-label","onClick"],P2=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((p,h)=>(p[h.type]=h.default,p),{})),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(p,h){switch(p){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${h}%`;case"hue":return`${h}°`;case"blur":case"sharpen":return h.toFixed(1);default:return h.toString()}}function c(p){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(p)}function l(p){if(!c(p))return;const h={id:`filter-${p}`,filterId:p,params:{value:i[p]},intensity:1};t("filter-change",h)}function d(){o.forEach(p=>{i[p.type]=p.default,l(p.type)})}function u(){const p=prompt("Enter preset name:");if(!p)return;const h={id:`custom-${Date.now()}`,name:p,values:{...i}};r.value.push(h)}function f(p){Object.entries(p.values).forEach(([h,g])=>{i[h]=g,l(h)})}return(p,h)=>(e.openBlock(),e.createElementBlock("div",I2,[h[3]||(h[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",F2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,g=>e.createElementVNode("div",{key:g.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${g.type}`},e.toDisplayString(g.label),9,R2),e.createElementVNode("div",$2,[e.withDirectives(e.createElementVNode("input",{id:`filter-${g.type}`,"onUpdate:modelValue":w=>i[g.type]=w,type:"range",min:g.min,max:g.max,step:g.step,class:"filter-slider","data-testid":`filter-${g.type}`,"aria-label":`${g.label} filter`,"aria-valuenow":i[g.type],"aria-valuemin":g.min,"aria-valuemax":g.max,onInput:w=>l(g.type)},null,40,D2),[[e.vModelText,i[g.type],void 0,{number:!0}]]),e.createElementVNode("span",U2,e.toDisplayString(s(g.type,i[g.type])),1)])])),64))]),e.createElementVNode("div",O2,[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(F.IonIcon),{icon:e.unref(mo)},null,8,["icon"]),h[0]||(h[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(dl)},null,8,["icon"]),h[1]||(h[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",L2,[h[2]||(h[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",A2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,g=>(e.openBlock(),e.createElementBlock("button",{key:g.id,class:"preset-btn","data-testid":`preset-${g.id}`,"aria-label":`Apply ${g.name} preset`,onClick:w=>f(g)},e.toDisplayString(g.name),9,z2))),128))])])):e.createCommentVNode("",!0)]))}}),W2=Ne(P2,[["__scopeId","data-v-5ad2ac63"]]),j2={class:"video-text-panel"},Z2={class:"text-input-group"},X2={class:"text-options"},H2={class:"option-row"},G2={class:"option-row"},J2={class:"option-row"},Y2={class:"option-row"},K2={class:"checkbox-label"},q2={class:"option-row"},Q2={class:"text-overlay-list"},eb={key:0,class:"empty-state"},tb=["data-testid"],nb={class:"overlay-preview"},ob={class:"overlay-controls"},ab=["data-testid","aria-label","onClick"],ib=["data-testid","aria-label","onClick"],rb=["data-testid","aria-label","onClick"],sb=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(f=>f.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",j2,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",Z2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=f=>i.text=f),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(F.IonIcon),{icon:e.unref(Di)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",X2,[e.createElementVNode("div",H2,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=f=>i.fontFamily=f),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,i.fontFamily]])]),e.createElementVNode("div",G2,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=f=>i.fontSize=f),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",J2,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=f=>i.color=f),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",Y2,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=f=>i.backgroundColor=f),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",K2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=f=>i.hasBackground=f),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",q2,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=f=>i.animation=f),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,i.animation]])])]),e.createElementVNode("div",Q2,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",eb," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(f,p)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${p}`},[e.createElementVNode("div",nb,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:f.fontFamily,fontSize:`${Math.min(f.fontSize/4,16)}px`,color:f.color})},e.toDisplayString(f.text),5)]),e.createElementVNode("div",ob,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${p}`,"aria-label":`Edit overlay: ${f.text}`,onClick:h=>c(f)},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Hd)},null,8,["icon"])],8,ab),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${p}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:h=>l(f)},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Xd)},null,8,["icon"])],8,ib),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${p}`,"aria-label":`Remove overlay: ${f.text}`,onClick:h=>s(f.id)},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(gu)},null,8,["icon"])],8,rb)])],8,tb))),128))])]))}}),lb=Ne(sb,[["__scopeId","data-v-4d240e1e"]]),cb={class:"video-tools-panel"},db={class:"tool-tabs"},ub=["data-testid","aria-label","aria-selected","onClick"],mb={class:"tool-content"},pb={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},fb={class:"trim-actions"},hb={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},vb={class:"transition-types"},gb=["data-testid","aria-label","onClick"],yb={class:"transition-preview"},wb=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:sl},{id:"filters",name:"Filters",icon:nn},{id:"text",name:"Text",icon:ul},{id:"transitions",name:"Transitions",icon:as}],t=[{id:"fade",name:"Fade",icon:ei},{id:"slide-left",name:"Slide Left",icon:Ld},{id:"slide-right",name:"Slide Right",icon:Ad},{id:"dissolve",name:"Dissolve",icon:ei},{id:"wipe",name:"Wipe",icon:as},{id:"zoom",name:"Zoom",icon:ei}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",cb,[e.createElementVNode("div",db,[(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(F.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,ub)),64))]),e.createElementVNode("div",mb,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",pb,[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",fb,[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(F.IonIcon),{icon:e.unref(ns)},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(F.IonIcon),{icon:e.unref(ns)},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(F.IonIcon),{icon:e.unref(so)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(W2,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(lb,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",hb,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",vb,[(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",yb,[e.createVNode(e.unref(F.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,gb)),64))])])):e.createCommentVNode("",!0)])]))}}),bb=Ne(wb,[["__scopeId","data-v-fc135306"]]),kb={class:"video-export-panel"},xb={class:"export-presets"},Eb=["value"],Vb={key:0,class:"preset-details"},Sb={class:"detail-row"},Cb={class:"detail-row"},Nb={class:"detail-row"},Tb={class:"advanced-options"},_b={class:"options-content"},Mb={class:"option-group"},Bb={class:"option-group"},Ib={class:"option-group"},Fb=["disabled"],Rb={key:1,class:"export-progress"},$b={class:"progress-message"},Db={class:"progress-bar"},Ub=["aria-valuenow"],Ob={class:"progress-percentage"},Lb=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",kb,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",xb,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=f=>i.value=f),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,Eb))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Vb,[e.createElementVNode("div",Sb,[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",Cb,[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",Nb,[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",Tb,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",_b,[e.createElementVNode("div",Mb,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=f=>r.quality=f),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,r.quality]])]),e.createElementVNode("div",Bb,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=f=>r.bitrate=f),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",Ib,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=f=>r.includeAudio=f),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(F.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ha)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,Fb),d.isExporting?(e.openBlock(),e.createElementBlock("div",Rb,[e.createElementVNode("div",$b,e.toDisplayString(c.value),1),e.createElementVNode("div",Db,[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,Ub)]),e.createElementVNode("div",Ob,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),Ab=Ne(Lb,[["__scopeId","data-v-5caf8fe6"]]),zb=["data-testid"],Pb={class:"progress-header"},Wb={class:"file-info"},jb={class:"file-details"},Zb={class:"file-name"},Xb={class:"file-meta"},Hb={class:"file-size"},Gb={key:0,class:"separator"},Jb={key:1,class:"upload-speed"},Yb={key:2,class:"separator"},Kb={key:3,class:"time-remaining"},qb={class:"progress-actions"},Qb={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},ek={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},tk={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},nk=["aria-valuenow","aria-label"],ok={class:"progress-bar"},ak={class:"progress-percent"},ik={key:1,class:"error-message","data-testid":"video-upload-error"},rk={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},sk=["src","alt"],lk={key:0,class:"video-duration"},ck=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 p=n.upload.timeRemaining;if(p<60)return`${Math.round(p)}s`;const h=Math.floor(p/60);return h<60?`${h}m ${Math.round(p%60)}s`:`${Math.floor(h/60)}h ${h%60}m`}),c=e.computed(()=>{var p;return n.upload.status==="completed"&&((p=n.upload.media)!=null&&p.thumbnail_url)?n.upload.media.thumbnail_url:null}),l=e.computed(()=>{var p;return(p=n.upload.media)==null?void 0:p.duration});function d(p){if(p===0)return"0 B";const h=["B","KB","MB","GB","TB"],g=1024,w=Math.floor(Math.log(p)/Math.log(g));return`${(p/Math.pow(g,w)).toFixed(1)} ${h[w]}`}function u(p){if(p===0)return"0 B/s";const h=["B/s","KB/s","MB/s","GB/s"],g=1024,w=Math.floor(Math.log(p)/Math.log(g));return`${(p/Math.pow(g,w)).toFixed(1)} ${h[w]}`}function f(p){const h=Math.floor(p/3600),g=Math.floor(p%3600/60),w=Math.floor(p%60);return h>0?`${h}:${g.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`:`${g}:${w.toString().padStart(2,"0")}`}return(p,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${p.upload.id}`},[e.createElementVNode("div",Pb,[e.createElementVNode("div",Wb,[e.createVNode(e.unref(F.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",jb,[e.createElementVNode("h4",Zb,e.toDisplayString(p.upload.filename),1),e.createElementVNode("p",Xb,[e.createElementVNode("span",Hb,e.toDisplayString(d(p.upload.bytesTotal||0)),1),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Gb,"•")):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Jb,e.toDisplayString(u(p.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Yb,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Kb,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",qb,[p.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",Qb,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(il)},null,8,["icon"])])):p.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",ek,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Od),"aria-hidden":"true"},null,8,["icon"])])):p.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",tk,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:3,fill:"clear",size:"small",onClick:h[0]||(h[0]=g=>p.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(so),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:4,fill:"clear",size:"small",onClick:h[1]||(h[1]=g=>p.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(mo),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:5,fill:"clear",size:"small",onClick:h[2]||(h[2]=g=>p.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(so),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":p.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",ok,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:p.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",ak,e.toDisplayString(Math.round(r.value))+"%",1)],8,nk)):e.createCommentVNode("",!0),p.upload.error?(e.openBlock(),e.createElementBlock("div",ik,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Vu)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(p.upload.error),1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",rk,[e.createElementVNode("img",{src:c.value,alt:p.upload.filename},null,8,sk),l.value?(e.openBlock(),e.createElementBlock("div",lk,e.toDisplayString(f(l.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,zb))}}),dk=Ne(ck,[["__scopeId","data-v-9eacbf91"]]),ui=4,uk=500,mk=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Oa(a){return typeof a=="object"&&a!==null}function Hs(a){return Oa(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function pk(a){if(Hs(a))return a;if(Oa(a)&&Hs(a.data))return a.data;throw new Error("Invalid upload response from backend")}function Gs(a){return Oa(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function fk(a){if(Gs(a))return a;if(Oa(a)&&Gs(a.data))return a.data;throw new Error("Invalid media response from backend")}function Lo(a){return a?{...a}:{}}function Js(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function hk(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function vk(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 gk(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} ${vk(i)}`).join(",")}function Ao(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 yk(a,n){return a instanceof Error?a:new Error(n)}function wk(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 Ys(a){const n=Math.max(0,a-1),t=uk*Math.pow(2,n);return Math.min(5e3,t)}function Ks(a){return new Promise(n=>{window.setTimeout(n,a)})}async function qs(a,n){for(let t=1;t<=ui;t+=1)try{const o=await n();if(o.ok||!mk.has(o.status)||t>=ui)return o;await Ks(Ys(t))}catch(o){if(!wk(o)||t>=ui)throw o;await Ks(Ys(t))}throw new Error(`${a} failed after retry attempts`)}function bk(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 x=Array.from(n.value.values());return x.length===0?0:x.reduce((I,U)=>I+U.progress,0)/x.length});function d(x){o.value=x}function u(){}async function f(x){var I;const _=x.filter(U=>p(U));if(_.length!==0&&((I=a.onFilesSelected)==null||I.call(a,_),a.autoUpload!==!1))for(const U of _)await h(U)}function p(x){return!(a.maxFileSize&&x.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(x.type))}async function h(x){var U,$,j;const _=O(x);if(n.value.has(_)){const P=n.value.get(_);if((P==null?void 0:P.status)==="uploading")return}const I={id:_,file:x,filename:x.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:x.size,bytesUploaded:0};n.value.set(I.id,I),t.value.add(I.id);try{I.status="uploading",(U=a.onUploadStart)==null||U.call(a,I);const P=await g(x);a.resumable===!0||P.resumable===!0?await E(I,P):await w(I,P),I.status="processing",I.progress=100;const L=await b(P.media_uuid);I.status="completed",I.media=L,($=a.onUploadComplete)==null||$.call(a,L)}catch(P){if(I.status!=="cancelled"){const T=yk(P,"Upload failed");I.status="error",I.error=T.message,(j=a.onUploadError)==null||j.call(a,T,I)}}finally{t.value.delete(I.id),i.delete(I.id),r.delete(I.id)}}async function g(x){if(!o.value)throw new Error("API client not configured");const _={collection:a.collection||"videos",filename:x.name,size:x.size,mime_type:x.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},I=await o.value.post("/api/v1/video/upload",_);return pk(I)}async function w(x,_){const I=new XMLHttpRequest,U=Js(_),$=Lo(_.headers);return new Promise((j,P)=>{I.upload.addEventListener("progress",T=>{var L;T.lengthComputable&&(Ao(x,T.loaded),(L=a.onUploadProgress)==null||L.call(a,x))}),I.addEventListener("load",()=>{i.delete(x.id),I.status>=200&&I.status<300?j():P(new Error(`Upload failed with status ${I.status}`))}),I.addEventListener("error",()=>{i.delete(x.id),P(new Error("Upload failed"))}),I.addEventListener("abort",()=>{i.delete(x.id),P(new Error("Upload cancelled"))}),I.open(U,_.upload_url),Object.entries($).forEach(([T,L])=>{I.setRequestHeader(T,L)}),!Object.keys($).some(T=>T.toLowerCase()==="content-type")&&x.file.type&&I.setRequestHeader("Content-Type",x.file.type),i.set(x.id,I),I.send(x.file)})}async function E(x,_){var P;if(hk(_)){await M(x,_);return}const I=a.chunkSize||5*1024*1024,U=V(x.file,I),$=new AbortController;r.set(x.id,$);const j=await m(_.upload_id);j&&(U.forEach(T=>{T.end<=j.bytesUploaded&&(T.uploaded=!0)}),Ao(x,j.bytesUploaded));for(const T of U)T.uploaded||(await y(x,_,T,$),Ao(x,T.end),(P=a.onUploadProgress)==null||P.call(a,x))}async function M(x,_){var G;const I=new AbortController;r.set(x.id,I);const U={...Lo(_.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(x.file.size),"Upload-Metadata":gk(x,_)},$=await qs("Resumable upload initialization",()=>fetch(_.upload_url,{method:"POST",headers:U,signal:I.signal}));if(!$.ok)throw new Error(`Failed to initialize resumable upload: ${$.status}`);const j=$.headers.get("Location");if(!j)throw new Error("Resumable upload endpoint did not return upload location");const P=new URL(j,_.upload_url).toString(),T=a.chunkSize||5*1024*1024;let L=0;for(;L<x.file.size;){const Z=Math.min(L+T,x.file.size),ce=x.file.slice(L,Z),_e={...Lo(_.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(L),"Content-Type":"application/offset+octet-stream"},Re=await qs("Resumable chunk upload",()=>fetch(P,{method:"PATCH",headers:_e,body:ce,signal:I.signal}));if(Re.status===409){const B=Number(Re.headers.get("Upload-Offset")??"-1");if(Number.isFinite(B)&&B>=0){L=B;continue}}if(!Re.ok)throw new Error(`Resumable chunk upload failed: ${Re.status}`);const ae=Number(Re.headers.get("Upload-Offset")??String(Z));L=Number.isFinite(ae)&&ae>L?ae:Z,Ao(x,L),(G=a.onUploadProgress)==null||G.call(a,x)}}function V(x,_){const I=[];let U=0,$=0;for(;U<x.size;){const j=Math.min(U+_,x.size);I.push({start:U,end:j,blob:x.slice(U,j),index:$,uploaded:!1}),U=j,$++}return I}async function y(x,_,I,U){const $={...Lo(_.headers),"Content-Range":`bytes ${I.start}-${I.end-1}/${x.file.size}`,"Content-Type":x.file.type||"application/octet-stream"},j=await fetch(_.upload_url,{method:Js(_),headers:$,body:I.blob,signal:U.signal});if(!j.ok)throw new Error(`Chunk upload failed: ${j.status}`);I.uploaded=!0}async function m(x){return null}async function b(x){if(!o.value)throw new Error("API client not configured");const _=60;let I=0;for(;I<_;){const U=await o.value.get(`/api/v1/video/${x}`),$=fk(U),j=String($.processing_status);if(j==="ready")return $;if(j==="failed"||j==="error")throw new Error("Video processing failed");await new Promise(P=>{window.setTimeout(P,5e3)}),I++}throw new Error("Video processing timeout")}function R(x){const _=n.value.get(x);if(!_)return;const I=i.get(x);I&&(I.abort(),i.delete(x));const U=r.get(x);U&&(U.abort(),r.delete(x)),_.status="cancelled",_.error="Upload cancelled",t.value.delete(x)}async function N(x){const _=n.value.get(x);_&&(_.status="pending",_.error="",_.progress=0,_.bytesUploaded=0,await h(_.file))}function v(x){n.value.delete(x),t.value.delete(x),i.delete(x),r.delete(x)}function C(){Array.from(n.value.entries()).forEach(([x,_])=>{_.status==="completed"&&n.value.delete(x)})}function O(x){return`${x.name}-${x.size}-${Date.now()}`}return{uploads:c,isUploading:s,totalProgress:l,openFilePicker:u,handleFileSelect:f,validateFile:p,startUpload:h,cancelUpload:R,retryUpload:N,removeUpload:v,clearCompleted:C,setApiClient:d}}const kk=["accept","multiple"],xk={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},Ek=["onKeydown"],Vk={key:1,class:"upload-list","data-testid":"video-upload-list"},Sk={class:"drag-content"},Ck=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:f,setApiClient:p}=bk({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:m=>o("upload-start",m),onUploadProgress:m=>o("upload-progress",m),onUploadComplete:m=>o("upload-complete",m),onUploadError:(m,b)=>o("upload-error",m,b),onFilesSelected:m=>o("files-selected",m)});t.apiClient&&p(t.apiClient);const h=e.computed(()=>t.allowedFormats.join(",")),g=e.computed(()=>t.multiple||s.value.length===0);function w(){i.value&&i.value.click()}function E(m){const b=m.target,R=Array.from(b.files||[]);R.length>0&&(l(R),b.value="")}function M(m){var N;m.preventDefault(),r.value=!1;const R=Array.from(((N=m.dataTransfer)==null?void 0:N.files)||[]).filter(v=>v.type.startsWith("video/"));R.length>0&&l(R)}function V(m){var b;m.preventDefault(),(b=m.dataTransfer)!=null&&b.types.includes("Files")&&(r.value=!0)}function y(m){m.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",V),document.addEventListener("dragleave",y),document.addEventListener("drop",m=>m.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",V),document.removeEventListener("dragleave",y),document.removeEventListener("drop",m=>m.preventDefault())}),(m,b)=>(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:h.value,multiple:m.multiple,onChange:E,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,kk),!e.unref(c)||g.value?(e.openBlock(),e.createElementBlock("div",xk,[e.renderSlot(m.$slots,"trigger",{open:w},()=>[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:w,onKeydown:[e.withKeys(w,["enter"]),e.withKeys(e.withModifiers(w,["prevent"]),["space"])]},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ml),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(m.label),1),e.createElementVNode("p",null,e.toDisplayString(m.description),1),e.createVNode(e.unref(F.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Di),slot:"start","aria-hidden":"true"},null,8,["icon"]),b[2]||(b[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,Ek)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",Vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),R=>(e.openBlock(),e.createBlock(dk,{key:R.id,upload:R,onCancel:N=>e.unref(d)(R.id),onRetry:N=>e.unref(u)(R.id),onRemove:N=>e.unref(f)(R.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:M,onDragover:b[0]||(b[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:b[1]||(b[1]=R=>r.value=!1)},[e.createElementVNode("div",Sk,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(ha),"aria-hidden":"true"},null,8,["icon"]),b[3]||(b[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Nk=Ne(Ck,[["__scopeId","data-v-ea7587f7"]]),Tk=["aria-valuenow","aria-valuemax","aria-label"],_k={class:"progress-bar"},Mk={class:"time-display","data-testid":"video-time-display"},Bk={class:"current-time"},Ik={class:"duration"},Fk={class:"control-buttons"},Rk={class:"controls-left"},$k=["aria-label"],Dk={class:"controls-center"},Uk={key:0,class:"volume-controls"},Ok=["aria-label"],Lk=["value"],Ak={class:"controls-right"},zk={key:0,class:"quality-selector"},Pk=["aria-expanded"],Wk={class:"quality-label"},jk={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},Zk=["data-testid","aria-label","onClick"],Xk=["aria-label"],Hk=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=F.isPlatform("mobile"),l="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),f=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let m=0;m<t.buffered.length;m++){const b=t.buffered.start(m),R=t.buffered.end(m);if(t.currentTime>=b&&t.currentTime<=R)return{width:`${R/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),p=e.computed(()=>t.muted||t.volume===0?xu:t.volume<33?wu:t.volume<66?bu:yu);let h=null;function g(){i.value=!0,w()}function w(){h&&clearTimeout(h),t.playing&&!c&&(h=setTimeout(()=>{i.value=!1},3e3))}function E(m){if(!s.value||t.isLive)return;const b=s.value.getBoundingClientRect(),N=(m.clientX-b.left)/b.width*t.duration;o("seek",Math.max(0,Math.min(N,t.duration)))}function M(m){const b=m.target;o("setVolume",parseInt(b.value))}function V(m){o("selectQuality",m),r.value=!1}function y(m){if(!isFinite(m))return"0:00";const b=Math.floor(m/3600),R=Math.floor(m%3600/60),N=Math.floor(m%60);return b>0?`${b}:${R.toString().padStart(2,"0")}:${N.toString().padStart(2,"0")}`:`${R}:${N.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",g),w()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",g),h&&clearTimeout(h)}),(m,b)=>(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(m.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(m.duration),"aria-label":m.isLive?"Live stream":"Video progress",tabindex:"0",onClick:E},[e.createElementVNode("div",_k,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",Mk,[e.createElementVNode("span",Bk,e.toDisplayString(y(m.currentTime)),1),b[7]||(b[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Ik,e.toDisplayString(m.isLive?"LIVE":y(m.duration)),1)])],8,Tk),e.createElementVNode("div",Fk,[e.createElementVNode("div",Rk,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:b[0]||(b[0]=R=>m.$emit("play-pause")),"aria-label":m.playing?"Pause":"Play"},[e.createVNode(e.unref(F.IonIcon),{icon:m.playing?e.unref(tu):e.unref(au),"aria-hidden":"true"},null,8,["icon"])],8,$k),m.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:b[1]||(b[1]=R=>m.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(iu),"aria-hidden":"true"},null,8,["icon"]),b[8]||(b[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),m.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:b[2]||(b[2]=R=>m.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(lu),"aria-hidden":"true"},null,8,["icon"]),b[9]||(b[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Dk,[e.unref(c)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Uk,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:b[3]||(b[3]=R=>m.$emit("toggleMute")),"aria-label":m.muted?"Unmute":"Mute"},[e.createVNode(e.unref(F.IonIcon),{icon:p.value,"aria-hidden":"true"},null,8,["icon"])],8,Ok),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:m.muted?0:m.volume,onInput:M,"aria-label":"Volume"},null,40,Lk)]))]),e.createElementVNode("div",Ak,[m.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",zk,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:b[4]||(b[4]=R=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(hu),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",Wk,e.toDisplayString(m.currentQuality),1)],8,Pk),r.value?(e.openBlock(),e.createElementBlock("div",jk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.qualityLevels,R=>(e.openBlock(),e.createElementBlock("button",{key:R.label,class:e.normalizeClass(["quality-option",{active:R.label===m.currentQuality}]),"data-testid":`btn-video-quality-${R.label}`,"aria-label":`Set quality to ${R.label}`,role:"menuitem",onClick:N=>V(R)},e.toDisplayString(R.label),11,Zk))),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:b[5]||(b[5]=R=>m.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(vu),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:b[6]||(b[6]=R=>m.$emit("toggleFullscreen")),"aria-label":m.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(F.IonIcon),{icon:m.fullscreen?e.unref(Zd):e.unref(Gd),"aria-hidden":"true"},null,8,["icon"])],8,Xk)])])],2))}}),Gk=Ne(Hk,[["__scopeId","data-v-2ae77c13"]]);function Jk(a={}){var ce,_e,Re;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),f=e.ref(!1),p=e.ref(null),h=e.ref("idle"),g=e.ref(a.playbackUrl||((ce=a.media)==null?void 0:ce.playback_url)||((_e=a.media)==null?void 0:_e.url)||""),w=e.ref(null),E=e.ref(a.isLive||!1),M=e.ref(null),V=e.ref(null);function y(ae){V.value=ae}if((Re=a.media)!=null&&Re.token_expires_at){const ae=new Date(a.media.token_expires_at);w.value=Number.isNaN(ae.getTime())?null:ae}async function m(){var B;const ae=E.value?t.value:n.value;if(ae)try{await ae.play(),o.value=!0,h.value=E.value?"live":"playing",(B=a.onPlay)==null||B.call(a)}catch{p.value="Failed to play video",h.value="error"}}function b(){var B;const ae=E.value?t.value:n.value;ae&&(ae.pause(),o.value=!1,h.value="paused",(B=a.onPause)==null||B.call(a))}function R(){o.value?b():m()}function N(ae){const B=E.value?t.value:n.value;if(!B||E.value)return;const z=Number.isFinite(B.duration)?B.duration:ae;B.currentTime=Math.max(0,Math.min(ae,z)),i.value=B.currentTime}function v(ae=10){const B=n.value;!B||E.value||N(B.currentTime+ae)}function C(ae=10){const B=n.value;!B||E.value||N(B.currentTime-ae)}function O(){const ae=E.value?t.value:n.value;ae&&(ae.muted=!ae.muted,c.value=ae.muted)}function x(ae){const B=E.value?t.value:n.value;if(!B)return;const z=Math.max(0,Math.min(100,ae));B.volume=z/100,s.value=z,z>0&&B.muted&&(B.muted=!1,c.value=!1)}function _(ae){const B=n.value;!B||E.value||(B.playbackRate=ae,u.value=ae)}async function I(){const ae=document.querySelector(".video-player-container");if(ae)try{document.fullscreenElement?(await document.exitFullscreen(),l.value=!1):(await ae.requestFullscreen(),l.value=!0)}catch{}}async function U(){const ae=E.value?t.value:n.value;if(ae)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ae.requestPictureInPicture()}catch{}}async function $(){var B;p.value=null,h.value="loading",(B=a.media)!=null&&B.provider&&a.media.provider!=="local"&&await j();const ae=E.value?t.value:n.value;ae&&(ae.load(),await m())}async function j(){if(!(!V.value||!a.media))try{f.value=!0;const ae=await V.value.get(`/api/v1/video/${a.media.uuid}/playback`);g.value=ae.playback_url,w.value=new Date(ae.token_expires_at);const B=E.value?t.value:n.value;if(B&&B.src!==g.value){const z=!B.paused,de=B.currentTime;B.src=g.value,E.value||(B.currentTime=de),z&&await m()}}catch{p.value="Failed to refresh playback token",h.value="error"}finally{f.value=!1}}async function P(ae){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ae;return}try{t.value.src=ae}catch{p.value="Live streaming not supported in this browser",h.value="error"}}}function T(){M.value&&(M.value.destroy(),M.value=null)}function L(){var B;const ae=E.value?t.value:n.value;ae&&(i.value=ae.currentTime,r.value=ae.duration,(B=a.onTimeUpdate)==null||B.call(a,ae.currentTime))}const G=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ae=0;ae<d.value.length;ae++){const B=d.value.start(ae),z=d.value.end(ae);if(i.value>=B&&i.value<=z)return z/r.value*100}return 0});function Z(){if(!w.value)return!1;const ae=new Date;return w.value.getTime()-ae.getTime()<5*60*1e3}return e.watch([n,t],([ae,B])=>{const z=E.value?B:ae;z&&(z.addEventListener("timeupdate",L),z.addEventListener("loadedmetadata",()=>{r.value=z.duration,h.value="ready"}),z.addEventListener("progress",()=>{d.value=z.buffered}),z.addEventListener("ended",()=>{var de;o.value=!1,h.value="ended",(de=a.onEnded)==null||de.call(a)}),z.addEventListener("error",de=>{var ie;h.value="error",(ie=a.onError)==null||ie.call(a,"Video playback error")}),z.volume=s.value/100,z.muted=c.value)}),e.onUnmounted(()=>{T();const ae=E.value?t.value:n.value;ae&&ae.removeEventListener("timeupdate",L)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:c,isFullscreen:l,bufferedRanges:d,bufferedPercent:G,playbackRate:u,isLoading:f,error:p,status:h,currentPlaybackUrl:g,tokenExpiresAt:w,play:m,pause:b,togglePlayPause:R,seek:N,skipForward:v,skipBackward:C,toggleMute:O,setVolume:x,setPlaybackRate:_,toggleFullscreen:I,togglePiP:U,retry:$,refreshToken:j,setupLiveStream:P,setApiClient:y,shouldRefreshToken:Z}}const Yk=["src","poster","controls","autoplay","muted","loop","preload"],Kk={key:1,ref:"livePlayerEl",class:"live-player"},qk=["controls","muted"],Qk={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},ex={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},tx={key:3,class:"video-error","data-testid":"video-error",role:"alert"},nx={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},ox=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:f,bufferedRanges:p,isLoading:h,error:g,status:w,currentPlaybackUrl:E,tokenExpiresAt:M,play:V,pause:y,seek:m,toggleMute:b,setVolume:R,toggleFullscreen:N,togglePlayPause:v,skipForward:C,skipBackward:O,retry:x,refreshToken:_,setApiClient:I,shouldRefreshToken:U,setupLiveStream:$}=Jk({...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 j(){await _()}const P=e.computed(()=>{const ie=["video-player-container"];return t.className&&ie.push(t.className),f.value&&ie.push("fullscreen"),t.isLive&&ie.push("is-live"),s.value&&ie.push("is-playing"),h.value&&ie.push("is-loading"),ie}),T=e.computed(()=>{var ie,K;if(t.poster)return t.poster;if((ie=t.media)!=null&&ie.poster_url)return t.media.poster_url;if((K=t.media)!=null&&K.thumbnail_url)return t.media.thumbnail_url});function L(ie){const K=ie.target;o("loadedmetadata",{duration:K.duration,width:K.videoWidth,height:K.videoHeight})}function G(ie){const K=ie.target;c.value=K.currentTime,o("timeupdate",K.currentTime)}function Z(){s.value=!0,o("play")}function ce(){s.value=!1,o("pause")}function _e(){s.value=!1,o("ended")}function Re(ie){const K=ie.target;let ee="Failed to load video";if(K.error)switch(K.error.code){case K.error.MEDIA_ERR_ABORTED:ee="Video playback aborted";break;case K.error.MEDIA_ERR_NETWORK:ee="Network error while loading video";break;case K.error.MEDIA_ERR_DECODE:ee="Video decoding error";break;case K.error.MEDIA_ERR_SRC_NOT_SUPPORTED:ee="Video format not supported";break}g.value=ee,o("error",ee)}function ae(ie){const K=ie.target;p.value=K.buffered,o("progress",K.buffered)}function B(){h.value=!0}function z(){h.value=!1}e.watch(()=>t.apiClient,ie=>{ie&&I(ie)},{immediate:!0}),e.watch(()=>t.playbackUrl,ie=>{typeof ie=="string"&&ie.length>0&&(E.value=ie)},{immediate:!0}),e.watch(()=>{var ie;return(ie=t.media)==null?void 0:ie.token_expires_at},ie=>{if(!ie){M.value=null;return}const K=new Date(ie);M.value=Number.isNaN(K.getTime())?null:K},{immediate:!0}),e.watch(()=>{var ie;return(ie=t.media)==null?void 0:ie.playback_url},async(ie,K)=>{if(t.playbackUrl||!ie||ie===K)return;const ee=i.value;if(!ee||t.isLive){E.value=ie;return}const ue=!ee.paused,ge=ee.currentTime;E.value=ie,await e.nextTick();try{ee.currentTime=ge}catch{}ue&&await V()},{immediate:!0});let de=null;return e.watch(()=>t.isLive,async ie=>{var ee;if(!ie)return;const K=t.playbackUrl||((ee=t.media)==null?void 0:ee.playback_url)||"";K&&await $(K)},{immediate:!0}),e.onMounted(()=>{var ie;(ie=t.media)!=null&&ie.provider&&t.media.provider!=="local"&&(de=setInterval(()=>{U()&&j()},3e4)),F.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{de&&clearInterval(de)}),(ie,K)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",P.value]),"data-testid":"video-player"},[ie.isLive?(e.openBlock(),e.createElementBlock("div",Kk,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ie.controls&&!ie.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:Z,onPause:ce,onError:Re,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,qk),e.unref(w)==="live"?(e.openBlock(),e.createElementBlock("div",Qk,[...K[3]||(K[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:T.value,controls:ie.controls&&!ie.showCustomControls,autoplay:ie.autoplay,muted:e.unref(u),loop:ie.loop,preload:ie.preload,onLoadedmetadata:L,onTimeupdate:G,onPlay:Z,onPause:ce,onEnded:_e,onError:Re,onProgress:ae,onWaiting:B,onCanplay:z,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Yk)),e.unref(h)?(e.openBlock(),e.createElementBlock("div",ex,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("div",tx,[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Ui),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(g)),1),e.createVNode(e.unref(F.IonButton),{size:"small",onClick:e.unref(x),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{icon:e.unref(mo),slot:"start","aria-hidden":"true"},null,8,["icon"]),K[4]||(K[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ie.showCustomControls&&!e.unref(g)?(e.openBlock(),e.createBlock(Gk,{key:4,playing:e.unref(s),currentTime:e.unref(c),duration:e.unref(l),buffered:e.unref(p),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(f),isLive:ie.isLive,onPlay:e.unref(V),onPause:e.unref(y),onSeek:e.unref(m),onToggleMute:e.unref(b),onSetVolume:e.unref(R),onToggleFullscreen:e.unref(N),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ie.enableGestures&&!e.unref(g)?(e.openBlock(),e.createElementBlock("div",nx,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:K[0]||(K[0]=(...ee)=>e.unref(O)&&e.unref(O)(...ee))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:K[1]||(K[1]=(...ee)=>e.unref(v)&&e.unref(v)(...ee))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:K[2]||(K[2]=(...ee)=>e.unref(C)&&e.unref(C)(...ee))},null,32)])):e.createCommentVNode("",!0)],2))}}),wc=Ne(ox,[["__scopeId","data-v-b8db4951"]]),ax=fa.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($,j){const P=a.value.get($);P&&a.value.set($,{...P,...j})}function f($){a.value.delete($)}function p($){return a.value.get($)}function h($){n.value.set($.id,$)}function g($,j){const P=n.value.get($);P&&n.value.set($,{...P,...j})}function w($,j){const P=n.value.get($);P&&n.value.set($,{...P,status:j.status,viewer_count:j.viewer_count,peak_viewers:j.peak_viewers})}function E($){n.value.delete($)}function M($){return n.value.get($)}function V($){return s.value.find(j=>j.media_uuid===$)}function y($){t.value.set($.id,$)}function m($,j){const P=t.value.get($);P&&t.value.set($,{...P,...j})}function b($){t.value.delete($)}function R($){return t.value.get($)}function N($){return Array.from(t.value.values()).filter(j=>j.media_uuid===$)}function v($){o.value=$}function C($){o.value&&(o.value={...o.value,...$})}function O(){o.value=null}function x($){i.value=$}function _(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function I($){a.value.clear(),$.forEach(j=>{a.value.set(j.uuid,j)})}function U($){n.value.clear(),$.forEach(j=>{n.value.set(j.id,j)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:c,processingVideos:l,setVideo:d,updateVideo:u,removeVideo:f,getVideo:p,setLiveStream:h,updateLiveStream:g,updateLiveStreamStats:w,removeLiveStream:E,getLiveStream:M,getLiveStreamByMedia:V,addExportJob:y,updateExportJob:m,removeExportJob:b,getExportJob:R,getExportJobsByMedia:N,setEditorState:v,updateEditorState:C,clearEditorState:O,setProcessing:x,clearAll:_,loadVideos:I,loadLiveStreams:U}});let dn=null;function ix(a){dn=a}const zo={post:async(a,n)=>{if(!dn)throw new Error("HTTP client not configured");return await dn(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!dn)throw new Error("HTTP client not configured");return await dn(`/api/v1/video${a}`)},delete:async a=>{if(!dn)throw new Error("HTTP client not configured");return await dn(`/api/v1/video${a}`,{method:"DELETE"})}};function Po(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 mi(a,n){return a instanceof Error&&a.message?a.message:n}function rx(a){const n=ax(),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),f=e.ref(0);let p;const h=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),g=e.computed(()=>{var O;if(!((O=t.value)!=null&&O.playback_url))return null;const C=new URL(t.value.playback_url);return C.searchParams.set("live","true"),o.value&&C.searchParams.set("latency","low"),C.toString()}),w=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="live"}),E=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="idle"}),M=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="ended"});async function V(C={}){s.value=!0,l.value=null;try{const O=await zo.post("/live",{title:r.value||C.title||"Live Stream",low_latency:C.low_latency??o.value,auto_record:C.auto_record??i.value,...C}),x=Po(O);return t.value=x,n.setLiveStream(x),R(),x}catch(O){throw l.value=mi(O,"Failed to create stream"),O instanceof Error?O:new Error(l.value)}finally{s.value=!1}}async function y(){if(!t.value)throw new Error("No active stream");c.value=!0,l.value=null;try{const C=await zo.post(`/live/${t.value.id}/end`),O=Po(C,t.value);return t.value=O,n.setLiveStream(O),N(),O}catch(C){throw l.value=mi(C,"Failed to end stream"),C instanceof Error?C:new Error(l.value)}finally{c.value=!1}}async function m(){if(t.value)try{const C=await zo.get(`/live/${t.value.id}`),O=Po(C,t.value);u.value=O.viewer_count,f.value=O.peak_viewers,t.value=O;const x={status:O.status,viewer_count:O.viewer_count,peak_viewers:O.peak_viewers};O.started_at&&(x.started_at=O.started_at),O.ended_at&&(x.ended_at=O.ended_at),n.updateLiveStreamStats(O.id,x),O.status==="live"&&!d.value&&O.started_at&&(d.value=new Date(O.started_at)),O.status==="ended"&&N()}catch{}}async function b(C){try{const O=await zo.get(`/live/${C}`),x=Po(O,t.value);return{rtmp_url:x.rtmp_url,stream_key:x.stream_key,playback_url:x.playback_url||""}}catch(O){throw l.value=mi(O,"Failed to get stream credentials"),O instanceof Error?O:new Error(l.value)}}function R(C=5e3){N(),p=window.setInterval(()=>{m()},C)}function N(){p!==void 0&&(clearInterval(p),p=void 0)}async function v(){if(!a)return;const C=n.getLiveStreamByMedia(a);C&&(t.value=C,u.value=C.viewer_count,f.value=C.peak_viewers,C.status==="live"&&(R(),C.started_at&&(d.value=new Date(C.started_at))))}return a&&v(),e.onUnmounted(()=>{N()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:c,error:l,streamDuration:h,viewerCount:u,peakViewers:f,playbackUrl:g,isLive:w,isIdle:E,hasEnded:M,createStream:V,endStream:y,refreshStreamStatus:m,getStreamCredentials:b,startStatusPolling:R,stopStatusPolling:N}}const sx={class:"stream-status"},lx={class:"flex items-center justify-between"},cx={class:"flex items-center gap-3"},dx={key:0,class:"flex items-center"},ux={key:2,class:"text-sm text-gray-600"},mx={key:0,class:"flex items-center gap-2"},px={class:"text-sm font-medium text-gray-700"},fx={key:0,class:"text-xs text-gray-500"},hx=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",sx,[e.createElementVNode("div",lx,[e.createElementVNode("div",cx,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",dx,[...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",ux,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",mx,[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",px,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",fx," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),vx=Ne(hx,[["__scopeId","data-v-1d09c19f"]]),gx={class:"stream-credentials"},yx={class:"space-y-3"},wx={class:"credential-field"},bx={class:"flex gap-2"},kx=["value"],xx={class:"credential-field"},Ex={class:"flex gap-2"},Vx=["value","type"],Sx=["aria-label"],Cx={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Nx={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Tx={key:0,class:"mt-2 text-sm text-green-600"},_x=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",gx,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",yx,[e.createElementVNode("div",wx,[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",bx,[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,kx),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>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",xx,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",Ex,[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,Vx),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",Nx,[...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",Cx,[...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,Sx),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>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",Tx,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),Mx=Ne(_x,[["__scopeId","data-v-306d92f6"]]),Bx={class:"live-stream-manager","data-testid":"live-stream-manager"},Ix={key:0,class:"stream-setup"},Fx={class:"space-y-4"},Rx={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},$x={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},Dx=["disabled"],Ux={key:0},Ox={key:1,class:"flex items-center justify-center"},Lx={key:1,class:"stream-active space-y-6"},Ax={key:1,class:"video-preview"},zx={key:2,class:"analytics-panel"},Px={class:"grid grid-cols-2 gap-4"},Wx={class:"bg-gray-50 p-3 rounded"},jx={class:"text-2xl font-bold text-gray-900"},Zx={class:"bg-gray-50 p-3 rounded"},Xx={class:"text-2xl font-bold text-gray-900"},Hx={class:"stream-controls flex gap-3"},Gx=["disabled"],Jx={key:0},Yx={key:1},Kx={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},qx={class:"text-red-600 text-sm"},Qx=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&&ix(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:c,isCreating:l,isEnding:d,error:u,createStream:f,endStream:p,streamDuration:h,playbackUrl:g,refreshStreamStatus:w}=rx(t.mediaUuid),E=e.ref(!1);async function M(){var R;try{const N=await f({title:c.value,low_latency:r.value,auto_record:s.value});o("stream-created",N),(R=t.onStreamCreated)==null||R.call(t,N)}catch(N){o("error",N)}}async function V(){var R;try{const N=await p();o("stream-ended",N),(R=t.onStreamEnded)==null||R.call(t,N)}catch(N){o("error",N)}}function y(){i.value=null,c.value="",E.value=!1,u.value=null}async function m(R,N){try{await navigator.clipboard.writeText(R)}catch{}}let b;return e.onMounted(()=>{var R;((R=i.value)==null?void 0:R.status)==="live"&&(b=window.setInterval(()=>{w()},5e3))}),e.onUnmounted(()=>{b&&clearInterval(b)}),(R,N)=>(e.openBlock(),e.createElementBlock("div",Bx,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",Lx,[e.createVNode(vx,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(h),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(Mx,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:m},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("div",Ax,[N[9]||(N[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(wc,{"playback-url":e.unref(g),"is-live":!0,muted:!0,controls:!1,class:"w-full rounded-lg overflow-hidden"},null,8,["playback-url"])])):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("div",zx,[N[12]||(N[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",Px,[e.createElementVNode("div",Wx,[e.createElementVNode("div",jx,e.toDisplayString(e.unref(i).viewer_count),1),N[10]||(N[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",Zx,[e.createElementVNode("div",Xx,e.toDisplayString(e.unref(i).peak_viewers),1),N[11]||(N[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",Hx,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[3]||(N[3]=v=>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:V,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",Yx,"Ending...")):(e.openBlock(),e.createElementBlock("span",Jx,"End Stream"))],8,Gx)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:y,class:"flex-1 py-2 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors"}," Start New Stream ")):e.createCommentVNode("",!0)])])):(e.openBlock(),e.createElementBlock("div",Ix,[N[8]||(N[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",Fx,[e.createElementVNode("div",Rx,[N[4]||(N[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":N[0]||(N[0]=v=>e.isRef(r)?r.value=v: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",$x,[N[5]||(N[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":N[1]||(N[1]=v=>e.isRef(s)?s.value=v: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,[N[6]||(N[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":N[2]||(N[2]=v=>e.isRef(c)?c.value=v: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:M,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",Ox,[...N[7]||(N[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",Ux,"Create Stream"))],8,Dx)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",Kx,[e.createElementVNode("p",qx,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),eE=Ne(Qx,[["__scopeId","data-v-26291f6f"]]),tE={class:"album-tree-node"},nE=["data-album-id","draggable","aria-selected","aria-expanded"],oE={key:1,class:"album-node__chevron-placeholder"},aE={key:2,"data-testid":"media-count",class:"album-node__count"},iE={key:0,class:"album-tree-node__children",role:"group"},rE=16,sE=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*rE}px`),d=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.dropTargetId)===t.album.id}),f=e.computed(()=>{var y;return(y=t.dragState)!=null&&y.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),p=e.computed(()=>{const y=["album-node"];return r.value&&y.push("album-node--selected"),s.value&&y.push("album-node--focused"),t.compact&&y.push("album-node--compact"),d.value&&y.push("album-node--dragging"),u.value&&y.push("album-node--drop-target"),f.value&&y.push("album-node--invalid-drop"),y});function h(){o("select",t.album)}function g(y){y.stopPropagation(),o("toggle-expand",t.album.id)}function w(y){t.draggable&&(y.dataTransfer&&(y.dataTransfer.setData("text/plain",t.album.id),y.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function E(y){t.draggable&&(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function M(){o("drag-leave",t.album.id)}function V(y){t.draggable&&(y.preventDefault(),o("drop",t.album.id))}return(y,m)=>{var R;const b=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",tE,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":y.album.id,class:e.normalizeClass(p.value),style:e.normalizeStyle({paddingLeft:l.value}),draggable:y.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":c.value?i.value:void 0,onDragstart:w,onDragover:E,onDragleave:M,onDrop:V},[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:g},[e.createVNode(e.unref(F.IonIcon),{icon:i.value?e.unref(Pd):e.unref(Wd)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",oE)),e.createVNode(e.unref(F.IonIcon),{icon:e.unref(Kd),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:h},e.toDisplayString(y.album.name),1),y.showMediaCount?(e.openBlock(),e.createElementBlock("span",aE,e.toDisplayString(y.album.media_count),1)):e.createCommentVNode("",!0)],46,nE),i.value&&((R=y.album.children)!=null&&R.length)?(e.openBlock(),e.createElementBlock("div",iE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.album.children,N=>(e.openBlock(),e.createBlock(b,{key:N.id,album:N,depth:y.depth+1,"selected-id":y.selectedId,"expanded-ids":y.expandedIds,"focused-id":y.focusedId,draggable:y.draggable,"show-media-count":y.showMediaCount,compact:y.compact,onSelect:m[0]||(m[0]=v=>o("select",v)),onToggleExpand:m[1]||(m[1]=v=>o("toggle-expand",v))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),lE=Ne(sE,[["__scopeId","data-v-76be65a6"]]),La=fa.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 m=new Map;return a.value.forEach(b=>m.set(b.id,b)),m}),s=e.computed(()=>a.value.filter(m=>m.parent_id===null));async function c(m){t.value=!0,o.value=null;try{const b=(m==null?void 0:m.parent_id)??null,R=b?`/api/v1/albums?parent_id=${b}`:"/api/v1/albums?parent_id=null",N=await fetch(R);if(!N.ok)throw new Error("Failed to fetch albums");((await N.json()).data||[]).forEach(O=>{const x=a.value.findIndex(_=>_.id===O.id);x>=0?a.value[x]=O:a.value.push(O)}),b!==null&&i.value.add(b)}catch(b){o.value=b instanceof Error?b.message:"Unknown error"}finally{t.value=!1}}async function l(m){t.value=!0,o.value=null;try{const b=await fetch(`/api/v1/albums/${m}`);if(!b.ok)throw new Error("Failed to fetch album");const N=(await b.json()).data,v=a.value.findIndex(C=>C.id===N.id);return v>=0?a.value[v]=N:a.value.push(N),N}catch(b){throw o.value=b instanceof Error?b.message:"Unknown error",b}finally{t.value=!1}}async function d(m){t.value=!0,o.value=null;try{const b=await fetch(`/api/v1/albums/${m}/media`);if(!b.ok)throw new Error("Failed to fetch album media");const N=(await b.json()).data||[];return n.value.set(m,N),N}catch(b){throw o.value=b instanceof Error?b.message:"Unknown error",b}finally{t.value=!1}}async function u(m,b){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${m}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:b})})).ok)throw new Error("Failed to reorder album media");const N=n.value.get(m)||[],v=b.map(C=>N.find(O=>O.uuid===C)).filter(C=>C!==void 0);n.value.set(m,v)}catch(R){throw o.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function f(m){t.value=!0,o.value=null;try{const b=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(m)});if(!b.ok)throw new Error("Failed to create album");const N=(await b.json()).data;return a.value.push(N),N}catch(b){throw o.value=b instanceof Error?b.message:"Unknown error",b}finally{t.value=!1}}async function p(m,b){t.value=!0,o.value=null;try{const R=await fetch(`/api/v1/albums/${m}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(b)});if(!R.ok)throw new Error("Failed to update album");const v=(await R.json()).data,C=a.value.findIndex(O=>O.id===v.id);return C>=0&&(a.value[C]=v),v}catch(R){throw o.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function h(m){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${m}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const R=a.value.findIndex(N=>N.id===m);R>=0&&a.value.splice(R,1),n.value.delete(m)}catch(b){throw o.value=b instanceof Error?b.message:"Unknown error",b}finally{t.value=!1}}function g(m){return a.value.filter(b=>b.parent_id===m)}function w(m){return i.value.has(m)}function E(m){return n.value.get(m)||[]}async function M(m,b){const R=a.value.findIndex(v=>v.id===m);if(R<0)return;const N=a.value[R];a.value[R]={...N,parent_id:b};try{if(!(await fetch(`/api/v1/albums/${m}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:b})})).ok)throw new Error("Failed to move album")}catch(v){throw a.value[R]=N,o.value=v instanceof Error?v.message:"Unknown error",v instanceof Error?v:new Error("Failed to move album")}}function V(m){a.value=m}function y(){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:f,updateAlbum:p,deleteAlbum:h,getChildrenOf:g,childrenLoaded:w,getAlbumMedia:E,moveAlbum:M,setAlbums:V,reset:y}});function bc(){const a=La(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=fa.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,f){await a.moveAlbum(u,f)}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(f,p){if(f===p)return!0;const h=new Set,g=[f];for(;g.length>0;){const w=g.shift();if(!w||h.has(w))continue;h.add(w);const E=n.get(w)||[];for(const M of E){if(M===p)return!0;g.push(M)}}return!1}function r(f,p){return f===p?!1:p===null?!0:!i(f,p)}function s(f){o.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function c(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function l(f){o.value.dropTargetId=f}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:p}=o.value;if(!f){c();return}if(!r(f,p)){c();return}try{await t(f,p)}finally{c()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:c,setDropTarget:l,clearDropTarget:d,executeDrop:u}}const cE={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},dE={key:1,"data-testid":"error-state",class:"album-tree__error"},uE={key:2,"data-testid":"empty-state",class:"album-tree__empty"},mE={key:3,class:"album-tree__content",role:"group"},pE=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:f,fetchAlbums:p,getChildrenOf:h,childrenLoaded:g,moveAlbum:w}=bc(),E=e.shallowRef(new Set(o.expandedIds)),M=e.ref(o.modelValue??null),V=e.ref(null),y=new Map,m=new Map;function b(B){y.clear(),m.clear();for(const z of B){y.set(z.id,z);const de=z.parent_id??null,ie=m.get(de)??[];ie.push(z.id),m.set(de,ie)}}e.watch(l,B=>{b(B)},{immediate:!0});const{dragState:R,canDropOn:N,startDrag:v,endDrag:C,setDropTarget:O,clearDropTarget:x,executeDrop:_}=kc({childrenByParentId:m,onMove:async(B,z)=>{await w(B,z),i("album-moved",{albumId:B,newParentId:z})}});e.watch(()=>o.modelValue,B=>{M.value=B??null}),e.watch(()=>o.expandedIds,B=>{E.value=new Set(B)}),e.onMounted(async()=>{await p({parent_id:null})});const I=e.computed(()=>d.value.map(B=>U(B)));function U(B){if(!E.value.has(B.id))return B;const z=h(B.id);return{...B,children:z.map(de=>U(de))}}const $=e.computed(()=>{const B=[];function z(de){var ie;for(const K of de)B.push(K),E.value.has(K.id)&&((ie=K.children)!=null&&ie.length)&&z(K.children)}return z(I.value),B});function j(B){var ie;if(!$.value.length)return;const z=V.value?$.value.findIndex(K=>K.id===V.value):-1,de=z>=0?$.value[z]:null;switch(B.key){case"ArrowDown":B.preventDefault(),z<$.value.length-1?V.value=$.value[z+1].id:z===-1&&$.value.length>0&&(V.value=$.value[0].id);break;case"ArrowUp":B.preventDefault(),z>0&&(V.value=$.value[z-1].id);break;case"ArrowRight":B.preventDefault(),de&&(de.children_count>0&&!E.value.has(de.id)?P(de.id):E.value.has(de.id)&&((ie=de.children)!=null&&ie.length)&&(V.value=de.children[0].id));break;case"ArrowLeft":B.preventDefault(),de&&(E.value.has(de.id)&&de.children_count>0?P(de.id):de.parent_id&&(V.value=de.parent_id));break;case"Enter":case" ":B.preventDefault(),de&&T(de);break;case"Home":B.preventDefault(),$.value.length>0&&(V.value=$.value[0].id);break;case"End":B.preventDefault(),$.value.length>0&&(V.value=$.value[$.value.length-1].id);break}}async function P(B){E.value.has(B)?(E.value.delete(B),i("album-collapsed",B)):(g(B)||await p({parent_id:B}),E.value.add(B),i("album-expanded",B))}function T(B){M.value=B.id,i("update:modelValue",B.id),i("album-selected",B)}function L(B){o.draggable&&v(B)}function G(B){var de;if(!o.draggable)return;const z=(de=R.value)==null?void 0:de.draggedAlbumId;z&&(O(B),N(z,B))}function Z(){o.draggable&&x()}async function ce(B){o.draggable&&(O(B),await _())}function _e(B){o.draggable&&(B.preventDefault(),O(null))}async function Re(B){o.draggable&&(B.preventDefault(),O(null),await _())}function ae(){C()}return n({focusedId:V}),(B,z)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:j,onDragover:_e,onDrop:Re,onDragend:ae},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",cE,[e.createVNode(e.unref(F.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",dE,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",mE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,de=>(e.openBlock(),e.createBlock(lE,{key:de.id,album:de,depth:0,"selected-id":M.value,"expanded-ids":E.value,"focused-id":V.value,draggable:r.value,"drag-state":r.value?e.unref(R):null,"show-media-count":s.value,compact:c.value,onSelect:T,onToggleExpand:P,onDragStart:L,onDragOver:G,onDragLeave:Z,onDrop:ce},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",uE,[z[0]||(z[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(B.$slots,"empty-action",{},void 0,!0)]))],32))}}),xc=Ne(pE,[["__scopeId","data-v-ae3dea7a"]]),fE=300,hE=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,h=>{i.value=h??null});const l=e.computed(()=>r.value!==null);function d(h){const g=Date.now();if(c.value===h.id&&g-s.value<fE){o("confirm",h);return}s.value=g,c.value=h.id,i.value=h.id,r.value=h}function u(){r.value&&o("confirm",r.value)}function f(){o("close")}function p(){o("close")}return(h,g)=>(e.openBlock(),e.createBlock(e.unref(F.IonModal),{"is-open":h.isOpen,class:"album-browser-modal",onDidDismiss:p},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.title),1)]),_:1}),e.createVNode(e.unref(F.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{"data-testid":"cancel-button",onClick:f},{default:e.withCtx(()=>[...g[1]||(g[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(F.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(xc,{modelValue:i.value,"onUpdate:modelValue":g[0]||(g[0]=w=>i.value=w),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(F.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...g[2]||(g[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(F.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!l.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Ec=Ne(hE,[["__scopeId","data-v-21676ec1"]]),vE={class:"ion-padding-start text-sm"},gE={class:"ion-padding-start text-sm"},yE={key:1},wE={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},bE={class:"flex items-center justify-between gap-3 pb-3"},kE={class:"text-base font-semibold text-gray-900"},xE={class:"ion-padding-start text-sm"},EE={class:"ion-padding-start text-sm"},VE={class:"flex justify-between pt-2"},SE={key:1},Hn=255,Gn=1e3,CE=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=La(),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),f=e.ref(!1),p=e.ref(null),h=e.ref(!1),g=e.ref(!1),w=e.computed(()=>d.value.name?l.value.name.trim()?l.value.name.length>Hn?`Name must be ${Hn} characters or less`:null:"Name is required":null),E=e.computed(()=>d.value.description&&l.value.description.length>Gn?`Description must be ${Gn} characters or less`:null),M=e.computed(()=>{const j=l.value.name.trim().length>0,P=l.value.name.length<=Hn,T=l.value.description.length<=Gn;return j&&P&&T&&!h.value}),V=e.computed(()=>{var j;return((j=u.value)==null?void 0:j.name)??"None (Root)"}),y=e.computed(()=>p.value?p.value.children_count===0&&p.value.media_count===0:!1),m=e.computed(()=>p.value?p.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":p.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${p.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await b()});async function b(){if(t.albumId)try{const j=await i.fetchAlbum(t.albumId);p.value=j,l.value={name:j.name,description:j.description??"",parent_id:j.parent_id},j.parent_id&&(u.value={id:j.parent_id,name:"Parent Album"})}catch(j){o("error",j)}}function R(){d.value.name=!0}function N(){d.value.description=!0}function v(){f.value=!0}function C(j){u.value={id:j.id,name:j.name},l.value.parent_id=j.id,f.value=!1}function O(){f.value=!1}function x(){o("close")}function _(){o("close")}async function I(){if(d.value.name=!0,d.value.description=!0,!(!M.value||h.value)){h.value=!0;try{const j={name:l.value.name.trim(),description:l.value.description.trim(),parent_id:l.value.parent_id};if(r.value&&t.albumId){const P=await i.updateAlbum(t.albumId,j);o("updated",P)}else{const P=await i.createAlbum(j);o("created",P)}o("close")}catch(j){o("error",j)}finally{h.value=!1}}}function U(){y.value&&(g.value=!0)}async function $(j){var T;if((((T=j.detail)==null?void 0:T.role)??"")!=="confirm"){g.value=!1;return}if(t.albumId){h.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(L){o("error",L)}finally{h.value=!1,g.value=!1}}}return(j,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[j.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(F.IonModal),{key:0,"is-open":j.isOpen,class:"album-manager-modal",onDidDismiss:_},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(F.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:x},{default:e.withCtx(()=>[...P[4]||(P[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(F.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(I,["prevent"])},[e.createVNode(e.unref(F.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...P[5]||(P[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(F.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":P[0]||(P[0]=T=>l.value.name=T),"data-testid":"name-input",maxlength:Hn,onIonBlur:R},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(F.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",vE,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...P[6]||(P[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(F.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":P[1]||(P[1]=T=>l.value.description=T),"data-testid":"description-input",maxlength:Gn,onIonBlur:N},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(F.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",gE,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonItem),{button:"","data-testid":"parent-selector",onClick:v},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...P[7]||(P[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(F.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(V.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(F.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!y.value,title:y.value?void 0:m.value,onClick:U},{default:e.withCtx(()=>[...P[8]||(P[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(F.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(F.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",yE,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",wE,[e.createElementVNode("div",bE,[e.createElementVNode("h2",kE,e.toDisplayString(s.value),1),e.createVNode(e.unref(F.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:x},{default:e.withCtx(()=>[...P[9]||(P[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(I,["prevent"])},[e.createVNode(e.unref(F.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...P[10]||(P[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(F.IonInput),{modelValue:l.value.name,"onUpdate:modelValue":P[2]||(P[2]=T=>l.value.name=T),"data-testid":"name-input",maxlength:Hn,onIonBlur:R},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(F.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",xE,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...P[11]||(P[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(F.IonTextarea),{modelValue:l.value.description,"onUpdate:modelValue":P[3]||(P[3]=T=>l.value.description=T),"data-testid":"description-input",maxlength:Gn,onIonBlur:N},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(F.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",EE,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonItem),{button:"","data-testid":"parent-selector",onClick:v},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonLabel),null,{default:e.withCtx(()=>[...P[12]||(P[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(F.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(V.value),1)]),_:1})]),_:1}),e.createElementVNode("div",VE,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(F.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!y.value,title:y.value?void 0:m.value,onClick:U},{default:e.withCtx(()=>[...P[13]||(P[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(F.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(F.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",SE,e.toDisplayString(c.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Ec,{"is-open":f.value,"selected-album-id":l.value.parent_id,title:"Select Parent Album",onClose:O,onConfirm:C},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(F.IonAlert),{"is-open":g.value,header:"Delete Album?",message:m.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:$},null,8,["is-open","message"])],64))}}),NE=Ne(CE,[["__scopeId","data-v-22083f3a"]]),TE={class:"album-media-grid"},_E={class:"aspect-square"},ME={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},BE={class:"text-gray-500"},IE=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],FE={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},RE={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},$E={class:"aspect-square relative"},DE=["src","alt"],UE={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},OE=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=La(),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),f=e.computed(()=>!u.value&&r.value.length===0),p=e.computed(()=>{const _=t.columns;return["grid","gap-4",`grid-cols-${_.mobile??2}`,`sm:grid-cols-${_.sm??3}`,`md:grid-cols-${_.md??4}`,`lg:grid-cols-${_.lg??5}`,`xl:grid-cols-${_.xl??6}`]}),h=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await g()}),e.watch(()=>t.albumId,async()=>{await g()});async function g(){s.value=!0;try{const _=await i.fetchAlbumMedia(t.albumId);r.value=_}catch{r.value=[]}finally{s.value=!1}}function w(_){return t.selectedItems.includes(_)}function E(_){o("toggle-select",_);const I=w(_.uuid)?t.selectedItems.filter(U=>U!==_.uuid):[...t.selectedItems,_.uuid];o("selection-change",I)}function M(_){if(_.conversions&&typeof _.conversions=="object"){const I=_.conversions.thumb;if(typeof I=="string")return I}return _.original_url}function V(_){c.value=_}function y(){c.value=null}function m(_){o("preview",_)}function b(_){o("edit",_)}function R(_){o("detach",_.uuid)}function N(){o("add")}function v(_,I){t.reorderable&&(l.value=I,_.dataTransfer&&(_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",String(I))))}function C(_,I){!t.reorderable||l.value===null||(_.preventDefault(),d.value=I)}function O(_,I){if(!t.reorderable||l.value===null)return;_.preventDefault();const U=l.value;if(U!==I){const $=[...r.value],[j]=$.splice(U,1);$.splice(I,0,j),r.value=$;const P=$.map(T=>T.uuid);o("reorder",P),i.reorderAlbumMedia(t.albumId,P).catch(()=>{g()})}l.value=null,d.value=null}function x(){l.value=null,d.value=null}return(_,I)=>(e.openBlock(),e.createElementBlock("div",TE,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,U=>(e.openBlock(),e.createBlock(e.unref(F.IonCard),{key:U,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",_E,[e.createVNode(e.unref(F.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",ME,[e.createVNode(e.unref(F.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",BE,e.toDisplayString(_.emptyText),1),e.createVNode(e.unref(F.IonButton),{"data-testid":"add-media-btn",onClick:N},{default:e.withCtx(()=>[...I[0]||(I[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(p.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:_.reorderable,onDragstart:j=>v(j,$),onDragover:j=>C(j,$),onDrop:j=>O(j,$),onDragend:x,onMouseenter:j=>V(U.uuid),onMouseleave:y},[d.value===$&&l.value!==$&&_.reorderable?(e.openBlock(),e.createElementBlock("div",FE)):e.createCommentVNode("",!0),_.reorderable?(e.openBlock(),e.createElementBlock("div",RE,[e.createVNode(e.unref(F.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),_.selectionMode?(e.openBlock(),e.createBlock(e.unref(F.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:w(U.uuid),class:"absolute top-2 left-2 z-20",onIonChange:j=>E(U)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(F.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",$E,[e.createElementVNode("img",{src:M(U),alt:U.file_name,class:"w-full h-full object-cover"},null,8,DE),_.showActions&&c.value===U.uuid?(e.openBlock(),e.createElementBlock("div",UE,[e.createVNode(e.unref(F.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:j=>m(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(F.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:j=>b(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(F.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:j=>R(U)},{default:e.withCtx(()=>[e.createVNode(e.unref(F.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,IE))),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:N},[e.createVNode(e.unref(F.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),I[1]||(I[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),LE=Ne(OE,[["__scopeId","data-v-d84b796a"]]);function ir(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 $i(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 rr(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),Mn(t)}return{name:"mediables",async upload(t,o){const r=await wt().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 wt().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await wt().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await wt().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await wt().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await wt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return wt().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 wt().deleteMedia(t)},async update(t,o){const r=await wt().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),Mn(o)}}}let ea=null;function AE(){return ea||(ea=rr()),ea}function zE(){ea=null}const PE={apiBaseUrl:"/media-library-pro"};function Wo(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function pi(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={...PE,...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||Wo();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 p=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(p.message||`HTTP ${d.status}`)}const u=await d.json(),f=pi(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:f,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||Wo();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(pi)}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||Wo();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||Wo();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 pi(l)},configure(o){Object.assign(n,o)}}}let ta=null;function WE(){return ta||(ta=sr()),ta}function jE(){ta=null}function Vc(a,n){switch(a){case"mediables":return rr(n);case"spatie":return sr(n);default:throw new Error(`Unknown adapter: ${a}`)}}function pa(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 lr(a){return a.type.startsWith("image/")}async function Cc(a){return lr(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 ${pa(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${pa(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(lr(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 cr(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 f=await o(u);d.set(u,f)})),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 ZE(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function XE(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function Tc(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),f=e.ref(new Set),p=o?{rules:o}:{},{validateFile:h}=cr(p);async function g(){if(f.value.size>=t)return;const x=Array.from(u.value.entries()).find(([U,$])=>$.status==="pending"&&!f.value.has(U));if(!x){Array.from(u.value.values()).every($=>$.status==="completed"||$.status==="error")&&u.value.size>0&&(d==null||d());return}const[_,I]=x;await w(_,I)}async function w(x,_){f.value.add(x),_.status="uploading",_.abortController=new AbortController,u.value.set(x,{..._}),r==null||r(_);try{const I={onProgress:$=>{_.progress=$,u.value.set(x,{..._}),s==null||s(_)},signal:_.abortController.signal};i&&(I.collection=i);const U=await n.upload(_.file,I);_.status="completed",_.progress=100,_.media=U.media,u.value.set(x,{..._}),c==null||c(_,U.media)}catch(I){I.name==="AbortError"?u.value.delete(x):(_.status="error",_.error=I.message,u.value.set(x,{..._}),l==null||l(_,I))}finally{f.value.delete(x),delete _.abortController,g()}}async function E(x){var U;const _=Array.from(x),I=[];for(const $ of _){const j=await h($),P=ZE(),T=XE($),L={id:P,file:$,progress:0,status:j.valid?"pending":"error"};!j.valid&&((U=j.errors[0])!=null&&U.message)&&(L.error=j.errors[0].message),T&&(L.previewUrl=T),u.value.set(P,L);const G={media:null,clientId:P,name:$.name,order:0,upload:L,errors:j.errors};I.push(G)}for(let $=0;$<t;$++)g();return I}function M(x){const _=u.value.get(x);_&&(_.abortController&&_.abortController.abort(),_.previewUrl&&URL.revokeObjectURL(_.previewUrl),u.value.delete(x),f.value.delete(x),g())}async function V(x){const _=u.value.get(x);!_||_.status!=="error"||(_.status="pending",_.progress=0,delete _.error,u.value.set(x,{..._}),g())}function y(){for(const[x,_]of u.value.entries())(_.status==="completed"||_.status==="error")&&(_.previewUrl&&URL.revokeObjectURL(_.previewUrl),u.value.delete(x))}function m(){for(const x of u.value.values())x.abortController&&x.abortController.abort(),x.previewUrl&&URL.revokeObjectURL(x.previewUrl);u.value.clear(),f.value.clear()}function b(x){return u.value.get(x)}const R=e.computed(()=>f.value.size>0),N=e.computed(()=>f.value.size),v=e.computed(()=>Array.from(u.value.values()).filter(x=>x.status==="pending").length),C=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(x=>x.status==="completed"||x.status==="error")),O=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:R,activeCount:N,pendingCount:v,isComplete:C,addFiles:E,cancelUpload:M,retryUpload:V,clearCompleted:y,clearAll:m,getUpload:b,uploadsArray:O}}function _c(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(V,y,m){n&&("dataTransfer"in V&&V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",String(m))),d=V.target,d&&d.classList.add(r),c.value={isDragging:!0,dragIndex:m,dropIndex:m,draggedItem:y},l.value=!0,o==null||o(y,m))}function f(V,y){var m;if(!(!n||!c.value.isDragging)&&(V.preventDefault(),c.value.dropIndex!==y)){const b=document.querySelector(`.${s}`);b==null||b.classList.remove(s);const R=(m=V.target)==null?void 0:m.closest("[data-index]");R==null||R.classList.add(s),c.value.dropIndex=y}}function p(){if(!c.value.isDragging)return;const{dragIndex:V,dropIndex:y,draggedItem:m}=c.value;d&&d.classList.remove(r);const b=document.querySelector(`.${s}`);b==null||b.classList.remove(s),V!==null&&y!==null&&V!==y&&m&&(t==null||t({fromIndex:V,toIndex:y,item:m})),g(),i==null||i()}function h(){d&&d.classList.remove(r);const V=document.querySelector(`.${s}`);V==null||V.classList.remove(s),g(),i==null||i()}function g(){c.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},l.value=!1,d=null}function w(V,y,m){const b=[...V],[R]=b.splice(y,1);return b.splice(m,0,R),b.map((N,v)=>({...N,order:v}))}function E(V,y){return{draggable:n,"data-index":y,onDragstart:m=>u(m,V,y),onDragover:m=>f(m,y),onDragend:()=>p(),onDrop:m=>{m.preventDefault(),p()}}}function M(V){V.key==="Escape"&&c.value.isDragging&&h()}return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onUnmounted(()=>{document.removeEventListener("keydown",M),h()}),{dragState:c,isDragging:l,startDrag:u,handleDragOver:f,endDrag:p,cancelDrag:h,reorderItems:w,getDragProps:E}}function Aa(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:f="mediables",adapter:p,maxConcurrentUploads:h=3,onChange:g,onUpload:w,onUploadComplete:E,onUploadError:M,onRemove:V,onReorder:y,onError:m,onReadyToSubmitChange:b}=a,R={maxItems:r,maxFileSize:s,acceptedMimeTypes:c,...u},N=p||Vc(f),v=e.ref([]),C=e.ref(!1),O=e.ref([]);function x(ne){if(ne.length===0)return[];const ke=ne[0];return"media"in ke&&"clientId"in ke?ne:$i(ne)}v.value=x(n);const{acceptString:_,canAddFiles:I}=cr({rules:R}),U=Tc({adapter:N,maxConcurrent:h,rules:R,collection:i,onUploadStart:ne=>{w==null||w(ne)},onUploadComplete:(ne,ke)=>{const he=v.value.findIndex(Je=>Je.clientId===ne.id);he!==-1&&(v.value[he]={...v.value[he],media:ke,name:ke.name||ke.file_name,upload:{...ne,status:"completed"}}),E==null||E(ke)},onUploadError:(ne,ke)=>{const he=v.value.findIndex(Je=>Je.clientId===ne.id);he!==-1&&(v.value[he]={...v.value[he],upload:{...ne,status:"error",error:ke.message},errors:[{field:"upload",message:ke.message,code:"UPLOAD_ERROR"}]}),M==null||M({file:ne.file,message:ke.message})},onQueueComplete:()=>{g==null||g(v.value)}}),{dragState:$,getDragProps:j,reorderItems:P}=_c({enabled:l&&!d,onReorder:ne=>{v.value=P(v.value,ne.fromIndex,ne.toIndex),y==null||y(v.value),g==null||g(v.value)}}),T=e.computed(()=>U.isUploading.value),L=e.computed(()=>!U.isUploading.value&&U.pendingCount.value===0),G=e.computed(()=>r?v.value.length>=r:!1),Z=e.computed(()=>ir(v.value)),ce=e.computed(()=>v.value.length),_e=e.computed(()=>r?Math.max(0,r-v.value.length):1/0);e.watch(L,ne=>{b==null||b(ne)});function Re(ne){v.value=x(ne),g==null||g(v.value)}async function ae(ne){if(d)return;const ke=Array.from(ne);if(!I(ke.length,v.value.length)){const mt={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};O.value=[mt],m==null||m([mt]);return}const he=await U.addFiles(ke),Je=v.value.length,lt=he.map((mt,me)=>({...mt,order:Je+me}));v.value=[...v.value,...lt],g==null||g(v.value)}function B(ne){d||(ne.upload&&(ne.upload.status==="uploading"||ne.upload.status==="pending")&&U.cancelUpload(ne.clientId),v.value=v.value.filter(ke=>ke.clientId!==ne.clientId),v.value=v.value.map((ke,he)=>({...ke,order:he})),V==null||V(ne),g==null||g(v.value))}function z(ne){const ke=v.value.find(he=>he.clientId===ne);ke&&B(ke)}function de(){d||(U.clearAll(),v.value=[],g==null||g(v.value))}function ie(ne,ke){d||!l||(v.value=P(v.value,ne,ke),y==null||y(v.value),g==null||g(v.value))}function K(ne,ke){if(d)return;const he=v.value.findIndex(Je=>Je.clientId===ne);he!==-1&&(v.value[he]={...v.value[he],...ke},g==null||g(v.value))}function ee(ne){U.cancelUpload(ne),z(ne)}async function ue(ne){await U.retryUpload(ne)}async function ge(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const ne={modelType:t,modelId:o,collection:i},ke=v.value.filter(he=>he.media&&!he.markedForRemoval).map(he=>he.media.uuid);C.value=!0;try{await N.attachMany(ke,ne),await N.reorder(ne,ke)}finally{C.value=!1}}async function xe(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const ne={modelType:t,modelId:o,collection:i};C.value=!0;try{const ke=await N.fetchModelMedia(ne);v.value=$i(ke),g==null||g(v.value)}finally{C.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&xe().catch(console.error)}),e.onUnmounted(()=>{U.clearAll()}),{items:v,setItems:Re,addFiles:ae,removeItem:B,removeItemById:z,clearAll:de,reorderItems:ie,updateItem:K,cancelUpload:ee,retryUpload:ue,save:ge,load:xe,isLoading:C,isUploading:T,isReadyToSubmit:L,isAtMaxItems:G,errors:O,dragState:$,getDragProps:j,adapter:N,formValues:Z,acceptString:_,count:ce,remainingSlots:_e}}const HE=["aria-disabled"],GE=["accept","multiple","disabled"],JE={class:"media-dropzone__content"},YE={class:"media-dropzone__title"},KE={class:"media-dropzone__subtitle"},qE=["disabled"],QE={key:0,class:"media-dropzone__helper"},e4=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 w=[];return t.maxFileSize&&w.push(`Max size: ${pa(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&w.push(`Max files: ${t.maxItems}`),w.join(" • ")});function l(w){w.preventDefault(),!t.disabled&&(i.value=!0)}function d(w){w.preventDefault(),i.value=!1}function u(w){w.preventDefault()}function f(w){var M;if(w.preventDefault(),i.value=!1,t.disabled)return;const E=(M=w.dataTransfer)==null?void 0:M.files;E&&E.length>0&&o("files",E)}function p(){var w;t.disabled||(w=r.value)==null||w.click()}function h(w){const E=w.target,M=E.files;M&&M.length>0&&o("files",M),E.value=""}function g(w){(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),p())}return(w,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":w.disabled,"aria-label":"Upload files",onClick:p,onKeydown:g,onDragenter:l,onDragleave:d,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:w.accept,multiple:w.multiple,disabled:w.disabled,class:"media-dropzone__input",onChange:h},null,40,GE),e.createElementVNode("div",JE,[e.renderSlot(w.$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",YE,[e.renderSlot(w.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(w.title),1)],!0)]),e.createElementVNode("p",KE,[e.renderSlot(w.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(w.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:w.disabled,onClick:e.withModifiers(p,["stop"])},[e.renderSlot(w.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(w.buttonText),1)],!0)],8,qE),c.value?(e.openBlock(),e.createElementBlock("p",QE,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])],42,HE))}}),dr=Ne(e4,[["__scopeId","data-v-b1366c1e"]]),t4=["data-index"],n4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},o4={class:"media-item__thumbnail"},a4=["src","alt"],i4={key:1,class:"media-item__file-icon"},r4={key:2,class:"media-item__progress-overlay"},s4={class:"media-item__progress-text"},l4={key:3,class:"media-item__processing-overlay"},c4={key:4,class:"media-item__error-overlay"},d4={class:"media-item__info"},u4=["title"],m4={key:0,class:"media-item__size"},p4={key:1,class:"media-item__error-message"},f4={class:"media-item__actions"},h4=["disabled"],v4=["disabled"],g4=["disabled"],y4=["disabled"],w4=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 y;return(y=t.item.upload)!=null&&y.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var y,m,b;return((y=t.item.upload)==null?void 0:y.status)==="uploading"||((m=t.item.upload)==null?void 0:m.status)==="pending"||((b=t.item.upload)==null?void 0:b.status)==="queued"}),c=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="processing"}),l=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var y;return(y=t.item.upload)!=null&&y.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.progress)||0}),f=e.computed(()=>{var y;return t.item.name||((y=t.item.media)==null?void 0:y.file_name)||"Unknown file"}),p=e.computed(()=>{var N,v;const y=((N=t.item.media)==null?void 0:N.size)||((v=t.item.upload)==null?void 0:v.file.size);if(!y)return"";const m=1024,b=["Bytes","KB","MB","GB"],R=Math.floor(Math.log(y)/Math.log(m));return parseFloat((y/Math.pow(m,R)).toFixed(2))+" "+b[R]}),h=e.computed(()=>{var m,b;const y=((m=t.item.media)==null?void 0:m.mime_type)||((b=t.item.upload)==null?void 0:b.file.type);return y==null?void 0:y.startsWith("image/")}),g=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 w(){t.disabled||o("remove",t.item)}function E(){t.disabled||o("edit",t.item)}function M(){t.disabled||o("retry",t.item)}function V(){t.disabled||o("cancel",t.item)}return(y,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(g.value),"data-index":y.index,onMouseenter:m[0]||(m[0]=b=>i.value=!0),onMouseleave:m[1]||(m[1]=b=>i.value=!1)},[y.sortable&&!y.disabled?(e.openBlock(),e.createElementBlock("div",n4,[...m[2]||(m[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",o4,[r.value&&h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:f.value,class:"media-item__image"},null,8,a4)):(e.openBlock(),e.createElementBlock("div",i4,[...m[3]||(m[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",r4,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",s4,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",l4,[...m[4]||(m[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",c4,[...m[5]||(m[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",d4,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,u4),p.value?(e.openBlock(),e.createElementBlock("span",m4,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",p4,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",f4,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:y.disabled,"aria-label":"Cancel upload",onClick:V},[...m[6]||(m[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,h4)):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:y.disabled,"aria-label":"Retry upload",onClick:M},[...m[7]||(m[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,v4)):e.createCommentVNode("",!0),y.showEdit&&y.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:y.disabled,"aria-label":"Edit",onClick:E},[...m[8]||(m[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,g4)):e.createCommentVNode("",!0),y.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:y.disabled,"aria-label":"Remove",onClick:w},[...m[9]||(m[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,y4)):e.createCommentVNode("",!0)])],42,t4))}}),ur=Ne(w4,[["__scopeId","data-v-ff81c9ec"]]),b4=["aria-label"],k4=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],x4={key:0,class:"media-collection__footer"},E4={class:"media-collection__count"},V4={key:0},S4={key:0,class:"media-collection__uploading"},C4=["name","value"],N4=["name","value"],T4=["name","value"],_4=["name","value"],M4={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},B4=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:T=>{o("update:modelValue",T),o("change",T)},onUpload:T=>{o("upload",T)},onUploadComplete:T=>{o("upload-complete",T)},onUploadError:T=>{o("upload-error",T)},onRemove:T=>{o("remove",T)},onReorder:T=>{o("reorder",T)},onError:T=>{o("validation-error",T)},onReadyToSubmitChange:T=>{o("is-ready-to-submit-change",T)}},{items:r,setItems:s,addFiles:c,removeItem:l,reorderItems:d,cancelUpload:u,retryUpload:f,isLoading:p,isUploading:h,isAtMaxItems:g,errors:w,dragState:E,getDragProps:M,adapter:V,formValues:y,acceptString:m,count:b,remainingSlots:R}=Aa(i);e.provide("mediaAdapter",V),e.provide("mediaCollection",{items:r,addFiles:c,removeItem:l,reorderItems:d}),e.watch(()=>t.modelValue,T=>{T!==r.value&&s(T)},{deep:!0});const N=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!g.value),v=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":p.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":E.value.isDragging}));function C(T){c(T)}function O(T){l(T)}function x(T){f(T.clientId)}function _(T){u(T.clientId)}function I(T){}function U(T,L,G){if(!t.sortable||t.disabled)return;const Z=M(L,G);Z.onDragstart&&Z.onDragstart(T)}function $(T,L){if(!t.sortable||t.disabled)return;T.preventDefault();const G=r.value[L],Z=M(G,L);Z.onDragover&&Z.onDragover(T)}function j(T,L){const G=M(T,L);G.onDragend&&G.onDragend()}function P(T,L){T.preventDefault();const G=r.value[L],Z=M(G,L);Z.onDrop&&Z.onDrop(T)}return(T,L)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value)},[e.renderSlot(T.$slots,"dropzone",{addFiles:e.unref(c)},()=>[N.value?(e.openBlock(),e.createBlock(dr,{key:0,accept:e.unref(m),multiple:T.maxItems!==1,disabled:T.disabled,"max-file-size":T.maxFileSize,"max-items":e.unref(R),onFiles:C},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(b)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(G,Z)=>e.renderSlot(T.$slots,"item",{key:G.clientId,item:G,index:Z,remove:()=>O(G)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(E).dropIndex===Z}]),draggable:T.sortable&&!T.disabled,"data-index":Z,onDragstart:ce=>U(ce,G,Z),onDragover:ce=>$(ce,Z),onDragend:ce=>j(G,Z),onDrop:ce=>P(ce,Z)},[e.createVNode(ur,{item:G,adapter:e.unref(V),disabled:T.disabled,sortable:T.sortable,"show-remove":!T.readonly,"show-edit":!1,index:Z,onRemove:O,onRetry:x,onCancel:_,onEdit:I},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,k4)],!0)),128))],8,b4)):N.value?e.createCommentVNode("",!0):e.renderSlot(T.$slots,"empty",{key:1},()=>[L[0]||(L[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(T.$slots,"footer",{count:e.unref(b),isUploading:e.unref(h)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",x4,[e.createElementVNode("span",E4,[e.createTextVNode(e.toDisplayString(e.unref(b))+" "+e.toDisplayString(e.unref(b)===1?"file":"files")+" ",1),T.maxItems?(e.openBlock(),e.createElementBlock("span",V4," / "+e.toDisplayString(T.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(h)?(e.openBlock(),e.createElementBlock("span",S4," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),T.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${T.name}-${G.uuid}`,type:"hidden",name:`${T.name}[${Z}][uuid]`,value:G.uuid},null,8,C4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${T.name}-${G.uuid}-name`,type:"hidden",name:`${T.name}[${Z}][name]`,value:G.name},null,8,N4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${T.name}-${G.uuid}-order`,type:"hidden",name:`${T.name}[${Z}][order]`,value:G.order},null,8,T4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,Z)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${T.name}-${G.uuid}-props`},[G.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${T.name}[${Z}][custom_properties]`,value:JSON.stringify(G.custom_properties)},null,8,_4)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(w).length>0?(e.openBlock(),e.createElementBlock("div",M4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),G=>(e.openBlock(),e.createElementBlock("p",{key:G.code||G.message,class:"media-collection__error"},e.toDisplayString(G.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),I4=Ne(B4,[["__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,p={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:N=>{t==null||t(N[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:c,onError:l,onReadyToSubmitChange:d},h=Aa(p),g=e.computed(()=>h.items.value[0]||null),w=e.computed(()=>g.value!==null),E=e.computed(()=>h.formValues.value[0]||null);function M(N){N===null?h.clearAll():h.setItems([N])}async function V(N){const v=g.value;v&&h.removeItem(v),await h.addFiles([N])}function y(){g.value&&h.removeItem(g.value)}async function m(N){const v=g.value;v&&h.removeItem(v),await h.addFiles([N]);const C=h.items.value[0];C&&(o==null||o(v,C))}function b(){var N;(N=g.value)!=null&&N.upload&&h.cancelUpload(g.value.clientId)}async function R(){var N,v;((v=(N=g.value)==null?void 0:N.upload)==null?void 0:v.status)==="error"&&await h.retryUpload(g.value.clientId)}return{item:g,setItem:M,addFile:V,removeItem:y,replaceItem:m,cancelUpload:b,retryUpload:R,save:h.save,load:h.load,isLoading:h.isLoading,isUploading:h.isUploading,isReadyToSubmit:h.isReadyToSubmit,hasItem:w,errors:h.errors,adapter:h.adapter,formValue:E,acceptString:h.acceptString}}const F4=["accept","disabled"],R4={class:"media-attachment__preview"},$4=["name","value"],D4=["name","value"],U4=["name","value"],O4=["name","value"],L4={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},A4=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:x=>{o("update:modelValue",x),o("change",x)},onUpload:x=>{o("upload",x)},onUploadComplete:x=>{o("upload-complete",x)},onUploadError:x=>{o("upload-error",x)},onRemove:x=>{o("remove",x)},onReplace:(x,_)=>{o("replace",_)},onError:x=>{o("validation-error",x)},onReadyToSubmitChange:x=>{o("is-ready-to-submit-change",x)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:h,hasItem:g,errors:w,adapter:E,formValue:M,acceptString:V}=mr(r);e.provide("mediaAdapter",E),e.watch(()=>t.modelValue,x=>{x!==s.value&&c(x)},{deep:!0});const y=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!g.value),m=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":h.value,"media-attachment--has-item":g.value}));function b(x){x.length>0&&l(x[0])}function R(){var x;(x=i.value)==null||x.click()}function N(x){const _=x.target,I=_.files;I&&I.length>0&&u(I[0]),_.value=""}function v(x){d()}function C(x){p()}function O(x){f()}return(x,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(m.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(V),disabled:x.disabled,class:"media-attachment__hidden-input",onChange:N},null,40,F4),y.value?e.renderSlot(x.$slots,"dropzone",{key:0,addFile:e.unref(l)},()=>[e.createVNode(dr,{accept:e.unref(V),multiple:!1,disabled:x.disabled,"max-file-size":x.maxFileSize,onFiles:b},null,8,["accept","disabled","max-file-size"])],!0):e.unref(g)&&e.unref(s)?e.renderSlot(x.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:R},()=>[e.createElementVNode("div",R4,[e.createVNode(ur,{item:e.unref(s),adapter:e.unref(E),disabled:x.disabled,sortable:!1,"show-remove":!x.readonly,"show-edit":!1,onRemove:v,onRetry:C,onCancel:O},null,8,["item","adapter","disabled","show-remove"]),x.showReplaceButton&&!x.readonly&&!x.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:R},[..._[0]||(_[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(x.$slots,"empty",{key:2},()=>[_[1]||(_[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),x.generateFormFields&&e.unref(M)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${x.name}[uuid]`,value:e.unref(M).uuid},null,8,$4),e.createElementVNode("input",{type:"hidden",name:`${x.name}[name]`,value:e.unref(M).name},null,8,D4),e.createElementVNode("input",{type:"hidden",name:`${x.name}[order]`,value:e.unref(M).order},null,8,U4),e.unref(M).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${x.name}[custom_properties]`,value:JSON.stringify(e.unref(M).custom_properties)},null,8,O4)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(w).length>0?(e.openBlock(),e.createElementBlock("div",L4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),I=>(e.openBlock(),e.createElementBlock("p",{key:I.code||I.message,class:"media-attachment__error"},e.toDisplayString(I.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),z4=Ne(A4,[["__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"}},P4=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:x=>{i("update:modelValue",x),i("change",x)},onUpload:x=>{i("upload",x)},onUploadComplete:x=>{i("upload-complete",x)},onUploadError:x=>{i("upload-error",x)},onRemove:x=>{i("remove",x)},onReorder:x=>{i("reorder",x)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{items:s,setItems:c,addFiles:l,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:h,isLoading:g,isUploading:w,isReadyToSubmit:E,isAtMaxItems:M,errors:V,dragState:y,getDragProps:m,adapter:b,formValues:R,acceptString:N}=Aa(r);e.provide("mediaAdapter",b),e.provide("mediaCollection",{items:s,addFiles:l,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,x=>{x!==s.value&&c(x)},{deep:!0});const v=e.computed(()=>({...Mc,...o.labels})),C=e.computed(()=>({accept:N.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||M.value})),O=e.computed(()=>({items:s.value,isLoading:g.value,isUploading:w.value,isReadyToSubmit:E.value,isAtMaxItems:M.value,errors:V.value,addFiles:l,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(x=>d(x))},cancelUpload:p,retryUpload:h,labels:v.value,dropzoneProps:C.value}));return n({items:s,addFiles:l,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:h,isLoading:g,isUploading:w,isReadyToSubmit:E,isAtMaxItems:M,errors:V,dragState:y,getDragProps:m,adapter:b,formValues:R,acceptString:N}),(x,_)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(O.value)))}}),W4=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:v=>{i("update:modelValue",v),i("change",v)},onUpload:v=>{i("upload",v)},onUploadComplete:v=>{i("upload-complete",v)},onUploadError:v=>{i("upload-error",v)},onRemove:v=>{i("remove",v)},onReplace:(v,C)=>{i("replace",C)},onError:v=>{i("validation-error",v)},onReadyToSubmitChange:v=>{i("is-ready-to-submit-change",v)}},{item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:h,isUploading:g,isReadyToSubmit:w,hasItem:E,errors:M,adapter:V,formValue:y,acceptString:m}=mr(r);e.provide("mediaAdapter",V),e.watch(()=>o.modelValue,v=>{v!==s.value&&c(v)},{deep:!0});const b=e.computed(()=>({...Mc,...o.labels})),R=e.computed(()=>({accept:m.value,multiple:!1,disabled:o.disabled||o.readonly||E.value})),N=e.computed(()=>({item:s.value,hasItem:E.value,isLoading:h.value,isUploading:g.value,isReadyToSubmit:w.value,errors:M.value,addFile:l,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,labels:b.value,dropzoneProps:R.value}));return n({item:s,setItem:c,addFile:l,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:h,isUploading:g,isReadyToSubmit:w,hasItem:E,errors:M,adapter:V,formValue:y,acceptString:m}),(v,C)=>e.renderSlot(v.$slots,"default",e.normalizeProps(e.guardReactiveProps(N.value)))}}),j4=["name","value"],Z4=["name","value"],X4=["name","value"],H4=["name","value"],G4=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(()=>ir(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,j4),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,Z4),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,X4),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,H4)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=Ec;exports.AlbumManager=NE;exports.AlbumMediaGrid=LE;exports.AlbumTree=xc;exports.ArrayBufferTarget=zi;exports.ImageEditor=ol;exports.ImageEditorModal=al;exports.LiveStreamManager=eE;exports.ManagedMediaGallery=Dd;exports.MediaAttachment=z4;exports.MediaCollection=I4;exports.MediaCollectionDropzone=dr;exports.MediaCollectionItem=ur;exports.MediaWorkspace=Id;exports.ModelMediaManager=Fm;exports.Muxer=Tl;exports.VideoEditor=yc;exports.VideoEditorDialog=Uw;exports.VideoEditorSimple=s2;exports.VideoExportPanel=Ab;exports.VideoJobClient=ar;exports.VideoPlayer=wc;exports.VideoTimeline=B2;exports.VideoToolsPanel=bb;exports.VideoUploader=Nk;exports._sfc_main=P4;exports._sfc_main$1=W4;exports._sfc_main$2=G4;exports.applyTemporaryMediaStoreConfig=tl;exports.configureMediaStore=Mn;exports.createAdapter=Vc;exports.createMediablesAdapter=rr;exports.createSpatieAdapter=sr;exports.formatFileSize=pa;exports.fromMediaArray=$i;exports.getFileExtension=Sc;exports.getImageDimensions=Cc;exports.getMediablesAdapter=AE;exports.getSpatieAdapter=WE;exports.isImageFile=lr;exports.resetMediablesAdapter=zE;exports.resetSpatieAdapter=jE;exports.restoreMediaStoreConfig=el;exports.snapshotMediaStoreConfig=Qs;exports.toFormValues=ir;exports.useAdminMediaStore=nl;exports.useAlbumDragDrop=kc;exports.useAlbumStore=La;exports.useAlbums=bc;exports.useMediaAttachment=mr;exports.useMediaCollection=Aa;exports.useMediaDragSort=_c;exports.useMediaStore=wt;exports.useMediaUploadQueue=Tc;exports.useMediaValidation=cr;exports.validateFile=Nc;
|
|
39
|
-
//# sourceMappingURL=index-Du0vZ5BO.cjs.map
|