@codingfactory/mediables-vue 2.5.0 → 2.6.1
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-BrsHCMHb.cjs → PixiFrameExporter-CetwQ3WI.cjs} +2 -2
- package/dist/{PixiFrameExporter-BrsHCMHb.cjs.map → PixiFrameExporter-CetwQ3WI.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-DFq2mc-y.js → PixiFrameExporter-DFchWLl5.js} +2 -2
- package/dist/{PixiFrameExporter-DFq2mc-y.js.map → PixiFrameExporter-DFchWLl5.js.map} +1 -1
- package/dist/components/ImageEditor/ImageEditor.vue.d.ts +1 -0
- package/dist/components/ImageEditorModal.vue.d.ts +2 -0
- package/dist/components/MediaManagementView.vue.d.ts +2 -0
- package/dist/composables/useFloatingPills.d.ts +4 -0
- package/dist/composables/useMediaDeletion.d.ts +66 -0
- package/dist/composables/useMediaTrash.d.ts +64 -0
- package/dist/editor-BTwIhrcA.cjs +2 -0
- package/dist/editor-BTwIhrcA.cjs.map +1 -0
- package/dist/{editor-2Q72CZjK.js → editor-CYj5y5bp.js} +1417 -1167
- package/dist/editor-CYj5y5bp.js.map +1 -0
- package/dist/filters/registry.d.ts +4 -0
- package/dist/{index-CaQc9GBh.js → index-DNgtg1bF.js} +12107 -10230
- package/dist/index-DNgtg1bF.js.map +1 -0
- package/dist/index-nQskCfGV.cjs +342 -0
- package/dist/index-nQskCfGV.cjs.map +1 -0
- package/dist/index.d.ts +6 -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 +69 -66
- package/dist/render-page/assets/{index-ZZVWF3LA.js → index-y90zwXpc.js} +713 -531
- package/dist/render-page/index.html +1 -1
- package/dist/style.css +1 -1
- package/dist/types/media.d.ts +26 -0
- package/dist/types/mediaLibraryPicker.d.ts +1 -0
- package/package.json +2 -2
- package/dist/editor-2Q72CZjK.js.map +0 -1
- package/dist/editor-DjvxEsss.cjs +0 -42
- package/dist/editor-DjvxEsss.cjs.map +0 -1
- package/dist/index-BTGCVCn6.cjs +0 -342
- package/dist/index-BTGCVCn6.cjs.map +0 -1
- package/dist/index-CaQc9GBh.js.map +0 -1
package/dist/index-BTGCVCn6.cjs
DELETED
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";var Yu=Object.defineProperty;var qu=(a,n,t)=>n in a?Yu(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var X=(a,n,t)=>qu(a,typeof n!="symbol"?n+"":n,t);const Aa=require("pinia"),e=require("vue"),ze=require("pixi.js"),dt=require("./editor-DjvxEsss.cjs"),L=require("@ionic/vue"),Ku=require("pixi-filters");function Qu(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Ye=Qu(ze),Qi=1,em=new Set(["free","square","circle"]);function tm(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function nm(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Er(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==Qi)return null;const t=n.crop,o=t&&nm(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&em.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,l=[];if(Array.isArray(s))for(const c of s){if(!c||typeof c!="object")continue;const d=c;if(typeof d.id!="string")continue;const u={},m=d.values;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[h,p]of Object.entries(m))tm(p)&&(u[h]=p);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:Qi,crop:{rect:o,aspectRatio:r,shape:i},filters:l}}function zl(a){const n=Er(a);return n?JSON.stringify(n):null}function om(a){try{const n=JSON.parse(a);return Er(n)}catch{return null}}function am(){return{version:Qi,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Nt={apiBaseUrl:"/api/v1",isAdmin:!1};function Zn(a){Nt={...Nt,...a}}function jl(){return{...Nt}}function Wl(a){Nt={...a}}function Zl(a){const n=jl();return Zn(a),()=>{Wl(n)}}const im=async(a,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.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 c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},_t=Aa.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),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),m=e.ref(new Map),h=e.ref(new Map),p=e.ref(new Set),y=e.ref(new Map),g=e.ref({}),x=5*60*1e3,M=e.computed(()=>{if(Nt.apiScope)return Nt.apiScope;if(Nt.isAdmin)return"admin"}),C=e.computed(()=>M.value==="admin");function b(){return Nt.httpClient||im}function f(ie){const me=Nt.apiBaseUrl||"/api/v1",we=M.value?`/${M.value}`:"";return`${me}${we}${ie}`}function w(ie,me){return`${M.value??"default"}-${ie}-${JSON.stringify(me)}`}function F(ie){return Date.now()-ie<x}function T(){y.value.clear(),g.value={}}function E(ie){if(!ie||!ie.data)return;const me={};ie.data.forEach(we=>{const ae=`${we.file_name}-${we.collection_name||"default"}`,le=me[ae];(!le||Object.keys(we.generated_conversions||{}).length>Object.keys(le.generated_conversions||{}).length)&&(me[ae]=we)}),a.value=Object.values(me),ie.meta&&(i.value=ie.meta.current_page,r.value=Math.ceil(ie.meta.total/ie.meta.per_page))}async function B(ie=1,me={}){const we=w(ie,me),ae=y.value.get(we);if(ae&&F(ae.timestamp)){const le=ae.data;return E(le),le}t.value=!0,o.value=null;try{const le=new URLSearchParams;le.append("page",ie.toString()),le.append("per_page",s.value.toString()),C.value&&le.append("linked","1");for(const ut in me)if(Object.prototype.hasOwnProperty.call(me,ut)){const Ze=me[ut];Ze!=null&&Ze!==""&&le.append(ut,String(Ze))}const _e=await b()(f(`/media?${le}`));return y.value.set(we,{data:_e,timestamp:Date.now()}),E(_e),_e}catch(le){throw o.value=le instanceof Error?le.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function U(ie,me){t.value=!0,o.value=null;const we=`${ie.name}-${Date.now()}`,ae={file:ie,progress:0,status:"uploading"};m.value.set(we,ae);try{const le=new FormData;le.append("file",ie),le.append("collection",me.collection),me.ownerUuid&&(le.append("owner_uuid",me.ownerUuid),le.append("owner_type",me.ownerType||"")),me.usageUuid&&(le.append("usage_uuid",me.usageUuid),le.append("usage_type",me.usageType||""),le.append("usage_purpose",me.usagePurpose||"")),me.customProperties&&le.append("custom_properties",JSON.stringify(me.customProperties));const _e=await b()(f("/media"),{method:"POST",body:le});return ae.status="completed",ae.progress=100,ae.media=_e==null?void 0:_e.data,i.value===1&&(_e!=null&&_e.data)&&(a.value=[_e.data,...a.value]),T(),(_e==null?void 0:_e.data)||null}catch(le){throw ae.status="error",ae.error=le instanceof Error?le.message:"Upload failed",o.value=ae.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(we)},5e3)}}async function S(ie){t.value=!0,o.value=null;const me=a.value.findIndex(ae=>ae.uuid===ie);let we;me!==-1&&(we=a.value.splice(me,1)[0]);try{return await b()(f(`/media/${ie}`),{method:"DELETE"}),p.value.delete(ie),T(),!0}catch(ae){throw we&&me!==-1&&a.value.splice(me,0,we),o.value=ae instanceof Error?ae.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function D(ie,me){t.value=!0,o.value=null;try{const ae=await b()(f(`/media/${ie}`),{method:"PATCH",body:me,data:me});if(ae!=null&&ae.data){const le=a.value.findIndex(ke=>ke.uuid===ie);return le!==-1&&(a.value[le]={...a.value[le],...ae.data}),T(),ae.data}return null}catch(we){throw o.value=we instanceof Error?we.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function I(){t.value=!0,o.value=null;try{const me=await b()(f("/media/collections"));return n.value=(me==null?void 0:me.data)||[],n.value}catch(ie){throw o.value=ie instanceof Error?ie.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function j(ie,me,we="images",ae){d.value=!0,u.value=null;try{const le=new URLSearchParams;le.append("collection",we),ae&&le.append("search",ae);const _e=await b()(f(`/media/model/${ie}/${me}?${le}`));return _e!=null&&_e.data?(c.value=_e.data,_e.data):[]}catch(le){throw u.value=le instanceof Error?le.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function $(ie,me,we,ae="images"){d.value=!0,u.value=null;const le=[...c.value];try{const _e=await b()(f(`/media/model/${ie}/${me}/attach`),{method:"POST",body:{media_uuids:we,collection:ae}});return await j(ie,me,ae),(_e==null?void 0:_e.data)||[]}catch(ke){throw c.value=le,u.value=ke instanceof Error?ke.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function P(ie,me,we,ae="images"){d.value=!0,u.value=null;const le=[...c.value];c.value=c.value.filter(ke=>ke.uuid!==we);try{return await b()(f(`/media/model/${ie}/${me}/detach`),{method:"POST",body:{media_uuid:we,collection:ae}}),!0}catch(ke){throw c.value=le,u.value=ke instanceof Error?ke.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function O(ie,me,we,ae="images"){d.value=!0,u.value=null;const le=[...c.value],ke=new Map(c.value.map(_e=>[_e.uuid,_e]));c.value=we.map(_e=>ke.get(_e)).filter(_e=>_e!==void 0);try{return await b()(f(`/media/model/${ie}/${me}/reorder`),{method:"POST",body:{media_uuids:we,collection:ae}}),!0}catch(_e){throw c.value=le,u.value=_e instanceof Error?_e.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function V(ie,me,we={}){const ae=b(),le=Nt.apiBaseUrl||"/api/v1",ke=new FormData,_e=me.imageData,ut=_e.match(/^data:(image\/\w+);base64,/),Ze=ut?ut[1]:"image/png",St=_e.replace(/^data:image\/\w+;base64,/,""),He=atob(St),nt=new Uint8Array(He.length);for(let yt=0;yt<He.length;yt++)nt[yt]=He.charCodeAt(yt);const Vt=new Blob([nt],{type:Ze});ke.append("image_file",Vt,`edited.${Ze==="image/jpeg"?"jpg":"png"}`);const $t=zl(me.state);$t&&ke.append("editor_state",$t),me.metadata&&(ke.append("filters",JSON.stringify(me.metadata.filters)),me.metadata.cropRect&&ke.append("crop_data",JSON.stringify(me.metadata.cropRect))),ke.append("save_as_new","true"),we.asVariant&&ke.append("as_variant","true"),we.name!==void 0&&ke.append("name",we.name);const st=await ae(`${le}/editor/${ie}/save`,{method:"POST",body:ke});if("media"in st&&st.media)return st.media;if("status_url"in st&&st.status_url)return R(ae,st.status_url,we.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function R(ie,me,we){const ae=Date.now(),le=2e3;for(;Date.now()-ae<we;){await new Promise(_e=>setTimeout(_e,le));const ke=await ie(me);if(ke.status==="completed"&&ke.media)return ke.media;if(ke.status==="failed")throw new Error(ke.error??"Image processing failed")}throw new Error("Image processing timed out")}function G(ie,me,we){l.value=we!==void 0?{type:ie,uuid:me,collection:we}:{type:ie,uuid:me},g.value[`${ie}-${me}`]={timestamp:Date.now()}}function J(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function te(){if(!l.value.type||!l.value.uuid)return;const ie=await j(l.value.type,l.value.uuid,l.value.collection||"images");c.value=ie||[]}function fe(){a.value.forEach(ie=>p.value.add(ie.uuid))}function ye(){p.value.clear()}function oe(ie){p.value.has(ie)?p.value.delete(ie):p.value.add(ie)}function _(ie){return p.value.has(ie)}function A(){return Array.from(m.value.values()).some(ie=>ie.status==="uploading")}function Q(ie){return m.value.get(ie)||h.value.get(ie)}function ee(){return[...Array.from(m.value.values()),...Array.from(h.value.values())]}async function ne(){const ie=Array.from(p.value);let me=0;for(const we of ie)try{await S(we),me++}catch{}return ye(),me}function pe(ie,me){var we;return me&&((we=ie.conversion_urls)!=null&&we[me])?ie.conversion_urls[me]||"":ie.original_url||ie.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:C,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:h,cachedResponses:g,fetchMedia:B,uploadFile:U,deleteMedia:S,updateMedia:D,clearCache:T,fetchCollections:I,fetchModelMedia:j,attachMedia:$,detachMedia:P,reorderMedia:O,saveEditedImage:V,setModelContext:G,clearModelContext:J,refreshModelMedia:te,selectAllItems:fe,clearSelection:ye,toggleSelection:oe,isSelected:_,deleteSelectedItems:ne,getHttpClient:b,getApiUrl:f,hasActiveUploads:A,getUploadProgress:Q,getAllUploadProgress:ee,getMediaUrl:pe}}),Xl=()=>((Nt.apiScope!=="admin"||Nt.isAdmin!==!0)&&Zn({...Nt,apiScope:"admin",isAdmin:!0}),_t());function rm(a,n){try{let t=dt.getFilter(a);if(t||(dt.registerCorePixiFilters(),t=dt.getFilter(a)),!t){try{const r=dt.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const sm=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function l(){var M;if(!r){o("error",new Error("Editor not initialized"));return}const m=r.exportImage("png",.92);if(!m){o("error",new Error("Failed to export image — the image could not be processed"));return}const h=r.getSerializableState(),p=r._renderer,y=((M=p.getExportDimensions)==null?void 0:M.call(p))??{width:0,height:0},g={width:Math.round(y.width),height:Math.round(y.height)};o("save",{imageData:m,dimensions:g,state:h})}function c(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Ye,dt.initializeFilterRegistry();const m={theme:t.theme};t.preset&&(m.preset=t.preset),t.preset?t.cropShape==="circle"&&(m.cropShape="circle",m.initialAspectRatio="1:1",m.initialMode="crop"):(m.cropShape=t.cropShape==="circle"?"circle":"free",m.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",m.initialMode=t.cropShape==="circle"?"crop":"adjust"),r=new dt.VanillaImageEditor(i.value,m),r.setFilterRegistry({getAllFilters:dt.getAllFilters,getFilter:dt.getFilter,getFiltersByCategory:dt.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",c),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(m=>{const h=m[0];h&&h.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))});const u=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})};return e.watch(()=>t.initialImage,(m,h)=>{!r||!m||m===h||u()}),e.watch(()=>t.sessionKey,(m,h)=>{m!==h&&u()}),e.watch(()=>t.initialState,(m,h)=>{m!==h&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(m,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Ve=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},Hl=Ve(sm,[["__scopeId","data-v-d5646104"]]),lm={class:"editor-modal-panel"},cm={class:"editor-fill"},dm=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{default:null},sessionKey:{default:0},acceptedFormats:{default:"image/jpeg,image/png,image/webp,image/gif"},maxFileSize:{default:10},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=g=>{o("error",g)},d=()=>{e.nextTick(()=>{if(i.value){const g=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");g&&g.focus()}})};e.watch(()=>t.modelValue,g=>{r.value=g,g&&(l.value=document.activeElement,d())},{immediate:!0});const u=g=>{try{s.value=!0,o("save",g)}catch(x){c(x)}finally{s.value=!1}},m=()=>{o("cancel"),p()},h=()=>{s.value||p()},p=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},y=g=>{if(g.key==="Escape"&&r.value&&!s.value){p();return}if(g.key==="Tab"&&r.value&&i.value){const x=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(x.length===0)return;const M=x[0],C=x[x.length-1];g.shiftKey&&document.activeElement===M?(g.preventDefault(),C.focus()):!g.shiftKey&&document.activeElement===C&&(g.preventDefault(),M.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",y)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",y)}),(g,x)=>(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(h,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:h}),e.createElementVNode("div",lm,[e.createElementVNode("div",cm,[e.createVNode(Hl,{"initial-image":g.initialImage,"initial-state":g.initialState,"session-key":g.sessionKey,theme:g.theme,"crop-shape":g.cropShape,preset:g.preset,"primary-color":g.primaryColor,"secondary-color":g.secondaryColor,"save-button-color":g.saveButtonColor,"download-button-color":g.downloadButtonColor,onSave:u,onCancel:m,onError:c},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),Gl=Ve(dm,[["__scopeId","data-v-437b6a27"]]),um={class:"media-workspace"},mm={class:"media-workspace-toolbar"},pm={class:"media-workspace-label"},fm=["value"],hm={class:"media-workspace-grid"},vm=["onClick"],gm=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var m;const t=a,o=n,i=_t(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(h=>h.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=Zl({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const h={};(p=l.value)!=null&&p.collection&&(h.collection=l.value.collection),await i.fetchMedia(1,h),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,h=>{h&&h!==r.value&&(r.value=h)}),e.watch(()=>t.subScopes,h=>{if(h.length===0){r.value="";return}h.some(p=>p.id===r.value)||(r.value=h[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,h=>{h&&(o("scope-change",h),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(h,p)=>(e.openBlock(),e.createElementBlock("div",um,[e.createElementVNode("div",mm,[e.createElementVNode("label",pm,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=y=>r.value=y),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,y=>(e.openBlock(),e.createElementBlock("option",{key:y.id,value:y.id},e.toDisplayString(y.label),9,fm))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=y=>o("upload"))}," Upload ")]),e.createElementVNode("div",hm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,y=>(e.openBlock(),e.createElementBlock("button",{key:y.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:g=>o("preview",y)},e.toDisplayString(y.file_name),9,vm))),128))])]))}}),ym=Ve(gm,[["__scopeId","data-v-895f26fe"]]),bm={class:"managed-media-gallery"},wm={class:"gallery-grid"},km=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",bm,[e.createElementVNode("div",wm,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),xm=Ve(km,[["__scopeId","data-v-a60fdcd7"]]),Em="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>",Sr="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>",Sm="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>",Vr="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>",Vm="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>",_m="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>",ho="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>",Cm="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>",Jl="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>",Yl="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>",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' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",Nm="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>",Tm="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>",Ps="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>",Xn="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>",zs="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>",Mm="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>",fn="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>",Bm="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>",lo="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>",Im="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>",Fm="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>",js="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>",ql="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>",Co="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>",$m="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>",Rm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-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>",Dm="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>",vo="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>",Ws="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>",$i="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>",Am="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>",Lm="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>",Ri="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>",Um="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>",Om="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>",Pm="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>",zm="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>",Kl="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>",Ql="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>",jm="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>",Wm="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>",Zm="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>",Xm="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>",ec="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>",Hm="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>",Gm="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>",tc="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>",Jm="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>",Ym="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>",Yn="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>",qm="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>",Km="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>",Zs="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>",_r="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>",Qm="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>",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='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>",pn="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>",co="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>",Xs="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>",ep="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>",nc="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>",tp="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>",oc="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>",np="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>",op="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>",ap="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>",ip="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>",rp="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>",sp="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>",lp="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>",ta="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 Hs=()=>{};function cp(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 dp(a,n={}){let t,o,i=Hs;const r=c=>{clearTimeout(c),i(),i=Hs};let s;return c=>{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(c())):new Promise((m,h)=>{i=n.rejectOnCancel?h:m,s=c,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,m(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,m(c())},d)})}}function up(a,n=200,t={}){return cp(dp(n,t),a)}const uo=new Map;function mp(a){const n=e.getCurrentScope();function t(l){var c;const d=uo.get(a)||new Set;d.add(l),uo.set(a,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function o(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=uo.get(a);c&&(c.delete(l),c.size||r())}function r(){uo.delete(a)}function s(l,c){var d;(d=uo.get(a))==null||d.forEach(u=>u(l,c))}return{on:t,once:o,off:i,emit:s,reset:r}}function ac(){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 l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function pp(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=mp("media-selection"),r=ac(),s=e.computed(()=>a.value.filter(w=>n.value.has(w.uuid))),l=e.computed(()=>n.value.size);e.watch(n,w=>{i.emit({type:"selection:changed",count:w.size,selectedIds:Array.from(w)})},{deep:!0});const c=e.computed(()=>a.value.length>0&&a.value.every(w=>n.value.has(w.uuid))),d=e.computed(()=>a.value.some(w=>n.value.has(w.uuid)));function u(w){return n.value.has(w)}function m(w){n.value.has(w)?(n.value.delete(w),t.value===w&&(t.value=null,o.value=-1)):(n.value.add(w),t.value=w,o.value=a.value.findIndex(F=>F.uuid===w),n.value.size===1&&r.selection())}function h(w){n.value.add(w),t.value=w,o.value=a.value.findIndex(F=>F.uuid===w)}function p(w){n.value.delete(w),t.value===w&&(t.value=null,o.value=-1)}function y(){a.value.forEach(w=>n.value.add(w.uuid))}function g(){n.value.clear(),t.value=null,o.value=-1}function x(){c.value?g():y()}function M(w,F){const T=a.value.findIndex(E=>E.uuid===w);if(T!==-1)if(F!=null&&F.shiftKey&&o.value!==-1){const E=Math.min(o.value,T),B=Math.max(o.value,T);for(let U=E;U<=B;U++)n.value.add(a.value[U].uuid)}else m(w)}function C(){if(a.value.length===0)return;let w=o.value+1;w>=a.value.length&&(w=0),g(),h(a.value[w].uuid)}function b(){if(a.value.length===0)return;let w=o.value-1;w<0&&(w=a.value.length-1),g(),h(a.value[w].uuid)}function f(w){switch(w.key){case"ArrowDown":w.preventDefault(),C();break;case"ArrowUp":w.preventDefault(),b();break;case"a":(w.ctrlKey||w.metaKey)&&(w.preventDefault(),y());break;case"Escape":w.preventDefault(),g();break;case" ":t.value&&(w.preventDefault(),m(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:m,select:h,deselect:p,selectAll:y,clear:g,toggleAll:x,rangeSelect:M,selectNext:C,selectPrevious:b,handleKeydown:f,selectionBus:i}}const fp={class:"flex items-center justify-between w-full px-4"},hp={class:"p-4"},vp={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},gp={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},yp=["value"],bp={class:"flex gap-2 mt-4"},wp={class:"flex justify-end mb-4"},kp={key:1,class:"flex justify-center items-center h-64"},xp={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Ep={class:"text-sm text-theme-secondary"},Sp={key:0},Vp={class:"mb-4"},_p={class:"mb-4"},Cp={class:"flex gap-2"},Np={class:"flex items-center justify-between px-4 py-2"},Tp={class:"text-sm text-theme-secondary"},Mp={key:0},Bp={key:0},Ip={key:1},Fp={class:"flex gap-2"},$p=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(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),m=e.ref(!1),h=e.ref({}),p=e.ref(["images","documents","videos"]),y=e.ref(1),g=e.ref(!0),x=e.ref(!1),M=Xl(),C=pp(c);function b(_){var me;const A=_.conversion_urls||{},Q=_.proxy_url||_.original_url||_.url||"",ee=A.thumb||A.preview||_.preview_url||_.thumbnail_url||Q,ne=_.custom_properties||{},pe=ne.width,ie=ne.height;return{..._,uuid:_.uuid,name:_.name||_.file_name,file_name:_.file_name,filename:_.file_name,mime_type:_.mime_type,size:_.size,collection_name:_.collection_name||"images",disk:_.disk,original_url:Q,url:Q,thumbnail_url:ee,conversions:_.conversions||{},conversion_urls:A,generated_conversions:_.generated_conversions||{},custom_properties:ne,caption:_.caption||null,alt_text:_.alt_text||null,created_at:_.created_at,updated_at:_.updated_at,is_image:((me=_.mime_type)==null?void 0:me.startsWith("image/"))||!1,...typeof pe=="number"?{width:pe}:{},...typeof ie=="number"?{height:ie}:{},..._.formatted_size!==void 0?{formatted_size:_.formatted_size}:{}}}e.watch(()=>t.selectedItems,_=>{u.value=new Set(_),C.clear(),_.forEach(A=>C.select(A))});const f=e.computed(()=>{var A;let _=c.value;return(A=h.value.types)!=null&&A.length&&(_=_.filter(Q=>{var ne,pe;const ee=(ne=Q.mime_type)==null?void 0:ne.split("/")[0];return(pe=h.value.types)==null?void 0:pe.includes(ee)})),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&(_=_.filter(Q=>{const ee=Q.size/1048576;return!(h.value.sizeMin!==void 0&&ee<h.value.sizeMin||h.value.sizeMax!==void 0&&ee>h.value.sizeMax)})),_}),w=e.computed(()=>{var A;let _=0;return h.value.search&&_++,h.value.collection&&_++,(h.value.dateFrom||h.value.dateTo)&&_++,(A=h.value.types)!=null&&A.length&&(_+=h.value.types.length),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&_++,_}),F=e.computed(()=>{const _=C.selectedCount.value;return _===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${_} ${_===1?"Item":"Items"}`:"Item"}`}),T=e.computed(()=>{const _=C.selectedCount.value;return!!(_===0||t.selectionMode==="single"&&_>1||t.maxSelection&&_>t.maxSelection)}),E=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 B(_=!0){_?(l.value=!0,c.value=[],y.value=1,g.value=!0):x.value=!0;try{const A={collection:h.value.collection||t.collection,per_page:24};switch((s.value||h.value.search)&&(A.search=s.value||h.value.search||""),h.value.dateFrom&&(A.from_date=h.value.dateFrom),h.value.dateTo&&(A.to_date=h.value.dateTo),i.value){case"recent":await M.fetchMedia(y.value,A),_?c.value=M.items.map(Q=>b(Q)):c.value=[...c.value,...M.items.map(Q=>b(Q))],g.value=M.currentPage<M.totalPages;break;case"model":if(t.modelType&&t.modelId){const Q=await M.fetchModelMedia(t.modelType,t.modelId,A.collection,A.search);c.value=Q?Q.map(ee=>b(ee)):[],g.value=!1}break;case"library":await M.fetchMedia(y.value,A),_?c.value=M.items.map(Q=>b(Q)):c.value=[...c.value,...M.items.map(Q=>b(Q))],g.value=M.currentPage<M.totalPages;break}}catch{}finally{l.value=!1,x.value=!1}}async function U(_){if(!g.value||x.value){_!=null&&_.target&&_.target.complete();return}y.value++,await B(!1),_!=null&&_.target&&(_.target.complete(),g.value||(_.target.disabled=!0))}function S(_){return _==="recent"||_==="model"||_==="library"}function D(_){i.value=_,B()}function I(_){typeof _=="string"&&S(_)&&D(_)}async function j(_){t.selectionMode==="single"?(C.clear(),C.select(_.uuid)):(C.toggle(_.uuid),t.maxSelection&&C.selectedCount.value>t.maxSelection&&(C.deselect(_.uuid),await(await L.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function $(){o("confirm",C.selectedItems.value)}function P(){o("close")}function O(_){}const V=e.ref(null),R=e.ref(!1);function G(_){V.value=_,R.value=!0}function J(_){const A=c.value.findIndex(ee=>ee.uuid===_.uuid);A!==-1&&(c.value[A]=_);const Q={};_.alt_text!==void 0&&(Q.alt_text=_.alt_text),_.caption!==void 0&&(Q.caption=_.caption),_.custom_properties!==void 0&&(Q.custom_properties=_.custom_properties),M.updateMedia(_.uuid,Q)}function te(){B()}function fe(){h.value={},s.value="",B()}const ye=up(()=>{B(!0)},300);e.watch(s,()=>{t.isOpen&&ye()});async function oe(_){try{await(await L.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(_),await B()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,_=>{_&&B()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(_=>C.select(_))}),(_,A)=>{const Q=e.resolveComponent("AdminMediaGrid"),ee=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(L.IonModal),{"is-open":_.isOpen,onDidDismiss:P,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(L.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{onClick:P},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(L.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(E.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",fp,[e.createVNode(e.unref(L.IonSegment),{value:i.value,onIonChange:A[0]||(A[0]=ne=>I(ne.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[15]||(A[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(L.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[16]||(A[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[17]||(A[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(L.IonButton),{fill:"clear",size:"small",onClick:A[1]||(A[1]=ne=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[w.value>0?(e.openBlock(),e.createBlock(e.unref(L.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(L.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",hp,[m.value?(e.openBlock(),e.createElementBlock("div",vp,[e.createElementVNode("div",gp,[e.createElementVNode("div",null,[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[18]||(A[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":A[2]||(A[2]=ne=>h.value.collection=ne),class:"w-full p-2 border rounded"},[A[19]||(A[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,ne=>(e.openBlock(),e.createElementBlock("option",{key:ne,value:ne},e.toDisplayString(ne),9,yp))),128))],512),[[e.vModelSelect,h.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[20]||(A[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[3]||(A[3]=ne=>h.value.dateFrom=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[21]||(A[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[4]||(A[4]=ne=>h.value.dateTo=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateTo]])])]),e.createElementVNode("div",bp,[e.createVNode(e.unref(L.IonButton),{size:"small",onClick:te},{default:e.withCtx(()=>[...A[22]||(A[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(L.IonButton),{size:"small",fill:"clear",onClick:fe},{default:e.withCtx(()=>[...A[23]||(A[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":A[5]||(A[5]=ne=>s.value=ne),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",wp,[e.createVNode(e.unref(L.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:A[6]||(A[6]=ne=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(L.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:A[7]||(A[7]=ne=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",kp,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",xp,[e.createVNode(e.unref(L.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),A[24]||(A[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Ep,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(Q,{key:3,"media-items":f.value,"selected-items":e.unref(C).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:j,onPreview:O,onEdit:G,onDelete:oe},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(L.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(ne,pe)=>(e.openBlock(),e.createBlock(ee,{key:ne.uuid,media:ne,selected:e.unref(C).isSelected(ne.uuid),"selection-mode":!0,index:pe,onToggleSelect:j,onPreview:O,onEdit:G,onDelete:oe},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(L.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:A[8]||(A[8]=ne=>U(ne))},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(L.IonModal),{"is-open":R.value,onDidDismiss:A[14]||(A[14]=ne=>R.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(L.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{onClick:A[9]||(A[9]=ne=>R.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(L.IonTitle),null,{default:e.withCtx(()=>[...A[25]||(A[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(L.IonContent),{class:"p-4"},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createElementBlock("div",Sp,[e.createElementVNode("div",Vp,[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[26]||(A[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[10]||(A[10]=ne=>V.value.caption=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,V.value.caption]])]),e.createElementVNode("div",_p,[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...A[27]||(A[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[11]||(A[11]=ne=>V.value.alt_text=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,V.value.alt_text]])]),e.createElementVNode("div",Cp,[e.createVNode(e.unref(L.IonButton),{onClick:A[12]||(A[12]=ne=>J(V.value))},{default:e.withCtx(()=>[...A[28]||(A[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(L.IonButton),{fill:"clear",onClick:A[13]||(A[13]=ne=>R.value=!1)},{default:e.withCtx(()=>[...A[29]||(A[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(L.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Np,[e.createElementVNode("div",Tp,[e.unref(C).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Mp,[e.createTextVNode(e.toDisplayString(e.unref(C).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Bp," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Ip," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Fp,[e.createVNode(e.unref(L.IonButton),{fill:"clear",onClick:P},{default:e.withCtx(()=>[...A[30]||(A[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(L.IonButton),{disabled:T.value,onClick:$},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(F.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Rp=Ve($p,[["__scopeId","data-v-9a8c0954"]]),Dp={key:1,class:"flex flex-col items-center justify-center py-16"},Ap=["draggable","onDragstart","onDragover","onDrop"],Lp={key:0,class:"absolute top-2 left-2 z-20"},Up=["checked","onChange"],Op={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Pp=["data-media-id"],zp={key:0,class:"w-full h-full flex items-center justify-center"},jp=["src","alt","onError","onLoad"],Wp={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},Zp={class:"text-center"},Xp={class:"text-4xl text-gray-400 mb-2"},Hp={class:"text-sm font-medium text-gray-500"},Gp={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Jp=["onClick"],Yp=["onClick"],qp=["onClick"],Kp={class:"p-3"},Qp={class:"text-sm font-medium truncate mb-1"},ef={class:"text-xs text-gray-600 dark:text-gray-400"},tf={key:0},nf={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},of=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),l=e.ref(null),c=T=>t.selectedItems.some(E=>E.uuid===T.uuid),d=e.computed(()=>{const T=t.columns,E=["grid","gap-4"];switch(T.mobile){case 1:E.push("grid-cols-1");break;case 2:E.push("grid-cols-2");break;case 3:E.push("grid-cols-3");break;case 4:E.push("grid-cols-4");break;default:E.push("grid-cols-2");break}switch(T.sm){case 1:E.push("sm:grid-cols-1");break;case 2:E.push("sm:grid-cols-2");break;case 3:E.push("sm:grid-cols-3");break;case 4:E.push("sm:grid-cols-4");break;case 5:E.push("sm:grid-cols-5");break;default:E.push("sm:grid-cols-3");break}switch(T.md){case 2:E.push("md:grid-cols-2");break;case 3:E.push("md:grid-cols-3");break;case 4:E.push("md:grid-cols-4");break;case 5:E.push("md:grid-cols-5");break;case 6:E.push("md:grid-cols-6");break;default:E.push("md:grid-cols-4");break}switch(T.lg){case 3:E.push("lg:grid-cols-3");break;case 4:E.push("lg:grid-cols-4");break;case 5:E.push("lg:grid-cols-5");break;case 6:E.push("lg:grid-cols-6");break;case 7:E.push("lg:grid-cols-7");break;default:E.push("lg:grid-cols-5");break}switch(T.xl){case 4:E.push("xl:grid-cols-4");break;case 5:E.push("xl:grid-cols-5");break;case 6:E.push("xl:grid-cols-6");break;case 7:E.push("xl:grid-cols-7");break;case 8:E.push("xl:grid-cols-8");break;default:E.push("xl:grid-cols-6");break}return E.join(" ")});function u(T,E,B){t.reorderable&&(i.value=E,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/html","")))}function m(T,E){t.reorderable&&(T.preventDefault(),r.value=E)}function h(){r.value=null}function p(T,E){if(!t.reorderable||!i.value)return;T.preventDefault();const B=[...t.mediaItems],U=B.findIndex(S=>{var D;return S.uuid===((D=i.value)==null?void 0:D.uuid)});if(U!==-1&&U!==E&&i.value){const[S]=B.splice(U,1);B.splice(E,0,S),o("reorder",B)}i.value=null,r.value=null}function y(T){return T<1024?T+" B":T<1024*1024?(T/1024).toFixed(1)+" KB":(T/(1024*1024)).toFixed(1)+" MB"}function g(T){var B;return T.thumbnail_url||((B=T.conversion_urls)==null?void 0:B.thumb)||T.original_url||T.url||""}function x(T){var U,S,D;const E=((U=T.mime_type)==null?void 0:U.startsWith("image/"))||!1,B=!!(T.thumbnail_url||(S=T.conversion_urls)!=null&&S.thumb||(D=T.conversion_urls)!=null&&D.preview||T.original_url||T.url);return E&&B}function M(T){var E;return((E=T.split(".").pop())==null?void 0:E.toUpperCase())||""}function C(T){var B;const E=((B=T.mime_type)==null?void 0:B.toLowerCase())||"";return E.startsWith("image/")?"image":E.startsWith("video/")?"videocam":E.startsWith("audio/")?"musical-notes":E.includes("pdf")?"document-text":E.includes("zip")||E.includes("rar")?"archive":E.includes("sheet")||E.includes("excel")?"grid":E.includes("document")||E.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(T=>{T.forEach(E=>{var B;if(E.isIntersecting){const U=E.target.getAttribute("data-media-id");U&&(s.value.add(U),(B=l.value)==null||B.unobserve(E.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function b(T){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(E=>{var U;const B=E.getAttribute("data-media-id");B&&!s.value.has(B)&&((U=l.value)==null||U.observe(E))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function w(T,E){const B=T.target;delete B.dataset.fallbackIndex}function F(T,E){const B=T.target,U=B.closest("[data-media-id]"),S=[E.original_url,E.url,E.thumbnail_url,"preview_url"in E?E.preview_url:void 0].filter(D=>D&&D.trim()!==""&&D!==B.src);if(S.length>0&&B.dataset.fallbackIndex){const D=parseInt(B.dataset.fallbackIndex);if(D<S.length){B.dataset.fallbackIndex=(D+1).toString(),B.src=S[D]||"";return}}else if(S.length>0){B.dataset.fallbackIndex="1",B.src=S[0]||"";return}if(B.style.display="none",U&&!U.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">${C(E)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${M(E.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,U.appendChild(I)}}return(T,E)=>T.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,B=>e.createElementVNode("div",{key:`skeleton-${B}`,class:"relative"},[...E[1]||(E[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)):!T.mediaItems||!T.mediaItems.length?(e.openBlock(),e.createElementBlock("div",Dp,[E[2]||(E[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)),E[3]||(E[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),E[4]||(E[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:E[0]||(E[0]=B=>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(T.mediaItems,(B,U)=>(e.openBlock(),e.createElementBlock("div",{key:B.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===U}]),draggable:T.reorderable,onDragstart:S=>u(S,B),onDragover:S=>m(S,U),onDragleave:h,onDrop:S=>p(S,U)},[T.selectionMode?(e.openBlock(),e.createElementBlock("div",Lp,[e.createElementVNode("input",{type:"checkbox",checked:c(B),onChange:S=>o("toggleSelect",B),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,Up)])):e.createCommentVNode("",!0),T.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",T.selectionMode?"left-10":"left-2"])},[e.renderSlot(T.$slots,"badge",{media:B,index:U},void 0,!0)],2)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",Op,[...E[5]||(E[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":c(B)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":B.uuid},[x(B)&&!b(B.uuid)?(e.openBlock(),e.createElementBlock("div",zp,[...E[6]||(E[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),x(B)&&b(B.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(B),alt:B.alt_text||B.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:S=>F(S,B),onLoad:S=>w(S)},null,40,jp)):(e.openBlock(),e.createElementBlock("div",Wp,[e.createElementVNode("div",Zp,[e.createElementVNode("div",Xp,e.toDisplayString(C(B)),1),e.createElementVNode("p",Hp,e.toDisplayString(M(B.file_name)),1)])])),e.createElementVNode("div",Gp,[e.createElementVNode("button",{onClick:S=>o("preview",B),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...E[7]||(E[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,Jp),T.showEditButton&&x(B)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:S=>o("edit",B),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...E[8]||(E[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,Yp)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:S=>o("delete",B.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...E[9]||(E[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,qp)])],8,Pp),e.createElementVNode("div",Kp,[e.createElementVNode("h4",Qp,e.toDisplayString(B.file_name),1),e.createElementVNode("p",ef,[e.createTextVNode(e.toDisplayString(y(B.size))+" ",1),B.width&&B.height?(e.openBlock(),e.createElementBlock("span",tf," • "+e.toDisplayString(B.width)+"x"+e.toDisplayString(B.height),1)):e.createCommentVNode("",!0)]),B.caption?(e.openBlock(),e.createElementBlock("p",nf,e.toDisplayString(B.caption),1)):e.createCommentVNode("",!0)])],2)],42,Ap))),128))],2))}}),af=Ve(of,[["__scopeId","data-v-f0c343b7"]]),rf={class:"model-media-manager"},sf=["accept","multiple"],lf={class:"flex items-center justify-between mb-4"},cf={key:0,class:"text-lg font-medium"},df={class:"flex gap-2"},uf={key:0,class:"flex items-center justify-center py-8"},mf={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"},pf={class:"text-gray-600 dark:text-gray-400"},ff={class:"flex gap-2 mt-4"},hf={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},vf=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=_t(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(0),m=e.ref(null),h=e.ref(void 0),p=e.ref(null),y=e.ref(null),g=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),x=e.computed(()=>i.modelMedia.map(R=>R.uuid)),M=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function C(){Zn({isAdmin:t.mode==="admin"})}async function b(R){await(await L.toastController.create({message:R,duration:3e3,color:"danger",position:"bottom"})).present()}async function f(){if(!s.value)if(s.value=!0,C(),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(R){const G=R instanceof Error?R.message:"Failed to fetch media";o("error",{operation:"fetch",message:G,details:R})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,R=>{s.value&&o("update:media",R)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,f()}),e.watch(()=>t.mode,()=>{C()}),e.onMounted(()=>{f()}),e.onUnmounted(()=>{i.clearModelContext()});function w(){return i.modelMedia.length>0}function F(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function T(R){var J,te,fe;if(!((J=R.mime_type)!=null&&J.startsWith("image/")))return null;const G=R.original_url||R.url||((te=R.conversion_urls)==null?void 0:te.preview)||((fe=R.conversion_urls)==null?void 0:fe.thumb)||R.thumbnail_url;return G&&G.trim()!==""?G:null}function E(){l.value=!0}function B(){var R;(R=y.value)==null||R.click()}function U(){l.value=!1}async function S(R){if(!t.allowEdit)return;const G=T(R);if(G){d.value=R,u.value++;try{const J=i.getHttpClient(),te=i.getApiUrl(""),fe=await J(`${te.replace(/\/$/,"")}/editor/${R.uuid}/edit`);h.value=fe.editable_source_url||G,m.value=fe.editor_state??null}catch{h.value=G,m.value=null}c.value=!0}}function D(){c.value=!1,d.value=null,h.value=void 0,m.value=null}async function I(R){if(!d.value)throw new Error("No media selected for editing");const G=d.value,J=t.editMode==="variant";try{p.value=null;const te=await i.saveEditedImage(G.uuid,R,{asVariant:J,name:G.file_name});J||await i.detachMedia(t.mediableType,t.mediableId,G.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[te.uuid],t.collection),o("edit-complete",{originalMedia:G,editedMedia:te,mode:t.editMode}),c.value=!1,d.value=null}catch(te){const fe=te instanceof Error?te.message:"Failed to save edited image";throw p.value=fe,await b(fe),te}}function j(R){if(p.value===R.message){p.value=null;return}b(R.message)}async function $(R){const G=R.target,J=G.files;if(!(!J||J.length===0)){for(let te=0;te<J.length;te++){const fe=J[te];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(fe.type)){o("error",{operation:"upload",message:`File type ${fe.type} is not accepted`,details:{file:fe.name}});continue}if(t.maxFileSize!==void 0&&fe.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:fe.name,size:fe.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:fe});try{const ye=await i.uploadFile(fe,{collection:t.collection});ye!=null&&ye.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[ye.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:fe}),o("attach",[ye]))}catch(ye){const oe=ye instanceof Error?ye.message:"Upload failed";o("error",{operation:"upload",message:oe,details:ye}),o("upload-progress",{status:"error",progress:0,file:fe,error:oe})}}G.value=""}}async function P(R){const G=R.map(J=>J.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,G,t.collection),o("reorder",i.modelMedia)}catch(J){const te=J instanceof Error?J.message:"Failed to reorder media";o("error",{operation:"reorder",message:te,details:J}),await b(te)}}async function O(R){const G=i.modelMedia.find(J=>J.uuid===R);try{await i.detachMedia(t.mediableType,t.mediableId,R,t.collection),G&&o("detach",G)}catch(J){const te=J instanceof Error?J.message:"Failed to detach media";o("error",{operation:"detach",message:te,details:J}),await b(te)}}async function V(R){l.value=!1;const G=R.map(fe=>fe.uuid),J=new Set(x.value);let te=Array.from(new Set(G)).filter(fe=>!J.has(fe));if(g.value!==void 0&&te.length>g.value&&(te=te.slice(0,g.value)),te.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,te,t.collection);const fe=i.modelMedia.filter(ye=>te.includes(ye.uuid));o("attach",fe)}catch(fe){const ye=fe instanceof Error?fe.message:"Failed to attach media";o("error",{operation:"attach",message:ye,details:fe})}}return(R,G)=>(e.openBlock(),e.createElementBlock("div",rf,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:y,type:"file",accept:M.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:$},null,40,sf),e.createElementVNode("div",lf,[R.title?(e.openBlock(),e.createElementBlock("h3",cf,e.toDisplayString(R.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",df,[R.allowBrowse?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:0,fill:"outline",size:"small",disabled:F(),"data-testid":"browse-button",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"start",icon:e.unref(Ri)},null,8,["icon"]),G[1]||(G[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),R.allowUpload?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:1,fill:"solid",size:"small",disabled:F(),"data-testid":"upload-button",onClick:B},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"start",icon:e.unref(zs)},null,8,["icon"]),G[2]||(G[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",uf,[e.createVNode(e.unref(L.IonSpinner),{"data-testid":"spinner"})])):w()?(e.openBlock(),e.createBlock(af,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!R.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!R.allowEdit,"selection-mode":!1,onReorder:P,onDelete:O,onEdit:S},e.createSlots({_:2},[R.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:J})=>[J===0?(e.openBlock(),e.createElementBlock("div",hf," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",mf,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Ri),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",pf,e.toDisplayString(R.emptyText),1),e.createElementVNode("div",ff,[R.allowBrowse?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"start",icon:e.unref(Ri)},null,8,["icon"]),G[3]||(G[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),R.allowUpload?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:B},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"start",icon:e.unref(zs)},null,8,["icon"]),G[4]||(G[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Rp,e.mergeProps({"is-open":l.value,"selected-items":x.value,collection:R.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:V,onClose:U}),null,16,["is-open","selected-items","collection"]),e.createVNode(Gl,{modelValue:c.value,"onUpdate:modelValue":G[0]||(G[0]=J=>c.value=J),"initial-image":h.value,"initial-state":m.value,"session-key":u.value,onSave:I,onCancel:D,onError:j},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),gf=Ve(vf,[["__scopeId","data-v-f68e70ec"]]),yf={class:"existing-media-selector","data-testid":"existing-media-selector"},bf={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},wf=["data-testid"],kf={class:"existing-media-selector__section-header"},xf={class:"existing-media-selector__section-title"},Ef=["data-testid","aria-label","onClick"],Sf={class:"existing-media-selector__grid"},Vf=["data-testid","aria-label","aria-pressed","onClick"],_f=["src","alt"],Cf={key:0,class:"existing-media-selector__selected-badge"},Nf={key:1,class:"existing-media-selector__caption"},Tf={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},Mf={class:"existing-media-selector__section-header"},Bf={class:"existing-media-selector__section-title"},If={class:"existing-media-selector__albums"},Ff=["data-testid","aria-label","aria-pressed","onClick"],$f={class:"existing-media-selector__album-name"},Rf={key:0,class:"existing-media-selector__album-count"},Df={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},Af={class:"existing-media-selector__section-header"},Lf={class:"existing-media-selector__section-subtitle"},Uf={key:0,class:"existing-media-selector__section-description"},Of={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},Pf={key:1,class:"existing-media-selector__grid"},zf=["data-testid","aria-label","aria-pressed","onClick"],jf=["src","alt"],Wf={key:0,class:"existing-media-selector__selected-badge"},Zf={key:1,class:"existing-media-selector__caption"},Xf={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},Hf={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Gf=e.defineComponent({__name:"ExistingMediaSelector",props:{sections:{default:()=>[]},albums:{default:()=>[]},selectedId:{default:null},activeAlbumId:{default:null},activeAlbumItems:{default:()=>[]},activeAlbumTitle:{},activeAlbumDescription:{},isLoading:{type:Boolean,default:!1},isAlbumLoading:{type:Boolean,default:!1},emptyMessage:{default:"No media available yet."},albumBrowseTitle:{default:"Browse Your Albums"},albumSectionTitle:{default:"Selected Album"},activeAlbumEmptyMessage:{default:"No media available in this album yet."}},emits:["select","update:activeAlbumId"],setup(a,{emit:n}){const t=a,o=n,i=e.reactive({}),r=e.computed(()=>t.sections.filter(f=>f.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),c=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const f=t.albums.find(w=>w.id===t.activeAlbumId);return f!=null&&f.name.trim().length?f.name.trim():t.albumSectionTitle}),d=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const f=t.albums.find(w=>w.id===t.activeAlbumId);return typeof(f==null?void 0:f.description)=="string"&&f.description.trim().length>0?f.description.trim():""});function u(f){const w=f.initialVisibleCount??6;return w>0?w:6}function m(f){return i[f]===!0}function h(f){i[f]=!m(f)}function p(f){return m(f.id)?f.items:f.items.slice(0,u(f))}function y(f){return f.items.length>u(f)}function g(f){o("select",f)}function x(f){o("update:activeAlbumId",f)}function M(f){var F;const w=(F=f.description)==null?void 0:F.trim();return w&&w.length>0?`Select ${w}`:"Select existing media"}function C(f,w){var T;const F=(T=w.description)==null?void 0:T.trim();return typeof w.alt=="string"&&w.alt.trim().length>0?w.alt.trim():F&&F.length>0?F:f.title}function b(f){const w=typeof f.mediaCount=="number"?` with ${f.mediaCount} item${f.mediaCount===1?"":"s"}`:"";return`Browse album ${f.name}${w}`}return(f,w)=>(e.openBlock(),e.createElementBlock("div",yf,[f.isLoading?(e.openBlock(),e.createElementBlock("div",bf," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,F=>(e.openBlock(),e.createElementBlock("section",{key:F.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${F.id}`},[e.createElementVNode("div",kf,[e.createElementVNode("h3",xf,e.toDisplayString(F.title),1),y(F)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${F.id}`,"aria-label":m(F.id)?`Show fewer items from ${F.title}`:`Show more items from ${F.title}`,onClick:T=>h(F.id)},e.toDisplayString(m(F.id)?"See less":"See more"),9,Ef)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Sf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(F),T=>(e.openBlock(),e.createElementBlock("button",{key:T.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===T.id}]),"data-testid":`existing-media-item-${F.id}-${T.id}`,"aria-label":M(T),"aria-pressed":f.selectedId===T.id?"true":"false",onClick:E=>g(T)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:T.previewUrl,alt:C(F,T)},null,8,_f),f.selectedId===T.id?(e.openBlock(),e.createElementBlock("div",Cf," Selected ")):e.createCommentVNode("",!0),T.description?(e.openBlock(),e.createElementBlock("div",Nf,e.toDisplayString(T.description),1)):e.createCommentVNode("",!0)],10,Vf))),128))])],8,wf))),128)),s.value?(e.openBlock(),e.createElementBlock("section",Tf,[e.createElementVNode("div",Mf,[e.createElementVNode("h3",Bf,e.toDisplayString(f.albumBrowseTitle),1)]),e.createElementVNode("div",If,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.albums,F=>(e.openBlock(),e.createElementBlock("button",{key:F.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":f.activeAlbumId===F.id}]),"data-testid":`existing-media-album-${F.id}`,"aria-label":b(F),"aria-pressed":f.activeAlbumId===F.id?"true":"false",onClick:T=>x(F.id)},[e.createElementVNode("span",$f,e.toDisplayString(F.name),1),typeof F.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",Rf,e.toDisplayString(F.mediaCount),1)):e.createCommentVNode("",!0)],10,Ff))),128))]),e.createElementVNode("div",Df,[e.createElementVNode("div",Af,[e.createElementVNode("div",null,[e.createElementVNode("h4",Lf,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",Uf,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),f.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",Of," Loading album... ")):f.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",Pf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.activeAlbumItems,F=>(e.openBlock(),e.createElementBlock("button",{key:F.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===F.id}]),"data-testid":`existing-media-item-album-${F.id}`,"aria-label":M(F),"aria-pressed":f.selectedId===F.id?"true":"false",onClick:T=>g(F)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:F.previewUrl,alt:F.alt||F.description||c.value},null,8,jf),f.selectedId===F.id?(e.openBlock(),e.createElementBlock("div",Wf," Selected ")):e.createCommentVNode("",!0),F.description?(e.openBlock(),e.createElementBlock("div",Zf,e.toDisplayString(F.description),1)):e.createCommentVNode("",!0)],10,zf))),128))])):(e.openBlock(),e.createElementBlock("div",Xf,[e.renderSlot(f.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(f.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Hf,[e.renderSlot(f.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(f.emptyMessage),1)],!0)]))],64))]))}}),Jf=Ve(Gf,[["__scopeId","data-v-904abb6b"]]);function na(a,n,t,o){if(t<=0||o<=0)return!1;try{return n.drawImage(a,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Yf(a,n){return a?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:n,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:n,opacity:"1",pointerEvents:"auto"}}const qf=["src","crossorigin"],Kf={class:"preview-controls"},Qf=["aria-label"],eh={class:"time-display"},th={class:"current-time"},nh={class:"total-time"},oh={key:0,class:"fps-display"},ah={key:0,class:"loading-overlay"},ih={key:1,class:"error-overlay"},rh=.1,sh=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Ye,r=a,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),h=e.ref(0),p=e.ref(0),y=e.ref(!1);let g,x,M=null,C=null,b=null,f=[],w="",F=null,T=0,E=0,B=0,U=0,S=!1,D=0,I=0,j,$=null,P=!1,O=!1,V=0;const R=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),G=e.computed(()=>{const ce=R.value;if(!(!ce||ce.startsWith("blob:")))return"anonymous"}),J=e.computed(()=>Yf(y.value,r.fitMode));function te(ce){return typeof ce=="number"&&Number.isFinite(ce)&&ce>=0?ce:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function fe(ce){const xe=te(ce.duration);return xe<=0?!1:ce.currentTime>=Math.max(0,xe-rh)}async function ye(){var ce,xe;if(!O&&c.value&&!g&&!(!d.value||d.value.readyState<3)){O=!0;try{m.value=void 0;let Ee=((ce=l.value)==null?void 0:ce.clientWidth)||800,Oe=((xe=l.value)==null?void 0:xe.clientHeight)||450;if((Ee<=0||Oe<=0)&&(Ee=d.value.videoWidth||800,Oe=d.value.videoHeight||450),g=new Ye.Application,await g.init({width:Ee,height:Oe,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(g.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!g&&ye()},100),g&&(g.destroy(!0),g=null);return}if(T=d.value.videoWidth,E=d.value.videoHeight,C=document.createElement("canvas"),C.width=T,C.height=E,b=C.getContext("2d"),!b)throw new Error("Unable to create 2D canvas context for video preview");const N=na(d.value,b,T,E),z=Ye.Texture.from(C);M=z.source,x=new Ye.Sprite(z),x.visible=!0,x.alpha=1,Vt(),g.stage.addChild(x),g.renderer&&!g.renderer.destroyed&&g.render()}Q(),r.targetFps<60?oe():g.ticker.add(_),y.value=!0,"ResizeObserver"in window&&(F=new ResizeObserver(N=>{S||(S=!0,requestAnimationFrame(()=>{S=!1;const z=N[N.length-1],{width:H,height:q}=z.contentRect;if(H<=0||q<=0)return;const de=Math.round(H),he=Math.round(q);de===B&&he===U||(B=de,U=he,Vt())}))}),F.observe(l.value)),r.filters&&r.filters.length>0&&Q(),r.showFps&&ut(),V=0}catch{if(He(),!P&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&V<2){V+=1,window.setTimeout(()=>{P||ye()},V*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{O=!1}}}function oe(){const ce=1e3/r.targetFps;let xe=performance.now();function Ee(){if(P||!g)return;const Oe=performance.now(),N=Oe-xe;N>=ce&&(_(),xe=Oe-N%ce),$=requestAnimationFrame(Ee)}$=requestAnimationFrame(Ee)}function _(){if(!(!g||!x||P)&&r.active)try{b&&C&&M&&d.value&&(d.value.readyState>=2&&na(d.value,b,C.width,C.height)&&M.update(),d.value.paused||s("frame-update",pe())),r.showFps&&I++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{P=!0}}function A(){for(const ce of f)try{ce.destroy()}catch{}f=[]}function Q(){if(x){if(!r.filters||r.filters.length===0){x.filters=null,A();return}A(),r.filters.forEach(ce=>{const xe=ee(ce);xe&&f.push(xe)}),x.filters=f.length>0?f:null,w=JSON.stringify(r.filters),g&&g.render()}}function ee(ce){const xe=ce.filterId,Ee=ce.params||{},Oe=dt.getFilter(xe);if(Oe&&!dt.isFilterCompatibleWithMedia(xe,"video"))return null;if(Oe&&Oe.createFilter)try{return Oe.createFilter(Ee)}catch{}const N=(z,H,q)=>Math.min(q,Math.max(H,z));switch(xe){case"brightness":{const z=new o,H=N(typeof Ee.brightness=="number"?Ee.brightness:typeof Ee.value=="number"?Ee.value:1,0,5);return z.brightness(H,!0),z}case"contrast":{const z=new o,H=N(typeof Ee.contrast=="number"?Ee.contrast:typeof Ee.value=="number"?Ee.value:1,0,5);return z.contrast(H,!0),z}case"saturation":{const z=new o,H=N(typeof Ee.saturation=="number"?Ee.saturation:typeof Ee.value=="number"?Ee.value:1,0,5);return z.saturate(H,!0),z}case"hue":{const z=new o,H=N(typeof Ee.value=="number"?Ee.value:0,-180,180);return z.hue(H,!0),z}case"gaussian-blur":case"blur":{const z=N(typeof Ee.blur=="number"?Ee.blur:typeof Ee.value=="number"?Ee.value:2,0,10);return new i(z)}case"grayscale":{const z=new o;return z.desaturate(),z}case"sepia":case"color-matrix":{const z=new o;return z.sepia(!0),z}case"vignette":{const z=typeof Ee.value=="number"?Ee.value:.3;return ne(N(z,0,1))}default:return null}}function ne(ce){const xe=`
|
|
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 Ye.Filter(void 0,xe,{strength:ce})}function pe(){var xe;return!g||!x?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((xe=d.value)==null?void 0:xe.currentTime)||0,width:T||0,height:E||0}}function ie(){var ce;h.value=te((ce=d.value)==null?void 0:ce.duration),s("duration-change",h.value)}function me(){u.value=!1,m.value=void 0}function we(){u.value&&(u.value=!1),!y.value&&r.active?ye():y.value}function ae(){var xe,Ee,Oe;const ce=((xe=d.value)==null?void 0:xe.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:ce,width:((Ee=d.value)==null?void 0:Ee.videoWidth)||0,height:((Oe=d.value)==null?void 0:Oe.videoHeight)||0})}function le(){d.value&&(d.value.currentTime=0),s("play-pause")}function ke(ce){var Ee;const xe=ce.target;if(xe!=null&&xe.error)switch(xe.error.code){case xe.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case xe.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case xe.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case xe.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(Ee=xe.src)==null?void 0:Ee.substring(0,100)}`;break;default:m.value="Failed to load video"}else m.value="Failed to load video";s("error",m.value),u.value=!1}function _e(ce){d.value&&(d.value.currentTime=Math.max(0,Math.min(ce,h.value)))}function ut(){j=window.setInterval(()=>{const ce=performance.now(),xe=ce-D;p.value=Math.round(I*1e3/xe),I=0,D=ce},1e3)}function Ze(ce){if(!Number.isFinite(ce)||ce<0)return"00:00";const xe=Math.floor(ce/60),Ee=Math.floor(ce%60);return`${xe.toString().padStart(2,"0")}:${Ee.toString().padStart(2,"0")}`}function St(){m.value=void 0,u.value=!0,V=0,He(),d.value&&d.value.load()}function He(){if(F&&(F.disconnect(),F=null),$&&(cancelAnimationFrame($),$=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(_)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),A(),g=null,x=null,M=null,C=null,b=null,y.value=!1,S=!1,w=""}function nt(){g&&(S||(S=!0,requestAnimationFrame(()=>{S=!1,Vt()})))}function Vt(){if(!g||!x||!T||!E||!l.value)return;const ce=Math.round(l.value.clientWidth),xe=Math.round(l.value.clientHeight);if(ce<=0||xe<=0)return;g.renderer.resize(ce,xe);const Ee=g.screen.width/T,Oe=g.screen.height/E;let N=1;switch(r.fitMode){case"cover":N=Math.max(Ee,Oe);break;case"none":N=1;break;case"contain":default:N=Math.min(Ee,Oe);break}x.scale.set(N),x.anchor.set(.5),x.position.set(g.screen.width/2,g.screen.height/2),x.visible=!0,x.alpha=1,g.renderer&&!g.renderer.destroyed&&g.render()}e.watch(()=>r.filters,()=>{y.value&&Q()},{deep:!0}),e.watch(()=>r.active,async ce=>{if(ce&&!g&&d.value&&d.value.readyState>=2){await ye();return}g&&(ce&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),x&&b&&C&&M&&(d.value&&d.value.readyState>=2&&na(d.value,b,C.width,C.height)&&M.update(),Vt(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(ce?g.ticker.start():g.ticker.stop()))}),e.watch(R,ce=>{ce?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function $t(){if(d.value){m.value=void 0,fe(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}m.value="Unable to start preview playback",s("error",m.value)}}e.watch(()=>r.isPlaying,ce=>{d.value&&(ce?$t():d.value.pause())}),e.watch(()=>r.playhead,ce=>{d.value&&Math.abs(d.value.currentTime-ce)>.5&&_e(ce)}),e.watch(()=>r.fitMode,()=>{Vt()}),e.onMounted(()=>{P=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",nt),D=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!y.value?ye():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(P=!0,$&&(cancelAnimationFrame($),$=null),window.removeEventListener("resize",nt),F&&(F.disconnect(),F=null),j&&clearInterval(j),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(_)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}f.forEach(ce=>{try{ce.destroy()}catch{}}),f=[],x=null,M=null,C=null,b=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function st(ce){if(!await yt()||!d.value||!b||!C||!M)return null;const Ee=d.value,Oe=Number.isFinite(h.value)&&h.value>0?h.value:Number.isFinite(Ee.duration)&&Ee.duration>0?Ee.duration:0,N=Math.max(0,Math.min(ce,Oe));return await new Promise(H=>{let q=!1,de=0;const he=()=>{q||(q=!0,Ee.removeEventListener("seeked",Ne),window.clearTimeout(de),H())},Ne=()=>{he()},Fe=Number.isFinite(Ee.currentTime)?Ee.currentTime:0;if(Math.abs(Fe-N)<.016){requestAnimationFrame(()=>he());return}Ee.addEventListener("seeked",Ne),de=window.setTimeout(()=>he(),700),Ee.currentTime=N}),na(Ee,b,C.width,C.height)?(M.update(),g.render(),g.canvas):null}async function yt(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await ye()}if(!g||!x||!b||!C||!M)return!1;if(r.filters&&r.filters.length>0){const ce=x.filters,xe=Array.isArray(ce)?ce.length:0,Oe=JSON.stringify(r.filters)!==w;(xe===0||xe!==r.filters.length||Oe)&&Q()}return await e.nextTick(),await new Promise(ce=>{requestAnimationFrame(()=>ce())}),!0}return n({captureFrameAt:st,ensureReadyForCapture:yt,duration:h,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(ce,xe)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:c},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:R.value,onLoadedmetadata:ie,onLoadeddata:me,onCanplay:we,onTimeupdate:ae,onEnded:le,onError:ke,style:e.normalizeStyle(J.value),crossorigin:G.value,preload:"auto",playsinline:"",controls:""},null,44,qf),e.createElementVNode("div",Kf,[e.createElementVNode("button",{class:"play-button",onClick:xe[0]||(xe[0]=Ee=>ce.$emit("play-pause")),"aria-label":ce.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(L.IonIcon),{icon:ce.isPlaying?e.unref(Kl):e.unref(ec)},null,8,["icon"])],8,Qf),e.createElementVNode("div",eh,[e.createElementVNode("span",th,e.toDisplayString(Ze(ce.playhead)),1),xe[1]||(xe[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",nh,e.toDisplayString(Ze(h.value)),1)]),ce.showFps?(e.openBlock(),e.createElementBlock("div",oh,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",ah,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"}),xe[2]||(xe[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",ih,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Vr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:St},"Retry")])):e.createCommentVNode("",!0)],512))}}),Gs=Ve(sh,[["__scopeId","data-v-dd1744f4"]]);var Cr=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},W=(a,n,t)=>(Cr(a,n,"read from private field"),t?t.call(a):n.get(a)),Ie=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},rt=(a,n,t,o)=>(Cr(a,n,"write to private field"),n.set(a,t),t),lh=(a,n,t,o)=>({set _(i){rt(a,n,i)},get _(){return W(a,n,o)}}),$e=(a,n,t)=>(Cr(a,n,"access private method"),t),Re=new Uint8Array(8),qt=new DataView(Re.buffer),tt=a=>[(a%256+256)%256],Pe=a=>(qt.setUint16(0,a,!1),[Re[0],Re[1]]),ch=a=>(qt.setInt16(0,a,!1),[Re[0],Re[1]]),ic=a=>(qt.setUint32(0,a,!1),[Re[1],Re[2],Re[3]]),be=a=>(qt.setUint32(0,a,!1),[Re[0],Re[1],Re[2],Re[3]]),dh=a=>(qt.setInt32(0,a,!1),[Re[0],Re[1],Re[2],Re[3]]),Tn=a=>(qt.setUint32(0,Math.floor(a/2**32),!1),qt.setUint32(4,a,!1),[Re[0],Re[1],Re[2],Re[3],Re[4],Re[5],Re[6],Re[7]]),Nr=a=>(qt.setInt16(0,2**8*a,!1),[Re[0],Re[1]]),Gt=a=>(qt.setInt32(0,2**16*a,!1),[Re[0],Re[1],Re[2],Re[3]]),Ai=a=>(qt.setInt32(0,2**30*a,!1),[Re[0],Re[1],Re[2],Re[3]]),It=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},Va=a=>a&&a[a.length-1],Tr=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Yt=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},rc=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]},sc=rc(0),lc=a=>[Gt(a[0]),Gt(a[1]),Ai(a[2]),Gt(a[3]),Gt(a[4]),Ai(a[5]),Gt(a[6]),Gt(a[7]),Ai(a[8])],ko=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(ko):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,ko(t)])),Hn=a=>a>=0&&a<2**32,Ke=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),je=(a,n,t,o,i)=>Ke(a,[tt(n),ic(t),o??[]],i),uh=a=>{let n=512;return a.fragmented?Ke("ftyp",[It("iso5"),be(n),It("iso5"),It("iso6"),It("mp41")]):Ke("ftyp",[It("isom"),be(n),It("isom"),a.holdsAvc?It("avc1"):[],It("mp41")])},er=a=>({type:"mdat",largeSize:a}),mh=a=>({type:"free",size:a}),pa=(a,n,t=!1)=>Ke("moov",null,[ph(n,a),...a.map(o=>fh(o,n)),t?Zh(a):null]),ph=(a,n)=>{let t=Yt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=Tr(s.samples);return l.presentationTimestamp+l.duration})),or),o=Math.max(...n.map(s=>s.id))+1,i=!Hn(a)||!Hn(t),r=i?Tn:be;return je("mvhd",+i,0,[r(a),r(a),be(or),r(t),Gt(1),Nr(1),Array(10).fill(0),lc(sc),Array(24).fill(0),be(o)])},fh=(a,n)=>Ke("trak",null,[hh(a,n),vh(a,n)]),hh=(a,n)=>{let t=Tr(a.samples),o=Yt(t?t.presentationTimestamp+t.duration:0,or),i=!Hn(n)||!Hn(o),r=i?Tn:be,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?rc(a.info.rotation):a.info.rotation:s=sc,je("tkhd",+i,3,[r(n),r(n),be(a.id),be(0),r(o),Array(8).fill(0),Pe(0),Pe(0),Nr(a.info.type==="audio"?1:0),Pe(0),lc(s),Gt(a.info.type==="video"?a.info.width:0),Gt(a.info.type==="video"?a.info.height:0)])},vh=(a,n)=>Ke("mdia",null,[gh(a,n),yh(a.info.type==="video"?"vide":"soun"),bh(a)]),gh=(a,n)=>{let t=Tr(a.samples),o=Yt(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Hn(n)||!Hn(o),r=i?Tn:be;return je("mdhd",+i,0,[r(n),r(n),be(a.timescale),r(o),Pe(21956),Pe(0)])},yh=a=>je("hdlr",0,0,[It("mhlr"),It(a),be(0),be(0),be(0),It("mp4-muxer-hdlr",!0)]),bh=a=>Ke("minf",null,[a.info.type==="video"?wh():kh(),xh(),Vh(a)]),wh=()=>je("vmhd",0,1,[Pe(0),Pe(0),Pe(0),Pe(0)]),kh=()=>je("smhd",0,0,[Pe(0),Pe(0)]),xh=()=>Ke("dinf",null,[Eh()]),Eh=()=>je("dref",0,0,[be(1)],[Sh()]),Sh=()=>je("url ",0,1),Vh=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Ke("stbl",null,[_h(a),Uh(a),Oh(a),Ph(a),zh(a),jh(a),n?Wh(a):null])},_h=a=>je("stsd",0,0,[be(1)],[a.info.type==="video"?Ch(tv[a.info.codec],a):Dh(ov[a.info.codec],a)]),Ch=(a,n)=>Ke(a,[Array(6).fill(0),Pe(1),Pe(0),Pe(0),Array(12).fill(0),Pe(n.info.width),Pe(n.info.height),be(4718592),be(4718592),be(0),Pe(1),Array(32).fill(0),Pe(24),ch(65535)],[nv[n.info.codec](n),n.info.decoderConfig.colorSpace?Bh(n):null]),Nh={bt709:1,bt470bg:5,smpte170m:6},Th={bt709:1,smpte170m:6,"iec61966-2-1":13},Mh={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Bh=a=>Ke("colr",[It("nclx"),Pe(Nh[a.info.decoderConfig.colorSpace.primaries]),Pe(Th[a.info.decoderConfig.colorSpace.transfer]),Pe(Mh[a.info.decoderConfig.colorSpace.matrix]),tt((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Ih=a=>a.info.decoderConfig&&Ke("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),Fh=a=>a.info.decoderConfig&&Ke("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),$h=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]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return je("vpcC",1,0,[tt(o),tt(i),tt(l),tt(2),tt(2),tt(2),Pe(0)])},Rh=()=>{let t=(1<<7)+1;return Ke("av1C",[t,0,0,0])},Dh=(a,n)=>Ke(a,[Array(6).fill(0),Pe(1),Pe(0),Pe(0),be(0),Pe(n.info.numberOfChannels),Pe(16),Pe(0),Pe(0),Gt(n.info.sampleRate)],[av[n.info.codec](n)]),Ah=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return je("esds",0,0,[be(58753152),tt(32+n.byteLength),Pe(1),tt(0),be(75530368),tt(18+n.byteLength),tt(64),tt(21),ic(0),be(130071),be(130071),be(92307584),tt(n.byteLength),...n,be(109084800),tt(1),tt(2)])},Lh=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 Ke("dOps",[tt(0),tt(a.info.numberOfChannels),Pe(n),be(a.info.sampleRate),Nr(t),tt(0)])},Uh=a=>je("stts",0,0,[be(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[be(n.sampleCount),be(n.sampleDelta)])]),Oh=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return je("stss",0,0,[be(n.length),n.map(([t])=>be(t+1))])},Ph=a=>je("stsc",0,0,[be(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[be(n.firstChunk),be(n.samplesPerChunk),be(1)])]),zh=a=>je("stsz",0,0,[be(0),be(a.samples.length),a.samples.map(n=>be(n.size))]),jh=a=>a.finalizedChunks.length>0&&Va(a.finalizedChunks).offset>=2**32?je("co64",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>Tn(n.offset))]):je("stco",0,0,[be(a.finalizedChunks.length),a.finalizedChunks.map(n=>be(n.offset))]),Wh=a=>je("ctts",0,0,[be(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[be(n.sampleCount),be(n.sampleCompositionTimeOffset)])]),Zh=a=>Ke("mvex",null,a.map(Xh)),Xh=a=>je("trex",0,0,[be(a.id),be(1),be(0),be(0),be(0)]),Js=(a,n)=>Ke("moof",null,[Hh(a),...n.map(Gh)]),Hh=a=>je("mfhd",0,0,[be(a)]),cc=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},Gh=a=>Ke("traf",null,[Jh(a),Yh(a),qh(a)]),Jh=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:cc(t)};return je("tfhd",0,n,[be(a.id),be(o.duration),be(o.size),be(o.flags)])},Yh=a=>je("tfdt",1,0,[Tn(Yt(a.currentChunk.startTimestamp,a.timescale))]),qh=a=>{let n=a.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(g=>g.size),o=a.currentChunk.samples.map(cc),i=a.currentChunk.samples.map(g=>Yt(g.presentationTimestamp-g.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),l=new Set(o),c=new Set(i),d=l.size===2&&o[0]!==o[1],u=r.size>1,m=s.size>1,h=!d&&l.size>1,p=c.size>1||[...c].some(g=>g!==0),y=0;return y|=1,y|=4*+d,y|=256*+u,y|=512*+m,y|=1024*+h,y|=2048*+p,je("trun",1,y,[be(a.currentChunk.samples.length),be(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?be(o[0]):[],a.currentChunk.samples.map((g,x)=>[u?be(n[x]):[],m?be(t[x]):[],h?be(o[x]):[],p?dh(i[x]):[]])])},Kh=a=>Ke("mfra",null,[...a.map(Qh),ev()]),Qh=(a,n)=>je("tfra",1,0,[be(a.id),be(63),be(a.finalizedChunks.length),a.finalizedChunks.map(o=>[Tn(Yt(o.startTimestamp,a.timescale)),Tn(o.moofOffset),be(n+1),be(1),be(1)])]),ev=()=>je("mfro",0,0,[be(0)]),tv={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},nv={avc:Ih,hevc:Fh,vp9:$h,av1:Rh},ov={aac:"mp4a",opus:"Opus"},av={aac:Ah,opus:Lh},La=class{},Mr=class extends La{constructor(){super(...arguments),this.buffer=null}},dc=class extends La{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.")}},iv=class extends La{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")}},bn,On,uc=class{constructor(){this.pos=0,Ie(this,bn,new Uint8Array(8)),Ie(this,On,new DataView(W(this,bn).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){W(this,On).setUint32(0,a,!1),this.write(W(this,bn).subarray(0,4))}writeU64(a){W(this,On).setUint32(0,Math.floor(a/2**32),!1),W(this,On).setUint32(4,a,!1),this.write(W(this,bn).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)W(this,On).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(W(this,bn));a.length%8!==0&&this.write(W(this,bn).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}}};bn=new WeakMap;On=new WeakMap;var fa,Cn,No,go,ha,tr,rv=class extends uc{constructor(a){super(),Ie(this,ha),Ie(this,fa,void 0),Ie(this,Cn,new ArrayBuffer(2**16)),Ie(this,No,new Uint8Array(W(this,Cn))),Ie(this,go,0),rt(this,fa,a)}write(a){$e(this,ha,tr).call(this,this.pos+a.byteLength),W(this,No).set(a,this.pos),this.pos+=a.byteLength,rt(this,go,Math.max(W(this,go),this.pos))}finalize(){$e(this,ha,tr).call(this,this.pos),W(this,fa).buffer=W(this,Cn).slice(0,Math.max(W(this,go),this.pos))}};fa=new WeakMap;Cn=new WeakMap;No=new WeakMap;go=new WeakMap;ha=new WeakSet;tr=function(a){let n=W(this,Cn).byteLength;for(;n<a;)n*=2;if(n===W(this,Cn).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(W(this,No),0),rt(this,Cn,t),rt(this,No,o)};var sv=2**24,lv=2,xo,wn,yo,on,Tt,_a,nr,Br,mc,Ir,pc,Eo,Ca,Fr=class extends uc{constructor(a){var n,t;super(),Ie(this,_a),Ie(this,Br),Ie(this,Ir),Ie(this,Eo),Ie(this,xo,void 0),Ie(this,wn,[]),Ie(this,yo,void 0),Ie(this,on,void 0),Ie(this,Tt,[]),rt(this,xo,a),rt(this,yo,((n=a.options)==null?void 0:n.chunked)??!1),rt(this,on,((t=a.options)==null?void 0:t.chunkSize)??sv)}write(a){W(this,wn).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(W(this,wn).length===0)return;let a=[],n=[...W(this,wn)].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 W(this,wn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);W(this,yo)?($e(this,_a,nr).call(this,i.data,i.start),$e(this,Eo,Ca).call(this)):(o=(t=W(this,xo).options).onData)==null||o.call(t,i.data,i.start)}W(this,wn).length=0}finalize(){W(this,yo)&&$e(this,Eo,Ca).call(this,!0)}};xo=new WeakMap;wn=new WeakMap;yo=new WeakMap;on=new WeakMap;Tt=new WeakMap;_a=new WeakSet;nr=function(a,n){let t=W(this,Tt).findIndex(l=>l.start<=n&&n<l.start+W(this,on));t===-1&&(t=$e(this,Ir,pc).call(this,n));let o=W(this,Tt)[t],i=n-o.start,r=a.subarray(0,Math.min(W(this,on)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if($e(this,Br,mc).call(this,o,s),o.written[0].start===0&&o.written[0].end===W(this,on)&&(o.shouldFlush=!0),W(this,Tt).length>lv){for(let l=0;l<W(this,Tt).length-1;l++)W(this,Tt)[l].shouldFlush=!0;$e(this,Eo,Ca).call(this)}r.byteLength<a.byteLength&&$e(this,_a,nr).call(this,a.subarray(r.byteLength),n+r.byteLength)};Br=new WeakSet;mc=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)};Ir=new WeakSet;pc=function(a){let t={start:Math.floor(a/W(this,on))*W(this,on),data:new Uint8Array(W(this,on)),written:[],shouldFlush:!1};return W(this,Tt).push(t),W(this,Tt).sort((o,i)=>o.start-i.start),W(this,Tt).indexOf(t)};Eo=new WeakSet;Ca=function(a=!1){var n,t;for(let o=0;o<W(this,Tt).length;o++){let i=W(this,Tt)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=W(this,xo).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);W(this,Tt).splice(o--,1)}}};var cv=class extends Fr{constructor(a){var n;super(new dc({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},or=1e3,dv=["avc","hevc","vp9","av1"],uv=["aac","opus"],mv=2082844800,pv=["strict","offset","cross-track-offset"],Ce,Te,Na,Ct,ct,it,Pn,zn,$r,kn,xn,So,ar,fc,ir,hc,Rr,vc,rr,gc,Dr,yc,va,sr,Ht,nn,Ar,bc,Vo,Ta,Ma,Lr,Gn,Io,ga,lr,wc=class{constructor(a){if(Ie(this,ar),Ie(this,ir),Ie(this,Rr),Ie(this,rr),Ie(this,Dr),Ie(this,va),Ie(this,Ht),Ie(this,Ar),Ie(this,Vo),Ie(this,Ma),Ie(this,Gn),Ie(this,ga),Ie(this,Ce,void 0),Ie(this,Te,void 0),Ie(this,Na,void 0),Ie(this,Ct,void 0),Ie(this,ct,null),Ie(this,it,null),Ie(this,Pn,Math.floor(Date.now()/1e3)+mv),Ie(this,zn,[]),Ie(this,$r,1),Ie(this,kn,[]),Ie(this,xn,[]),Ie(this,So,!1),$e(this,ar,fc).call(this,a),a.video=ko(a.video),a.audio=ko(a.audio),a.fastStart=ko(a.fastStart),this.target=a.target,rt(this,Ce,{firstTimestampBehavior:"strict",...a}),a.target instanceof Mr)rt(this,Te,new rv(a.target));else if(a.target instanceof dc)rt(this,Te,new Fr(a.target));else if(a.target instanceof iv)rt(this,Te,new cv(a.target));else throw new Error(`Invalid target: ${a.target}`);$e(this,rr,gc).call(this),$e(this,ir,hc).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($e(this,ga,lr).call(this),!W(this,Ce).video)throw new Error("No video track declared.");if(typeof W(this,Ce).fastStart=="object"&&W(this,ct).samples.length===W(this,Ce).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${W(this,Ce).fastStart.expectedVideoChunks}).`);let s=$e(this,va,sr).call(this,W(this,ct),a,n,t,o,i,r);if(W(this,Ce).fastStart==="fragmented"&&W(this,it)){for(;W(this,xn).length>0&&W(this,xn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=W(this,xn).shift();$e(this,Ht,nn).call(this,W(this,it),l)}s.decodeTimestamp<=W(this,it).lastDecodeTimestamp?$e(this,Ht,nn).call(this,W(this,ct),s):W(this,kn).push(s)}else $e(this,Ht,nn).call(this,W(this,ct),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($e(this,ga,lr).call(this),!W(this,Ce).audio)throw new Error("No audio track declared.");if(typeof W(this,Ce).fastStart=="object"&&W(this,it).samples.length===W(this,Ce).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${W(this,Ce).fastStart.expectedAudioChunks}).`);let r=$e(this,va,sr).call(this,W(this,it),a,n,t,o,i);if(W(this,Ce).fastStart==="fragmented"&&W(this,ct)){for(;W(this,kn).length>0&&W(this,kn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=W(this,kn).shift();$e(this,Ht,nn).call(this,W(this,ct),s)}r.decodeTimestamp<=W(this,ct).lastDecodeTimestamp?$e(this,Ht,nn).call(this,W(this,it),r):W(this,xn).push(r)}else $e(this,Ht,nn).call(this,W(this,it),r)}finalize(){if(W(this,So))throw new Error("Cannot finalize a muxer more than once.");if(W(this,Ce).fastStart==="fragmented"){for(let n of W(this,kn))$e(this,Ht,nn).call(this,W(this,ct),n);for(let n of W(this,xn))$e(this,Ht,nn).call(this,W(this,it),n);$e(this,Ma,Lr).call(this,!1)}else W(this,ct)&&$e(this,Vo,Ta).call(this,W(this,ct)),W(this,it)&&$e(this,Vo,Ta).call(this,W(this,it));let a=[W(this,ct),W(this,it)].filter(Boolean);if(W(this,Ce).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=pa(a,W(this,Pn)),r=W(this,Te).measureBox(i);n=W(this,Te).measureBox(W(this,Ct));let s=W(this,Te).pos+r+n;for(let l of W(this,zn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(W(this,Ct).largeSize=!0)}let t=pa(a,W(this,Pn));W(this,Te).writeBox(t),W(this,Ct).size=n,W(this,Te).writeBox(W(this,Ct));for(let o of W(this,zn))for(let i of o.samples)W(this,Te).write(i.data),i.data=null}else if(W(this,Ce).fastStart==="fragmented"){let n=W(this,Te).pos,t=Kh(a);W(this,Te).writeBox(t);let o=W(this,Te).pos-n;W(this,Te).seek(W(this,Te).pos-4),W(this,Te).writeU32(o)}else{let n=W(this,Te).offsets.get(W(this,Ct)),t=W(this,Te).pos-n;W(this,Ct).size=t,W(this,Ct).largeSize=t>=2**32,W(this,Te).patchBox(W(this,Ct));let o=pa(a,W(this,Pn));if(typeof W(this,Ce).fastStart=="object"){W(this,Te).seek(W(this,Na)),W(this,Te).writeBox(o);let i=n-W(this,Te).pos;W(this,Te).writeBox(mh(i))}else W(this,Te).writeBox(o)}$e(this,Gn,Io).call(this),W(this,Te).finalize(),rt(this,So,!0)}};Ce=new WeakMap;Te=new WeakMap;Na=new WeakMap;Ct=new WeakMap;ct=new WeakMap;it=new WeakMap;Pn=new WeakMap;zn=new WeakMap;$r=new WeakMap;kn=new WeakMap;xn=new WeakMap;So=new WeakMap;ar=new WeakSet;fc=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 La))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!dv.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(!uv.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&&!pv.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.")};ir=new WeakSet;hc=function(){var a;if(W(this,Te).writeBox(uh({holdsAvc:((a=W(this,Ce).video)==null?void 0:a.codec)==="avc",fragmented:W(this,Ce).fastStart==="fragmented"})),rt(this,Na,W(this,Te).pos),W(this,Ce).fastStart==="in-memory")rt(this,Ct,er(!1));else if(W(this,Ce).fastStart!=="fragmented"){if(typeof W(this,Ce).fastStart=="object"){let n=$e(this,Rr,vc).call(this);W(this,Te).seek(W(this,Te).pos+n)}rt(this,Ct,er(!0)),W(this,Te).writeBox(W(this,Ct))}$e(this,Gn,Io).call(this)};Rr=new WeakSet;vc=function(){if(typeof W(this,Ce).fastStart!="object")return;let a=0,n=[W(this,Ce).fastStart.expectedVideoChunks,W(this,Ce).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};rr=new WeakSet;gc=function(){if(W(this,Ce).video&&rt(this,ct,{id:1,info:{type:"video",codec:W(this,Ce).video.codec,width:W(this,Ce).video.width,height:W(this,Ce).video.height,rotation:W(this,Ce).video.rotation??0,decoderConfig:null},timescale:W(this,Ce).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),W(this,Ce).audio&&(rt(this,it,{id:W(this,Ce).video?2:1,info:{type:"audio",codec:W(this,Ce).audio.codec,numberOfChannels:W(this,Ce).audio.numberOfChannels,sampleRate:W(this,Ce).audio.sampleRate,decoderConfig:null},timescale:W(this,Ce).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),W(this,Ce).audio.codec==="aac")){let a=$e(this,Dr,yc).call(this,2,W(this,Ce).audio.sampleRate,W(this,Ce).audio.numberOfChannels);W(this,it).info.decoderConfig={codec:W(this,Ce).audio.codec,description:a,numberOfChannels:W(this,Ce).audio.numberOfChannels,sampleRate:W(this,Ce).audio.sampleRate}}};Dr=new WeakSet;yc=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 l=Math.ceil(s.length/8)*8;s=s.padEnd(l,"0");let c=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)c[d/8]=parseInt(s.slice(d,d+8),2);return c};va=new WeakSet;sr=function(a,n,t,o,i,r,s){let l=o/1e6,c=(o-(s??0))/1e6,d=i/1e6,u=$e(this,Ar,bc).call(this,l,c,a);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:Yt(d,a.timescale)}};Ht=new WeakSet;nn=function(a,n){W(this,Ce).fastStart!=="fragmented"&&a.samples.push(n);const t=Yt(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=Yt(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,W(this,Ce).fastStart!=="fragmented"){let s=Va(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 l=Va(a.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,W(this,Ce).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:Yt(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(W(this,Ce).fastStart==="fragmented"){let r=W(this,ct)??W(this,it);const s=W(this,Ce).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,$e(this,Ma,Lr).call(this))}else o=i>=.5}o&&(a.currentChunk&&$e(this,Vo,Ta).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};Ar=new WeakSet;bc=function(a,n,t){var s,l;const o=W(this,Ce).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
19
|
-
|
|
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(W(this,Ce).firstTimestampBehavior==="offset"||W(this,Ce).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;W(this,Ce).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=W(this,ct))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=W(this,it))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,a-=c}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}};Vo=new WeakSet;Ta=function(a){if(W(this,Ce).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),W(this,zn).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||Va(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),W(this,Ce).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=W(this,Te).pos;for(let n of a.currentChunk.samples)W(this,Te).write(n.data),n.data=null;$e(this,Gn,Io).call(this)}};Ma=new WeakSet;Lr=function(a=!0){if(W(this,Ce).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[W(this,ct),W(this,it)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=lh(this,$r)._++;if(t===1){let l=pa(n,W(this,Pn),!0);W(this,Te).writeBox(l)}let o=W(this,Te).pos,i=Js(t,n);W(this,Te).writeBox(i);{let l=er(!1),c=0;for(let u of n)for(let m of u.currentChunk.samples)c+=m.size;let d=W(this,Te).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=W(this,Te).measureBox(l)+c),l.size=d,W(this,Te).writeBox(l)}for(let l of n){l.currentChunk.offset=W(this,Te).pos,l.currentChunk.moofOffset=o;for(let c of l.currentChunk.samples)W(this,Te).write(c.data),c.data=null}let r=W(this,Te).pos;W(this,Te).seek(W(this,Te).offsets.get(i));let s=Js(t,n);W(this,Te).writeBox(s),W(this,Te).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),W(this,zn).push(l.currentChunk),l.currentChunk=null;a&&$e(this,Gn,Io).call(this)};Gn=new WeakSet;Io=function(){W(this,Te)instanceof Fr&&W(this,Te).flush()};ga=new WeakSet;lr=function(){if(W(this,So))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const To=30;class Jn extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);X(this,"message");X(this,"code");this.code=o,this.message=t}}class an extends Jn{}class qe extends Jn{}class Ba extends Jn{}class Ys extends Jn{}function fv(a,n=To){if(n<1)throw new qe({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function jn(a,n=To){if(n<1)throw new qe({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class ge{constructor(n=0){X(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return fv(this.millis/1e3)}set frames(n){this.millis=jn(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=jn(n);return this.millis=this.millis+t,this}add(n){return new ge(n.millis+this.millis)}subtract(n){return new ge(this.millis-n.millis)}static fromSeconds(n){const t=new ge;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new ge;return o.millis=jn(n,t),o}copy(){return new ge(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new ge(n)}}function qs(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function ya(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function hv(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function Ks(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function vv(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 gv(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),l=i.getChannelData(r),c=a.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,m=Math.floor(u),h=Math.ceil(u);if(h>=s.length)l[d]=s[m];else{const p=u-m;l[d]=s[m]*(1-p)+s[h]*p}}}return i}async function yv(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"],l=[];for(const d of r)for(const u of s)l.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const c=[];if(!("VideoEncoder"in window))return c;for(const d of l){const u=await VideoEncoder.isConfigSupported(d);u.supported&&c.push(u.config??d)}return c.sort(bv)}function bv(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function wv(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 c=0;c<i.length;c++)r[c]=i.charCodeAt(c);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function Qs(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 el(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 oa{constructor(n){X(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 ge}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new ge}}var cr=(a=>(a.en="en",a.de="de",a))(cr||{});class tl{constructor(n,t,o,i){X(this,"id",crypto.randomUUID());X(this,"text");X(this,"start");X(this,"stop");X(this,"confidence");this.text=n,this.start=new ge(t),this.stop=new ge(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class Sn{constructor(n=[],t=cr.en){X(this,"id",crypto.randomUUID());X(this,"language",cr.en);X(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,l]of i.words.entries())r&&(n&&r.words.length>=ya(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=ya(...t)?(yield r,r=void 0):o&&r.text.length>=ya(...o)&&(yield r,r=void 0)),r?r.words.push(l):r=new oa([l]),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=el(i.start.seconds),s=el(i.stop.seconds);o+=`${t}
|
|
22
|
-
`+Qs(r)+" --> "+Qs(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 tl(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new Sn([new oa(i)]);return new Sn([new oa(i)])}copy(){return Sn.fromJSON(this.toJSON())}static fromJSON(n){const t=new Sn;for(const o of n){const i=new oa;for(const r of o)i.words.push(new tl(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 an({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return Sn.fromJSON(await o.json())}}function ba(a,n,t){return a+(n-a)*t}function kv(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,l=o&255,c=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(ba(r,c,t)),h=Math.round(ba(s,d,t)),p=Math.round(ba(l,u,t));return`#${((1<<24)+(m<<16)+(h<<8)+p).toString(16).slice(1)}`}const xv={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 Se{constructor(n,t,o={}){X(this,"input");X(this,"output");X(this,"options");if(n.length!==t.length)throw new qe({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>jn(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=xv[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return ba(o,i,r);if(typeof o=="string"&&typeof i=="string")return kv(o,i,r);if(this.output.length==1)return this.output[0];throw new qe({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(jn(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Se([],[]);return Object.assign(t,n),t}}class Ft{constructor(){X(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 ve(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);X(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 l in this._handlers[t]??{})(r=this._handlers[t])==null||r[l](i);for(const l in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[l](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 Ur(a,n,t=0){if(!(a instanceof ze.Container||a instanceof ze.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Se&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&Ur(i,n,t+1))}}var Ev=Object.defineProperty,Ua=(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&&Ev(n,t,i),i};const $o=class kc extends Fo(Ft){constructor(t={}){super();X(this,"_name");X(this,"_start",new ge);X(this,"_stop",ge.fromSeconds(16));X(this,"type","base");X(this,"source");X(this,"view",new ze.Container);X(this,"createdAt",new Date);X(this,"disabled",!1);X(this,"state","IDLE");X(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",ge.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=ge.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new qe({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new qe({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),Ur(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(o,i+1),o}copy(){return kc.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Ua([ve()],$o.prototype,"_name");Ua([ve(ge)],$o.prototype,"_start");Ua([ve(ge)],$o.prototype,"_stop");Ua([ve()],$o.prototype,"disabled");let Ro=$o;var Sv=Object.defineProperty,In=(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&&Sv(n,t,i),i};class Kt extends Fo(Ft){constructor(){super(...arguments);X(this,"state","IDLE");X(this,"metadata");X(this,"objectURL");X(this,"duration",ge.fromSeconds(16));X(this,"added",!1);X(this,"type","base");X(this,"name","");X(this,"mimeType");X(this,"externalURL");X(this,"external",!1);X(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 qe({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=pr(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 an({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=pr(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();wv(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}In([ve()],Kt.prototype,"objectURL");In([ve()],Kt.prototype,"duration");In([ve()],Kt.prototype,"type");In([ve()],Kt.prototype,"name");In([ve()],Kt.prototype,"mimeType");In([ve()],Kt.prototype,"externalURL");In([ve()],Kt.prototype,"external");const nl="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Vv(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 ol(a){if(!a||!a.body)return nl;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 nl;const s=new XMLSerializer,l=i?s.serializeToString(i):"",c=s.serializeToString(r),d=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${l}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${c}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+Vv(d)}class al extends Kt{constructor(){super();X(this,"type","html");X(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=ol(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=ol(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 _v(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),l=a.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let m=0;m<s.length;m+=o){let h=0;const p=Math.min(m+o,s.length);for(let y=m;y<p;y++)h+=s[y]*s[y];h=Math.sqrt(h/(p-m)),h<t?(u+=o,d===null&&(d=m)):(d!==null&&u>=c&&r.push({start:ge.fromSeconds(d/l),stop:ge.fromSeconds(m/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:ge.fromSeconds(d/l),stop:ge.fromSeconds(s.length/l)}),r}const Li=3e3;class hn extends Kt{constructor(){super(...arguments);X(this,"type","audio");X(this,"decoding",!1);X(this,"_silences");X(this,"transcript");X(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),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let m=0;m<l;m+=c){let h=0;for(let p=m;p<m+s;p++)h+=Math.abs(d[m]);u.push(Math.log1p(h/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,Li,!0),l=s.getChannelData(0),c=Math.floor(Math.max(o*Li/1e3,0)),d=i?Math.floor(Math.min(i*Li/1e3,s.length)):s.length,u=Math.floor((d-c)/t),m=new Float32Array(t);for(let h=0;h<t;h++){const p=c+h*u,y=p+u;let g=-1/0;for(let x=p;x<y;x++){const M=l[x];M>g&&(g=M)}m[h]=r?Math.log2(1+g):g}return m}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=_v(r,t),i.close(),this._silences}}class dr extends Kt{constructor(){super(...arguments);X(this,"type","image")}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-cover w-full aspect-video h-auto",t}}class Vn extends hn{constructor(){super(...arguments);X(this,"type","video");X(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new an({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=pr(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 qe({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),l=i==null?void 0:i.duration;l&&r&&r.width>0&&(i.currentTime=Math.round(l*(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 Cv{static fromJSON(n){return[new ge(n[0]),new ge(n[1])]}}var Nv=Object.defineProperty,Tv=Object.getOwnPropertyDescriptor,qn=(a,n,t,o)=>{for(var i=o>1?void 0:o?Tv(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&&Nv(n,t,i),i};const Fn=class xc extends Ro{constructor(t={}){super();X(this,"source",new hn);X(this,"_offset",new ge);X(this,"playing",!1);X(this,"duration",new ge);X(this,"range",[new ge,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=ge.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=ge.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",ge.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 Ys({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=ge.fromFrames(t)),typeof o=="number"&&(o=ge.fromFrames(o)),t.millis>=o.millis)throw new qe({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=xc.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=ge.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new qe({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ys({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),Ur(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.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 qe({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=>il(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(o.length==0)return[this];const i=t.padding??500,r=[this];for(const s of o){const l=r.at(-1);if(!l)break;if(!il(s,l.range))continue;const c=new ge(Math.min(s.start.millis+i,s.stop.millis));if(s.start.millis>l.range[0].millis&&s.stop.millis<l.range[1].millis){const d=l.copy();l.range[1]=c,d.range[0]=s.stop,r.push(d)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=c)}return r}};qn([ve(ge)],Fn.prototype,"_offset",2);qn([ve(ge)],Fn.prototype,"duration",2);qn([ve(Cv)],Fn.prototype,"range",2);qn([ve(Sn)],Fn.prototype,"transcript",1);qn([ve()],Fn.prototype,"muted",1);qn([ve()],Fn.prototype,"volume",1);let Oa=Fn;function il(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 aa{static fromJSON(n){return typeof n=="object"?Se.fromJSON(n):n}}class Ui{static fromJSON(n){return typeof n.x=="object"&&(n.x=Se.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Se.fromJSON(n.y)),n}}let Mv=class{constructor(a){X(this,"target");X(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 Se(i,r,{easing:o})}};function Bv(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new qe({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new ge(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 Iv extends Mv{}var Fv=Object.defineProperty,$v=Object.getOwnPropertyDescriptor,mn=(a,n,t,o)=>{for(var i=o>1?void 0:o?$v(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&&Fv(n,t,i),i};function Pa(a){class n extends a{constructor(){super(...arguments);X(this,"filters");X(this,"_height");X(this,"_width");X(this,"_position",{x:this.view.position.x,y:this.view.position.y});X(this,"_scale");X(this,"rotation",this.view.angle);X(this,"alpha",1);X(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 Se||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof ze.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(i){const r=typeof i=="number"?{x:i,y:i}:i;for(const s of this.view.children)s instanceof ze.Sprite&&s.anchor.set(r.x,r.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return Bv(new Iv(this))}}return mn([ve(aa)],n.prototype,"_height",2),mn([ve(aa)],n.prototype,"_width",2),mn([ve(Ui)],n.prototype,"_position",2),mn([ve(Ui)],n.prototype,"_scale",2),mn([ve(aa)],n.prototype,"rotation",2),mn([ve(aa)],n.prototype,"alpha",2),mn([ve(Ui)],n.prototype,"translate",2),mn([ve()],n.prototype,"anchor",1),n}function za(a,n,t){const o=t.value;return t.value=function(...i){var m,h,p,y;const r=i[0].subtract(this.start),s={width:((h=(m=this.track)==null?void 0:m.composition)==null?void 0:h.width)??1920,height:((y=(p=this.track)==null?void 0:p.composition)==null?void 0:y.height)??1080};let l;typeof this.translate.x=="number"?l=this.translate.x:typeof this.translate.x=="function"?l=this.translate.x.bind(this)(r):l=this.translate.x.value(r);let c;typeof this.translate.y=="number"?c=this.translate.y:typeof this.translate.y=="function"?c=this.translate.y.bind(this)(r):c=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+l,u+c),typeof this._height=="string"?this.view.height=Math.round(Number.parseFloat(this._height)*s.height/100):typeof this._height=="object"?this.view.height=this._height.value(r):typeof this._height=="function"?this.view.height=this._height.bind(this)(r):this._height&&(this.view.height=this._height),this._height&&!this._width&&this.view.scale.set(this.view.scale.y),typeof this._width=="string"?this.view.width=Math.round(Number.parseFloat(this._width)*s.width/100):typeof this._width=="object"?this.view.width=this._width.value(r):typeof this._width=="function"?this.view.width=this._width.bind(this)(r):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let g;typeof this._scale.x=="number"?g=this._scale.x:typeof this._scale.x=="function"?g=this._scale.x.bind(this)(r):g=this._scale.x.value(r);let x;typeof this._scale.y=="number"?x=this._scale.y:typeof this._scale.y=="function"?x=this._scale.y.bind(this)(r):x=this._scale.y.value(r),(this._width||this._height)&&(g*=this.view.scale._x,x*=this.view.scale._y),this.view.scale.set(g,x)}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 Rv=Object.defineProperty,Dv=Object.getOwnPropertyDescriptor,Av=(a,n,t,o)=>{for(var i=Dv(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Rv(n,t,i),i};const Ec=class Sc extends Pa(Ro){constructor(t,o={}){super();X(this,"type","image");X(this,"element",new Image);X(this,"source",new dr);X(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),t instanceof dr&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,o)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{this.sprite.texture=ze.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new an({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Sc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Av([za],Ec.prototype,"update");let Lv=Ec;const ia={"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 Uv=Object.defineProperty,ja=(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&&Uv(n,t,i),i};const Do=class ur extends Fo(Ft){constructor(t){super();X(this,"loaded",!1);X(this,"family");X(this,"weight");X(this,"source");X(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=ur.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(ia).map(t=>({family:t,variants:ia[t].weights.map(o=>({family:t,source:`url(${ia[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new ur({family:t,source:`url(${ia[t].url})`,weight:o})}};ja([ve()],Do.prototype,"family");ja([ve()],Do.prototype,"weight");ja([ve()],Do.prototype,"source");ja([ve()],Do.prototype,"style");let pt=Do;const Jt=4,Vc={center:.5,justify:.5,left:0,right:1},_c={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Ov=Object.defineProperty,Pv=Object.getOwnPropertyDescriptor,Et=(a,n,t,o)=>{for(var i=Pv(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ov(n,t,i),i};const gt=class Cc extends Pa(Ro){constructor(t){super();X(this,"type","text");X(this,"_text","");X(this,"_textCase");X(this,"_anchor",{x:0,y:0});X(this,"_font",new pt);X(this,"style",new ze.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const o=new ze.Text({text:this.transformedText,style:this.style,resolution:Jt,scale:Jt});this.view.addChild(o)}this.view.children[0]instanceof ze.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*Jt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Jt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Vc[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=_c[t]}get fillStyle(){const{fill:t}=this.style;return new ze.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:o=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new ze.Color(t).toHex().toUpperCase(),{color:t,alpha:o,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:o="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:o,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof ze.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:o,blur:i,color:r,distance:s}=this.style.dropShadow,l=new ze.Color(r).toHex().toUpperCase();return{alpha:t,angle:o,blur:i,color:l,distance:s}}set shadow(t){t?this.style.dropShadow=t:this.style.dropShadow=!1}get fontFamily(){return Array.isArray(this.style.fontFamily)?this.style.fontFamily[0]:this.style.fontFamily}get fontSize(){return this.style.fontSize}set fontSize(t){this.style.fontSize=t}get leading(){return this.style.leading}set leading(t){this.style.leading=t}update(t){}copy(){const t=Cc.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,l;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=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Jt;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};Et([ve()],gt.prototype,"text");Et([ve(pt)],gt.prototype,"font");Et([ve()],gt.prototype,"maxWidth");Et([ve()],gt.prototype,"textAlign");Et([ve()],gt.prototype,"padding");Et([ve()],gt.prototype,"textBaseline");Et([ve()],gt.prototype,"fillStyle");Et([ve()],gt.prototype,"anchor");Et([ve()],gt.prototype,"stroke");Et([ve()],gt.prototype,"textCase");Et([ve()],gt.prototype,"shadow");Et([ve()],gt.prototype,"fontSize");Et([ve()],gt.prototype,"leading");Et([za],gt.prototype,"update");let Kn=gt;function Oi(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const zv={get(a,n){const t=a[n];return typeof t=="number"?t*Jt:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*Jt):t}};function jv(a){return new Proxy(a,zv)}class Wv{constructor(){X(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 rl{constructor(){X(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 Zv{static fromJSON(n){return n.map(t=>(t.font&&(t.font=pt.fromJSON(t.font)),t))}}var Xv=Object.defineProperty,Hv=Object.getOwnPropertyDescriptor,Qn=(a,n,t,o)=>{for(var i=o>1?void 0:o?Hv(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&&Xv(n,t,i),i};const $n=class Nc extends Kn{constructor(t){super();X(this,"type","complex_text");X(this,"_maxWidth");X(this,"_textAlign","left");X(this,"_textBaseline","top");X(this,"model",new ze.Container);X(this,"segments",[]);X(this,"metrics",new rl);X(this,"background");X(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=Vc[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=_c[t];let o=0;for(const i of this.metrics.lines){const r=i.height;for(const s of i.tokens){let l=0;t=="middle"&&(l=(r-s.metrics.lineHeight)/2),t=="bottom"&&(l=r-s.metrics.lineHeight),this.model.children[s.index].y=o+l}o+=r}}copy(){const t=Nc.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:Oi(o.substring(0,(r=t==null?void 0:t.at(0))==null?void 0:r.start))}];for(let l=0;l<t.length;l++)i.push({index:t[l].index,tokens:Oi(o.substring(t[l].start,t[l].stop))}),!((t[l].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:Oi(o.substring(t[l].stop,(s=t.at(l+1))==null?void 0:s.start))});return i.filter(l=>l.tokens.join("").trim().length)}createTextMetrics(t,o){var r,s,l;const i=new rl;for(const c of t){const d=c.index!=null?o[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const m=jv(ze.CanvasTextMetrics.measureText(c.tokens[u],d)),h=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,y=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(h>p||y||!i.lines.length)&&i.lines.push(new Wv),this.model.addChild(new ze.Text({text:c.tokens[u],style:d,resolution:Jt,scale:Jt})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var l,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((l=this.background.padding)==null?void 0:l.x)??40,r=((c=this.background.padding)==null?void 0:c.y)??10,s=new ze.Graphics;s.roundRect(0-i/2,2-r/2,t+i,o+r,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var l;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=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Jt;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Qn([ve()],$n.prototype,"background",2);Qn([ve(Zv)],$n.prototype,"styles",2);Qn([ve()],$n.prototype,"text",1);Qn([ve()],$n.prototype,"maxWidth",1);Qn([ve()],$n.prototype,"textAlign",1);Qn([ve()],$n.prototype,"textBaseline",1);let Wa=$n;const Tc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Gv=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),sl=typeof self<"u"&&self.Blob&&new Blob([Gv(Tc)],{type:"text/javascript;charset=utf-8"});function Jv(a){let n;try{if(n=sl&&(self.URL||self.webkitURL).createObjectURL(sl),!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,"+Tc,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class Yv{constructor(){X(this,"frames",[]);X(this,"state","active");X(this,"onenqueue");X(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 qv(a,n,t){const o=t.value;return t.value=function(...i){var r,s,l,c;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),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var Kv=Object.defineProperty,Qv=Object.getOwnPropertyDescriptor,e0=(a,n,t,o)=>{for(var i=Qv(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Kv(n,t,i),i};const Mc=class Bc extends Pa(Oa){constructor(t,o={}){super();X(this,"source",new Vn);X(this,"type","video");X(this,"worker");X(this,"buffer");X(this,"canvas",document.createElement("canvas"));X(this,"context",this.canvas.getContext("2d"));X(this,"element",document.createElement("video"));X(this,"textrues",{html5:ze.Texture.from(this.element),canvas:ze.Texture.from(this.canvas)});X(this,"sprite",new ze.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof Vn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new an({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(ge.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,l,c;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((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=Bc.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 Yv,this.worker=new Jv,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)??To}),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}};e0([za,qv],Mc.prototype,"update");let mr=Mc;class Ia extends Oa{constructor(t,o={}){super();X(this,"type","audio");X(this,"source",new hn);X(this,"element",new Audio);t instanceof hn&&(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 an({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,o,i,r,s,l;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():!((l=(s=this.track)==null?void 0:s.composition)!=null&&l.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=Ia.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const t0={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 pr(a){if(!Object.keys(t0.MIXED).includes(a??""))throw new qe({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var n0=Object.defineProperty,o0=Object.getOwnPropertyDescriptor,a0=(a,n,t,o)=>{for(var i=o0(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&n0(n,t,i),i};const i0=class Ic extends Pa(Ro){constructor(t,o={}){super();X(this,"type","html");X(this,"source",new al);X(this,"element",new Image);X(this,"canvas",document.createElement("canvas"));X(this,"context",this.canvas.getContext("2d"));X(this,"sprite",new ze.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof al&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;!i||!r||(this.canvas.width=i,this.canvas.height=r,this.context.imageSmoothingEnabled=!1,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(this.element,0,0),this.sprite.texture=ze.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new an({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,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new an({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new an({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Ic.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};a0([za],i0.prototype,"update");const Fc=["DEFAULT","STACK"];class ll{constructor(){X(this,"mode",Fc[0]);X(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=ul(n,t.clips[i]),!!o);i++)dl(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(cl))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(cl);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!ul(n,t.clips[o]))break;dl(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class r0{constructor(){X(this,"mode",Fc[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 ge(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 ge(r))}o=i.stop.millis+1}}offset(){}}function cl(a,n){return a.start.millis-n.start.millis}function dl(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 ul(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const l=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(c=>c.type==a.type&&!c.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return l?(l.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 eo extends Fo(Ft){constructor(){super(...arguments);X(this,"_disabled",!1);X(this,"view",new ze.Container);X(this,"clips",[]);X(this,"pointer",0);X(this,"composition");X(this,"type","base");X(this,"strategy",new ll)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&zi(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 r0,this.strategy.update(new Ro,this)):this.strategy=new ll,this.trigger("update",void 0),this}layer(t){var l,c;const o=((l=this.composition)==null?void 0:l.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,hv(o,i,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(ge.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(zi(this.clipRef)&&(!Pi(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!Pi(o,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(Pi(o,c)&&!c.disabled)return this.pointer=l,zi(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(o<c.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;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 ge}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new ge}apply(t){this.clips.forEach(t)}detach(){var t;return(t=this.composition)==null||t.removeTrack(this),this}get clipRef(){return this.clips[this.pointer]}}function Pi(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function zi(a){return a?!!a.view.parent:!1}class s0{static fromType(n){switch(n.type){case"video":return new l0;case"audio":return new d0;case"html":return new u0;case"image":return new c0;case"text":return new ml;case"complex_text":return new ml;case"caption":return new p0;default:return new eo}}}class $c extends eo{constructor(){super(...arguments);X(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 l0 extends $c{constructor(){super(...arguments);X(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class c0 extends eo{constructor(){super(...arguments);X(this,"type","image")}}class d0 extends $c{constructor(){super(...arguments);X(this,"type","audio")}}class ml extends eo{constructor(){super(...arguments);X(this,"type","text")}}class u0 extends eo{constructor(){super(...arguments);X(this,"type","html")}}var m0=Object.defineProperty,Or=(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&&m0(n,t,i),i};class Ao extends Ft{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","CLASSIC");X(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new Kn({text:c.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:c.stop.add(o),start:c.start.add(o),scale:new Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"})}))}}Or([ve()],Ao.prototype,"generatorOptions");Or([ve()],Ao.prototype,"type");Or([ve()],Ao.prototype,"position");class p0 extends eo{constructor(){super(...arguments);X(this,"clip");X(this,"type","caption");X(this,"preset",new Ao)}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 f0=Object.defineProperty,Za=(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&&f0(n,t,i),i};class Lo extends Ft{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","SPOTLIGHT");X(this,"color");X(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,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Wa({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:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}Za([ve()],Lo.prototype,"generatorOptions");Za([ve()],Lo.prototype,"type");Za([ve()],Lo.prototype,"color");Za([ve()],Lo.prototype,"position");var h0=Object.defineProperty,Pr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&h0(n,t,i),i};class Xa extends Ft{constructor(t={}){super();X(this,"type","GUINEA");X(this,"colors");X(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l,c,d,u,m;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const h of t.clip.transcript.iter({length:[18]})){const{segments:p,words:y}=this.splitSequence(h);for(let g=0;g<h.words.length;g++){const x=(d=(c=y[g])==null?void 0:c.at(0))==null?void 0:d.start,M=(m=(u=y[g])==null?void 0:u.at(-1))==null?void 0:m.stop;!x||!M||await t.add(new Wa({text:p.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:M.add(o),start:x.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:ya(0,2),start:p.slice(0,g).join(" ").length,stop:p.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(o[c].match(/ /)){r=c;break}if(o[d].match(/ /)){r=d;break}}const s=[...qs(o,r).map(c=>c.trim())],l=qs(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}Pr([ve()],Xa.prototype,"type");Pr([ve()],Xa.prototype,"colors");Pr([ve()],Xa.prototype,"position");var v0=Object.defineProperty,zr=(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&&v0(n,t,i),i};class Ha extends Ft{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","CASCADE");X(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(m=>m.text).slice(0,d+1).join(" ");await t.add(new Kn({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:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}zr([ve()],Ha.prototype,"generatorOptions");zr([ve()],Ha.prototype,"type");zr([ve()],Ha.prototype,"position");var g0=Object.defineProperty,jr=(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&&g0(n,t,i),i};class Ga extends Ft{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","SOLAR");X(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,c;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await pt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new ge,r=new Ku.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Kn({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 Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}jr([ve()],Ga.prototype,"generatorOptions");jr([ve()],Ga.prototype,"type");jr([ve()],Ga.prototype,"position");var y0=Object.defineProperty,Ja=(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&&y0(n,t,i),i};class Uo extends Ft{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","WHISPER");X(this,"color");X(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,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Wa({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:13,background:{alpha:.3,padding:{x:50,y:30}},maxWidth:t.composition.width*.8,font:i,position:this.position,styles:[{fillStyle:this.color}],stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Ja([ve()],Uo.prototype,"generatorOptions");Ja([ve()],Uo.prototype,"type");Ja([ve()],Uo.prototype,"color");Ja([ve()],Uo.prototype,"position");var b0=Object.defineProperty,Ya=(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&&b0(n,t,i),i};class qa extends Ft{constructor(t={}){super();X(this,"type","VERDANT");X(this,"generatorOptions");X(this,"color");X(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,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new qe({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await pt.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Wa({text:u.join(" "),textAlign:"center",textBaseline:"middle",fontSize:15,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:4,alpha:.7,angle:Math.PI/4,distance:2},stroke:{width:3,color:"#000000"},maxWidth:t.composition.width*.5,leading:1.1,font:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Ya([ve()],qa.prototype,"type");Ya([ve()],qa.prototype,"generatorOptions");Ya([ve()],qa.prototype,"color");Ya([ve()],qa.prototype,"position");class w0 extends Fo(Ft){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();X(this,"_duration",new ge);X(this,"renderer");X(this,"stage",new ze.Container);X(this,"settings");X(this,"tracks",[]);X(this,"frame",0);X(this,"fixedDuration");X(this,"state","IDLE");X(this,"fps",To);X(this,"canvas");X(this,"context");this.settings={height:t,width:o,background:i,backend:r},this.on("update",this.update.bind(this)),this.on("attach",this.update.bind(this)),this.on("detach",this.update.bind(this)),this.on("load",this.update.bind(this)),this.on("frame",this.update.bind(this)),this.on("error",this.update.bind(this)),ze.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Jn({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 ge?this.fixedDuration=t:this.fixedDuration=ge.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=s0.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 Ks(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;Ks(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(ge.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 Jn({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(ge.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(ge.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 l of this.findClips(Oa)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*r.sampleRate),d=Math.round(l.range[0].seconds*r.sampleRate),u=Math.round(l.range[1].seconds*r.sampleRate);try{const m=await l.source.decode(t,o),h=m.numberOfChannels-1;for(let p=0;p<t;p++){const y=r.getChannelData(p),g=m.getChannelData(p>h?h:p);for(let x=0;x<y.length-1;x++)x<c+d||x>c+u||x-c<0||(y[x]+=(g[x-c]??0)*l.volume,y[x]>1&&(y[x]=1),y[x]<-1&&(y[x]=-1));r.getChannelData(p).set(y)}}catch{}}return r}time(t){const o=jn(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/To;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 k0(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 fr=[8e3,12e3,16e3,24e3,48e3],x0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",E0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class S0{constructor(n){X(this,"output");X(this,"error");X(this,"config");X(this,"encoder");X(this,"opus");X(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(E0),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!fr.includes(i))throw new Ba({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${fr.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?x0:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:k0(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 Ba({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let l=0;const c=s/i*1e6;for(;l<t;){const d=n.subarray(l*r,(l+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const m=4e3,h=this.opus._malloc(m),p=this.opus._opus_encode(this.encoder,u,s,h,m);if(p>0){const y=new Uint8Array(this.opus.HEAPU8.subarray(h,h+p));this.output({data:y,timestamp:o,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(h),l+=s,o+=c}}}function V0(a){const n=fr;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class _0{constructor(n,t){X(this,"canvas");X(this,"muxer");X(this,"videoEncoder");X(this,"frame",0);X(this,"sampleRate");X(this,"numberOfChannels");X(this,"videoBitrate");X(this,"gpuBatchSize");X(this,"fps");X(this,"height");X(this,"width");X(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=V0((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 yv({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new wc({target:new Mr,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 Ba({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=gv(n,this.sampleRate,this.numberOfChannels),o=new S0({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:vv(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 Ba({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 C0(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 Dt(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 ra(a){return a>5?a/100:a}function At(a,n,t){return Math.min(t,Math.max(n,a))}function wt(){return new Ye.ColorMatrixFilter}function N0(a,n){switch(a){case"brightness":{const t=wt(),o=Dt(n.value??n.brightness,1);return t.brightness(At(ra(o),0,5),!1),t}case"contrast":{const t=wt(),o=Dt(n.value??n.contrast,1);return t.contrast(At(ra(o),0,5),!1),t}case"saturation":{const t=wt(),o=Dt(n.value??n.saturation,1);return t.saturate(At(ra(o),0,5),!1),t}case"hue":{const t=wt(),o=Dt(n.degrees??n.value,0);return t.hue(At(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=Dt(n.radius??n.blur??n.value,t);return new Ye.BlurFilter({strength:At(o,0,32),quality:4})}case"grayscale":{const t=wt(),o=At(Dt(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(At(Dt(n.amount,100),0,100)<=0)return null;const o=wt();return o.sepia(!1),o}case"invert":{if(At(Dt(n.amount,100),0,100)<=0)return null;const o=wt();return o.negative(!1),o}case"warmth":{const t=wt(),o=At(Dt(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=wt(),o=At(Dt(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,l=parseInt(r.slice(2,4),16)/255,c=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=wt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=wt(),o=At(ra(Dt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=wt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=wt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=wt();return t.brightness(1.05,!1),t.saturate(.9,!1),t.contrast(.95,!1),t}default:return null}}typeof window<"u"&&!window.PIXI&&(window.PIXI=Ye);class Rc{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 w0({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 c,d,u,m;const l=this.composition;((d=(c=l==null?void 0:l.app)==null?void 0:c.renderer)!=null&&d.view||(u=l==null?void 0:l.renderer)!=null&&u.view||(m=l==null?void 0:l.renderer)!=null&&m.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...n){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await C0(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(n,t){var o,i;try{const r=n.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((o=Vn.from)==null?void 0:o.call(Vn,r,{crossOrigin:"anonymous"}))??await Vn.from(r),l=new mr(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let c=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const h=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),p=n.sourceOut!==void 0?Math.max(h+1,Math.floor(n.sourceOut*this.fps)):null;c=h,d=p;try{if(l.offset=l.offset||{frames:0},l.offset.frames=h,p!==null){const y=Math.max(1,p-h);l.duration=l.duration||{frames:y},l.duration.frames=y}}catch{}}const u=await this.composition.add(l);if(d!==null&&c>=0)try{const h=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:h},u.duration.frames=h}catch{}const m=Math.floor(n.timelineStart*this.fps);m>0&&u.offsetBy(m),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(h=>requestAnimationFrame(h)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=pt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new Kn({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,l=r*this.fps,c=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Se([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Se([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}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(c=>c.id));for(const[c,d]of i.entries())if(!r.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=i.get(c.id);let m=null;if(u&&u.signature===d)m=u.instance;else{if(u)try{u.instance.destroy()}catch{}m=this.createPixiFilter(c),m?i.set(c.id,{instance:m,signature:d}):i.delete(c.id)}m&&s.push(m)}this.filterCache.set(n,i);const l=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(l&&"filters"in l)try{l.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(dt.getFilter(n.filterId)&&!dt.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=rm(n.filterId,o);return r||(r=N0(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,l,c,d,u,m,h,p,y;const t=n.fps??this.fps,o=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((h=(m=this.composition)==null?void 0:m.renderer)==null?void 0:h.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(p=n.onProgress)==null||p.call(n,0);const i=new _0(o,{fps:t});await i.init();const r=await i.export();return(y=n.onProgress)==null||y.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,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),c=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),c=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=l+c;if(n>=l&&n<d){const u=n-l;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const T0=["src"],M0={class:"preview-controls"},B0=["aria-label"],I0={class:"time-display"},F0={class:"current-time"},$0={class:"total-time"},R0={key:2,class:"loading-overlay"},D0={key:3,class:"error-overlay"},A0=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(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),m=e.ref(0),h=e.ref(0);let p=null;const y=e.computed(()=>!!t.enableEngine&&!!t.recipe),g=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),x=e.computed(()=>{var S,D;return(S=t.media)!=null&&S.url?t.media.url:(((D=t.media)==null?void 0:D.file)instanceof File,"")});async function M(){var S,D,I;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const j=((S=t.recipe.source)==null?void 0:S.original_width)||1920,$=((D=t.recipe.source)==null?void 0:D.original_height)||1080,P=((I=t.recipe.output)==null?void 0:I.fps)||30;p=new Rc(j,$,P,{fitMode:t.fitMode}),p.attachPlayer(r.value),c.value="Loading composition...",await p.loadFromRecipe(t.recipe),h.value=p.durationInSeconds,o("duration-change",h.value),C(),l.value=!1,o("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(j){const $=j instanceof Error?j.message:String(j);d.value=`Failed to initialize: ${$}`,l.value=!1}}function C(){if(!p)return;const S=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,o("time-update",m.value))},100);U.value=S}function b(){y.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,o("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,o("play-state-change",u.value))}function f(S){const D=Math.floor(S/60),I=Math.floor(S%60);return`${D}:${I.toString().padStart(2,"0")}`}function w(){d.value=null,y.value&&M()}function F(){!y.value&&s.value&&(h.value=s.value.duration,o("duration-change",h.value))}function T(){!y.value&&s.value&&(m.value=s.value.currentTime,o("time-update",m.value))}function E(){u.value=!1,o("play-state-change",!1)}function B(S){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{y.value&&t.recipe&&M()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),U.value&&(clearInterval(U.value),U.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async S=>{if(y.value&&S)if(p)try{await p.loadFromRecipe(S),h.value=p.durationInSeconds,o("duration-change",h.value)}catch{}else await M()}),e.watch(()=>t.enableEngine,async S=>{S?await M():p&&(U.value&&(clearInterval(U.value),U.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async S=>{if(!(!y.value||!p))try{p.setFitMode(S||"contain")}catch{}});const U=e.ref(null);return(S,D)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[y.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:x.value,onLoadedmetadata:F,onTimeupdate:T,onEnded:E,onError:B,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,T0)),e.createElementVNode("div",M0,[e.createElementVNode("button",{class:"play-button",onClick:b,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(L.IonIcon),{icon:u.value?e.unref(Kl):e.unref(ec)},null,8,["icon"])],8,B0),e.createElementVNode("div",I0,[e.createElementVNode("span",F0,e.toDisplayString(f(m.value)),1),D[0]||(D[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",$0,e.toDisplayString(f(h.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",R0,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",D0,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Vr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:w},"Retry")])):e.createCommentVNode("",!0)],512))}}),pl=Ve(A0,[["__scopeId","data-v-7e604791"]]),L0=["aria-label"],U0=["aria-label"],O0={class:"clip-content"},P0={key:0,class:"clip-thumbnail"},z0=["src","alt"],j0={class:"clip-waveform"},W0={class:"clip-info"},Z0={class:"clip-label"},X0={class:"clip-duration"},H0={key:1,class:"filter-indicators"},G0={key:2,class:"speed-indicator"},J0={key:0,class:"selection-overlay"},Y0=420,q0=8,K0=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["select","long-press","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),l=e.ref(0),c=e.ref(0),d=e.ref(0),u=e.ref(0),m=e.ref(!1),h=e.ref(!1),p=e.ref(null),y=e.computed(()=>{const V=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${V}px`}}),g=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),x=e.computed(()=>{const O=t.clip.timelineEnd-t.clip.timelineStart;return b(O)}),M=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),C=e.computed(()=>t.clip.filters||[]);function b(O){if(O<1)return`${Math.round(O*30)}f`;if(O<60)return`${O.toFixed(1)}s`;{const V=Math.floor(O/60),R=Math.floor(O%60);return`${V}:${R.toString().padStart(2,"0")}`}}function f(O){return!O||typeof O!="string"?Zs:O.includes("color")||O.includes("brightness")?fn:O.includes("blur")?Dm:O.includes("style")?ho:O.includes("effect")?pn:Zs}function w(){r.value||o("select")}function F(O){O.button===0&&(B("move",O.clientX),O.preventDefault())}function T(O){if(O.touches.length!==1)return;const V=O.touches[0];if(!t.isMobile){B("move",V.clientX),O.preventDefault();return}d.value=V.clientX,u.value=V.clientY,m.value=!1,h.value=!1,U(),S(),p.value=window.setTimeout(()=>{h.value=!0,S(),t.selected||o("select"),o("long-press")},Y0),document.addEventListener("touchmove",D),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),O.preventDefault()}function E(O,V){const R="touches"in V?V.touches[0].clientX:V.clientX;s.value=O==="start"?"trim-start":"trim-end",B(s.value,R),V.preventDefault(),V.stopPropagation()}function B(O,V){U(),S(),r.value=!0,s.value=O,l.value=V,O==="move"?c.value=t.clip.timelineStart:O==="trim-start"?c.value=t.clip.sourceIn:O==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",j),document.addEventListener("mouseup",$),document.addEventListener("touchmove",j),document.addEventListener("touchend",$),t.selected||o("select")}function U(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function S(){document.removeEventListener("touchmove",D),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}function D(O){if(O.touches.length!==1)return;const V=O.touches[0],R=V.clientX-d.value,G=V.clientY-u.value;Math.hypot(R,G)<q0||(m.value=!0,U(),S(),B("move",V.clientX),j(O),O.preventDefault())}function I(){const O=!m.value&&!h.value&&!r.value;U(),S(),m.value=!1,h.value=!1,O&&o("select")}function j(O){if(!r.value||!s.value)return;const V="touches"in O?O.touches[0].clientX:O.clientX,G=V-l.value;s.value==="move"?(o("drag",G),o("drag-abs",V)):s.value==="trim-start"?(o("trim-start",G),o("trim-start-abs",V)):s.value==="trim-end"&&(o("trim-end",G),o("trim-end-abs",V))}function $(){r.value=!1,s.value=null,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",$),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",$)}function P(){if(!i.value)return;const O=i.value,V=O.getContext("2d");if(!V)return;O.width=O.clientWidth*window.devicePixelRatio,O.height=O.clientHeight*window.devicePixelRatio,V.scale(window.devicePixelRatio,window.devicePixelRatio),V.strokeStyle="rgba(255, 255, 255, 0.3)",V.lineWidth=1,V.beginPath();const R=O.clientWidth,G=O.clientHeight,J=G/2;V.moveTo(0,J),V.lineTo(R,J);for(let te=0;te<R;te+=4){const fe=Math.sin(te*.05)*(G*.3);V.moveTo(te,J-fe),V.lineTo(te,J+fe)}V.stroke()}return e.onMounted(()=>{P(),window.addEventListener("resize",P)}),e.onUnmounted(()=>{$(),U(),S(),window.removeEventListener("resize",P)}),(O,V)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:O.selected,mobile:O.isMobile,"has-filters":M.value}]),style:e.normalizeStyle(y.value),onClick:w,onMousedown:F,onTouchstart:T},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:V[0]||(V[0]=e.withModifiers(R=>E("start",R),["stop"])),onTouchstart:V[1]||(V[1]=e.withModifiers(R=>E("start",R),["stop"])),"aria-label":`Trim start of ${O.clip.label||"clip"}`},[...V[4]||(V[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,L0),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:V[2]||(V[2]=e.withModifiers(R=>E("end",R),["stop"])),onTouchstart:V[3]||(V[3]=e.withModifiers(R=>E("end",R),["stop"])),"aria-label":`Trim end of ${O.clip.label||"clip"}`},[...V[5]||(V[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,U0),e.createElementVNode("div",O0,[O.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",P0,[e.createElementVNode("img",{src:O.clip.thumbnail,alt:O.clip.label||"Video clip"},null,8,z0)])):e.createCommentVNode("",!0),e.createElementVNode("div",j0,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",W0,[e.createElementVNode("span",Z0,e.toDisplayString(g.value),1),e.createElementVNode("span",X0,e.toDisplayString(x.value),1)]),M.value?(e.openBlock(),e.createElementBlock("div",H0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,R=>(e.openBlock(),e.createBlock(e.unref(L.IonIcon),{key:R.id||R.filterId,icon:f(R.filterId||R.id),title:`Filter: ${R.filterId||R.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),O.clip.speed&&O.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",G0,e.toDisplayString(O.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),O.selected?(e.openBlock(),e.createElementBlock("div",J0)):e.createCommentVNode("",!0)],38))}}),Q0=Ve(K0,[["__scopeId","data-v-be208792"]]);class Dc{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new mr(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await Vn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=ge.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof mr&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((l=i.source)==null?void 0:l.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 eg={class:"time-markers"},tg=["aria-label","title"],ng={key:0,class:"timeline-scrollbar"},og=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},duration:{},zoomLevel:{default:50},isMobile:{type:Boolean,default:!1},snapEnabled:{type:Boolean,default:!0},selectedClipId:{},fps:{default:30},useFrameMode:{type:Boolean,default:!1},sensitivity:{default:.25}},emits:["update:playhead","trim","split","clip-select","clip-move","clip-long-press","snap-state-change","toggle-frame-mode"],setup(a,{expose:n,emit:t}){const o=a,i=e.computed(()=>o.isMobile===!0),r=t,s=e.ref(),l=e.ref(o.selectedClipId||null),c=e.ref(!1),d=e.ref(0),u=e.ref(),m=e.ref(0),h=e.computed(()=>o.selectedClipId??l.value);e.watch(()=>o.selectedClipId,N=>{N!==void 0&&(l.value=N)});const p=new Dc(o.fps),y=e.ref(!1),g=e.ref(null),x=e.ref(0),M=e.ref(0),C=e.ref(null),b=e.ref(0),f=e.ref(0),w=e.ref(0),F=e.ref(!1),T=e.ref(0),E=e.ref(o.zoomLevel),B=e.computed(()=>o.zoomLevel);function U(N){const z=o.clips.find(q=>q.id===N);if(!z)return null;const H=o.clips.filter(q=>q.id!==N&&q.timelineStart>=z.timelineEnd-1e-9).map(q=>q.timelineStart);return H.length?Math.min(...H):null}function S(N){const z=N.sourceMaxOut??o.duration,H=N.timelineStart+(z-N.sourceIn),q=U(N.id),de=q!=null?Math.max(N.timelineStart,q):1/0;return Math.min(H,de)}function D(N){const z=N.sourceMinIn??0,q=(N.sourceMaxOut??o.duration)-z,de=N.sourceIn-z;return{left:`${(N.timelineStart-de)*B.value-d.value}px`,width:`${q*B.value}px`,top:"0px",height:"80px",opacity:h.value===N.id?.25:.15}}const I=e.computed(()=>o.useFrameMode?o.zoomLevel:o.zoomLevel/o.fps),j=e.computed(()=>p.secondsToFrames(o.duration)),$=e.computed(()=>o.useFrameMode?j.value*I.value:o.duration*B.value),P=e.computed(()=>{var N;return m.value||((N=s.value)==null?void 0:N.clientWidth)||800}),O=e.computed(()=>$.value>P.value),V=e.computed(()=>Math.max(0,$.value-P.value)),R=e.computed(()=>d.value>0),G=e.computed(()=>d.value<V.value),J=e.computed(()=>o.useFrameMode?p.secondsToFrames(o.playhead)*I.value-d.value:o.playhead*B.value-d.value),te=e.computed(()=>C.value===null?null:o.useFrameMode?p.secondsToFrames(C.value)*I.value-d.value:C.value*B.value-d.value),fe=e.computed(()=>{const N=Math.max(50,P.value/$.value*P.value),z=d.value/V.value*(P.value-N);return{width:`${N}px`,left:`${z}px`}}),ye=e.computed(()=>{const N=[],z=oe();for(let H=0;H<=o.duration;H+=z){const q=H*B.value-d.value;q>=-50&&q<=P.value+50&&N.push({position:q,label:_(H),time:H})}return N});function oe(){const z=80/B.value;return z<=1?1:z<=5?5:z<=10?10:z<=30?30:z<=60?60:Math.ceil(z/60)*60}function _(N){if(o.useFrameMode)return`F${p.secondsToFrames(N)}`;{const z=Math.floor(N/60),H=Math.floor(N%60),q=Math.floor(N%1*o.fps);return B.value>100?`${z}:${H.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`:`${z}:${H.toString().padStart(2,"0")}`}}function A(N){const z=s.value.getBoundingClientRect();let q=(N.clientX-z.left+d.value)/B.value;const de=o.clips.find(he=>q>=he.timelineStart&&q<=he.timelineEnd);if(de)q=Math.max(de.timelineStart,Math.min(de.timelineEnd,q));else if(o.selectedClipId){const he=o.clips.find(Ne=>Ne.id===o.selectedClipId);if(he){const Ne=Math.abs(q-he.timelineStart),Fe=Math.abs(q-he.timelineEnd);q=Ne<Fe?he.timelineStart:he.timelineEnd}}else q=Math.max(0,Math.min(q,o.duration));r("update:playhead",q)}function Q(N){if(!O.value)return;const z=Math.abs(N.deltaX)>Math.abs(N.deltaY)?N.deltaX:N.deltaY;z!==0&&(N.preventDefault(),d.value=Math.max(0,Math.min(V.value,d.value+z)))}function ee(){return[...o.clips].sort((N,z)=>N.timelineStart-z.timelineStart)}function ne(N){const z=ee(),H=z.findIndex(q=>q.id===N);return{previous:H>0?z[H-1]:null,next:H!==-1&&H<z.length-1?z[H+1]:null}}function pe(N){const z=N.timelineEnd-N.timelineStart,{previous:H,next:q}=ne(N.id),de=H?H.timelineEnd:0,he=q?q.timelineStart-z:Math.max(N.timelineStart,o.duration-z);return{minStart:de,maxStart:Math.max(de,he)}}function ie(){return 12/Math.max(B.value,1)}function me(N){return Array.from(new Set(N.filter(z=>typeof z=="number"&&Number.isFinite(z))))}function we(N,z,H,q){const de=Math.max(H,Math.min(N,q));if(!o.snapEnabled)return{value:de,guideTime:null};const he=ie();let Ne=de,Fe=null,Me=Number.POSITIVE_INFINITY;for(const De of me(z)){if(De<H||De>q)continue;const Qe=Math.abs(De-de);Qe<=he&&Qe<Me&&(Ne=De,Fe=De,Me=Qe)}return{value:Ne,guideTime:Fe}}function ae(N){if(N.touches.length===2){F.value=!0;const z=N.touches[0],H=N.touches[1];T.value=Math.hypot(H.clientX-z.clientX,H.clientY-z.clientY),E.value=o.zoomLevel}else N.touches.length===1&&(b.value=N.touches[0].clientX,f.value=N.touches[0].clientY,w.value=b.value)}function le(N){if(F.value&&N.touches.length===2){const z=N.touches[0],H=N.touches[1],de=Math.hypot(H.clientX-z.clientX,H.clientY-z.clientY)/T.value;Math.max(10,Math.min(200,E.value*de)),r("update:playhead",o.playhead)}else if(N.touches.length===1&&!F.value){const z=N.touches[0],H=w.value-z.clientX;Math.abs(H)>Math.abs(z.clientY-f.value)&&(N.preventDefault(),d.value=Math.max(0,Math.min($.value-P.value,d.value+H)),w.value=z.clientX)}}function ke(){F.value=!1}function _e(N){const z=N.target;if(z.closest(".playhead-handle"))return;const H=N.button===1,q=!!z.closest(".video-track");(H||!q&&O.value)&&ut(N)}function ut(N){y.value=!0,g.value="pan",x.value=N.clientX,M.value=d.value,document.addEventListener("mousemove",He),document.addEventListener("mouseup",nt)}function Ze(N){N.preventDefault(),N.stopPropagation(),y.value=!0,g.value="playhead";const z="touches"in N?N.touches[0].clientX:N.clientX;x.value=z,M.value=o.playhead,"touches"in N?(document.addEventListener("touchmove",He),document.addEventListener("touchend",nt)):(document.addEventListener("mousemove",He),document.addEventListener("mouseup",nt))}function St(N){N.preventDefault(),N.stopPropagation(),y.value=!0,g.value="scrollbar";const z="touches"in N?N.touches[0].clientX:N.clientX;x.value=z,M.value=d.value,"touches"in N?(document.addEventListener("touchmove",He),document.addEventListener("touchend",nt)):(document.addEventListener("mousemove",He),document.addEventListener("mouseup",nt))}function He(N){if(!y.value)return;const H=("touches"in N?N.touches[0].clientX:N.clientX)-x.value;if(g.value==="playhead"){const q=H/B.value;let de=M.value+q;if(o.selectedClipId){const he=o.clips.find(Ne=>Ne.id===o.selectedClipId);he?de=Math.max(he.timelineStart,Math.min(he.timelineEnd,de)):de=Math.max(0,Math.min(o.duration,de))}else{const he=o.clips.find(Ne=>o.playhead>=Ne.timelineStart&&o.playhead<=Ne.timelineEnd);he?de=Math.max(he.timelineStart,Math.min(he.timelineEnd,de)):de=Math.max(0,Math.min(o.duration,de))}r("update:playhead",de)}else if(g.value==="scrollbar"){const q=H/P.value*$.value;d.value=Math.max(0,Math.min(V.value,M.value+q))}else if(g.value==="pan"){const q=M.value-H;d.value=Math.max(0,Math.min(V.value,q))}}function nt(){y.value=!1,g.value=null,C.value=null,document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",nt),document.removeEventListener("touchmove",He),document.removeEventListener("touchend",nt)}function Vt(N){l.value=l.value===N?null:N,r("clip-select",l.value)}function $t(N){l.value=N,r("clip-select",N),r("clip-long-press",N)}function st(N,z){const H=o.clips.find(de=>de.id===N);if(!H||Math.abs(z)<2)return;const q=z/B.value*o.sensitivity;if(o.useFrameMode){const de=p.secondsToFrames(H.sourceIn),he=p.secondsToFrames(q),Ne=Math.max(0,de+he),Fe=p.framesToSeconds(Ne);r("trim",N,"start",Fe)}else{const de=Math.max(0,H.sourceIn+q);r("trim",N,"start",de)}}function yt(N,z){const H=o.clips.find(Ot=>Ot.id===N);if(!H||!s.value)return;const q=s.value.getBoundingClientRect(),de=z-q.left,he=80;if(de<he)d.value=Math.max(0,d.value-8);else if(de>q.width-he){const Ot=Math.max(0,$.value-P.value);d.value=Math.min(Ot,d.value+8)}const Ne=de+d.value,Fe=1/o.fps;let Me=Ne/B.value;const{previous:De}=ne(H.id),Qe=we(Me,[0,De==null?void 0:De.timelineEnd,o.playhead],0,H.timelineEnd-Fe);Me=Qe.value,C.value=Qe.guideTime;let ht=H.sourceIn+(Me-H.timelineStart);ht=Math.round(ht*o.fps)/o.fps,r("trim",N,"start",ht)}function ce(N,z){const H=o.clips.find(oo=>oo.id===N);if(!H||!s.value)return;const q=s.value.getBoundingClientRect(),de=z-q.left,he=80;if(de<he)d.value=Math.max(0,d.value-8);else if(de>q.width-he){const oo=Math.max(0,$.value-P.value);d.value=Math.min(oo,d.value+8)}const Ne=de+d.value,Fe=1/o.fps,Me=S(H);let De=Ne/B.value;const{next:Qe}=ne(H.id),ht=we(De,[Qe==null?void 0:Qe.timelineStart,o.playhead],H.timelineStart+Fe,Me);De=ht.value,C.value=ht.guideTime;let Ot=H.sourceIn+(De-H.timelineStart);Ot=Math.round(Ot*o.fps)/o.fps,r("trim",N,"end",Ot)}function xe(N,z){const H=o.clips.find(ht=>ht.id===N);if(!H||!s.value)return;const q=s.value.getBoundingClientRect(),de=z-q.left,he=80;if(de<he)d.value=Math.max(0,d.value-8);else if(de>q.width-he){const ht=Math.max(0,$.value-P.value);d.value=Math.min(ht,d.value+8)}const Ne=de+d.value,Fe=H.timelineEnd-H.timelineStart,Me=pe(H);let De=Ne/B.value;const Qe=we(De,[Me.minStart,Me.maxStart,o.playhead,o.playhead-Fe],Me.minStart,Me.maxStart);De=Qe.value,C.value=Qe.guideTime,De=Math.round(De*o.fps)/o.fps,r("clip-move",N,De)}function Ee(N,z){const H=o.clips.find(he=>he.id===N);if(!H||Math.abs(z)<2)return;const q=z/B.value*o.sensitivity,de=he=>Math.max(0,Math.round(he*o.fps)/o.fps);if(o.useFrameMode){const he=p.secondsToFrames(H.sourceOut),Ne=p.secondsToFrames(q),Fe=S(H),Me=H.sourceIn+(Fe-H.timelineStart),De=p.secondsToFrames(Me),Qe=Math.min(De,he+Ne),ht=p.framesToSeconds(Qe);r("trim",N,"end",ht)}else{const he=S(H),Ne=H.sourceIn+(he-H.timelineStart),Fe=Math.min(Ne,H.sourceOut+q),Me=de(Fe);r("trim",N,"end",Me)}}function Oe(N,z){const H=o.clips.find(he=>he.id===N);if(!H||Math.abs(z)<2)return;const q=z/B.value*o.sensitivity,de=he=>Math.max(0,Math.round(he*o.fps)/o.fps);if(o.useFrameMode){const he=p.secondsToFrames(H.timelineStart),Ne=p.secondsToFrames(q),Fe=Math.max(0,he+Ne),Me=p.framesToSeconds(Fe);r("clip-move",N,Me)}else{const he=Math.max(0,H.timelineStart+q),Ne=de(he);r("clip-move",N,Ne)}}return n({handleTrimStart:st,handleTrimEnd:Ee,handleClipDrag:Oe,handleTrimStartAbs:yt,handleTrimEndAbs:ce,handleClipDragAbs:xe,handleClipLongPress:$t}),e.watch(()=>o.playhead,N=>{const z=N*B.value;z<d.value+50?d.value=Math.max(0,z-50):z>d.value+P.value-50&&(d.value=Math.min(V.value,z-P.value+50))}),e.onMounted(()=>{const N=new ResizeObserver(z=>{z[0]&&(m.value=Math.round(z[0].contentRect.width))});s.value&&N.observe(s.value),e.onUnmounted(()=>N.disconnect())}),e.onUnmounted(()=>{nt()}),e.watch([$,P],()=>{d.value>V.value&&(d.value=V.value)}),e.watch(C,(N,z)=>{const H=N!==null;H!==(z!==null)&&r("snap-state-change",H)}),(N,z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:Q},[e.createElementVNode("div",{class:"timeline-ruler",onClick:A},[e.createElementVNode("div",eg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ye.value,H=>(e.openBlock(),e.createElementBlock("span",{key:H.position,class:"time-marker",style:e.normalizeStyle({left:`${H.position}px`})},e.toDisplayString(H.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":O.value,"is-panning":y.value&&g.value==="pan","overflow-left":R.value,"overflow-right":G.value}]),onTouchstart:ae,onTouchmove:le,onTouchend:ke,onMousedown:_e},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.clips,H=>(e.openBlock(),e.createElementBlock("div",{key:`${H.id}-extent`,class:"clip-extent",style:e.normalizeStyle(D(H)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.clips,H=>(e.openBlock(),e.createBlock(Q0,{key:H.id,clip:H,scale:B.value,"scroll-offset":d.value,selected:h.value===H.id,"is-mobile":i.value,onSelect:q=>Vt(H.id),onLongPress:q=>$t(H.id),onTrimStartAbs:q=>yt(H.id,q),onTrimEndAbs:q=>ce(H.id,q),onDragAbs:q=>xe(H.id,q)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${J.value}px`}),onMousedown:Ze,onTouchstart:Ze},[...z[1]||(z[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:`${J.value}px`})},null,4)):e.createCommentVNode("",!0),te.value!==null?(e.openBlock(),e.createElementBlock("div",{key:1,class:"snap-guide",style:e.normalizeStyle({left:`${te.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"frame-mode-toggle",onClick:z[0]||(z[0]=H=>N.$emit("toggle-frame-mode")),"aria-label":N.useFrameMode?"Switch to time mode":"Switch to frame mode",title:N.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(N.useFrameMode?"F":"T"),9,tg))],34),O.value?(e.openBlock(),e.createElementBlock("div",ng,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(fe.value),onMousedown:St,onTouchstart:St},null,36)])):e.createCommentVNode("",!0)],34))}}),fl=Ve(og,[["__scopeId","data-v-d46ec03b"]]),ag={class:"control-group zoom-controls"},ig={class:"zoom-slider"},rg=["value"],sg={class:"control-group playback-controls"},lg=["aria-label"],cg={key:0,class:"control-group speed-control"},dg=["value"],ug=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(a,{emit:n}){const t=n;function o(u){const m=u.target;t("zoom-change",Number(m.value))}function i(){t("fit-to-window")}function r(){t("frame-forward")}function s(){t("frame-backward")}function l(){t("skip-to-start")}function c(){t("skip-to-end")}function d(u){const m=u.target;t("speed-change",Number(m.value))}return(u,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",ag,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=h=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(qm)},null,8,["icon"])]),e.createElementVNode("div",ig,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:o,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,rg)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=h=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Em)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Rm)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",sg,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Jm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Zm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=h=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(L.IonIcon),{icon:u.isPlaying?e.unref(Ql):e.unref(tc)},null,8,["icon"])],8,lg),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Gm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Ym)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",cg,[m[5]||(m[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...m[4]||(m[4]=[e.createStaticVNode('<option value="0.25" data-v-7bf65ab9>0.25x</option><option value="0.5" data-v-7bf65ab9>0.5x</option><option value="1" data-v-7bf65ab9>1x</option><option value="1.5" data-v-7bf65ab9>1.5x</option><option value="2" data-v-7bf65ab9>2x</option>',5)])],40,dg)]))],2))}}),mg=Ve(ug,[["__scopeId","data-v-7bf65ab9"]]),pg={key:0,class:"category-section"},fg={class:"category-carousel-wrapper"},hg=["disabled"],vg=["onClick","data-testid","aria-label"],gg={class:"category-name"},yg=["disabled"],bg={class:"filter-section"},wg={class:"filter-carousel-wrapper"},kg=["disabled"],xg=["onClick","onKeydown","data-testid","aria-label"],Eg=["onClick"],Sg={class:"filter-preview"},Vg={class:"filter-placeholder"},_g={class:"filter-name"},Cg=["disabled"],Ng={class:"carousel-pagination"},Tg=["onClick"],Mg={key:1,class:"filter-adjustments"},Bg={class:"adjustment-header"},Ig={class:"adjustment-actions"},Fg={key:0},$g={key:0,class:"slider-control"},Rg={class:"control-label"},Dg={class:"slider-wrapper"},Ag={class:"slider-value"},Lg={key:1,class:"color-control"},Ug={class:"control-label"},Og={class:"color-wrapper"},Pg=["value","onInput","disabled"],zg={class:"color-value"},jg={key:2,class:"toggle-control"},Wg={class:"control-label"},Zg={key:3,class:"select-control"},Xg={class:"control-label"},Hg=["value","onChange","disabled"],Gg=["value"],Jg={key:1,class:"no-params"},Yg=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),m={all:pn,adjust:lo,color:fn,blur:ta,light:co,effects:$i,stylize:ho,advanced:pn,distortion:vo,transform:vo};function h(V){return V.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(V){return V.replace(/[-_]/g," ").replace(/\b\w/g,R=>R.toUpperCase())}function y(V){return m[V.toLowerCase()]??pn}const g=e.computed(()=>{const V=Array.from(new Set(t.filters.map(R=>R.category).filter(R=>typeof R=="string"&&R.length>0))).sort((R,G)=>R.localeCompare(G));return[{id:"all",name:"All",icon:pn},...V.map(R=>({id:R,name:p(R),icon:y(R)}))]}),x=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(V=>V.category===i.value));e.watch(g,V=>{new Set(V.map(J=>J.id)).has(i.value)||(i.value="all");const G=Math.max(0,V.length-3);s.value>G&&(s.value=G)},{immediate:!0});function M(V){var R;return((R=t.activeFilters)==null?void 0:R.has(V))||!1}function C(V){if(r.value=V,!M(V.id)&&(o("apply-filter",V),V.params&&V.params.length>0)){const R=new Map;V.params.forEach(G=>{R.set(G.id,G.default)}),c.value.set(V.id,R)}o("preview-filter",V)}function b(V){var R;o("remove-filter",V),c.value.delete(V),((R=r.value)==null?void 0:R.id)===V&&(r.value=null)}function f(V){if(typeof V=="number"&&Number.isFinite(V))return V;if(typeof V=="string"){const R=Number(V);return Number.isFinite(R)?R:null}return null}function w(V,R){var _;const G=t.filters.find(A=>A.id===V),J=G==null?void 0:G.params.find(A=>A.id===R),te=(J==null?void 0:J.default)??0,fe=A=>typeof te=="number"?f(A)??te:typeof te=="boolean"?typeof A=="boolean"?A:te:typeof A=="string"?A:te,ye=(_=t.activeFilters)==null?void 0:_.get(V);if(ye&&ye.params){const A=ye.params[R];if(A!=null)return fe(A)}const oe=c.value.get(V);if(oe){const A=oe.get(R);if(A!=null)return fe(A)}return te}function F(V,R,G){var J;c.value.has(V)||c.value.set(V,new Map),(J=c.value.get(V))==null||J.set(R,G),o("update-param",V,R,G)}function T(V){if(typeof V=="boolean")return V?"On":"Off";if(typeof V=="string"){const G=f(V);return G===null?"0":Number.isInteger(G)?G.toString():G.toFixed(2)}const R=f(V);return R===null?"0":Number.isInteger(R)?R.toString():R.toFixed(2)}function E(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const V=new Map;r.value.params.forEach(R=>{V.set(R.id,R.default)}),c.value.set(r.value.id,V)}}function B(V){const R=t.filters.find(G=>G.id===V);R&&R.params&&R.params.forEach(G=>{F(V,G.id,G.default)})}function U(V){return{basic:lo,color:fn,blur:ta,light:co,effects:$i,stylize:ho,adjustment:lo,"color-matrix":fn,glow:pn,distortion:vo}[V]||pn}function S(V){return{adjustment:lo,brightness:co,contrast:lo,saturation:fn,blur:ta,"gaussian-blur":ta,"color-matrix":fn,grayscale:ho,sepia:ho,vignette:vo,glow:pn,glitch:$i,godray:co,lightmap:co}[V.id]||U(V.category)}function D(){s.value>0&&(s.value--,O(d.value,s.value))}function I(){s.value<g.value.length-3&&(s.value++,O(d.value,s.value))}function j(){l.value>0&&(l.value--,O(u.value,l.value))}function $(){l.value<x.value.length-4&&(l.value++,O(u.value,l.value))}function P(V){l.value=V*4,O(u.value,l.value)}function O(V,R){var G;if(V){const J=((G=V.querySelector(".category-chip, .filter-card"))==null?void 0:G.clientWidth)||100;V.scrollTo({left:R*(J+8),behavior:"smooth"})}}return(V,R)=>{var G;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:V.compact}])},[V.showCategories?(e.openBlock(),e.createElementBlock("div",pg,[e.createElementVNode("div",fg,[e.createElementVNode("button",{onClick:D,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Os)},null,8,["icon"])],8,hg),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,J=>(e.openBlock(),e.createElementBlock("button",{key:J.id,onClick:te=>i.value=J.id,class:e.normalizeClass(["category-chip",{active:i.value===J.id}]),"data-testid":`btn-filter-category-${h(J.id)}`,"aria-label":`Filter category ${J.name}`},[e.createVNode(e.unref(L.IonIcon),{icon:J.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",gg,e.toDisplayString(J.name),1)],10,vg))),128))],512),e.createElementVNode("button",{onClick:I,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Ps)},null,8,["icon"])],8,yg)])])):e.createCommentVNode("",!0),e.createElementVNode("div",bg,[e.createElementVNode("div",wg,[e.createElementVNode("button",{onClick:j,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Os)},null,8,["icon"])],8,kg),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,J=>{var te;return e.openBlock(),e.createElementBlock("div",{key:J.id,class:e.normalizeClass(["filter-card",{active:M(J.id),selected:((te=r.value)==null?void 0:te.id)===J.id}]),onClick:fe=>C(J),onKeydown:[e.withKeys(fe=>C(J),["enter"]),e.withKeys(e.withModifiers(fe=>C(J),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${h(J.id)}`,"aria-label":`Select filter ${J.name}`},[M(J.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(fe=>b(J.id),["stop"])},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Jl)},null,8,["icon"])],8,Eg)):e.createCommentVNode("",!0),e.createElementVNode("div",Sg,[e.createElementVNode("div",Vg,[e.createVNode(e.unref(L.IonIcon),{icon:S(J),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",_g,e.toDisplayString(J.name),1)],42,xg)}),128))],512),e.createElementVNode("button",{onClick:$,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,x.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Ps)},null,8,["icon"])],8,Cg)]),e.createElementVNode("div",Ng,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(x.value.length/4),(J,te)=>(e.openBlock(),e.createElementBlock("span",{key:te,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===te}]),onClick:fe=>P(te)},null,10,Tg))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",Mg,[e.createElementVNode("div",Bg,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",Ig,[M(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:E,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),M(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:R[0]||(R[0]=J=>b(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:R[1]||(R[1]=J=>B(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",Fg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,J=>(e.openBlock(),e.createElementBlock("div",{key:J.id,class:"adjustment-control"},[!J.type||J.type==="slider"?(e.openBlock(),e.createElementBlock("div",$g,[e.createElementVNode("label",Rg,e.toDisplayString(J.label||J.id),1),e.createElementVNode("div",Dg,[e.createVNode(e.unref(L.IonRange),{value:w(r.value.id,J.id),onIonChange:te=>F(r.value.id,J.id,te.detail.value),min:J.min,max:J.max,step:J.step||.01,color:"primary",class:"compact-slider",disabled:!M(r.value.id),"data-testid":`range-filter-${h(r.value.id)}-${h(J.id)}`,"aria-label":`Adjust ${J.label||J.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Ag,e.toDisplayString(T(w(r.value.id,J.id))),1)])])):J.type==="color"?(e.openBlock(),e.createElementBlock("div",Lg,[e.createElementVNode("label",Ug,e.toDisplayString(J.label||J.id),1),e.createElementVNode("div",Og,[e.createElementVNode("input",{type:"color",value:w(r.value.id,J.id),onInput:te=>F(r.value.id,J.id,te.target.value),disabled:!M(r.value.id),class:"color-input"},null,40,Pg),e.createElementVNode("span",zg,e.toDisplayString(w(r.value.id,J.id)),1)])])):J.type==="toggle"?(e.openBlock(),e.createElementBlock("div",jg,[e.createElementVNode("label",Wg,e.toDisplayString(J.label||J.id),1),e.createVNode(e.unref(L.IonToggle),{checked:!!w(r.value.id,J.id),onIonChange:te=>F(r.value.id,J.id,te.detail.checked),disabled:!M(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):J.type==="select"?(e.openBlock(),e.createElementBlock("div",Zg,[e.createElementVNode("label",Xg,e.toDisplayString(J.label||J.id),1),e.createElementVNode("select",{value:w(r.value.id,J.id),onChange:te=>F(r.value.id,J.id,te.target.value),disabled:!M(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(J.options,te=>(e.openBlock(),e.createElementBlock("option",{key:String(te.value),value:te.value},e.toDisplayString(te.label),9,Gg))),128))],40,Hg)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",Jg," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),qg=Ve(Yg,[["__scopeId","data-v-9efd15d9"]]);class Kg{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 Qg={class:"video-filter-preview"},e1={class:"preview-title"},t1={class:"filter-controls"},n1={class:"control-input"},o1=["value","onInput","min","max","step"],a1={class:"param-value"},i1={class:"preview-container"},r1={key:0,class:"filter-presets"},s1=["onClick"],l1={class:"preview-actions"},c1=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 l,c,d=null,u=null;const m=e.computed(()=>{var E;return((E=t.filter)==null?void 0:E.paramRanges)||{}}),h=e.computed(()=>p.value.length>0),p=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function y(){var E;if(i.value){t.useVideoEngine&&t.composition&&(u=new Kg(t.composition));try{if(l=new Ye.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(E=t.currentFrame)!=null&&E.dataUrl){const B=await Ye.Assets.load(t.currentFrame.dataUrl);c=new Ye.Sprite(B);const U=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(U),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}g()}catch{}}}function g(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const E={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([E]).then(()=>{}).catch(B=>{}),d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}function x(E,B){switch(E){case"brightness":{const U=new Ye.ColorMatrixFilter,S=1+(B.value??0);return typeof U.brightness=="function"&&U.brightness(S,!1),U}case"contrast":{const U=new Ye.ColorMatrixFilter,S=B.value??1;return typeof U.contrast=="function"&&U.contrast(S,!1),U}case"saturation":{const U=new Ye.ColorMatrixFilter,S=B.value??1;return typeof U.saturate=="function"&&U.saturate(S,!1),U}case"hue":{const U=new Ye.ColorMatrixFilter,S=B.value??0;return typeof U.hue=="function"&&U.hue(S,!1),U}case"gaussian-blur":{const U=B.value??5;return new Ye.BlurFilter({strength:U,quality:4})}case"sepia":{const U=new Ye.ColorMatrixFilter;return typeof U.sepia=="function"&&U.sepia(!1),U}case"grayscale":{const U=new Ye.ColorMatrixFilter;return typeof U.desaturate=="function"&&U.desaturate(),U}default:return null}}function M(E,B){const U=B.target,S=Number.parseFloat(U.value),D=Number.isFinite(S)?S:0;s.value={...s.value,[E]:D},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),g()}function C(E){return E.charAt(0).toUpperCase()+E.slice(1).replace(/_/g," ")}function b(E,B){var S;const U=typeof E=="number"?E:Number(E);return Number.isFinite(U)?B==="hue"||B==="angle"?`${U}°`:B==="value"&&((S=t.filter)==null?void 0:S.id)==="brightness"?`${Math.round((1+U)*100)}%`:Number.isInteger(U)?U.toString():U.toFixed(2):"0"}function f(){var E;s.value=((E=t.filter)==null?void 0:E.defaultParams)||{},o("update-params",s.value),g()}function w(E){s.value={...E.params},o("update-params",s.value),g()}function F(E){return JSON.stringify(E.params)===JSON.stringify(s.value)}function T(){o("apply")}return e.watch(()=>t.filter,E=>{E&&(s.value={...E.defaultParams},g())}),e.watch(()=>t.currentFrame,async E=>{if(E!=null&&E.dataUrl&&c){const B=await Ye.Assets.load(E.dataUrl);c.texture=B}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),y()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(E,B)=>{var U;return e.openBlock(),e.createElementBlock("div",Qg,[e.createElementVNode("h4",e1,e.toDisplayString((U=E.filter)==null?void 0:U.name)+" Settings",1),e.createElementVNode("div",t1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(S,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(C(D)),1),e.createElementVNode("div",n1,[e.createElementVNode("input",{type:"range",value:s.value[D],onInput:I=>M(D,I),min:S.min,max:S.max,step:S.step,class:"param-slider"},null,40,o1),e.createElementVNode("span",a1,e.toDisplayString(b(s.value[D],D)),1)])]))),128))]),e.createElementVNode("div",i1,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:B[0]||(B[0]=S=>r.value=!0),onMouseup:B[1]||(B[1]=S=>r.value=!1),onTouchstart:B[2]||(B[2]=S=>r.value=!0),onTouchend:B[3]||(B[3]=S=>r.value=!1)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(vo)},null,8,["icon"]),B[4]||(B[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),h.value?(e.openBlock(),e.createElementBlock("div",r1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,S=>(e.openBlock(),e.createElementBlock("button",{key:S.name,class:e.normalizeClass(["preset-button",{active:F(S)}]),onClick:D=>w(S)},e.toDisplayString(S.name),11,s1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",l1,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yn)},null,8,["icon"]),B[5]||(B[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:T},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yl)},null,8,["icon"]),B[6]||(B[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),d1=Ve(c1,[["__scopeId","data-v-3de3dd04"]]),u1={class:"export-settings"},m1={class:"setting-group"},p1={class:"setting-group"},f1={class:"estimated-size"},h1={key:0,class:"export-progress"},v1={class:"progress-header"},g1={class:"progress-percentage"},y1={class:"progress-time"},b1={class:"action-buttons"},w1=["disabled"],k1=["disabled"],x1=["disabled"],E1={class:"export-options"},S1=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),l=e.ref(!1),c=e.ref(0),d=e.ref(0),u=e.ref(0);let m=null;const h=e.computed(()=>{const f=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return f<1e3?`~${Math.round(f)} MB`:`~${(f/1e3).toFixed(1)} GB`});function p(){t.isExporting?(o("cancel-export"),x()):y()}function y(){const C={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:l.value};o("export",C),g()}function g(){c.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const C=d.value/t.exportProgress*100;u.value=Math.max(0,C-d.value)}},1e3)}function x(){m&&(clearInterval(m),m=null)}function M(C){const b=Math.floor(C/60),f=Math.floor(C%60);return`${b}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,C=>{C||x()}),e.onUnmounted(()=>{x()}),(C,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:C.isMobile}])},[e.createElementVNode("div",u1,[b[10]||(b[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",m1,[b[7]||(b[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[0]||(b[0]=f=>i.value=f),class:"setting-select"},[...b[6]||(b[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",p1,[b[9]||(b[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[1]||(b[1]=f=>r.value=f),class:"setting-select"},[...b[8]||(b[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",f1,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Um)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(h.value),1)])]),C.isExporting?(e.openBlock(),e.createElementBlock("div",h1,[e.createElementVNode("div",v1,[b[11]||(b[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",g1,e.toDisplayString(C.exportProgress??0)+"%",1)]),e.createVNode(e.unref(L.IonProgressBar),{value:(C.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",y1,[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",b1,[e.createElementVNode("button",{class:"control-button secondary",onClick:b[2]||(b[2]=f=>C.$emit("save-draft")),disabled:!C.canExport||C.isExporting},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(_r)},null,8,["icon"]),b[12]||(b[12]=e.createTextVNode(" Save Draft ",-1))],8,w1),e.createElementVNode("button",{class:"control-button secondary",onClick:b[3]||(b[3]=f=>C.$emit("reset")),disabled:C.isExporting},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yn)},null,8,["icon"]),b[13]||(b[13]=e.createTextVNode(" Reset ",-1))],8,k1),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!C.canExport&&!C.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(L.IonIcon),{icon:C.isExporting?e.unref(Xn):e.unref(Co)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(C.isExporting?"Cancel":"Export Video"),1)],8,x1)]),e.createElementVNode("div",E1,[e.createVNode(e.unref(L.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":b[4]||(b[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...b[14]||(b[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(L.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":b[5]||(b[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...b[15]||(b[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),V1=Ve(S1,[["__scopeId","data-v-e1338d5e"]]),_1={class:"thumbnail-picker"},C1={class:"thumbnail-grid"},N1=["onClick"],T1=["src","alt"],M1={key:1,class:"thumbnail-placeholder"},B1={class:"thumbnail-time"},I1={class:"custom-selector"},F1={class:"time-input-group"},$1=["max"],R1={class:"time-value"},D1=["disabled"],A1={class:"picker-actions"},L1=["disabled"],U1=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),l=e.ref(!1);function c(){const M=[];if(t.duration<=10)for(let b=0;b<Math.min(9,t.duration);b++)M.push(b);else{const b=t.duration/10;for(let f=1;f<=9;f++)M.push(b*f)}return M}async function d(M){try{const C=document.createElement("video");return C.crossOrigin="anonymous",C.src=await u(),new Promise(b=>{C.addEventListener("loadedmetadata",()=>{C.currentTime=M}),C.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=C.videoWidth,f.height=C.videoHeight;const w=f.getContext("2d");w?(w.drawImage(C,0,0),b(f.toDataURL("image/jpeg",.8))):b(null),C.remove()}),C.addEventListener("error",()=>{b(null),C.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function m(){const M=c();i.value=M.map(b=>({time:b,loading:!0}));const C=3;for(let b=0;b<i.value.length;b+=C){const f=i.value.slice(b,b+C);await Promise.all(f.map(async w=>{const F=await d(w.time);F&&(w.dataUrl=F),w.loading=!1}))}}function h(M){r.value=M,s.value=i.value[M].time}function p(){r.value=-1}async function y(){l.value=!0;try{const M=await d(s.value);if(M){const C=i.value.findIndex(b=>Math.abs(b.time-s.value)<.1);C>=0?(i.value[C].dataUrl=M,r.value=C):(i.value.push({time:s.value,dataUrl:M}),r.value=i.value.length-1,i.value.sort((b,f)=>b.time-f.time),r.value=i.value.findIndex(b=>b.time===s.value))}}finally{l.value=!1}}function g(){const M=r.value>=0?i.value[r.value].time:s.value;o("select",M)}function x(M){const C=Math.floor(M/60),b=Math.floor(M%60),f=Math.floor(M%1*100);return C>0?`${C}:${b.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${b}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(M,C)=>(e.openBlock(),e.createElementBlock("div",_1,[C[5]||(C[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",C1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(b,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass(["thumbnail-item",{selected:r.value===f}]),onClick:w=>h(f)},[b.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:b.dataUrl,alt:`Frame at ${x(b.time)}`},null,8,T1)):(e.openBlock(),e.createElementBlock("div",M1,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",B1,e.toDisplayString(x(b.time)),1)],10,N1))),128))]),e.createElementVNode("div",I1,[C[3]||(C[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",F1,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":C[0]||(C[0]=b=>s.value=b),min:0,max:M.duration,step:.1,onInput:p,class:"time-slider"},null,40,$1),[[e.vModelText,s.value]]),e.createElementVNode("span",R1,e.toDisplayString(x(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:y,disabled:l.value},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Cm)},null,8,["icon"]),C[2]||(C[2]=e.createTextVNode(" Capture Frame ",-1))],8,D1)]),e.createElementVNode("div",A1,[e.createElementVNode("button",{class:"action-button",onClick:C[1]||(C[1]=b=>M.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:g,disabled:r.value===-1},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yl)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,L1)])]))}}),O1=Ve(U1,[["__scopeId","data-v-336c322c"]]),P1={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},z1={class:"mb-4"},j1={class:"space-y-2 max-h-64 overflow-y-auto"},W1={class:"flex items-center justify-between"},Z1={class:"flex-1"},X1={class:"font-medium text-gray-900 dark:text-white"},H1={class:"text-sm text-gray-500 dark:text-gray-400"},G1={class:"flex items-center space-x-2"},J1=["onClick"],Y1=["onClick"],q1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},K1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Q1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},ey={class:"space-y-4"},ty={class:"grid grid-cols-2 gap-4"},ny={class:"grid grid-cols-2 gap-4"},oy={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},ay={class:"grid grid-cols-2 gap-3"},iy={class:"flex justify-end space-x-3 mt-6"},ry=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 l(h){Object.assign(s,h),i.value=h}function c(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const h={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(h.animation={type:s.animationType},s.animationDuration!==void 0&&(h.animation.duration=s.animationDuration),s.animationEasing&&(h.animation.easing=s.animationEasing),h.animation))switch(s.animationType){case"rotate":h.animation.rotation={from:0,to:360};break;case"scale":h.animation.scale={from:.5,to:1};break;case"slide":h.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,h):t("add-overlay",h),c()}function u(h){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",h)}function m(h){const p=Math.floor(h/60),y=Math.floor(h%60);return`${p}:${y.toString().padStart(2,"0")}`}return(h,p)=>(e.openBlock(),e.createElementBlock("div",P1,[e.createElementVNode("div",z1,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=y=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...p[10]||(p[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",j1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.overlays,y=>(e.openBlock(),e.createElementBlock("div",{key:y.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",W1,[e.createElementVNode("div",Z1,[e.createElementVNode("div",X1,e.toDisplayString(y.text.substring(0,30))+e.toDisplayString(y.text.length>30?"...":""),1),e.createElementVNode("div",H1,e.toDisplayString(m(y.startTime??0))+" - "+e.toDisplayString(m((y.startTime||0)+(y.duration||5))),1)]),e.createElementVNode("div",G1,[e.createElementVNode("button",{onClick:g=>l(y),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,J1),e.createElementVNode("button",{onClick:g=>u(y.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Y1)])])]))),128)),h.overlays.length===0?(e.openBlock(),e.createElementBlock("div",q1," 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(c,["self"])},[e.createElementVNode("div",K1,[e.createElementVNode("h4",Q1,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",ey,[e.createElementVNode("div",null,[p[14]||(p[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":p[1]||(p[1]=y=>s.text=y),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",ty,[e.createElementVNode("div",null,[p[15]||(p[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[2]||(p[2]=y=>s.fontSize=y),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[16]||(p[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[3]||(p[3]=y=>s.color=y),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[p[18]||(p[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[4]||(p[4]=y=>s.position=y),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[17]||(p[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",ny,[e.createElementVNode("div",null,[p[19]||(p[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[5]||(p[5]=y=>s.startTime=y),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[20]||(p[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[6]||(p[6]=y=>s.duration=y),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[p[22]||(p[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[7]||(p[7]=y=>s.animationType=y),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[21]||(p[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",oy,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",ay,[e.createElementVNode("div",null,[p[23]||(p[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[8]||(p[8]=y=>s.animationDuration=y),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[25]||(p[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[9]||(p[9]=y=>s.animationEasing=y),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...p[24]||(p[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",iy,[e.createElementVNode("button",{onClick:c,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:d,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},e.toDisplayString(i.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),sy=Ve(ry,[["__scopeId","data-v-f86e688c"]]),_o=class _o{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",l=this.findTrackForClip(n),c=this.findTrackForClip(t);if(!l||!c)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 Se([o,i],[1,0],{easing:r}),t.alpha=new Se([o,i],[0,1],{easing:r}),t.start=ge.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 Se([o,i],[1,0],{easing:r}),t.alpha=new Se([o,i],[0,1],{easing:r}),t.start=ge.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 l={x:0,y:0},c={x:0,y:0};switch(o){case"wipe-left":l.x=new Se([i,r],[0,-1920],{easing:s}),c.x=new Se([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Se([i,r],[0,1920],{easing:s}),c.x=new Se([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Se([i,r],[0,-1080],{easing:s}),c.y=new Se([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Se([i,r],[0,1080],{easing:s}),c.y=new Se([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=ge.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 l={x:0,y:0},c={x:0,y:0};switch(o){case"slide-left":l.x=new Se([i,r],[0,-1920],{easing:s}),c.x=new Se([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Se([i,r],[0,1920],{easing:s}),c.x=new Se([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Se([i,r],[0,-1080],{easing:s}),c.y=new Se([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Se([i,r],[0,1080],{easing:s}),c.y=new Se([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=ge.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 Se([i,r],[1,2],{easing:s}),n.alpha=new Se([i,r],[1,0],{easing:s}),t.scale=new Se([i,r],[.5,1],{easing:s}),t.alpha=new Se([i,r],[0,1],{easing:s})):(n.scale=new Se([i,r],[1,.5],{easing:s}),n.alpha=new Se([i,r],[1,0],{easing:s}),t.scale=new Se([i,r],[2,1],{easing:s}),t.alpha=new Se([i,r],[0,1],{easing:s})),t.start=ge.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 l=Math.round((i+r)/2),c=o==="dip-to-black"?"#000000":"#ffffff",d=await dr.fromColor(c),u=new Lv(d,{start:ge.fromFrames(i),stop:ge.fromFrames(r)});n.alpha=new Se([i,l],[1,0],{easing:s}),u.alpha=new Se([i,l,r],[0,1,0],{easing:s}),t.alpha=new Se([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=ge.fromFrames(l)}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[..._o.TRANSITIONS]}static previewTransition(n){return _o.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};_o.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 Fa=_o;const ly={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},cy={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},dy=["onClick"],uy={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"},my={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},py={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},fy={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},hy={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"},vy={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"},gy={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"},yy={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},by={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},wy={class:"space-y-3"},ky={class:"flex items-center space-x-2"},xy=["disabled"],Ey=["disabled"],Sy={key:1,class:"mt-4"},Vy={class:"space-y-2 max-h-32 overflow-y-auto"},_y={class:"text-sm text-gray-700 dark:text-gray-300"},Cy=["onClick"],Ny=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(Fa.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),l=e.ref("linear"),c=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function d(y){r.value=y}function u(){if(!r.value||!c.value)return;const y={type:r.value.type,duration:s.value,easing:l.value};o("apply-transition",y),r.value=null}function m(){if(!r.value)return;const y={type:r.value.type,duration:s.value,easing:l.value};o("preview-transition",y)}function h(y){o("remove-transition",y)}function p(y){return["fade","wipe","slide","zoom"].some(g=>y.includes(g))}return(y,g)=>(e.openBlock(),e.createElementBlock("div",ly,[g[9]||(g[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",cy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,x=>{var M;return e.openBlock(),e.createElementBlock("div",{key:x.type,onClick:C=>d(x),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((M=r.value)==null?void 0:M.type)===x.type?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"])},[e.createElementVNode("div",uy,[p(x.type)?(e.openBlock(),e.createElementBlock("svg",my,[x.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",py)):x.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",fy)):x.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",hy)):x.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",vy)):(e.openBlock(),e.createElementBlock("path",gy))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",yy,e.toDisplayString(x.name),1)],10,dy)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",by,[g[6]||(g[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",wy,[e.createElementVNode("div",null,[g[3]||(g[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",ky,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=x=>s.value=x),type:"range",min:"0.1",max:"3",step:"0.1",class:"flex-1"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[1]||(g[1]=x=>s.value=x),type:"number",min:"0.1",max:"3",step:"0.1",class:"w-16 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[g[5]||(g[5]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[2]||(g[2]=x=>l.value=x),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...g[4]||(g[4]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("button",{onClick:u,disabled:!c.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",c.value?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])}," Apply Transition ",10,xy),e.createElementVNode("button",{onClick:m,disabled:!r.value,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"}," Preview ",8,Ey)])])):e.createCommentVNode("",!0),y.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Sy,[g[8]||(g[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",Vy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.appliedTransitions,(x,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",_y,e.toDisplayString(x.name)+" ("+e.toDisplayString(x.duration)+"s) ",1),e.createElementVNode("button",{onClick:C=>h(M),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Cy)]))),128))])])):e.createCommentVNode("",!0),g[10]||(g[10]=e.createElementVNode("div",{class:"mt-4 text-xs text-gray-500 dark:text-gray-400"},[e.createElementVNode("p",null,"Select clips in the timeline, then choose a transition to apply between them.")],-1))]))}}),Ty=Ve(Ny,[["__scopeId","data-v-5ef1b100"]]),My={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},By={class:"mb-4"},Iy={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Fy={class:"flex items-center justify-between mb-2"},$y={class:"text-sm text-gray-600 dark:text-gray-400"},Ry={class:"flex items-center space-x-2"},Dy={class:"space-y-3 max-h-64 overflow-y-auto"},Ay={class:"flex items-center justify-between mb-2"},Ly={class:"font-medium text-gray-900 dark:text-white"},Uy={class:"flex items-center space-x-2"},Oy=["onClick","title"],Py={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},zy={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},jy=["onClick"],Wy=["onClick"],Zy={class:"flex items-center space-x-2"},Xy={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},Hy=["value","onInput","disabled"],Gy={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Jy={key:0,class:"ml-2"},Yy={key:1,class:"ml-2"},qy={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Ky={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Qy={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},eb={class:"space-y-4"},tb={class:"space-y-2"},nb={class:"flex items-center"},ob={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},ab={class:"grid grid-cols-2 gap-4"},ib={class:"grid grid-cols-2 gap-4"},rb={class:"flex items-center"},sb={class:"flex justify-end space-x-3 mt-6"},lb=["disabled"],cb=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),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(b){const f=b.target;f.files&&f.files[0]&&(c.sourceFile=f.files[0],c.name=c.name||f.files[0].name.replace(/\.[^/.]+$/,""))}function m(b){Object.assign(c,b),r.value=b}function h(){i.value=!1,r.value=null,Object.assign(c,l())}function p(){if(!d.value)return;const b={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(b.duration=c.duration),c.fadeIn>0&&(b.fadeIn=c.fadeIn),c.fadeOut>0&&(b.fadeOut=c.fadeOut),r.value?o("update-track",r.value.id,b):o("add-track",b),h()}function y(b){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",b)}function g(b,f){const w=f.target,F=parseFloat(w.value);o("update-volume",b.id,F)}function x(b){o("toggle-mute",b.id,!b.muted)}function M(){o("update-master-volume",s.value)}function C(b){const f=Math.floor(b/60),w=Math.floor(b%60);return`${f}:${w.toString().padStart(2,"0")}`}return(b,f)=>(e.openBlock(),e.createElementBlock("div",My,[e.createElementVNode("div",By,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=w=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...f[10]||(f[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",Iy,[e.createElementVNode("div",Fy,[f[12]||(f[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",$y,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",Ry,[f[13]||(f[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=w=>s.value=w),onInput:M,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),f[14]||(f[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",Dy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.audioLayers,w=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",Ay,[e.createElementVNode("div",Ly,e.toDisplayString(w.name),1),e.createElementVNode("div",Uy,[e.createElementVNode("button",{onClick:F=>x(w),class:e.normalizeClass(["p-1 rounded",w.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:w.muted?"Unmute":"Mute"},[w.muted?(e.openBlock(),e.createElementBlock("svg",zy,[...f[16]||(f[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Py,[...f[15]||(f[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,Oy),e.createElementVNode("button",{onClick:F=>m(w),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...f[17]||(f[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,jy),e.createElementVNode("button",{onClick:F=>y(w.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[18]||(f[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Wy)])]),e.createElementVNode("div",Zy,[e.createElementVNode("span",Xy,e.toDisplayString(Math.round((w.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:w.volume||1,onInput:F=>g(w,F),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:w.muted},null,40,Hy)]),e.createElementVNode("div",Gy,[e.createTextVNode(e.toDisplayString(C(w.startTime||0))+" - "+e.toDisplayString(C((w.startTime||0)+(w.duration||0)))+" ",1),w.fadeIn?(e.openBlock(),e.createElementBlock("span",Jy,"Fade In: "+e.toDisplayString(w.fadeIn)+"s",1)):e.createCommentVNode("",!0),w.fadeOut?(e.openBlock(),e.createElementBlock("span",Yy,"Fade Out: "+e.toDisplayString(w.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),b.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",qy," 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(h,["self"])},[e.createElementVNode("div",Ky,[e.createElementVNode("h4",Qy,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",eb,[e.createElementVNode("div",null,[f[20]||(f[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",tb,[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",nb,[f[19]||(f[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[2]||(f[2]=w=>c.sourceUrl=w),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[f[21]||(f[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[3]||(f[3]=w=>c.name=w),type:"text",placeholder:"Background Music",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",ob," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[4]||(f[4]=w=>c.volume=w),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,c.volume,void 0,{number:!0}]])]),e.createElementVNode("div",ab,[e.createElementVNode("div",null,[f[22]||(f[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[5]||(f[5]=w=>c.startTime=w),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[23]||(f[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[6]||(f[6]=w=>c.duration=w),type:"number",min:"0.1",step:"0.1",placeholder:"Auto",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",ib,[e.createElementVNode("div",null,[f[24]||(f[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[7]||(f[7]=w=>c.fadeIn=w),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[25]||(f[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[8]||(f[8]=w=>c.fadeOut=w),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",rb,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[9]||(f[9]=w=>c.loop=w),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),f[26]||(f[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",sb,[e.createElementVNode("button",{onClick:h,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:p,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(r.value?"Save":"Add"),11,lb)])])])):e.createCommentVNode("",!0)]))}}),db=Ve(cb,[["__scopeId","data-v-593719ac"]]);function Le(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function hl(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let vl=!1;function ub(){if(vl)return;vl=!0;const a=`
|
|
34
|
-
/* ── MobileVideoFilterPanel — global (not scoped) ── */
|
|
35
|
-
.mvfp {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* ── Horizontal scroll rows ── */
|
|
44
|
-
.mvfp-row {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 8px;
|
|
47
|
-
padding: 8px 12px;
|
|
48
|
-
overflow-x: auto;
|
|
49
|
-
-webkit-overflow-scrolling: touch;
|
|
50
|
-
scrollbar-width: none;
|
|
51
|
-
flex-shrink: 0;
|
|
52
|
-
}
|
|
53
|
-
.mvfp-row::-webkit-scrollbar { display: none; }
|
|
54
|
-
|
|
55
|
-
/* ── Category chips ── */
|
|
56
|
-
.mvfp-cat {
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
gap: 6px;
|
|
60
|
-
min-height: 36px;
|
|
61
|
-
padding: 8px 14px;
|
|
62
|
-
border-radius: 20px;
|
|
63
|
-
border: 1.5px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
64
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
65
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
66
|
-
font-size: 13px;
|
|
67
|
-
font-weight: 500;
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
transition: all 0.15s;
|
|
72
|
-
-webkit-tap-highlight-color: transparent;
|
|
73
|
-
}
|
|
74
|
-
.mvfp-cat.active {
|
|
75
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
76
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
77
|
-
color: #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* ── Filter cards ── */
|
|
81
|
-
.mvfp-filter {
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-direction: column;
|
|
84
|
-
align-items: center;
|
|
85
|
-
justify-content: center;
|
|
86
|
-
min-width: 72px;
|
|
87
|
-
max-width: 100px;
|
|
88
|
-
min-height: 48px;
|
|
89
|
-
padding: 10px 12px;
|
|
90
|
-
border-radius: 12px;
|
|
91
|
-
border: 2px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
92
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
93
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
text-align: center;
|
|
96
|
-
line-height: 1.3;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
flex-shrink: 0;
|
|
99
|
-
position: relative;
|
|
100
|
-
transition: all 0.15s;
|
|
101
|
-
-webkit-tap-highlight-color: transparent;
|
|
102
|
-
}
|
|
103
|
-
.mvfp-filter.active {
|
|
104
|
-
border-color: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
105
|
-
}
|
|
106
|
-
.mvfp-filter.selected {
|
|
107
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.15);
|
|
108
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
109
|
-
}
|
|
110
|
-
.mvfp-filter .mvfp-check {
|
|
111
|
-
position: absolute;
|
|
112
|
-
top: -5px;
|
|
113
|
-
right: -5px;
|
|
114
|
-
width: 18px;
|
|
115
|
-
height: 18px;
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
background: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
118
|
-
color: #fff;
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
font-size: 11px;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* ── Active filter chips ── */
|
|
127
|
-
.mvfp-active-row {
|
|
128
|
-
display: flex;
|
|
129
|
-
gap: 6px;
|
|
130
|
-
padding: 6px 12px;
|
|
131
|
-
overflow-x: auto;
|
|
132
|
-
-webkit-overflow-scrolling: touch;
|
|
133
|
-
scrollbar-width: none;
|
|
134
|
-
flex-shrink: 0;
|
|
135
|
-
}
|
|
136
|
-
.mvfp-active-row::-webkit-scrollbar { display: none; }
|
|
137
|
-
|
|
138
|
-
.mvfp-achip {
|
|
139
|
-
display: flex;
|
|
140
|
-
align-items: center;
|
|
141
|
-
gap: 6px;
|
|
142
|
-
padding: 6px 10px 6px 12px;
|
|
143
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.12);
|
|
144
|
-
border: 1px solid var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
145
|
-
border-radius: 20px;
|
|
146
|
-
white-space: nowrap;
|
|
147
|
-
flex-shrink: 0;
|
|
148
|
-
font-size: 12px;
|
|
149
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
transition: all 0.15s;
|
|
152
|
-
}
|
|
153
|
-
.mvfp-achip.selected {
|
|
154
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
155
|
-
color: #fff;
|
|
156
|
-
}
|
|
157
|
-
.mvfp-achip-x {
|
|
158
|
-
width: 20px;
|
|
159
|
-
height: 20px;
|
|
160
|
-
border-radius: 50%;
|
|
161
|
-
border: 1.5px solid currentColor;
|
|
162
|
-
background: transparent;
|
|
163
|
-
color: inherit;
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
padding: 0;
|
|
169
|
-
opacity: 0.7;
|
|
170
|
-
flex-shrink: 0;
|
|
171
|
-
}
|
|
172
|
-
.mvfp-achip-x:hover, .mvfp-achip-x:active {
|
|
173
|
-
background: var(--ion-color-danger, #ef4444);
|
|
174
|
-
border-color: var(--ion-color-danger, #ef4444);
|
|
175
|
-
color: #fff;
|
|
176
|
-
opacity: 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.mvfp-placeholder {
|
|
180
|
-
font-size: 12px;
|
|
181
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
182
|
-
padding: 6px 12px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ── Drawer ── */
|
|
186
|
-
.mvfp-drawer {
|
|
187
|
-
position: absolute;
|
|
188
|
-
bottom: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
right: 0;
|
|
191
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
192
|
-
border-top: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
193
|
-
transform: translateY(100%);
|
|
194
|
-
z-index: 20;
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
border-radius: 14px 14px 0 0;
|
|
199
|
-
}
|
|
200
|
-
.mvfp-drawer-hdr {
|
|
201
|
-
display: flex;
|
|
202
|
-
justify-content: space-between;
|
|
203
|
-
align-items: center;
|
|
204
|
-
padding: 8px 14px;
|
|
205
|
-
border-bottom: 1px solid var(--app-border, var(--ion-color-step-200, #333));
|
|
206
|
-
flex-shrink: 0;
|
|
207
|
-
}
|
|
208
|
-
.mvfp-drawer-title {
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
font-size: 14px;
|
|
211
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
212
|
-
}
|
|
213
|
-
.mvfp-drawer-actions {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
gap: 10px;
|
|
217
|
-
}
|
|
218
|
-
.mvfp-drawer-btn {
|
|
219
|
-
background: none;
|
|
220
|
-
border: none;
|
|
221
|
-
font-size: 13px;
|
|
222
|
-
font-weight: 500;
|
|
223
|
-
cursor: pointer;
|
|
224
|
-
padding: 4px 6px;
|
|
225
|
-
color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
226
|
-
}
|
|
227
|
-
.mvfp-drawer-btn.danger {
|
|
228
|
-
color: var(--ion-color-danger, #ef4444);
|
|
229
|
-
}
|
|
230
|
-
.mvfp-drawer-close {
|
|
231
|
-
width: 28px;
|
|
232
|
-
height: 28px;
|
|
233
|
-
border: none;
|
|
234
|
-
border-radius: 50%;
|
|
235
|
-
background: var(--app-surface-sunken, var(--ion-color-step-100, #2a2a2a));
|
|
236
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
justify-content: center;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
padding: 0;
|
|
242
|
-
}
|
|
243
|
-
.mvfp-drawer-body {
|
|
244
|
-
flex: 1 1 auto;
|
|
245
|
-
overflow-y: auto;
|
|
246
|
-
-webkit-overflow-scrolling: touch;
|
|
247
|
-
padding: 10px 14px 16px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* ── Drawer slider controls ── */
|
|
251
|
-
.mvfp-ctl {
|
|
252
|
-
margin-bottom: 12px;
|
|
253
|
-
}
|
|
254
|
-
.mvfp-ctl-label {
|
|
255
|
-
display: block;
|
|
256
|
-
font-size: 11px;
|
|
257
|
-
font-weight: 600;
|
|
258
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
259
|
-
text-transform: uppercase;
|
|
260
|
-
letter-spacing: 0.5px;
|
|
261
|
-
margin-bottom: 4px;
|
|
262
|
-
}
|
|
263
|
-
.mvfp-slider-row {
|
|
264
|
-
display: flex;
|
|
265
|
-
align-items: center;
|
|
266
|
-
gap: 10px;
|
|
267
|
-
}
|
|
268
|
-
.mvfp-range {
|
|
269
|
-
flex: 1;
|
|
270
|
-
height: 6px;
|
|
271
|
-
-webkit-appearance: none;
|
|
272
|
-
appearance: none;
|
|
273
|
-
background: var(--app-border, var(--ion-color-step-200, #333));
|
|
274
|
-
border-radius: 3px;
|
|
275
|
-
outline: none;
|
|
276
|
-
}
|
|
277
|
-
.mvfp-range::-webkit-slider-thumb {
|
|
278
|
-
-webkit-appearance: none;
|
|
279
|
-
width: 22px;
|
|
280
|
-
height: 22px;
|
|
281
|
-
border-radius: 50%;
|
|
282
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
border: 2px solid #fff;
|
|
285
|
-
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
|
286
|
-
}
|
|
287
|
-
.mvfp-range-val {
|
|
288
|
-
min-width: 3rem;
|
|
289
|
-
text-align: right;
|
|
290
|
-
font-size: 12px;
|
|
291
|
-
font-weight: 500;
|
|
292
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
293
|
-
}
|
|
294
|
-
.mvfp-toggle-row {
|
|
295
|
-
display: flex;
|
|
296
|
-
align-items: center;
|
|
297
|
-
justify-content: space-between;
|
|
298
|
-
gap: 10px;
|
|
299
|
-
}
|
|
300
|
-
.mvfp-color-row {
|
|
301
|
-
display: flex;
|
|
302
|
-
align-items: center;
|
|
303
|
-
justify-content: space-between;
|
|
304
|
-
gap: 10px;
|
|
305
|
-
}
|
|
306
|
-
.mvfp-color-input {
|
|
307
|
-
width: 36px;
|
|
308
|
-
height: 36px;
|
|
309
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
310
|
-
border-radius: 8px;
|
|
311
|
-
padding: 2px;
|
|
312
|
-
cursor: pointer;
|
|
313
|
-
background: transparent;
|
|
314
|
-
}
|
|
315
|
-
.mvfp-select-row {
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: space-between;
|
|
319
|
-
gap: 10px;
|
|
320
|
-
}
|
|
321
|
-
.mvfp-select {
|
|
322
|
-
padding: 6px 10px;
|
|
323
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
324
|
-
border-radius: 8px;
|
|
325
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
326
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
327
|
-
font-size: 13px;
|
|
328
|
-
}
|
|
329
|
-
.mvfp-no-params {
|
|
330
|
-
text-align: center;
|
|
331
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
332
|
-
font-style: italic;
|
|
333
|
-
font-size: 13px;
|
|
334
|
-
padding: 12px 0;
|
|
335
|
-
}
|
|
336
|
-
`,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class mb{constructor({filters:n=[],callbacks:t={}}){ub(),this._filters=n,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(n){return this._root=Le("div",{className:"mvfp"}),this._catRow=Le("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Le("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Le("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=Le("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=Le("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Le("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Le("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Le("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(c=>c.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Le("div",{className:`mvfp-achip${i?" selected":""}`}),s=Le("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),l=Le("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:c=>{c.stopPropagation(),this._removeFilter(t)}});l.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(s),r.appendChild(l),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=Le("div",{className:"mvfp-drawer"});const n=Le("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Le("span",{className:"mvfp-drawer-title"},"Filter");const t=Le("div",{className:"mvfp-drawer-actions"});t.appendChild(Le("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Le("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=Le("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Le("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(Le("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=Le("div",{className:"mvfp-ctl"}),l=Le("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Le("div",{className:"mvfp-slider-row"}),u=Le("span",{className:"mvfp-range-val"},hl(r)),m=Le("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:h=>{var y,g;const p=parseFloat(h.target.value);u.textContent=hl(p),(g=(y=this._cb).onUpdateParam)==null||g.call(y,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Le("div",{className:"mvfp-toggle-row"}),u=Le("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=Le("div",{className:"mvfp-color-row"}),u=Le("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=Le("div",{className:"mvfp-select-row"}),u=Le("select",{className:"mvfp-select",onChange:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const h=Le("option",{value:m.value},m.label||String(m.value));m.value===r&&(h.selected=!0),u.appendChild(h)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function gl(a){var s,l;pb(a);const n=fb(a.clips),t=[],o=hb(a),i=vb(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:((l=a.media)==null?void 0:l.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(c=>typeof c.source=="string")),r}function pb(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 fb(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 l=Number(o?n.sourceIn:s),c=i?Number(n.sourceOut):Number(s)+r/t;return c>l||(c=l+Math.max(.033,r/Math.max(1e-6,t))),{id:n.id,type:"clip",timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:l,sourceOut:c,speed:t,filters:n.filters?[...n.filters]:[]}})}function hb(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 vb(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 gb(a,n,t){var Ee,Oe;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([]),l=e.ref([]),c=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),m=e.shallowRef(null),h=new Dc(30),p=e.ref(30),y=e.ref(!1),g=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(T(n),(Ee=n.output)!=null&&Ee.fps&&(p.value=n.output.fps,h.setFps(p.value))):(f(),n&&((Oe=n.output)!=null&&Oe.fps&&(p.value=n.output.fps,h.setFps(p.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const x=e.ref(1),M=e.computed(()=>i.selectedClipId?i.clips.find(N=>N.id===i.selectedClipId)??null:null);e.watch(M,N=>{x.value=(N==null?void 0:N.speed)??1},{immediate:!0});const C=e.computed(()=>s.value.length>0),b=e.computed(()=>l.value.length>0);function f(){const N=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=N,i.totalDuration=N;const z=ne(),H={id:z,type:"clip",timelineStart:0,timelineEnd:N,sourceIn:0,sourceOut:N,sourceMinIn:0,sourceMaxOut:N,speed:1};i.clips=[H],i.selectedClipId=z,c.value=z,!(t||o.startsWith("temp-"))&&(async()=>{try{const q=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!q.ok)throw new Error(`Failed to fetch media: ${q.status}`);const de=await q.json(),he=typeof de=="object"&&de!==null&&"data"in de?de.data:de;if(!he||typeof he!="object")throw new Error("Failed to parse media payload");const Ne=he;i.media=Ne;const Fe=typeof Ne.duration=="number"&&Ne.duration>0?Ne.duration:N;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==z)return;i.originalDuration=Fe,i.totalDuration=Fe;const Me=i.clips[0];Me.timelineStart=0,Me.timelineEnd=Fe,Me.sourceIn=0,Me.sourceOut=Fe,Me.sourceMinIn=0,Me.sourceMaxOut=Fe,R(),d=!0}catch{}})()}function w(N,z){if(N.originalDuration!==1)return;N.originalDuration=z,N.totalDuration===1&&(N.totalDuration=z);const H=N.clips[0],q=!n&&N.clips.length===1&&H!==void 0&&H.timelineStart===0&&H.timelineEnd===1&&H.sourceIn===0&&H.sourceOut===1;for(const de of N.clips)(de.sourceMaxOut===1||de.sourceMaxOut===void 0)&&(de.sourceMaxOut=z);q&&H!==void 0&&(H.sourceOut=z,H.timelineEnd=z)}function F(N){if(!Number.isFinite(N)||N<=0||d)return;const z=i.hasChanges;i.originalDuration=N,i.totalDuration=Math.max(i.totalDuration,N),i.media&&(i.media.duration=N);for(const de of i.clips)de.sourceMaxOut=N;const H=i.clips[0];!n&&i.clips.length===1&&H!==void 0&&H.timelineStart===0&&H.timelineEnd===1&&H.sourceIn===0&&H.sourceOut===1&&H!==void 0&&(H.sourceOut=N,H.timelineEnd=H.timelineStart+(H.sourceOut-H.sourceIn)),R();for(const de of s.value)w(de,N);for(const de of l.value)w(de,N);d=!0,e.nextTick(()=>{z||(i.hasChanges=!1)})}function T(N){i.clips=N.timeline.map(z=>({...z,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??N.source.duration})),i.filters=[],i.audioVolume=N.audio.volume,i.audioFadeIn=N.audio.fadeIn||0,i.audioFadeOut=N.audio.fadeOut||0,i.exportFormat=N.output.format,i.exportQuality=N.output.quality,i.originalDuration=N.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),R()}function E(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function B(){if(!C.value)return;const N=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,N)}function U(){if(!b.value)return;const N=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,N)}function S(N,z,H){E();const q=i.clips.find(Me=>Me.id===N);if(!q)return;const he=1/30,Ne=q.sourceMinIn??0,Fe=q.sourceMaxOut??i.originalDuration;if(z==="start"){const Me=q.sourceIn,De=Math.max(Ne,Math.min(H,q.sourceOut-he));q.sourceIn=De;const Qe=De-Me;q.timelineStart+=Qe}else{const Me=Math.max(q.sourceIn+he,Math.min(H,Fe));q.sourceOut=Me;const De=q.sourceOut-q.sourceIn;q.timelineEnd=q.timelineStart+De}R(),m.value&&m.value.trimClip(N,q.sourceIn,q.sourceOut)}function D(N){E();const z=i.clips.find(Ne=>N>Ne.timelineStart&&N<Ne.timelineEnd);if(!z)return;const H=N-z.timelineStart,q=z.sourceIn+H,de={id:ne(),type:"clip",timelineStart:N,timelineEnd:z.timelineEnd,sourceIn:q,sourceOut:z.sourceOut,speed:z.speed??1,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??i.originalDuration,filters:[...z.filters||[]]};z.timelineEnd=N,z.sourceOut=q;const he=i.clips.indexOf(z);i.clips.splice(he+1,0,de),i.selectedClipId=de.id}function I(){D(i.playheadPosition)}function j(N){var H;const z=N??i.selectedClipId??c.value??((H=i.clips[0])==null?void 0:H.id);z&&(i.selectedClipId=z,c.value=z)}function $(){if(!i.selectedClipId||i.clips.length<=1)return;E();const N=i.clips.findIndex(z=>z.id===i.selectedClipId);if(N!==-1){i.clips.splice(N,1);const z=Math.min(N,i.clips.length-1);i.selectedClipId=i.clips[z].id,c.value=i.selectedClipId,R()}}function P(){return[...i.clips].sort((N,z)=>N.timelineStart-z.timelineStart)}function O(N){const z=P(),H=z.findIndex(De=>De.id===N);if(H===-1)return null;const q=z[H],de=q.timelineEnd-q.timelineStart,he=H>0?z[H-1]:null,Ne=H<z.length-1?z[H+1]:null,Fe=he?he.timelineEnd:0,Me=Ne?Ne.timelineStart-de:Math.max(q.timelineStart,i.totalDuration-de);return{minStart:Fe,maxStart:Math.max(Fe,Me)}}function V(N,z){const H=i.clips.find(Ne=>Ne.id===N);if(!H)return;const q=O(N),de=q?Math.min(q.maxStart,Math.max(q.minStart,z)):Math.max(0,z);if(de===H.timelineStart)return;E();const he=de-H.timelineStart;H.timelineStart=de,H.timelineEnd+=he,R(),m.value&&m.value.moveClip(N,de)}function R(){if(i.clips.length===0){i.totalDuration=0;return}const N=i.clips.reduce((z,H)=>H.timelineEnd>z.timelineEnd?H:z);i.totalDuration=N.timelineEnd}function G(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function J(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function te(N){i.zoomLevel=Math.max(10,Math.min(600,Math.round(N)))}function fe(){i.isPlaying=!i.isPlaying}function ye(N){i.isPlaying=N}function oe(N){i.playheadPosition=Math.max(0,Math.min(N,i.totalDuration))}function _(){const N=gl(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(N))}catch{}return N}function A(){i.hasChanges=!1}function Q(){return confirm("Are you sure you want to reset all changes?")?(E(),f(),i.hasChanges=!1,!0):!1}function ee(){return gl(i)}function ne(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function pe(N=1920,z=1080){if(u.value)try{m.value=new Rc(N,z,p.value),await ie()}catch{m.value=null}}async function ie(){if(!(!m.value||g.value)){g.value=!0;try{const N=ee();await m.value.loadFromRecipe(N);const z=h.secondsToFrames(i.playheadPosition);m.value.seek(z)}catch{}finally{g.value=!1}}}function me(N){}function we(N){return h.secondsToFrames(N)}function ae(N){return h.framesToSeconds(N)}function le(N){const z=ae(N);oe(z),m.value&&m.value.seek(N)}function ke(){y.value=!y.value}function _e(){ie()}function ut(N){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&ie()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&ie()},{deep:!0}),e.watch(()=>i.clips.map(N=>N.id),()=>{var z;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(H=>H.id===i.selectedClipId)){const H=c.value&&((z=i.clips.find(q=>q.id===c.value))==null?void 0:z.id);i.selectedClipId=H??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function Ze(N){const z=i.selectedClipId?i.clips.find(H=>H.id===i.selectedClipId):i.clips[0];z&&(z.filters=[...N],i.hasChanges=!0)}function St(N){i.textOverlays=[...N]}function He(N){i.audioTracks=[...N]}e.watch(u,N=>{N?pe():m.value&&(m.value.destroy(),m.value=null)}),e.watch(y,()=>{}),e.watch(p,N=>{h.setFps(N)});function nt(){if(!i.selectedClipId)return;E();const N=i.clips.find(q=>q.id===i.selectedClipId);if(!N)return;const z={...N,id:ne(),timelineStart:N.timelineEnd,timelineEnd:N.timelineEnd+(N.timelineEnd-N.timelineStart),filters:[...N.filters||[]]},H=i.clips.indexOf(N);i.clips.splice(H+1,0,z),i.selectedClipId=z.id,i.hasChanges=!0}function Vt(N){const z=N??800,H=i.totalDuration;if(H<=0){i.zoomLevel=50;return}const q=z*.8/H;i.zoomLevel=Math.max(10,Math.min(600,Math.round(q)))}function $t(){const N=1/p.value;oe(Math.min(i.playheadPosition+N,i.totalDuration))}function st(){const N=1/p.value;oe(Math.max(i.playheadPosition-N,0))}function yt(){oe(0)}function ce(){oe(i.totalDuration)}function xe(N){if(!Number.isFinite(N)||N<=0)return;const z=M.value??i.clips[0];if(!z){x.value=N;return}const H=z.speed??1;if(H===N){x.value=N;return}E();const q=Math.max(1/p.value,z.sourceOut-z.sourceIn),de=q/H,he=q/N,Ne=he-de;z.speed=N,z.timelineEnd=z.timelineStart+he;const Fe=i.clips.findIndex(Me=>Me.id===z.id);if(Fe!==-1&&Ne!==0)for(let Me=Fe+1;Me<i.clips.length;Me+=1){const De=i.clips[Me];De.timelineStart+=Ne,De.timelineEnd+=Ne}R(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,x.value=N}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:x,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:p,useFrameMode:y,handleTrim:S,handleSplit:D,handleClipSelect:j,splitAtPlayhead:I,deleteSelectedClip:$,duplicateSelectedClip:nt,setFilters:Ze,setTextOverlays:St,setAudioTracks:He,moveClip:V,saveDraft:_,clearHasChanges:A,resetChanges:Q,generateRecipe:ee,zoomIn:G,zoomOut:J,setZoomLevel:te,fitToWindow:Vt,togglePlayback:fe,setPlaying:ye,seekTo:oe,frameForward:$t,frameBackward:st,skipToStart:yt,skipToEnd:ce,setPlaybackSpeed:xe,updateSourceDuration:F,undo:B,redo:U,canUndo:C,canRedo:b,initializeComposition:pe,syncCompositionWithState:ie,syncWithComposition:me,convertToFrames:we,convertToSeconds:ae,seekToFrame:le,toggleFrameMode:ke,onCompositionReady:_e,onCompositionError:ut}}const yb=[{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}}}],bb={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Ka(a){return typeof a=="object"&&a!==null}function wb(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 Qa(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function kb(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=Qa(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function Ac(a,n,t){const o=dt.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&Ka(r))for(const[s,l]of Object.entries(r))i[s]=Qa(l)??null;for(const s of n){const l=s.property??s.id;i[l]===void 0&&s.default!==void 0&&(i[l]=s.default)}return i}function Lc(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 xb(a,n,t,o){const i=o.map(kb);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:Ac(a,i),paramRanges:Lc(i)}}function Eb(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var l;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=Qa((l=a.defaultParams)==null?void 0:l[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:Ac(a.id,t,a.defaultParams),paramRanges:Lc(t)}}function Sb(a,n){return n.toLowerCase()==="unlisted"?!1:dt.isFilterCompatibleWithMedia(a,"video")}function ji(a){return bb[a]??a}function bo(a){const n=wb(a,1);return Math.max(0,Math.min(1,n))}function wo(a){if(!Ka(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=Qa(o)??null;return n}function Vb(a){return!Ka(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:wo(a.params),intensity:bo(a.intensity)}}function _b(a){if(!Ka(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>Vb(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 Cb(){dt.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,j=dt.getRegisteredFilters();for(const $ of j)Sb($.id,$.category)&&I.set($.id,xb($.id,$.name,$.category,$.controls));for(const $ of yb)I.has($.id)||I.set($.id,Eb($));return Array.from(I.values())}),l=e.computed(()=>{const I=new Map;for(const j of s.value)I.set(j.id,j);return I}),c=e.computed(()=>a.value.length>0),d=e.computed(()=>{const I={};for(const j of s.value)I[j.category]||(I[j.category]=[]),I[j.category].push(j);return I});function u(I){const j=l.value.get(I);if(j)return j;const $=ji(I);return l.value.get($)??null}function m(I){const j=l.value.get(I);if(j)return j.id;const $=ji(I),P=l.value.get($);return P?P.id:null}function h(I){const j=I?u(I):n.value;if(!j)return;const $=j.defaultParams||{},P={id:B(),filterId:j.id,params:{...$},intensity:1};return a.value.push(P),i.value=P.id,n.value=j,Object.keys(r).forEach(O=>delete r[O]),Object.assign(r,P.params),t.value=null,P}function p(I){const j=u(I);if(!j)return;n.value=j;const $=j.defaultParams||S(I);Object.assign(r,$),t.value={id:"preview",filterId:j.id,params:{...$},intensity:1}}function y(I){if(Object.assign(r,I),t.value&&(t.value.params={...r}),i.value){const j=a.value.find($=>$.id===i.value);j&&(j.params={...r})}}function g(I){const j=a.value.findIndex($=>$.id===I);j!==-1&&a.value.splice(j,1)}function x(I,j){if(I<0||I>=a.value.length||j<0||j>=a.value.length)return;const[$]=a.value.splice(I,1);a.value.splice(j,0,$)}function M(I,j){const $=a.value.find(P=>P.id===I);$&&($.intensity=Math.max(0,Math.min(1,j)))}function C(I){const j=a.value.find($=>$.id===I);j&&(j.intensity=j.intensity>0?0:1)}function b(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(I=>delete r[I])}function f(I){const j={id:U(),name:I,filters:a.value.map(P=>({filterId:P.filterId,params:wo(P.params),intensity:bo(P.intensity)})),created_at:new Date().toISOString()};o.value.push(j);const $=o.value.map(P=>({...P}));return localStorage.setItem("video-filter-presets",JSON.stringify($)),j}function w(I){const j=o.value.find($=>$.id===I);if(j){b();for(const $ of j.filters){const P=u($.filterId);P&&a.value.push({id:B(),filterId:P.id,params:{...$.params},intensity:bo($.intensity)})}}}function F(I){const j=o.value.findIndex($=>$.id===I);j!==-1&&(o.value.splice(j,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function T(){try{const I=localStorage.getItem("video-filter-presets");if(!I)return;const j=JSON.parse(I);if(!Array.isArray(j))return;o.value=j.map($=>_b($)).filter($=>$!==null)}catch{}}function E(){if(a.value.length===0)return"No filters applied";const I=a.value.map(j=>{const $=D(j.filterId);return($==null?void 0:$.name)||j.filterId});return I.length===1?I[0]:I.length===2?`${I[0]} + ${I[1]}`:`${I[0]} + ${I.length-1} more`}function B(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function U(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function S(I){const j=u(I);return j?j.defaultParams||{}:{}}function D(I){return u(I)}return T(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:h,previewFilterEffect:p,updateFilterParams:y,removeFilter:g,reorderFilters:x,updateFilterIntensity:M,toggleFilter:C,clearAllFilters:b,saveFilterPreset:f,loadFilterPreset:w,deleteFilterPreset:F,getFilterSummary:E,setActiveFilters(I){var $;const j=[];for(const P of I){const O=m(P.filterId);if(!O){const V=ji(P.filterId);j.push({...P,filterId:V,params:wo(P.params),intensity:bo(P.intensity)});continue}j.push({...P,filterId:O,params:wo(P.params),intensity:bo(P.intensity)})}a.value=j,i.value=(($=a.value[0])==null?void 0:$.id)??null,Object.keys(r).forEach(P=>delete r[P]),a.value[0]&&Object.assign(r,wo(a.value[0].params))}}}class Nb{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 pt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new pt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new pt({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 pt({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new pt({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=ge.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;o.stop=ge.fromSeconds(l+n.duration)}n.animation&&this.applyAnimation(o,n.animation,n);const s=new Kn(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),l=i+s,c=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Se([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Se([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Se([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Se([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Se([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Se([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Se([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Se([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Se([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});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 c,d;const r={classic:Ao,cascade:Ha,guinea:Xa,solar:Ga,spotlight:Lo,whisper:Uo}[t],s=await this.composition.createTrack("caption"),l=new Oa({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),o&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,o)}}}class Tb{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 hn.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 hn)o=n.source;else if(typeof n.source=="string")o=await hn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)o=await hn.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const i={source:o,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=ge.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;i.stop=ge.fromSeconds(c+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new Ia(i);let s=this.composition.tracks.find(c=>c.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,l),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 l=Math.round(n.fadeIn*30);r.push(o,o+l),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const l=o+Math.round(i*30),c=Math.round(n.fadeOut*30);n.fadeIn||(r.push(l-c),s.push(t)),r.push(l),s.push(0)}return new Se(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 Ia({source:o.clip.source,start:ge.fromSeconds(i),stop:ge.fromSeconds(t),volume:o.clip.volume}),l=o.track.clips.indexOf(o.clip);l!==-1&&(o.track.clips[l]=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 Uc(a,n){return function(){return a.apply(n,arguments)}}const{toString:Mb}=Object.prototype,{getPrototypeOf:Wr}=Object,{iterator:ei,toStringTag:Oc}=Symbol,ti=(a=>n=>{const t=Mb.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=a=>(a=a.toLowerCase(),n=>ti(n)===a),ni=a=>n=>typeof n===a,{isArray:to}=Array,Mo=ni("undefined");function Oo(a){return a!==null&&!Mo(a)&&a.constructor!==null&&!Mo(a.constructor)&&kt(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const Pc=Ut("ArrayBuffer");function Bb(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&Pc(a.buffer),n}const Ib=ni("string"),kt=ni("function"),zc=ni("number"),Po=a=>a!==null&&typeof a=="object",Fb=a=>a===!0||a===!1,wa=a=>{if(ti(a)!=="object")return!1;const n=Wr(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Oc in a)&&!(ei in a)},$b=a=>{if(!Po(a)||Oo(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},Rb=Ut("Date"),Db=Ut("File"),Ab=Ut("Blob"),Lb=Ut("FileList"),Ub=a=>Po(a)&&kt(a.pipe),Ob=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||kt(a.append)&&((n=ti(a))==="formdata"||n==="object"&&kt(a.toString)&&a.toString()==="[object FormData]"))},Pb=Ut("URLSearchParams"),[zb,jb,Wb,Zb]=["ReadableStream","Request","Response","Headers"].map(Ut),Xb=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function zo(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),to(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(Oo(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let l;for(o=0;o<s;o++)l=r[o],n.call(null,a[l],l,a)}}function jc(a,n){if(Oo(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 _n=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wc=a=>!Mo(a)&&a!==_n;function hr(){const{caseless:a}=Wc(this)&&this||{},n={},t=(o,i)=>{const r=a&&jc(n,i)||i;wa(n[r])&&wa(o)?n[r]=hr(n[r],o):wa(o)?n[r]=hr({},o):to(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&zo(arguments[o],t);return n}const Hb=(a,n,t,{allOwnKeys:o}={})=>(zo(n,(i,r)=>{t&&kt(i)?a[r]=Uc(i,t):a[r]=i},{allOwnKeys:o}),a),Gb=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),Jb=(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)},Yb=(a,n,t,o)=>{let i,r,s;const l={};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))&&!l[s]&&(n[s]=a[s],l[s]=!0);a=t!==!1&&Wr(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},qb=(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},Kb=a=>{if(!a)return null;if(to(a))return a;let n=a.length;if(!zc(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},Qb=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&Wr(Uint8Array)),ew=(a,n)=>{const o=(a&&a[ei]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},tw=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},nw=Ut("HTMLFormElement"),ow=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),yl=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),aw=Ut("RegExp"),Zc=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};zo(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},iw=a=>{Zc(a,(n,t)=>{if(kt(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(kt(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+"'")})}})},rw=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return to(a)?o(a):o(String(a).split(n)),t},sw=()=>{},lw=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function cw(a){return!!(a&&kt(a.append)&&a[Oc]==="FormData"&&a[ei])}const dw=a=>{const n=new Array(10),t=(o,i)=>{if(Po(o)){if(n.indexOf(o)>=0)return;if(Oo(o))return o;if(!("toJSON"in o)){n[i]=o;const r=to(o)?[]:{};return zo(o,(s,l)=>{const c=t(s,i+1);!Mo(c)&&(r[l]=c)}),n[i]=void 0,r}}return o};return t(a,0)},uw=Ut("AsyncFunction"),mw=a=>a&&(Po(a)||kt(a))&&kt(a.then)&&kt(a.catch),Xc=((a,n)=>a?setImmediate:n?((t,o)=>(_n.addEventListener("message",({source:i,data:r})=>{i===_n&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),_n.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",kt(_n.postMessage)),pw=typeof queueMicrotask<"u"?queueMicrotask.bind(_n):typeof process<"u"&&process.nextTick||Xc,fw=a=>a!=null&&kt(a[ei]),Y={isArray:to,isArrayBuffer:Pc,isBuffer:Oo,isFormData:Ob,isArrayBufferView:Bb,isString:Ib,isNumber:zc,isBoolean:Fb,isObject:Po,isPlainObject:wa,isEmptyObject:$b,isReadableStream:zb,isRequest:jb,isResponse:Wb,isHeaders:Zb,isUndefined:Mo,isDate:Rb,isFile:Db,isBlob:Ab,isRegExp:aw,isFunction:kt,isStream:Ub,isURLSearchParams:Pb,isTypedArray:Qb,isFileList:Lb,forEach:zo,merge:hr,extend:Hb,trim:Xb,stripBOM:Gb,inherits:Jb,toFlatObject:Yb,kindOf:ti,kindOfTest:Ut,endsWith:qb,toArray:Kb,forEachEntry:ew,matchAll:tw,isHTMLForm:nw,hasOwnProperty:yl,hasOwnProp:yl,reduceDescriptors:Zc,freezeMethods:iw,toObjectSet:rw,toCamelCase:ow,noop:sw,toFiniteNumber:lw,findKey:jc,global:_n,isContextDefined:Wc,isSpecCompliantForm:cw,toJSONObject:dw,isAsyncFn:uw,isThenable:mw,setImmediate:Xc,asap:pw,isIterable:fw};function Be(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)}Y.inherits(Be,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:Y.toJSONObject(this.config),code:this.code,status:this.status}}});const Hc=Be.prototype,Gc={};["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=>{Gc[a]={value:a}});Object.defineProperties(Be,Gc);Object.defineProperty(Hc,"isAxiosError",{value:!0});Be.from=(a,n,t,o,i,r)=>{const s=Object.create(Hc);return Y.toFlatObject(a,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Be.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const hw=null;function vr(a){return Y.isPlainObject(a)||Y.isArray(a)}function Jc(a){return Y.endsWith(a,"[]")?a.slice(0,-2):a}function bl(a,n,t){return a?a.concat(n).map(function(i,r){return i=Jc(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function vw(a){return Y.isArray(a)&&!a.some(vr)}const gw=Y.toFlatObject(Y,{},null,function(n){return/^is[A-Z]/.test(n)});function oi(a,n,t){if(!Y.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=Y.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!Y.isUndefined(x[g])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(n);if(!Y.isFunction(i))throw new TypeError("visitor must be a function");function d(y){if(y===null)return"";if(Y.isDate(y))return y.toISOString();if(Y.isBoolean(y))return y.toString();if(!c&&Y.isBlob(y))throw new Be("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(y)||Y.isTypedArray(y)?c&&typeof Blob=="function"?new Blob([y]):Buffer.from(y):y}function u(y,g,x){let M=y;if(y&&!x&&typeof y=="object"){if(Y.endsWith(g,"{}"))g=o?g:g.slice(0,-2),y=JSON.stringify(y);else if(Y.isArray(y)&&vw(y)||(Y.isFileList(y)||Y.endsWith(g,"[]"))&&(M=Y.toArray(y)))return g=Jc(g),M.forEach(function(b,f){!(Y.isUndefined(b)||b===null)&&n.append(s===!0?bl([g],f,r):s===null?g:g+"[]",d(b))}),!1}return vr(y)?!0:(n.append(bl(x,g,r),d(y)),!1)}const m=[],h=Object.assign(gw,{defaultVisitor:u,convertValue:d,isVisitable:vr});function p(y,g){if(!Y.isUndefined(y)){if(m.indexOf(y)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(y),Y.forEach(y,function(M,C){(!(Y.isUndefined(M)||M===null)&&i.call(n,M,Y.isString(C)?C.trim():C,g,h))===!0&&p(M,g?g.concat(C):[C])}),m.pop()}}if(!Y.isObject(a))throw new TypeError("data must be an object");return p(a),n}function wl(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function Zr(a,n){this._pairs=[],a&&oi(a,this,n)}const Yc=Zr.prototype;Yc.append=function(n,t){this._pairs.push([n,t])};Yc.toString=function(n){const t=n?function(o){return n.call(this,o,wl)}:wl;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function yw(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function qc(a,n,t){if(!n)return a;const o=t&&t.encode||yw;Y.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=Y.isURLSearchParams(n)?n.toString():new Zr(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class kl{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){Y.forEach(this.handlers,function(o){o!==null&&n(o)})}}const Kc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bw=typeof URLSearchParams<"u"?URLSearchParams:Zr,ww=typeof FormData<"u"?FormData:null,kw=typeof Blob<"u"?Blob:null,xw={isBrowser:!0,classes:{URLSearchParams:bw,FormData:ww,Blob:kw},protocols:["http","https","file","blob","url","data"]},Xr=typeof window<"u"&&typeof document<"u",gr=typeof navigator=="object"&&navigator||void 0,Ew=Xr&&(!gr||["ReactNative","NativeScript","NS"].indexOf(gr.product)<0),Sw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Vw=Xr&&window.location.href||"http://localhost",_w=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Xr,hasStandardBrowserEnv:Ew,hasStandardBrowserWebWorkerEnv:Sw,navigator:gr,origin:Vw},Symbol.toStringTag,{value:"Module"})),ft={..._w,...xw};function Cw(a,n){return oi(a,new ft.classes.URLSearchParams,{visitor:function(t,o,i,r){return ft.isNode&&Y.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function Nw(a){return Y.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Tw(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 Qc(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&Y.isArray(i)?i.length:s,c?(Y.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!l):((!i[s]||!Y.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&Y.isArray(i[s])&&(i[s]=Tw(i[s])),!l)}if(Y.isFormData(a)&&Y.isFunction(a.entries)){const t={};return Y.forEachEntry(a,(o,i)=>{n(Nw(o),i,t,0)}),t}return null}function Mw(a,n,t){if(Y.isString(a))try{return(n||JSON.parse)(a),Y.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const jo={transitional:Kc,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=Y.isObject(n);if(r&&Y.isHTMLForm(n)&&(n=new FormData(n)),Y.isFormData(n))return i?JSON.stringify(Qc(n)):n;if(Y.isArrayBuffer(n)||Y.isBuffer(n)||Y.isStream(n)||Y.isFile(n)||Y.isBlob(n)||Y.isReadableStream(n))return n;if(Y.isArrayBufferView(n))return n.buffer;if(Y.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return Cw(n,this.formSerializer).toString();if((l=Y.isFileList(n))||o.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return oi(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Mw(n)):n}],transformResponse:[function(n){const t=this.transitional||jo.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(Y.isResponse(n)||Y.isReadableStream(n))return n;if(n&&Y.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?Be.from(l,Be.ERR_BAD_RESPONSE,this,null,this.response):l}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ft.classes.FormData,Blob:ft.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],a=>{jo.headers[a]={}});const Bw=Y.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"]),Iw=a=>{const n={};let t,o,i;return a&&a.split(`
|
|
337
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&Bw[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},xl=Symbol("internals");function mo(a){return a&&String(a).trim().toLowerCase()}function ka(a){return a===!1||a==null?a:Y.isArray(a)?a.map(ka):String(a)}function Fw(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 $w=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function Wi(a,n,t,o,i){if(Y.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!Y.isString(n)){if(Y.isString(o))return n.indexOf(o)!==-1;if(Y.isRegExp(o))return o.test(n)}}function Rw(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function Dw(a,n){const t=Y.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 xt=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(l,c,d){const u=mo(c);if(!u)throw new Error("header name must be a non-empty string");const m=Y.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||c]=ka(l))}const s=(l,c)=>Y.forEach(l,(d,u)=>r(d,u,c));if(Y.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(Y.isString(n)&&(n=n.trim())&&!$w(n))s(Iw(n),t);else if(Y.isObject(n)&&Y.isIterable(n)){let l={},c,d;for(const u of n){if(!Y.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?Y.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=mo(n),n){const o=Y.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return Fw(i);if(Y.isFunction(t))return t.call(this,i,o);if(Y.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=mo(n),n){const o=Y.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||Wi(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=mo(s),s){const l=Y.findKey(o,s);l&&(!t||Wi(o,o[l],l,t))&&(delete o[l],i=!0)}}return Y.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||Wi(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return Y.forEach(this,(i,r)=>{const s=Y.findKey(o,r);if(s){t[s]=ka(i),delete t[r];return}const l=n?Rw(r):String(r).trim();l!==r&&delete t[r],t[l]=ka(i),o[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return Y.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&Y.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
|
|
338
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[xl]=this[xl]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=mo(s);o[l]||(Dw(i,s),o[l]=!0)}return Y.isArray(n)?n.forEach(r):r(n),this}};xt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Y.reduceDescriptors(xt.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});Y.freezeMethods(xt);function Zi(a,n){const t=this||jo,o=n||t,i=xt.from(o.headers);let r=o.data;return Y.forEach(a,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function ed(a){return!!(a&&a.__CANCEL__)}function no(a,n,t){Be.call(this,a??"canceled",Be.ERR_CANCELED,n,t),this.name="CanceledError"}Y.inherits(no,Be,{__CANCEL__:!0});function td(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new Be("Request failed with status code "+t.status,[Be.ERR_BAD_REQUEST,Be.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Aw(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function Lw(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(c){const d=Date.now(),u=o[r];s||(s=d),t[i]=c,o[i]=d;let m=r,h=0;for(;m!==i;)h+=t[m++],m=m%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const p=u&&d-u;return p?Math.round(h*1e3/p):void 0}}function Uw(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-m)))},()=>i&&s(i)]}const $a=(a,n,t=3)=>{let o=0;const i=Lw(50,250);return Uw(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-o,d=i(c),u=s<=l;o=s;const m={loaded:s,total:l,progress:l?s/l:void 0,bytes:c,rate:d||void 0,estimated:d&&l&&u?(l-s)/d:void 0,event:r,lengthComputable:l!=null,[n?"download":"upload"]:!0};a(m)},t)},El=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},Sl=a=>(...n)=>Y.asap(()=>a(...n)),Ow=ft.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,ft.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(ft.origin),ft.navigator&&/(msie|trident)/i.test(ft.navigator.userAgent)):()=>!0,Pw=ft.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];Y.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),Y.isString(o)&&s.push("path="+o),Y.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 zw(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function jw(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function nd(a,n,t){let o=!zw(n);return a&&(o||t==!1)?jw(a,n):n}const Vl=a=>a instanceof xt?{...a}:a;function Mn(a,n){n=n||{};const t={};function o(d,u,m,h){return Y.isPlainObject(d)&&Y.isPlainObject(u)?Y.merge.call({caseless:h},d,u):Y.isPlainObject(u)?Y.merge({},u):Y.isArray(u)?u.slice():u}function i(d,u,m,h){if(Y.isUndefined(u)){if(!Y.isUndefined(d))return o(void 0,d,m,h)}else return o(d,u,m,h)}function r(d,u){if(!Y.isUndefined(u))return o(void 0,u)}function s(d,u){if(Y.isUndefined(u)){if(!Y.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function l(d,u,m){if(m in n)return o(d,u);if(m in a)return o(void 0,d)}const c={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:l,headers:(d,u,m)=>i(Vl(d),Vl(u),m,!0)};return Y.forEach(Object.keys({...a,...n}),function(u){const m=c[u]||i,h=m(a[u],n[u],u);Y.isUndefined(h)&&m!==l||(t[u]=h)}),t}const od=a=>{const n=Mn({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=xt.from(s),n.url=qc(nd(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(Y.isFormData(t)){if(ft.hasStandardBrowserEnv||ft.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(ft.hasStandardBrowserEnv&&(o&&Y.isFunction(o)&&(o=o(n)),o||o!==!1&&Ow(n.url))){const d=i&&r&&Pw.read(r);d&&s.set(i,d)}return n},Ww=typeof XMLHttpRequest<"u",Zw=Ww&&function(a){return new Promise(function(t,o){const i=od(a);let r=i.data;const s=xt.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,m,h,p,y;function g(){p&&p(),y&&y(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(i.method.toUpperCase(),i.url,!0),x.timeout=i.timeout;function M(){if(!x)return;const b=xt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),w={data:!l||l==="text"||l==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:b,config:a,request:x};td(function(T){t(T),g()},function(T){o(T),g()},w),x=null}"onloadend"in x?x.onloadend=M:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(M)},x.onabort=function(){x&&(o(new Be("Request aborted",Be.ECONNABORTED,a,x)),x=null)},x.onerror=function(){o(new Be("Network Error",Be.ERR_NETWORK,a,x)),x=null},x.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const w=i.transitional||Kc;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),o(new Be(f,w.clarifyTimeoutError?Be.ETIMEDOUT:Be.ECONNABORTED,a,x)),x=null},r===void 0&&s.setContentType(null),"setRequestHeader"in x&&Y.forEach(s.toJSON(),function(f,w){x.setRequestHeader(w,f)}),Y.isUndefined(i.withCredentials)||(x.withCredentials=!!i.withCredentials),l&&l!=="json"&&(x.responseType=i.responseType),d&&([h,y]=$a(d,!0),x.addEventListener("progress",h)),c&&x.upload&&([m,p]=$a(c),x.upload.addEventListener("progress",m),x.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=b=>{x&&(o(!b||b.type?new no(null,a,x):b),x.abort(),x=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const C=Aw(i.url);if(C&&ft.protocols.indexOf(C)===-1){o(new Be("Unsupported protocol "+C+":",Be.ERR_BAD_REQUEST,a));return}x.send(r||null)})},Xw=(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,l();const u=d instanceof Error?d:this.reason;o.abort(u instanceof Be?u:new no(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Be(`timeout ${n} of ms exceeded`,Be.ETIMEDOUT))},n);const l=()=>{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:c}=o;return c.unsubscribe=()=>Y.asap(l),c}},Hw=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},Gw=async function*(a,n){for await(const t of Jw(a))yield*Hw(t,n)},Jw=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()}},_l=(a,n,t,o)=>{const i=Gw(a,n);let r=0,s,l=c=>{s||(s=!0,o&&o(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let m=u.byteLength;if(t){let h=r+=m;t(h)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},ai=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ad=ai&&typeof ReadableStream=="function",Yw=ai&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),id=(a,...n)=>{try{return!!a(...n)}catch{return!1}},qw=ad&&id(()=>{let a=!1;const n=new Request(ft.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),Cl=64*1024,yr=ad&&id(()=>Y.isReadableStream(new Response("").body)),Ra={stream:yr&&(a=>a.body)};ai&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Ra[n]&&(Ra[n]=Y.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new Be(`Response type '${n}' is not supported`,Be.ERR_NOT_SUPPORT,o)})})})(new Response);const Kw=async a=>{if(a==null)return 0;if(Y.isBlob(a))return a.size;if(Y.isSpecCompliantForm(a))return(await new Request(ft.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(a)||Y.isArrayBuffer(a))return a.byteLength;if(Y.isURLSearchParams(a)&&(a=a+""),Y.isString(a))return(await Yw(a)).byteLength},Qw=async(a,n)=>{const t=Y.toFiniteNumber(a.getContentLength());return t??Kw(n)},e2=ai&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:h}=od(a);d=d?(d+"").toLowerCase():"text";let p=Xw([i,r&&r.toAbortSignal()],s),y;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let x;try{if(c&&qw&&t!=="get"&&t!=="head"&&(x=await Qw(u,o))!==0){let w=new Request(n,{method:"POST",body:o,duplex:"half"}),F;if(Y.isFormData(o)&&(F=w.headers.get("content-type"))&&u.setContentType(F),w.body){const[T,E]=El(x,$a(Sl(c)));o=_l(w.body,Cl,T,E)}}Y.isString(m)||(m=m?"include":"omit");const M="credentials"in Request.prototype;y=new Request(n,{...h,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:M?m:void 0});let C=await fetch(y,h);const b=yr&&(d==="stream"||d==="response");if(yr&&(l||b&&g)){const w={};["status","statusText","headers"].forEach(B=>{w[B]=C[B]});const F=Y.toFiniteNumber(C.headers.get("content-length")),[T,E]=l&&El(F,$a(Sl(l),!0))||[];C=new Response(_l(C.body,Cl,T,()=>{E&&E(),g&&g()}),w)}d=d||"text";let f=await Ra[Y.findKey(Ra,d)||"text"](C,a);return!b&&g&&g(),await new Promise((w,F)=>{td(w,F,{data:f,headers:xt.from(C.headers),status:C.status,statusText:C.statusText,config:a,request:y})})}catch(M){throw g&&g(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Be("Network Error",Be.ERR_NETWORK,a,y),{cause:M.cause||M}):Be.from(M,M&&M.code,a,y)}}),br={http:hw,xhr:Zw,fetch:e2};Y.forEach(br,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const Nl=a=>`- ${a}`,t2=a=>Y.isFunction(a)||a===null||a===!1,rd={getAdapter:a=>{a=Y.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,!t2(t)&&(o=br[(s=String(t)).toLowerCase()],o===void 0))throw new Be(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
|
|
339
|
-
`+r.map(Nl).join(`
|
|
340
|
-
`):" "+Nl(r[0]):"as no adapter specified";throw new Be("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:br};function Xi(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new no(null,a)}function Tl(a){return Xi(a),a.headers=xt.from(a.headers),a.data=Zi.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),rd.getAdapter(a.adapter||jo.adapter)(a).then(function(o){return Xi(a),o.data=Zi.call(a,a.transformResponse,o),o.headers=xt.from(o.headers),o},function(o){return ed(o)||(Xi(a),o&&o.response&&(o.response.data=Zi.call(a,a.transformResponse,o.response),o.response.headers=xt.from(o.response.headers))),Promise.reject(o)})}const sd="1.11.0",ii={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{ii[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const Ml={};ii.transitional=function(n,t,o){function i(r,s){return"[Axios v"+sd+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,l)=>{if(n===!1)throw new Be(i(s," has been removed"+(t?" in "+t:"")),Be.ERR_DEPRECATED);return t&&!Ml[s]&&(Ml[s]=!0),n?n(r,s,l):!0}};ii.spelling=function(n){return(t,o)=>!0};function n2(a,n,t){if(typeof a!="object")throw new Be("options must be an object",Be.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 l=a[r],c=l===void 0||s(l,r,a);if(c!==!0)throw new Be("option "+r+" must be "+c,Be.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Be("Unknown option "+r,Be.ERR_BAD_OPTION)}}const xa={assertOptions:n2,validators:ii},Xt=xa.validators;let Nn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new kl,response:new kl}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
|
341
|
-
`+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=Mn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&xa.assertOptions(o,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),i!=null&&(Y.isFunction(i)?t.paramsSerializer={serialize:i}:xa.assertOptions(i,{encode:Xt.function,serialize:Xt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),xa.assertOptions(t,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&Y.merge(r.common,r[t.method]);r&&Y.forEach(["delete","get","head","post","put","patch","common"],y=>{delete r[y]}),t.headers=xt.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(c=c&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,m=0,h;if(!c){const y=[Tl.bind(this),void 0];for(y.unshift(...l),y.push(...d),h=y.length,u=Promise.resolve(t);m<h;)u=u.then(y[m++],y[m++]);return u}h=l.length;let p=t;for(m=0;m<h;){const y=l[m++],g=l[m++];try{p=y(p)}catch(x){g.call(this,x);break}}try{u=Tl.call(this,p)}catch(y){return Promise.reject(y)}for(m=0,h=d.length;m<h;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=Mn(this.defaults,n);const t=nd(n.baseURL,n.url,n.allowAbsoluteUrls);return qc(t,n.params,n.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(n){Nn.prototype[n]=function(t,o){return this.request(Mn(o||{},{method:n,url:t,data:(o||{}).data}))}});Y.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,l){return this.request(Mn(l||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Nn.prototype[n]=t(),Nn.prototype[n+"Form"]=t(!0)});let o2=class ld{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(l=>{o.subscribe(l),r=l}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,l){o.reason||(o.reason=new no(r,s,l),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 ld(function(i){n=i}),cancel:n}}};function a2(a){return function(t){return a.apply(null,t)}}function i2(a){return Y.isObject(a)&&a.isAxiosError===!0}const wr={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(wr).forEach(([a,n])=>{wr[n]=a});function cd(a){const n=new Nn(a),t=Uc(Nn.prototype.request,n);return Y.extend(t,Nn.prototype,n,{allOwnKeys:!0}),Y.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return cd(Mn(a,i))},t}const Je=cd(jo);Je.Axios=Nn;Je.CanceledError=no;Je.CancelToken=o2;Je.isCancel=ed;Je.VERSION=sd;Je.toFormData=oi;Je.AxiosError=Be;Je.Cancel=Je.CanceledError;Je.all=function(n){return Promise.all(n)};Je.spread=a2;Je.isAxiosError=i2;Je.mergeConfig=Mn;Je.AxiosHeaders=xt;Je.formToJSON=a=>Qc(Y.isHTMLForm(a)?new FormData(a):a);Je.getAdapter=rd.getAdapter;Je.HttpStatusCode=wr;Je.default=Je;const{Axios:zC,AxiosError:jC,CanceledError:WC,isCancel:ZC,CancelToken:XC,VERSION:HC,all:GC,Cancel:JC,isAxiosError:YC,spread:qC,toFormData:KC,AxiosHeaders:QC,HttpStatusCode:eN,formToJSON:tN,getAdapter:nN,mergeConfig:oN}=Je;class Hr{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,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.error_message??"Render job failed"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(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 l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(o.completed_at=l),o}}new Hr;const r2={key:0,class:"mobile-layout"},s2={class:"mobile-toolbar"},l2={class:"mobile-toolbar-left"},c2=["aria-label"],d2={class:"mobile-toolbar-right"},u2=["disabled"],m2=["disabled"],p2={class:"preview-section"},f2={key:0,class:"mobile-export-overlay"},h2={class:"mobile-export-progress"},v2={class:"mobile-export-bar"},g2={class:"mobile-timeline-zoom"},y2={class:"mobile-edit-strip"},b2={class:"mobile-selection-summary"},w2={class:"mobile-selection-title"},k2={class:"mobile-selection-meta"},x2={class:"mobile-readout-row"},E2=["disabled"],S2={class:"mobile-readout-grid"},V2={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},_2={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},C2={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},N2={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},T2=["disabled"],M2={class:"mobile-speed-strip"},B2={class:"mobile-speed-chips"},I2=["data-testid","onClick"],F2={class:"mobile-edit-actions"},$2=["disabled"],R2=["disabled"],D2=["disabled"],A2=["disabled"],L2=["disabled"],U2={class:"mobile-action-sheet-header"},O2={class:"mobile-action-sheet-title"},P2={class:"mobile-action-sheet-subtitle"},z2={class:"mobile-action-sheet-actions"},j2=["disabled"],W2=["disabled"],Z2=["disabled"],X2=["disabled"],H2=["disabled"],G2={key:1,class:"desktop-layout"},J2={class:"desktop-main-row"},Y2={class:"preview-panel"},q2={class:"fit-toggle"},K2={class:"editor-content"},Q2={class:"editor-tabs"},ek={class:"tab-header"},tk=["onClick"],nk={class:"tab-content-area"},ok={class:"filter-controls"},ak={class:"text-controls"},ik={class:"transition-controls"},rk={class:"audio-controls"},sk={class:"adjustments-controls"},lk={key:1,class:"no-filter-selected"},ck={class:"export-controls"},dk={key:0,"data-testid":"video-export-status-completed"},uk={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},mk={class:"desktop-timeline-row"},pk={class:"timeline-zoom"},fk=["value"],hk={class:"zoom-readout"},vk={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},gk={class:"dev-editor-row"},yk={class:"dev-editor-field"},bk={class:"dev-editor-field"},wk=["disabled"],kk=["disabled"],xk=["disabled"],Ek={class:"dev-editor-row"},Sk={class:"dev-editor-field dev-editor-field--wide"},Vk=["value"],_k=["disabled"],Ck=["disabled"],Nk=["disabled"],Tk=["disabled"],Mk=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const v=o.media.uuid??o.media.id;return typeof v=="string"&&v.trim()!==""?v.trim():void 0}),s=e.computed(()=>{const v=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return v!==""?v:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),c=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const v=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},k=o.featureFlags;return k?{filters:typeof k.filters=="boolean"?k.filters:v.filters,adjustments:typeof k.adjustments=="boolean"?k.adjustments:v.adjustments,text:typeof k.text=="boolean"?k.text:v.text,transitions:typeof k.transitions=="boolean"?k.transitions:v.transitions,audio:typeof k.audio=="boolean"?k.audio:v.audio,export:typeof k.export=="boolean"?k.export:v.export}:v}),m=e.computed(()=>l.value?c.value:d.value),h=e.computed(()=>m.value==="filters"||x.value),p=e.computed(()=>m.value!=="filters"&&!x.value),y=e.ref(null),g=e.ref(null),x=e.ref(!1),M=e.computed(()=>l.value?y.value:g.value);function C(v){return v==="contain"||v==="cover"||v==="none"}function b(v){if(!(v!=null&&v.metadata))return null;const k=v.metadata.fit_mode;return C(k)?k:null}const f=e.shallowRef(null),w=e.ref(null),F=e.ref(b(o.initialRecipe)??"contain"),T=e.ref(null),E=e.ref(null),B=e.ref(null),U=e.ref(!1),S=new Map,D=e.ref([]),I=e.ref([]),j=e.ref([]),$=e.ref([]),P=e.ref(1),O=()=>{l.value=window.innerWidth<768},V=[{id:"filters",label:"Filters",icon:fn},{id:"adjustments",label:"Adjust",icon:Om},{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:Co}],R=[{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(()=>V.filter(v=>u.value[v.id])),J=e.computed(()=>R.filter(v=>u.value[v.id])),te=e.computed(()=>{var v,k;return((v=J.value[0])==null?void 0:v.id)??((k=G.value[0])==null?void 0:k.id)??"filters"});e.watch(u,v=>{v[c.value]||(c.value=te.value),v[d.value]||(d.value=te.value)},{immediate:!0,deep:!0}),e.watch(te,v=>{u.value[c.value]||(c.value=v),u.value[d.value]||(d.value=v)},{immediate:!0}),e.watch(u,v=>{v.export||(c.value==="export"&&(c.value=te.value),d.value==="export"&&(d.value=te.value))},{immediate:!0,deep:!0});const fe=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),ye=ac(),{currentFrame:oe,playheadPosition:_,timelineClips:A,totalDuration:Q,hasChanges:ee,isPlaying:ne,selectedClip:pe,zoomLevel:ie,playbackSpeed:me,handleTrim:we,handleSplit:ae,handleClipSelect:le,splitAtPlayhead:ke,deleteSelectedClip:_e,duplicateSelectedClip:ut,setZoomLevel:Ze,moveClip:St,setFilters:He,setTextOverlays:nt,setAudioTracks:Vt,saveDraft:$t,clearHasChanges:st,resetChanges:yt,generateRecipe:ce,zoomIn:xe,zoomOut:Ee,fitToWindow:Oe,togglePlayback:N,setPlaying:z,seekTo:H,frameForward:q,frameBackward:de,skipToStart:he,skipToEnd:Ne,setPlaybackSpeed:Fe,updateSourceDuration:Me,undo:De,redo:Qe,canUndo:ht,canRedo:Ot}=gb(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:oo,activeFilters:et,selectedFilter:as,previewFilter:Wo,previewFilterEffect:is,applyFilter:rs,updateFilterParams:Ad,removeFilter:Ld,clearAllFilters:ss,setActiveFilters:Ud}=Cb();function ao(v){var Z,K;const k=((Z=pe.value)==null?void 0:Z.id)??((K=A.value[0])==null?void 0:K.id);k&&(U.value=!0,typeof v=="object"&&v.id?rs(v.id):typeof v=="string"&&rs(v),He(et.value),f.value?f.value.setClipFilters(k,et.value):S.set(k,[...et.value]),le(k),U.value=!1,jt())}function Od(){var k,Z;const v=((k=pe.value)==null?void 0:k.id)??((Z=A.value[0])==null?void 0:Z.id);v&&le(v)}function ls(v){const k=et.value.find(Z=>Z.filterId===v);k&&Ld(k.id)}const io=e.computed(()=>oo.value.map(k=>{var K;const Z=[];if(k.controls&&k.controls.length>0)for(const ue of k.controls){const re=ue.type;if(re==="button"||re==="text"||re==="range")continue;const se={id:ue.property||ue.id,label:ue.label||ue.id,type:re,default:ue.default??(re==="toggle"?!1:re==="color"?"#ffffff":0)};re==="slider"&&(se.min=ue.min??0,se.max=ue.max??1,se.step=ue.step??.01),re==="select"&&ue.options&&(se.options=ue.options),Z.push(se)}else if(k.paramRanges){const ue=Object.entries(k.paramRanges);for(const[re,se]of ue){const Ae=re.replace(/[-_]/g," ").replace(/\b\w/g,Wt=>Wt.toUpperCase()),vt=(K=k.defaultParams)==null?void 0:K[re],tn=(se.min+se.max)/2;Z.push({id:re,label:Ae,min:se.min,max:se.max,step:se.step??.01,default:typeof vt=="number"?vt:tn})}}return{id:k.id,name:k.name,category:k.category,params:Z}})),Rn=e.ref("0.00"),Dn=e.ref("0.00"),rn=e.ref("");e.watch(io,v=>{if(v.length===0){rn.value="";return}v.some(Z=>Z.id===rn.value)||(rn.value=v[0].id)},{immediate:!0});const ot=e.ref(!1),Xe=e.ref(0),Qt=e.ref(!1),We=e.ref(null),Rt=e.ref(null);let Zo=null,Mt=!1,en=null;const ci=e.computed(()=>{const v=new Map;return et.value.forEach(k=>v.set(k.filterId,k)),v}),Pd=e.computed(()=>{var v,k;return oe.value?oe.value:((v=o.media)==null?void 0:v.thumbnail_url)||((k=o.media)==null?void 0:k.url)}),Pt=e.ref("");e.watch(()=>{var v,k;return{file:(v=o.media)==null?void 0:v.file,url:(k=o.media)==null?void 0:k.url}},(v,k,Z)=>{var ue,re;const K=Pt.value;Z(()=>{K&&K.startsWith("blob:")&&URL.revokeObjectURL(K)}),(ue=o.media)!=null&&ue.file?Pt.value=URL.createObjectURL(o.media.file):(re=o.media)!=null&&re.url?Pt.value=o.media.url:Pt.value=""},{immediate:!0}),e.onUnmounted(()=>{Pt.value&&Pt.value.startsWith("blob:")&&URL.revokeObjectURL(Pt.value)});const di=e.computed(()=>Pt.value),cs=e.computed(()=>{if(!o.media)return null;const{file:v,...k}=o.media;return{...k,url:Pt.value}}),ds=e.computed(()=>{var k;const v=(k=o.media)==null?void 0:k.url;return!!(v&&/^https?:/i.test(v))}),us=e.computed(()=>et.value),ms=e.computed(()=>_.value),ui=e.computed(()=>!!pe.value&&_.value>0),mi=e.computed(()=>!!pe.value&&A.value.length>1),ps=e.computed(()=>!!pe.value),sn=e.ref(!0),zd=[.5,1,1.5,2],Xo=e.computed(()=>{const v=new Set([0,Bt.value]);for(const k of A.value)v.add(k.timelineStart),v.add(k.timelineEnd);return Array.from(v).filter(k=>Number.isFinite(k)).sort((k,Z)=>k-Z)}),jd=e.computed(()=>Xo.value.some(v=>v<_.value-.001)),Wd=e.computed(()=>Xo.value.some(v=>v>_.value+.001)),Ho=e.ref(!1),Go=e.ref(null);function ln(v){if(!Number.isFinite(v)||v<0)return"0:00";const k=Math.floor(v/60),Z=Math.floor(v%60);return`${k}:${Z.toString().padStart(2,"0")}`}const Zd=e.computed(()=>{var Z;const v=pe.value??A.value[0];if(!v)return"No clip selected";const k=(Z=v.label)==null?void 0:Z.trim();return k&&k.length>0?k:`Clip ${v.id.slice(-4)}`}),Xd=e.computed(()=>{const v=pe.value??A.value[0];if(!v)return"Tap a clip to start editing";const k=Math.max(0,v.timelineEnd-v.timelineStart);return`${ln(v.timelineStart)} - ${ln(v.timelineEnd)} • ${k.toFixed(1)}s`});function fs(v){return!Number.isFinite(v)||v<0?"0.0s":v<60?`${v.toFixed(1)}s`:ln(v)}const Hd=e.computed(()=>ln(_.value)),Gd=e.computed(()=>{const v=pe.value??A.value[0];return v?ln(v.sourceIn):"0:00"}),Jd=e.computed(()=>{const v=pe.value??A.value[0];return v?ln(v.sourceOut):"0:00"}),Yd=e.computed(()=>{const v=pe.value??A.value[0];return v?fs(v.timelineEnd-v.timelineStart):"0.0s"}),pi=e.computed(()=>Go.value===null?pe.value??A.value[0]??null:A.value.find(v=>v.id===Go.value)??null),qd=e.computed(()=>{var Z;const v=pi.value;if(!v)return"Clip actions";const k=(Z=v.label)==null?void 0:Z.trim();return k&&k.length>0?k:`Clip ${v.id.slice(-4)}`}),Kd=e.computed(()=>{const v=pi.value;return v?`${ln(v.timelineStart)} - ${ln(v.timelineEnd)} • ${fs(v.timelineEnd-v.timelineStart)}`:"Choose an action"}),fi=e.ref(0),Bt=e.computed(()=>{try{const v=Q.value??Q;return v&&typeof v=="number"&&v>0?v:fi.value}catch{return fi.value}}),An=e.ref(),hi=e.ref(),vi=e.ref(),gi=e.ref(),Jo=e.ref(0),vn=e.ref(!1);let bt=null,zt=null;e.watch(Bt,v=>{var Z;if(vn.value||!v||v<=0)return;const k=Jo.value||((Z=An.value)==null?void 0:Z.clientWidth)||0;k>0&&(vn.value=!0,Oe(k))}),e.watch(Jo,v=>{if(vn.value||!v||v<=0)return;Bt.value>0&&(vn.value=!0,Oe(v))}),e.watch(l,v=>{v||gn()}),e.watch(()=>{var v;return(v=pi.value)==null?void 0:v.id},v=>{Ho.value&&!v&&gn()});function Ln(v){return Number.isFinite(v)?v.toFixed(2):"0.00"}function hs(v){const k=Number(v);return Number.isFinite(k)?k:null}function Qd(v){v&&(Rn.value=Ln(v.sourceIn),Dn.value=Ln(v.sourceOut))}e.watch(()=>{var v,k,Z;return[(v=pe.value)==null?void 0:v.id,(k=pe.value)==null?void 0:k.sourceIn,(Z=pe.value)==null?void 0:Z.sourceOut]},()=>{Qd(pe.value)},{immediate:!0});function vs(v){const k=pe.value;if(!k)return;const Z=1/30,K=k.sourceMinIn??0,ue=k.sourceMaxOut??Bt.value,re=k.sourceIn+(_.value-k.timelineStart);if(v==="start"){const Ae=Math.max(K,Math.min(re,k.sourceOut-Z));Rn.value=Ln(Ae);return}const se=Math.max(k.sourceIn+Z,Math.min(re,ue));Dn.value=Ln(se)}function eu(){const v=pe.value;if(!v)return;const k=hs(Rn.value),Z=hs(Dn.value);if(k===null||Z===null)return;const K=1/30,ue=v.sourceMinIn??0,re=v.sourceMaxOut??Bt.value,se=Math.max(ue,Math.min(k,re-K)),Ae=Math.max(se+K,Math.min(Z,re));we(v.id,"start",se),we(v.id,"end",Ae),Rn.value=Ln(se),Dn.value=Ln(Ae),pe.value&&H(pe.value.timelineStart)}function tu(){rn.value.trim()!==""&&ao(rn.value)}function nu(){var v;ss(),He(et.value),(v=pe.value)!=null&&v.id&&(f.value?f.value.setClipFilters(pe.value.id,et.value):S.set(pe.value.id,[...et.value])),jt()}function gs(v,k,Z){var ue,re;const K=et.value.find(se=>se.filterId===v);K?(K.params={...K.params,[k]:Z},He(et.value),f.value&&((ue=pe.value)!=null&&ue.id)?f.value.setClipFilters(pe.value.id,et.value):(re=pe.value)!=null&&re.id&&S.set(pe.value.id,[...et.value]),jt(),Od()):Wo.value&&Wo.value.filterId===v&&(Wo.value.params={...Wo.value.params||{},[k]:Z})}function ys(v){H(v)}function bs(v){!v||!Number.isFinite(v.timestamp)||H(v.timestamp)}function ws(v){z(v)}function Yo(v){!Number.isFinite(v)||v<=0||(fi.value=v,Me(v))}function gn(){Ho.value=!1,Go.value=null}function ou(v){l.value&&(Go.value=v,Ho.value=!0)}function yi(v){var K,ue,re,se;const k=((K=pe.value)==null?void 0:K.id)??((ue=A.value[0])==null?void 0:ue.id)??null;le(v),(((re=pe.value)==null?void 0:re.id)??((se=A.value[0])==null?void 0:se.id)??null)!==k&&ye.selection()}function ks(v){yi(v),ou(v)}function xs(v){v&&ye.selection()}function Es(){sn.value=!sn.value,ye.selection()}function Ss(){const v=Xo.value.filter(Z=>Z<_.value-.001),k=v.length>0?v[v.length-1]:0;H(k)}function Vs(){const v=Xo.value.find(k=>k>_.value+.001);H(v??Bt.value)}function bi(){De()}function wi(){Qe()}function qo(){const v=A.value.length;ke(),A.value.length>v&&(ye.success(),gn())}function _s(v){const k=A.value.length;ae(v),A.value.length>k&&ye.success()}function ki(){const v=A.value.length;ut(),A.value.length>v&&(ye.selection(),gn())}function xi(){const v=A.value.length;_e(),A.value.length<v&&(ye.error(),gn())}function au(v){const k=me.value;Fe(v),me.value!==k&&ye.selection()}function iu(v){return v instanceof HTMLElement?v.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Cs(v){if(l.value||iu(v.target))return;const k=v.key.toLowerCase(),Z=v.metaKey||v.ctrlKey;if(v.code==="Space"){v.preventDefault(),N();return}if(!Z&&k==="s"){v.preventDefault(),qo();return}if(k==="arrowleft"){v.preventDefault(),de();return}if(k==="arrowright"){v.preventDefault(),q();return}if(k==="home"){v.preventDefault(),he();return}if(k==="end"){v.preventDefault(),Ne();return}if(!Z&&k==="["){v.preventDefault(),Ss();return}if(!Z&&k==="]"){v.preventDefault(),Vs();return}if(Z&&k==="z"&&v.shiftKey){v.preventDefault(),wi();return}Z&&k==="z"&&(v.preventDefault(),bi())}function ru(){var k;const v=Jo.value||((k=An.value)==null?void 0:k.clientWidth)||800;Oe(v)}function Ei(v){vn.value=!0,Ze(v)}function su(){vn.value=!0,xe()}function lu(){vn.value=!0,Ee()}function cu(v){const k=v.target,Z=Number(k.value);Ei(Z)}function Ns(v){const k=Math.min(600,Math.max(10,ie.value+v));Ei(k)}function Si(){zt==null||zt(),zt=null;const v=vi.value,k=gi.value;if(!l.value||!v||!k)return;const Z=()=>{Ns(-20)},K=()=>{Ns(20)};v.addEventListener("click",Z),k.addEventListener("click",K),zt=()=>{v.removeEventListener("click",Z),k.removeEventListener("click",K)}}e.watch([l,vi,gi],()=>{Si()},{flush:"post"});function Ts(v){var k;f.value=v,(k=f.value)!=null&&k.composition&&(T.value=new Nb(f.value.composition),E.value=new Fa(f.value.composition),B.value=new Tb(f.value.composition));try{S.size&&(S.forEach((Z,K)=>{f.value.setClipFilters(K,Z)}),S.clear(),f.value.composition.computeFrame())}catch{}}function du(v){v!=null&&v.id&&is(v.id)}function uu(v){Ad(v),jt()}async function mu(v){if(!T.value)return;const k=await T.value.addTextOverlay(v);D.value.push({id:k,...v})}async function pu(v,k){if(!T.value)return;await T.value.updateTextOverlay(v,k);const Z=D.value.findIndex(K=>K.id===v);Z!==-1&&(D.value[Z]={...D.value[Z],...k})}async function fu(v){T.value&&(await T.value.removeTextOverlay(v),D.value=D.value.filter(k=>k.id!==v))}async function hu(v){if(!E.value||$.value.length<2)return;const[k,Z]=$.value,K=await E.value.applyTransition(k,Z,v);I.value.push({id:K,...v,name:v.type})}function vu(v){if(!E.value)return;const k=I.value[v];k&&(E.value.removeTransition(k.id),I.value.splice(v,1))}function gu(v){}async function yu(v){if(!B.value)return;const k=await B.value.addAudioTrack(v);j.value.push({id:k,...v})}async function bu(v,k){if(!B.value)return;const Z=j.value.findIndex(K=>K.id===v);Z!==-1&&(j.value[Z]={...j.value[Z],...k})}async function wu(v){B.value&&(await B.value.removeAudioTrack(v),j.value=j.value.filter(k=>k.id!==v))}async function ku(v,k){if(!B.value)return;await B.value.updateVolume(v,k);const Z=j.value.find(K=>K.id===v);Z&&(Z.volume=k)}async function xu(v,k){if(!B.value)return;await B.value.muteTrack(v,k);const Z=j.value.find(K=>K.id===v);Z&&(Z.muted=k)}function Eu(v){B.value&&(B.value.setMasterVolume(v),P.value=v)}function Su(v){i("thumbnail-selected",v)}function cn(){Zo!==null&&(clearInterval(Zo),Zo=null)}function Vu(v,k){return k?{...v,output:{...v.output,format:k.format,quality:k.quality}}:v}function ro(v){var k;return v.metadata||(v.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),v.metadata.fit_mode=F.value,(k=o.media)!=null&&k.url&&/^https?:/i.test(o.media.url)?v.metadata.source_url=o.media.url:delete v.metadata.source_url,v}function Ge(v,k,Z){return Math.min(Z,Math.max(k,v))}function Vi(v,k){if(typeof v=="number"&&Number.isFinite(v))return v;if(typeof v=="string"){const Z=Number(v);if(Number.isFinite(Z))return Z}return k}function mt(v,k,Z){for(const K of k)if(K in v)return Vi(v[K],Z);return Z}function _u(v){const k=typeof v.params=="object"&&v.params!==null?v.params:{};switch(v.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Ge(mt(k,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Ge(mt(k,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Ge(mt(k,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Ge(mt(k,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Ge(mt(k,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const K=Ge(mt(k,["brightness"],1)-1,-1,1),ue=Ge(mt(k,["contrast"],1),.1,3),re=Ge(mt(k,["saturation"],1),0,3);return[{type:"brightness",value:K},{type:"contrast",value:ue},{type:"saturation",value:re}]}default:return[]}}function Cu(v){const k=v.timeline[0],Z=Array.isArray(k==null?void 0:k.filters)?k.filters:[],K=[];for(const re of Z)if(K.push(..._u(re)),K.length>=12)break;const ue={...v,filters:K.slice(0,12)};if(v.timeline.length===1&&k){const re=Math.max(0,Vi(k.sourceIn,0)),se=Vi(k.sourceOut,re);se>re&&(ue.trim={start:re,end:se})}return ue}function Nu(v){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[v??""]??[1920,1080]}function Tu(v){if(!v||typeof v!="object")return null;const k=v.duration;if(typeof k=="number"&&Number.isFinite(k)&&k>0)return k;if(k&&typeof k=="object"&&"value"in k){const Z=k.value;if(typeof Z=="number"&&Number.isFinite(Z)&&Z>0)return Z}return null}async function Ms(v,k,Z){var tn,Wt,Un,un;const K=v.timeline[0],ue=K?Math.max(0,K.sourceIn):0,re=K?K.sourceOut:void 0,[se,Ae]=Nu((k==null?void 0:k.quality)??((tn=v.output)==null?void 0:tn.quality)),vt=((Wt=v.output)==null?void 0:Wt.fps)||30;z(!1),x.value=!0,await e.nextTick();try{const at=[200,500,1e3];let lt=!1;for(const Fi of at){await new Promise(Ju=>setTimeout(Ju,Fi));const ea=M.value;if(!(!ea||typeof ea.captureFrameAt!="function")&&typeof ea.ensureReadyForCapture=="function"&&(lt=await ea.ensureReadyForCapture(),lt))break}const Zt=M.value;if(!Zt||typeof Zt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!lt)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:so,isWebCodecsSupported:Bi}=await Promise.resolve().then(()=>require("./PixiFrameExporter-BrsHCMHb.cjs"));if(!Bi())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");en=new AbortController;const Qo={width:se,height:Ae,fps:vt,trimStart:ue,signal:en.signal};re!==void 0&&(Qo.trimEnd=re),Z&&(Qo.onProgress=Z);const Us=Pt.value;Us!==""&&(Qo.sourceUrl=Us);const Wu=typeof Zt.duration=="number"&&Zt.duration>0?Zt.duration:((Un=v.source)==null?void 0:Un.duration)??re??0,Zu=await so({captureFrameAt:Fi=>Zt.captureFrameAt(Fi),duration:{value:Wu}},Qo),Ii=new File([Zu],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),Xu=Tu(Zt),Hu=((un=v.source)==null?void 0:un.duration)??0,Gu=Math.max(0,(re??Xu??Hu)-ue);return{file:Ii,recipe:v,meta:{duration:Gu,width:se,height:Ae,format:"mp4",sizeBytes:Ii.size,size_bytes:Ii.size}}}finally{x.value=!1,en=null}}async function Mu(v,k){var un;cn(),Mt=!1,en=null,Rt.value=null,We.value=null,Qt.value=!1,Xe.value=0;const Z=ro(v??ce()),K=As(Z),ue=Array.isArray(K.filters)&&K.filters.length>0,re=Ni(K);if(!(ee.value||ue||re))return st(),i("video-exported",null),null;const Ae=K.timeline[0],vt=Ae?Math.max(0,Ae.sourceIn):0,Wt=((Ae==null?void 0:Ae.sourceOut)??((un=K.source)==null?void 0:un.duration)??Bt.value)-vt,Un=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&Wt>o.clientExportThreshold;if(Un){ot.value=!0;try{return await Bu(K),null}catch(at){const lt=at instanceof Error?at.message:"Server render failed";throw We.value=lt,i("server-render-failed",lt),at}finally{ot.value=!1}}if(o.maxDuration>0&&Wt>o.maxDuration&&!Un){const at=`This video is too long for in-browser export (${Math.round(Wt)}s). Server rendering is not available. Try a shorter clip.`;return We.value=at,i("video-exported",null),null}ot.value=!0;try{const at=await Ms(K,k,lt=>{Mt||(Xe.value=lt)});return Mt?(We.value="Export canceled.",Xe.value=0,i("video-exported",null),null):(st(),i("recipe-generated",K),i("video-exported",at),Xe.value=100,Qt.value=!0,at)}catch(at){if(Mt)return We.value="Export canceled.",Xe.value=0,i("video-exported",null),null;const lt=at instanceof Error?at.message:"Local WebGL export failed.";throw We.value=lt,new Error(`Video export failed: ${lt}`)}finally{ot.value=!1}}function Ko(){return new Hr(o.serverRenderEndpoint??"/api/v1")}async function Bu(v){const k=Ko();We.value="Starting server render...",Xe.value=0;const Z=await k.createRenderJob({source_media_uuid:s.value,recipe:v});Rt.value=Z.id,i("server-render-started",Z.id),i("export-started",Z.id),We.value="Rendering on server...";const K=await k.pollRenderJob(Z.id,(re,se)=>{Xe.value=re,se==="processing"&&(We.value=`Server rendering: ${re}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);Xe.value=100,Qt.value=!0,We.value="Server render complete!",st(),i("recipe-generated",v);const ue={id:K.id};typeof K.output_media_id=="string"&&K.output_media_id!==""&&(ue.output_media_id=K.output_media_id),i("server-render-completed",ue)}async function Bs(){if(!ot.value)return;Mt=!0,x.value=!1,en&&(en.abort(),en=null),cn();const v=Rt.value;if(v)try{await Ko().cancelJob(v)}catch(k){const Z=k instanceof Error?k.message:"Failed to cancel export";We.value=Z,ot.value=!1,Rt.value=null;return}ot.value=!1,Xe.value=0,Qt.value=!1,Rt.value=null,We.value="Export canceled."}async function Is(v){cn(),Mt=!1,en=null,Rt.value=null,We.value=null,Qt.value=!1,ot.value=!0,Xe.value=0;try{const k=ro(Vu(ce(),v));i("recipe-generated",k);const Z=s.value.startsWith("temp-"),K=k.timeline[0],ue=Array.isArray(K==null?void 0:K.filters)?K.filters:[],re=!0,se=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(re)try{const lt=await Ms(k,v,Bi=>{Mt||(Xe.value=Bi)});if(Mt){We.value="Export canceled.",ot.value=!1,Xe.value=0;return}i("video-exported",lt);const Zt=URL.createObjectURL(lt.file),so=document.createElement("a");so.href=Zt,so.download=`edited-video-${Date.now()}.mp4`,so.click(),setTimeout(()=>URL.revokeObjectURL(Zt),100),ot.value=!1,Xe.value=100,Qt.value=!0;return}catch(lt){if(Mt){We.value="Export canceled.",ot.value=!1,Xe.value=0;return}if(Z||!se)throw lt;Xe.value=0,We.value="Local filter export failed, falling back to server render."}const Ae={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},vt=(v==null?void 0:v.quality)??k.output.quality,tn=Ae[vt]??"high",Wt={...Cu(k),export:{format:(v==null?void 0:v.format)??k.output.format,quality:tn,resolution:vt,framerate:k.output.fps}},un=await Ko().createJob({source_media_id:s.value,recipe:Wt}),at=typeof un.id=="string"?un.id:null;if(!at)throw new Error("Export failed: missing job id");Rt.value=at,i("export-started",at),zu(at)}catch(k){if(x.value=!1,en=null,Mt){We.value="Export canceled.",ot.value=!1,Xe.value=0,Rt.value=null;return}try{const Z=ro(ce()),K=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),ue=URL.createObjectURL(K),re=document.createElement("a");re.href=ue,re.download=`video-recipe-${Date.now()}.json`,re.click(),setTimeout(()=>URL.revokeObjectURL(ue),100)}finally{ot.value=!1,Xe.value=0,Rt.value=null,We.value=k instanceof Error?k.message:"Export failed"}}}const _i=async v=>{await new Promise(k=>{window.setTimeout(k,v)})},Ci=v=>{if(!v||v.width<=0||v.height<=0)return null;try{return v.toDataURL("image/jpeg",.85)}catch{return null}},Iu=v=>{if(!v||typeof v!="object")return null;const Z=v.pixiCanvas;if(Z&&typeof Z=="object"&&"value"in Z){const K=Z.value;return K instanceof HTMLCanvasElement?K:null}return Z instanceof HTMLCanvasElement?Z:null},Fu=v=>{if(!v||typeof v!="object")return null;const k=v.duration;if(typeof k=="number"&&Number.isFinite(k))return k;if(k&&typeof k=="object"&&"value"in k){const Z=k.value;if(typeof Z=="number"&&Number.isFinite(Z))return Z}return null},$u=v=>{if(!v||typeof v!="object")return null;const Z=v.videoElement;if(Z&&typeof Z=="object"&&"value"in Z){const K=Z.value;return K instanceof HTMLVideoElement?K:null}return Z instanceof HTMLVideoElement?Z:null},Fs=v=>typeof v.params=="object"&&v.params!==null?v.params:{},Ru=v=>{const k=[];for(const Z of v){const K=Fs(Z),ue=Z.filterId.trim().toLowerCase();if(ue==="brightness"){const se=(Ge(mt(K,["value","brightness"],0),-1,1)+1)*100;k.push(`brightness(${se.toFixed(2)}%)`);continue}if(ue==="contrast"){const re=Ge(mt(K,["value","contrast"],1),.1,4);k.push(`contrast(${(re*100).toFixed(2)}%)`);continue}if(ue==="saturation"||ue==="saturate"){const re=Ge(mt(K,["value","saturation"],1),0,4);k.push(`saturate(${(re*100).toFixed(2)}%)`);continue}if(ue==="grayscale"){k.push("grayscale(100%)");continue}if(ue==="sepia"){k.push("sepia(100%)");continue}if(ue==="blur"||ue==="gaussian-blur"||ue==="kawase-blur"){const re=Ge(mt(K,["value","blur","radius"],0),0,30);re>.01&&k.push(`blur(${re.toFixed(2)}px)`);continue}if(ue==="adjustment"){const re=mt(K,["brightness"],1),se=mt(K,["contrast"],1),Ae=mt(K,["saturation"],1);Math.abs(re-1)>.01&&k.push(`brightness(${(Ge(re,0,5)*100).toFixed(2)}%)`),Math.abs(se-1)>.01&&k.push(`contrast(${(Ge(se,.1,5)*100).toFixed(2)}%)`),Math.abs(Ae-1)>.01&&k.push(`saturate(${(Ge(Ae,0,5)*100).toFixed(2)}%)`);continue}if(ue==="cinematic"){k.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ue==="dramatic"){k.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ue==="dreamy"){k.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return k.join(" ")},Du=v=>{const k=v.find(ue=>ue.filterId.trim().toLowerCase()==="noise");if(!k)return 0;const Z=Fs(k),K=mt(Z,["noise","value","amount","intensity"],.2);return K<=1?Ge(K,0,1):Ge(K/100,0,1)},Au=(v,k,Z,K)=>{if(K<=0)return;const ue=v.getImageData(0,0,k,Z),re=255*K;for(let se=0;se<ue.data.length;se+=4){const Ae=(Math.random()*2-1)*re;ue.data[se]=Ge(ue.data[se]+Ae,0,255),ue.data[se+1]=Ge(ue.data[se+1]+Ae,0,255),ue.data[se+2]=Ge(ue.data[se+2]+Ae,0,255)}v.putImageData(ue,0,0)},$s=async v=>{v.readyState>=2&&v.videoWidth>0&&v.videoHeight>0||await new Promise(k=>{let Z=!1,K=0;const ue=()=>{Z||(Z=!0,v.removeEventListener("loadedmetadata",re),v.removeEventListener("loadeddata",re),v.removeEventListener("canplay",re),window.clearTimeout(K),k())},re=()=>{ue()};v.addEventListener("loadedmetadata",re),v.addEventListener("loadeddata",re),v.addEventListener("canplay",re),K=window.setTimeout(()=>ue(),800),v.play().catch(()=>{})})},Lu=async(v,k)=>{await new Promise(Z=>{let K=!1,ue=0;const re=()=>{K||(K=!0,v.removeEventListener("seeked",se),window.clearTimeout(ue),Z())},se=()=>{re()};if(Math.abs(v.currentTime-k)<.016){requestAnimationFrame(()=>re());return}v.addEventListener("seeked",se),ue=window.setTimeout(()=>re(),700),v.currentTime=k})},Rs=async(v,k)=>{await $s(v);const Z=Math.floor(v.videoWidth),K=Math.floor(v.videoHeight);if(Z<=0||K<=0)return null;const ue=Number.isFinite(v.duration)&&v.duration>0?v.duration:0,re=ue>0?Ge(k,0,ue):0;await Lu(v,re);const se=document.createElement("canvas");se.width=Z,se.height=K;const Ae=se.getContext("2d");if(!Ae)return null;const vt=Ru(et.value);vt!==""&&(Ae.filter=vt);try{Ae.drawImage(v,0,0,Z,K)}catch{return null}const tn=Du(et.value);return Au(Ae,Z,K,tn),Ci(se)},Uu=async(v,k)=>{const Z=document.createElement("video");Z.src=v,Z.muted=!0,Z.playsInline=!0,Z.preload="auto",v.startsWith("blob:")||(Z.crossOrigin="anonymous");try{return await $s(Z),await Rs(Z,k)}catch{return null}finally{Z.pause(),Z.removeAttribute("src"),Z.load()}},Ou=async v=>{const k=M.value,Z=Ci(Iu(k));if(Z)return Z;if(k!=null&&k.captureFrameAt)for(let re=0;re<4;re+=1){const se=Fu(k);if(se!==null&&se<=0&&re<2){await _i(80);continue}const Ae=await Promise.race([k.captureFrameAt(v),_i(450).then(()=>null)]),vt=Ci(Ae);if(vt)return vt;await _i(80)}const K=$u(k);if(K){const re=await Rs(K,v);if(re)return re}const ue=di.value.trim();if(ue!==""){const re=await Uu(ue,v);if(re)return re}return null},Ds=v=>v.map(k=>({...k,params:k.params&&typeof k.params=="object"?{...k.params}:k.params}));function As(v){const k=Ds(et.value);if(!Ni(v)&&k.length>0&&Array.isArray(v.timeline)&&v.timeline.length>0){const K=v.timeline[0];K&&(v.timeline=[{...K,filters:k},...v.timeline.slice(1)])}return v}const Ni=v=>Array.isArray(v.timeline)?v.timeline.some(k=>Array.isArray(k.filters)&&k.filters.length>0):!1,Pu=v=>{if(!v||typeof v!="object")return null;const k=v.posterFrame;if(typeof k!="string")return null;const Z=k.trim();return Z!==""?Z:null};async function Ti(){const v=ro(As($t())),k=Ds(et.value),Z=Ni(v)||k.length>0,K=Pu(o.initialRecipe);if(Z){const ue=_.value>0?_.value:.1;try{const re=await Ou(ue);re?v.posterFrame=re:K&&(v.posterFrame=K)}catch{K&&(v.posterFrame=K)}}else delete v.posterFrame;return st(),i("draft-saved",v),v}function Ls(){yt()&&(ss(),jt())}async function zu(v){cn();const k=Ko();Zo=window.setInterval(async()=>{try{if(Mt){cn();return}const Z=await k.getJob(v),K=Number(Z.progress??0);if(Xe.value=Number.isFinite(K)?K:0,Z.status==="completed"||Z.status==="failed"||Z.status==="cancelled")if(cn(),ot.value=!1,Rt.value=null,Z.status==="completed")Xe.value=100,Qt.value=!0,We.value=null;else{const ue=Z.status==="cancelled"||typeof Z.error_message=="string"&&/cancel/i.test(Z.error_message);We.value=ue?"Export canceled.":typeof Z.error_message=="string"&&Z.error_message.trim()!==""?Z.error_message:"Export failed"}}catch(Z){cn(),ot.value=!1,Rt.value=null,We.value=Z instanceof Error?Z.message:"Failed to check export progress"}},2e3)}function Mi(){const v=ro(ce());try{const k=v.timeline??[]}catch{}w.value=v}let yn=null;function jt(){yn&&clearTimeout(yn),yn=setTimeout(()=>{Mi(),yn=null},200)}e.watch(()=>A.value,jt,{deep:!0}),e.watch(()=>pe.value,v=>{if(U.value||!v)return;const k=(v==null?void 0:v.filters)??[];Ud(k)},{immediate:!0}),e.watch(()=>et.value,v=>{He(v),jt()},{deep:!0}),e.watch(()=>D.value,v=>{nt(v),jt()},{deep:!0}),e.watch(()=>j.value,v=>{const k=v.map(Z=>({...Z,source:typeof Z.source=="string"?Z.source:void 0}));Vt(k),jt()},{deep:!0}),e.watch(()=>_.value,jt),n({saveDraft:Ti,exportForUpload:Mu}),Mi(),e.onUnmounted(()=>{cn(),Mt=!0,yn&&(clearTimeout(yn),yn=null),f.value&&(f.value.destroy(),f.value=null),T.value=null,E.value=null,B.value=null});function ju(){bt||!hi.value||(bt=new mb({filters:io.value,callbacks:{onApplyFilter:v=>{ao(v.id)},onRemoveFilter:v=>{ls(v)},onUpdateParam:(v,k,Z)=>{gs(v,k,Z)},onPreviewFilter:v=>{is(v.id)}}}),bt.mount(hi.value),bt.setActiveFilters(ci.value))}e.watch(ci,v=>{bt==null||bt.setActiveFilters(v)},{deep:!0}),e.watch(io,v=>{bt==null||bt.setFilters(v)});let dn=null;return e.onMounted(()=>{window.addEventListener("resize",O),window.addEventListener("keydown",Cs);const v=()=>{!An.value||dn||(dn=new ResizeObserver(k=>{k[0]&&(Jo.value=Math.round(k[0].contentRect.width))}),dn.observe(An.value))};v(),dn||e.nextTick(v),l.value&&(Si(),zt||e.nextTick(Si)),o.media&&Mi(),l.value&&e.nextTick(()=>{ju()}),e.nextTick(()=>{const k=document.querySelector(".video-editor");k&&k.getBoundingClientRect();const Z=document.querySelector(".mobile-layout");Z&&Z.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",O),window.removeEventListener("keydown",Cs),dn==null||dn.disconnect(),dn=null,zt==null||zt(),zt=null,bt==null||bt.destroy(),bt=null}),(v,k)=>{var Z,K,ue,re;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",r2,[e.createElementVNode("div",s2,[e.createElementVNode("div",l2,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ne)}]),onClick:k[0]||(k[0]=(...se)=>e.unref(N)&&e.unref(N)(...se)),"aria-label":e.unref(ne)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(ne)?e.unref(Ql):e.unref(tc)},null,8,["icon"])],10,c2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:Ls,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yn)},null,8,["icon"])])]),e.createElementVNode("div",d2,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Ti,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ee)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(_r)},null,8,["icon"]),k[13]||(k[13]=e.createElementVNode("span",null,"Save",-1))],8,u2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:k[1]||(k[1]=se=>Is()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:ot.value||!e.unref(ee)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Co)},null,8,["icon"])],8,m2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:k[2]||(k[2]=se=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Xn)},null,8,["icon"])])])]),e.createElementVNode("div",p2,[e.withDirectives(e.createVNode(Gs,{ref_key:"pixiPreviewMobileRef",ref:y,"aria-hidden":!h.value,class:"preview-host-child",source:di.value,"fallback-duration":Bt.value,filters:us.value,playhead:ms.value,"is-playing":e.unref(ne),"fit-mode":F.value,active:h.value,onPlayPause:e.unref(N),onFrameUpdate:bs,onDurationChange:Yo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(pl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:cs.value,"enable-engine":p.value&&ds.value,"fit-mode":F.value,onTimeUpdate:ys,onPlayStateChange:ws,onDurationChange:Yo,onEngineReady:Ts},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),ot.value?(e.openBlock(),e.createElementBlock("div",f2,[e.createElementVNode("div",h2,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Xe.value)+"%",1),e.createElementVNode("div",v2,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Xe.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Bs},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:An,class:"timeline-section"},[e.createElementVNode("div",g2,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:vi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...k[14]||(k[14]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512),e.createElementVNode("button",{ref_key:"mobileZoomInButtonRef",ref:gi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...k[15]||(k[15]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8M8 4v8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512)]),e.createVNode(fl,{playhead:e.unref(_),clips:e.unref(A),"selected-clip-id":((Z=e.unref(pe))==null?void 0:Z.id)??((K=e.unref(A)[0])==null?void 0:K.id)??null,duration:Bt.value,"zoom-level":e.unref(ie),"snap-enabled":sn.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(H),onTrim:e.unref(we),onSplit:_s,onClipSelect:yi,onClipMove:e.unref(St),onClipLongPress:ks,onSnapStateChange:xs},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",y2,[e.createElementVNode("div",b2,[e.createElementVNode("span",w2,e.toDisplayString(Zd.value),1),e.createElementVNode("span",k2,e.toDisplayString(Xd.value),1)]),e.createElementVNode("div",x2,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!jd.value,onClick:Ss}," Prev Cut ",8,E2),e.createElementVNode("div",S2,[e.createElementVNode("span",V2,"Playhead "+e.toDisplayString(Hd.value),1),e.createElementVNode("span",_2,"In "+e.toDisplayString(Gd.value),1),e.createElementVNode("span",C2,"Out "+e.toDisplayString(Jd.value),1),e.createElementVNode("span",N2,"Duration "+e.toDisplayString(Yd.value),1)]),e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-next-cut","aria-label":"Jump to next cut",disabled:!Wd.value,onClick:Vs}," Next Cut ",8,T2)]),e.createElementVNode("div",M2,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:sn.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:Es},e.toDisplayString(sn.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",B2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(zd,se=>e.createElementVNode("button",{key:se,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(me)===se}]),"data-testid":`btn-mobile-speed-${String(se).replace(".","-")}`,onClick:Ae=>au(se)},e.toDisplayString(se)+"x ",11,I2)),64))])]),e.createElementVNode("div",F2,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(ht),onClick:bi}," Undo ",8,$2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(Ot),onClick:wi}," Redo ",8,R2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!ui.value,onClick:qo}," Split ",8,D2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!ps.value,onClick:ki}," Duplicate ",8,A2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!mi.value,onClick:xi}," Delete ",8,L2)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:hi,class:"controls-section mobile-controls"},null,512),Ho.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:gn},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:k[3]||(k[3]=e.withModifiers(()=>{},["stop"]))},[k[16]||(k[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",U2,[e.createElementVNode("span",O2,e.toDisplayString(qd.value),1),e.createElementVNode("span",P2,e.toDisplayString(Kd.value),1)]),e.createElementVNode("div",z2,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(ht),onClick:bi},"Undo",8,j2),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(Ot),onClick:wi},"Redo",8,W2),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!ui.value,onClick:qo},"Split",8,Z2),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!ps.value,onClick:ki},"Duplicate",8,X2),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!mi.value,onClick:xi},"Delete",8,H2),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:gn},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",G2,[e.createElementVNode("div",J2,[e.createElementVNode("div",Y2,[e.createElementVNode("div",q2,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":k[4]||(k[4]=se=>F.value=se),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...k[17]||(k[17]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,F.value]])])]),e.withDirectives(e.createVNode(Gs,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!h.value,class:"preview-host-child",source:di.value,"fallback-duration":Bt.value,filters:us.value,playhead:ms.value,"is-playing":e.unref(ne),"fit-mode":F.value,active:h.value,onPlayPause:e.unref(N),onFrameUpdate:bs,onDurationChange:Yo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(pl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:cs.value,"enable-engine":p.value&&ds.value,"fit-mode":F.value,onTimeUpdate:ys,onPlayStateChange:ws,onDurationChange:Yo,onEngineReady:Ts},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),v.showThumbnailPicker?(e.openBlock(),e.createBlock(O1,{key:0,"media-uuid":s.value,duration:Bt.value,onSelect:Su},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",K2,[e.createElementVNode("div",Q2,[e.createElementVNode("div",ek,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(J.value,se=>(e.openBlock(),e.createElementBlock("button",{key:se.id,class:e.normalizeClass(["tab-btn",{active:d.value===se.id}]),onClick:Ae=>d.value=se.id},e.toDisplayString(se.label),11,tk))),128))]),e.createElementVNode("div",nk,[e.withDirectives(e.createElementVNode("div",ok,[e.createVNode(qg,{filters:io.value,"active-filters":ci.value,"thumbnail-url":Pd.value,onApplyFilter:ao,onRemoveFilter:ls,onUpdateParam:gs,onPreviewFilter:du},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",ak,[e.createVNode(sy,{overlays:D.value,onAddOverlay:mu,onUpdateOverlay:pu,onRemoveOverlay:fu},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",ik,[e.createVNode(Ty,{"selected-clips":$.value,"applied-transitions":I.value,onApplyTransition:hu,onRemoveTransition:vu,onPreviewTransition:gu},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",rk,[e.createVNode(db,{"audio-layers":j.value,"master-volume":P.value,onAddTrack:yu,onUpdateTrack:bu,onRemoveTrack:wu,onUpdateVolume:ku,onToggleMute:xu,onUpdateMasterVolume:Eu},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",sk,[e.unref(as)?(e.openBlock(),e.createBlock(d1,{key:0,filter:e.unref(as),"current-frame":e.unref(oe),onUpdateParams:uu},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",lk,[...k[18]||(k[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",ck,[e.createVNode(V1,{"can-export":e.unref(ee),"is-exporting":ot.value,"export-progress":Xe.value,onExport:Is,onCancelExport:Bs,onSaveDraft:Ti,onReset:Ls},null,8,["can-export","is-exporting","export-progress"]),Qt.value?(e.openBlock(),e.createElementBlock("div",dk," Export complete ")):e.createCommentVNode("",!0),We.value&&!Qt.value?(e.openBlock(),e.createElementBlock("div",uk,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",mk,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:An,class:"timeline-container"},[e.createElementVNode("div",pk,[e.createElementVNode("label",null,[k[19]||(k[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ie),onInput:k[5]||(k[5]=se=>cu(se))},null,40,fk)]),e.createElementVNode("span",hk,e.toDisplayString(Math.round(e.unref(ie)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:sn.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:Es},e.toDisplayString(sn.value?"Snap On":"Snap Off"),3)]),e.createVNode(fl,{playhead:e.unref(_),clips:e.unref(A),"selected-clip-id":((ue=e.unref(pe))==null?void 0:ue.id)??((re=e.unref(A)[0])==null?void 0:re.id)??null,duration:Bt.value,"zoom-level":e.unref(ie),"snap-enabled":sn.value,sensitivity:.25,"onUpdate:playhead":e.unref(H),onTrim:e.unref(we),onSplit:_s,onClipSelect:yi,onClipMove:e.unref(St),onClipLongPress:ks,onSnapStateChange:xs},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(mg,{"selected-clip":e.unref(pe),"can-split":ui.value,"can-delete":mi.value,"is-playing":e.unref(ne),"zoom-level":e.unref(ie),"playback-speed":e.unref(me),onSplit:qo,onDelete:xi,onDuplicate:ki,onZoomIn:su,onZoomOut:lu,onZoomChange:Ei,onFitToWindow:ru,onPlayPause:e.unref(N),onFrameForward:e.unref(q),onFrameBackward:e.unref(de),onSkipToStart:e.unref(he),onSkipToEnd:e.unref(Ne),onSpeedChange:e.unref(Fe)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),fe.value?(e.openBlock(),e.createElementBlock("div",vk,[e.createElementVNode("div",gk,[e.createElementVNode("label",yk,[k[20]||(k[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":k[6]||(k[6]=se=>Rn.value=se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Rn.value]])]),e.createElementVNode("label",bk,[k[21]||(k[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":k[7]||(k[7]=se=>Dn.value=se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Dn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(pe),onClick:k[8]||(k[8]=se=>vs("start"))}," Start = Playhead ",8,wk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(pe),onClick:k[9]||(k[9]=se=>vs("end"))}," End = Playhead ",8,kk),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(pe),onClick:eu}," Apply Trim ",8,xk)]),e.createElementVNode("div",Ek,[e.createElementVNode("label",Sk,[k[22]||(k[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":k[10]||(k[10]=se=>rn.value=se),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(io.value,se=>(e.openBlock(),e.createElementBlock("option",{key:se.id,value:se.id},e.toDisplayString(se.name),9,Vk))),128))],512),[[e.vModelSelect,rn.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(pe)||rn.value==="",onClick:tu}," Apply Filter ",8,_k),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(et).length===0,onClick:nu}," Clear Filters ",8,Ck),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(pe),onClick:k[11]||(k[11]=se=>ao("noise"))}," QA: Noise ",8,Nk),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(pe),onClick:k[12]||(k[12]=se=>ao("grayscale"))}," QA: Grayscale ",8,Tk)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),kr=Ve(Mk,[["__scopeId","data-v-f427827a"]]),Lt=a=>a===null||typeof a!="object"||Array.isArray(a)?null:a,Ue=a=>{if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const n=Number(a);return Number.isFinite(n)?n:null}return null},Bk=(a,n)=>{if(n===null)return;const t=Lt(a.source)??{},o=Ue(t.duration);if(!(o!==null&&o>0&&o<=1&&n>o))return;t.duration=n,a.source=t;const r=Array.isArray(a.timeline)?a.timeline:[];if(r.length===1){const c=Lt(r[0]);if(c!==null){const d=Ue(c.sourceIn)??0,u=Ue(c.sourceOut)??Ue(c.end)??Ue(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const h=Ue(c.end);h!==null&&h>0&&h<=1&&(c.end=n);const p=Ue(c.timelineEnd);p!==null&&p>0&&p<=1&&(c.timelineEnd=n)}}}const s=Ue(a.trimEnd)??Ue(a.trim_end);s!==null&&s>0&&s<=1&&(a.trimEnd=n);const l=Lt(a.trim);if(l!==null){const c=Ue(l.end);c!==null&&c>0&&c<=1&&(l.end=n,a.trim=l)}},Ik=(a,n)=>{if(!a)return!1;const t=Lt(a);if(t===null)return!1;const o=Lt(t.trim),i=Lt(t.source),s=Ue(i==null?void 0:i.duration)??n,l=Array.isArray(a.filters)&&a.filters.length>0;let c=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(c=!0)}let d=!1;const u=Ue(t.trimStart)??Ue(t.trim_start)??Ue(o==null?void 0:o.start),m=Ue(t.trimEnd)??Ue(t.trim_end)??Ue(o==null?void 0:o.end);if(u!==null&&u>0&&(d=!0),m!==null&&s!==void 0&&m<s&&(d=!0),!d&&Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const y=Ue(p.sourceIn),g=Ue(p.sourceOut);y!==null&&y>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let h=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const p=a.timeline[0];if(p){const y=Ue(p.speed);h=y!==null&&y!==1}}return l||c||d||h},dd=a=>{if(!a)return!1;const n=Lt(a);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(a.timeline)&&a.timeline.length>1)},Fk=(a,n={})=>{var h,p;const t=JSON.parse(JSON.stringify(a)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?Lt(o[0]):null,r=Array.isArray(i==null?void 0:i.filters)?i.filters:[],s=Array.isArray(t.filters)?t.filters:[];if(s.length>0?t.filters=s:t.filters=r,o.length===1&&i!==null){const y=Ue(i.sourceIn),g=Ue(i.sourceOut);y!==null&&t.trimStart===void 0&&(t.trimStart=y),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const l=Lt(t.trim);if(t.trimStart===void 0){const y=Ue(l==null?void 0:l.start);y!==null&&(t.trimStart=y)}if(t.trimEnd===void 0){const y=Ue(l==null?void 0:l.end);y!==null&&(t.trimEnd=y)}const c=Lt(t.source),d=Ue(t.width)??Ue(c==null?void 0:c.original_width)??Ue((h=n.exportMeta)==null?void 0:h.width);d!==null&&(t.width=d);const u=Ue(t.height)??Ue(c==null?void 0:c.original_height)??Ue((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Lt(t.output);return t.fps=Ue(t.fps)??Ue(m==null?void 0:m.fps)??30,Bk(t,n.mediaDuration??null),t},$k={key:0},Rk=["data-testid"],Dk={class:"ve-mobile-header"},Ak=["data-testid"],Lk={class:"ve-mobile-title"},Uk=["data-testid","disabled"],Ok={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},Pk={class:"ve-body"},zk=["data-testid"],jk=["aria-label"],Wk={class:"ve-header"},Zk={class:"ve-title"},Xk=["data-testid"],Hk={class:"ve-body"},Gk={class:"ve-footer"},Jk=["data-testid"],Yk=["data-testid","disabled"],qk=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),l=e.computed(()=>o.saveImmediate===!1),c=e.computed(()=>o.closeText),d=e.computed(()=>m.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),m=e.ref(!1),h=e.ref(!1),p=e.ref(null),y=`temp-${Date.now()}`,g=e.computed(()=>{var P;const $=(P=o.featureFlags)==null?void 0:P.export;return typeof $=="boolean"?$:o.workflowMode==="full"}),x=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():y),M=e.computed(()=>{const $={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&($.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&($.initialRecipe=o.initialRecipe),o.media!==void 0&&($.media=o.media),$}),C=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",C)}),e.onUnmounted(()=>{window.removeEventListener("resize",C)}),e.onErrorCaptured(()=>(h.value=!0,!1));const b=$=>{const P=Array.isArray($.timeline)?$.timeline:[];if(P.length===0)return 0;let O=0;for(const V of P){const R=Number(V.sourceIn),G=Number(V.sourceOut),J=Number(V.speed??1),te=Number.isFinite(J)&&J>0?J:1;if(Number.isFinite(R)&&Number.isFinite(G)&&G>R){O+=(G-R)/te;continue}const fe=Number(V.timelineStart),ye=Number(V.timelineEnd);Number.isFinite(fe)&&Number.isFinite(ye)&&ye>fe&&(O+=ye-fe)}return O},f=($,P,O)=>{let V=null;const R=new Promise((G,J)=>{V=setTimeout(()=>J(new Error(`${O} timed out after ${P}ms`)),P)});return Promise.race([$,R]).finally(()=>{V!==null&&clearTimeout(V)})},w=()=>{var R;const O=(R=o.media)==null?void 0:R.duration;if(typeof O!="number"||!Number.isFinite(O)||O<=0)return 12e3;const V=Math.round(O*1e3);return Math.min(45e3,Math.max(12e3,V))},F=()=>{i("close"),i("update:open",!1)},T=()=>{m.value=!1,F()},E=$=>{i("recipe-generated",$)},B=$=>{i("export-started",$),i("save-started",$)},U=$=>{i("video-exported",$)},S=$=>{i("thumbnail-selected",$)},D=($,P,O)=>{i("save-recipe",$);const V={recipe:$,exportPayload:P};O!==void 0&&(V.toastDescription=O),i("save-complete",V),F()},I=$=>{m.value||(i("draft-saved",$),D($,null))},j=async()=>{var $;if(!m.value){if(h.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),F();return}m.value=!0;try{const P=await f(p.value.saveDraft(),w(),"saveDraft");let O=null,V=!1,R;const G=b(P),J=G>0?G:(($=o.media)==null?void 0:$.duration)??0;if(g.value&&J>0&&J<=o.clientExportThreshold&&typeof p.value.exportForUpload=="function"){V=!0;const fe=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{O=await f(p.value.exportForUpload(P),fe,"exportForUpload")}catch{O=null}}if(dd(P)&&O===null){i("save-error",{code:"unsupported-client-export-required",message:"These edits require in-browser export. Shorten the clip or remove text overlays, transitions, or extra clips and try again."});return}V&&O===null&&(R="Video edits saved. Final render will happen when you share."),D(P,O,R)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),F()}finally{m.value=!1}}};return n({saveDraft:j}),($,P)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",$k,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",Dk,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:T},e.toDisplayString(c.value),9,Ak),e.createElementVNode("h2",Lk,e.toDisplayString($.title),1),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-mobile-action ve-mobile-action--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:j},e.toDisplayString(d.value),9,Uk)):(e.openBlock(),e.createElementBlock("span",Ok))]),e.createElementVNode("section",Pk,[e.createVNode(kr,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":x.value},M.value,{onClose:T,onDraftSaved:I,onExportStarted:B,onRecipeGenerated:E,onThumbnailSelected:S,onVideoExported:U}),null,16,["media-uuid"])])],8,Rk)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(T,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":$.title,"aria-modal":"true"},[e.createElementVNode("header",Wk,[e.createElementVNode("h2",Zk,e.toDisplayString($.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:T}," ✕ ",8,Xk)]),e.createElementVNode("section",Hk,[e.createVNode(kr,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":x.value},M.value,{onClose:T,onDraftSaved:I,onExportStarted:B,onRecipeGenerated:E,onThumbnailSelected:S,onVideoExported:U}),null,16,["media-uuid"])]),e.createElementVNode("footer",Gk,[e.renderSlot($.$slots,"footer",{close:T,isSaving:m.value,save:j},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:T},e.toDisplayString(c.value),9,Jk),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:j},e.toDisplayString(d.value),9,Yk)):e.createCommentVNode("",!0)],!0)])],8,jk)],8,zk))])):e.createCommentVNode("",!0)]))}}),Kk=Ve(qk,[["__scopeId","data-v-0ff40919"]]),Qk={class:"video-editor-modal"},ex={class:"video-preview-container"},tx=["src"],nx={class:"video-overlay-controls"},ox=["aria-label"],ax={class:"time-display"},ix={class:"timeline-container"},rx={class:"clip-name"},sx={class:"timeline-time-labels"},lx={class:"tool-tabs"},cx=["onClick"],dx={class:"tool-panel"},ux={key:0,class:"trim-panel"},mx={class:"trim-controls"},px={key:1,class:"filters-panel"},fx={class:"filter-grid"},hx=["onClick"],vx={key:2,class:"text-panel"},gx={key:3,class:"transitions-panel"},yx={class:"transition-grid"},bx=["onClick"],wx={class:"action-buttons"},kx=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),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),m=e.ref(0),h=e.ref(null),p=e.ref("trim"),y=e.ref(null),g=e.ref(""),x=[{id:"trim",label:"Trim",icon:ql},{id:"filters",label:"Filters",icon:Mm},{id:"text",label:"Text",icon:nc},{id:"transitions",label:"Transitions",icon:Lm}],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"}],C=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],b=e.ref();e.onMounted(()=>{var V,R;(V=t.media)!=null&&V.url?r.value=t.media.url:(R=t.media)!=null&&R.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var V;(V=t.media)!=null&&V.file&&r.value&&URL.revokeObjectURL(r.value)});function f(){i.value&&(c.value=i.value.duration,m.value=c.value)}function w(){i.value&&(l.value=i.value.currentTime)}function F(){s.value=!1}function T(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function E(V){if(!V||isNaN(V))return"00:00";const R=Math.floor(V/60),G=Math.floor(V%60);return`${R.toString().padStart(2,"0")}:${G.toString().padStart(2,"0")}`}function B(V){if(!i.value||!b.value)return;const R=b.value.getBoundingClientRect(),te=(V.clientX-R.left)/R.width*c.value;i.value.currentTime=Math.max(0,Math.min(te,c.value))}function U(){u.value=l.value}function S(){m.value=l.value}function D(){u.value=0,m.value=c.value}function I(V){h.value=V;const R=J=>{if(!h.value||!b.value)return;const te=b.value.getBoundingClientRect(),oe=(J.clientX-te.left)/te.width*c.value;h.value==="start"?u.value=Math.max(0,Math.min(oe,m.value-1)):m.value=Math.max(u.value+1,Math.min(oe,c.value))},G=()=>{h.value=null,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",G)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",G)}function j(V){if(y.value=V,!i.value)return;const R={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=R[V]||"none"}function $(){}function P(V){}function O(){const V={timeline:[{id:d.value,url:r.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:m.value,track:0}],filters:y.value?[{type:y.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:m.value-u.value};o("save",V)}return(V,R)=>(e.openBlock(),e.createElementBlock("div",Qk,[e.createElementVNode("div",ex,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:f,onTimeupdate:w,onEnded:F,controls:""},null,40,tx),e.createElementVNode("div",nx,[e.createElementVNode("button",{class:"play-pause-btn",onClick:T,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(L.IonIcon),{icon:s.value?e.unref(zm):e.unref(Xm)},null,8,["icon"])],8,ox),e.createElementVNode("div",ax,e.toDisplayString(E(l.value))+" / "+e.toDisplayString(E(c.value)),1)])]),e.createElementVNode("div",ix,[e.createElementVNode("div",{class:"timeline-track",onClick:B,ref_key:"timelineTrack",ref:b},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-m.value/c.value*100}%`})},[e.createElementVNode("span",rx,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:R[0]||(R[0]=G=>I("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/c.value*100}%`}),onMousedown:R[1]||(R[1]=G=>I("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",sx,[e.createElementVNode("span",null,e.toDisplayString(E(0)),1),e.createElementVNode("span",null,e.toDisplayString(E(c.value)),1)])]),e.createElementVNode("div",lx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(x,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["tool-tab",{active:p.value===G.id}]),onClick:J=>p.value=G.id},[e.createVNode(e.unref(L.IonIcon),{icon:G.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(G.label),1)],10,cx)),64))]),e.createElementVNode("div",dx,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",ux,[R[7]||(R[7]=e.createElementVNode("h3",null,"Trim Video",-1)),R[8]||(R[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",mx,[e.createElementVNode("button",{class:"btn-trim",onClick:U},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(js)},null,8,["icon"]),R[4]||(R[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:S},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(js)},null,8,["icon"]),R[5]||(R[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:D},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),R[6]||(R[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",px,[R[9]||(R[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",fx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(M,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["filter-option",{active:y.value===G.id}]),onClick:J=>j(G.id)},e.toDisplayString(G.name),11,hx)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",vx,[R[10]||(R[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[2]||(R[2]=G=>g.value=G),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:$},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",gx,[R[11]||(R[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",yx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(C,G=>e.createElementVNode("button",{key:G.id,class:"transition-option",onClick:J=>(G.id,void 0)},e.toDisplayString(G.name),9,bx)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",wx,[e.createElementVNode("button",{class:"btn-cancel",onClick:R[3]||(R[3]=G=>V.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:O},"SAVE")])]))}}),xx=Ve(kx,[["__scopeId","data-v-b933f33b"]]),Ex={class:"time-label"},Sx=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=[],l=i(n.duration,n.zoom);for(let c=0;c<=n.duration;c+=l){const d=`${c/n.duration*100}%`,u=r(c),m=c%(l*5)===0;s.push({time:c,position:d,label:u,major:m})}return s});function i(s,l){const c=s/(10*l);return c<=1?1:c<=5?5:c<=10?10:c<=30?30:c<=60?60:Math.ceil(c/60)*60}function r(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",Ex,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),Vx=Ve(Sx,[["__scopeId","data-v-0ef9c910"]]),_x=["data-track-index"],Cx={class:"track-header"},Nx={class:"track-label"},Tx={class:"track-controls"},Mx=["data-testid","aria-label"],Bx=["data-testid","onMousedown","onClick"],Ix={class:"clip-content"},Fx={class:"clip-name"},$x={key:0,class:"clip-thumbnail"},Rx=["src","alt"],Dx=["onMousedown","aria-label"],Ax=["onMousedown","aria-label"],Lx=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),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(x){const M=x.timelineEnd-x.timelineStart,C=x.timelineStart/t.duration*100,b=M/t.duration*100;return{left:`${C}%`,width:`${b}%`,backgroundColor:u(x)}}function u(x){const M=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],C=parseInt(x.id.replace(/\D/g,""))%M.length;return M[C]}function m(x){return x.label?x.label:x.url?(x.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${x.id.slice(-4)}`}function h(x){i.value=x.id,o("clip-select",x.id)}function p(){r.value=!r.value}function y(x,M){if(l.value)return;s.value=!0;const C=M.clientX,b=x.timelineStart,f=F=>{if(!s.value)return;const T=F.clientX-C,E=parseFloat(c.value.width),B=T/(t.zoom*100)*(t.duration/E),U=Math.max(0,b+B);o("clip-move",x.id,U)},w=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",w)}function g(x,M,C){l.value=M;const b=C.clientX,f=x.sourceIn,w=x.sourceOut,F=E=>{if(!l.value)return;const B=E.clientX-b,U=parseFloat(c.value.width),S=B/(t.zoom*100)*(t.duration/U);if(l.value==="start"){const D=Math.max(0,f+S);o("clip-trim",x.id,D,w)}else{const D=Math.max(f+1,w+S);o("clip-trim",x.id,f,D)}},T=()=>{l.value=null,document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",T)}return(x,M)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":x.trackIndex},[e.createElementVNode("div",Cx,[e.createElementVNode("span",Nx,"Track "+e.toDisplayString(x.trackIndex+1),1),e.createElementVNode("div",Tx,[x.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${x.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${x.trackIndex+1}`,onClick:p},[e.createVNode(e.unref(L.IonIcon),{icon:r.value?e.unref(sp):e.unref(ip)},null,8,["icon"])],8,Mx)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.clips,C=>(e.openBlock(),e.createElementBlock("div",{key:C.id,class:e.normalizeClass(["timeline-clip",{selected:C.id===i.value}]),style:e.normalizeStyle(d(C)),"data-testid":`clip-${C.id}`,onMousedown:b=>y(C,b),onClick:b=>h(C)},[e.createElementVNode("div",Ix,[e.createElementVNode("span",Fx,e.toDisplayString(m(C)),1),C.thumbnail?(e.openBlock(),e.createElementBlock("div",$x,[e.createElementVNode("img",{src:C.thumbnail,alt:m(C)},null,8,Rx)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(b=>g(C,"start",b),["stop"]),"aria-label":`Trim start of ${m(C)}`},null,40,Dx),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(b=>g(C,"end",b),["stop"]),"aria-label":`Trim end of ${m(C)}`},null,40,Ax)],46,Bx))),128))],4)],8,_x))}}),Ux=Ve(Lx,[["__scopeId","data-v-48e480d2"]]),Ox={class:"video-timeline"},Px={class:"timeline-tracks"},zx=["aria-label","aria-valuenow","aria-valuemax"],jx={class:"timeline-controls"},Wx={class:"zoom-level"},Zx=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),l=e.ref(),c=e.computed(()=>{const b=Math.max(0,...t.clips.map(f=>f.track||0));return Array(b+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(b){return t.clips.filter(f=>(f.track||0)===b)}function m(b){const f=Math.floor(b/60),w=Math.floor(b%60);return`${f}:${w.toString().padStart(2,"0")}`}function h(b,f){o("clip-move",b,f)}function p(b,f,w){o("clip-trim",b,f,w)}function y(b){r.value=b}function g(){i.value=Math.min(i.value*1.2,5)}function x(){i.value=Math.max(i.value/1.2,.5)}function M(){s.value=!0;const b=w=>{if(!s.value||!l.value)return;const F=l.value.getBoundingClientRect(),B=Math.max(0,Math.min(w.clientX-F.left,F.width))/F.width*t.duration;o("seek",B)},f=()=>{s.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",f)}function C(b){let f=t.currentTime;switch(b.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}b.preventDefault(),o("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(b,f)=>(e.openBlock(),e.createElementBlock("div",Ox,[e.createVNode(Vx,{duration:b.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",Px,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(w,F)=>(e.openBlock(),e.createBlock(Ux,{key:`track-${F}`,"data-testid":`track-${F}`,clips:u(F),"track-index":F,zoom:i.value,duration:b.duration,onClipMove:h,onClipTrim:p,onClipSelect:y},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 ${m(b.currentTime)}`,role:"slider","aria-valuenow":b.currentTime,"aria-valuemax":b.duration,tabindex:"0",onKeydown:C},null,44,zx),e.createElementVNode("div",jx,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Sr)},null,8,["icon"])]),e.createElementVNode("span",Wx,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:x},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Km)},null,8,["icon"])])])]))}}),Xx=Ve(Zx,[["__scopeId","data-v-001df415"]]),Hx={class:"video-filters-panel"},Gx={class:"filter-controls"},Jx=["for"],Yx={class:"filter-slider-group"},qx=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],Kx={class:"filter-value"},Qx={class:"filter-actions"},eE={key:0,class:"filter-presets"},tE={class:"preset-list"},nE=["data-testid","aria-label","onClick"],oE=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((h,p)=>(h[p.type]=p.default,h),{})),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(h,p){switch(h){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function l(h){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(h)}function c(h){if(!l(h))return;const p={id:`filter-${h}`,filterId:h,params:{value:i[h]},intensity:1};t("filter-change",p)}function d(){o.forEach(h=>{i[h.type]=h.default,c(h.type)})}function u(){const h=prompt("Enter preset name:");if(!h)return;const p={id:`custom-${Date.now()}`,name:h,values:{...i}};r.value.push(p)}function m(h){Object.entries(h.values).forEach(([p,y])=>{i[p]=y,c(p)})}return(h,p)=>(e.openBlock(),e.createElementBlock("div",Hx,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",Gx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,y=>e.createElementVNode("div",{key:y.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${y.type}`},e.toDisplayString(y.label),9,Jx),e.createElementVNode("div",Yx,[e.withDirectives(e.createElementVNode("input",{id:`filter-${y.type}`,"onUpdate:modelValue":g=>i[y.type]=g,type:"range",min:y.min,max:y.max,step:y.step,class:"filter-slider","data-testid":`filter-${y.type}`,"aria-label":`${y.label} filter`,"aria-valuenow":i[y.type],"aria-valuemin":y.min,"aria-valuemax":y.max,onInput:g=>c(y.type)},null,40,qx),[[e.vModelText,i[y.type],void 0,{number:!0}]]),e.createElementVNode("span",Kx,e.toDisplayString(s(y.type,i[y.type])),1)])])),64))]),e.createElementVNode("div",Qx,[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(L.IonIcon),{icon:e.unref(Yn)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(_r)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",eE,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",tE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,y=>(e.openBlock(),e.createElementBlock("button",{key:y.id,class:"preset-btn","data-testid":`preset-${y.id}`,"aria-label":`Apply ${y.name} preset`,onClick:g=>m(y)},e.toDisplayString(y.name),9,nE))),128))])])):e.createCommentVNode("",!0)]))}}),aE=Ve(oE,[["__scopeId","data-v-5ad2ac63"]]),iE={class:"video-text-panel"},rE={class:"text-input-group"},sE={class:"text-options"},lE={class:"option-row"},cE={class:"option-row"},dE={class:"option-row"},uE={class:"option-row"},mE={class:"checkbox-label"},pE={class:"option-row"},fE={class:"text-overlay-list"},hE={key:0,class:"empty-state"},vE=["data-testid"],gE={class:"overlay-preview"},yE={class:"overlay-controls"},bE=["data-testid","aria-label","onClick"],wE=["data-testid","aria-label","onClick"],kE=["data-testid","aria-label","onClick"],xE=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const d={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(m=>m.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function l(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 c(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",iE,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",rE,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=m=>i.text=m),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Sr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",sE,[e.createElementVNode("div",lE,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=m=>i.fontFamily=m),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,i.fontFamily]])]),e.createElementVNode("div",cE,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=m=>i.fontSize=m),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",dE,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=m=>i.color=m),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",uE,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=m=>i.backgroundColor=m),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",mE,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=m=>i.hasBackground=m),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",pE,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=m=>i.animation=m),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,i.animation]])])]),e.createElementVNode("div",fE,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",hE," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${h}`},[e.createElementVNode("div",gE,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:m.fontFamily,fontSize:`${Math.min(m.fontSize/4,16)}px`,color:m.color})},e.toDisplayString(m.text),5)]),e.createElementVNode("div",yE,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${h}`,"aria-label":`Edit overlay: ${m.text}`,onClick:p=>l(m)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Fm)},null,8,["icon"])],8,bE),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${h}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:p=>c(m)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Im)},null,8,["icon"])],8,wE),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${h}`,"aria-label":`Remove overlay: ${m.text}`,onClick:p=>s(m.id)},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(tp)},null,8,["icon"])],8,kE)])],8,vE))),128))])]))}}),EE=Ve(xE,[["__scopeId","data-v-4d240e1e"]]),SE={class:"video-tools-panel"},VE={class:"tool-tabs"},_E=["data-testid","aria-label","aria-selected","onClick"],CE={class:"tool-content"},NE={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},TE={class:"trim-actions"},ME={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},BE={class:"transition-types"},IE=["data-testid","aria-label","onClick"],FE={class:"transition-preview"},$E=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:ql},{id:"filters",name:"Filters",icon:fn},{id:"text",name:"Text",icon:nc},{id:"transitions",name:"Transitions",icon:Xs}],t=[{id:"fade",name:"Fade",icon:Di},{id:"slide-left",name:"Slide Left",icon:Vm},{id:"slide-right",name:"Slide Right",icon:_m},{id:"dissolve",name:"Dissolve",icon:Di},{id:"wipe",name:"Wipe",icon:Xs},{id:"zoom",name:"Zoom",icon:Di}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",SE,[e.createElementVNode("div",VE,[(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(L.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,_E)),64))]),e.createElementVNode("div",CE,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",NE,[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",TE,[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(L.IonIcon),{icon:e.unref(Ws)},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(L.IonIcon),{icon:e.unref(Ws)},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(L.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(aE,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(EE,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",ME,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",BE,[(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",FE,[e.createVNode(e.unref(L.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,IE)),64))])])):e.createCommentVNode("",!0)])]))}}),RE=Ve($E,[["__scopeId","data-v-fc135306"]]),DE={class:"video-export-panel"},AE={class:"export-presets"},LE=["value"],UE={key:0,class:"preset-details"},OE={class:"detail-row"},PE={class:"detail-row"},zE={class:"detail-row"},jE={class:"advanced-options"},WE={class:"options-content"},ZE={class:"option-group"},XE={class:"option-group"},HE={class:"option-group"},GE=["disabled"],JE={key:1,class:"export-progress"},YE={class:"progress-message"},qE={class:"progress-bar"},KE=["aria-valuenow"],QE={class:"progress-percentage"},e4=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)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function c(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",DE,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",AE,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=m=>i.value=m),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,m=>(e.openBlock(),e.createElementBlock("option",{key:m.id,value:m.id},e.toDisplayString(m.name),9,LE))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",UE,[e.createElementVNode("div",OE,[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",PE,[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",zE,[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",jE,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",WE,[e.createElementVNode("div",ZE,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=m=>r.quality=m),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,r.quality]])]),e.createElementVNode("div",XE,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=m=>r.bitrate=m),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",HE,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=m=>r.includeAudio=m),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:d.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:c},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(L.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Co)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,GE),d.isExporting?(e.openBlock(),e.createElementBlock("div",JE,[e.createElementVNode("div",YE,e.toDisplayString(l.value),1),e.createElementVNode("div",qE,[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,KE)]),e.createElementVNode("div",QE,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),t4=Ve(e4,[["__scopeId","data-v-5caf8fe6"]]),n4=["data-testid"],o4={class:"progress-header"},a4={class:"file-info"},i4={class:"file-details"},r4={class:"file-name"},s4={class:"file-meta"},l4={class:"file-size"},c4={key:0,class:"separator"},d4={key:1,class:"upload-speed"},u4={key:2,class:"separator"},m4={key:3,class:"time-remaining"},p4={class:"progress-actions"},f4={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},h4={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},v4={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},g4=["aria-valuenow","aria-label"],y4={class:"progress-bar"},b4={class:"progress-percent"},w4={key:1,class:"error-message","data-testid":"video-upload-error"},k4={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},x4=["src","alt"],E4={key:0,class:"video-duration"},S4=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(()=>oc),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 h=n.upload.timeRemaining;if(h<60)return`${Math.round(h)}s`;const p=Math.floor(h/60);return p<60?`${p}m ${Math.round(h%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),l=e.computed(()=>{var h;return n.upload.status==="completed"&&((h=n.upload.media)!=null&&h.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var h;return(h=n.upload.media)==null?void 0:h.duration});function d(h){if(h===0)return"0 B";const p=["B","KB","MB","GB","TB"],y=1024,g=Math.floor(Math.log(h)/Math.log(y));return`${(h/Math.pow(y,g)).toFixed(1)} ${p[g]}`}function u(h){if(h===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],y=1024,g=Math.floor(Math.log(h)/Math.log(y));return`${(h/Math.pow(y,g)).toFixed(1)} ${p[g]}`}function m(h){const p=Math.floor(h/3600),y=Math.floor(h%3600/60),g=Math.floor(h%60);return p>0?`${p}:${y.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${y}:${g.toString().padStart(2,"0")}`}return(h,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${h.upload.id}`},[e.createElementVNode("div",o4,[e.createElementVNode("div",a4,[e.createVNode(e.unref(L.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",i4,[e.createElementVNode("h4",r4,e.toDisplayString(h.upload.filename),1),e.createElementVNode("p",s4,[e.createElementVNode("span",l4,e.toDisplayString(d(h.upload.bytesTotal||0)),1),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",c4,"•")):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",d4,e.toDisplayString(u(h.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",u4,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",m4,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",p4,[h.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",f4,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Jl)},null,8,["icon"])])):h.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",h4,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Sm),"aria-hidden":"true"},null,8,["icon"])])):h.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",v4,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=y=>h.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Xn),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=y=>h.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yn),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=y=>h.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Xn),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":h.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",y4,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:h.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",b4,e.toDisplayString(Math.round(r.value))+"%",1)],8,g4)):e.createCommentVNode("",!0),h.upload.error?(e.openBlock(),e.createElementBlock("div",w4,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(lp)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(h.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",k4,[e.createElementVNode("img",{src:l.value,alt:h.upload.filename},null,8,x4),c.value?(e.openBlock(),e.createElementBlock("div",E4,e.toDisplayString(m(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,n4))}}),V4=Ve(S4,[["__scopeId","data-v-9eacbf91"]]),Hi=4,_4=500,C4=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function ri(a){return typeof a=="object"&&a!==null}function Bl(a){return ri(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function N4(a){if(Bl(a))return a;if(ri(a)&&Bl(a.data))return a.data;throw new Error("Invalid upload response from backend")}function Il(a){return ri(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function T4(a){if(Il(a))return a;if(ri(a)&&Il(a.data))return a.data;throw new Error("Invalid media response from backend")}function sa(a){return a?{...a}:{}}function Fl(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function M4(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function B4(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 I4(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} ${B4(i)}`).join(",")}function la(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 F4(a,n){return a instanceof Error?a:new Error(n)}function $4(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 $l(a){const n=Math.max(0,a-1),t=_4*Math.pow(2,n);return Math.min(5e3,t)}function Rl(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Dl(a,n){for(let t=1;t<=Hi;t+=1)try{const o=await n();if(o.ok||!C4.has(o.status)||t>=Hi)return o;await Rl($l(t))}catch(o){if(!$4(o)||t>=Hi)throw o;await Rl($l(t))}throw new Error(`${a} failed after retry attempts`)}function R4(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),l=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>{const S=Array.from(n.value.values());return S.length===0?0:S.reduce((I,j)=>I+j.progress,0)/S.length});function d(S){o.value=S}function u(){}async function m(S){var I;const D=S.filter(j=>h(j));if(D.length!==0&&((I=a.onFilesSelected)==null||I.call(a,D),a.autoUpload!==!1))for(const j of D)await p(j)}function h(S){return!(a.maxFileSize&&S.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(S.type))}async function p(S){var j,$,P;const D=U(S);if(n.value.has(D)){const O=n.value.get(D);if((O==null?void 0:O.status)==="uploading")return}const I={id:D,file:S,filename:S.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:S.size,bytesUploaded:0};n.value.set(I.id,I),t.value.add(I.id);try{I.status="uploading",(j=a.onUploadStart)==null||j.call(a,I);const O=await y(S);a.resumable===!0||O.resumable===!0?await x(I,O):await g(I,O),I.status="processing",I.progress=100;const R=await w(O.media_uuid);I.status="completed",I.media=R,($=a.onUploadComplete)==null||$.call(a,R)}catch(O){if(I.status!=="cancelled"){const V=F4(O,"Upload failed");I.status="error",I.error=V.message,(P=a.onUploadError)==null||P.call(a,V,I)}}finally{t.value.delete(I.id),i.delete(I.id),r.delete(I.id)}}async function y(S){if(!o.value)throw new Error("API client not configured");const D={collection:a.collection||"videos",filename:S.name,size:S.size,mime_type:S.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},I=await o.value.post("/api/v1/video/upload",D);return N4(I)}async function g(S,D){const I=new XMLHttpRequest,j=Fl(D),$=sa(D.headers);return new Promise((P,O)=>{I.upload.addEventListener("progress",V=>{var R;V.lengthComputable&&(la(S,V.loaded),(R=a.onUploadProgress)==null||R.call(a,S))}),I.addEventListener("load",()=>{i.delete(S.id),I.status>=200&&I.status<300?P():O(new Error(`Upload failed with status ${I.status}`))}),I.addEventListener("error",()=>{i.delete(S.id),O(new Error("Upload failed"))}),I.addEventListener("abort",()=>{i.delete(S.id),O(new Error("Upload cancelled"))}),I.open(j,D.upload_url),Object.entries($).forEach(([V,R])=>{I.setRequestHeader(V,R)}),!Object.keys($).some(V=>V.toLowerCase()==="content-type")&&S.file.type&&I.setRequestHeader("Content-Type",S.file.type),i.set(S.id,I),I.send(S.file)})}async function x(S,D){var O;if(M4(D)){await M(S,D);return}const I=a.chunkSize||5*1024*1024,j=C(S.file,I),$=new AbortController;r.set(S.id,$);const P=await f(D.upload_id);P&&(j.forEach(V=>{V.end<=P.bytesUploaded&&(V.uploaded=!0)}),la(S,P.bytesUploaded));for(const V of j)V.uploaded||(await b(S,D,V,$),la(S,V.end),(O=a.onUploadProgress)==null||O.call(a,S))}async function M(S,D){var G;const I=new AbortController;r.set(S.id,I);const j={...sa(D.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(S.file.size),"Upload-Metadata":I4(S,D)},$=await Dl("Resumable upload initialization",()=>fetch(D.upload_url,{method:"POST",headers:j,signal:I.signal}));if(!$.ok)throw new Error(`Failed to initialize resumable upload: ${$.status}`);const P=$.headers.get("Location");if(!P)throw new Error("Resumable upload endpoint did not return upload location");const O=new URL(P,D.upload_url).toString(),V=a.chunkSize||5*1024*1024;let R=0;for(;R<S.file.size;){const J=Math.min(R+V,S.file.size),te=S.file.slice(R,J),fe={...sa(D.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(R),"Content-Type":"application/offset+octet-stream"},ye=await Dl("Resumable chunk upload",()=>fetch(O,{method:"PATCH",headers:fe,body:te,signal:I.signal}));if(ye.status===409){const _=Number(ye.headers.get("Upload-Offset")??"-1");if(Number.isFinite(_)&&_>=0){R=_;continue}}if(!ye.ok)throw new Error(`Resumable chunk upload failed: ${ye.status}`);const oe=Number(ye.headers.get("Upload-Offset")??String(J));R=Number.isFinite(oe)&&oe>R?oe:J,la(S,R),(G=a.onUploadProgress)==null||G.call(a,S)}}function C(S,D){const I=[];let j=0,$=0;for(;j<S.size;){const P=Math.min(j+D,S.size);I.push({start:j,end:P,blob:S.slice(j,P),index:$,uploaded:!1}),j=P,$++}return I}async function b(S,D,I,j){const $={...sa(D.headers),"Content-Range":`bytes ${I.start}-${I.end-1}/${S.file.size}`,"Content-Type":S.file.type||"application/octet-stream"},P=await fetch(D.upload_url,{method:Fl(D),headers:$,body:I.blob,signal:j.signal});if(!P.ok)throw new Error(`Chunk upload failed: ${P.status}`);I.uploaded=!0}async function f(S){return null}async function w(S){if(!o.value)throw new Error("API client not configured");const D=60;let I=0;for(;I<D;){const j=await o.value.get(`/api/v1/video/${S}`),$=T4(j),P=String($.processing_status);if(P==="ready")return $;if(P==="failed"||P==="error")throw new Error("Video processing failed");await new Promise(O=>{window.setTimeout(O,5e3)}),I++}throw new Error("Video processing timeout")}function F(S){const D=n.value.get(S);if(!D)return;const I=i.get(S);I&&(I.abort(),i.delete(S));const j=r.get(S);j&&(j.abort(),r.delete(S)),D.status="cancelled",D.error="Upload cancelled",t.value.delete(S)}async function T(S){const D=n.value.get(S);D&&(D.status="pending",D.error="",D.progress=0,D.bytesUploaded=0,await p(D.file))}function E(S){n.value.delete(S),t.value.delete(S),i.delete(S),r.delete(S)}function B(){Array.from(n.value.entries()).forEach(([S,D])=>{D.status==="completed"&&n.value.delete(S)})}function U(S){return`${S.name}-${S.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:m,validateFile:h,startUpload:p,cancelUpload:F,retryUpload:T,removeUpload:E,clearCompleted:B,setApiClient:d}}const D4=["accept","multiple"],A4={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},L4=["onKeydown"],U4={key:1,class:"upload-list","data-testid":"video-upload-list"},O4={class:"drag-content"},P4=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:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:h}=R4({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:f=>o("upload-start",f),onUploadProgress:f=>o("upload-progress",f),onUploadComplete:f=>o("upload-complete",f),onUploadError:(f,w)=>o("upload-error",f,w),onFilesSelected:f=>o("files-selected",f)});t.apiClient&&h(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),y=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function x(f){const w=f.target,F=Array.from(w.files||[]);F.length>0&&(c(F),w.value="")}function M(f){var T;f.preventDefault(),r.value=!1;const F=Array.from(((T=f.dataTransfer)==null?void 0:T.files)||[]).filter(E=>E.type.startsWith("video/"));F.length>0&&c(F)}function C(f){var w;f.preventDefault(),(w=f.dataTransfer)!=null&&w.types.includes("Files")&&(r.value=!0)}function b(f){f.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",C),document.addEventListener("dragleave",b),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",C),document.removeEventListener("dragleave",b),document.removeEventListener("drop",f=>f.preventDefault())}),(f,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(l)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:f.multiple,onChange:x,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,D4),!e.unref(l)||y.value?(e.openBlock(),e.createElementBlock("div",A4,[e.renderSlot(f.$slots,"trigger",{open:g},()=>[e.createElementVNode("div",{class:"default-upload-area","data-testid":"video-uploader-area",role:"button",tabindex:"0","aria-label":"Click to select video for upload",onClick:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(oc),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(f.label),1),e.createElementVNode("p",null,e.toDisplayString(f.description),1),e.createVNode(e.unref(L.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Sr),slot:"start","aria-hidden":"true"},null,8,["icon"]),w[2]||(w[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,L4)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",U4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),F=>(e.openBlock(),e.createBlock(V4,{key:F.id,upload:F,onCancel:T=>e.unref(d)(F.id),onRetry:T=>e.unref(u)(F.id),onRemove:T=>e.unref(m)(F.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:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:w[1]||(w[1]=F=>r.value=!1)},[e.createElementVNode("div",O4,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Co),"aria-hidden":"true"},null,8,["icon"]),w[3]||(w[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),z4=Ve(P4,[["__scopeId","data-v-ea7587f7"]]),j4=["aria-valuenow","aria-valuemax","aria-label"],W4={class:"progress-bar"},Z4={class:"time-display","data-testid":"video-time-display"},X4={class:"current-time"},H4={class:"duration"},G4={class:"control-buttons"},J4={class:"controls-left"},Y4=["aria-label"],q4={class:"controls-center"},K4={key:0,class:"volume-controls"},Q4=["aria-label"],eS=["value"],tS={class:"controls-right"},nS={key:0,class:"quality-selector"},oS=["aria-expanded"],aS={class:"quality-label"},iS={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},rS=["data-testid","aria-label","onClick"],sS=["aria-label"],lS=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(),l=L.isPlatform("mobile"),c="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),m=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let f=0;f<t.buffered.length;f++){const w=t.buffered.start(f),F=t.buffered.end(f);if(t.currentTime>=w&&t.currentTime<=F)return{width:`${F/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),h=e.computed(()=>t.muted||t.volume===0?rp:t.volume<33?op:t.volume<66?ap:np);let p=null;function y(){i.value=!0,g()}function g(){p&&clearTimeout(p),t.playing&&!l&&(p=setTimeout(()=>{i.value=!1},3e3))}function x(f){if(!s.value||t.isLive)return;const w=s.value.getBoundingClientRect(),T=(f.clientX-w.left)/w.width*t.duration;o("seek",Math.max(0,Math.min(T,t.duration)))}function M(f){const w=f.target;o("setVolume",parseInt(w.value))}function C(f){o("selectQuality",f),r.value=!1}function b(f){if(!isFinite(f))return"0:00";const w=Math.floor(f/3600),F=Math.floor(f%3600/60),T=Math.floor(f%60);return w>0?`${w}:${F.toString().padStart(2,"0")}:${T.toString().padStart(2,"0")}`:`${F}:${T.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",y),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",y),p&&clearTimeout(p)}),(f,w)=>(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(f.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(f.duration),"aria-label":f.isLive?"Live stream":"Video progress",tabindex:"0",onClick:x},[e.createElementVNode("div",W4,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(m.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",Z4,[e.createElementVNode("span",X4,e.toDisplayString(b(f.currentTime)),1),w[7]||(w[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",H4,e.toDisplayString(f.isLive?"LIVE":b(f.duration)),1)])],8,j4),e.createElementVNode("div",G4,[e.createElementVNode("div",J4,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:w[0]||(w[0]=F=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(L.IonIcon),{icon:f.playing?e.unref(Pm):e.unref(jm),"aria-hidden":"true"},null,8,["icon"])],8,Y4),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:w[1]||(w[1]=F=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Wm),"aria-hidden":"true"},null,8,["icon"]),w[8]||(w[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:w[2]||(w[2]=F=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Hm),"aria-hidden":"true"},null,8,["icon"]),w[9]||(w[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",q4,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",K4,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:w[3]||(w[3]=F=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(L.IonIcon),{icon:h.value,"aria-hidden":"true"},null,8,["icon"])],8,Q4),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:f.muted?0:f.volume,onInput:M,"aria-label":"Volume"},null,40,eS)]))]),e.createElementVNode("div",tS,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",nS,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:w[4]||(w[4]=F=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Qm),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",aS,e.toDisplayString(f.currentQuality),1)],8,oS),r.value?(e.openBlock(),e.createElementBlock("div",iS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,F=>(e.openBlock(),e.createElementBlock("button",{key:F.label,class:e.normalizeClass(["quality-option",{active:F.label===f.currentQuality}]),"data-testid":`btn-video-quality-${F.label}`,"aria-label":`Set quality to ${F.label}`,role:"menuitem",onClick:T=>C(F)},e.toDisplayString(F.label),11,rS))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&c?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:w[5]||(w[5]=F=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(ep),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:w[6]||(w[6]=F=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(L.IonIcon),{icon:f.fullscreen?e.unref(Bm):e.unref($m),"aria-hidden":"true"},null,8,["icon"])],8,sS)])])],2))}}),cS=Ve(lS,[["__scopeId","data-v-2ae77c13"]]);function dS(a={}){var te,fe,ye;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(a.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),h=e.ref(null),p=e.ref("idle"),y=e.ref(a.playbackUrl||((te=a.media)==null?void 0:te.playback_url)||((fe=a.media)==null?void 0:fe.url)||""),g=e.ref(null),x=e.ref(a.isLive||!1),M=e.ref(null),C=e.ref(null);function b(oe){C.value=oe}if((ye=a.media)!=null&&ye.token_expires_at){const oe=new Date(a.media.token_expires_at);g.value=Number.isNaN(oe.getTime())?null:oe}async function f(){var _;const oe=x.value?t.value:n.value;if(oe)try{await oe.play(),o.value=!0,p.value=x.value?"live":"playing",(_=a.onPlay)==null||_.call(a)}catch{h.value="Failed to play video",p.value="error"}}function w(){var _;const oe=x.value?t.value:n.value;oe&&(oe.pause(),o.value=!1,p.value="paused",(_=a.onPause)==null||_.call(a))}function F(){o.value?w():f()}function T(oe){const _=x.value?t.value:n.value;if(!_||x.value)return;const A=Number.isFinite(_.duration)?_.duration:oe;_.currentTime=Math.max(0,Math.min(oe,A)),i.value=_.currentTime}function E(oe=10){const _=n.value;!_||x.value||T(_.currentTime+oe)}function B(oe=10){const _=n.value;!_||x.value||T(_.currentTime-oe)}function U(){const oe=x.value?t.value:n.value;oe&&(oe.muted=!oe.muted,l.value=oe.muted)}function S(oe){const _=x.value?t.value:n.value;if(!_)return;const A=Math.max(0,Math.min(100,oe));_.volume=A/100,s.value=A,A>0&&_.muted&&(_.muted=!1,l.value=!1)}function D(oe){const _=n.value;!_||x.value||(_.playbackRate=oe,u.value=oe)}async function I(){const oe=document.querySelector(".video-player-container");if(oe)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await oe.requestFullscreen(),c.value=!0)}catch{}}async function j(){const oe=x.value?t.value:n.value;if(oe)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await oe.requestPictureInPicture()}catch{}}async function $(){var _;h.value=null,p.value="loading",(_=a.media)!=null&&_.provider&&a.media.provider!=="local"&&await P();const oe=x.value?t.value:n.value;oe&&(oe.load(),await f())}async function P(){if(!(!C.value||!a.media))try{m.value=!0;const oe=await C.value.get(`/api/v1/video/${a.media.uuid}/playback`);y.value=oe.playback_url,g.value=new Date(oe.token_expires_at);const _=x.value?t.value:n.value;if(_&&_.src!==y.value){const A=!_.paused,Q=_.currentTime;_.src=y.value,x.value||(_.currentTime=Q),A&&await f()}}catch{h.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function O(oe){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=oe;return}try{t.value.src=oe}catch{h.value="Live streaming not supported in this browser",p.value="error"}}}function V(){M.value&&(M.value.destroy(),M.value=null)}function R(){var _;const oe=x.value?t.value:n.value;oe&&(i.value=oe.currentTime,r.value=oe.duration,(_=a.onTimeUpdate)==null||_.call(a,oe.currentTime))}const G=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let oe=0;oe<d.value.length;oe++){const _=d.value.start(oe),A=d.value.end(oe);if(i.value>=_&&i.value<=A)return A/r.value*100}return 0});function J(){if(!g.value)return!1;const oe=new Date;return g.value.getTime()-oe.getTime()<5*60*1e3}return e.watch([n,t],([oe,_])=>{const A=x.value?_:oe;A&&(A.addEventListener("timeupdate",R),A.addEventListener("loadedmetadata",()=>{r.value=A.duration,p.value="ready"}),A.addEventListener("progress",()=>{d.value=A.buffered}),A.addEventListener("ended",()=>{var Q;o.value=!1,p.value="ended",(Q=a.onEnded)==null||Q.call(a)}),A.addEventListener("error",Q=>{var ee;p.value="error",(ee=a.onError)==null||ee.call(a,"Video playback error")}),A.volume=s.value/100,A.muted=l.value)}),e.onUnmounted(()=>{V();const oe=x.value?t.value:n.value;oe&&oe.removeEventListener("timeupdate",R)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:G,playbackRate:u,isLoading:m,error:h,status:p,currentPlaybackUrl:y,tokenExpiresAt:g,play:f,pause:w,togglePlayPause:F,seek:T,skipForward:E,skipBackward:B,toggleMute:U,setVolume:S,setPlaybackRate:D,toggleFullscreen:I,togglePiP:j,retry:$,refreshToken:P,setupLiveStream:O,setApiClient:b,shouldRefreshToken:J}}const uS=["src","poster","controls","autoplay","muted","loop","preload"],mS={key:1,ref:"livePlayerEl",class:"live-player"},pS=["controls","muted"],fS={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},hS={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},vS={key:3,class:"video-error","data-testid":"video-error",role:"alert"},gS={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},yS=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:l,duration:c,volume:d,muted:u,isFullscreen:m,bufferedRanges:h,isLoading:p,error:y,status:g,currentPlaybackUrl:x,tokenExpiresAt:M,play:C,pause:b,seek:f,toggleMute:w,setVolume:F,toggleFullscreen:T,togglePlayPause:E,skipForward:B,skipBackward:U,retry:S,refreshToken:D,setApiClient:I,shouldRefreshToken:j,setupLiveStream:$}=dS({...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 P(){await D()}const O=e.computed(()=>{const ee=["video-player-container"];return t.className&&ee.push(t.className),m.value&&ee.push("fullscreen"),t.isLive&&ee.push("is-live"),s.value&&ee.push("is-playing"),p.value&&ee.push("is-loading"),ee}),V=e.computed(()=>{var ee,ne;if(t.poster)return t.poster;if((ee=t.media)!=null&&ee.poster_url)return t.media.poster_url;if((ne=t.media)!=null&&ne.thumbnail_url)return t.media.thumbnail_url});function R(ee){const ne=ee.target;o("loadedmetadata",{duration:ne.duration,width:ne.videoWidth,height:ne.videoHeight})}function G(ee){const ne=ee.target;l.value=ne.currentTime,o("timeupdate",ne.currentTime)}function J(){s.value=!0,o("play")}function te(){s.value=!1,o("pause")}function fe(){s.value=!1,o("ended")}function ye(ee){const ne=ee.target;let pe="Failed to load video";if(ne.error)switch(ne.error.code){case ne.error.MEDIA_ERR_ABORTED:pe="Video playback aborted";break;case ne.error.MEDIA_ERR_NETWORK:pe="Network error while loading video";break;case ne.error.MEDIA_ERR_DECODE:pe="Video decoding error";break;case ne.error.MEDIA_ERR_SRC_NOT_SUPPORTED:pe="Video format not supported";break}y.value=pe,o("error",pe)}function oe(ee){const ne=ee.target;h.value=ne.buffered,o("progress",ne.buffered)}function _(){p.value=!0}function A(){p.value=!1}e.watch(()=>t.apiClient,ee=>{ee&&I(ee)},{immediate:!0}),e.watch(()=>t.playbackUrl,ee=>{typeof ee=="string"&&ee.length>0&&(x.value=ee)},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.token_expires_at},ee=>{if(!ee){M.value=null;return}const ne=new Date(ee);M.value=Number.isNaN(ne.getTime())?null:ne},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.playback_url},async(ee,ne)=>{if(t.playbackUrl||!ee||ee===ne)return;const pe=i.value;if(!pe||t.isLive){x.value=ee;return}const ie=!pe.paused,me=pe.currentTime;x.value=ee,await e.nextTick();try{pe.currentTime=me}catch{}ie&&await C()},{immediate:!0});let Q=null;return e.watch(()=>t.isLive,async ee=>{var pe;if(!ee)return;const ne=t.playbackUrl||((pe=t.media)==null?void 0:pe.playback_url)||"";ne&&await $(ne)},{immediate:!0}),e.onMounted(()=>{var ee;(ee=t.media)!=null&&ee.provider&&t.media.provider!=="local"&&(Q=setInterval(()=>{j()&&P()},3e4)),L.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{Q&&clearInterval(Q)}),(ee,ne)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",O.value]),"data-testid":"video-player"},[ee.isLive?(e.openBlock(),e.createElementBlock("div",mS,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ee.controls&&!ee.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:J,onPause:te,onError:ye,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,pS),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",fS,[...ne[3]||(ne[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(x),poster:V.value,controls:ee.controls&&!ee.showCustomControls,autoplay:ee.autoplay,muted:e.unref(u),loop:ee.loop,preload:ee.preload,onLoadedmetadata:R,onTimeupdate:G,onPlay:J,onPause:te,onEnded:fe,onError:ye,onProgress:oe,onWaiting:_,onCanplay:A,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,uS)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",hS,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(y)?(e.openBlock(),e.createElementBlock("div",vS,[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Vr),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(y)),1),e.createVNode(e.unref(L.IonButton),{size:"small",onClick:e.unref(S),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Yn),slot:"start","aria-hidden":"true"},null,8,["icon"]),ne[4]||(ne[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ee.showCustomControls&&!e.unref(y)?(e.openBlock(),e.createBlock(cS,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(h),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ee.isLive,onPlay:e.unref(C),onPause:e.unref(b),onSeek:e.unref(f),onToggleMute:e.unref(w),onSetVolume:e.unref(F),onToggleFullscreen:e.unref(T),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ee.enableGestures&&!e.unref(y)?(e.openBlock(),e.createElementBlock("div",gS,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ne[0]||(ne[0]=(...pe)=>e.unref(U)&&e.unref(U)(...pe))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ne[1]||(ne[1]=(...pe)=>e.unref(E)&&e.unref(E)(...pe))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ne[2]||(ne[2]=(...pe)=>e.unref(B)&&e.unref(B)(...pe))},null,32)])):e.createCommentVNode("",!0)],2))}}),ud=Ve(yS,[["__scopeId","data-v-b8db4951"]]),bS=Aa.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())),l=e.computed(()=>s.value.filter($=>$.status==="live")),c=e.computed(()=>r.value.filter($=>$.processing_status==="processing"));function d($){a.value.set($.uuid,$)}function u($,P){const O=a.value.get($);O&&a.value.set($,{...O,...P})}function m($){a.value.delete($)}function h($){return a.value.get($)}function p($){n.value.set($.id,$)}function y($,P){const O=n.value.get($);O&&n.value.set($,{...O,...P})}function g($,P){const O=n.value.get($);O&&n.value.set($,{...O,status:P.status,viewer_count:P.viewer_count,peak_viewers:P.peak_viewers})}function x($){n.value.delete($)}function M($){return n.value.get($)}function C($){return s.value.find(P=>P.media_uuid===$)}function b($){t.value.set($.id,$)}function f($,P){const O=t.value.get($);O&&t.value.set($,{...O,...P})}function w($){t.value.delete($)}function F($){return t.value.get($)}function T($){return Array.from(t.value.values()).filter(P=>P.media_uuid===$)}function E($){o.value=$}function B($){o.value&&(o.value={...o.value,...$})}function U(){o.value=null}function S($){i.value=$}function D(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function I($){a.value.clear(),$.forEach(P=>{a.value.set(P.uuid,P)})}function j($){n.value.clear(),$.forEach(P=>{n.value.set(P.id,P)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:m,getVideo:h,setLiveStream:p,updateLiveStream:y,updateLiveStreamStats:g,removeLiveStream:x,getLiveStream:M,getLiveStreamByMedia:C,addExportJob:b,updateExportJob:f,removeExportJob:w,getExportJob:F,getExportJobsByMedia:T,setEditorState:E,updateEditorState:B,clearEditorState:U,setProcessing:S,clearAll:D,loadVideos:I,loadLiveStreams:j}});let En=null;function wS(a){En=a}const ca={post:async(a,n)=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${a}`)},delete:async a=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${a}`,{method:"DELETE"})}};function da(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 Gi(a,n){return a instanceof Error&&a.message?a.message:n}function kS(a){const n=bS(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),m=e.ref(0);let h;const p=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),y=e.computed(()=>{var U;if(!((U=t.value)!=null&&U.playback_url))return null;const B=new URL(t.value.playback_url);return B.searchParams.set("live","true"),o.value&&B.searchParams.set("latency","low"),B.toString()}),g=e.computed(()=>{var B;return((B=t.value)==null?void 0:B.status)==="live"}),x=e.computed(()=>{var B;return((B=t.value)==null?void 0:B.status)==="idle"}),M=e.computed(()=>{var B;return((B=t.value)==null?void 0:B.status)==="ended"});async function C(B={}){s.value=!0,c.value=null;try{const U=await ca.post("/live",{title:r.value||B.title||"Live Stream",low_latency:B.low_latency??o.value,auto_record:B.auto_record??i.value,...B}),S=da(U);return t.value=S,n.setLiveStream(S),F(),S}catch(U){throw c.value=Gi(U,"Failed to create stream"),U instanceof Error?U:new Error(c.value)}finally{s.value=!1}}async function b(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const B=await ca.post(`/live/${t.value.id}/end`),U=da(B,t.value);return t.value=U,n.setLiveStream(U),T(),U}catch(B){throw c.value=Gi(B,"Failed to end stream"),B instanceof Error?B:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const B=await ca.get(`/live/${t.value.id}`),U=da(B,t.value);u.value=U.viewer_count,m.value=U.peak_viewers,t.value=U;const S={status:U.status,viewer_count:U.viewer_count,peak_viewers:U.peak_viewers};U.started_at&&(S.started_at=U.started_at),U.ended_at&&(S.ended_at=U.ended_at),n.updateLiveStreamStats(U.id,S),U.status==="live"&&!d.value&&U.started_at&&(d.value=new Date(U.started_at)),U.status==="ended"&&T()}catch{}}async function w(B){try{const U=await ca.get(`/live/${B}`),S=da(U,t.value);return{rtmp_url:S.rtmp_url,stream_key:S.stream_key,playback_url:S.playback_url||""}}catch(U){throw c.value=Gi(U,"Failed to get stream credentials"),U instanceof Error?U:new Error(c.value)}}function F(B=5e3){T(),h=window.setInterval(()=>{f()},B)}function T(){h!==void 0&&(clearInterval(h),h=void 0)}async function E(){if(!a)return;const B=n.getLiveStreamByMedia(a);B&&(t.value=B,u.value=B.viewer_count,m.value=B.peak_viewers,B.status==="live"&&(F(),B.started_at&&(d.value=new Date(B.started_at))))}return a&&E(),e.onUnmounted(()=>{T()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:y,isLive:g,isIdle:x,hasEnded:M,createStream:C,endStream:b,refreshStreamStatus:f,getStreamCredentials:w,startStatusPolling:F,stopStatusPolling:T}}const xS={class:"stream-status"},ES={class:"flex items-center justify-between"},SS={class:"flex items-center gap-3"},VS={key:0,class:"flex items-center"},_S={key:2,class:"text-sm text-gray-600"},CS={key:0,class:"flex items-center gap-2"},NS={class:"text-sm font-medium text-gray-700"},TS={key:0,class:"text-xs text-gray-500"},MS=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),l=n.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",xS,[e.createElementVNode("div",ES,[e.createElementVNode("div",SS,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",VS,[...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",_S,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",CS,[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",NS,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",TS," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),BS=Ve(MS,[["__scopeId","data-v-1d09c19f"]]),IS={class:"stream-credentials"},FS={class:"space-y-3"},$S={class:"credential-field"},RS={class:"flex gap-2"},DS=["value"],AS={class:"credential-field"},LS={class:"flex gap-2"},US=["value","type"],OS=["aria-label"],PS={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},zS={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},jS={key:0,class:"mt-2 text-sm text-green-600"},WS=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 l(){i.value=!i.value}async function c(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",IS,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",FS,[e.createElementVNode("div",$S,[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",RS,[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,DS),e.createElementVNode("button",{onClick:u[0]||(u[0]=m=>c(d.rtmpUrl,"RTMP URL")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy RTMP URL"},[...u[2]||(u[2]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])]),e.createElementVNode("div",AS,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",LS,[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,US),e.createElementVNode("button",{onClick:l,class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":i.value?"Hide stream key":"Show stream key"},[i.value?(e.openBlock(),e.createElementBlock("svg",zS,[...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",PS,[...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,OS),e.createElementVNode("button",{onClick:u[1]||(u[1]=m=>c(d.streamKey,"Stream Key")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy stream key"},[...u[6]||(u[6]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])])]),u[9]||(u[9]=e.createElementVNode("details",{class:"mt-4"},[e.createElementVNode("summary",{class:"cursor-pointer text-sm text-blue-600 hover:text-blue-700"}," How to connect with OBS Studio "),e.createElementVNode("div",{class:"mt-2 p-3 bg-blue-50 rounded-md text-sm text-gray-700"},[e.createElementVNode("ol",{class:"list-decimal list-inside space-y-1"},[e.createElementVNode("li",null,"Open OBS Studio"),e.createElementVNode("li",null,"Go to Settings → Stream"),e.createElementVNode("li",null,'Set Service to "Custom"'),e.createElementVNode("li",null,'Paste the RTMP URL in "Server"'),e.createElementVNode("li",null,'Paste the Stream Key in "Stream Key"'),e.createElementVNode("li",null,'Click OK and then "Start Streaming"')])])],-1)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createElementBlock("div",jS,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),ZS=Ve(WS,[["__scopeId","data-v-306d92f6"]]),XS={class:"live-stream-manager","data-testid":"live-stream-manager"},HS={key:0,class:"stream-setup"},GS={class:"space-y-4"},JS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},YS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},qS=["disabled"],KS={key:0},QS={key:1,class:"flex items-center justify-center"},eV={key:1,class:"stream-active space-y-6"},tV={key:1,class:"video-preview"},nV={key:2,class:"analytics-panel"},oV={class:"grid grid-cols-2 gap-4"},aV={class:"bg-gray-50 p-3 rounded"},iV={class:"text-2xl font-bold text-gray-900"},rV={class:"bg-gray-50 p-3 rounded"},sV={class:"text-2xl font-bold text-gray-900"},lV={class:"stream-controls flex gap-3"},cV=["disabled"],dV={key:0},uV={key:1},mV={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},pV={class:"text-red-600 text-sm"},fV=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&&wS(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:m,endStream:h,streamDuration:p,playbackUrl:y,refreshStreamStatus:g}=kS(t.mediaUuid),x=e.ref(!1);async function M(){var F;try{const T=await m({title:l.value,low_latency:r.value,auto_record:s.value});o("stream-created",T),(F=t.onStreamCreated)==null||F.call(t,T)}catch(T){o("error",T)}}async function C(){var F;try{const T=await h();o("stream-ended",T),(F=t.onStreamEnded)==null||F.call(t,T)}catch(T){o("error",T)}}function b(){i.value=null,l.value="",x.value=!1,u.value=null}async function f(F,T){try{await navigator.clipboard.writeText(F)}catch{}}let w;return e.onMounted(()=>{var F;((F=i.value)==null?void 0:F.status)==="live"&&(w=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{w&&clearInterval(w)}),(F,T)=>(e.openBlock(),e.createElementBlock("div",XS,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",eV,[e.createVNode(BS,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(ZS,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:f},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(y)?(e.openBlock(),e.createElementBlock("div",tV,[T[9]||(T[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(ud,{"playback-url":e.unref(y),"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",nV,[T[12]||(T[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",oV,[e.createElementVNode("div",aV,[e.createElementVNode("div",iV,e.toDisplayString(e.unref(i).viewer_count),1),T[10]||(T[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",rV,[e.createElementVNode("div",sV,e.toDisplayString(e.unref(i).peak_viewers),1),T[11]||(T[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",lV,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:T[3]||(T[3]=E=>x.value=!x.value),class:"flex-1 py-2 px-4 bg-gray-200 text-gray-700 font-medium rounded-lg hover:bg-gray-300 transition-colors"},e.toDisplayString(x.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:C,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",uV,"Ending...")):(e.openBlock(),e.createElementBlock("span",dV,"End Stream"))],8,cV)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:b,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",HS,[T[8]||(T[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",GS,[e.createElementVNode("div",JS,[T[4]||(T[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":T[0]||(T[0]=E=>e.isRef(r)?r.value=E: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",YS,[T[5]||(T[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":T[1]||(T[1]=E=>e.isRef(s)?s.value=E: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,[T[6]||(T[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":T[2]||(T[2]=E=>e.isRef(l)?l.value=E:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:M,disabled:e.unref(c),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",QS,[...T[7]||(T[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",KS,"Create Stream"))],8,qS)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",mV,[e.createElementVNode("p",pV,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),hV=Ve(fV,[["__scopeId","data-v-26291f6f"]]),vV={class:"album-tree-node"},gV=["data-album-id","draggable","aria-selected","aria-expanded"],yV={key:1,class:"album-node__chevron-placeholder"},bV={key:2,"data-testid":"media-count",class:"album-node__count"},wV={key:0,class:"album-tree-node__children",role:"group"},kV=16,xV=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),l=e.computed(()=>t.album.children_count>0),c=e.computed(()=>`${t.depth*kV}px`),d=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.dropTargetId)===t.album.id}),m=e.computed(()=>{var b;return(b=t.dragState)!=null&&b.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),h=e.computed(()=>{const b=["album-node"];return r.value&&b.push("album-node--selected"),s.value&&b.push("album-node--focused"),t.compact&&b.push("album-node--compact"),d.value&&b.push("album-node--dragging"),u.value&&b.push("album-node--drop-target"),m.value&&b.push("album-node--invalid-drop"),b});function p(){o("select",t.album)}function y(b){b.stopPropagation(),o("toggle-expand",t.album.id)}function g(b){t.draggable&&(b.dataTransfer&&(b.dataTransfer.setData("text/plain",t.album.id),b.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function x(b){t.draggable&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function M(){o("drag-leave",t.album.id)}function C(b){t.draggable&&(b.preventDefault(),o("drop",t.album.id))}return(b,f)=>{var F;const w=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",vV,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":b.album.id,class:e.normalizeClass(h.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:b.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:g,onDragover:x,onDragleave:M,onDrop:C},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:y},[e.createVNode(e.unref(L.IonIcon),{icon:i.value?e.unref(Nm):e.unref(Tm)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",yV)),e.createVNode(e.unref(L.IonIcon),{icon:e.unref(Am),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(b.album.name),1),b.showMediaCount?(e.openBlock(),e.createElementBlock("span",bV,e.toDisplayString(b.album.media_count),1)):e.createCommentVNode("",!0)],46,gV),i.value&&((F=b.album.children)!=null&&F.length)?(e.openBlock(),e.createElementBlock("div",wV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.album.children,T=>(e.openBlock(),e.createBlock(w,{key:T.id,album:T,depth:b.depth+1,"selected-id":b.selectedId,"expanded-ids":b.expandedIds,"focused-id":b.focusedId,draggable:b.draggable,"show-media-count":b.showMediaCount,compact:b.compact,onSelect:f[0]||(f[0]=E=>o("select",E)),onToggleExpand:f[1]||(f[1]=E=>o("toggle-expand",E))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),EV=Ve(xV,[["__scopeId","data-v-76be65a6"]]),si=Aa.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 f=new Map;return a.value.forEach(w=>f.set(w.id,w)),f}),s=e.computed(()=>a.value.filter(f=>f.parent_id===null));async function l(f){t.value=!0,o.value=null;try{const w=(f==null?void 0:f.parent_id)??null,F=w?`/api/v1/albums?parent_id=${w}`:"/api/v1/albums?parent_id=null",T=await fetch(F);if(!T.ok)throw new Error("Failed to fetch albums");((await T.json()).data||[]).forEach(U=>{const S=a.value.findIndex(D=>D.id===U.id);S>=0?a.value[S]=U:a.value.push(U)}),w!==null&&i.value.add(w)}catch(w){o.value=w instanceof Error?w.message:"Unknown error"}finally{t.value=!1}}async function c(f){t.value=!0,o.value=null;try{const w=await fetch(`/api/v1/albums/${f}`);if(!w.ok)throw new Error("Failed to fetch album");const T=(await w.json()).data,E=a.value.findIndex(B=>B.id===T.id);return E>=0?a.value[E]=T:a.value.push(T),T}catch(w){throw o.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function d(f){t.value=!0,o.value=null;try{const w=await fetch(`/api/v1/albums/${f}/media`);if(!w.ok)throw new Error("Failed to fetch album media");const T=(await w.json()).data||[];return n.value.set(f,T),T}catch(w){throw o.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function u(f,w){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${f}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:w})})).ok)throw new Error("Failed to reorder album media");const T=n.value.get(f)||[],E=w.map(B=>T.find(U=>U.uuid===B)).filter(B=>B!==void 0);n.value.set(f,E)}catch(F){throw o.value=F instanceof Error?F.message:"Unknown error",F}finally{t.value=!1}}async function m(f){t.value=!0,o.value=null;try{const w=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(f)});if(!w.ok)throw new Error("Failed to create album");const T=(await w.json()).data;return a.value.push(T),T}catch(w){throw o.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function h(f,w){t.value=!0,o.value=null;try{const F=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(w)});if(!F.ok)throw new Error("Failed to update album");const E=(await F.json()).data,B=a.value.findIndex(U=>U.id===E.id);return B>=0&&(a.value[B]=E),E}catch(F){throw o.value=F instanceof Error?F.message:"Unknown error",F}finally{t.value=!1}}async function p(f){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${f}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const F=a.value.findIndex(T=>T.id===f);F>=0&&a.value.splice(F,1),n.value.delete(f)}catch(w){throw o.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}function y(f){return a.value.filter(w=>w.parent_id===f)}function g(f){return i.value.has(f)}function x(f){return n.value.get(f)||[]}async function M(f,w){const F=a.value.findIndex(E=>E.id===f);if(F<0)return;const T=a.value[F];a.value[F]={...T,parent_id:w};try{if(!(await fetch(`/api/v1/albums/${f}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:w})})).ok)throw new Error("Failed to move album")}catch(E){throw a.value[F]=T,o.value=E instanceof Error?E.message:"Unknown error",E instanceof Error?E:new Error("Failed to move album")}}function C(f){a.value=f}function b(){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:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:h,deleteAlbum:p,getChildrenOf:y,childrenLoaded:g,getAlbumMedia:x,moveAlbum:M,setAlbums:C,reset:b}});function md(){const a=si(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=Aa.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function l(u){return a.getChildrenOf(u)}function c(u){return a.childrenLoaded(u)}async function d(u,m){await a.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function pd(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,h){if(m===h)return!0;const p=new Set,y=[m];for(;y.length>0;){const g=y.shift();if(!g||p.has(g))continue;p.add(g);const x=n.get(g)||[];for(const M of x){if(M===h)return!0;y.push(M)}}return!1}function r(m,h){return m===h?!1:h===null?!0:!i(m,h)}function s(m){o.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function l(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(m){o.value.dropTargetId=m}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:h}=o.value;if(!m){l();return}if(!r(m,h)){l();return}try{await t(m,h)}finally{l()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const SV={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},VV={key:1,"data-testid":"error-state",class:"album-tree__error"},_V={key:2,"data-testid":"empty-state",class:"album-tree__empty"},CV={key:3,class:"album-tree__content",role:"group"},NV=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),l=e.computed(()=>o.compact===!0),{albums:c,rootAlbums:d,loading:u,error:m,fetchAlbums:h,getChildrenOf:p,childrenLoaded:y,moveAlbum:g}=md(),x=e.shallowRef(new Set(o.expandedIds)),M=e.ref(o.modelValue??null),C=e.ref(null),b=new Map,f=new Map;function w(_){b.clear(),f.clear();for(const A of _){b.set(A.id,A);const Q=A.parent_id??null,ee=f.get(Q)??[];ee.push(A.id),f.set(Q,ee)}}e.watch(c,_=>{w(_)},{immediate:!0});const{dragState:F,canDropOn:T,startDrag:E,endDrag:B,setDropTarget:U,clearDropTarget:S,executeDrop:D}=pd({childrenByParentId:f,onMove:async(_,A)=>{await g(_,A),i("album-moved",{albumId:_,newParentId:A})}});e.watch(()=>o.modelValue,_=>{M.value=_??null}),e.watch(()=>o.expandedIds,_=>{x.value=new Set(_)}),e.onMounted(async()=>{await h({parent_id:null})});const I=e.computed(()=>d.value.map(_=>j(_)));function j(_){if(!x.value.has(_.id))return _;const A=p(_.id);return{..._,children:A.map(Q=>j(Q))}}const $=e.computed(()=>{const _=[];function A(Q){var ee;for(const ne of Q)_.push(ne),x.value.has(ne.id)&&((ee=ne.children)!=null&&ee.length)&&A(ne.children)}return A(I.value),_});function P(_){var ee;if(!$.value.length)return;const A=C.value?$.value.findIndex(ne=>ne.id===C.value):-1,Q=A>=0?$.value[A]:null;switch(_.key){case"ArrowDown":_.preventDefault(),A<$.value.length-1?C.value=$.value[A+1].id:A===-1&&$.value.length>0&&(C.value=$.value[0].id);break;case"ArrowUp":_.preventDefault(),A>0&&(C.value=$.value[A-1].id);break;case"ArrowRight":_.preventDefault(),Q&&(Q.children_count>0&&!x.value.has(Q.id)?O(Q.id):x.value.has(Q.id)&&((ee=Q.children)!=null&&ee.length)&&(C.value=Q.children[0].id));break;case"ArrowLeft":_.preventDefault(),Q&&(x.value.has(Q.id)&&Q.children_count>0?O(Q.id):Q.parent_id&&(C.value=Q.parent_id));break;case"Enter":case" ":_.preventDefault(),Q&&V(Q);break;case"Home":_.preventDefault(),$.value.length>0&&(C.value=$.value[0].id);break;case"End":_.preventDefault(),$.value.length>0&&(C.value=$.value[$.value.length-1].id);break}}async function O(_){x.value.has(_)?(x.value.delete(_),i("album-collapsed",_)):(y(_)||await h({parent_id:_}),x.value.add(_),i("album-expanded",_))}function V(_){M.value=_.id,i("update:modelValue",_.id),i("album-selected",_)}function R(_){o.draggable&&E(_)}function G(_){var Q;if(!o.draggable)return;const A=(Q=F.value)==null?void 0:Q.draggedAlbumId;A&&(U(_),T(A,_))}function J(){o.draggable&&S()}async function te(_){o.draggable&&(U(_),await D())}function fe(_){o.draggable&&(_.preventDefault(),U(null))}async function ye(_){o.draggable&&(_.preventDefault(),U(null),await D())}function oe(){B()}return n({focusedId:C}),(_,A)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:P,onDragover:fe,onDrop:ye,onDragend:oe},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",SV,[e.createVNode(e.unref(L.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",VV,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",CV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,Q=>(e.openBlock(),e.createBlock(EV,{key:Q.id,album:Q,depth:0,"selected-id":M.value,"expanded-ids":x.value,"focused-id":C.value,draggable:r.value,"drag-state":r.value?e.unref(F):null,"show-media-count":s.value,compact:l.value,onSelect:V,onToggleExpand:O,onDragStart:R,onDragOver:G,onDragLeave:J,onDrop:te},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",_V,[A[0]||(A[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(_.$slots,"empty-action",{},void 0,!0)]))],32))}}),fd=Ve(NV,[["__scopeId","data-v-ae3dea7a"]]),TV=300,MV=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),l=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const c=e.computed(()=>r.value!==null);function d(p){const y=Date.now();if(l.value===p.id&&y-s.value<TV){o("confirm",p);return}s.value=y,l.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&o("confirm",r.value)}function m(){o("close")}function h(){o("close")}return(p,y)=>(e.openBlock(),e.createBlock(e.unref(L.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:h},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(L.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{"data-testid":"cancel-button",onClick:m},{default:e.withCtx(()=>[...y[1]||(y[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(L.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(fd,{modelValue:i.value,"onUpdate:modelValue":y[0]||(y[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(L.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{fill:"clear",onClick:m},{default:e.withCtx(()=>[...y[2]||(y[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(L.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),hd=Ve(MV,[["__scopeId","data-v-21676ec1"]]),BV={class:"ion-padding-start text-sm"},IV={class:"ion-padding-start text-sm"},FV={key:1},$V={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},RV={class:"flex items-center justify-between gap-3 pb-3"},DV={class:"text-base font-semibold text-gray-900"},AV={class:"ion-padding-start text-sm"},LV={class:"ion-padding-start text-sm"},UV={class:"flex justify-between pt-2"},OV={key:1},po=255,fo=1e3,PV=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=si(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),l=e.computed(()=>r.value?"Save":"Create"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),m=e.ref(!1),h=e.ref(null),p=e.ref(!1),y=e.ref(!1),g=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>po?`Name must be ${po} characters or less`:null:"Name is required":null),x=e.computed(()=>d.value.description&&c.value.description.length>fo?`Description must be ${fo} characters or less`:null),M=e.computed(()=>{const P=c.value.name.trim().length>0,O=c.value.name.length<=po,V=c.value.description.length<=fo;return P&&O&&V&&!p.value}),C=e.computed(()=>{var P;return((P=u.value)==null?void 0:P.name)??"None (Root)"}),b=e.computed(()=>h.value?h.value.children_count===0&&h.value.media_count===0:!1),f=e.computed(()=>h.value?h.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":h.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${h.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await w()});async function w(){if(t.albumId)try{const P=await i.fetchAlbum(t.albumId);h.value=P,c.value={name:P.name,description:P.description??"",parent_id:P.parent_id},P.parent_id&&(u.value={id:P.parent_id,name:"Parent Album"})}catch(P){o("error",P)}}function F(){d.value.name=!0}function T(){d.value.description=!0}function E(){m.value=!0}function B(P){u.value={id:P.id,name:P.name},c.value.parent_id=P.id,m.value=!1}function U(){m.value=!1}function S(){o("close")}function D(){o("close")}async function I(){if(d.value.name=!0,d.value.description=!0,!(!M.value||p.value)){p.value=!0;try{const P={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const O=await i.updateAlbum(t.albumId,P);o("updated",O)}else{const O=await i.createAlbum(P);o("created",O)}o("close")}catch(P){o("error",P)}finally{p.value=!1}}}function j(){b.value&&(y.value=!0)}async function $(P){var V;if((((V=P.detail)==null?void 0:V.role)??"")!=="confirm"){y.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(R){o("error",R)}finally{p.value=!1,y.value=!1}}}return(P,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[P.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(L.IonModal),{key:0,"is-open":P.isOpen,class:"album-manager-modal",onDidDismiss:D},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(L.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:S},{default:e.withCtx(()=>[...O[4]||(O[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(L.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(L.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...O[5]||(O[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(L.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":O[0]||(O[0]=V=>c.value.name=V),"data-testid":"name-input",maxlength:po,onIonBlur:F},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(L.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",BV,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...O[6]||(O[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(L.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":O[1]||(O[1]=V=>c.value.description=V),"data-testid":"description-input",maxlength:fo,onIonBlur:T},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(L.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",IV,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonItem),{button:"","data-testid":"parent-selector",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...O[7]||(O[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(L.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(L.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!b.value,title:b.value?void 0:f.value,onClick:j},{default:e.withCtx(()=>[...O[8]||(O[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(L.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(L.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",FV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",$V,[e.createElementVNode("div",RV,[e.createElementVNode("h2",DV,e.toDisplayString(s.value),1),e.createVNode(e.unref(L.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:S},{default:e.withCtx(()=>[...O[9]||(O[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(L.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...O[10]||(O[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(L.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":O[2]||(O[2]=V=>c.value.name=V),"data-testid":"name-input",maxlength:po,onIonBlur:F},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(L.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",AV,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...O[11]||(O[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(L.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":O[3]||(O[3]=V=>c.value.description=V),"data-testid":"description-input",maxlength:fo,onIonBlur:T},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(L.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",LV,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonItem),{button:"","data-testid":"parent-selector",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonLabel),null,{default:e.withCtx(()=>[...O[12]||(O[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(L.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1}),e.createElementVNode("div",UV,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(L.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!b.value,title:b.value?void 0:f.value,onClick:j},{default:e.withCtx(()=>[...O[13]||(O[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(L.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(L.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",OV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(hd,{"is-open":m.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:U,onConfirm:B},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(L.IonAlert),{"is-open":y.value,header:"Delete Album?",message:f.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:$},null,8,["is-open","message"])],64))}}),zV=Ve(PV,[["__scopeId","data-v-22083f3a"]]),jV={class:"album-media-grid"},WV={class:"aspect-square"},ZV={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},XV={class:"text-gray-500"},HV=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],GV={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},JV={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},YV={class:"aspect-square relative"},qV=["src","alt"],KV={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},QV=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=si(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),c=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),m=e.computed(()=>!u.value&&r.value.length===0),h=e.computed(()=>{const D=t.columns;return["grid","gap-4",`grid-cols-${D.mobile??2}`,`sm:grid-cols-${D.sm??3}`,`md:grid-cols-${D.md??4}`,`lg:grid-cols-${D.lg??5}`,`xl:grid-cols-${D.xl??6}`]}),p=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await y()}),e.watch(()=>t.albumId,async()=>{await y()});async function y(){s.value=!0;try{const D=await i.fetchAlbumMedia(t.albumId);r.value=D}catch{r.value=[]}finally{s.value=!1}}function g(D){return t.selectedItems.includes(D)}function x(D){o("toggle-select",D);const I=g(D.uuid)?t.selectedItems.filter(j=>j!==D.uuid):[...t.selectedItems,D.uuid];o("selection-change",I)}function M(D){if(D.conversions&&typeof D.conversions=="object"){const I=D.conversions.thumb;if(typeof I=="string")return I}return D.original_url}function C(D){l.value=D}function b(){l.value=null}function f(D){o("preview",D)}function w(D){o("edit",D)}function F(D){o("detach",D.uuid)}function T(){o("add")}function E(D,I){t.reorderable&&(c.value=I,D.dataTransfer&&(D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("text/plain",String(I))))}function B(D,I){!t.reorderable||c.value===null||(D.preventDefault(),d.value=I)}function U(D,I){if(!t.reorderable||c.value===null)return;D.preventDefault();const j=c.value;if(j!==I){const $=[...r.value],[P]=$.splice(j,1);$.splice(I,0,P),r.value=$;const O=$.map(V=>V.uuid);o("reorder",O),i.reorderAlbumMedia(t.albumId,O).catch(()=>{y()})}c.value=null,d.value=null}function S(){c.value=null,d.value=null}return(D,I)=>(e.openBlock(),e.createElementBlock("div",jV,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(h.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,j=>(e.openBlock(),e.createBlock(e.unref(L.IonCard),{key:j,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",WV,[e.createVNode(e.unref(L.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",ZV,[e.createVNode(e.unref(L.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",XV,e.toDisplayString(D.emptyText),1),e.createVNode(e.unref(L.IonButton),{"data-testid":"add-media-btn",onClick:T},{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(h.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(j,$)=>(e.openBlock(),e.createElementBlock("div",{key:j.uuid,"data-media-id":j.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===$,"ring-2 ring-primary":d.value===$&&c.value!==$}]),draggable:D.reorderable,onDragstart:P=>E(P,$),onDragover:P=>B(P,$),onDrop:P=>U(P,$),onDragend:S,onMouseenter:P=>C(j.uuid),onMouseleave:b},[d.value===$&&c.value!==$&&D.reorderable?(e.openBlock(),e.createElementBlock("div",GV)):e.createCommentVNode("",!0),D.reorderable?(e.openBlock(),e.createElementBlock("div",JV,[e.createVNode(e.unref(L.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),D.selectionMode?(e.openBlock(),e.createBlock(e.unref(L.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(j.uuid),class:"absolute top-2 left-2 z-20",onIonChange:P=>x(j)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(L.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",YV,[e.createElementVNode("img",{src:M(j),alt:j.file_name,class:"w-full h-full object-cover"},null,8,qV),D.showActions&&l.value===j.uuid?(e.openBlock(),e.createElementBlock("div",KV,[e.createVNode(e.unref(L.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:P=>f(j)},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(L.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:P=>w(j)},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(L.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:P=>F(j)},{default:e.withCtx(()=>[e.createVNode(e.unref(L.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,HV))),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:T},[e.createVNode(e.unref(L.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))]))}}),e3=Ve(QV,[["__scopeId","data-v-d84b796a"]]),t3={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},n3={class:"media-album-inline-create__field"},o3={class:"media-album-inline-create__field"},a3={class:"media-album-inline-create__actions"},i3=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"}},emits:["cancel","create"],setup(a,{emit:n}){const t=n,o=e.ref(""),i=e.ref(""),r=()=>{o.value.trim()!==""&&(t("create",o.value.trim(),i.value.trim()!==""?i.value.trim():void 0),o.value="",i.value="")};return(s,l)=>s.open?(e.openBlock(),e.createElementBlock("section",t3,[e.createElementVNode("label",n3,[e.createElementVNode("span",null,e.toDisplayString(s.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[0]||(l[0]=c=>o.value=c),type:"text","data-testid":"input-media-album-name"},null,512),[[e.vModelText,o.value]])]),e.createElementVNode("label",o3,[l[3]||(l[3]=e.createElementVNode("span",null,"Parent album ID (optional)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=c=>i.value=c),type:"text","data-testid":"input-media-album-parent-id"},null,512),[[e.vModelText,i.value]])]),e.createElementVNode("div",a3,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:l[2]||(l[2]=c=>t("cancel"))}," Cancel "),e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button media-album-inline-create__button--primary","data-testid":"btn-media-album-create",onClick:r}," Create ")])])):e.createCommentVNode("",!0)}}),vd=Ve(i3,[["__scopeId","data-v-296bf150"]]),r3={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},s3=e.defineComponent({__name:"MediaAlbumUnavailableState",props:{title:{default:"Album unavailable"},body:{default:"You no longer have access to this album."},actionLabel:{default:"Go to library"}},emits:["goToLibrary"],setup(a,{emit:n}){const t=n;return(o,i)=>(e.openBlock(),e.createElementBlock("section",r3,[e.createElementVNode("h3",null,e.toDisplayString(o.title),1),e.createElementVNode("p",null,e.toDisplayString(o.body),1),e.createElementVNode("button",{type:"button",class:"media-album-unavailable-state__button",onClick:i[0]||(i[0]=r=>t("goToLibrary"))},e.toDisplayString(o.actionLabel),1)]))}}),gd=Ve(s3,[["__scopeId","data-v-04620e64"]]),l3={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},c3={class:"media-preview-sheet__header"},d3=["src","alt"],u3=["src"],m3={class:"media-preview-sheet__actions"},p3=["disabled"],f3=["disabled"],h3=e.defineComponent({__name:"MediaPreviewSheet",props:{open:{type:Boolean,default:!1},media:{default:null},canGoPrevious:{type:Boolean,default:!1},canGoNext:{type:Boolean,default:!1},selected:{type:Boolean,default:!1}},emits:["close","previous","next","toggleSelect"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>{var l;return((l=t.media)==null?void 0:l.mime_type.startsWith("image/"))===!0}),r=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:""),s=()=>{t.media&&o("toggleSelect",t.media)};return(l,c)=>l.open&&l.media?(e.openBlock(),e.createElementBlock("section",l3,[e.createElementVNode("header",c3,[e.createElementVNode("strong",null,e.toDisplayString(l.media.file_name),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__close","aria-label":"Close preview",onClick:c[0]||(c[0]=d=>o("close"))}," Close ")]),i.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:r.value,alt:l.media.file_name},null,8,d3)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,u3)),e.createElementVNode("div",m3,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>o("previous"))}," Previous ",8,p3),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select",onClick:s},e.toDisplayString(l.selected?"Deselect":"Select"),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoNext,onClick:c[2]||(c[2]=d=>o("next"))}," Next ",8,f3)])])):e.createCommentVNode("",!0)}}),yd=Ve(h3,[["__scopeId","data-v-9a05f74e"]]),v3={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},g3={class:"media-selection-tray__header"},y3={class:"media-selection-tray__title"},b3={class:"media-selection-tray__items"},w3={class:"media-selection-tray__item-copy"},k3=["aria-label","onClick"],x3=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(a,{emit:n}){const t=n;return(o,i)=>o.items.length>0?(e.openBlock(),e.createElementBlock("section",v3,[e.createElementVNode("header",g3,[e.createElementVNode("h3",y3,e.toDisplayString(o.selectedCountLabel),1)]),e.createElementVNode("div",b3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,r=>{var s,l;return e.openBlock(),e.createElementBlock("article",{key:r.id,class:"media-selection-tray__item"},[e.createElementVNode("div",w3,[e.createElementVNode("strong",null,e.toDisplayString(((s=r.media)==null?void 0:s.file_name)??r.id),1),e.createElementVNode("span",null,e.toDisplayString(r.status),1)]),e.createElementVNode("button",{type:"button",class:"media-selection-tray__remove","aria-label":`${o.dismissLabel} ${((l=r.media)==null?void 0:l.file_name)??r.id}`,onClick:c=>t("remove",r.id)},e.toDisplayString(o.dismissLabel),9,k3)])}),128))])])):e.createCommentVNode("",!0)}}),bd=Ve(x3,[["__scopeId","data-v-bb0cd35d"]]),E3={key:0,class:"media-source-sheet","data-testid":"media-source-sheet"},S3={class:"media-source-sheet__header"},V3=["data-testid","onClick"],_3=e.defineComponent({__name:"MediaSourceSheet",props:{open:{type:Boolean,default:!1},currentView:{},albums:{},viewLibraryLabel:{default:"Library"},browseAlbumsLabel:{default:"Albums"},createAlbumLabel:{default:"Create album"}},emits:["close","selectLibrary","selectAlbum","createAlbum"],setup(a,{emit:n}){const t=n;return(o,i)=>o.open?(e.openBlock(),e.createElementBlock("section",E3,[e.createElementVNode("header",S3,[e.createElementVNode("h3",null,e.toDisplayString(o.browseAlbumsLabel),1),e.createElementVNode("button",{type:"button",class:"media-source-sheet__close","aria-label":"Close source picker",onClick:i[0]||(i[0]=r=>t("close"))}," Close ")]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-source-sheet__action",{"is-active":o.currentView.scope==="library"}]),"data-testid":"btn-media-source-library",onClick:i[1]||(i[1]=r=>t("selectLibrary"))},e.toDisplayString(o.viewLibraryLabel),3),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.albums,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["media-source-sheet__action",{"is-active":o.currentView.scope==="album"&&o.currentView.albumId===r.id}]),"data-testid":`btn-media-source-album-${r.id}`,onClick:s=>t("selectAlbum",r)},e.toDisplayString(r.name),11,V3))),128)),e.createElementVNode("button",{type:"button",class:"media-source-sheet__create","data-testid":"btn-media-source-create-album",onClick:i[2]||(i[2]=r=>t("createAlbum"))},e.toDisplayString(o.createAlbumLabel),1)])):e.createCommentVNode("",!0)}}),wd=Ve(_3,[["__scopeId","data-v-909e8c9e"]]),C3={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},N3={class:"media-upload-sheet__header"},T3={class:"media-upload-sheet__picker"},M3=["accept"],B3={key:0,class:"media-upload-sheet__queue"},I3=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"}},emits:["close","filesSelected"],setup(a,{emit:n}){const t=n,o=i=>{const r=i.target;!(r instanceof HTMLInputElement)||r.files===null||(t("filesSelected",Array.from(r.files)),r.value="")};return(i,r)=>i.open?(e.openBlock(),e.createElementBlock("section",C3,[e.createElementVNode("header",N3,[e.createElementVNode("h3",null,e.toDisplayString(i.uploadLabel),1),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close","aria-label":"Close upload panel",onClick:r[0]||(r[0]=s=>t("close"))}," Close ")]),e.createElementVNode("label",T3,[r[1]||(r[1]=e.createElementVNode("span",null,"Choose files",-1)),e.createElementVNode("input",{type:"file",accept:i.accept,multiple:"","data-testid":"input-media-upload-sheet",onChange:o},null,40,M3)]),i.queue.length>0?(e.openBlock(),e.createElementBlock("ul",B3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.queue,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("strong",null,e.toDisplayString(s.file.name),1),e.createElementVNode("span",null,e.toDisplayString(s.status)+" · "+e.toDisplayString(s.progress)+"%",1)]))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),kd=Ve(I3,[["__scopeId","data-v-45405727"]]),F3=["aria-label","aria-pressed","data-testid"],$3=["src","alt"],R3={key:1,class:"media-thumbnail-cell__video"},D3={class:"media-thumbnail-cell__video-name"},A3={key:2,class:"media-thumbnail-cell__selected-badge"},L3={key:3,class:"media-thumbnail-cell__status-badge"},U3=["aria-label"],O3=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.media.thumbnail_url??t.media.preview_url??t.media.original_url),r=e.computed(()=>t.media.mime_type.startsWith("image/")),s=e.computed(()=>{switch(t.status){case"missing":return"Unavailable";case"forbidden":return"Restricted";case"uploading":return"Uploading";case"failed":return"Failed";case"file_lost":return"Needs file";default:return null}}),l=e.computed(()=>{const u=t.media.file_name;return t.selected?`Deselect ${u}`:`Select ${u}`}),c=()=>{o("toggle",t.media)},d=()=>{o("preview",t.media)};return(u,m)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["media-thumbnail-cell",{"is-selected":u.selected,"has-status":s.value!==null}])},[e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__button","aria-label":l.value,"aria-pressed":u.selected?"true":"false","data-testid":u.testId,onClick:c},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,$3)):(e.openBlock(),e.createElementBlock("div",R3,[m[0]||(m[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",D3,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",A3," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",L3,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,F3),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,U3)],2))}}),xd=Ve(O3,[["__scopeId","data-v-edd4f0ad"]]),P3={class:"virtual-media-grid"},z3={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},j3={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},W3={key:2,class:"virtual-media-grid__items"},Z3=["disabled"],X3=e.defineComponent({__name:"VirtualMediaGrid",props:{items:{},selectedItems:{},loading:{type:Boolean,default:!1},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},emptyMessage:{default:"No media found."},testIdPrefix:{default:"media-grid-item"}},emits:["toggle","preview","loadMore"],setup(a,{emit:n}){const t=a,o=n;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",P3,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",z3," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",j3,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",W3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(xd,{key:l.uuid,media:l,selected:((c=i(l.uuid))==null?void 0:c.status)==="ready",status:(d=i(l.uuid))==null?void 0:d.status,"test-id":`${r.testIdPrefix}-${l.uuid}`,onToggle:s[0]||(s[0]=u=>o("toggle",u)),onPreview:s[1]||(s[1]=u=>o("preview",u))},null,8,["media","selected","status","test-id"])}),128))])),r.hasMore?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"virtual-media-grid__load-more",disabled:r.loadingMore,"data-testid":"btn-media-grid-load-more",onClick:s[2]||(s[2]=l=>o("loadMore"))},e.toDisplayString(r.loadingMore?"Loading…":"Load more"),9,Z3)):e.createCommentVNode("",!0)]))}}),Ed=Ve(X3,[["__scopeId","data-v-820b9a4f"]]);function Da(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 Sd(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function Gr(a){return a.type.startsWith("image/")}async function Vd(a){return Gr(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 _d(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Da(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Da(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=Sd(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(Gr(a)&&(n.maxDimensions||n.minDimensions)){const o=await Vd(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 Jr(a={}){const n=e.ref(a.rules||{});function t(c){n.value=c}async function o(c){return _d(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const m=await o(u);d.set(u,m)})),d}function r(c,d){return n.value.maxItems?d+c<=n.value.maxItems:!0}const s=e.computed(()=>{const c=[];return n.value.acceptedMimeTypes&&c.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&c.push(...n.value.acceptedExtensions),c.join(",")});function l(c){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:n,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function H3(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function G3(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function Yr(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d,postUpload:u}=a,m=e.ref(new Map),h=e.ref(new Set),p=o?{rules:o}:{},{validateFile:y}=Jr(p);async function g(){if(h.value.size>=t)return;const D=Array.from(m.value.entries()).find(([$,P])=>P.status==="pending"&&!h.value.has($));if(!D){Array.from(m.value.values()).every(P=>P.status==="completed"||P.status==="error")&&m.value.size>0&&(d==null||d());return}const[I,j]=D;await x(I,j)}async function x(D,I){h.value.add(D),I.status="uploading",I.abortController=new AbortController,m.value.set(D,{...I}),r==null||r(I);try{const j={onProgress:P=>{I.progress=P,m.value.set(D,{...I}),s==null||s(I)},signal:I.abortController.signal};i&&(j.collection=i);const $=await n.upload(I.file,j);u&&(I.status="attaching",m.value.set(D,{...I}),s==null||s(I),await u(I,$.media,n)),I.status="completed",I.progress=100,I.media=$.media,m.value.set(D,{...I}),l==null||l(I,$.media)}catch(j){j.name==="AbortError"?m.value.delete(D):(I.status="error",I.error=j.message,m.value.set(D,{...I}),c==null||c(I,j))}finally{h.value.delete(D),delete I.abortController,g()}}async function M(D){var $;const I=Array.from(D),j=[];for(const P of I){const O=await y(P),V=H3(),R=G3(P),G={id:V,file:P,progress:0,status:O.valid?"pending":"error"};!O.valid&&(($=O.errors[0])!=null&&$.message)&&(G.error=O.errors[0].message),R&&(G.previewUrl=R),m.value.set(V,G);const J={media:null,clientId:V,name:P.name,order:0,upload:G,errors:O.errors};j.push(J)}for(let P=0;P<t;P++)g();return j}function C(D){const I=m.value.get(D);I&&(I.abortController&&I.abortController.abort(),I.previewUrl&&URL.revokeObjectURL(I.previewUrl),m.value.delete(D),h.value.delete(D),g())}async function b(D){const I=m.value.get(D);!I||I.status!=="error"||(I.status="pending",I.progress=0,delete I.error,m.value.set(D,{...I}),g())}function f(){for(const[D,I]of m.value.entries())(I.status==="completed"||I.status==="error")&&(I.previewUrl&&URL.revokeObjectURL(I.previewUrl),m.value.delete(D))}function w(){for(const D of m.value.values())D.abortController&&D.abortController.abort(),D.previewUrl&&URL.revokeObjectURL(D.previewUrl);m.value.clear(),h.value.clear()}function F(D){return m.value.get(D)}const T=e.computed(()=>h.value.size>0),E=e.computed(()=>h.value.size),B=e.computed(()=>Array.from(m.value.values()).filter(D=>D.status==="pending").length),U=e.computed(()=>m.value.size===0?!0:Array.from(m.value.values()).every(D=>D.status==="completed"||D.status==="error")),S=e.computed(()=>Array.from(m.value.values()));return{uploads:m,isUploading:T,activeCount:E,pendingCount:B,isComplete:U,addFiles:M,cancelUpload:C,retryUpload:b,clearCompleted:f,clearAll:w,getUpload:F,uploadsArray:S}}function Bn(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function Bo(a){return typeof a=="string"?a:null}function Al(a){return typeof a=="number"?a:null}function J3(a){return typeof a=="boolean"?a:null}function Cd(a){return Bn(a)&&typeof a.uuid=="string"&&typeof a.file_name=="string"&&typeof a.mime_type=="string"&&typeof a.original_url=="string"&&typeof a.size=="number"&&typeof a.disk=="string"&&typeof a.created_at=="string"&&typeof a.updated_at=="string"}function Y3(a){return!Bn(a)||typeof a.id!="string"||typeof a.status!="string"?null:a.status==="ready"?Cd(a.media)?{id:a.id,status:"ready",media:a.media}:null:a.status==="missing"||a.status==="forbidden"?{id:a.id,status:a.status}:null}function q3(a){return Bn(a)?{next_cursor:Bo(a.next_cursor),previous_cursor:Bo(a.previous_cursor),has_more:J3(a.has_more)??!1,per_page:Al(a.per_page),count:Al(a.count)}:null}function Ll(a){const n=Bn(a)?a:{},t=Array.isArray(n.data)?n.data.filter(Cd):[],o=Bn(n.meta)?n.meta:{},i=q3(o.pagination),r=(i==null?void 0:i.next_cursor)??Bo(o.next_cursor)??Bo(o.cursor),s=(i==null?void 0:i.has_more)??o.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(Y3).filter(c=>c!==null):[];return{data:t,meta:{cursor:r,has_more:s,pagination:i??void 0},hydrated:l}}function Ul(a,n,t,o,i){const r={view:a.scope==="album"?{scope:"album",album_id:a.albumId}:{scope:"library"},per_page:t,sort:n.sort??"newest"};return n.query&&n.query.trim()!==""&&(r.query=n.query.trim()),n.kinds&&n.kinds.length>0&&(r.kinds=n.kinds),o!==null&&(r.cursor=o),i&&i.length>0&&(r.hydrate_ids=i),r}function Ol(a){const n=new Set,t=[];for(const o of a)n.has(o.uuid)||(n.add(o.uuid),t.push(o));return t}function K3(a){var t;if(!(a instanceof Error))return null;const n=(t=a.response)==null?void 0:t.status;return typeof n=="number"?n:null}function Q3(a){var n;return a instanceof Error?((n=a.response)==null?void 0:n.data)??null:null}function e_(a){if(!Bn(a))return[];const n=[];for(const t of Object.values(a)){if(typeof t=="string"&&t.trim()!==""){n.push(t.trim());continue}if(Array.isArray(t))for(const o of t){if(typeof o!="string")continue;const i=o.trim();i!==""&&n.push(i)}}return Array.from(new Set(n))}function t_(a){var r;const n=Q3(a),t=Bn(n)?n:null,o=((r=Bo(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=e_(t==null?void 0:t.errors);return o!==null&&i.length>0?o==="Validation failed"?i.join(" "):i.every(l=>o.includes(l))?o:`${o} ${i.join(" ")}`:o!==null?o:i.length>0?i.join(" "):a instanceof Error?a.message:"Failed to load media."}function Pl(a,n){const t=t_(n),o=K3(n);return{code:o===403?"permission_denied":a,message:t,retriable:o!==403,cause:n}}function Nd(a){const n=a.perPage??40,t=e.ref([]),o=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);let u=null,m=0;const h=async g=>{m+=1;const x=m;u==null||u.abort();const M=new AbortController;u=M,g?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const C=await a.httpClient.get("/v1/media/library",{params:Ul(a.view.value,a.filters.value,n,g?i.value:null),signal:M.signal});if(x!==m)return;const b=Ll(C);t.value=g?Ol([...t.value,...b.data]):b.data,o.value=b.hydrated,i.value=b.meta.cursor,r.value=b.meta.has_more}catch(C){if(M.signal.aborted||x!==m)return;const b=Pl(g?"load_more_failed":"query_failed",C);d.value=b,c.value=b.code==="permission_denied",g||(t.value=[],i.value=null,r.value=!1)}finally{x===m&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:o,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:c,error:d,loadInitial:async()=>{i.value=null,await h(!1)},loadMore:async()=>{!r.value||l.value||await h(!0)},refresh:async()=>{i.value=null,await h(!1)},hydrateSelection:async g=>{if(g.length===0)return o.value=[],[];try{const x=await a.httpClient.get("/v1/media/library",{params:Ul(a.view.value,a.filters.value,1,null,g)}),M=Ll(x);return o.value=M.hydrated,M.hydrated}catch(x){return d.value=Pl("hydration_failed",x),[]}},prepend:g=>{t.value=Ol([g,...t.value])}}}const n_="mediables.media-library.";function o_(a){return!a||a.key.trim()===""?null:`${n_}${a.key}`}function Ji(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function a_(a,n){const t=Date.parse(a);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function Td(a){const n=o_(a),t=(a==null?void 0:a.ttlMinutes)??30,o=`${(a==null?void 0:a.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(n===null)return null;const l=Ji();if(l===null)return null;const c=l.getItem(n);if(c===null)return null;let d;try{d=JSON.parse(c)}catch{return l.removeItem(n),null}if(typeof d!="object"||d===null||Array.isArray(d))return l.removeItem(n),null;const u=d;if(u.version!==1||typeof u.savedAt!="string"||a_(u.savedAt,t))return l.removeItem(n),null;const m={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(h=>typeof h=="string"&&h.trim()!==""):[]};return((a==null?void 0:a.restoreView)??!0)&&u.view&&(m.view=u.view),u.filters&&(m.filters=u.filters),m},save:l=>{if(n===null)return;const c=Ji();if(c===null)return;const d={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((a==null?void 0:a.restoreView)??!0)&&l.view&&(d.view=l.view),l.filters&&(d.filters=l.filters),c.setItem(n,JSON.stringify(d))},clear:()=>{if(n===null)return;const l=Ji();l==null||l.removeItem(n)},sessionId:o}}function Md(a){const n=e.ref(a);return{state:n,transition:o=>{n.value=o}}}function Bd(a){return{emitMetric:(t,o)=>{const i={name:t,timestamp:new Date().toISOString()};o!==void 0&&(i.payload=o),a==null||a(i)}}}function Wn(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function i_(a){const n=Wn(a)?a:{};return(Array.isArray(n.data)?n.data:Wn(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(a)?a:[]).map(o=>{if(!Wn(o)||typeof o.id!="string"||typeof o.name!="string")return null;const i={id:o.id,name:o.name};return typeof o.description=="string"&&o.description.trim()!==""&&(i.description=o.description),typeof o.media_count=="number"&&(i.mediaCount=o.media_count),i}).filter(o=>o!==null)}function r_(a){const n=Wn(a)?a:{},t=Wn(n.data)?n.data:Wn(a)?a:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const o={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(o.description=t.description),o}function s_(a){return a==="ready"||a==="uploading"||a==="failed"}function ua(a,n="ready"){return{id:a.uuid,media:a,status:n,countsTowardMax:s_(n)}}function l_(a,n){return a.scope==="library"?!0:n.type==="album"&&n.albumId===a.albumId}function c_(a,n){return a.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===a.albumId}function Yi(a){return{code:"configuration_error",message:a,retriable:!1}}function Id(a){var fe,ye,oe;const n=a.selectionMode??"multiple",t=a.maxSelection,o=a.uploadBehavior??"adapter",i=e.ref(a.initialView??{scope:"library"}),r=e.ref({sort:((fe=a.initialFilters)==null?void 0:fe.sort)??"newest",...(ye=a.initialFilters)!=null&&ye.query?{query:a.initialFilters.query}:{},...(oe=a.initialFilters)!=null&&oe.kinds?{kinds:a.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=Td(a.sessionPolicy),{emitMetric:m}=Bd(a.telemetry),h=Md("idle"),p=Nd({httpClient:a.deps.httpClient,view:i,filters:r}),y=e.computed(()=>l.value.map(_=>_.id)),g=e.computed(()=>{const _=c.value;return _===null?null:p.items.value[_]??null}),x=e.computed(()=>a.uploadTarget??{type:"library"}),M=Yr({adapter:a.deps.uploadAdapter??{name:"missing-upload-adapter",upload:async()=>{throw new Error("Upload adapter is not configured.")},attach:async()=>{},attachMany:async()=>{},detach:async()=>{},reorder:async()=>{},fetchModelMedia:async()=>[],getUrl:_=>_.original_url,getThumbnailUrl:_=>_.thumbnail_url??_.preview_url??_.original_url},postUpload:async(_,A,Q)=>{const ee=x.value;ee.type!=="album"||!ee.albumId||await Q.attach(A.uuid,{modelType:"album",modelId:ee.albumId})},onUploadComplete:(_,A)=>{const Q=x.value;l_(i.value,Q)&&p.prepend(A),a.autoSelectUploaded&&c_(i.value,Q)&&T(A),m("upload-complete",{mediaId:A.uuid,targetType:Q.type,targetAlbumId:Q.albumId})},onUploadError:(_,A)=>{d.value={code:"upload_failed",message:A.message,retriable:!0,cause:A}}}),C=e.computed(()=>M.isUploading.value),b=()=>{u.save({selectedIds:[...y.value],view:i.value,filters:r.value})},f=async _=>{const A=await p.hydrateSelection(_);l.value=A.map(Q=>Q.status==="ready"&&Q.media?ua(Q.media):{id:Q.id,media:null,status:Q.status,countsTowardMax:!1})},w=e.computed(()=>l.value.filter(_=>_.countsTowardMax).length),F=()=>n==="single"||t===void 0?!0:w.value<t,T=_=>{if(l.value.findIndex(Q=>Q.id===_.uuid)>=0){n==="multiple"?l.value=l.value.filter(Q=>Q.id!==_.uuid):l.value=[ua(_)],b();return}if(!F()){d.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}n==="single"?l.value=[ua(_)]:l.value=[...l.value,ua(_)],d.value=null,b()},E=async()=>{var A;h.transition("restoring");const _=u.restore();if(_===null){h.transition("ready");return}_.view&&(i.value=_.view),_.filters&&(r.value={sort:_.filters.sort??"newest",..._.filters.query?{query:_.filters.query}:{},..._.filters.kinds?{kinds:_.filters.kinds}:{}}),await p.loadInitial(),(((A=a.sessionPolicy)==null?void 0:A.restoreSelection)??!0)&&await f(_.selectedIds),h.transition("ready")};e.watch(()=>p.error.value,_=>{_!==null&&(d.value=_,h.transition("error"))});const B=async()=>{d.value=null,h.transition("idle"),await E(),p.items.value.length===0&&!p.loading.value&&!p.permissionDenied.value&&await p.loadInitial();const _=a.defaultSelectedIds??[];l.value.length===0&&_.length>0&&await f(_),h.transition("ready")},U=async(_,A="user")=>{const Q=i.value;i.value=_,A==="user"&&a.preserveSelectionOnViewChange===!1&&(l.value=[]),m("view-change",{from:Q.scope,to:_.scope,reason:A}),await p.loadInitial(),b()},S=async()=>{const _=await a.deps.httpClient.get("/v1/albums");s.value=i_(_)},D=async(_,A)=>{try{const Q={name:_,visibility:"private"};A&&A.trim()!==""&&(Q.parent_id=A);const ee=await a.deps.httpClient.post("/v1/albums",Q),ne=r_(ee);return ne===null?Yi("Album creation response was invalid."):(s.value=[ne,...s.value.filter(pe=>pe.id!==ne.id)],await U({scope:"album",albumId:ne.id,albumName:ne.name},"inline-album-created"),ne)}catch(Q){const ee={code:"album_create_failed",message:Q instanceof Error?Q.message:"Album creation failed.",retriable:!0,cause:Q};return d.value=ee,ee}},I=async _=>{if(!a.enableUpload){d.value=Yi("Uploads are not enabled for this picker.");return}if(o!=="delegate"){if(!a.deps.uploadAdapter){d.value=Yi("Uploads require a configured upload adapter.");return}await M.addFiles(_)}},j=()=>{var Q;const _=((Q=a.validateSelection)==null?void 0:Q.call(a,l.value))??null;if(_!==null){const ee={code:"selection_invalid",message:_,retriable:!0};return d.value=ee,ee}if(l.value.filter(ee=>ee.status==="ready"&&ee.media!==null).length===0){const ee={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ee,ee}return{orderedIds:y.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},$=_=>{const A=p.items.value.findIndex(Q=>Q.uuid===_.uuid);c.value=A>=0?A:null},P=()=>{c.value=null},O=()=>{c.value===null||c.value<=0||(c.value-=1)},V=()=>{c.value===null||c.value>=p.items.value.length-1||(c.value+=1)},R=_=>{l.value=l.value.filter(A=>A.id!==_),b()},G=async()=>{await p.refresh()},J=async _=>{r.value={...r.value,..._&&_.trim()!==""?{query:_.trim()}:{}},(!_||_.trim()==="")&&delete r.value.query,await p.loadInitial(),b()},te=async()=>{await U({scope:"library"},"permission-unavailable")};return{view:i,filters:r,albums:s,selectedItems:l,orderedIds:y,queryItems:p.items,cursor:p.cursor,hasMore:p.hasMore,loading:p.loading,loadingMore:p.loadingMore,permissionDenied:p.permissionDenied,error:d,uploadQueue:M.uploadsArray,isUploading:C,previewIndex:c,previewItem:g,initialize:B,refresh:G,loadMore:p.loadMore,setQuery:J,setView:U,toggleSelection:T,removeSelected:R,confirmSelection:j,openPreview:$,closePreview:P,showPreviousPreview:O,showNextPreview:V,loadAlbums:S,createAlbum:D,addUploadFiles:I,goToLibrary:te,sessionId:u.sessionId}}const d_=["data-testid"],u_={class:"media-library-picker__header"},m_={class:"media-library-picker__title"},p_={class:"media-library-picker__subtitle"},f_={class:"media-library-picker__header-actions"},h_=["placeholder"],v_={key:0,class:"media-library-picker__error","data-testid":"media-picker-error"},g_={class:"media-library-picker__footer"},y_=e.defineComponent({__name:"MediaLibraryPicker",props:{deps:{},modelValue:{default:()=>[]},defaultSelectedIds:{default:()=>[]},selectionMode:{default:"multiple"},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean,default:!0},initialView:{default:()=>({scope:"library"})},initialFilters:{default:()=>({sort:"newest"})},enableUpload:{type:Boolean,default:!1},uploadBehavior:{default:"adapter"},enablePreview:{type:Boolean,default:!0},enableAlbumCreation:{type:Boolean,default:!1},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean,default:!1},createAlbumDefaultVisibility:{default:"private"},sessionPolicy:{},labels:{default:()=>({})},testIdPrefix:{default:"media-picker"},telemetry:{}},emits:["update:modelValue","confirm","cancel","selection-change","view-change","error","metric","request-upload-files"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>{var U,S,D,I,j,$,P,O,V,R,G,J,te,fe,ye,oe,_,A;return{title:((U=t.labels)==null?void 0:U.title)??"Media library",searchPlaceholder:((S=t.labels)==null?void 0:S.searchPlaceholder)??"Search your media",viewLibrary:((D=t.labels)==null?void 0:D.viewLibrary)??"Library",browseAlbums:((I=t.labels)==null?void 0:I.browseAlbums)??"Albums",createAlbum:((j=t.labels)==null?void 0:j.createAlbum)??"Create album",createAlbumNameLabel:(($=t.labels)==null?void 0:$.createAlbumNameLabel)??"Album name",emptyLibrary:((P=t.labels)==null?void 0:P.emptyLibrary)??"No media found in your library.",emptyAlbum:((O=t.labels)==null?void 0:O.emptyAlbum)??"No media found in this album.",networkError:((V=t.labels)==null?void 0:V.networkError)??"Unable to load media right now.",retry:((R=t.labels)==null?void 0:R.retry)??"Retry",selectedCount:((G=t.labels)==null?void 0:G.selectedCount)??(Q=>`${Q} selected`),confirmAction:((J=t.labels)==null?void 0:J.confirmAction)??"Attach selected",cancel:((te=t.labels)==null?void 0:te.cancel)??"Cancel",dismiss:((fe=t.labels)==null?void 0:fe.dismiss)??"Remove",uploadLabel:((ye=t.labels)==null?void 0:ye.uploadLabel)??"Upload",albumUnavailableTitle:((oe=t.labels)==null?void 0:oe.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((_=t.labels)==null?void 0:_.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((A=t.labels)==null?void 0:A.goToLibrary)??"Go to library"}}),r={deps:t.deps,selectionMode:t.selectionMode,initialView:t.initialView,initialFilters:t.initialFilters,...t.maxSelection!==void 0?{maxSelection:t.maxSelection}:{},...t.modelValue.length>0||t.defaultSelectedIds.length>0?{defaultSelectedIds:t.modelValue.length>0?t.modelValue:t.defaultSelectedIds}:{},...t.sessionPolicy?{sessionPolicy:t.sessionPolicy}:{},...t.enableUpload?{enableUpload:!0}:{},uploadBehavior:t.uploadBehavior,...t.uploadTarget?{uploadTarget:t.uploadTarget}:{},...t.autoSelectUploaded?{autoSelectUploaded:!0}:{},...t.validateSelection?{validateSelection:t.validateSelection}:{},preserveSelectionOnViewChange:t.preserveSelectionOnViewChange,telemetry:U=>{var S;(S=t.telemetry)==null||S.call(t,U),o("metric",U)}},s=Id(r),l=e.ref(t.initialFilters.query??""),c=e.ref(!1),d=e.ref(!1),u=e.ref(!1),m=JSON.stringify(t.modelValue.length>0?t.modelValue:t.defaultSelectedIds);let h=null;const p=e.computed(()=>JSON.stringify(s.orderedIds.value)!==m),y=e.computed(()=>s.view.value.scope==="album"?i.value.emptyAlbum:i.value.emptyLibrary),g=e.computed(()=>i.value.selectedCount(s.selectedItems.value.length)),x=()=>{h!==null&&(window.clearTimeout(h),h=null)},M=()=>{o("update:modelValue",[...s.orderedIds.value]),o("selection-change",{orderedIds:[...s.orderedIds.value],items:[...s.selectedItems.value],dirty:p.value})},C=U=>{U!==null&&o("error",U)},b=U=>typeof U.code=="string",f=U=>typeof U=="object"&&U!==null&&"code"in U&&typeof U.code=="string",w=()=>{const U=s.confirmSelection();if(b(U)){C(U);return}o("confirm",{...U,dirty:p.value})},F=(U="user")=>{o("cancel",{dirty:p.value,reason:U,sessionId:s.sessionId})},T=async()=>{c.value=!c.value,c.value&&await s.loadAlbums()},E=async(U,S)=>{const D=s.view.value,I=await s.createAlbum(U,S);if(f(I)){C(I);return}u.value=!1,c.value=!1,o("view-change",{from:D,to:{scope:"album",albumId:I.id,albumName:I.name},reason:"inline-album-created",restoredFromSession:!1})},B=async U=>{if(t.uploadBehavior==="delegate"){o("request-upload-files",{files:[...U],view:s.view.value,filters:s.filters.value,sessionId:s.sessionId}),d.value=!1;return}await s.addUploadFiles(U),d.value=!1};return e.watch(()=>l.value,U=>{x(),h=window.setTimeout(()=>{s.setQuery(U)},250)}),e.watch(()=>s.selectedItems.value,()=>{M()},{deep:!0}),e.watch(()=>s.error.value,U=>{C(U)}),e.onMounted(()=>{s.initialize()}),e.onBeforeUnmount(()=>{x()}),(U,S)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":U.testIdPrefix},[e.createElementVNode("header",u_,[e.createElementVNode("div",null,[e.createElementVNode("h2",m_,e.toDisplayString(i.value.title),1),e.createElementVNode("p",p_,e.toDisplayString(e.unref(s).view.value.scope==="album"?e.unref(s).view.value.albumName??"Album view":i.value.viewLibrary),1)]),e.createElementVNode("div",f_,[e.createElementVNode("button",{type:"button",class:"media-library-picker__header-button","data-testid":"btn-media-picker-source-sheet",onClick:T},e.toDisplayString(i.value.browseAlbums),1),U.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-library-picker__header-button","data-testid":"btn-media-picker-upload-sheet",onClick:S[0]||(S[0]=D=>d.value=!d.value)},e.toDisplayString(i.value.uploadLabel),1)):e.createCommentVNode("",!0),U.enableAlbumCreation?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-library-picker__header-button","data-testid":"btn-media-picker-create-album",onClick:S[1]||(S[1]=D=>u.value=!u.value)},e.toDisplayString(i.value.createAlbum),1)):e.createCommentVNode("",!0)])]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":S[2]||(S[2]=D=>l.value=D),class:"media-library-picker__search",type:"search",placeholder:i.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,h_),[[e.vModelText,l.value]]),e.createVNode(wd,{open:c.value,"current-view":e.unref(s).view.value,albums:e.unref(s).albums.value,"view-library-label":i.value.viewLibrary,"browse-albums-label":i.value.browseAlbums,"create-album-label":i.value.createAlbum,onClose:S[3]||(S[3]=D=>c.value=!1),onSelectLibrary:S[4]||(S[4]=D=>{e.unref(s).goToLibrary(),c.value=!1}),onSelectAlbum:S[5]||(S[5]=D=>{e.unref(s).setView({scope:"album",albumId:D.id,albumName:D.name}),c.value=!1}),onCreateAlbum:S[6]||(S[6]=D=>u.value=!0)},null,8,["open","current-view","albums","view-library-label","browse-albums-label","create-album-label"]),e.createVNode(vd,{open:u.value,"name-label":i.value.createAlbumNameLabel,onCancel:S[7]||(S[7]=D=>u.value=!1),onCreate:E},null,8,["open","name-label"]),U.enableUpload?(e.openBlock(),e.createBlock(kd,{key:0,open:d.value,queue:e.unref(s).uploadQueue.value,accept:U.accept,"upload-label":i.value.uploadLabel,onClose:S[8]||(S[8]=D=>d.value=!1),onFilesSelected:B},null,8,["open","queue","accept","upload-label"])):e.createCommentVNode("",!0),e.unref(s).permissionDenied.value&&e.unref(s).view.value.scope==="album"?(e.openBlock(),e.createBlock(gd,{key:1,title:i.value.albumUnavailableTitle,body:i.value.albumUnavailableBody,"action-label":i.value.goToLibrary,onGoToLibrary:e.unref(s).goToLibrary},null,8,["title","body","action-label","onGoToLibrary"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.unref(s).error.value?(e.openBlock(),e.createElementBlock("div",v_,[e.createElementVNode("p",null,e.toDisplayString(e.unref(s).error.value.message||i.value.networkError),1),e.createElementVNode("button",{type:"button",class:"media-library-picker__retry",onClick:S[9]||(S[9]=(...D)=>e.unref(s).refresh&&e.unref(s).refresh(...D))},e.toDisplayString(i.value.retry),1)])):e.createCommentVNode("",!0),e.createVNode(Ed,{items:e.unref(s).queryItems.value,"selected-items":e.unref(s).selectedItems.value,loading:e.unref(s).loading.value,"loading-more":e.unref(s).loadingMore.value,"has-more":e.unref(s).hasMore.value,"empty-message":y.value,"test-id-prefix":`${U.testIdPrefix}-item`,onToggle:e.unref(s).toggleSelection,onPreview:e.unref(s).openPreview,onLoadMore:e.unref(s).loadMore},null,8,["items","selected-items","loading","loading-more","has-more","empty-message","test-id-prefix","onToggle","onPreview","onLoadMore"])],64)),e.createVNode(bd,{items:e.unref(s).selectedItems.value,"selected-count-label":g.value,"dismiss-label":i.value.dismiss,onRemove:e.unref(s).removeSelected},null,8,["items","selected-count-label","dismiss-label","onRemove"]),e.createElementVNode("footer",g_,[e.createElementVNode("button",{type:"button",class:"media-library-picker__footer-button","data-testid":"btn-media-picker-cancel",onClick:S[10]||(S[10]=D=>F())},e.toDisplayString(i.value.cancel),1),e.createElementVNode("button",{type:"button",class:"media-library-picker__footer-button media-library-picker__footer-button--primary","data-testid":"btn-media-picker-confirm",onClick:w},e.toDisplayString(i.value.confirmAction),1)]),U.enablePreview?(e.openBlock(),e.createBlock(yd,{key:3,open:e.unref(s).previewItem.value!==null,media:e.unref(s).previewItem.value,"can-go-previous":e.unref(s).previewIndex.value!==null&&e.unref(s).previewIndex.value>0,"can-go-next":e.unref(s).previewIndex.value!==null&&e.unref(s).previewIndex.value<e.unref(s).queryItems.value.length-1,selected:e.unref(s).previewItem.value!==null&&e.unref(s).orderedIds.value.includes(e.unref(s).previewItem.value.uuid),onClose:e.unref(s).closePreview,onPrevious:e.unref(s).showPreviousPreview,onNext:e.unref(s).showNextPreview,onToggleSelect:e.unref(s).toggleSelection},null,8,["open","media","can-go-previous","can-go-next","selected","onClose","onPrevious","onNext","onToggleSelect"])):e.createCommentVNode("",!0)],8,d_))}}),Fd=Ve(y_,[["__scopeId","data-v-bc7da441"]]),b_={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},w_={class:"media-library-picker-modal__panel"},k_=e.defineComponent({__name:"MediaLibraryPickerModal",props:{deps:{},modelValue:{},defaultSelectedIds:{},selectionMode:{},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean},initialView:{},initialFilters:{},enableUpload:{type:Boolean},uploadBehavior:{},enablePreview:{type:Boolean},enableAlbumCreation:{type:Boolean},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean},createAlbumDefaultVisibility:{},sessionPolicy:{},labels:{},testIdPrefix:{},telemetry:{},isOpen:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0}},emits:["update:modelValue","confirm","cancel","close"],setup(a,{emit:n}){const t=a,o=n,i=()=>{t.closeOnBackdrop&&o("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",b_,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",w_,[e.createVNode(Fd,e.mergeProps(t,{"onUpdate:modelValue":s[0]||(s[0]=l=>o("update:modelValue",l)),onConfirm:s[1]||(s[1]=l=>o("confirm",l)),onCancel:s[2]||(s[2]=l=>o("cancel",l))}),null,16)])])):e.createCommentVNode("",!0)}}),x_=Ve(k_,[["__scopeId","data-v-a92e8703"]]);function qr(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),l=e.ref(null),c=e.computed(()=>l.value!==null),d=M=>{if(r.value++,l.value=null,i.value=null,t.value=!1,M!=null&&typeof M=="object"&&!(M instanceof Blob)&&("image"in M||"state"in M||"sessionKey"in M)){const C=M;o.value=C.image??null,s.value=C.state??null}else o.value=M??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},m=async M=>{try{return t.value=!0,i.value=M,a.onSave&&await a.onSave(M),u(),M}catch(C){const b=C;throw l.value=b,a.onError&&a.onError(b),b}finally{t.value=!1}},h=()=>{a.onCancel&&a.onCancel(),u()},p=M=>{l.value=M,a.onError&&a.onError(M)},y=()=>{l.value=null},g=()=>i.value,x=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:x,open:d,close:u,handleSave:m,handleCancel:h,handleError:p,clearError:y,getEditedImage:g}}let qi=null;function E_(a){return qi||(qi=qr(a)),qi}function S_(a){return n=>new Promise((t,o)=>{qr({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function Kr(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 xr(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 Qr(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),Zn(t)}return{name:"mediables",async upload(t,o){const r=await _t().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 _t().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await _t().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await _t().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await _t().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await _t().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return _t().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 _t().deleteMedia(t)},async update(t,o){const r=await _t().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),Zn(o)}}}let Ea=null;function V_(){return Ea||(Ea=Qr()),Ea}function __(){Ea=null}const C_={apiBaseUrl:"/media-library-pro"};function ma(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function Ki(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 es(a){const n={...C_,...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},l=n.csrfToken||ma();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(c.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,c);if(!d.ok){const h=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(h.message||`HTTP ${d.status}`)}const u=await d.json(),m=Ki(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||ma();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 l=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(Ki)}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||ma();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||ma();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const d=await l.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${l.status}`)}const c=await l.json();return Ki(c)},configure(o){Object.assign(n,o)}}}let Sa=null;function N_(){return Sa||(Sa=es()),Sa}function T_(){Sa=null}function $d(a,n){switch(a){case"mediables":return Qr(n);case"spatie":return es(n);default:throw new Error(`Unknown adapter: ${a}`)}}function Rd(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(C,b,f){n&&("dataTransfer"in C&&C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",String(f))),d=C.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:b},c.value=!0,o==null||o(b,f))}function m(C,b){var f;if(!(!n||!l.value.isDragging)&&(C.preventDefault(),l.value.dropIndex!==b)){const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s);const F=(f=C.target)==null?void 0:f.closest("[data-index]");F==null||F.classList.add(s),l.value.dropIndex=b}}function h(){if(!l.value.isDragging)return;const{dragIndex:C,dropIndex:b,draggedItem:f}=l.value;d&&d.classList.remove(r);const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s),C!==null&&b!==null&&C!==b&&f&&(t==null||t({fromIndex:C,toIndex:b,item:f})),y(),i==null||i()}function p(){d&&d.classList.remove(r);const C=document.querySelector(`.${s}`);C==null||C.classList.remove(s),y(),i==null||i()}function y(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function g(C,b,f){const w=[...C],[F]=w.splice(b,1);return w.splice(f,0,F),w.map((T,E)=>({...T,order:E}))}function x(C,b){return{draggable:n,"data-index":b,onDragstart:f=>u(f,C,b),onDragover:f=>m(f,b),onDragend:()=>h(),onDrop:f=>{f.preventDefault(),h()}}}function M(C){C.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onUnmounted(()=>{document.removeEventListener("keydown",M),p()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:m,endDrag:h,cancelDrag:p,reorderItems:g,getDragProps:x}}function li(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:h,maxConcurrentUploads:p=3,onChange:y,onUpload:g,onUploadComplete:x,onUploadError:M,onRemove:C,onReorder:b,onError:f,onReadyToSubmitChange:w}=a,F={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},T=h||$d(m),E=e.ref([]),B=e.ref(!1),U=e.ref([]);function S(ae){if(ae.length===0)return[];const le=ae[0];return"media"in le&&"clientId"in le?ae:xr(ae)}E.value=S(n);const{acceptString:D,canAddFiles:I}=Jr({rules:F}),j=Yr({adapter:T,maxConcurrent:p,rules:F,collection:i,onUploadStart:ae=>{g==null||g(ae)},onUploadComplete:(ae,le)=>{const ke=E.value.findIndex(_e=>_e.clientId===ae.id);ke!==-1&&(E.value[ke]={...E.value[ke],media:le,name:le.name||le.file_name,upload:{...ae,status:"completed"}}),x==null||x(le)},onUploadError:(ae,le)=>{const ke=E.value.findIndex(_e=>_e.clientId===ae.id);ke!==-1&&(E.value[ke]={...E.value[ke],upload:{...ae,status:"error",error:le.message},errors:[{field:"upload",message:le.message,code:"UPLOAD_ERROR"}]}),M==null||M({file:ae.file,message:le.message})},onQueueComplete:()=>{y==null||y(E.value)}}),{dragState:$,getDragProps:P,reorderItems:O}=Rd({enabled:c&&!d,onReorder:ae=>{E.value=O(E.value,ae.fromIndex,ae.toIndex),b==null||b(E.value),y==null||y(E.value)}}),V=e.computed(()=>j.isUploading.value),R=e.computed(()=>!j.isUploading.value&&j.pendingCount.value===0),G=e.computed(()=>r?E.value.length>=r:!1),J=e.computed(()=>Kr(E.value)),te=e.computed(()=>E.value.length),fe=e.computed(()=>r?Math.max(0,r-E.value.length):1/0);e.watch(R,ae=>{w==null||w(ae)});function ye(ae){E.value=S(ae),y==null||y(E.value)}async function oe(ae){if(d)return;const le=Array.from(ae);if(!I(le.length,E.value.length)){const Ze={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};U.value=[Ze],f==null||f([Ze]);return}const ke=await j.addFiles(le),_e=E.value.length,ut=ke.map((Ze,St)=>({...Ze,order:_e+St}));E.value=[...E.value,...ut],y==null||y(E.value)}function _(ae){d||(ae.upload&&(ae.upload.status==="uploading"||ae.upload.status==="pending")&&j.cancelUpload(ae.clientId),E.value=E.value.filter(le=>le.clientId!==ae.clientId),E.value=E.value.map((le,ke)=>({...le,order:ke})),C==null||C(ae),y==null||y(E.value))}function A(ae){const le=E.value.find(ke=>ke.clientId===ae);le&&_(le)}function Q(){d||(j.clearAll(),E.value=[],y==null||y(E.value))}function ee(ae,le){d||!c||(E.value=O(E.value,ae,le),b==null||b(E.value),y==null||y(E.value))}function ne(ae,le){if(d)return;const ke=E.value.findIndex(_e=>_e.clientId===ae);ke!==-1&&(E.value[ke]={...E.value[ke],...le},y==null||y(E.value))}function pe(ae){j.cancelUpload(ae),A(ae)}async function ie(ae){await j.retryUpload(ae)}async function me(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const ae={modelType:t,modelId:o,collection:i},le=E.value.filter(ke=>ke.media&&!ke.markedForRemoval).map(ke=>ke.media.uuid);B.value=!0;try{await T.attachMany(le,ae),await T.reorder(ae,le)}finally{B.value=!1}}async function we(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const ae={modelType:t,modelId:o,collection:i};B.value=!0;try{const le=await T.fetchModelMedia(ae);E.value=xr(le),y==null||y(E.value)}finally{B.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&we().catch(console.error)}),e.onUnmounted(()=>{j.clearAll()}),{items:E,setItems:ye,addFiles:oe,removeItem:_,removeItemById:A,clearAll:Q,reorderItems:ee,updateItem:ne,cancelUpload:pe,retryUpload:ie,save:me,load:we,isLoading:B,isUploading:V,isReadyToSubmit:R,isAtMaxItems:G,errors:U,dragState:$,getDragProps:P,adapter:T,formValues:J,acceptString:D,count:te,remainingSlots:fe}}const M_=["aria-disabled"],B_=["accept","multiple","disabled"],I_={class:"media-dropzone__content"},F_={class:"media-dropzone__title"},$_={class:"media-dropzone__subtitle"},R_=["disabled"],D_={key:0,class:"media-dropzone__helper"},A_=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})),l=e.computed(()=>{const g=[];return t.maxFileSize&&g.push(`Max size: ${Da(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function c(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function m(g){var M;if(g.preventDefault(),i.value=!1,t.disabled)return;const x=(M=g.dataTransfer)==null?void 0:M.files;x&&x.length>0&&o("files",x)}function h(){var g;t.disabled||(g=r.value)==null||g.click()}function p(g){const x=g.target,M=x.files;M&&M.length>0&&o("files",M),x.value=""}function y(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),h())}return(g,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":g.disabled,"aria-label":"Upload files",onClick:h,onKeydown:y,onDragenter:c,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:p},null,40,B_),e.createElementVNode("div",I_,[e.renderSlot(g.$slots,"icon",{},()=>[x[0]||(x[0]=e.createElementVNode("svg",{class:"media-dropzone__icon",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1))],!0),e.createElementVNode("p",F_,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",$_,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(h,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,R_),l.value?(e.openBlock(),e.createElementBlock("p",D_,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,M_))}}),ts=Ve(A_,[["__scopeId","data-v-b1366c1e"]]),L_=["data-index"],U_={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},O_={class:"media-item__thumbnail"},P_=["src","alt"],z_={key:1,class:"media-item__file-icon"},j_={key:2,class:"media-item__progress-overlay"},W_={class:"media-item__progress-text"},Z_={key:3,class:"media-item__processing-overlay"},X_={key:4,class:"media-item__error-overlay"},H_={class:"media-item__info"},G_=["title"],J_={key:0,class:"media-item__size"},Y_={key:1,class:"media-item__error-message"},q_={class:"media-item__actions"},K_=["disabled"],Q_=["disabled"],eC=["disabled"],tC=["disabled"],nC=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 b;return(b=t.item.upload)!=null&&b.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var b,f,w;return((b=t.item.upload)==null?void 0:b.status)==="uploading"||((f=t.item.upload)==null?void 0:f.status)==="pending"||((w=t.item.upload)==null?void 0:w.status)==="queued"}),l=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="processing"}),c=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var b;return(b=t.item.upload)!=null&&b.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.progress)||0}),m=e.computed(()=>{var b;return t.item.name||((b=t.item.media)==null?void 0:b.file_name)||"Unknown file"}),h=e.computed(()=>{var T,E;const b=((T=t.item.media)==null?void 0:T.size)||((E=t.item.upload)==null?void 0:E.file.size);if(!b)return"";const f=1024,w=["Bytes","KB","MB","GB"],F=Math.floor(Math.log(b)/Math.log(f));return parseFloat((b/Math.pow(f,F)).toFixed(2))+" "+w[F]}),p=e.computed(()=>{var f,w;const b=((f=t.item.media)==null?void 0:f.mime_type)||((w=t.item.upload)==null?void 0:w.file.type);return b==null?void 0:b.startsWith("image/")}),y=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.value,"media-item--error":c.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function g(){t.disabled||o("remove",t.item)}function x(){t.disabled||o("edit",t.item)}function M(){t.disabled||o("retry",t.item)}function C(){t.disabled||o("cancel",t.item)}return(b,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(y.value),"data-index":b.index,onMouseenter:f[0]||(f[0]=w=>i.value=!0),onMouseleave:f[1]||(f[1]=w=>i.value=!1)},[b.sortable&&!b.disabled?(e.openBlock(),e.createElementBlock("div",U_,[...f[2]||(f[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",O_,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,P_)):(e.openBlock(),e.createElementBlock("div",z_,[...f[3]||(f[3]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),s.value?(e.openBlock(),e.createElementBlock("div",j_,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",W_,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",Z_,[...f[4]||(f[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",X_,[...f[5]||(f[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",H_,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,G_),h.value?(e.openBlock(),e.createElementBlock("span",J_,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",Y_,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",q_,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:b.disabled,"aria-label":"Cancel upload",onClick:C},[...f[6]||(f[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,K_)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:b.disabled,"aria-label":"Retry upload",onClick:M},[...f[7]||(f[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,Q_)):e.createCommentVNode("",!0),b.showEdit&&b.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:b.disabled,"aria-label":"Edit",onClick:x},[...f[8]||(f[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,eC)):e.createCommentVNode("",!0),b.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:b.disabled,"aria-label":"Remove",onClick:g},[...f[9]||(f[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,tC)):e.createCommentVNode("",!0)])],42,L_))}}),ns=Ve(nC,[["__scopeId","data-v-ff81c9ec"]]),oC=["aria-label"],aC=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],iC={key:0,class:"media-collection__footer"},rC={class:"media-collection__count"},sC={key:0},lC={key:0,class:"media-collection__uploading"},cC=["name","value"],dC=["name","value"],uC=["name","value"],mC=["name","value"],pC={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},fC=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:V=>{o("update:modelValue",V),o("change",V)},onUpload:V=>{o("upload",V)},onUploadComplete:V=>{o("upload-complete",V)},onUploadError:V=>{o("upload-error",V)},onRemove:V=>{o("remove",V)},onReorder:V=>{o("reorder",V)},onError:V=>{o("validation-error",V)},onReadyToSubmitChange:V=>{o("is-ready-to-submit-change",V)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:h,isUploading:p,isAtMaxItems:y,errors:g,dragState:x,getDragProps:M,adapter:C,formValues:b,acceptString:f,count:w,remainingSlots:F}=li(i);e.provide("mediaAdapter",C),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,V=>{V!==r.value&&s(V)},{deep:!0});const T=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!y.value),E=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":h.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":x.value.isDragging}));function B(V){l(V)}function U(V){c(V)}function S(V){m(V.clientId)}function D(V){u(V.clientId)}function I(V){}function j(V,R,G){if(!t.sortable||t.disabled)return;const J=M(R,G);J.onDragstart&&J.onDragstart(V)}function $(V,R){if(!t.sortable||t.disabled)return;V.preventDefault();const G=r.value[R],J=M(G,R);J.onDragover&&J.onDragover(V)}function P(V,R){const G=M(V,R);G.onDragend&&G.onDragend()}function O(V,R){V.preventDefault();const G=r.value[R],J=M(G,R);J.onDrop&&J.onDrop(V)}return(V,R)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(E.value)},[e.renderSlot(V.$slots,"dropzone",{addFiles:e.unref(l)},()=>[T.value?(e.openBlock(),e.createBlock(ts,{key:0,accept:e.unref(f),multiple:V.maxItems!==1,disabled:V.disabled,"max-file-size":V.maxFileSize,"max-items":e.unref(F),onFiles:B},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(w)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(G,J)=>e.renderSlot(V.$slots,"item",{key:G.clientId,item:G,index:J,remove:()=>U(G)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(x).dropIndex===J}]),draggable:V.sortable&&!V.disabled,"data-index":J,onDragstart:te=>j(te,G,J),onDragover:te=>$(te,J),onDragend:te=>P(G,J),onDrop:te=>O(te,J)},[e.createVNode(ns,{item:G,adapter:e.unref(C),disabled:V.disabled,sortable:V.sortable,"show-remove":!V.readonly,"show-edit":!1,index:J,onRemove:U,onRetry:S,onCancel:D,onEdit:I},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,aC)],!0)),128))],8,oC)):T.value?e.createCommentVNode("",!0):e.renderSlot(V.$slots,"empty",{key:1},()=>[R[0]||(R[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(V.$slots,"footer",{count:e.unref(w),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",iC,[e.createElementVNode("span",rC,[e.createTextVNode(e.toDisplayString(e.unref(w))+" "+e.toDisplayString(e.unref(w)===1?"file":"files")+" ",1),V.maxItems?(e.openBlock(),e.createElementBlock("span",sC," / "+e.toDisplayString(V.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",lC," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),V.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(G,J)=>(e.openBlock(),e.createElementBlock("input",{key:`${V.name}-${G.uuid}`,type:"hidden",name:`${V.name}[${J}][uuid]`,value:G.uuid},null,8,cC))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(G,J)=>(e.openBlock(),e.createElementBlock("input",{key:`${V.name}-${G.uuid}-name`,type:"hidden",name:`${V.name}[${J}][name]`,value:G.name},null,8,dC))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(G,J)=>(e.openBlock(),e.createElementBlock("input",{key:`${V.name}-${G.uuid}-order`,type:"hidden",name:`${V.name}[${J}][order]`,value:G.order},null,8,uC))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(G,J)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${V.name}-${G.uuid}-props`},[G.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${V.name}[${J}][custom_properties]`,value:JSON.stringify(G.custom_properties)},null,8,mC)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",pC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),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))}}),hC=Ve(fC,[["__scopeId","data-v-10a5bfff"]]);function os(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=a,h={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:T=>{t==null||t(T[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},p=li(h),y=e.computed(()=>p.items.value[0]||null),g=e.computed(()=>y.value!==null),x=e.computed(()=>p.formValues.value[0]||null);function M(T){T===null?p.clearAll():p.setItems([T])}async function C(T){const E=y.value;E&&p.removeItem(E),await p.addFiles([T])}function b(){y.value&&p.removeItem(y.value)}async function f(T){const E=y.value;E&&p.removeItem(E),await p.addFiles([T]);const B=p.items.value[0];B&&(o==null||o(E,B))}function w(){var T;(T=y.value)!=null&&T.upload&&p.cancelUpload(y.value.clientId)}async function F(){var T,E;((E=(T=y.value)==null?void 0:T.upload)==null?void 0:E.status)==="error"&&await p.retryUpload(y.value.clientId)}return{item:y,setItem:M,addFile:C,removeItem:b,replaceItem:f,cancelUpload:w,retryUpload:F,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:g,errors:p.errors,adapter:p.adapter,formValue:x,acceptString:p.acceptString}}const vC=["accept","disabled"],gC={class:"media-attachment__preview"},yC=["name","value"],bC=["name","value"],wC=["name","value"],kC=["name","value"],xC={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},EC=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:S=>{o("update:modelValue",S),o("change",S)},onUpload:S=>{o("upload",S)},onUploadComplete:S=>{o("upload-complete",S)},onUploadError:S=>{o("upload-error",S)},onRemove:S=>{o("remove",S)},onReplace:(S,D)=>{o("replace",D)},onError:S=>{o("validation-error",S)},onReadyToSubmitChange:S=>{o("is-ready-to-submit-change",S)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,hasItem:y,errors:g,adapter:x,formValue:M,acceptString:C}=os(r);e.provide("mediaAdapter",x),e.watch(()=>t.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const b=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!y.value),f=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":y.value}));function w(S){S.length>0&&c(S[0])}function F(){var S;(S=i.value)==null||S.click()}function T(S){const D=S.target,I=D.files;I&&I.length>0&&u(I[0]),D.value=""}function E(S){d()}function B(S){h()}function U(S){m()}return(S,D)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(C),disabled:S.disabled,class:"media-attachment__hidden-input",onChange:T},null,40,vC),b.value?e.renderSlot(S.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(ts,{accept:e.unref(C),multiple:!1,disabled:S.disabled,"max-file-size":S.maxFileSize,onFiles:w},null,8,["accept","disabled","max-file-size"])],!0):e.unref(y)&&e.unref(s)?e.renderSlot(S.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:F},()=>[e.createElementVNode("div",gC,[e.createVNode(ns,{item:e.unref(s),adapter:e.unref(x),disabled:S.disabled,sortable:!1,"show-remove":!S.readonly,"show-edit":!1,onRemove:E,onRetry:B,onCancel:U},null,8,["item","adapter","disabled","show-remove"]),S.showReplaceButton&&!S.readonly&&!S.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:F},[...D[0]||(D[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(S.$slots,"empty",{key:2},()=>[D[1]||(D[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),S.generateFormFields&&e.unref(M)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${S.name}[uuid]`,value:e.unref(M).uuid},null,8,yC),e.createElementVNode("input",{type:"hidden",name:`${S.name}[name]`,value:e.unref(M).name},null,8,bC),e.createElementVNode("input",{type:"hidden",name:`${S.name}[order]`,value:e.unref(M).order},null,8,wC),e.unref(M).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${S.name}[custom_properties]`,value:JSON.stringify(e.unref(M).custom_properties)},null,8,kC)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",xC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),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))}}),SC=Ve(EC,[["__scopeId","data-v-26911174"]]),Dd={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"}},VC=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:S=>{i("update:modelValue",S),i("change",S)},onUpload:S=>{i("upload",S)},onUploadComplete:S=>{i("upload-complete",S)},onUploadError:S=>{i("upload-error",S)},onRemove:S=>{i("remove",S)},onReorder:S=>{i("reorder",S)},onError:S=>{i("validation-error",S)},onReadyToSubmitChange:S=>{i("is-ready-to-submit-change",S)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:y,isUploading:g,isReadyToSubmit:x,isAtMaxItems:M,errors:C,dragState:b,getDragProps:f,adapter:w,formValues:F,acceptString:T}=li(r);e.provide("mediaAdapter",w),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const E=e.computed(()=>({...Dd,...o.labels})),B=e.computed(()=>({accept:T.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||M.value})),U=e.computed(()=>({items:s.value,isLoading:y.value,isUploading:g.value,isReadyToSubmit:x.value,isAtMaxItems:M.value,errors:C.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(S=>d(S))},cancelUpload:h,retryUpload:p,labels:E.value,dropzoneProps:B.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:y,isUploading:g,isReadyToSubmit:x,isAtMaxItems:M,errors:C,dragState:b,getDragProps:f,adapter:w,formValues:F,acceptString:T}),(S,D)=>e.renderSlot(S.$slots,"default",e.normalizeProps(e.guardReactiveProps(U.value)))}}),_C=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:E=>{i("update:modelValue",E),i("change",E)},onUpload:E=>{i("upload",E)},onUploadComplete:E=>{i("upload-complete",E)},onUploadError:E=>{i("upload-error",E)},onRemove:E=>{i("remove",E)},onReplace:(E,B)=>{i("replace",B)},onError:E=>{i("validation-error",E)},onReadyToSubmitChange:E=>{i("is-ready-to-submit-change",E)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:y,isReadyToSubmit:g,hasItem:x,errors:M,adapter:C,formValue:b,acceptString:f}=os(r);e.provide("mediaAdapter",C),e.watch(()=>o.modelValue,E=>{E!==s.value&&l(E)},{deep:!0});const w=e.computed(()=>({...Dd,...o.labels})),F=e.computed(()=>({accept:f.value,multiple:!1,disabled:o.disabled||o.readonly||x.value})),T=e.computed(()=>({item:s.value,hasItem:x.value,isLoading:p.value,isUploading:y.value,isReadyToSubmit:g.value,errors:M.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,labels:w.value,dropzoneProps:F.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:y,isReadyToSubmit:g,hasItem:x,errors:M,adapter:C,formValue:b,acceptString:f}),(E,B)=>e.renderSlot(E.$slots,"default",e.normalizeProps(e.guardReactiveProps(T.value)))}}),CC=["name","value"],NC=["name","value"],TC=["name","value"],MC=["name","value"],BC=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(()=>Kr(t.value));function i(l,c){var u;const d=((u=o.value[l])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${c}]`}function r(l,c){return`${n.name}[${l}][${c}]`}function s(l,c){return n.format==="spatie"?i(l,c):r(l,c)}return(l,c)=>(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,CC),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,NC),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,TC),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,MC)):e.createCommentVNode("",!0)],64))),128))}}),IC=["data-testid"],FC=["data-testid"],$C=["id"],RC=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],DC=e.defineComponent({__name:"MediaAttachmentMetadataFields",props:{items:{},disabled:{type:Boolean,default:!1},label:{default:"Caption"},placeholder:{default:"Add an optional caption"},maxLength:{default:500},testIdPrefix:{default:"media-attachment-metadata"},getItemLabel:{type:Function,default:(a,n)=>`${a.type==="video"?"video":"photo"} ${n+1}`}},emits:["update:items"],setup(a,{emit:n}){const t=a,o=n;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&o("update:items",t.items.map((c,d)=>d!==r?c:{...c,caption:l.value===""?null:l.value}))}return(r,s)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-attachment-metadata-fields","data-testid":r.testIdPrefix},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(l,c)=>(e.openBlock(),e.createElementBlock("div",{key:l._key??l.id??`${l.url}:${c}`,class:"media-attachment-metadata-fields__row","data-testid":`${r.testIdPrefix}-${c}`},[e.createElementVNode("p",{id:`${r.testIdPrefix}-label-${c}`,class:"media-attachment-metadata-fields__label"},e.toDisplayString(r.label)+" for "+e.toDisplayString(r.getItemLabel(l,c)),9,$C),e.createElementVNode("input",{value:l.caption??"",type:"text",class:"media-attachment-metadata-fields__input",maxlength:r.maxLength,disabled:r.disabled,"aria-labelledby":`${r.testIdPrefix}-label-${c}`,placeholder:r.placeholder,"data-testid":`input-${r.testIdPrefix}-${c}`,onInput:d=>i(c,d)},null,40,RC)],8,FC))),128))],8,IC)):e.createCommentVNode("",!0)}}),AC=Ve(DC,[["__scopeId","data-v-a153768a"]]);exports.AlbumBrowser=hd;exports.AlbumManager=zV;exports.AlbumMediaGrid=e3;exports.AlbumTree=fd;exports.ArrayBufferTarget=Mr;exports.ExistingMediaSelector=Jf;exports.ImageEditor=Hl;exports.ImageEditorModal=Gl;exports.LiveStreamManager=hV;exports.ManagedMediaGallery=xm;exports.MediaAlbumInlineCreate=vd;exports.MediaAlbumUnavailableState=gd;exports.MediaAttachment=SC;exports.MediaAttachmentMetadataFields=AC;exports.MediaCollection=hC;exports.MediaCollectionDropzone=ts;exports.MediaCollectionItem=ns;exports.MediaLibraryPicker=Fd;exports.MediaLibraryPickerModal=x_;exports.MediaPreviewSheet=yd;exports.MediaSelectionTray=bd;exports.MediaSourceSheet=wd;exports.MediaThumbnailCell=xd;exports.MediaUploadSheet=kd;exports.MediaWorkspace=ym;exports.ModelMediaManager=gf;exports.Muxer=wc;exports.VideoEditor=kr;exports.VideoEditorDialog=Kk;exports.VideoEditorSimple=xx;exports.VideoExportPanel=t4;exports.VideoJobClient=Hr;exports.VideoPlayer=ud;exports.VideoTimeline=Xx;exports.VideoToolsPanel=RE;exports.VideoUploader=z4;exports.VirtualMediaGrid=Ed;exports._sfc_main=VC;exports._sfc_main$1=_C;exports._sfc_main$2=BC;exports.applyTemporaryMediaStoreConfig=Zl;exports.configureMediaStore=Zn;exports.createAdapter=$d;exports.createEmptyEditorState=am;exports.createImageEditor=S_;exports.createMediablesAdapter=Qr;exports.createSpatieAdapter=es;exports.deserializeEditorState=om;exports.formatFileSize=Da;exports.fromMediaArray=xr;exports.getFileExtension=Sd;exports.getImageDimensions=Vd;exports.getMediablesAdapter=V_;exports.getSpatieAdapter=N_;exports.isImageFile=Gr;exports.normalizeEditorState=Er;exports.normalizeRecipeForServerRender=Fk;exports.recipeHasServerRenderableEdits=Ik;exports.recipeHasUnsupportedServerEdits=dd;exports.resetMediablesAdapter=__;exports.resetSpatieAdapter=T_;exports.restoreMediaStoreConfig=Wl;exports.serializeEditorState=zl;exports.snapshotMediaStoreConfig=jl;exports.toFormValues=Kr;exports.useAdminMediaStore=Xl;exports.useAlbumDragDrop=pd;exports.useAlbumStore=si;exports.useAlbums=md;exports.useGlobalImageEditor=E_;exports.useImageEditorModal=qr;exports.useMediaAttachment=os;exports.useMediaCollection=li;exports.useMediaDragSort=Rd;exports.useMediaLibraryPickerController=Id;exports.useMediaLibraryQuery=Nd;exports.useMediaLibrarySession=Td;exports.useMediaLibraryStateMachine=Md;exports.useMediaLibraryTelemetry=Bd;exports.useMediaStore=_t;exports.useMediaUploadQueue=Yr;exports.useMediaValidation=Jr;exports.validateFile=_d;
|
|
342
|
-
//# sourceMappingURL=index-BTGCVCn6.cjs.map
|