@codingfactory/mediables-vue 2.9.3 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/{PixiFrameExporter-6l-tVJXc.cjs → PixiFrameExporter-CZ20kvpH.cjs} +2 -2
  2. package/dist/{PixiFrameExporter-6l-tVJXc.cjs.map → PixiFrameExporter-CZ20kvpH.cjs.map} +1 -1
  3. package/dist/{PixiFrameExporter-DiX2TyR3.js → PixiFrameExporter-hR8D733U.js} +2 -2
  4. package/dist/{PixiFrameExporter-DiX2TyR3.js.map → PixiFrameExporter-hR8D733U.js.map} +1 -1
  5. package/dist/components/MediaLibraryPicker.vue.d.ts +14 -1
  6. package/dist/components/MediaManagementView.vue.d.ts +19 -1
  7. package/dist/composables/useAssetImport.d.ts +48 -0
  8. package/dist/composables/useEditorShortcuts.d.ts +53 -0
  9. package/dist/composables/useMediaLibraryPickerController.d.ts +2 -1
  10. package/dist/composables/useProjectDraftSync.d.ts +43 -0
  11. package/dist/composables/useVideoEditor.d.ts +14 -8
  12. package/dist/index-CeeQFiXM.cjs +357 -0
  13. package/dist/{index-Dvqt7Fr6.cjs.map → index-CeeQFiXM.cjs.map} +1 -1
  14. package/dist/index-DDDfEJgO.js +34969 -0
  15. package/dist/{index--jjdabLj.js.map → index-DDDfEJgO.js.map} +1 -1
  16. package/dist/mediables-vue.cjs +1 -1
  17. package/dist/mediables-vue.mjs +1 -1
  18. package/dist/style.css +1 -1
  19. package/dist/types/mediaLibraryPicker.d.ts +119 -0
  20. package/dist/video/project/assetBlobCache.d.ts +41 -0
  21. package/dist/video/project/assetLifecycle.d.ts +95 -0
  22. package/dist/video/project/editorCommandResult.d.ts +25 -0
  23. package/dist/video/project/projectDraftStore.d.ts +91 -0
  24. package/dist/video/project/sourceUsage.d.ts +20 -0
  25. package/dist/video/project/timelineCollision.d.ts +41 -0
  26. package/dist/video/project/trackCompatibility.d.ts +16 -0
  27. package/package.json +1 -1
  28. package/dist/index--jjdabLj.js +0 -33206
  29. package/dist/index-Dvqt7Fr6.cjs +0 -350
@@ -0,0 +1,357 @@
1
+ "use strict";var Cf=Object.defineProperty;var Vf=(n,a,t)=>a in n?Cf(n,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[a]=t;var Y=(n,a,t)=>Vf(n,typeof a!="symbol"?a+"":a,t);const Lr=require("pinia"),e=require("vue"),vt=require("pixi.js"),be=require("./editor-BTwIhrcA.cjs"),W=require("@ionic/vue"),Nf=require("pixi-filters");function Tf(n){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(a,t,o.get?o:{enumerable:!0,get:()=>n[t]})}}return a.default=n,Object.freeze(a)}const Dt=Tf(vt),Qs=1,Mf=new Set(["free","square","circle"]);function Bf(n){const a=typeof n;return a==="string"||a==="number"||a==="boolean"}function If(n){if(!n||typeof n!="object")return!1;const a=n;return typeof a.x=="number"&&typeof a.y=="number"&&typeof a.width=="number"&&typeof a.height=="number"}function Ul(n){if(!n||typeof n!="object")return null;const a=n;if(a.version!==Qs)return null;const t=a.crop,o=t&&If(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Mf.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=a.filters,l=[];if(Array.isArray(s))for(const d of s){if(!d||typeof d!="object")continue;const c=d;if(typeof c.id!="string")continue;const u={},f=c.values;if(f&&typeof f=="object"&&!Array.isArray(f))for(const[m,p]of Object.entries(f))Bf(p)&&(u[m]=p);l.push({id:c.id,enabled:c.enabled!==!1,values:u})}return{version:Qs,crop:{rect:o,aspectRatio:r,shape:i},filters:l}}function bu(n){const a=Ul(n);return a?JSON.stringify(a):null}function Ff(n){try{const a=JSON.parse(n);return Ul(a)}catch{return null}}function $f(){return{version:Qs,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let ya={apiBaseUrl:"/api/v1",isAdmin:!1};function ho(n){ya={...ya,...n}}function wu(){return{...ya}}function ku(n){ya={...n}}function _u(n){const a=wu();return ho(n),()=>{ku(a)}}const Df=async(n,a={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),o={Accept:"application/json",...a.headers};t&&(o["X-CSRF-TOKEN"]=t),a.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:a.method||"GET",headers:o,credentials:"include"};a.body instanceof FormData?r.body=a.body:a.body!==void 0&&(r.body=JSON.stringify(a.body));const s=await fetch(n,r);if(!s.ok){const d=await s.json().catch(()=>({message:"Request failed"}));throw new Error(d.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},va=Lr.defineStore("media",()=>{const n=e.ref([]),a=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}),d=e.ref([]),c=e.ref(!1),u=e.ref(null),f=e.ref(new Map),m=e.ref(new Map),p=e.ref(new Set),h=e.ref(new Map),v=e.ref({}),k=5*60*1e3,V=e.computed(()=>{if(ya.apiScope)return ya.apiScope;if(ya.isAdmin)return"admin"}),B=e.computed(()=>V.value==="admin");function _(){return ya.httpClient||Df}function g(me){const ge=ya.apiBaseUrl||"/api/v1",Te=V.value?`/${V.value}`:"";return`${ge}${Te}${me}`}function E(me,ge){return`${V.value??"default"}-${me}-${JSON.stringify(ge)}`}function C(me){return Date.now()-me<k}function N(){h.value.clear(),v.value={}}function S(me){if(!me||!me.data)return;const ge={};me.data.forEach(Te=>{const he=`${Te.file_name}-${Te.collection_name||"default"}`,ye=ge[he];(!ye||Object.keys(Te.generated_conversions||{}).length>Object.keys(ye.generated_conversions||{}).length)&&(ge[he]=Te)}),n.value=Object.values(ge),me.meta&&(i.value=me.meta.current_page,r.value=Math.ceil(me.meta.total/me.meta.per_page))}async function A(me=1,ge={}){const Te=E(me,ge),he=h.value.get(Te);if(he&&C(he.timestamp)){const ye=he.data;return S(ye),ye}t.value=!0,o.value=null;try{const ye=new URLSearchParams;ye.append("page",me.toString()),ye.append("per_page",s.value.toString()),B.value&&ye.append("linked","1");for(const at in ge)if(Object.prototype.hasOwnProperty.call(ge,at)){const et=ge[at];et!=null&&et!==""&&ye.append(at,String(et))}const Ne=await _()(g(`/media?${ye}`));return h.value.set(Te,{data:Ne,timestamp:Date.now()}),S(Ne),Ne}catch(ye){throw o.value=ye instanceof Error?ye.message:"Failed to fetch media",n.value=[],new Error(o.value)}finally{t.value=!1}}async function Z(me,ge){t.value=!0,o.value=null;const Te=`${me.name}-${Date.now()}`,he={file:me,progress:0,status:"uploading"};f.value.set(Te,he);try{const ye=new FormData;ye.append("file",me),ye.append("collection",ge.collection),ge.ownerUuid&&(ye.append("owner_uuid",ge.ownerUuid),ye.append("owner_type",ge.ownerType||"")),ge.usageUuid&&(ye.append("usage_uuid",ge.usageUuid),ye.append("usage_type",ge.usageType||""),ye.append("usage_purpose",ge.usagePurpose||"")),ge.customProperties&&ye.append("custom_properties",JSON.stringify(ge.customProperties));const Ne=await _()(g("/media"),{method:"POST",body:ye});return he.status="completed",he.progress=100,he.media=Ne==null?void 0:Ne.data,i.value===1&&(Ne!=null&&Ne.data)&&(n.value=[Ne.data,...n.value]),N(),(Ne==null?void 0:Ne.data)||null}catch(ye){throw he.status="error",he.error=ye instanceof Error?ye.message:"Upload failed",o.value=he.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{f.value.delete(Te)},5e3)}}async function x(me){t.value=!0,o.value=null;const ge=n.value.findIndex(he=>he.uuid===me);let Te;ge!==-1&&(Te=n.value.splice(ge,1)[0]);try{return await _()(g(`/media/${me}`),{method:"DELETE"}),p.value.delete(me),N(),!0}catch(he){throw Te&&ge!==-1&&n.value.splice(ge,0,Te),o.value=he instanceof Error?he.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function F(me,ge){t.value=!0,o.value=null;try{const he=await _()(g(`/media/${me}`),{method:"PATCH",body:ge,data:ge});if(he!=null&&he.data){const ye=n.value.findIndex(Se=>Se.uuid===me);return ye!==-1&&(n.value[ye]={...n.value[ye],...he.data}),N(),he.data}return null}catch(Te){throw o.value=Te instanceof Error?Te.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function b(){t.value=!0,o.value=null;try{const ge=await _()(g("/media/collections"));return a.value=(ge==null?void 0:ge.data)||[],a.value}catch(me){throw o.value=me instanceof Error?me.message:"Failed to fetch collections",a.value=[],new Error(o.value)}finally{t.value=!1}}async function R(me,ge,Te="images",he){c.value=!0,u.value=null;try{const ye=new URLSearchParams;ye.append("collection",Te),he&&ye.append("search",he);const Ne=await _()(g(`/media/model/${me}/${ge}?${ye}`));return Ne!=null&&Ne.data?(d.value=Ne.data,Ne.data):[]}catch(ye){throw u.value=ye instanceof Error?ye.message:"Failed to fetch model media",d.value=[],new Error(u.value)}finally{c.value=!1}}async function P(me,ge,Te,he="images"){c.value=!0,u.value=null;const ye=[...d.value];try{const Ne=await _()(g(`/media/model/${me}/${ge}/attach`),{method:"POST",body:{media_uuids:Te,collection:he}});return await R(me,ge,he),(Ne==null?void 0:Ne.data)||[]}catch(Se){throw d.value=ye,u.value=Se instanceof Error?Se.message:"Failed to attach media",new Error(u.value)}finally{c.value=!1}}async function O(me,ge,Te,he="images"){c.value=!0,u.value=null;const ye=[...d.value];d.value=d.value.filter(Se=>Se.uuid!==Te);try{return await _()(g(`/media/model/${me}/${ge}/detach`),{method:"POST",body:{media_uuid:Te,collection:he}}),!0}catch(Se){throw d.value=ye,u.value=Se instanceof Error?Se.message:"Failed to detach media",new Error(u.value)}finally{c.value=!1}}async function U(me,ge,Te,he="images"){c.value=!0,u.value=null;const ye=[...d.value],Se=new Map(d.value.map(Ne=>[Ne.uuid,Ne]));d.value=Te.map(Ne=>Se.get(Ne)).filter(Ne=>Ne!==void 0);try{return await _()(g(`/media/model/${me}/${ge}/reorder`),{method:"POST",body:{media_uuids:Te,collection:he}}),!0}catch(Ne){throw d.value=ye,u.value=Ne instanceof Error?Ne.message:"Failed to reorder media",new Error(u.value)}finally{c.value=!1}}async function M(me,ge,Te={}){const he=_(),ye=ya.apiBaseUrl||"/api/v1",Se=new FormData,Ne=ge.imageData,at=Ne.match(/^data:(image\/\w+);base64,/),et=at?at[1]:"image/png",gt=Ne.replace(/^data:image\/\w+;base64,/,""),Ct=atob(gt),yt=new Uint8Array(Ct.length);for(let xt=0;xt<Ct.length;xt++)yt[xt]=Ct.charCodeAt(xt);const mt=new Blob([yt],{type:et});Se.append("image_file",mt,`edited.${et==="image/jpeg"?"jpg":"png"}`);const ot=bu(ge.state);ot&&Se.append("editor_state",ot),ge.metadata&&(Se.append("filters",JSON.stringify(ge.metadata.filters)),ge.metadata.cropRect&&Se.append("crop_data",JSON.stringify(ge.metadata.cropRect))),Se.append("save_as_new","true"),Te.asVariant&&Se.append("as_variant","true"),Te.name!==void 0&&Se.append("name",Te.name);const kt=await he(`${ye}/editor/${me}/save`,{method:"POST",body:Se});if("media"in kt&&kt.media)return kt.media;if("status_url"in kt&&kt.status_url)return I(he,kt.status_url,Te.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function I(me,ge,Te){const he=Date.now(),ye=2e3;for(;Date.now()-he<Te;){await new Promise(Ne=>setTimeout(Ne,ye));const Se=await me(ge);if(Se.status==="completed"&&Se.media)return Se.media;if(Se.status==="failed")throw new Error(Se.error??"Image processing failed")}throw new Error("Image processing timed out")}function z(me,ge,Te){l.value=Te!==void 0?{type:me,uuid:ge,collection:Te}:{type:me,uuid:ge},v.value[`${me}-${ge}`]={timestamp:Date.now()}}function X(){l.value={type:null,uuid:null},d.value=[],u.value=null}async function le(){if(!l.value.type||!l.value.uuid)return;const me=await R(l.value.type,l.value.uuid,l.value.collection||"images");d.value=me||[]}function ve(){n.value.forEach(me=>p.value.add(me.uuid))}function ie(){p.value.clear()}function ne(me){p.value.has(me)?p.value.delete(me):p.value.add(me)}function L(me){return p.value.has(me)}function D(){return Array.from(f.value.values()).some(me=>me.status==="uploading")}function j(me){return f.value.get(me)||m.value.get(me)}function q(){return[...Array.from(f.value.values()),...Array.from(m.value.values())]}async function te(){const me=Array.from(p.value);let ge=0;for(const Te of me)try{await x(Te),ge++}catch{}return ie(),ge}function ce(me,ge){var Te;return ge&&((Te=me.conversion_urls)!=null&&Te[ge])?me.conversion_urls[ge]||"":me.original_url||me.url||""}return{items:n,collections:a,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:B,modelContext:l,modelMedia:d,isLoadingModelMedia:c,modelMediaError:u,selectedItems:p,uploadProgress:f,uploadQueue:m,cachedResponses:v,fetchMedia:A,uploadFile:Z,deleteMedia:x,updateMedia:F,clearCache:N,fetchCollections:b,fetchModelMedia:R,attachMedia:P,detachMedia:O,reorderMedia:U,saveEditedImage:M,setModelContext:z,clearModelContext:X,refreshModelMedia:le,selectAllItems:ve,clearSelection:ie,toggleSelection:ne,isSelected:L,deleteSelectedItems:te,getHttpClient:_,getApiUrl:g,hasActiveUploads:D,getUploadProgress:j,getAllUploadProgress:q,getMediaUrl:ce}}),Eu=()=>((ya.apiScope!=="admin"||ya.isAdmin!==!0)&&ho({...ya,apiScope:"admin",isAdmin:!0}),va());class xu{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._tabs=new Map,this._unsubscribers=[],this._onSelect=null}render({onSelect:a}={}){return this._onSelect=a,this.element=be.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),be.EDITOR_CATEGORIES.forEach(t=>{const o=be.el("button",{type:"button",className:`panel-tab ${this._isSelected(t.id)?"active":""}`,role:"tab","aria-selected":this._isSelected(t.id)?"true":"false","data-category":t.id,"data-testid":`v2-category-${t.id}`,onClick:()=>this._selectCategory(t.id)});if(t.icon){const i=be.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,o.appendChild(i)}o.appendChild(be.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,o),this.element.appendChild(o)}),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._refreshActive())),this.element}_isSelected(a){const t=this.state.get("selectedCategory");return a==="crop"?this.state.get("mode")==="crop":t===a&&this.state.get("mode")!=="crop"}_selectCategory(a){var o;this.state.set("selectedCategory",a);const t=this.state.get("mode");a==="crop"?t!=="crop"&&this.editor.setMode("crop"):t!=="filters"&&this.editor.setMode("filters"),this._refreshActive(),(o=this._onSelect)==null||o.call(this,a)}_refreshActive(){this._tabs.forEach((a,t)=>{const o=this._isSelected(t);a.classList.toggle("active",o),a.setAttribute("aria-selected",o?"true":"false")})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._tabs.clear(),(a=this.element)==null||a.remove(),this.element=null}}class Su{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onToggle=null,this._onSelect=null}render({onToggle:a,onSelect:t}={}){return this._onToggle=a,this._onSelect=t,this.element=be.el("div",{className:"filter-list",role:"listbox","aria-label":"Filters","data-testid":"v2-filter-list"}),this._renderRows(),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._renderRows()),this.state.on("change:activeFilters",()=>this._renderRows()),this.state.on("change:selectedFilter",()=>this._renderRows()),this.state.on("change:filterValues",()=>this._refreshSummaries())),this.element}_renderRows(){this.element.innerHTML="";const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),o=this.state.get("activeFilters"),i=this.state.get("selectedFilter");t.forEach(r=>{var d;const s=((d=o==null?void 0:o.has)==null?void 0:d.call(o,r.id))??!1,l=i===r.id;this.element.appendChild(this._renderRow(r,s,l))})}_renderRow(a,t,o){const i=be.el("button",{type:"button",className:`filter-row ${o?"selected":""}`,role:"option","aria-selected":o?"true":"false","data-filter":a.id,"data-testid":`v2-filter-${a.id}`,onClick:()=>{var c;return(c=this._onSelect)==null?void 0:c.call(this,a.id)}}),r=be.el("button",{type:"button",className:`filter-row-toggle ${t?"active":""}`,"aria-label":`${t?"Disable":"Enable"} ${a.name}`,"aria-pressed":t?"true":"false","data-testid":`v2-filter-toggle-${a.id}`,onClick:c=>{var f,m,p,h;c.stopPropagation();const u=!((m=(f=this.state.get("activeFilters"))==null?void 0:f.has)!=null&&m.call(f,a.id));(p=this._onToggle)==null||p.call(this,a.id,u),u&&((h=this._onSelect)==null||h.call(this,a.id))}});t&&(r.innerHTML=be.checkmark),i.appendChild(r);const s=be.el("div",{className:"filter-row-body"});s.appendChild(be.el("span",{className:"filter-row-name"},a.name));const l=this._buildSummary(a,t);l&&s.appendChild(be.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const d=be.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return d.innerHTML=be.chevronRight,i.appendChild(d),i}_buildSummary(a,t){if(!t)return a.description||"";const o=this.state.getFilterValues(a.id);if(!o||Object.keys(o).length===0)return a.description||"Active";const i=[];for(const r of(a.controls||[]).slice(0,4)){const s=o[r.id];if(!(s===void 0||s===r.default)&&(i.push(this._formatControlValue(r,s)),i.length>=2))break}return i.length===0?"Active":i.join(" · ")}_formatControlValue(a,t){return a.type==="toggle"?a.label:typeof t=="number"?(a.max??1)<=1&&(a.min??0)>=0?`${a.label} ${Math.round(t*100)}%`:Number.isInteger(t)?`${a.label} ${t}`:`${a.label} ${t.toFixed(2)}`:typeof t=="string"?`${a.label}`:a.label}_refreshSummaries(){var i;const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),o=this.state.get("activeFilters");for(const r of t){const s=this.element.querySelector(`[data-filter="${r.id}"]`);if(!s)continue;const l=((i=o==null?void 0:o.has)==null?void 0:i.call(o,r.id))??!1,d=this._buildSummary(r,l),c=s.querySelector(".filter-row-summary");if(d&&c)c.textContent=d;else if(d&&!c){const u=s.querySelector(".filter-row-body");u==null||u.appendChild(be.el("span",{className:"filter-row-summary"},d))}else!d&&c&&c.remove()}}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Cu{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onChange=null,this._onReset=null,this._onAction=null}render({onChange:a,onReset:t,onAction:o}={}){return this._onChange=a,this._onReset=t,this._onAction=o,this.element=be.el("div",{className:"controls-section","data-testid":"v2-controls-section"}),this._renderControls(),this._unsubscribers.push(this.state.on("change:selectedFilter",()=>this._renderControls()),this.state.on("change:activeFilters",()=>this._renderControls())),this.element}_renderControls(){this.element.innerHTML="";const a=this.state.get("selectedFilter");if(!a){this.element.appendChild(be.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(a);if(!t){this.element.appendChild(be.el("div",{className:"no-filter-selected"},"Filter not found"));return}const o=be.el("div",{className:"controls-header"});o.appendChild(be.el("span",{className:"controls-title"},t.name)),o.appendChild(be.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(a)})),this.element.appendChild(o);const i=be.el("div",{className:"controls-grid"}),r=this.state.getFilterValues(a);(t.controls||[]).forEach(l=>{if(l.hidden)return;const d=this._createControl(a,l,r[l.id]??l.default);d&&i.appendChild(d)});const s=this.filterManager.getInstance(a);if(s&&typeof s.getDynamicControls=="function"){let l=[];try{l=s.getDynamicControls()||[]}catch{}l.forEach(d=>{const c=d.property||d.id,u=r[c]??d.default,f=this._createControl(a,d,u);f&&i.appendChild(f)})}this.element.appendChild(i)}_createControl(a,t,o){if(t.hidden)return null;const i=t.label||t.id,r=this._normalizeControlType(t.type),s=t.property||t.id;switch(r){case"slider":return be.createSlider({id:`v2-${a}-${t.id}`,label:i,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof o=="number"?o:t.default??0,onChange:l=>{var d;return(d=this._onChange)==null?void 0:d.call(this,a,s,l)}});case"toggle":return be.createToggle({id:`v2-${a}-${t.id}`,label:i,checked:!!o,onChange:l=>{var d;return(d=this._onChange)==null?void 0:d.call(this,a,s,l)}});case"color":return be.createColorPicker({id:`v2-${a}-${t.id}`,label:i,value:typeof o=="string"&&o.startsWith("#")?o:t.default||"#000000",onChange:l=>{var d;return(d=this._onChange)==null?void 0:d.call(this,a,s,l)}});case"select":{const l=(t.options||[]).map(d=>typeof d=="object"&&d.value!==void 0?{value:d.value,label:d.label||String(d.value)}:{value:d,label:String(d)});return be.createSelect({id:`v2-${a}-${t.id}`,label:i,options:l,value:o??t.default,onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d)}})}case"text":return be.createTextInput({id:`v2-${a}-${t.id}`,label:i,value:typeof o=="string"?o:t.default??"",placeholder:t.placeholder||"",onCommit:l=>{var d;return(d=this._onChange)==null?void 0:d.call(this,a,s,l)}});case"button":{const l=be.el("div",{className:"button-control"});return l.appendChild(be.createButton({label:i,className:"btn-secondary",onClick:()=>{var d;(d=this._onAction)==null||d.call(this,a,t.action||t.id),this._renderControls()}})),l}default:return null}}_normalizeControlType(a){return{slider:"slider",range:"slider",toggle:"toggle",checkbox:"toggle",color:"color",select:"select",dropdown:"select",button:"button",text:"text"}[a]||a}_handleReset(a){var t;(t=this._onReset)==null||t.call(this,a),this._renderControls()}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Rf{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onRemove=null,this._onSelect=null,this._onClearAll=null}render({onRemove:a,onSelect:t,onClearAll:o}={}){return this._onRemove=a,this._onSelect=t,this._onClearAll=o,this.element=be.el("div",{className:"panel-section","data-testid":"v2-active-stack"}),this._renderContents(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderContents()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderContents(){this.element.innerHTML="";const a=this.state.get("activeFilters"),t=(a==null?void 0:a.size)??0,o=be.el("div",{className:"panel-section-title"});if(o.appendChild(be.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&o.appendChild(be.el("button",{type:"button",className:"btn btn-text",style:{padding:"2px 8px",fontSize:"11px"},"data-testid":"v2-clear-all",onClick:()=>{var s;return(s=this._onClearAll)==null?void 0:s.call(this)}},"Clear all")),this.element.appendChild(o),t===0){this.element.appendChild(be.el("div",{className:"active-empty"},"No filters applied"));return}const i=be.el("div",{className:"active-stack"}),r=this.state.get("selectedFilter");for(const s of a){const l=this.filterManager.getFilterDef(s);l&&i.appendChild(this._renderChip(l,s===r))}this.element.appendChild(i)}_renderChip(a,t){const o=be.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-active-${a.id}`});o.appendChild(be.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${a.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,a.id)}},a.name));const i=be.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-active-remove-${a.id}`,onClick:()=>{var r;return(r=this._onRemove)==null?void 0:r.call(this,a.id)}});return i.innerHTML=be.close,o.appendChild(i),o}_refreshSelection(){var o;const a=this.state.get("selectedFilter"),t=(o=this.element)==null?void 0:o.querySelectorAll(".active-chip");t&&t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const so=["collapsed","half","full"];class Af{constructor(a={}){this._onSnapChange=a.onSnapChange||null,this._ariaLabel=a.ariaLabel||"Filter controls drawer",this.element=null,this._handle=null,this._body=null,this._headerSlot=null,this._snap="half",this._dragging=!1,this._dragStartY=0,this._dragStartHeight=0,this._dragPointerId=null,this._containerHeight=0}build({header:a,body:t}={}){this.element=be.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=be.el("button",{type:"button",className:"drawer-handle","aria-label":"Drag to resize filters drawer","aria-expanded":this._snap==="full"?"true":"false","data-testid":"v2-drawer-handle"});const o=be.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(o),this._handle.addEventListener("click",i=>{if(this._wasDragging){this._wasDragging=!1,i.preventDefault();return}this._cycleSnap()}),this._handle.addEventListener("pointerdown",i=>this._onPointerDown(i)),this._handle.addEventListener("pointermove",i=>this._onPointerMove(i)),this._handle.addEventListener("pointerup",i=>this._onPointerEnd(i)),this._handle.addEventListener("pointercancel",i=>this._onPointerEnd(i)),this.element.appendChild(this._handle),this._headerSlot=be.el("div",{className:"drawer-header"}),a&&this._headerSlot.appendChild(a),this.element.appendChild(this._headerSlot),this._body=be.el("div",{className:"drawer-body"}),t&&this._body.appendChild(t),this.element.appendChild(this._body),this.element}updateContainerHeight(a){this._containerHeight=Math.max(0,Number(a)||0),this._applySnap(this._snap,{animate:!1})}snapTo(a,t={}){so.includes(a)&&this._applySnap(a,{animate:t.animate!==!1})}get snap(){return this._snap}setBodyContent(a){this._body&&(this._body.innerHTML="",a&&this._body.appendChild(a))}setHeaderContent(a){this._headerSlot&&(this._headerSlot.innerHTML="",a&&this._headerSlot.appendChild(a))}_onPointerDown(a){var t,o,i;if(!(a.button!==void 0&&a.button!==0)){this._dragging=!0,this._wasDragging=!1,this._dragPointerId=a.pointerId,this._dragStartY=a.clientY,this._dragStartHeight=((t=this.element)==null?void 0:t.offsetHeight)||0;try{(i=(o=this._handle)==null?void 0:o.setPointerCapture)==null||i.call(o,a.pointerId)}catch{}this.element&&(this.element.style.transition="none")}}_onPointerMove(a){if(!this._dragging||a.pointerId!==this._dragPointerId)return;const t=a.clientY-this._dragStartY,o=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),s=Math.max(i,Math.min(r,o));this.element&&(this.element.style.height=`${s}px`),Math.abs(t)>4&&(this._wasDragging=!0),a.preventDefault()}_onPointerEnd(a){var i,r,s;if(!this._dragging)return;this._dragging=!1;try{(r=(i=this._handle)==null?void 0:i.releasePointerCapture)==null||r.call(i,a.pointerId)}catch{}this._dragPointerId=null;const t=((s=this.element)==null?void 0:s.offsetHeight)||0,o=this._nearestSnap(t);this._applySnap(o,{animate:!0})}_cycleSnap(){const a=so.indexOf(this._snap),t=so[(a+1)%so.length];this._applySnap(t,{animate:!0})}_heightForSnap(a){const t=this._containerHeight||window.innerHeight||600;switch(a){case"collapsed":return 80;case"half":return Math.round(t*.45);case"full":return Math.round(t*.85);default:return Math.round(t*.45)}}_nearestSnap(a){let t=so[0],o=1/0;for(const i of so){const r=this._heightForSnap(i),s=Math.abs(r-a);s<o&&(o=s,t=i)}return t}_applySnap(a,{animate:t}){var r,s;if(!this.element)return;const o=this._snap;this._snap=a;const i=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);t&&!i?this.element.style.transition="height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":this.element.style.transition="none",this.element.style.height=`${this._heightForSnap(a)}px`,this.element.dataset.snap=a,this._handle&&this._handle.setAttribute("aria-expanded",a==="full"?"true":"false"),a!==o&&((s=this._onSnapChange)==null||s.call(this,a,o))}destroy(){var a;(a=this.element)==null||a.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}class Lf{constructor(a,t,o){this.state=a,this.filterManager=t,this.editor=o,this.element=null,this._headerEl=null,this._bodyEl=null,this._view="categories",this._onNavigate=null,this._callbacks=null,this._unsubscribers=[],this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null}build(a){return this._callbacks=a,this._onNavigate=a.onViewChange||null,this.element=be.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=be.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=be.el("div",{className:"drawer-nav-body"}),this.element.appendChild(this._bodyEl),this._buildViews(),this._unsubscribers.push(this.state.on("change:selectedFilter",({value:t})=>{t&&this._view!=="controls"&&this.navigateTo("controls")}),this.state.on("change:selectedCategory",()=>{}),this.state.on("change:mode",({value:t})=>{t==="filters"&&this._view!=="categories"&&!this.state.get("selectedFilter")&&this.navigateTo("categories")})),this.navigateTo("categories"),this.element}_buildViews(){this._categoryTabs=new xu(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new Su(this.state,this.filterManager),this._filterListEl=this._filterListView.render({onToggle:(a,t)=>this._callbacks.onFilterToggle(a,t),onSelect:a=>{this._callbacks.onFilterSelect(a),this.navigateTo("controls")}}),this._filterControlsView=new Cu(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(a,t,o)=>this._callbacks.onFilterChange(a,t,o),onReset:a=>this._callbacks.onFilterReset(a),onAction:(a,t)=>this._callbacks.onFilterAction(a,t)})}navigateTo(a){var o;if(!this.element)return;this._view=a,this._renderHeader(),this._bodyEl.innerHTML="";let t=null;switch(a){case"categories":t=this._categoryTabsEl;break;case"filters":t=this._filterListEl;break;case"controls":t=this._filterControlsEl;break;default:t=this._categoryTabsEl}t&&this._bodyEl.appendChild(t),(o=this._onNavigate)==null||o.call(this,a)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const o=be.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});o.innerHTML=be.chevronLeft,this._headerEl.appendChild(o)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(be.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const o=this.state.get("selectedFilter");o&&this._headerEl.appendChild(be.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(o)}))}}_titleForView(a){switch(a){case"categories":return"Filters";case"filters":{const t=this.state.get("selectedCategory");return this._categoryLabel(t)||"Filters"}case"controls":{const t=this.state.get("selectedFilter"),o=t?this.filterManager.getFilterDef(t):null;return(o==null?void 0:o.name)||"Filter"}default:return""}}_categoryLabel(a){var t;return a&&((t=be.EDITOR_CATEGORIES.find(o=>o.id===a))==null?void 0:t.name)||null}_goBack(){this._view==="controls"?(this.state.set("selectedFilter",null),this.navigateTo("filters")):this._view==="filters"&&this.navigateTo("categories")}get currentView(){return this._view}destroy(){var a,t,o,i;this._unsubscribers.forEach(r=>r()),this._unsubscribers=[],(a=this._categoryTabs)==null||a.destroy(),(t=this._filterListView)==null||t.destroy(),(o=this._filterControlsView)==null||o.destroy(),(i=this.element)==null||i.remove(),this.element=null}}class Pf{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._onSelect=null,this._onRemove=null,this._unsubscribers=[]}render({onSelect:a,onRemove:t}={}){return this._onSelect=a,this._onRemove=t,this.element=be.el("div",{className:"mobile-active-chips",role:"region","aria-label":"Active filters","data-testid":"v2-mobile-active-chips"}),this._renderChips(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderChips()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderChips(){this.element.innerHTML="";const a=this.state.get("activeFilters");if(((a==null?void 0:a.size)??0)===0){this.element.style.display="none";return}this.element.style.display="";const o=be.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter");for(const r of a){const s=this.filterManager.getFilterDef(r);s&&o.appendChild(this._renderChip(s,r===i))}this.element.appendChild(o)}_renderChip(a,t){const o=be.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-mobile-chip-${a.id}`});o.appendChild(be.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${a.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,a.id)}},a.name));const i=be.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-mobile-chip-remove-${a.id}`,onClick:r=>{var s;r.stopPropagation(),(s=this._onRemove)==null||s.call(this,a.id)}});return i.innerHTML=be.close,o.appendChild(i),o}_refreshSelection(){var o;const a=this.state.get("selectedFilter"),t=(o=this.element)==null?void 0:o.querySelectorAll(".mobile-active-chip");t==null||t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const Ud="(max-width: 900px)";let Of=class{constructor(a,t,o){this.state=a,this.filterManager=t,this.editor=o,this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null,this._callbacks=null,this._isMobile=!1,this._panel=null,this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null,this._activeStack=null,this._desktopFilterListSection=null,this._desktopCropWrapper=null,this._mobileChips=null,this._mobileDrawer=null,this._mobileNav=null,this._mobileCropWrapper=null,this._cropControlsEl=null,this._unsubscribers=[],this._mql=null,this._mqlHandler=null,this._resizeObserver=null}build(a){var t;return this._callbacks=a,this.root=be.el("div",{className:"editor-v2-body"}),this.canvasSection=be.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=be.el("div",{className:"canvas-container"}),this.cropOverlay=be.el("canvas",{className:"crop-overlay","aria-hidden":"true"}),this.canvasSection.appendChild(this.canvasContainer),this.canvasSection.appendChild(this.cropOverlay),this.root.appendChild(this.canvasSection),this._isMobile=typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,Ud).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(Ud),this._mqlHandler=o=>this._handleBreakpointChange(o.matches),this._mql.addEventListener?this._mql.addEventListener("change",this._mqlHandler):this._mql.addListener&&this._mql.addListener(this._mqlHandler)),this._unsubscribers.push(this.state.on("change:mode",({value:o})=>this._applyMode(o))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(a){this._cropControlsEl=a,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=be.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new xu(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const a=be.el("div",{className:"panel-body"});this._desktopFilterListSection=be.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(be.el("div",{className:"panel-section-title"},be.el("span",{},"Filters"))),this._filterListView=new Su(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,o)=>this._callbacks.onFilterToggle(t,o),onSelect:t=>this._callbacks.onFilterSelect(t)})),a.appendChild(this._desktopFilterListSection),this._filterControlsView=new Cu(this.state,this.filterManager),a.appendChild(this._filterControlsView.render({onChange:(t,o,i)=>this._callbacks.onFilterChange(t,o,i),onReset:t=>this._callbacks.onFilterReset(t),onAction:(t,o)=>this._callbacks.onFilterAction(t,o)})),this._desktopCropWrapper=be.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),a.appendChild(this._desktopCropWrapper),this._activeStack=new Rf(this.state,this.filterManager),a.appendChild(this._activeStack.render({onRemove:t=>this._callbacks.onFilterToggle(t,!1),onSelect:t=>this._callbacks.onFilterSelect(t),onClearAll:()=>{var t,o;return(o=(t=this._callbacks).onClearAll)==null?void 0:o.call(t)}})),this._panel.appendChild(a),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new Pf(this.state,this.filterManager);const a=this._mobileChips.render({onSelect:r=>{var s,l;this._callbacks.onFilterSelect(r),(s=this._mobileDrawer)==null||s.snapTo("full"),(l=this._mobileNav)==null||l.navigateTo("controls")},onRemove:r=>this._callbacks.onFilterToggle(r,!1)});this.root.appendChild(a),this._mobileDrawer=new Af({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new Lf(this.state,this.filterManager,this.editor);const t=this._mobileNav.build({onFilterToggle:this._callbacks.onFilterToggle,onFilterSelect:this._callbacks.onFilterSelect,onFilterChange:this._callbacks.onFilterChange,onFilterReset:this._callbacks.onFilterReset,onFilterAction:this._callbacks.onFilterAction,onViewChange:r=>{var s;r==="controls"&&((s=this._mobileDrawer)==null?void 0:s.snap)==="collapsed"&&this._mobileDrawer.snapTo("half")}});this._mobileCropWrapper=be.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const o=be.el("div",{className:"drawer-content"});o.appendChild(t),o.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:o});this.root.appendChild(i),this._wireDrawerSizing(),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_wireDrawerSizing(){if(!this.root||!this._mobileDrawer)return;const a=()=>{const t=this.root.getBoundingClientRect().height;this._mobileDrawer.updateContainerHeight(t)};a(),this._resizeObserver=new ResizeObserver(()=>a()),this._resizeObserver.observe(this.root)}_destroyDesktopShell(){var a,t,o,i,r,s,l;(a=this._categoryTabs)==null||a.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(o=this._filterControlsView)==null||o.destroy(),this._filterControlsView=null,(i=this._activeStack)==null||i.destroy(),this._activeStack=null,this._desktopFilterListSection=null,(r=this._desktopCropWrapper)!=null&&r.parentElement&&((s=this._cropControlsEl)==null?void 0:s.parentElement)===this._desktopCropWrapper&&this._desktopCropWrapper.removeChild(this._cropControlsEl),this._desktopCropWrapper=null,(l=this._panel)==null||l.remove(),this._panel=null}_destroyMobileShell(){var a,t,o,i,r;(a=this._resizeObserver)==null||a.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(o=this._mobileChips)==null||o.destroy(),this._mobileChips=null,this._mobileCropWrapper&&((i=this._cropControlsEl)==null?void 0:i.parentElement)===this._mobileCropWrapper&&this._mobileCropWrapper.removeChild(this._cropControlsEl),this._mobileCropWrapper=null,(r=this._mobileDrawer)==null||r.destroy(),this._mobileDrawer=null}_handleBreakpointChange(a){a!==this._isMobile&&(this._isMobile=a,a?(this._destroyDesktopShell(),this._buildMobileShell()):(this._destroyMobileShell(),this._buildDesktopShell()))}_mountCropControlsInActiveShell(){if(!this._cropControlsEl)return;this._cropControlsEl.remove();const a=this._isMobile?this._mobileCropWrapper:this._desktopCropWrapper;a==null||a.appendChild(this._cropControlsEl)}_handleDesktopCategoryChange(){if(this.state.get("mode")==="crop")return;const t=this.state.get("selectedFilter");if(!t)return;this.filterManager.getFiltersByCategory(this.state.get("selectedCategory")).some(i=>i.id===t)||this.state.set("selectedFilter",null)}_applyMode(a){var o,i,r;const t=a==="crop";this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t?"none":""),(o=this._filterControlsView)!=null&&o.element&&(this._filterControlsView.element.style.display=t?"none":""),(i=this._activeStack)!=null&&i.element&&(this._activeStack.element.style.display=t?"none":""),this._desktopCropWrapper&&(this._desktopCropWrapper.style.display=t?"":"none"),(r=this._mobileNav)!=null&&r.element&&(this._mobileNav.element.style.display=t?"none":""),this._mobileCropWrapper&&(this._mobileCropWrapper.style.display=t?"":"none"),t&&this._mobileDrawer&&this._mobileDrawer.snapTo("half")}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._mql&&this._mqlHandler&&(this._mql.removeEventListener?this._mql.removeEventListener("change",this._mqlHandler):this._mql.removeListener&&this._mql.removeListener(this._mqlHandler),this._mql=null,this._mqlHandler=null),this._destroyDesktopShell(),this._destroyMobileShell(),(a=this.root)==null||a.remove(),this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null}};class Uf extends be.EventEmitter{constructor(a,t={}){var r,s,l;if(super(),!a)throw new Error("VanillaImageEditorV2: container element is required");this._container=a,this._destroyed=!1,this._loadVersion=0,this._objectUrls=new Set;const o=t.preset?be.getPreset(t.preset):null,i=o?{initialMode:o.initialMode==="crop"?"crop":"adjust",cropShape:o.cropShape,initialAspectRatio:o.aspectRatio}:{};this._options={theme:"auto",initialImage:null,initialMode:"adjust",cropShape:"free",initialAspectRatio:"free",layout:"split-panel",backgroundRemoval:{enabled:!0,endpoint:"/api/v1/media/remove-bg",fallbackEndpoint:null},...i,...t},this._preset=o,this._state=be.createState(),this._state.set("theme",this._options.theme),this._state.set("crop.shape",this._options.cropShape),this._state.set("crop.aspect",this._options.initialAspectRatio),this._preset&&(this._state.set("lockCropShape",!!this._preset.lockCropShape),this._state.set("lockAspectRatio",!!this._preset.lockAspectRatio),this._state.set("showFilters",this._preset.showFilters!==!1),this._state.set("showCropControls",this._preset.showCropControls!==!1),this._state.set("autoZoomOnCropOverflow",!!this._preset.autoZoomOnCropOverflow)),this._renderer=new be.PixiRenderer,this._filterManager=new be.FilterManager(this._state,this._renderer),this._cropManager=new be.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new be.RemoveBgManager({endpoint:(s=this._options.backgroundRemoval)==null?void 0:s.endpoint,fallbackEndpoint:(l=this._options.backgroundRemoval)==null?void 0:l.fallbackEndpoint})),this._loadingOverlay=null,this._toolbar=null,this._layout=null,this._cropControls=null,this._editorEl=null,this._toolbarContainer=null,this._canvasContainer=null,this._cropOverlay=null,this._fileInput=null,this._resizeObserver=null,this._init()}async _init(){this._state.detectTheme(),this._buildDOM(),await this._renderer.mount(this._canvasContainer,0,{backgroundAlpha:0}),this._cropManager.setOverlayCanvas(this._cropOverlay),this._initUI(),this._setupResizeObserver(),this._setupWindowResize(),this._subscribeToState(),this._options.initialImage&&await this.loadImage(this._options.initialImage),this.emit("ready")}_buildDOM(){this._container.innerHTML="",this._editorEl=be.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=be.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new Of(this._state,this._filterManager,this);const{root:a,canvasContainer:t,cropOverlay:o}=this._layout.build({onFilterToggle:(i,r)=>this._handleFilterToggle(i,r),onFilterSelect:i=>this._handleFilterSelect(i),onFilterChange:(i,r,s)=>this._handleFilterChange(i,r,s),onFilterReset:i=>this._handleFilterReset(i),onFilterAction:(i,r)=>this._handleFilterAction(i,r),onClearAll:()=>this.resetAll()});this._canvasContainer=t,this._cropOverlay=o,this._editorEl.appendChild(a),this._fileInput=be.el("input",{type:"file",accept:"image/*",className:"hidden-file-input",style:{display:"none"},"aria-label":"Choose image file to edit",onChange:i=>this._handleFileSelect(i)}),this._editorEl.appendChild(this._fileInput),this._container.appendChild(this._editorEl)}_initUI(){this._toolbar=new be.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new be.CropControls(this._state,this._cropManager);const a=this._cropControls.render();this._layout.mountCropControls(a)}_setupResizeObserver(){if(!this._canvasContainer)return;let a=null;this._resizeObserver=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{var t,o;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((o=(t=this._cropManager).drawOverlay)==null||o.call(t)))},50)}),this._resizeObserver.observe(this._canvasContainer)}_setupWindowResize(){this._handleWindowResize=()=>{},window.addEventListener("resize",this._handleWindowResize)}_subscribeToState(){this._state.on("change:isDarkMode",({value:a})=>{var t,o;(t=this._editorEl)==null||t.classList.toggle("dark",a),(o=this._editorEl)==null||o.classList.toggle("light",!a)})}async _handleFileSelect(a){var o;const t=(o=a.target.files)==null?void 0:o[0];t&&await this.loadImage(t),this._fileInput.value=""}_handleFilterToggle(a,t){this._filterManager.toggle(a,t),t?this._state.set("selectedFilter",a):this._state.get("selectedFilter")===a&&this._state.set("selectedFilter",null)}_handleFilterSelect(a){var i;const t=this._state.get("activeFilters");(i=t==null?void 0:t.has)!=null&&i.call(t,a)||this._filterManager.toggle(a,!0),this._state.set("selectedFilter",a);const o=this._filterManager.getFilterDef(a);if(typeof(o==null?void 0:o.category)=="string"){const r=be.REGISTRY_TO_UI[o.category]||o.category;this._state.get("selectedCategory")!==r&&this._state.set("selectedCategory",r)}}_handleFilterChange(a,t,o){this._filterManager.updateValue(a,t,o)||this._filterManager.applyFilters(),this._renderer.render()}_handleFilterReset(a){this._filterManager.resetValues(a),this._filterManager.applyFilters()}_handleFilterAction(a,t){this._filterManager.performFilterAction(a,t)}setFilterRegistry(a){this._filterManager.setRegistry(a)}async loadImage(a,t={}){if(this._destroyed)return;const o=++this._loadVersion;let i=a;this._resetEditorState(),a instanceof Blob&&(i=URL.createObjectURL(a),this._objectUrls.add(i));const r=await this._renderer.loadTexture(i);if(!(this._destroyed||this._loadVersion!==o)){if(!r){this.emit("error",new Error("Failed to load image"));return}this._state.set("hasImage",!0),this._state.set("imageUrl",i),t.state&&this._hydrateState(t.state),this._options.initialMode==="crop"&&this.setMode("crop"),this.emit("imageLoaded",{url:i})}}_resetEditorState(){this._filterManager.resetAll(),this._state.set("crop.rect",null),this._state.set("crop.appliedRect",null),this._state.set("crop.appliedShape",null),this._state.set("crop.appliedAspect",null),this._state.set("crop.shape",this._options.cropShape||"free"),this._state.set("crop.aspect",this._options.initialAspectRatio||"free"),this._state.get("mode")==="crop"&&(this._cropManager.disable(),this._state.set("mode","filters"))}_hydrateState(a){if(!(!a||a.version!==1)){if(a.crop){const t=a.crop.shape||"free",o=a.crop.aspectRatio||"free";a.crop.rect&&(this._cropManager.applyFromPixelRect(a.crop.rect,t),this._state.set("crop.appliedRect",{...a.crop.rect}),this._state.set("crop.appliedShape",t),this._state.set("crop.appliedAspect",o)),this._state.set("crop.shape",t),this._state.set("crop.aspect",o)}if(Array.isArray(a.filters)){let t=null;for(const o of a.filters)if(o.enabled&&(t===null&&(t=o.id),this._state.toggleFilter(o.id,!0),this._filterManager.initializeValues(o.id),o.values))for(const[i,r]of Object.entries(o.values))this._state.setFilterValue(o.id,i,r);if(t!==null){this._state.set("selectedFilter",t);const o=this._filterManager.getFilterDef(t);if(typeof(o==null?void 0:o.category)=="string"){const i=be.REGISTRY_TO_UI[o.category]??o.category;this._state.set("selectedCategory",i)}}this._filterManager.applyFilters()}}}openFilePicker(){var a;(a=this._fileInput)==null||a.click()}exportImage(a="png",t=.92,o={}){return this._state.get("crop.rect")&&!this._cropManager.apply()?null:this._renderer.exportImage(a,t,o.maxEdge??0,o.dontUpscale!==!1,o.maxPixels??0)}save(){if(this._state.get("hasImage")){this._state.set("isSaving",!0);try{const a=this.exportImage("png",.92);if(!a)throw new Error("Failed to export image");const t=this._renderer.originalTexture,o={width:Math.round((t==null?void 0:t.width)||0),height:Math.round((t==null?void 0:t.height)||0)},i=document.createElement("a");i.href=a,i.download=`edited-image-${Date.now()}.png`,document.body.appendChild(i),i.click(),document.body.removeChild(i),this.emit("save",{imageData:a,dimensions:o,state:this.getSerializableState()})}catch(a){this.emit("error",{error:a})}finally{this._state.set("isSaving",!1)}}}getSerializableState(){const a=this._state.get("activeFilters"),t=[];if(a)for(const s of a){const l=this._state.getFilterValues(s);t.push({id:s,enabled:!0,values:{...l}})}const o=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=o||i;return{version:1,crop:{rect:r?{...r}:null,aspectRatio:this._state.get("crop.appliedAspect")||this._state.get("crop.aspect")||"free",shape:this._state.get("crop.appliedShape")||this._state.get("crop.shape")||"free"},filters:t}}close(){this.emit("cancel")}setZoom(a){this._renderer.setZoom(a)}fitToScreen(){this._renderer.fitToScreen()}resetAll(){this._filterManager.resetAll()}toggleTheme(){const a=this._state.get("isDarkMode");this._state.set("isDarkMode",!a)}setTheme(a){this._state.set("theme",a),this._state.detectTheme()}setMode(a){a==="crop"?this._cropManager.enable():this._cropManager.disable(),this._state.set("mode",a)}getState(){return this._state.getAll()}async removeBackground(a={}){if(!this._removeBgManager)throw new Error("Background removal is not enabled");if(!this._state.get("hasImage"))throw new Error("No image loaded");this._state.set("isProcessing",!0),this._showLoadingOverlay("Removing background...");try{const t=this.exportImage("png");if(!t)throw new Error("Failed to export image for background removal");const o=await this._removeBgManager.removeBackground(t,a);return await this.loadImage(o.dataUrl),this.emit("background-removed",{model:o.model,processMs:o.processMs}),{model:o.model,processMs:o.processMs}}catch(t){throw this.emit("error",{error:t,context:"background-removal"}),t}finally{this._state.set("isProcessing",!1),this._hideLoadingOverlay()}}async isBackgroundRemovalAvailable(){return this._removeBgManager?this._removeBgManager.isAvailable():!1}_showLoadingOverlay(a){var o;if(!this._loadingOverlay)this._loadingOverlay=be.el("div",{className:"editor-loading-overlay"},be.el("div",{className:"editor-loading-spinner"}),be.el("div",{className:"editor-loading-text"},a));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=a)}const t=(o=this._canvasContainer)==null?void 0:o.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var a;(a=this._loadingOverlay)==null||a.remove()}destroy(){var a,t,o,i,r;this._destroyed=!0;for(const s of this._objectUrls)try{URL.revokeObjectURL(s)}catch{}this._objectUrls.clear(),(a=this._resizeObserver)==null||a.disconnect(),this._renderer.destroy(),this._cropManager.disable(),this._handleWindowResize&&window.removeEventListener("resize",this._handleWindowResize),(t=this._toolbar)==null||t.destroy(),(o=this._cropControls)==null||o.destroy(),(i=this._layout)==null||i.destroy(),(r=this._editorEl)==null||r.remove(),this._container=null,this._state=null,this.emit("destroyed"),this.removeAllListeners()}}function zf(n,a){try{let t=be.getFilter(n);if(t||(be.registerCorePixiFilters(),t=be.getFilter(n)),!t){try{const r=be.getAllFilters()}catch{}return null}const o={...t.defaultParams,...a};return t.createFilter(o)}catch{return null}}const Ts=78e5,jf=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null);let r=null,s=null;function l(){var _;if(!r){o("error",new Error("Editor not initialized"));return}const f=r.exportImage("png",.92,{maxPixels:Ts});if(!f){o("error",new Error("Failed to export image — the image could not be processed"));return}const m=r.getSerializableState(),p=r._renderer,h=((_=p==null?void 0:p.getExportDimensions)==null?void 0:_.call(p))??{width:0,height:0},v=h.width*h.height,k=v>Ts?Math.sqrt(Ts/Math.max(1,v)):1,V={width:Math.max(1,Math.floor(h.width*k)),height:Math.max(1,Math.floor(h.height*k))};o("save",{imageData:f,dimensions:V,state:m})}function d(){o("cancel")}function c(){if(!i.value||r)return;window.PIXI=Dt,be.initializeFilterRegistry();const f={theme:t.theme};t.preset&&(f.preset=t.preset),t.preset?t.cropShape==="circle"&&(f.cropShape="circle",f.initialAspectRatio="1:1",f.initialMode="crop"):(f.cropShape=t.cropShape==="circle"?"circle":"free",f.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",f.initialMode=t.cropShape==="circle"?"crop":"adjust");const m=t.editorVersion==="v2"?Uf:be.VanillaImageEditor;r=new m(i.value,f),r.setFilterRegistry({getAllFilters:be.getAllFilters,getFilter:be.getFilter,getFiltersByCategory:be.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",d),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?c():(s=new ResizeObserver(f=>{const m=f[0];m&&m.contentRect.width>0&&!r&&(c(),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,(f,m)=>{!r||!f||f===m||u()}),e.watch(()=>t.sessionKey,(f,m)=>{f!==m&&u()}),e.watch(()=>t.initialState,(f,m)=>{f!==m&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(f,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Be=(n,a)=>{const t=n.__vccOpts||n;for(const[o,i]of a)t[o]=i;return t},Vu=Be(jf,[["__scopeId","data-v-24c46711"]]),Wf={class:"editor-modal-panel"},Zf={class:"editor-fill"},Hf=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:{},editorVersion:{default:"v2"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),d=v=>{o("error",v)},c=()=>{e.nextTick(()=>{if(i.value){const v=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");v&&v.focus()}})};e.watch(()=>t.modelValue,v=>{r.value=v,v&&(l.value=document.activeElement,c())},{immediate:!0});const u=v=>{try{s.value=!0,o("save",v)}catch(k){d(k)}finally{s.value=!1}},f=()=>{o("cancel"),p()},m=()=>{s.value||p()},p=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},h=v=>{if(v.key==="Escape"&&r.value&&!s.value){p();return}if(v.key==="Tab"&&r.value&&i.value){const k=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const V=k[0],B=k[k.length-1];v.shiftKey&&document.activeElement===V?(v.preventDefault(),B.focus()):!v.shiftKey&&document.activeElement===B&&(v.preventDefault(),V.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(v,k)=>(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(m,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:m}),e.createElementVNode("div",Wf,[e.createElementVNode("div",Zf,[e.createVNode(Vu,{"initial-image":v.initialImage,"initial-state":v.initialState,"session-key":v.sessionKey,theme:v.theme,"crop-shape":v.cropShape,preset:v.preset,"editor-version":v.editorVersion,"primary-color":v.primaryColor,"secondary-color":v.secondaryColor,"save-button-color":v.saveButtonColor,"download-button-color":v.downloadButtonColor,onSave:u,onCancel:f,onError:d},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","editor-version","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),Nu=Be(Hf,[["__scopeId","data-v-adf95668"]]),Xf={class:"media-workspace"},Gf={class:"media-workspace-toolbar"},Jf={class:"media-workspace-label"},Kf=["value"],qf={class:"media-workspace-grid"},Yf=["onClick"],Qf=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(n,{emit:a}){var f;const t=n,o=a,i=va(),r=e.ref(t.initialScopeId??((f=t.subScopes[0])==null?void 0:f.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(m=>m.id===r.value));let d=null;function c(){d&&(d(),d=null),t.apiScope&&(d=_u({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const m={};(p=l.value)!=null&&p.collection&&(m.collection=l.value.collection),await i.fetchMedia(1,m),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,m=>{m&&m!==r.value&&(r.value=m)}),e.watch(()=>t.subScopes,m=>{if(m.length===0){r.value="";return}m.some(p=>p.id===r.value)||(r.value=m[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{c(),u()}),e.watch(r,m=>{m&&(o("scope-change",m),u())}),e.onMounted(()=>{c(),u()}),e.onUnmounted(()=>{d&&(d(),d=null)}),(m,p)=>(e.openBlock(),e.createElementBlock("div",Xf,[e.createElementVNode("div",Gf,[e.createElementVNode("label",Jf,[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]=h=>r.value=h),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,h=>(e.openBlock(),e.createElementBlock("option",{key:h.id,value:h.id},e.toDisplayString(h.label),9,Kf))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=h=>o("upload"))}," Upload ")]),e.createElementVNode("div",qf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,h=>(e.openBlock(),e.createElementBlock("button",{key:h.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:v=>o("preview",h)},e.toDisplayString(h.file_name),9,Yf))),128))])]))}}),eh=Be(Qf,[["__scopeId","data-v-895f26fe"]]),th={class:"managed-media-gallery"},ah={class:"gallery-grid"},nh=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(n){return(a,t)=>(e.openBlock(),e.createElementBlock("div",th,[e.createElementVNode("div",ah,[e.renderSlot(a.$slots,"default",{},void 0,!0)])]))}}),oh=Be(nh,[["__scopeId","data-v-10a9b8c5"]]),rr="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>",zl="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>",ih="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>",jl="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>",rh="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>",sh="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>",zd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256L272 88v96C103.57 184 64 304.77 64 424c48.61-62.24 91.6-96 208-96v96z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",jd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M240 424v-96c116.4 0 159.39 33.76 208 96 0-119.23-39.57-240-208-240V88L64 256z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ko="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>",lh="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>",Tu="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>",Mu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Wd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",dh="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>",ch="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>",Zd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Un="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>",Hd="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>",uh="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>",pn="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>",mh="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>",jo="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>",el="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>",ph="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>",Xd="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>",br="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='104' cy='152' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='104' cy='360' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M157 175l-11 15 37 15s3.46-6.42 7-10z' stroke-linecap='square' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M154.17 334.43L460 162c-2.5-6.7-28-12-64-4-29.12 6.47-121.16 29.05-159.16 56.05C205.85 236.06 227 272 192 298c-25.61 19-44.43 22.82-44.43 22.82zM344.47 278.24L295 306.67c14.23 6.74 65.54 33.27 117 36.33 14.92.89 30 .39 39-6z' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='240' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",vo="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M176 272l80 80 80-80M256 48v288' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fh="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='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='416' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='96' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",hh="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>",vh="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>",gh="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>",qo="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>",Gd="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>",Ms="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>",yh="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>",bh="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>",Bs="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>",wh="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>",kh="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>",_h="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>",Eh="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>",Bu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 192v128M304 192v128' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Wl="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>",xh="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>",Sh="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>",Ch="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>",Vh="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>",Iu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path 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>",Nh="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>",Th="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>",Zl="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>",Mh="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>",Bh="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>",Xn="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>",Ih="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>",Fh="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>",Jd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Pr="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>",$h="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>",Is="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",mn="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>",Wo="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>",Kd="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>",Dh="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>",Fu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",wr="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>",$u="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>",Rh="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>",Ah="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>",Lh="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>",Ph="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>",Oh="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>",Uh="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>",zh="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>",Wi="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 qd=()=>{};function jh(n,a){function t(...o){return new Promise((i,r)=>{Promise.resolve(n(()=>a.apply(this,o),{fn:a,thisArg:this,args:o})).then(i).catch(r)})}return t}function Wh(n,a={}){let t,o,i=qd;const r=d=>{clearTimeout(d),i(),i=qd};let s;return d=>{const c=e.toValue(n),u=e.toValue(a.maxWait);return t&&r(t),c<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(d())):new Promise((f,m)=>{i=a.rejectOnCancel?m:f,s=d,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,f(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,f(d())},c)})}}function Zh(n,a=200,t={}){return jh(Wh(a,t),n)}const Zo=new Map;function Hh(n){const a=e.getCurrentScope();function t(l){var d;const c=Zo.get(n)||new Set;c.add(l),Zo.set(n,c);const u=()=>i(l);return(d=a==null?void 0:a.cleanups)==null||d.push(u),u}function o(l){function d(...c){i(d),l(...c)}return t(d)}function i(l){const d=Zo.get(n);d&&(d.delete(l),d.size||r())}function r(){Zo.delete(n)}function s(l,d){var c;(c=Zo.get(n))==null||c.forEach(u=>u(l,d))}return{on:t,once:o,off:i,emit:s,reset:r}}function Du(){var r,s;const n=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,d;if(n)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,d;if(n)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,d;if(n)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,d;if(n)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function Ru(n){const a=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=Hh("media-selection"),r=Du(),s=e.computed(()=>n.value.filter(E=>a.value.has(E.uuid))),l=e.computed(()=>a.value.size);e.watch(a,E=>{i.emit({type:"selection:changed",count:E.size,selectedIds:Array.from(E)})},{deep:!0});const d=e.computed(()=>n.value.length>0&&n.value.every(E=>a.value.has(E.uuid))),c=e.computed(()=>n.value.some(E=>a.value.has(E.uuid)));function u(E){return a.value.has(E)}function f(E){a.value.has(E)?(a.value.delete(E),t.value===E&&(t.value=null,o.value=-1)):(a.value.add(E),t.value=E,o.value=n.value.findIndex(C=>C.uuid===E),a.value.size===1&&r.selection())}function m(E){a.value.add(E),t.value=E,o.value=n.value.findIndex(C=>C.uuid===E)}function p(E){a.value.delete(E),t.value===E&&(t.value=null,o.value=-1)}function h(){n.value.forEach(E=>a.value.add(E.uuid))}function v(){a.value.clear(),t.value=null,o.value=-1}function k(){d.value?v():h()}function V(E,C){const N=n.value.findIndex(S=>S.uuid===E);if(N!==-1)if(C!=null&&C.shiftKey&&o.value!==-1){const S=Math.min(o.value,N),A=Math.max(o.value,N);for(let Z=S;Z<=A;Z++)a.value.add(n.value[Z].uuid)}else f(E)}function B(){if(n.value.length===0)return;let E=o.value+1;E>=n.value.length&&(E=0),v(),m(n.value[E].uuid)}function _(){if(n.value.length===0)return;let E=o.value-1;E<0&&(E=n.value.length-1),v(),m(n.value[E].uuid)}function g(E){switch(E.key){case"ArrowDown":E.preventDefault(),B();break;case"ArrowUp":E.preventDefault(),_();break;case"a":(E.ctrlKey||E.metaKey)&&(E.preventDefault(),h());break;case"Escape":E.preventDefault(),v();break;case" ":t.value&&(E.preventDefault(),f(t.value));break}}return{selectedIds:e.computed(()=>a.value),selectedItems:s,selectedCount:l,isAllSelected:d,isSomeSelected:c,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:f,select:m,deselect:p,selectAll:h,clear:v,toggleAll:k,rangeSelect:V,selectNext:B,selectPrevious:_,handleKeydown:g,selectionBus:i}}const Xh={class:"flex items-center justify-between w-full px-4"},Gh={class:"p-4"},Jh={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Kh={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},qh=["value"],Yh={class:"flex gap-2 mt-4"},Qh={class:"flex justify-end mb-4"},ev={key:1,class:"flex justify-center items-center h-64"},tv={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},av={class:"text-sm text-theme-secondary"},nv={key:0},ov={class:"mb-4"},iv={class:"mb-4"},rv={class:"flex gap-2"},sv={class:"flex items-center justify-between px-4 py-2"},lv={class:"text-sm text-theme-secondary"},dv={key:0},cv={key:0},uv={key:1},mv={class:"flex gap-2"},pv=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(n,{emit:a}){const t=n,o=a,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),l=e.ref(!1),d=e.ref([]),{selectedItems:c}=e.toRefs(t),u=e.ref(new Set(c.value)),f=e.ref(!1),m=e.ref({}),p=e.ref(["images","documents","videos"]),h=e.ref(1),v=e.ref(!0),k=e.ref(!1),V=Eu(),B=Ru(d);function _(L){var ge;const D=L.conversion_urls||{},j=L.proxy_url||L.original_url||L.url||"",q=D.thumb||D.preview||L.preview_url||L.thumbnail_url||j,te=L.custom_properties||{},ce=te.width,me=te.height;return{...L,uuid:L.uuid,name:L.name||L.file_name,file_name:L.file_name,filename:L.file_name,mime_type:L.mime_type,size:L.size,collection_name:L.collection_name||"images",disk:L.disk,original_url:j,url:j,thumbnail_url:q,conversions:L.conversions||{},conversion_urls:D,generated_conversions:L.generated_conversions||{},custom_properties:te,caption:L.caption||null,alt_text:L.alt_text||null,created_at:L.created_at,updated_at:L.updated_at,is_image:((ge=L.mime_type)==null?void 0:ge.startsWith("image/"))||!1,...typeof ce=="number"?{width:ce}:{},...typeof me=="number"?{height:me}:{},...L.formatted_size!==void 0?{formatted_size:L.formatted_size}:{}}}e.watch(()=>t.selectedItems,L=>{u.value=new Set(L),B.clear(),L.forEach(D=>B.select(D))});const g=e.computed(()=>{var D;let L=d.value;return(D=m.value.types)!=null&&D.length&&(L=L.filter(j=>{var te,ce;const q=(te=j.mime_type)==null?void 0:te.split("/")[0];return(ce=m.value.types)==null?void 0:ce.includes(q)})),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&(L=L.filter(j=>{const q=j.size/1048576;return!(m.value.sizeMin!==void 0&&q<m.value.sizeMin||m.value.sizeMax!==void 0&&q>m.value.sizeMax)})),L}),E=e.computed(()=>{var D;let L=0;return m.value.search&&L++,m.value.collection&&L++,(m.value.dateFrom||m.value.dateTo)&&L++,(D=m.value.types)!=null&&D.length&&(L+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&L++,L}),C=e.computed(()=>{const L=B.selectedCount.value;return L===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${L} ${L===1?"Item":"Items"}`:"Item"}`}),N=e.computed(()=>{const L=B.selectedCount.value;return!!(L===0||t.selectionMode==="single"&&L>1||t.maxSelection&&L>t.maxSelection)}),S=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 A(L=!0){L?(l.value=!0,d.value=[],h.value=1,v.value=!0):k.value=!0;try{const D={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(D.search=s.value||m.value.search||""),m.value.dateFrom&&(D.from_date=m.value.dateFrom),m.value.dateTo&&(D.to_date=m.value.dateTo),i.value){case"recent":await V.fetchMedia(h.value,D),L?d.value=V.items.map(j=>_(j)):d.value=[...d.value,...V.items.map(j=>_(j))],v.value=V.currentPage<V.totalPages;break;case"model":if(t.modelType&&t.modelId){const j=await V.fetchModelMedia(t.modelType,t.modelId,D.collection,D.search);d.value=j?j.map(q=>_(q)):[],v.value=!1}break;case"library":await V.fetchMedia(h.value,D),L?d.value=V.items.map(j=>_(j)):d.value=[...d.value,...V.items.map(j=>_(j))],v.value=V.currentPage<V.totalPages;break}}catch{}finally{l.value=!1,k.value=!1}}async function Z(L){if(!v.value||k.value){L!=null&&L.target&&L.target.complete();return}h.value++,await A(!1),L!=null&&L.target&&(L.target.complete(),v.value||(L.target.disabled=!0))}function x(L){return L==="recent"||L==="model"||L==="library"}function F(L){i.value=L,A()}function b(L){typeof L=="string"&&x(L)&&F(L)}async function R(L){t.selectionMode==="single"?(B.clear(),B.select(L.uuid)):(B.toggle(L.uuid),t.maxSelection&&B.selectedCount.value>t.maxSelection&&(B.deselect(L.uuid),await(await W.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){o("confirm",B.selectedItems.value)}function O(){o("close")}function U(L){}const M=e.ref(null),I=e.ref(!1);function z(L){M.value=L,I.value=!0}function X(L){const D=d.value.findIndex(q=>q.uuid===L.uuid);D!==-1&&(d.value[D]=L);const j={};L.alt_text!==void 0&&(j.alt_text=L.alt_text),L.caption!==void 0&&(j.caption=L.caption),L.custom_properties!==void 0&&(j.custom_properties=L.custom_properties),V.updateMedia(L.uuid,j)}function le(){A()}function ve(){m.value={},s.value="",A()}const ie=Zh(()=>{A(!0)},300);e.watch(s,()=>{t.isOpen&&ie()});async function ne(L){try{await(await W.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 V.deleteMedia(L),await A()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,L=>{L&&A()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(L=>B.select(L))}),(L,D)=>{const j=e.resolveComponent("AdminMediaGrid"),q=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(W.IonModal),{"is-open":L.isOpen,onDidDismiss:O,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(W.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{onClick:O},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(W.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Xh,[e.createVNode(e.unref(W.IonSegment),{value:i.value,onIonChange:D[0]||(D[0]=te=>b(te.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[15]||(D[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(W.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[16]||(D[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[17]||(D[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(W.IonButton),{fill:"clear",size:"small",onClick:D[1]||(D[1]=te=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[E.value>0?(e.openBlock(),e.createBlock(e.unref(W.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(E.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(W.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Gh,[f.value?(e.openBlock(),e.createElementBlock("div",Jh,[e.createElementVNode("div",Kh,[e.createElementVNode("div",null,[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[18]||(D[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":D[2]||(D[2]=te=>m.value.collection=te),class:"w-full p-2 border rounded"},[D[19]||(D[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,te=>(e.openBlock(),e.createElementBlock("option",{key:te,value:te},e.toDisplayString(te),9,qh))),128))],512),[[e.vModelSelect,m.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[20]||(D[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[3]||(D[3]=te=>m.value.dateFrom=te),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[21]||(D[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[4]||(D[4]=te=>m.value.dateTo=te),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateTo]])])]),e.createElementVNode("div",Yh,[e.createVNode(e.unref(W.IonButton),{size:"small",onClick:le},{default:e.withCtx(()=>[...D[22]||(D[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(W.IonButton),{size:"small",fill:"clear",onClick:ve},{default:e.withCtx(()=>[...D[23]||(D[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":D[5]||(D[5]=te=>s.value=te),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Qh,[e.createVNode(e.unref(W.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:D[6]||(D[6]=te=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(W.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:D[7]||(D[7]=te=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",ev,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"})])):g.value.length===0?(e.openBlock(),e.createElementBlock("div",tv,[e.createVNode(e.unref(W.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),D[24]||(D[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",av,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(j,{key:3,"media-items":g.value,"selected-items":e.unref(B).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:R,onPreview:U,onEdit:z,onDelete:ne},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(W.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(te,ce)=>(e.openBlock(),e.createBlock(q,{key:te.uuid,media:te,selected:e.unref(B).isSelected(te.uuid),"selection-mode":!0,index:ce,onToggleSelect:R,onPreview:U,onEdit:z,onDelete:ne},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&g.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(W.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:D[8]||(D[8]=te=>Z(te))},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(W.IonModal),{"is-open":I.value,onDidDismiss:D[14]||(D[14]=te=>I.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(W.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{onClick:D[9]||(D[9]=te=>I.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(W.IonTitle),null,{default:e.withCtx(()=>[...D[25]||(D[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(W.IonContent),{class:"p-4"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",nv,[e.createElementVNode("div",ov,[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[26]||(D[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[10]||(D[10]=te=>M.value.caption=te),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,M.value.caption]])]),e.createElementVNode("div",iv,[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...D[27]||(D[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[11]||(D[11]=te=>M.value.alt_text=te),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,M.value.alt_text]])]),e.createElementVNode("div",rv,[e.createVNode(e.unref(W.IonButton),{onClick:D[12]||(D[12]=te=>X(M.value))},{default:e.withCtx(()=>[...D[28]||(D[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(W.IonButton),{fill:"clear",onClick:D[13]||(D[13]=te=>I.value=!1)},{default:e.withCtx(()=>[...D[29]||(D[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(W.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",sv,[e.createElementVNode("div",lv,[e.unref(B).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",dv,[e.createTextVNode(e.toDisplayString(e.unref(B).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",cv," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",uv," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",mv,[e.createVNode(e.unref(W.IonButton),{fill:"clear",onClick:O},{default:e.withCtx(()=>[...D[30]||(D[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(W.IonButton),{disabled:N.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),fv=Be(pv,[["__scopeId","data-v-9a8c0954"]]),hv={key:1,class:"flex flex-col items-center justify-center py-16"},vv=["draggable","onDragstart","onDragover","onDrop"],gv={key:0,class:"absolute top-2 left-2 z-20"},yv=["checked","onChange"],bv={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},wv=["data-media-id"],kv={key:0,class:"w-full h-full flex items-center justify-center"},_v=["src","alt","onError","onLoad"],Ev={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},xv={class:"text-center"},Sv={class:"text-4xl text-gray-400 mb-2"},Cv={class:"text-sm font-medium text-gray-500"},Vv={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Nv=["onClick"],Tv=["onClick"],Mv=["onClick"],Bv={class:"p-3"},Iv={class:"text-sm font-medium truncate mb-1"},Fv={class:"text-xs text-gray-600 dark:text-gray-400"},$v={key:0},Dv={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Rv=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),d=N=>t.selectedItems.some(S=>S.uuid===N.uuid),c=e.computed(()=>{const N=t.columns,S=["grid","gap-4"];switch(N.mobile){case 1:S.push("grid-cols-1");break;case 2:S.push("grid-cols-2");break;case 3:S.push("grid-cols-3");break;case 4:S.push("grid-cols-4");break;default:S.push("grid-cols-2");break}switch(N.sm){case 1:S.push("sm:grid-cols-1");break;case 2:S.push("sm:grid-cols-2");break;case 3:S.push("sm:grid-cols-3");break;case 4:S.push("sm:grid-cols-4");break;case 5:S.push("sm:grid-cols-5");break;default:S.push("sm:grid-cols-3");break}switch(N.md){case 2:S.push("md:grid-cols-2");break;case 3:S.push("md:grid-cols-3");break;case 4:S.push("md:grid-cols-4");break;case 5:S.push("md:grid-cols-5");break;case 6:S.push("md:grid-cols-6");break;default:S.push("md:grid-cols-4");break}switch(N.lg){case 3:S.push("lg:grid-cols-3");break;case 4:S.push("lg:grid-cols-4");break;case 5:S.push("lg:grid-cols-5");break;case 6:S.push("lg:grid-cols-6");break;case 7:S.push("lg:grid-cols-7");break;default:S.push("lg:grid-cols-5");break}switch(N.xl){case 4:S.push("xl:grid-cols-4");break;case 5:S.push("xl:grid-cols-5");break;case 6:S.push("xl:grid-cols-6");break;case 7:S.push("xl:grid-cols-7");break;case 8:S.push("xl:grid-cols-8");break;default:S.push("xl:grid-cols-6");break}return S.join(" ")});function u(N,S,A){t.reorderable&&(i.value=S,N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/html","")))}function f(N,S){t.reorderable&&(N.preventDefault(),r.value=S)}function m(){r.value=null}function p(N,S){if(!t.reorderable||!i.value)return;N.preventDefault();const A=[...t.mediaItems],Z=A.findIndex(x=>{var F;return x.uuid===((F=i.value)==null?void 0:F.uuid)});if(Z!==-1&&Z!==S&&i.value){const[x]=A.splice(Z,1);A.splice(S,0,x),o("reorder",A)}i.value=null,r.value=null}function h(N){return N<1024?N+" B":N<1024*1024?(N/1024).toFixed(1)+" KB":(N/(1024*1024)).toFixed(1)+" MB"}function v(N){var A;return N.thumbnail_url||((A=N.conversion_urls)==null?void 0:A.thumb)||N.original_url||N.url||""}function k(N){var Z,x,F;const S=((Z=N.mime_type)==null?void 0:Z.startsWith("image/"))||!1,A=!!(N.thumbnail_url||(x=N.conversion_urls)!=null&&x.thumb||(F=N.conversion_urls)!=null&&F.preview||N.original_url||N.url);return S&&A}function V(N){var S;return((S=N.split(".").pop())==null?void 0:S.toUpperCase())||""}function B(N){var A;const S=((A=N.mime_type)==null?void 0:A.toLowerCase())||"";return S.startsWith("image/")?"image":S.startsWith("video/")?"videocam":S.startsWith("audio/")?"musical-notes":S.includes("pdf")?"document-text":S.includes("zip")||S.includes("rar")?"archive":S.includes("sheet")||S.includes("excel")?"grid":S.includes("document")||S.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(N=>{N.forEach(S=>{var A;if(S.isIntersecting){const Z=S.target.getAttribute("data-media-id");Z&&(s.value.add(Z),(A=l.value)==null||A.unobserve(S.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function _(N){return!0}function g(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(S=>{var Z;const A=S.getAttribute("data-media-id");A&&!s.value.has(A)&&((Z=l.value)==null||Z.observe(S))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),g()},{immediate:!0,deep:!0});function E(N,S){const A=N.target;delete A.dataset.fallbackIndex}function C(N,S){const A=N.target,Z=A.closest("[data-media-id]"),x=[S.original_url,S.url,S.thumbnail_url,"preview_url"in S?S.preview_url:void 0].filter(F=>F&&F.trim()!==""&&F!==A.src);if(x.length>0&&A.dataset.fallbackIndex){const F=parseInt(A.dataset.fallbackIndex);if(F<x.length){A.dataset.fallbackIndex=(F+1).toString(),A.src=x[F]||"";return}}else if(x.length>0){A.dataset.fallbackIndex="1",A.src=x[0]||"";return}if(A.style.display="none",Z&&!Z.querySelector(".media-fallback-icon")){const b=document.createElement("div");b.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",b.innerHTML=`
2
+ <div class="text-center">
3
+ <div class="text-4xl text-gray-400 mb-2">${B(S)}</div>
4
+ <p class="text-sm font-medium text-gray-500">${V(S.file_name)}</p>
5
+ </div>
6
+ `,Z.appendChild(b)}}return(N,S)=>N.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,A=>e.createElementVNode("div",{key:`skeleton-${A}`,class:"relative"},[...S[1]||(S[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!N.mediaItems||!N.mediaItems.length?(e.openBlock(),e.createElementBlock("div",hv,[S[2]||(S[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)),S[3]||(S[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),S[4]||(S[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:S[0]||(S[0]=A=>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(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.mediaItems,(A,Z)=>(e.openBlock(),e.createElementBlock("div",{key:A.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===Z}]),draggable:N.reorderable,onDragstart:x=>u(x,A),onDragover:x=>f(x,Z),onDragleave:m,onDrop:x=>p(x,Z)},[N.selectionMode?(e.openBlock(),e.createElementBlock("div",gv,[e.createElementVNode("input",{type:"checkbox",checked:d(A),onChange:x=>o("toggleSelect",A),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,yv)])):e.createCommentVNode("",!0),N.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",N.selectionMode?"left-10":"left-2"])},[e.renderSlot(N.$slots,"badge",{media:A,index:Z},void 0,!0)],2)):e.createCommentVNode("",!0),N.reorderable?(e.openBlock(),e.createElementBlock("div",bv,[...S[5]||(S[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":d(A)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":A.uuid},[k(A)&&!_(A.uuid)?(e.openBlock(),e.createElementBlock("div",kv,[...S[6]||(S[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),k(A)&&_(A.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:v(A),alt:A.alt_text||A.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:x=>C(x,A),onLoad:x=>E(x)},null,40,_v)):(e.openBlock(),e.createElementBlock("div",Ev,[e.createElementVNode("div",xv,[e.createElementVNode("div",Sv,e.toDisplayString(B(A)),1),e.createElementVNode("p",Cv,e.toDisplayString(V(A.file_name)),1)])])),e.createElementVNode("div",Vv,[e.createElementVNode("button",{onClick:x=>o("preview",A),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...S[7]||(S[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,Nv),N.showEditButton&&k(A)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x=>o("edit",A),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...S[8]||(S[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,Tv)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:x=>o("delete",A.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...S[9]||(S[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,Mv)])],8,wv),e.createElementVNode("div",Bv,[e.createElementVNode("h4",Iv,e.toDisplayString(A.file_name),1),e.createElementVNode("p",Fv,[e.createTextVNode(e.toDisplayString(h(A.size))+" ",1),A.width&&A.height?(e.openBlock(),e.createElementBlock("span",$v," • "+e.toDisplayString(A.width)+"x"+e.toDisplayString(A.height),1)):e.createCommentVNode("",!0)]),A.caption?(e.openBlock(),e.createElementBlock("p",Dv,e.toDisplayString(A.caption),1)):e.createCommentVNode("",!0)])],2)],42,vv))),128))],2))}}),Av=Be(Rv,[["__scopeId","data-v-f0c343b7"]]),Lv={class:"model-media-manager"},Pv=["accept","multiple"],Ov={class:"flex items-center justify-between mb-4"},Uv={key:0,class:"text-lg font-medium"},zv={class:"flex gap-2"},jv={key:0,class:"flex items-center justify-center py-8"},Wv={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"},Zv={class:"text-gray-600 dark:text-gray-400"},Hv={class:"flex gap-2 mt-4"},Xv={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Gv=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(n,{emit:a}){const t=n,o=a,i=va(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),d=e.ref(!1),c=e.ref(null),u=e.ref(0),f=e.ref(null),m=e.ref(void 0),p=e.ref(null),h=e.ref(null),v=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),k=e.computed(()=>i.modelMedia.map(I=>I.uuid)),V=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function B(){ho({isAdmin:t.mode==="admin"})}async function _(I){await(await W.toastController.create({message:I,duration:3e3,color:"danger",position:"bottom"})).present()}async function g(){if(!s.value)if(s.value=!0,B(),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(I){const z=I instanceof Error?I.message:"Failed to fetch media";o("error",{operation:"fetch",message:z,details:I})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,I=>{s.value&&o("update:media",I)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,g()}),e.watch(()=>t.mode,()=>{B()}),e.onMounted(()=>{g()}),e.onUnmounted(()=>{i.clearModelContext()});function E(){return i.modelMedia.length>0}function C(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function N(I){var X,le,ve;if(!((X=I.mime_type)!=null&&X.startsWith("image/")))return null;const z=I.original_url||I.url||((le=I.conversion_urls)==null?void 0:le.preview)||((ve=I.conversion_urls)==null?void 0:ve.thumb)||I.thumbnail_url;return z&&z.trim()!==""?z:null}function S(){l.value=!0}function A(){var I;(I=h.value)==null||I.click()}function Z(){l.value=!1}async function x(I){if(!t.allowEdit)return;const z=N(I);if(z){c.value=I,u.value++;try{const X=i.getHttpClient(),le=i.getApiUrl(""),ve=await X(`${le.replace(/\/$/,"")}/editor/${I.uuid}/edit`);m.value=ve.editable_source_url||z,f.value=ve.editor_state??null}catch{m.value=z,f.value=null}d.value=!0}}function F(){d.value=!1,c.value=null,m.value=void 0,f.value=null}async function b(I){if(!c.value)throw new Error("No media selected for editing");const z=c.value,X=t.editMode==="variant";try{p.value=null;const le=await i.saveEditedImage(z.uuid,I,{asVariant:X,name:z.file_name});X||await i.detachMedia(t.mediableType,t.mediableId,z.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[le.uuid],t.collection),o("edit-complete",{originalMedia:z,editedMedia:le,mode:t.editMode}),d.value=!1,c.value=null}catch(le){const ve=le instanceof Error?le.message:"Failed to save edited image";throw p.value=ve,await _(ve),le}}function R(I){if(p.value===I.message){p.value=null;return}_(I.message)}async function P(I){const z=I.target,X=z.files;if(!(!X||X.length===0)){for(let le=0;le<X.length;le++){const ve=X[le];if(v.value!==void 0&&v.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ve.type)){o("error",{operation:"upload",message:`File type ${ve.type} is not accepted`,details:{file:ve.name}});continue}if(t.maxFileSize!==void 0&&ve.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ve.name,size:ve.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:ve});try{const ie=await i.uploadFile(ve,{collection:t.collection});ie!=null&&ie.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[ie.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:ve}),o("attach",[ie]))}catch(ie){const ne=ie instanceof Error?ie.message:"Upload failed";o("error",{operation:"upload",message:ne,details:ie}),o("upload-progress",{status:"error",progress:0,file:ve,error:ne})}}z.value=""}}async function O(I){const z=I.map(X=>X.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,z,t.collection),o("reorder",i.modelMedia)}catch(X){const le=X instanceof Error?X.message:"Failed to reorder media";o("error",{operation:"reorder",message:le,details:X}),await _(le)}}async function U(I){const z=i.modelMedia.find(X=>X.uuid===I);try{await i.detachMedia(t.mediableType,t.mediableId,I,t.collection),z&&o("detach",z)}catch(X){const le=X instanceof Error?X.message:"Failed to detach media";o("error",{operation:"detach",message:le,details:X}),await _(le)}}async function M(I){l.value=!1;const z=I.map(ve=>ve.uuid),X=new Set(k.value);let le=Array.from(new Set(z)).filter(ve=>!X.has(ve));if(v.value!==void 0&&le.length>v.value&&(le=le.slice(0,v.value)),le.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,le,t.collection);const ve=i.modelMedia.filter(ie=>le.includes(ie.uuid));o("attach",ve)}catch(ve){const ie=ve instanceof Error?ve.message:"Failed to attach media";o("error",{operation:"attach",message:ie,details:ve})}}return(I,z)=>(e.openBlock(),e.createElementBlock("div",Lv,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:h,type:"file",accept:V.value,multiple:v.value===void 0||v.value>1,class:"hidden","data-testid":"upload-input",onChange:P},null,40,Pv),e.createElementVNode("div",Ov,[I.title?(e.openBlock(),e.createElementBlock("h3",Uv,e.toDisplayString(I.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",zv,[I.allowBrowse?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:0,fill:"outline",size:"small",disabled:C(),"data-testid":"browse-button",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"start",icon:e.unref(Bs)},null,8,["icon"]),z[1]||(z[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),I.allowUpload?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:1,fill:"solid",size:"small",disabled:C(),"data-testid":"upload-button",onClick:A},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"start",icon:e.unref(Hd)},null,8,["icon"]),z[2]||(z[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",jv,[e.createVNode(e.unref(W.IonSpinner),{"data-testid":"spinner"})])):E()?(e.openBlock(),e.createBlock(Av,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!I.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!I.allowEdit,"selection-mode":!1,onReorder:O,onDelete:U,onEdit:x},e.createSlots({_:2},[I.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:X})=>[X===0?(e.openBlock(),e.createElementBlock("div",Xv," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Wv,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Bs),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Zv,e.toDisplayString(I.emptyText),1),e.createElementVNode("div",Hv,[I.allowBrowse?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"start",icon:e.unref(Bs)},null,8,["icon"]),z[3]||(z[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),I.allowUpload?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:A},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"start",icon:e.unref(Hd)},null,8,["icon"]),z[4]||(z[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(fv,e.mergeProps({"is-open":l.value,"selected-items":k.value,collection:I.collection},v.value!==null&&v.value!==void 0?{maxSelection:v.value}:{},{onConfirm:M,onClose:Z}),null,16,["is-open","selected-items","collection"]),e.createVNode(Nu,{modelValue:d.value,"onUpdate:modelValue":z[0]||(z[0]=X=>d.value=X),"initial-image":m.value,"initial-state":f.value,"session-key":u.value,onSave:b,onCancel:F,onError:R},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),Jv=Be(Gv,[["__scopeId","data-v-f68e70ec"]]),Kv={class:"existing-media-selector","data-testid":"existing-media-selector"},qv={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},Yv=["data-testid"],Qv={class:"existing-media-selector__section-header"},eg={class:"existing-media-selector__section-title"},tg=["data-testid","aria-label","onClick"],ag={class:"existing-media-selector__grid"},ng=["data-testid","aria-label","aria-pressed","onClick"],og=["src","alt"],ig={key:0,class:"existing-media-selector__selected-badge"},rg={key:1,class:"existing-media-selector__caption"},sg={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},lg={class:"existing-media-selector__section-header"},dg={class:"existing-media-selector__section-title"},cg={class:"existing-media-selector__albums"},ug=["data-testid","aria-label","aria-pressed","onClick"],mg={class:"existing-media-selector__album-name"},pg={key:0,class:"existing-media-selector__album-count"},fg={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},hg={class:"existing-media-selector__section-header"},vg={class:"existing-media-selector__section-subtitle"},gg={key:0,class:"existing-media-selector__section-description"},yg={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},bg={key:1,class:"existing-media-selector__grid"},wg=["data-testid","aria-label","aria-pressed","onClick"],kg=["src","alt"],_g={key:0,class:"existing-media-selector__selected-badge"},Eg={key:1,class:"existing-media-selector__caption"},xg={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},Sg={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Cg=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(n,{emit:a}){const t=n,o=a,i=e.reactive({}),r=e.computed(()=>t.sections.filter(g=>g.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),d=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const g=t.albums.find(E=>E.id===t.activeAlbumId);return g!=null&&g.name.trim().length?g.name.trim():t.albumSectionTitle}),c=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const g=t.albums.find(E=>E.id===t.activeAlbumId);return typeof(g==null?void 0:g.description)=="string"&&g.description.trim().length>0?g.description.trim():""});function u(g){const E=g.initialVisibleCount??6;return E>0?E:6}function f(g){return i[g]===!0}function m(g){i[g]=!f(g)}function p(g){return f(g.id)?g.items:g.items.slice(0,u(g))}function h(g){return g.items.length>u(g)}function v(g){o("select",g)}function k(g){o("update:activeAlbumId",g)}function V(g){var C;const E=(C=g.description)==null?void 0:C.trim();return E&&E.length>0?`Select ${E}`:"Select existing media"}function B(g,E){var N;const C=(N=E.description)==null?void 0:N.trim();return typeof E.alt=="string"&&E.alt.trim().length>0?E.alt.trim():C&&C.length>0?C:g.title}function _(g){const E=typeof g.mediaCount=="number"?` with ${g.mediaCount} item${g.mediaCount===1?"":"s"}`:"";return`Browse album ${g.name}${E}`}return(g,E)=>(e.openBlock(),e.createElementBlock("div",Kv,[g.isLoading?(e.openBlock(),e.createElementBlock("div",qv," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,C=>(e.openBlock(),e.createElementBlock("section",{key:C.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${C.id}`},[e.createElementVNode("div",Qv,[e.createElementVNode("h3",eg,e.toDisplayString(C.title),1),h(C)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${C.id}`,"aria-label":f(C.id)?`Show fewer items from ${C.title}`:`Show more items from ${C.title}`,onClick:N=>m(C.id)},e.toDisplayString(f(C.id)?"See less":"See more"),9,tg)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ag,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(C),N=>(e.openBlock(),e.createElementBlock("button",{key:N.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":g.selectedId===N.id}]),"data-testid":`existing-media-item-${C.id}-${N.id}`,"aria-label":V(N),"aria-pressed":g.selectedId===N.id?"true":"false",onClick:S=>v(N)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:N.previewUrl,alt:B(C,N)},null,8,og),g.selectedId===N.id?(e.openBlock(),e.createElementBlock("div",ig," Selected ")):e.createCommentVNode("",!0),N.description?(e.openBlock(),e.createElementBlock("div",rg,e.toDisplayString(N.description),1)):e.createCommentVNode("",!0)],10,ng))),128))])],8,Yv))),128)),s.value?(e.openBlock(),e.createElementBlock("section",sg,[e.createElementVNode("div",lg,[e.createElementVNode("h3",dg,e.toDisplayString(g.albumBrowseTitle),1)]),e.createElementVNode("div",cg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.albums,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":g.activeAlbumId===C.id}]),"data-testid":`existing-media-album-${C.id}`,"aria-label":_(C),"aria-pressed":g.activeAlbumId===C.id?"true":"false",onClick:N=>k(C.id)},[e.createElementVNode("span",mg,e.toDisplayString(C.name),1),typeof C.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",pg,e.toDisplayString(C.mediaCount),1)):e.createCommentVNode("",!0)],10,ug))),128))]),e.createElementVNode("div",fg,[e.createElementVNode("div",hg,[e.createElementVNode("div",null,[e.createElementVNode("h4",vg,e.toDisplayString(d.value),1),c.value?(e.openBlock(),e.createElementBlock("p",gg,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])]),g.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",yg," Loading album... ")):g.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",bg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.activeAlbumItems,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":g.selectedId===C.id}]),"data-testid":`existing-media-item-album-${C.id}`,"aria-label":V(C),"aria-pressed":g.selectedId===C.id?"true":"false",onClick:N=>v(C)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:C.previewUrl,alt:C.alt||C.description||d.value},null,8,kg),g.selectedId===C.id?(e.openBlock(),e.createElementBlock("div",_g," Selected ")):e.createCommentVNode("",!0),C.description?(e.openBlock(),e.createElementBlock("div",Eg,e.toDisplayString(C.description),1)):e.createCommentVNode("",!0)],10,wg))),128))])):(e.openBlock(),e.createElementBlock("div",xg,[e.renderSlot(g.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(g.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Sg,[e.renderSlot(g.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(g.emptyMessage),1)],!0)]))],64))]))}}),Vg=Be(Cg,[["__scopeId","data-v-904abb6b"]]);function Zi(n,a,t,o){if(t<=0||o<=0)return!1;try{return a.drawImage(n,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Ng(n,a){return n?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:a,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:a,opacity:"1",pointerEvents:"auto"}}const Tg=["src","crossorigin"],Mg={class:"preview-controls"},Bg=["aria-label"],Ig={class:"time-display"},Fg={class:"current-time"},$g={class:"total-time"},Dg={key:0,class:"fps-display"},Rg={key:0,class:"loading-overlay"},Ag={key:1,class:"error-overlay"},Lg=.1,Pg=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(n,{expose:a,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Dt,r=n,s=t,l=e.ref(),d=e.ref(),c=e.ref(),u=e.ref(!0),f=e.ref(),m=e.ref(0),p=e.ref(0),h=e.ref(!1);let v,k,V=null,B=null,_=null,g=[],E="",C=null,N=0,S=0,A=0,Z=0,x=!1,F=0,b=0,R,P=null,O=!1,U=!1,M=0;const I=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),z=e.computed(()=>{const we=I.value;if(!(!we||we.startsWith("blob:")))return"anonymous"}),X=e.computed(()=>Ng(h.value,r.fitMode));function le(we){return typeof we=="number"&&Number.isFinite(we)&&we>=0?we:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function ve(we){const Ce=le(we.duration);return Ce<=0?!1:we.currentTime>=Math.max(0,Ce-Lg)}async function ie(){var we,Ce;if(!U&&d.value&&!v&&!(!c.value||c.value.readyState<3)){U=!0;try{f.value=void 0;let $e=((we=l.value)==null?void 0:we.clientWidth)||800,Ye=((Ce=l.value)==null?void 0:Ce.clientHeight)||450;if(($e<=0||Ye<=0)&&($e=c.value.videoWidth||800,Ye=c.value.videoHeight||450),v=new Dt.Application,await v.init({width:$e,height:Ye,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),d.value.appendChild(v.canvas),c.value){if(c.value.videoWidth===0||c.value.videoHeight===0){setTimeout(()=>{c.value&&c.value.videoWidth>0&&!v&&ie()},100),v&&(v.destroy(!0),v=null);return}if(N=c.value.videoWidth,S=c.value.videoHeight,B=document.createElement("canvas"),B.width=N,B.height=S,_=B.getContext("2d"),!_)throw new Error("Unable to create 2D canvas context for video preview");const Xe=Zi(c.value,_,N,S),ze=Dt.Texture.from(B);V=ze.source,k=new Dt.Sprite(ze),k.visible=!0,k.alpha=1,mt(),v.stage.addChild(k),v.renderer&&!v.renderer.destroyed&&v.render()}j(),r.targetFps<60?ne():v.ticker.add(L),h.value=!0,"ResizeObserver"in window&&(C=new ResizeObserver(Xe=>{x||(x=!0,requestAnimationFrame(()=>{x=!1;const ze=Xe[Xe.length-1],{width:_t,height:ct}=ze.contentRect;if(_t<=0||ct<=0)return;const Zt=Math.round(_t),ta=Math.round(ct);Zt===A&&ta===Z||(A=Zt,Z=ta,mt())}))}),C.observe(l.value)),r.filters&&r.filters.length>0&&j(),r.showFps&&at(),M=0}catch{if(Ct(),!O&&!!c.value&&c.value.readyState>=2&&c.value.videoWidth>0&&c.value.videoHeight>0&&M<2){M+=1,window.setTimeout(()=>{O||ie()},M*150);return}f.value="Failed to initialize video preview",s("error",f.value)}finally{U=!1}}}function ne(){const we=1e3/r.targetFps;let Ce=performance.now();function $e(){if(O||!v)return;const Ye=performance.now(),Xe=Ye-Ce;Xe>=we&&(L(),Ce=Ye-Xe%we),P=requestAnimationFrame($e)}P=requestAnimationFrame($e)}function L(){if(!(!v||!k||O)&&r.active)try{_&&B&&V&&c.value&&(c.value.readyState>=2&&Zi(c.value,_,B.width,B.height)&&V.update(),c.value.paused||s("frame-update",ce())),r.showFps&&b++,v.renderer&&!v.renderer.destroyed&&v.render()}catch{O=!0}}function D(){for(const we of g)try{we.destroy()}catch{}g=[]}function j(){if(k){if(!r.filters||r.filters.length===0){k.filters=null,D();return}D(),r.filters.forEach(we=>{const Ce=q(we);Ce&&g.push(Ce)}),k.filters=g.length>0?g:null,E=JSON.stringify(r.filters),v&&v.render()}}function q(we){const Ce=we.filterId,$e=we.params||{},Ye=be.getFilter(Ce);if(Ye&&!be.isFilterCompatibleWithMedia(Ce,"video"))return null;if(Ye&&Ye.createFilter)try{return Ye.createFilter($e)}catch{}const Xe=(ze,_t,ct)=>Math.min(ct,Math.max(_t,ze));switch(Ce){case"brightness":{const ze=new o,_t=Xe(typeof $e.brightness=="number"?$e.brightness:typeof $e.value=="number"?$e.value:1,0,5);return ze.brightness(_t,!0),ze}case"contrast":{const ze=new o,_t=Xe(typeof $e.contrast=="number"?$e.contrast:typeof $e.value=="number"?$e.value:1,0,5);return ze.contrast(_t,!0),ze}case"saturation":{const ze=new o,_t=Xe(typeof $e.saturation=="number"?$e.saturation:typeof $e.value=="number"?$e.value:1,0,5);return ze.saturate(_t,!0),ze}case"hue":{const ze=new o,_t=Xe(typeof $e.value=="number"?$e.value:0,-180,180);return ze.hue(_t,!0),ze}case"gaussian-blur":case"blur":{const ze=Xe(typeof $e.blur=="number"?$e.blur:typeof $e.value=="number"?$e.value:2,0,10);return new i(ze)}case"grayscale":{const ze=new o;return ze.desaturate(),ze}case"sepia":case"color-matrix":{const ze=new o;return ze.sepia(!0),ze}case"vignette":{const ze=typeof $e.value=="number"?$e.value:.3;return te(Xe(ze,0,1))}default:return null}}function te(we){const Ce=`
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 Dt.Filter(void 0,Ce,{strength:we})}function ce(){var Ce;return!v||!k?null:{dataUrl:v.canvas.toDataURL("image/jpeg",.8),timestamp:((Ce=c.value)==null?void 0:Ce.currentTime)||0,width:N||0,height:S||0}}function me(){var we;m.value=le((we=c.value)==null?void 0:we.duration),s("duration-change",m.value)}function ge(){u.value=!1,f.value=void 0}function Te(){u.value&&(u.value=!1),!h.value&&r.active?ie():h.value}function he(){var Ce,$e,Ye;const we=((Ce=c.value)==null?void 0:Ce.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:we,width:(($e=c.value)==null?void 0:$e.videoWidth)||0,height:((Ye=c.value)==null?void 0:Ye.videoHeight)||0})}function ye(){c.value&&(c.value.currentTime=0),s("play-pause")}function Se(we){var $e;const Ce=we.target;if(Ce!=null&&Ce.error)switch(Ce.error.code){case Ce.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case Ce.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case Ce.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case Ce.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${($e=Ce.src)==null?void 0:$e.substring(0,100)}`;break;default:f.value="Failed to load video"}else f.value="Failed to load video";s("error",f.value),u.value=!1}function Ne(we){c.value&&(c.value.currentTime=Math.max(0,Math.min(we,m.value)))}function at(){R=window.setInterval(()=>{const we=performance.now(),Ce=we-F;p.value=Math.round(b*1e3/Ce),b=0,F=we},1e3)}function et(we){if(!Number.isFinite(we)||we<0)return"00:00";const Ce=Math.floor(we/60),$e=Math.floor(we%60);return`${Ce.toString().padStart(2,"0")}:${$e.toString().padStart(2,"0")}`}function gt(){f.value=void 0,u.value=!0,M=0,Ct(),c.value&&c.value.load()}function Ct(){if(C&&(C.disconnect(),C=null),P&&(cancelAnimationFrame(P),P=null),v!=null&&v.ticker&&(v.ticker.stop(),v.ticker.remove(L)),v)try{v.destroy(!0,{children:!0,texture:!0})}catch{}d.value&&(d.value.innerHTML=""),D(),v=null,k=null,V=null,B=null,_=null,h.value=!1,x=!1,E=""}function yt(){v&&(x||(x=!0,requestAnimationFrame(()=>{x=!1,mt()})))}function mt(){if(!v||!k||!N||!S||!l.value)return;const we=Math.round(l.value.clientWidth),Ce=Math.round(l.value.clientHeight);if(we<=0||Ce<=0)return;v.renderer.resize(we,Ce);const $e=v.screen.width/N,Ye=v.screen.height/S;let Xe=1;switch(r.fitMode){case"cover":Xe=Math.max($e,Ye);break;case"none":Xe=1;break;case"contain":default:Xe=Math.min($e,Ye);break}k.scale.set(Xe),k.anchor.set(.5),k.position.set(v.screen.width/2,v.screen.height/2),k.visible=!0,k.alpha=1,v.renderer&&!v.renderer.destroyed&&v.render()}e.watch(()=>r.filters,()=>{h.value&&j()},{deep:!0}),e.watch(()=>r.active,async we=>{if(we&&!v&&c.value&&c.value.readyState>=2){await ie();return}v&&(we&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),k&&_&&B&&V&&(c.value&&c.value.readyState>=2&&Zi(c.value,_,B.width,B.height)&&V.update(),mt(),v.renderer&&!v.renderer.destroyed&&v.render())),r.targetFps>=60&&v.ticker&&(we?v.ticker.start():v.ticker.stop()))}),e.watch(I,we=>{we?(u.value=!0,f.value=void 0,e.nextTick(()=>{c.value&&c.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0});async function ot(){if(c.value){f.value=void 0,ve(c.value)&&(c.value.currentTime=0);try{await c.value.play();return}catch{if(!c.value.muted){c.value.muted=!0;try{await c.value.play();return}catch{}}}f.value="Unable to start preview playback",s("error",f.value)}}e.watch(()=>r.isPlaying,we=>{c.value&&(we?ot():c.value.pause())}),e.watch(()=>r.playhead,we=>{c.value&&Math.abs(c.value.currentTime-we)>.5&&Ne(we)}),e.watch(()=>r.fitMode,()=>{mt()}),e.onMounted(()=>{O=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),c.value}),window.addEventListener("resize",yt),F=performance.now(),e.nextTick(()=>{c.value&&c.value.readyState>=2&&!h.value?ie():c.value&&c.value.src&&c.value.readyState===0&&c.value.load()})}),e.onUnmounted(()=>{if(O=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",yt),C&&(C.disconnect(),C=null),R&&clearInterval(R),v&&v.ticker&&(v.ticker.stop(),v.ticker.remove(L)),v){try{v.destroy(!0,{children:!0,texture:!0})}catch{}v=null}g.forEach(we=>{try{we.destroy()}catch{}}),g=[],k=null,V=null,B=null,_=null,c.value&&(c.value.pause(),c.value.removeAttribute("src"),c.value.load())});async function kt(we){if(!await xt()||!c.value||!_||!B||!V)return null;const $e=c.value,Ye=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite($e.duration)&&$e.duration>0?$e.duration:0,Xe=Math.max(0,Math.min(we,Ye));return await new Promise(_t=>{let ct=!1,Zt=0;const ta=()=>{ct||(ct=!0,$e.removeEventListener("seeked",aa),window.clearTimeout(Zt),_t())},aa=()=>{ta()},ia=Number.isFinite($e.currentTime)?$e.currentTime:0;if(Math.abs(ia-Xe)<.016){requestAnimationFrame(()=>ta());return}$e.addEventListener("seeked",aa),Zt=window.setTimeout(()=>ta(),700),$e.currentTime=Xe}),Zi($e,_,B.width,B.height)?(V.update(),v.render(),v.canvas):null}async function xt(){if(!c.value)return!1;if(!v){if(!(c.value.readyState>=2))return!1;await ie()}if(!v||!k||!_||!B||!V)return!1;if(r.filters&&r.filters.length>0){const we=k.filters,Ce=Array.isArray(we)?we.length:0,Ye=JSON.stringify(r.filters)!==E;(Ce===0||Ce!==r.filters.length||Ye)&&j()}return await e.nextTick(),await new Promise(we=>{requestAnimationFrame(()=>we())}),!0}return a({captureFrameAt:kt,ensureReadyForCapture:xt,duration:m,pixiCanvas:e.computed(()=>v?v.canvas:null),videoElement:e.computed(()=>c.value??null)}),(we,Ce)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:d},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:c,src:I.value,onLoadedmetadata:me,onLoadeddata:ge,onCanplay:Te,onTimeupdate:he,onEnded:ye,onError:Se,style:e.normalizeStyle(X.value),crossorigin:z.value,preload:"auto",playsinline:"",controls:""},null,44,Tg),e.createElementVNode("div",Mg,[e.createElementVNode("button",{class:"play-button",onClick:Ce[0]||(Ce[0]=$e=>we.$emit("play-pause")),"aria-label":we.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(W.IonIcon),{icon:we.isPlaying?e.unref(Bu):e.unref(Iu)},null,8,["icon"])],8,Bg),e.createElementVNode("div",Ig,[e.createElementVNode("span",Fg,e.toDisplayString(et(we.playhead)),1),Ce[1]||(Ce[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",$g,e.toDisplayString(et(m.value)),1)]),we.showFps?(e.openBlock(),e.createElementBlock("div",Dg,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",Rg,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"}),Ce[2]||(Ce[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",Ag,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(jl)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:gt},"Retry")])):e.createCommentVNode("",!0)],512))}}),tl=Be(Pg,[["__scopeId","data-v-dd1744f4"]]);var Hl=(n,a,t)=>{if(!a.has(n))throw TypeError("Cannot "+t)},J=(n,a,t)=>(Hl(n,a,"read from private field"),t?t.call(n):a.get(n)),Je=(n,a,t)=>{if(a.has(n))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(n):a.set(n,t)},Wt=(n,a,t,o)=>(Hl(n,a,"write to private field"),a.set(n,t),t),Og=(n,a,t,o)=>({set _(i){Wt(n,a,i)},get _(){return J(n,a,o)}}),Qe=(n,a,t)=>(Hl(n,a,"access private method"),t),tt=new Uint8Array(8),Ha=new DataView(tt.buffer),Pt=n=>[(n%256+256)%256],st=n=>(Ha.setUint16(0,n,!1),[tt[0],tt[1]]),Ug=n=>(Ha.setInt16(0,n,!1),[tt[0],tt[1]]),Au=n=>(Ha.setUint32(0,n,!1),[tt[1],tt[2],tt[3]]),Ae=n=>(Ha.setUint32(0,n,!1),[tt[0],tt[1],tt[2],tt[3]]),zg=n=>(Ha.setInt32(0,n,!1),[tt[0],tt[1],tt[2],tt[3]]),zn=n=>(Ha.setUint32(0,Math.floor(n/2**32),!1),Ha.setUint32(4,n,!1),[tt[0],tt[1],tt[2],tt[3],tt[4],tt[5],tt[6],tt[7]]),Xl=n=>(Ha.setInt16(0,2**8*n,!1),[tt[0],tt[1]]),ja=n=>(Ha.setInt32(0,2**16*n,!1),[tt[0],tt[1],tt[2],tt[3]]),Fs=n=>(Ha.setInt32(0,2**30*n,!1),[tt[0],tt[1],tt[2],tt[3]]),_a=(n,a=!1)=>{let t=Array(n.length).fill(null).map((o,i)=>n.charCodeAt(i));return a&&t.push(0),t},kr=n=>n&&n[n.length-1],Gl=n=>{let a;for(let t of n)(!a||t.presentationTimestamp>a.presentationTimestamp)&&(a=t);return a},Za=(n,a,t=!0)=>{let o=n*a;return t?Math.round(o):o},Lu=n=>{let a=n*(Math.PI/180),t=Math.cos(a),o=Math.sin(a);return[t,o,0,-o,t,0,0,0,1]},Pu=Lu(0),Ou=n=>[ja(n[0]),ja(n[1]),Fs(n[2]),ja(n[3]),ja(n[4]),Fs(n[5]),ja(n[6]),ja(n[7]),Fs(n[8])],ai=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(ai):Object.fromEntries(Object.entries(n).map(([a,t])=>[a,ai(t)])),go=n=>n>=0&&n<2**32,At=(n,a,t)=>({type:n,contents:a&&new Uint8Array(a.flat(10)),children:t}),Et=(n,a,t,o,i)=>At(n,[Pt(a),Au(t),o??[]],i),jg=n=>{let a=512;return n.fragmented?At("ftyp",[_a("iso5"),Ae(a),_a("iso5"),_a("iso6"),_a("mp41")]):At("ftyp",[_a("isom"),Ae(a),_a("isom"),n.holdsAvc?_a("avc1"):[],_a("mp41")])},al=n=>({type:"mdat",largeSize:n}),Wg=n=>({type:"free",size:n}),sr=(n,a,t=!1)=>At("moov",null,[Zg(a,n),...n.map(o=>Hg(o,a)),t?E0(n):null]),Zg=(n,a)=>{let t=Za(Math.max(0,...a.filter(s=>s.samples.length>0).map(s=>{const l=Gl(s.samples);return l.presentationTimestamp+l.duration})),il),o=Math.max(...a.map(s=>s.id))+1,i=!go(n)||!go(t),r=i?zn:Ae;return Et("mvhd",+i,0,[r(n),r(n),Ae(il),r(t),ja(1),Xl(1),Array(10).fill(0),Ou(Pu),Array(24).fill(0),Ae(o)])},Hg=(n,a)=>At("trak",null,[Xg(n,a),Gg(n,a)]),Xg=(n,a)=>{let t=Gl(n.samples),o=Za(t?t.presentationTimestamp+t.duration:0,il),i=!go(a)||!go(o),r=i?zn:Ae,s;return n.info.type==="video"?s=typeof n.info.rotation=="number"?Lu(n.info.rotation):n.info.rotation:s=Pu,Et("tkhd",+i,3,[r(a),r(a),Ae(n.id),Ae(0),r(o),Array(8).fill(0),st(0),st(0),Xl(n.info.type==="audio"?1:0),st(0),Ou(s),ja(n.info.type==="video"?n.info.width:0),ja(n.info.type==="video"?n.info.height:0)])},Gg=(n,a)=>At("mdia",null,[Jg(n,a),Kg(n.info.type==="video"?"vide":"soun"),qg(n)]),Jg=(n,a)=>{let t=Gl(n.samples),o=Za(t?t.presentationTimestamp+t.duration:0,n.timescale),i=!go(a)||!go(o),r=i?zn:Ae;return Et("mdhd",+i,0,[r(a),r(a),Ae(n.timescale),r(o),st(21956),st(0)])},Kg=n=>Et("hdlr",0,0,[_a("mhlr"),_a(n),Ae(0),Ae(0),Ae(0),_a("mp4-muxer-hdlr",!0)]),qg=n=>At("minf",null,[n.info.type==="video"?Yg():Qg(),e0(),n0(n)]),Yg=()=>Et("vmhd",0,1,[st(0),st(0),st(0),st(0)]),Qg=()=>Et("smhd",0,0,[st(0),st(0)]),e0=()=>At("dinf",null,[t0()]),t0=()=>Et("dref",0,0,[Ae(1)],[a0()]),a0=()=>Et("url ",0,1),n0=n=>{const a=n.compositionTimeOffsetTable.length>1||n.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return At("stbl",null,[o0(n),g0(n),y0(n),b0(n),w0(n),k0(n),a?_0(n):null])},o0=n=>Et("stsd",0,0,[Ae(1)],[n.info.type==="video"?i0(F0[n.info.codec],n):f0(D0[n.info.codec],n)]),i0=(n,a)=>At(n,[Array(6).fill(0),st(1),st(0),st(0),Array(12).fill(0),st(a.info.width),st(a.info.height),Ae(4718592),Ae(4718592),Ae(0),st(1),Array(32).fill(0),st(24),Ug(65535)],[$0[a.info.codec](a),a.info.decoderConfig.colorSpace?d0(a):null]),r0={bt709:1,bt470bg:5,smpte170m:6},s0={bt709:1,smpte170m:6,"iec61966-2-1":13},l0={rgb:0,bt709:1,bt470bg:5,smpte170m:6},d0=n=>At("colr",[_a("nclx"),st(r0[n.info.decoderConfig.colorSpace.primaries]),st(s0[n.info.decoderConfig.colorSpace.transfer]),st(l0[n.info.decoderConfig.colorSpace.matrix]),Pt((n.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),c0=n=>n.info.decoderConfig&&At("avcC",[...new Uint8Array(n.info.decoderConfig.description)]),u0=n=>n.info.decoderConfig&&At("hvcC",[...new Uint8Array(n.info.decoderConfig.description)]),m0=n=>{if(!n.info.decoderConfig)return null;let a=n.info.decoderConfig;if(!a.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=a.codec.split("."),o=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(a.colorSpace.fullRange);return Et("vpcC",1,0,[Pt(o),Pt(i),Pt(l),Pt(2),Pt(2),Pt(2),st(0)])},p0=()=>{let t=(1<<7)+1;return At("av1C",[t,0,0,0])},f0=(n,a)=>At(n,[Array(6).fill(0),st(1),st(0),st(0),Ae(0),st(a.info.numberOfChannels),st(16),st(0),st(0),ja(a.info.sampleRate)],[R0[a.info.codec](a)]),h0=n=>{let a=new Uint8Array(n.info.decoderConfig.description);return Et("esds",0,0,[Ae(58753152),Pt(32+a.byteLength),st(1),Pt(0),Ae(75530368),Pt(18+a.byteLength),Pt(64),Pt(21),Au(0),Ae(130071),Ae(130071),Ae(92307584),Pt(a.byteLength),...a,Ae(109084800),Pt(1),Pt(2)])},v0=n=>{var i;let a=3840,t=0;const o=(i=n.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);a=r.getUint16(10,!0),t=r.getInt16(14,!0)}return At("dOps",[Pt(0),Pt(n.info.numberOfChannels),st(a),Ae(n.info.sampleRate),Xl(t),Pt(0)])},g0=n=>Et("stts",0,0,[Ae(n.timeToSampleTable.length),n.timeToSampleTable.map(a=>[Ae(a.sampleCount),Ae(a.sampleDelta)])]),y0=n=>{if(n.samples.every(t=>t.type==="key"))return null;let a=[...n.samples.entries()].filter(([,t])=>t.type==="key");return Et("stss",0,0,[Ae(a.length),a.map(([t])=>Ae(t+1))])},b0=n=>Et("stsc",0,0,[Ae(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(a=>[Ae(a.firstChunk),Ae(a.samplesPerChunk),Ae(1)])]),w0=n=>Et("stsz",0,0,[Ae(0),Ae(n.samples.length),n.samples.map(a=>Ae(a.size))]),k0=n=>n.finalizedChunks.length>0&&kr(n.finalizedChunks).offset>=2**32?Et("co64",0,0,[Ae(n.finalizedChunks.length),n.finalizedChunks.map(a=>zn(a.offset))]):Et("stco",0,0,[Ae(n.finalizedChunks.length),n.finalizedChunks.map(a=>Ae(a.offset))]),_0=n=>Et("ctts",0,0,[Ae(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(a=>[Ae(a.sampleCount),Ae(a.sampleCompositionTimeOffset)])]),E0=n=>At("mvex",null,n.map(x0)),x0=n=>Et("trex",0,0,[Ae(n.id),Ae(1),Ae(0),Ae(0),Ae(0)]),Yd=(n,a)=>At("moof",null,[S0(n),...a.map(C0)]),S0=n=>Et("mfhd",0,0,[Ae(n)]),Uu=n=>{let a=0,t=0,o=0,i=0,r=n.type==="delta";return t|=+r,r?a|=1:a|=2,a<<24|t<<16|o<<8|i},C0=n=>At("traf",null,[V0(n),N0(n),T0(n)]),V0=n=>{let a=0;a|=8,a|=16,a|=32,a|=131072;let t=n.currentChunk.samples[1]??n.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:Uu(t)};return Et("tfhd",0,a,[Ae(n.id),Ae(o.duration),Ae(o.size),Ae(o.flags)])},N0=n=>Et("tfdt",1,0,[zn(Za(n.currentChunk.startTimestamp,n.timescale))]),T0=n=>{let a=n.currentChunk.samples.map(v=>v.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(v=>v.size),o=n.currentChunk.samples.map(Uu),i=n.currentChunk.samples.map(v=>Za(v.presentationTimestamp-v.decodeTimestamp,n.timescale)),r=new Set(a),s=new Set(t),l=new Set(o),d=new Set(i),c=l.size===2&&o[0]!==o[1],u=r.size>1,f=s.size>1,m=!c&&l.size>1,p=d.size>1||[...d].some(v=>v!==0),h=0;return h|=1,h|=4*+c,h|=256*+u,h|=512*+f,h|=1024*+m,h|=2048*+p,Et("trun",1,h,[Ae(n.currentChunk.samples.length),Ae(n.currentChunk.offset-n.currentChunk.moofOffset||0),c?Ae(o[0]):[],n.currentChunk.samples.map((v,k)=>[u?Ae(a[k]):[],f?Ae(t[k]):[],m?Ae(o[k]):[],p?zg(i[k]):[]])])},M0=n=>At("mfra",null,[...n.map(B0),I0()]),B0=(n,a)=>Et("tfra",1,0,[Ae(n.id),Ae(63),Ae(n.finalizedChunks.length),n.finalizedChunks.map(o=>[zn(Za(o.startTimestamp,n.timescale)),zn(o.moofOffset),Ae(a+1),Ae(1),Ae(1)])]),I0=()=>Et("mfro",0,0,[Ae(0)]),F0={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},$0={avc:c0,hevc:u0,vp9:m0,av1:p0},D0={aac:"mp4a",opus:"Opus"},R0={aac:h0,opus:v0},Or=class{},Jl=class extends Or{constructor(){super(...arguments),this.buffer=null}},zu=class extends Or{constructor(n){if(super(),this.options=n,typeof n!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(n.onData){if(typeof n.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(n.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(n.chunked!==void 0&&typeof n.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},A0=class extends Or{constructor(n,a){if(super(),this.stream=n,this.options=a,!(n instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(a!==void 0&&typeof a!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(a&&a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},Mn,co,ju=class{constructor(){this.pos=0,Je(this,Mn,new Uint8Array(8)),Je(this,co,new DataView(J(this,Mn).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){J(this,co).setUint32(0,n,!1),this.write(J(this,Mn).subarray(0,4))}writeU64(n){J(this,co).setUint32(0,Math.floor(n/2**32),!1),J(this,co).setUint32(4,n,!1),this.write(J(this,Mn).subarray(0,8))}writeAscii(n){for(let a=0;a<n.length;a++)J(this,co).setUint8(a%8,n.charCodeAt(a)),a%8===7&&this.write(J(this,Mn));n.length%8!==0&&this.write(J(this,Mn).subarray(0,n.length%8))}writeBox(n){if(this.offsets.set(n,this.pos),n.contents&&!n.children)this.writeBoxHeader(n,n.size??n.contents.byteLength+8),this.write(n.contents);else{let a=this.pos;if(this.writeBoxHeader(n,0),n.contents&&this.write(n.contents),n.children)for(let i of n.children)i&&this.writeBox(i);let t=this.pos,o=n.size??t-a;this.seek(a),this.writeBoxHeader(n,o),this.seek(t)}}writeBoxHeader(n,a){this.writeU32(n.largeSize?1:a),this.writeAscii(n.type),n.largeSize&&this.writeU64(a)}measureBoxHeader(n){return 8+(n.largeSize?8:0)}patchBox(n){let a=this.pos;this.seek(this.offsets.get(n)),this.writeBox(n),this.seek(a)}measureBox(n){if(n.contents&&!n.children)return this.measureBoxHeader(n)+n.contents.byteLength;{let a=this.measureBoxHeader(n);if(n.contents&&(a+=n.contents.byteLength),n.children)for(let t of n.children)t&&(a+=this.measureBox(t));return a}}};Mn=new WeakMap;co=new WeakMap;var lr,Pn,pi,Yo,dr,nl,L0=class extends ju{constructor(n){super(),Je(this,dr),Je(this,lr,void 0),Je(this,Pn,new ArrayBuffer(2**16)),Je(this,pi,new Uint8Array(J(this,Pn))),Je(this,Yo,0),Wt(this,lr,n)}write(n){Qe(this,dr,nl).call(this,this.pos+n.byteLength),J(this,pi).set(n,this.pos),this.pos+=n.byteLength,Wt(this,Yo,Math.max(J(this,Yo),this.pos))}finalize(){Qe(this,dr,nl).call(this,this.pos),J(this,lr).buffer=J(this,Pn).slice(0,Math.max(J(this,Yo),this.pos))}};lr=new WeakMap;Pn=new WeakMap;pi=new WeakMap;Yo=new WeakMap;dr=new WeakSet;nl=function(n){let a=J(this,Pn).byteLength;for(;a<n;)a*=2;if(a===J(this,Pn).byteLength)return;let t=new ArrayBuffer(a),o=new Uint8Array(t);o.set(J(this,pi),0),Wt(this,Pn,t),Wt(this,pi,o)};var P0=2**24,O0=2,ni,Bn,Qo,Ya,ba,_r,ol,Kl,Wu,ql,Zu,oi,Er,Yl=class extends ju{constructor(n){var a,t;super(),Je(this,_r),Je(this,Kl),Je(this,ql),Je(this,oi),Je(this,ni,void 0),Je(this,Bn,[]),Je(this,Qo,void 0),Je(this,Ya,void 0),Je(this,ba,[]),Wt(this,ni,n),Wt(this,Qo,((a=n.options)==null?void 0:a.chunked)??!1),Wt(this,Ya,((t=n.options)==null?void 0:t.chunkSize)??P0)}write(n){J(this,Bn).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){var t,o;if(J(this,Bn).length===0)return;let n=[],a=[...J(this,Bn)].sort((i,r)=>i.start-r.start);n.push({start:a[0].start,size:a[0].data.byteLength});for(let i=1;i<a.length;i++){let r=n[n.length-1],s=a[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):n.push({start:s.start,size:s.data.byteLength})}for(let i of n){i.data=new Uint8Array(i.size);for(let r of J(this,Bn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);J(this,Qo)?(Qe(this,_r,ol).call(this,i.data,i.start),Qe(this,oi,Er).call(this)):(o=(t=J(this,ni).options).onData)==null||o.call(t,i.data,i.start)}J(this,Bn).length=0}finalize(){J(this,Qo)&&Qe(this,oi,Er).call(this,!0)}};ni=new WeakMap;Bn=new WeakMap;Qo=new WeakMap;Ya=new WeakMap;ba=new WeakMap;_r=new WeakSet;ol=function(n,a){let t=J(this,ba).findIndex(l=>l.start<=a&&a<l.start+J(this,Ya));t===-1&&(t=Qe(this,ql,Zu).call(this,a));let o=J(this,ba)[t],i=a-o.start,r=n.subarray(0,Math.min(J(this,Ya)-i,n.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Qe(this,Kl,Wu).call(this,o,s),o.written[0].start===0&&o.written[0].end===J(this,Ya)&&(o.shouldFlush=!0),J(this,ba).length>O0){for(let l=0;l<J(this,ba).length-1;l++)J(this,ba)[l].shouldFlush=!0;Qe(this,oi,Er).call(this)}r.byteLength<n.byteLength&&Qe(this,_r,ol).call(this,n.subarray(r.byteLength),a+r.byteLength)};Kl=new WeakSet;Wu=function(n,a){let t=0,o=n.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);n.written[r].start<=a.start?(t=r+1,i=r):o=r-1}for(n.written.splice(i+1,0,a),(i===-1||n.written[i].end<a.start)&&i++;i<n.written.length-1&&n.written[i].end>=n.written[i+1].start;)n.written[i].end=Math.max(n.written[i].end,n.written[i+1].end),n.written.splice(i+1,1)};ql=new WeakSet;Zu=function(n){let t={start:Math.floor(n/J(this,Ya))*J(this,Ya),data:new Uint8Array(J(this,Ya)),written:[],shouldFlush:!1};return J(this,ba).push(t),J(this,ba).sort((o,i)=>o.start-i.start),J(this,ba).indexOf(t)};oi=new WeakSet;Er=function(n=!1){var a,t;for(let o=0;o<J(this,ba).length;o++){let i=J(this,ba)[o];if(!(!i.shouldFlush&&!n)){for(let r of i.written)(t=(a=J(this,ni).options).onData)==null||t.call(a,i.data.subarray(r.start,r.end),i.start+r.start);J(this,ba).splice(o--,1)}}};var U0=class extends Yl{constructor(n){var a;super(new zu({onData:(t,o)=>n.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(a=n.options)==null?void 0:a.chunkSize}))}},il=1e3,z0=["avc","hevc","vp9","av1"],j0=["aac","opus"],W0=2082844800,Z0=["strict","offset","cross-track-offset"],Ue,je,xr,ga,Xt,jt,uo,mo,Ql,In,Fn,ii,rl,Hu,sl,Xu,ed,Gu,ll,Ju,td,Ku,cr,dl,za,qa,ad,qu,ri,Sr,Cr,nd,yo,wi,ur,cl,Yu=class{constructor(n){if(Je(this,rl),Je(this,sl),Je(this,ed),Je(this,ll),Je(this,td),Je(this,cr),Je(this,za),Je(this,ad),Je(this,ri),Je(this,Cr),Je(this,yo),Je(this,ur),Je(this,Ue,void 0),Je(this,je,void 0),Je(this,xr,void 0),Je(this,ga,void 0),Je(this,Xt,null),Je(this,jt,null),Je(this,uo,Math.floor(Date.now()/1e3)+W0),Je(this,mo,[]),Je(this,Ql,1),Je(this,In,[]),Je(this,Fn,[]),Je(this,ii,!1),Qe(this,rl,Hu).call(this,n),n.video=ai(n.video),n.audio=ai(n.audio),n.fastStart=ai(n.fastStart),this.target=n.target,Wt(this,Ue,{firstTimestampBehavior:"strict",...n}),n.target instanceof Jl)Wt(this,je,new L0(n.target));else if(n.target instanceof zu)Wt(this,je,new Yl(n.target));else if(n.target instanceof A0)Wt(this,je,new U0(n.target));else throw new Error(`Invalid target: ${n.target}`);Qe(this,ll,Ju).call(this),Qe(this,sl,Xu).call(this)}addVideoChunk(n,a,t,o){if(!(n instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(a&&typeof a!="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(n.byteLength);n.copyTo(i),this.addVideoChunkRaw(i,n.type,t??n.timestamp,n.duration,a,o)}addVideoChunkRaw(n,a,t,o,i,r){if(!(n instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(a!=="key"&&a!=="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(Qe(this,ur,cl).call(this),!J(this,Ue).video)throw new Error("No video track declared.");if(typeof J(this,Ue).fastStart=="object"&&J(this,Xt).samples.length===J(this,Ue).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${J(this,Ue).fastStart.expectedVideoChunks}).`);let s=Qe(this,cr,dl).call(this,J(this,Xt),n,a,t,o,i,r);if(J(this,Ue).fastStart==="fragmented"&&J(this,jt)){for(;J(this,Fn).length>0&&J(this,Fn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=J(this,Fn).shift();Qe(this,za,qa).call(this,J(this,jt),l)}s.decodeTimestamp<=J(this,jt).lastDecodeTimestamp?Qe(this,za,qa).call(this,J(this,Xt),s):J(this,In).push(s)}else Qe(this,za,qa).call(this,J(this,Xt),s)}addAudioChunk(n,a,t){if(!(n instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(a&&typeof a!="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(n.byteLength);n.copyTo(o),this.addAudioChunkRaw(o,n.type,t??n.timestamp,n.duration,a)}addAudioChunkRaw(n,a,t,o,i){if(!(n instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(a!=="key"&&a!=="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(Qe(this,ur,cl).call(this),!J(this,Ue).audio)throw new Error("No audio track declared.");if(typeof J(this,Ue).fastStart=="object"&&J(this,jt).samples.length===J(this,Ue).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${J(this,Ue).fastStart.expectedAudioChunks}).`);let r=Qe(this,cr,dl).call(this,J(this,jt),n,a,t,o,i);if(J(this,Ue).fastStart==="fragmented"&&J(this,Xt)){for(;J(this,In).length>0&&J(this,In)[0].decodeTimestamp<=r.decodeTimestamp;){let s=J(this,In).shift();Qe(this,za,qa).call(this,J(this,Xt),s)}r.decodeTimestamp<=J(this,Xt).lastDecodeTimestamp?Qe(this,za,qa).call(this,J(this,jt),r):J(this,Fn).push(r)}else Qe(this,za,qa).call(this,J(this,jt),r)}finalize(){if(J(this,ii))throw new Error("Cannot finalize a muxer more than once.");if(J(this,Ue).fastStart==="fragmented"){for(let a of J(this,In))Qe(this,za,qa).call(this,J(this,Xt),a);for(let a of J(this,Fn))Qe(this,za,qa).call(this,J(this,jt),a);Qe(this,Cr,nd).call(this,!1)}else J(this,Xt)&&Qe(this,ri,Sr).call(this,J(this,Xt)),J(this,jt)&&Qe(this,ri,Sr).call(this,J(this,jt));let n=[J(this,Xt),J(this,jt)].filter(Boolean);if(J(this,Ue).fastStart==="in-memory"){let a;for(let o=0;o<2;o++){let i=sr(n,J(this,uo)),r=J(this,je).measureBox(i);a=J(this,je).measureBox(J(this,ga));let s=J(this,je).pos+r+a;for(let l of J(this,mo)){l.offset=s;for(let{data:d}of l.samples)s+=d.byteLength,a+=d.byteLength}if(s<2**32)break;a>=2**32&&(J(this,ga).largeSize=!0)}let t=sr(n,J(this,uo));J(this,je).writeBox(t),J(this,ga).size=a,J(this,je).writeBox(J(this,ga));for(let o of J(this,mo))for(let i of o.samples)J(this,je).write(i.data),i.data=null}else if(J(this,Ue).fastStart==="fragmented"){let a=J(this,je).pos,t=M0(n);J(this,je).writeBox(t);let o=J(this,je).pos-a;J(this,je).seek(J(this,je).pos-4),J(this,je).writeU32(o)}else{let a=J(this,je).offsets.get(J(this,ga)),t=J(this,je).pos-a;J(this,ga).size=t,J(this,ga).largeSize=t>=2**32,J(this,je).patchBox(J(this,ga));let o=sr(n,J(this,uo));if(typeof J(this,Ue).fastStart=="object"){J(this,je).seek(J(this,xr)),J(this,je).writeBox(o);let i=a-J(this,je).pos;J(this,je).writeBox(Wg(i))}else J(this,je).writeBox(o)}Qe(this,yo,wi).call(this),J(this,je).finalize(),Wt(this,ii,!0)}};Ue=new WeakMap;je=new WeakMap;xr=new WeakMap;ga=new WeakMap;Xt=new WeakMap;jt=new WeakMap;uo=new WeakMap;mo=new WeakMap;Ql=new WeakMap;In=new WeakMap;Fn=new WeakMap;ii=new WeakMap;rl=new WeakSet;Hu=function(n){if(typeof n!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(n.target instanceof Or))throw new TypeError("The target must be provided and an instance of Target.");if(n.video){if(!z0.includes(n.video.codec))throw new TypeError(`Unsupported video codec: ${n.video.codec}`);if(!Number.isInteger(n.video.width)||n.video.width<=0)throw new TypeError(`Invalid video width: ${n.video.width}. Must be a positive integer.`);if(!Number.isInteger(n.video.height)||n.video.height<=0)throw new TypeError(`Invalid video height: ${n.video.height}. Must be a positive integer.`);const a=n.video.rotation;if(typeof a=="number"&&![0,90,180,270].includes(a))throw new TypeError(`Invalid video rotation: ${a}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(a)&&(a.length!==9||a.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${a.join()}`);if(n.video.frameRate!==void 0&&(!Number.isInteger(n.video.frameRate)||n.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${n.video.frameRate}. Must be a positive integer.`)}if(n.audio){if(!j0.includes(n.audio.codec))throw new TypeError(`Unsupported audio codec: ${n.audio.codec}`);if(!Number.isInteger(n.audio.numberOfChannels)||n.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${n.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(n.audio.sampleRate)||n.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${n.audio.sampleRate}. Must be a positive integer.`)}if(n.firstTimestampBehavior&&!Z0.includes(n.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${n.firstTimestampBehavior}`);if(typeof n.fastStart=="object"){if(n.video){if(n.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(n.fastStart.expectedVideoChunks)||n.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(n.audio){if(n.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(n.fastStart.expectedAudioChunks)||n.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(n.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(n.minFragmentDuration!==void 0&&(!Number.isFinite(n.minFragmentDuration)||n.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};sl=new WeakSet;Xu=function(){var n;if(J(this,je).writeBox(jg({holdsAvc:((n=J(this,Ue).video)==null?void 0:n.codec)==="avc",fragmented:J(this,Ue).fastStart==="fragmented"})),Wt(this,xr,J(this,je).pos),J(this,Ue).fastStart==="in-memory")Wt(this,ga,al(!1));else if(J(this,Ue).fastStart!=="fragmented"){if(typeof J(this,Ue).fastStart=="object"){let a=Qe(this,ed,Gu).call(this);J(this,je).seek(J(this,je).pos+a)}Wt(this,ga,al(!0)),J(this,je).writeBox(J(this,ga))}Qe(this,yo,wi).call(this)};ed=new WeakSet;Gu=function(){if(typeof J(this,Ue).fastStart!="object")return;let n=0,a=[J(this,Ue).fastStart.expectedVideoChunks,J(this,Ue).fastStart.expectedAudioChunks];for(let t of a)t&&(n+=8*Math.ceil(2/3*t),n+=4*t,n+=12*Math.ceil(2/3*t),n+=4*t,n+=8*t);return n+=4096,n};ll=new WeakSet;Ju=function(){if(J(this,Ue).video&&Wt(this,Xt,{id:1,info:{type:"video",codec:J(this,Ue).video.codec,width:J(this,Ue).video.width,height:J(this,Ue).video.height,rotation:J(this,Ue).video.rotation??0,decoderConfig:null},timescale:J(this,Ue).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),J(this,Ue).audio&&(Wt(this,jt,{id:J(this,Ue).video?2:1,info:{type:"audio",codec:J(this,Ue).audio.codec,numberOfChannels:J(this,Ue).audio.numberOfChannels,sampleRate:J(this,Ue).audio.sampleRate,decoderConfig:null},timescale:J(this,Ue).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),J(this,Ue).audio.codec==="aac")){let n=Qe(this,td,Ku).call(this,2,J(this,Ue).audio.sampleRate,J(this,Ue).audio.numberOfChannels);J(this,jt).info.decoderConfig={codec:J(this,Ue).audio.codec,description:n,numberOfChannels:J(this,Ue).audio.numberOfChannels,sampleRate:J(this,Ue).audio.sampleRate}}};td=new WeakSet;Ku=function(n,a,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(a),r=t,s="";s+=n.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=a.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 d=new Uint8Array(s.length/8);for(let c=0;c<s.length;c+=8)d[c/8]=parseInt(s.slice(c,c+8),2);return d};cr=new WeakSet;dl=function(n,a,t,o,i,r,s){let l=o/1e6,d=(o-(s??0))/1e6,c=i/1e6,u=Qe(this,ad,qu).call(this,l,d,n);return l=u.presentationTimestamp,d=u.decodeTimestamp,r!=null&&r.decoderConfig&&(n.info.decoderConfig===null?n.info.decoderConfig=r.decoderConfig:Object.assign(n.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:d,duration:c,data:a,size:a.byteLength,type:t,timescaleUnitsToNextSample:Za(c,n.timescale)}};za=new WeakSet;qa=function(n,a){J(this,Ue).fastStart!=="fragmented"&&n.samples.push(a);const t=Za(a.presentationTimestamp-a.decodeTimestamp,n.timescale);if(n.lastTimescaleUnits!==null){let i=Za(a.decodeTimestamp,n.timescale,!1),r=Math.round(i-n.lastTimescaleUnits);if(n.lastTimescaleUnits+=r,n.lastSample.timescaleUnitsToNextSample=r,J(this,Ue).fastStart!=="fragmented"){let s=kr(n.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,n.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=kr(n.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else n.lastTimescaleUnits=0,J(this,Ue).fastStart!=="fragmented"&&(n.timeToSampleTable.push({sampleCount:1,sampleDelta:Za(a.duration,n.timescale)}),n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));n.lastSample=a;let o=!1;if(!n.currentChunk)o=!0;else{let i=a.presentationTimestamp-n.currentChunk.startTimestamp;if(J(this,Ue).fastStart==="fragmented"){let r=J(this,Xt)??J(this,jt);const s=J(this,Ue).minFragmentDuration??1;n===r&&a.type==="key"&&i>=s&&(o=!0,Qe(this,Cr,nd).call(this))}else o=i>=.5}o&&(n.currentChunk&&Qe(this,ri,Sr).call(this,n),n.currentChunk={startTimestamp:a.presentationTimestamp,samples:[]}),n.currentChunk.samples.push(a)};ad=new WeakSet;qu=function(n,a,t){var s,l;const o=J(this,Ue).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&a!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${a}).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(J(this,Ue).firstTimestampBehavior==="offset"||J(this,Ue).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=a);let d;J(this,Ue).firstTimestampBehavior==="offset"?d=t.firstDecodeTimestamp:d=Math.min(((s=J(this,Xt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=J(this,jt))==null?void 0:l.firstDecodeTimestamp)??1/0),a-=d,n-=d}if(a<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${a*1e6}).`);return t.lastDecodeTimestamp=a,{presentationTimestamp:n,decodeTimestamp:a}};ri=new WeakSet;Sr=function(n){if(J(this,Ue).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(n.currentChunk){if(n.finalizedChunks.push(n.currentChunk),J(this,mo).push(n.currentChunk),(n.compactlyCodedChunkTable.length===0||kr(n.compactlyCodedChunkTable).samplesPerChunk!==n.currentChunk.samples.length)&&n.compactlyCodedChunkTable.push({firstChunk:n.finalizedChunks.length,samplesPerChunk:n.currentChunk.samples.length}),J(this,Ue).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=J(this,je).pos;for(let a of n.currentChunk.samples)J(this,je).write(a.data),a.data=null;Qe(this,yo,wi).call(this)}};Cr=new WeakSet;nd=function(n=!0){if(J(this,Ue).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let a=[J(this,Xt),J(this,jt)].filter(l=>l&&l.currentChunk);if(a.length===0)return;let t=Og(this,Ql)._++;if(t===1){let l=sr(a,J(this,uo),!0);J(this,je).writeBox(l)}let o=J(this,je).pos,i=Yd(t,a);J(this,je).writeBox(i);{let l=al(!1),d=0;for(let u of a)for(let f of u.currentChunk.samples)d+=f.size;let c=J(this,je).measureBox(l)+d;c>=2**32&&(l.largeSize=!0,c=J(this,je).measureBox(l)+d),l.size=c,J(this,je).writeBox(l)}for(let l of a){l.currentChunk.offset=J(this,je).pos,l.currentChunk.moofOffset=o;for(let d of l.currentChunk.samples)J(this,je).write(d.data),d.data=null}let r=J(this,je).pos;J(this,je).seek(J(this,je).offsets.get(i));let s=Yd(t,a);J(this,je).writeBox(s),J(this,je).seek(r);for(let l of a)l.finalizedChunks.push(l.currentChunk),J(this,mo).push(l.currentChunk),l.currentChunk=null;n&&Qe(this,yo,wi).call(this)};yo=new WeakSet;wi=function(){J(this,je)instanceof Yl&&J(this,je).flush()};ur=new WeakSet;cl=function(){if(J(this,ii))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const fi=30;class bo extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);Y(this,"message");Y(this,"code");this.code=o,this.message=t}}class Qa extends bo{}class Rt extends bo{}class Vr extends bo{}class Qd extends bo{}function H0(n,a=fi){if(a<1)throw new Rt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n*a)}function po(n,a=fi){if(a<1)throw new Rt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n/a*1e3)}class Ie{constructor(a=0){Y(this,"time");this.time=Math.round(a)}get millis(){return this.time}set millis(a){this.time=Math.round(a)}get frames(){return H0(this.millis/1e3)}set frames(a){this.millis=po(a)}get seconds(){return this.millis/1e3}set seconds(a){this.millis=a*1e3}addMillis(a){return this.millis=this.millis+a,this}addFrames(a){const t=po(a);return this.millis=this.millis+t,this}add(a){return new Ie(a.millis+this.millis)}subtract(a){return new Ie(this.millis-a.millis)}static fromSeconds(a){const t=new Ie;return t.millis=a*1e3,t}static fromFrames(a,t){const o=new Ie;return o.millis=po(a,t),o}copy(){return new Ie(this.millis)}toJSON(){return this.millis}static fromJSON(a){return new Ie(a)}}function ec(n,a){return[n.slice(0,a),n.slice(a)].filter(t=>t.length>0)}function mr(n,a){return a?Math.floor(Math.random()*(a-n+1)+n):n}function X0(n,a,t){t<0&&(t=0);const o=n[a];n.splice(a,1),n.splice(t,0,o)}function tc(n){return typeof n!="function"?!1:/^class\s/.test(Function.prototype.toString.call(n))}function G0(n){const a=n.numberOfChannels,t=n.length,o=new Int16Array(t*a);for(let i=0;i<t;i++)for(let r=0;r<a;r++){let s=n.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*a+r]=s}return o}function J0(n,a=44100,t=2){if(n.sampleRate==a&&n.numberOfChannels==t)return n;const o=Math.floor(n.duration*a),i=new OfflineAudioContext(t,1,a).createBuffer(t,o,a);for(let r=0;r<n.numberOfChannels;r++){const s=n.getChannelData(r),l=i.getChannelData(r),d=n.sampleRate/a;for(let c=0;c<l.length;c++){const u=c*d,f=Math.floor(u),m=Math.ceil(u);if(m>=s.length)l[c]=s[f];else{const p=u-f;l[c]=s[f]*(1-p)+s[m]*p}}}return i}async function K0(n){const{fps:a,height:t,width:o,bitrate:i}=n,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const c of r)for(const u of s)l.push({codec:c,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:a});const d=[];if(!("VideoEncoder"in window))return d;for(const c of l){const u=await VideoEncoder.isConfigSupported(c);u.supported&&d.push(u.config??c)}return d.sort(q0)}function q0(n,a){const t=n.hardwareAcceleration??"",o=a.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function Y0(n,a="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=a,typeof n=="string"&&n.startsWith("data:image/svg+xml;base64,")){const o=n.split(",")[1],i=atob(o),r=new Array(i.length);for(let d=0;d<i.length;d++)r[d]=i.charCodeAt(d);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=a.split(".")[0]+".svg"}else typeof n=="string"?t.href=n:t.href=URL.createObjectURL(n);t.click(),t.remove()}function ac(n){return`${n.hours.toString().padStart(2,"0")}:${n.minutes.toString().padStart(2,"0")}:${n.seconds.toString().padStart(2,"0")},`+n.milliseconds.toString().padStart(3,"0")}function nc(n){const a=new Date(1970,0,1);return a.setSeconds(n),a.setMilliseconds(Math.round(n%1*1e3)),{hours:a.getHours(),minutes:a.getMinutes(),seconds:a.getSeconds(),milliseconds:a.getMilliseconds()}}class Hi{constructor(a){Y(this,"words",[]);a&&(this.words=a)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:a})=>a).join(" ")}get start(){var a;return((a=this.words.at(0))==null?void 0:a.start)??new Ie}get stop(){var a;return((a=this.words.at(-1))==null?void 0:a.stop)??new Ie}}var ul=(n=>(n.en="en",n.de="de",n))(ul||{});class oc{constructor(a,t,o,i){Y(this,"id",crypto.randomUUID());Y(this,"text");Y(this,"start");Y(this,"stop");Y(this,"confidence");this.text=a,this.start=new Ie(t),this.stop=new Ie(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class Dn{constructor(a=[],t=ul.en){Y(this,"id",crypto.randomUUID());Y(this,"language",ul.en);Y(this,"groups",[]);this.groups=a,this.language=t}get text(){return this.groups.map(({text:a})=>a).join(" ")}get words(){return this.groups.flatMap(({words:a})=>a)}*iter({count:a,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(a&&r.words.length>=mr(...a)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=mr(...t)?(yield r,r=void 0):o&&r.text.length>=mr(...o)&&(yield r,r=void 0)),r?r.words.push(l):r=new Hi([l]),s==i.words.length-1&&(yield r)}}optimize(){const a=this.groups.flatMap(t=>t.words);for(let t=0;t<a.length-1;t++){const o=a[t],i=a[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(a={}){let t=1,o="";for(const i of this.iter(a)){const r=nc(i.start.seconds),s=nc(i.stop.seconds);o+=`${t}
22
+ `+ac(r)+" --> "+ac(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(a=>a.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(a,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 oc(s.text,s.start.millis-o,s.stop.millis-o)),i.length==a)return new Dn([new Hi(i)]);return new Dn([new Hi(i)])}copy(){return Dn.fromJSON(this.toJSON())}static fromJSON(a){const t=new Dn;for(const o of a){const i=new Hi;for(const r of o)i.words.push(new oc(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(a,t){const o=await fetch(a,t);if(!o.ok)throw new Qa({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return Dn.fromJSON(await o.json())}}function pr(n,a,t){return n+(a-n)*t}function Q0(n,a,t){const o=Number.parseInt(n.slice(1),16),i=Number.parseInt(a.slice(1),16),r=o>>16&255,s=o>>8&255,l=o&255,d=i>>16&255,c=i>>8&255,u=i&255,f=Math.round(pr(r,d,t)),m=Math.round(pr(s,c,t)),p=Math.round(pr(l,u,t));return`#${((1<<24)+(f<<16)+(m<<8)+p).toString(16).slice(1)}`}const ey={linear:n=>n,easeIn:n=>n*n,easeOut:n=>n*(2-n),easeInOut:n=>n<.5?2*n*n:-1+(4-2*n)*n};class Oe{constructor(a,t,o={}){Y(this,"input");Y(this,"output");Y(this,"options");if(a.length!==t.length)throw new Rt({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=a.map(i=>po(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(a){const{input:t}=this;if(a<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(a-t[0])/(t[1]-t[0]),segment:0};if(a>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(a-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(a>=i&&a<=r)return{t:(a-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(a,t){const o=this.output[t],i=this.output[t+1],r=ey[this.options.easing](a);if(typeof o=="number"&&typeof i=="number")return pr(o,i,r);if(typeof o=="string"&&typeof i=="string")return Q0(o,i,r);if(this.output.length==1)return this.output[0];throw new Rt({code:"invalidKeyframes",message:"Unsupported output range types"})}value(a){const{t,segment:o}=this.normalize(typeof a=="number"?a:a.millis);return this.interpolate(t,o)}push(a,t){return this.input.push(po(a)),this.output.push(t),this}toJSON(){return this}static fromJSON(a){const t=new Oe([],[]);return Object.assign(t,a),t}}class xa{constructor(){Y(this,"id",crypto.randomUUID())}toJSON(){const a={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?a[t]=i.toJSON():a[t]=i}),a}static fromJSON(a){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(a.hasOwnProperty(o))if(i){const r=i.fromJSON(a[o]);t[o]=r}else t[o]=a[o]}),t}}function Me(n){return function(a,t){a.constructor.__serializableProperties||(a.constructor.__serializableProperties=[]),a.constructor.__serializableProperties.push({propertyKey:t,serializer:n})}}function ki(n){return class extends n{constructor(){super(...arguments);Y(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 od(n,a,t=0){if(!(n instanceof vt.Container||n instanceof vt.Filter||t==3))for(const o in n){const i=n[o];o&&(i instanceof Oe&&(n[o]=i.value(a)),i!=null&&typeof i=="object"&&Object.keys(i).length&&od(i,a,t+1))}}var ty=Object.defineProperty,Ur=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&ty(a,t,i),i};const _i=class Qu extends ki(xa){constructor(t={}){super();Y(this,"_name");Y(this,"_start",new Ie);Y(this,"_stop",Ie.fromSeconds(16));Y(this,"type","base");Y(this,"source");Y(this,"view",new vt.Container);Y(this,"createdAt",new Date);Y(this,"disabled",!1);Y(this,"state","IDLE");Y(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",Ie.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=Ie.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Rt({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Rt({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),od(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 Qu.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Ur([Me()],_i.prototype,"_name");Ur([Me(Ie)],_i.prototype,"_start");Ur([Me(Ie)],_i.prototype,"_stop");Ur([Me()],_i.prototype,"disabled");let Ei=_i;var ay=Object.defineProperty,Gn=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&ay(a,t,i),i};class Xa extends ki(xa){constructor(){super(...arguments);Y(this,"state","IDLE");Y(this,"metadata");Y(this,"objectURL");Y(this,"duration",Ie.fromSeconds(16));Y(this,"added",!1);Y(this,"type","base");Y(this,"name","");Y(this,"mimeType");Y(this,"externalURL");Y(this,"external",!1);Y(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 Rt({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=hl(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 Qa({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=hl(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();Y0(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}Gn([Me()],Xa.prototype,"objectURL");Gn([Me()],Xa.prototype,"duration");Gn([Me()],Xa.prototype,"type");Gn([Me()],Xa.prototype,"name");Gn([Me()],Xa.prototype,"mimeType");Gn([Me()],Xa.prototype,"externalURL");Gn([Me()],Xa.prototype,"external");const ic="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function ny(n){const a=new TextEncoder().encode(n);let t="";const o=a.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(a[i]);return btoa(t)}function rc(n){if(!n||!n.body)return ic;const a=n.body.scrollWidth,t=n.body.scrollHeight,o=n.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 ic;const s=new XMLSerializer,l=i?s.serializeToString(i):"",d=s.serializeToString(r),c=`
26
+ <svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${t}">
27
+ body { padding: 0; }
28
+ ${l}
29
+ <foreignObject width="100%" height="100%">
30
+ ${d}
31
+ </foreignObject>
32
+ </svg>`;return"data:image/svg+xml;base64,"+ny(c)}class sc extends Xa{constructor(){super();Y(this,"type","html");Y(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=rc(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=rc(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 oy(n,a={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=a,r=[],s=n.getChannelData(0),l=n.sampleRate,d=Math.floor(i/1e3*l);let c=null,u=0;for(let f=0;f<s.length;f+=o){let m=0;const p=Math.min(f+o,s.length);for(let h=f;h<p;h++)m+=s[h]*s[h];m=Math.sqrt(m/(p-f)),m<t?(u+=o,c===null&&(c=f)):(c!==null&&u>=d&&r.push({start:Ie.fromSeconds(c/l),stop:Ie.fromSeconds(f/l)}),c=null,u=0)}return c!==null&&u>=d&&r.push({start:Ie.fromSeconds(c/l),stop:Ie.fromSeconds(s.length/l)}),r}const $s=3e3;class fn extends Xa{constructor(){super(...arguments);Y(this,"type","audio");Y(this,"decoding",!1);Y(this,"_silences");Y(this,"transcript");Y(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,d=Math.ceil(l/t),c=r.getChannelData(0),u=[];for(let f=0;f<l;f+=d){let m=0;for(let p=f;p<f+s;p++)m+=Math.abs(c[f]);u.push(Math.log1p(m/s*100))}return u.map(f=>Math.round(f/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,$s,!0),l=s.getChannelData(0),d=Math.floor(Math.max(o*$s/1e3,0)),c=i?Math.floor(Math.min(i*$s/1e3,s.length)):s.length,u=Math.floor((c-d)/t),f=new Float32Array(t);for(let m=0;m<t;m++){const p=d+m*u,h=p+u;let v=-1/0;for(let k=p;k<h;k++){const V=l[k];V>v&&(v=V)}f[m]=r?Math.log2(1+v):v}return f}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=oy(r,t),i.close(),this._silences}}class ml extends Xa{constructor(){super(...arguments);Y(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 An extends fn{constructor(){super(...arguments);Y(this,"type","video");Y(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Qa({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=hl(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 Rt({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 iy{static fromJSON(a){return[new Ie(a[0]),new Ie(a[1])]}}var ry=Object.defineProperty,sy=Object.getOwnPropertyDescriptor,ko=(n,a,t,o)=>{for(var i=o>1?void 0:o?sy(a,t):a,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(a,t,i):s(i))||i);return o&&i&&ry(a,t,i),i};const Jn=class em extends Ei{constructor(t={}){super();Y(this,"source",new fn);Y(this,"_offset",new Ie);Y(this,"playing",!1);Y(this,"duration",new Ie);Y(this,"range",[new Ie,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=Ie.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=Ie.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",Ie.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 Qd({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=Ie.fromFrames(t)),typeof o=="number"&&(o=Ie.fromFrames(o)),t.millis>=o.millis)throw new Rt({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=em.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=Ie.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Rt({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new Qd({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),od(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 Rt({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=>lc(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(!lc(s,l.range))continue;const d=new Ie(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 c=l.copy();l.range[1]=d,c.range[0]=s.stop,r.push(c)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=d)}return r}};ko([Me(Ie)],Jn.prototype,"_offset",2);ko([Me(Ie)],Jn.prototype,"duration",2);ko([Me(iy)],Jn.prototype,"range",2);ko([Me(Dn)],Jn.prototype,"transcript",1);ko([Me()],Jn.prototype,"muted",1);ko([Me()],Jn.prototype,"volume",1);let zr=Jn;function lc(n,a){return n.start.millis>=a[0].millis&&n.start.millis<=a[1].millis||n.stop.millis<=a[1].millis&&n.stop.millis>=a[0].millis}class Xi{static fromJSON(a){return typeof a=="object"?Oe.fromJSON(a):a}}class Ds{static fromJSON(a){return typeof a.x=="object"&&(a.x=Oe.fromJSON(a.x)),typeof a.y=="object"&&(a.y=Oe.fromJSON(a.y)),a}}let ly=class{constructor(n){Y(this,"target");Y(this,"animation");this.target=n}init(n,a,t=0,o){if(!(n in this.target))throw new Error(`Property [${String(n)}] cannot be assigned`);const i=[t],r=[a];typeof this.target[n]==typeof a&&t!=0&&(i.unshift(0),r.unshift(this.target[n])),this.target[n]=this.animation=new Oe(i,r,{easing:o})}};function dy(n){const a=new Proxy(n,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Rt({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new Ie(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),a}:(i,r,s)=>(t.init(o,i,r,s),a)}});return a}class cy extends ly{}var uy=Object.defineProperty,my=Object.getOwnPropertyDescriptor,un=(n,a,t,o)=>{for(var i=o>1?void 0:o?my(a,t):a,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(a,t,i):s(i))||i);return o&&i&&uy(a,t,i),i};function jr(n){class a extends n{constructor(){super(...arguments);Y(this,"filters");Y(this,"_height");Y(this,"_width");Y(this,"_position",{x:this.view.position.x,y:this.view.position.y});Y(this,"_scale");Y(this,"rotation",this.view.angle);Y(this,"alpha",1);Y(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 Oe||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 vt.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 vt.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 dy(new cy(this))}}return un([Me(Xi)],a.prototype,"_height",2),un([Me(Xi)],a.prototype,"_width",2),un([Me(Ds)],a.prototype,"_position",2),un([Me(Ds)],a.prototype,"_scale",2),un([Me(Xi)],a.prototype,"rotation",2),un([Me(Xi)],a.prototype,"alpha",2),un([Me(Ds)],a.prototype,"translate",2),un([Me()],a.prototype,"anchor",1),a}function Wr(n,a,t){const o=t.value;return t.value=function(...i){var f,m,p,h;const r=i[0].subtract(this.start),s={width:((m=(f=this.track)==null?void 0:f.composition)==null?void 0:m.width)??1920,height:((h=(p=this.track)==null?void 0:p.composition)==null?void 0:h.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 d;typeof this.translate.y=="number"?d=this.translate.y:typeof this.translate.y=="function"?d=this.translate.y.bind(this)(r):d=this.translate.y.value(r);let c;typeof this._position.x=="number"?c=this._position.x:typeof this._position.x=="string"?c=Number.parseFloat(this._position.x)*s.width/100:typeof this._position.x=="function"?c=this._position.x.bind(this)(r):c=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(c+l,u+d),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 v;typeof this._scale.x=="number"?v=this._scale.x:typeof this._scale.x=="function"?v=this._scale.x.bind(this)(r):v=this._scale.x.value(r);let k;typeof this._scale.y=="number"?k=this._scale.y:typeof this._scale.y=="function"?k=this._scale.y.bind(this)(r):k=this._scale.y.value(r),(this._width||this._height)&&(v*=this.view.scale._x,k*=this.view.scale._y),this.view.scale.set(v,k)}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 py=Object.defineProperty,fy=Object.getOwnPropertyDescriptor,hy=(n,a,t,o)=>{for(var i=fy(a,t),r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&py(a,t,i),i};const tm=class am extends jr(Ei){constructor(t,o={}){super();Y(this,"type","image");Y(this,"element",new Image);Y(this,"source",new ml);Y(this,"sprite",new vt.Sprite);this.view.addChild(this.sprite),t instanceof ml&&(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=vt.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Qa({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=am.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};hy([Wr],tm.prototype,"update");let vy=tm;const Gi={"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 gy=Object.defineProperty,Zr=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&gy(a,t,i),i};const xi=class pl extends ki(xa){constructor(t){super();Y(this,"loaded",!1);Y(this,"family");Y(this,"weight");Y(this,"source");Y(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=pl.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(Gi).map(t=>({family:t,variants:Gi[t].weights.map(o=>({family:t,source:`url(${Gi[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new pl({family:t,source:`url(${Gi[t].url})`,weight:o})}};Zr([Me()],xi.prototype,"family");Zr([Me()],xi.prototype,"weight");Zr([Me()],xi.prototype,"source");Zr([Me()],xi.prototype,"style");let Qt=xi;const Wa=4,nm={center:.5,justify:.5,left:0,right:1},om={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var yy=Object.defineProperty,by=Object.getOwnPropertyDescriptor,ma=(n,a,t,o)=>{for(var i=by(a,t),r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&yy(a,t,i),i};const oa=class im extends jr(Ei){constructor(t){super();Y(this,"type","text");Y(this,"_text","");Y(this,"_textCase");Y(this,"_anchor",{x:0,y:0});Y(this,"_font",new Qt);Y(this,"style",new vt.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 vt.Text({text:this.transformedText,style:this.style,resolution:Wa,scale:Wa});this.view.addChild(o)}this.view.children[0]instanceof vt.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*Wa}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Wa):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=nm[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=om[t]}get fillStyle(){const{fill:t}=this.style;return new vt.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 vt.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 vt.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 vt.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=im.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)*Wa;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};ma([Me()],oa.prototype,"text");ma([Me(Qt)],oa.prototype,"font");ma([Me()],oa.prototype,"maxWidth");ma([Me()],oa.prototype,"textAlign");ma([Me()],oa.prototype,"padding");ma([Me()],oa.prototype,"textBaseline");ma([Me()],oa.prototype,"fillStyle");ma([Me()],oa.prototype,"anchor");ma([Me()],oa.prototype,"stroke");ma([Me()],oa.prototype,"textCase");ma([Me()],oa.prototype,"shadow");ma([Me()],oa.prototype,"fontSize");ma([Me()],oa.prototype,"leading");ma([Wr],oa.prototype,"update");let _o=oa;function Rs(n){const a=n.split(" ").map(t=>`${t} `);return a[a.length-1]=a[a.length-1].replace(/ $/,""),a}const wy={get(n,a){const t=n[a];return typeof t=="number"?t*Wa:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*Wa):t}};function ky(n){return new Proxy(n,wy)}class _y{constructor(){Y(this,"tokens",[])}get width(){return this.tokens.reduce((a,t)=>a+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(a=>a.metrics.lineHeight))}}class dc{constructor(){Y(this,"lines",[])}get width(){return Math.max(...this.lines.map(a=>a.width))}get height(){return this.lines.reduce((a,t)=>a+t.height,0)}}class Ey{static fromJSON(a){return a.map(t=>(t.font&&(t.font=Qt.fromJSON(t.font)),t))}}var xy=Object.defineProperty,Sy=Object.getOwnPropertyDescriptor,Eo=(n,a,t,o)=>{for(var i=o>1?void 0:o?Sy(a,t):a,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(a,t,i):s(i))||i);return o&&i&&xy(a,t,i),i};const Kn=class rm extends _o{constructor(t){super();Y(this,"type","complex_text");Y(this,"_maxWidth");Y(this,"_textAlign","left");Y(this,"_textBaseline","top");Y(this,"model",new vt.Container);Y(this,"segments",[]);Y(this,"metrics",new dc);Y(this,"background");Y(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=nm[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=om[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=rm.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:Rs(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:Rs(o.substring(t[l].start,t[l].stop))}),!((t[l].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:Rs(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 dc;for(const d of t){const c=d.index!=null?o[d.index]:this.style;for(let u=0;u<d.tokens.length;u++){const f=ky(vt.CanvasTextMetrics.measureText(d.tokens[u],c)),m=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+f.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,h=(s=d.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>p||h||!i.lines.length)&&i.lines.push(new _y),this.model.addChild(new vt.Text({text:d.tokens[u],style:c,resolution:Wa,scale:Wa})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:f,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var l,d;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=((d=this.background.padding)==null?void 0:d.y)??10,s=new vt.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)*Wa;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Eo([Me()],Kn.prototype,"background",2);Eo([Me(Ey)],Kn.prototype,"styles",2);Eo([Me()],Kn.prototype,"text",1);Eo([Me()],Kn.prototype,"maxWidth",1);Eo([Me()],Kn.prototype,"textAlign",1);Eo([Me()],Kn.prototype,"textBaseline",1);let Hr=Kn;const sm="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Cy=n=>Uint8Array.from(atob(n),a=>a.charCodeAt(0)),cc=typeof self<"u"&&self.Blob&&new Blob([Cy(sm)],{type:"text/javascript;charset=utf-8"});function Vy(n){let a;try{if(a=cc&&(self.URL||self.webkitURL).createObjectURL(cc),!a)throw"";const t=new Worker(a,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(a)}),t}catch{return new Worker("data:text/javascript;base64,"+sm,{name:n==null?void 0:n.name})}finally{a&&(self.URL||self.webkitURL).revokeObjectURL(a)}}class Ny{constructor(){Y(this,"frames",[]);Y(this,"state","active");Y(this,"onenqueue");Y(this,"onclose")}enqueue(a){var t;this.frames.unshift(a),(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 a;this.state="closed",(a=this.onclose)==null||a.call(this)}terminate(){for(const a of this.frames)a.close()}async waitFor(a){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${a} ms`)},a);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function Ty(n,a,t){const o=t.value;return t.value=function(...i){var r,s,l,d;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),!((d=(l=this.track)==null?void 0:l.composition)!=null&&d.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var My=Object.defineProperty,By=Object.getOwnPropertyDescriptor,Iy=(n,a,t,o)=>{for(var i=By(a,t),r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&My(a,t,i),i};const lm=class dm extends jr(zr){constructor(t,o={}){super();Y(this,"source",new An);Y(this,"type","video");Y(this,"worker");Y(this,"buffer");Y(this,"canvas",document.createElement("canvas"));Y(this,"context",this.canvas.getContext("2d"));Y(this,"element",document.createElement("video"));Y(this,"textrues",{html5:vt.Texture.from(this.element),canvas:vt.Texture.from(this.canvas)});Y(this,"sprite",new vt.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 An&&(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 Qa({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(Ie.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,d;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((d=(l=this.track)==null?void 0:l.composition)!=null&&d.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=dm.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 Ny,this.worker=new Vy,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)??fi}),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}};Iy([Wr,Ty],lm.prototype,"update");let fl=lm;class si extends zr{constructor(t,o={}){super();Y(this,"type","audio");Y(this,"source",new fn);Y(this,"element",new Audio);t instanceof fn&&(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 Qa({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=si.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const Fy={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 hl(n){if(!Object.keys(Fy.MIXED).includes(n??""))throw new Rt({message:`${n} is not an accepted mime type`,code:"invalid_mimetype"});return n}var $y=Object.defineProperty,Dy=Object.getOwnPropertyDescriptor,Ry=(n,a,t,o)=>{for(var i=Dy(a,t),r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&$y(a,t,i),i};const Ay=class cm extends jr(Ei){constructor(t,o={}){super();Y(this,"type","html");Y(this,"source",new sc);Y(this,"element",new Image);Y(this,"canvas",document.createElement("canvas"));Y(this,"context",this.canvas.getContext("2d"));Y(this,"sprite",new vt.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof sc&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,d,c;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(c=(d=this.source.document)==null?void 0:d.body)==null?void 0:c.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=vt.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Qa({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,d,c;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(c=(d=this.source.document)==null?void 0:d.body)==null?void 0:c.scrollHeight;if(!i||!r)return o(new Qa({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Qa({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=cm.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Ry([Wr],Ay.prototype,"update");const um=["DEFAULT","STACK"];class uc{constructor(){Y(this,"mode",um[0]);Y(this,"pauseAlignmet",!1)}add(a,t){let o=!0;for(let i=0;i<t.clips.length&&(o=fc(a,t.clips[i]),!!o);i++)pc(a,t.clips[i]);o&&(t.clips.push(a),t.clips.sort(mc))}update(a,t){if(!this.pauseAlignmet){t.clips.sort(mc);for(let o=0;o<t.clips.length;o++)if(a.id!=t.clips[o].id){if(!fc(a,t.clips[o]))break;pc(a,t.clips[o])}}}offset(a,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(a);this.pauseAlignmet=!1}}class Ly{constructor(){Y(this,"mode",um[1])}add(a,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),a.offsetBy(new Ie(i-a.start.millis+1)),o==null?t.clips.push(a):(t.clips.splice(o,0,a),t.clips.slice(o+1).forEach(s=>{s.offsetBy(a.stop.subtract(a.start))}))}update(a,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new Ie(r))}o=i.stop.millis+1}}offset(){}}function mc(n,a){return n.start.millis-a.start.millis}function pc(n,a){n.start.millis>=a.start.millis&&n.start.millis<=a.stop.millis&&(n.start=a.stop.copy().addMillis(1)),n.stop.millis>=a.start.millis&&n.stop.millis<=a.stop.millis&&(n.stop=a.start.copy().addMillis(-1))}function fc(n,a){var t,o,i,r,s;if(n.start.millis>=a.start.millis&&n.stop.millis<=a.stop.millis){const l=(o=(t=a.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(d=>d.type==n.type&&!d.clips.some(c=>n.id!=c.id&&n.start.millis>=c.start.millis&&n.stop.millis<=c.stop.millis));return l?(l.add(n.detach()),!1):((s=(r=(i=a.track)==null?void 0:i.composition)==null?void 0:r.createTrack(n.type))==null||s.add(n.detach()),!1)}return!0}class xo extends ki(xa){constructor(){super(...arguments);Y(this,"_disabled",!1);Y(this,"view",new vt.Container);Y(this,"clips",[]);Y(this,"pointer",0);Y(this,"composition");Y(this,"type","base");Y(this,"strategy",new uc)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&Ls(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 Ly,this.strategy.update(new Ei,this)):this.strategy=new uc,this.trigger("update",void 0),this}layer(t){var l,d;const o=((l=this.composition)==null?void 0:l.tracks)??[],i=o.findIndex(c=>c.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,X0(o,i,s),(d=this.composition)==null||d.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(Ie.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(Ls(this.clipRef)&&(!As(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!As(o,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,d=this.clips[l],c=this.clips[l-1];if(As(o,d)&&!d.disabled)return this.pointer=l,Ls(d)||(d.enter(),this.view.addChild(d.view)),d.update(t);if(o<d.start.millis&&o>((c==null?void 0:c.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 Ie}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new Ie}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 As(n,a){return a?n>=a.start.millis&&n<=a.stop.millis:!1}function Ls(n){return n?!!n.view.parent:!1}class Py{static fromType(a){switch(a.type){case"video":return new Oy;case"audio":return new zy;case"html":return new jy;case"image":return new Uy;case"text":return new hc;case"complex_text":return new hc;case"caption":return new Zy;default:return new xo}}}class mm extends xo{constructor(){super(...arguments);Y(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 Oy extends mm{constructor(){super(...arguments);Y(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class Uy extends xo{constructor(){super(...arguments);Y(this,"type","image")}}class zy extends mm{constructor(){super(...arguments);Y(this,"type","audio")}}class hc extends xo{constructor(){super(...arguments);Y(this,"type","text")}}class jy extends xo{constructor(){super(...arguments);Y(this,"type","html")}}var Wy=Object.defineProperty,id=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Wy(a,t,i),i};class Si extends xa{constructor(t={}){super();Y(this,"generatorOptions");Y(this,"type","CLASSIC");Y(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 Rt({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 Ie,i=await Qt.fromFamily({family:"Figtree",weight:"700"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new _o({text:d.words.map(c=>c.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:d.stop.add(o),start:d.start.add(o),scale:new Oe([0,8],[.96,1],{easing:"easeOut"}),alpha:new Oe([0,4],[0,1],{easing:"easeOut"})}))}}id([Me()],Si.prototype,"generatorOptions");id([Me()],Si.prototype,"type");id([Me()],Si.prototype,"position");class Zy extends xo{constructor(){super(...arguments);Y(this,"clip");Y(this,"type","caption");Y(this,"preset",new Si)}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 Hy=Object.defineProperty,Xr=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Hy(a,t,i),i};class Ci extends xa{constructor(t={}){super();Y(this,"generatorOptions");Y(this,"type","SPOTLIGHT");Y(this,"color");Y(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 Rt({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 Ie,i=await Qt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new Hr({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:d.words.length>1?[{index:0,start:u.slice(0,c).join(" ").length,stop:u.slice(0,c+1).join(" ").length}]:void 0,stop:d.words[c].stop.add(o),start:d.words[c].start.add(o)}))}}}Xr([Me()],Ci.prototype,"generatorOptions");Xr([Me()],Ci.prototype,"type");Xr([Me()],Ci.prototype,"color");Xr([Me()],Ci.prototype,"position");var Xy=Object.defineProperty,rd=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Xy(a,t,i),i};class Gr extends xa{constructor(t={}){super();Y(this,"type","GUINEA");Y(this,"colors");Y(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l,d,c,u,f;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Rt({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 Ie,i=await Qt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const m of t.clip.transcript.iter({length:[18]})){const{segments:p,words:h}=this.splitSequence(m);for(let v=0;v<m.words.length;v++){const k=(c=(d=h[v])==null?void 0:d.at(0))==null?void 0:c.start,V=(f=(u=h[v])==null?void 0:u.at(-1))==null?void 0:f.stop;!k||!V||await t.add(new Hr({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:V.add(o),start:k.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:mr(0,2),start:p.slice(0,v).join(" ").length,stop:p.slice(0,v+1).join(" ").length+v*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let d=i,c=i;d>0&&c<t.text.length-1;d--,c++){if(o[d].match(/ /)){r=d;break}if(o[c].match(/ /)){r=c;break}}const s=[...ec(o,r).map(d=>d.trim())],l=ec(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}rd([Me()],Gr.prototype,"type");rd([Me()],Gr.prototype,"colors");rd([Me()],Gr.prototype,"position");var Gy=Object.defineProperty,sd=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Gy(a,t,i),i};class Jr extends xa{constructor(t={}){super();Y(this,"generatorOptions");Y(this,"type","CASCADE");Y(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 Rt({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 Ie,i=await Qt.fromFamily({family:"Geologica",weight:"400"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=()=>d.words.length==1?d.text:d.words.map(f=>f.text).slice(0,c+1).join(" ");await t.add(new _o({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:d.words[c].stop.add(o),start:d.words[c].start.add(o)}))}}}sd([Me()],Jr.prototype,"generatorOptions");sd([Me()],Jr.prototype,"type");sd([Me()],Jr.prototype,"position");var Jy=Object.defineProperty,ld=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Jy(a,t,i),i};class Kr extends xa{constructor(t={}){super();Y(this,"generatorOptions");Y(this,"type","SOLAR");Y(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,d;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new Rt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await Qt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((d=t.clip)==null?void 0:d.offset)??new Ie,r=new Nf.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new _o({text:c.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:c.stop.add(i),start:c.start.add(i),scale:new Oe([0,8],[.96,1],{easing:"easeOut"}),alpha:new Oe([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}ld([Me()],Kr.prototype,"generatorOptions");ld([Me()],Kr.prototype,"type");ld([Me()],Kr.prototype,"position");var Ky=Object.defineProperty,qr=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&Ky(a,t,i),i};class Vi extends xa{constructor(t={}){super();Y(this,"generatorOptions");Y(this,"type","WHISPER");Y(this,"color");Y(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 Rt({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 Ie,i=await Qt.fromFamily({family:"Montserrat",weight:"300"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new Hr({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:d.words[c].stop.add(o),start:d.words[c].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,c+1).join(" ").length}]:void 0}))}}}qr([Me()],Vi.prototype,"generatorOptions");qr([Me()],Vi.prototype,"type");qr([Me()],Vi.prototype,"color");qr([Me()],Vi.prototype,"position");var qy=Object.defineProperty,Yr=(n,a,t,o)=>{for(var i=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(a,t,i)||i);return i&&qy(a,t,i),i};class Qr extends xa{constructor(t={}){super();Y(this,"type","VERDANT");Y(this,"generatorOptions");Y(this,"color");Y(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 Rt({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 Ie,i=await Qt.fromFamily({family:"Montserrat",weight:"800"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new Hr({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:d.words[c].stop.add(o),start:d.words[c].start.add(o),segments:[{index:0,start:u.slice(0,c).join(" ").length,stop:u.slice(0,c+1).join(" ").length}]}))}}}Yr([Me()],Qr.prototype,"type");Yr([Me()],Qr.prototype,"generatorOptions");Yr([Me()],Qr.prototype,"color");Yr([Me()],Qr.prototype,"position");class Yy extends ki(xa){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();Y(this,"_duration",new Ie);Y(this,"renderer");Y(this,"stage",new vt.Container);Y(this,"settings");Y(this,"tracks",[]);Y(this,"frame",0);Y(this,"fixedDuration");Y(this,"state","IDLE");Y(this,"fps",fi);Y(this,"canvas");Y(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)),vt.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new bo({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 Ie?this.fixedDuration=t:this.fixedDuration=Ie.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=Py.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 tc(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;tc(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(Ie.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 bo({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(Ie.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(Ie.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(zr)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const d=Math.round(l.offset.seconds*r.sampleRate),c=Math.round(l.range[0].seconds*r.sampleRate),u=Math.round(l.range[1].seconds*r.sampleRate);try{const f=await l.source.decode(t,o),m=f.numberOfChannels-1;for(let p=0;p<t;p++){const h=r.getChannelData(p),v=f.getChannelData(p>m?m:p);for(let k=0;k<h.length-1;k++)k<d+c||k>d+u||k-d<0||(h[k]+=(v[k-d]??0)*l.volume,h[k]>1&&(h[k]=1),h[k]<-1&&(h[k]=-1));r.getChannelData(p).set(h)}}catch{}}return r}time(t){const o=po(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/fi;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 Qy(n,a){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]=a,t[10]=0,t[11]=0,t[12]=n&255,t[13]=n>>8&255,t[14]=n>>16&255,t[15]=n>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const vl=[8e3,12e3,16e3,24e3,48e3],eb="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",tb="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class ab{constructor(a){Y(this,"output");Y(this,"error");Y(this,"config");Y(this,"encoder");Y(this,"opus");Y(this,"meta");this.output=a.output,this.error=a.error}async configure(a){const t=await import(tb),{numberOfChannels:o,sampleRate:i}=this.config=a;if(!vl.includes(i))throw new Vr({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${vl.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?eb:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:Qy(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:a,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new Vr({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 d=s/i*1e6;for(;l<t;){const c=a.subarray(l*r,(l+s)*r),u=this.opus._malloc(c.length*2);this.opus.HEAP16.set(c,u>>1);const f=4e3,m=this.opus._malloc(f),p=this.opus._opus_encode(this.encoder,u,s,m,f);if(p>0){const h=new Uint8Array(this.opus.HEAPU8.subarray(m,m+p));this.output({data:h,timestamp:o,type:"key",duration:d},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(m),l+=s,o+=d}}}function nb(n){const a=vl;let t=48e3;for(const o of a)Math.abs(n-o)<Math.abs(n-t)&&(t=o);return t}class ob{constructor(a,t){Y(this,"canvas");Y(this,"muxer");Y(this,"videoEncoder");Y(this,"frame",0);Y(this,"sampleRate");Y(this,"numberOfChannels");Y(this,"videoBitrate");Y(this,"gpuBatchSize");Y(this,"fps");Y(this,"height");Y(this,"width");Y(this,"audio");this.canvas=a,this.width=a.width,this.height=a.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=nb((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 a=await K0({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Yu({target:new Jl,video:{...a[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(a[0])}async encodeVideo(a){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(a??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(a){if(!this.audio)throw new Vr({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=J0(a,this.sampleRate,this.numberOfChannels),o=new ab({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:G0(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 a=(i=this.muxer)==null?void 0:i.target.buffer;if(!a)throw new Vr({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([a],{type:"video/mp4"})}async export(){return this.blob()}}async function ib(n){var o,i;const a=(o=n.metadata)==null?void 0:o.source_url;if(a)return a;const t=(i=n.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{}}}const mi=class mi{constructor(a){this.transitions=new Map,this.nextId=0,this.composition=a}async applyTransition(a,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",l=this.findTrackForClip(a),d=this.findTrackForClip(t);if(!l||!d)throw new Error("Clips must be added to composition before applying transitions");const c=a.stop.frames-r,u=a.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(a,t,c,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(a,t,c,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(a,t,o.type,c,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(a,t,o.type,c,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(a,t,o.type,c,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(a,t,o.type,c,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(a,t,o,i,r){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");a.alpha=new Oe([o,i],[1,0],{easing:r}),t.alpha=new Oe([o,i],[0,1],{easing:r}),t.start=Ie.fromFrames(o)}async applyCrossFadeTransition(a,t,o,i,r){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");a.alpha=new Oe([o,i],[1,0],{easing:r}),t.alpha=new Oe([o,i],[0,1],{easing:r}),t.start=Ie.fromFrames(o)}async applyWipeTransition(a,t,o,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},d={x:0,y:0};switch(o){case"wipe-left":l.x=new Oe([i,r],[0,-1920],{easing:s}),d.x=new Oe([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Oe([i,r],[0,1920],{easing:s}),d.x=new Oe([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Oe([i,r],[0,-1080],{easing:s}),d.y=new Oe([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Oe([i,r],[0,1080],{easing:s}),d.y=new Oe([i,r],[-1080,0],{easing:s});break}a.translate=l,t.translate=d,t.start=Ie.fromFrames(i)}async applySlideTransition(a,t,o,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},d={x:0,y:0};switch(o){case"slide-left":l.x=new Oe([i,r],[0,-1920],{easing:s}),d.x=new Oe([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Oe([i,r],[0,1920],{easing:s}),d.x=new Oe([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Oe([i,r],[0,-1080],{easing:s}),d.y=new Oe([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Oe([i,r],[0,1080],{easing:s}),d.y=new Oe([i,r],[-1080,0],{easing:s});break}a.translate=l,t.translate=d,t.start=Ie.fromFrames(i)}async applyZoomTransition(a,t,o,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(a.scale=new Oe([i,r],[1,2],{easing:s}),a.alpha=new Oe([i,r],[1,0],{easing:s}),t.scale=new Oe([i,r],[.5,1],{easing:s}),t.alpha=new Oe([i,r],[0,1],{easing:s})):(a.scale=new Oe([i,r],[1,.5],{easing:s}),a.alpha=new Oe([i,r],[1,0],{easing:s}),t.scale=new Oe([i,r],[2,1],{easing:s}),t.alpha=new Oe([i,r],[0,1],{easing:s})),t.start=Ie.fromFrames(i)}async applyDipTransition(a,t,o,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((i+r)/2),d=o==="dip-to-black"?"#000000":"#ffffff",c=await ml.fromColor(d),u=new vy(c,{start:Ie.fromFrames(i),stop:Ie.fromFrames(r)});a.alpha=new Oe([i,l],[1,0],{easing:s}),u.alpha=new Oe([i,l,r],[0,1,0],{easing:s}),t.alpha=new Oe([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=Ie.fromFrames(l)}findTrackForClip(a){for(const t of this.composition.tracks)if(t.clips.includes(a))return t}removeTransition(a){this.transitions.delete(a)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...mi.TRANSITIONS]}static previewTransition(a){return mi.TRANSITIONS.find(t=>t.type===a)}isVideoClip(a){return"alpha"in a&&"scale"in a&&"translate"in a}};mi.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 hi=mi;function Ba(n,a){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return a}function Ji(n){return n>5?n/100:n}function Ia(n,a,t){return Math.min(t,Math.max(a,n))}function da(){return new Dt.ColorMatrixFilter}function rb(n,a){switch(n){case"brightness":{const t=da(),o=Ba(a.value??a.brightness,1);return t.brightness(Ia(Ji(o),0,5),!1),t}case"contrast":{const t=da(),o=Ba(a.value??a.contrast,1);return t.contrast(Ia(Ji(o),0,5),!1),t}case"saturation":{const t=da(),o=Ba(a.value??a.saturation,1);return t.saturate(Ia(Ji(o),0,5),!1),t}case"hue":{const t=da(),o=Ba(a.degrees??a.value,0);return t.hue(Ia(o,-180,180),!1),t}case"blur":case"softFocus":{const t=n==="softFocus"?1:0,o=Ba(a.radius??a.blur??a.value,t);return new Dt.BlurFilter({strength:Ia(o,0,32),quality:4})}case"grayscale":{const t=da(),o=Ia(Ba(a.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Ia(Ba(a.amount,100),0,100)<=0)return null;const o=da();return o.sepia(!1),o}case"invert":{if(Ia(Ba(a.amount,100),0,100)<=0)return null;const o=da();return o.negative(!1),o}case"warmth":{const t=da(),o=Ia(Ba(a.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=da(),o=Ia(Ba(a.intensity,.3),0,1),i=typeof a.color=="string"?a.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,d=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*d,0,0,0,0,0,1,0]}return t}case"vintage":{const t=da();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=da(),o=Ia(Ji(Ba(a.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=da();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=da();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=da();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=Dt);class pm{constructor(a=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 Yy({width:a,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 d,c,u,f;const l=this.composition;((c=(d=l==null?void 0:l.app)==null?void 0:d.renderer)!=null&&c.view||(u=l==null?void 0:l.renderer)!=null&&u.view||(f=l==null?void 0:l.renderer)!=null&&f.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...a){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(a){this.player=a,this.isDebug()&&this.dbg("attachPlayer:begin",{w:a.clientWidth,h:a.clientHeight}),this.composition.attachPlayer(a),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 a=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!a)return;const t=Math.min(a.clientWidth/this.composition.width,a.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(a){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=a.source)==null?void 0:o.original_width)&&a.source.original_width>0&&Number.isFinite((i=a.source)==null?void 0:i.original_height)&&a.source.original_height>0?{width:a.source.original_width,height:a.source.original_height}:null;const t=await ib(a);for(const s of a.timeline)await this.addTimelineClip(s,t);if(a.textOverlays)for(const s of a.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of a.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);a.transitions&&a.transitions.length>0&&await this.applyTransitionsToClips(a.transitions),this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async applyTransitionsToClips(a){const t=new hi(this.composition);for(const o of a){if(o.type==="cut")continue;const i=this.clips.get(o.fromClipId),r=this.clips.get(o.toClipId),s=this.mapTransitionType(o.type);if(!i||!r||!s)continue;const l={type:s,duration:o.duration,easing:this.mapTransitionEasing(o.easing)};try{await t.applyTransition(i,r,l)}catch{}}}mapTransitionType(a){switch(a){case"fade":return"fade";case"crossfade":return"cross-fade";case"dip-to-black":return"dip-to-black";case"wipe-left":return"wipe-left";case"wipe-right":return"wipe-right";case"slide-left":return"slide-left";case"slide-right":return"slide-right";case"zoom":return"zoom-in";case"cut":return null}}mapTransitionEasing(a){switch(a){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}}async addTimelineClip(a,t){var o,i;try{const r=a.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=An.from)==null?void 0:o.call(An,r,{crossOrigin:"anonymous"}))??await An.from(r),l=new fl(s,{muted:a.muted||!1,scale:a.scale||1,position:"center"});let d=0,c=null;if(a.sourceIn!==void 0||a.sourceOut!==void 0){const m=Math.max(0,Math.floor((a.sourceIn||0)*this.fps)),p=a.sourceOut!==void 0?Math.max(m+1,Math.floor(a.sourceOut*this.fps)):null;d=m,c=p;try{if(l.offset=l.offset||{frames:0},l.offset.frames=m,p!==null){const h=Math.max(1,p-m);l.duration=l.duration||{frames:h},l.duration.frames=h}}catch{}}const u=await this.composition.add(l);if(c!==null&&d>=0)try{const m=Math.max(1,c-d);u.offset=u.offset||{frames:0},u.offset.frames=d,u.duration=u.duration||{frames:m},u.duration.frames=m}catch{}const f=Math.floor(a.timelineStart*this.fps);f>0&&u.offsetBy(f),this.clipTimelineStart.set(a.id,a.timelineStart),this.applyFitToClip(u),this.clips.set(a.id,u),(i=a.filters)!=null&&i.length&&(await new Promise(m=>requestAnimationFrame(m)),this.applyFiltersToClip(a.id,a.filters))}catch{}}async addTextOverlay(a){try{const t=Qt.fromFamily({family:a.fontFamily||"Arial",weight:a.fontWeight||"400"}),o=new _o({text:a.content,font:t,fontSize:a.fontSize||34,position:a.position||"center",fillStyle:a.color||"#FFFFFF",textAlign:a.textAlign||"center",textBaseline:a.textBaseline||"middle"});if(a.animation){const r=a.animation.duration||1,s=0,l=r*this.fps,d=a.animation.easing||"linear";a.animation.type==="rotate"&&a.animation.rotation?o.rotation=new Oe([s,l],[a.animation.rotation.from,a.animation.rotation.to],{easing:d}):a.animation.type==="scale"&&a.animation.scale&&(o.scale=new Oe([s,l],[a.animation.scale.from,a.animation.scale.to],{easing:d}))}a.startTime&&a.startTime>0&&o.offsetBy(a.startTime*this.fps),a.duration&&o.subclip(0,a.duration*this.fps);const i=await this.composition.add(o);this.clips.set(a.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(a,t){const o=this.clips.get(a);if(!o)return;const i=this.filterCache.get(a)??new Map,r=new Set(t.map(d=>d.id));for(const[d,c]of i.entries())if(!r.has(d)){try{typeof c.instance.destroy=="function"&&c.instance.destroy()}catch{}i.delete(d)}const s=[];for(const d of t){const c=this.buildFilterSignature(d),u=i.get(d.id);let f=null;if(u&&u.signature===c)f=u.instance;else{if(u)try{u.instance.destroy()}catch{}f=this.createPixiFilter(d),f?i.set(d.id,{instance:f,signature:c}):i.delete(d.id)}f&&s.push(f)}this.filterCache.set(a,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(a){const t=typeof a.params=="object"&&a.params!==null?a.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:a.filterId,intensity:a.intensity??1,params:o})}setClipFilters(a,t){this.applyFiltersToClip(a,t),this.composition.computeFrame()}createPixiFilter(a){const t=a.intensity??1,o=a.params||{};if(be.getFilter(a.filterId)&&!be.isFilterCompatibleWithMedia(a.filterId,"video"))return null;let r=zf(a.filterId,o);return r||(r=rb(a.filterId,o)),r?(t!==1&&r&&(a.filterId==="colorOverlay"||a.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(a){this.composition.seek(a)}seekToTime(a){this.composition.seek(a*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(a={}){var s,l,d,c,u,f,m,p,h;const t=a.fps??this.fps,o=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(c=(d=this.composition)==null?void 0:d.app)==null?void 0:c.renderer)==null?void 0:u.view)??((m=(f=this.composition)==null?void 0:f.renderer)==null?void 0:m.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(p=a.onProgress)==null||p.call(a,0);const i=new ob(o,{fps:t});await i.init();const r=await i.export();return(h=a.onProgress)==null||h.call(a,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 a=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(a)};a()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(a,t){const o=this.clips.get(a);if(!o)return;const i=this.clipTimelineStart.get(a)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(a,t),this.composition.computeFrame())}setFitMode(a){this.fitMode=a,this.applyFitModeToClips()}applyFitModeToClips(){for(const a of this.clips.values())"scale"in a&&typeof a.scale<"u"&&this.applyFitToClip(a);this.composition.computeFrame()}applyFitToClip(a){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=a.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),d=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!l||!d)return;const c=Math.min(i/l,r/d),u=Math.max(i/l,r/d),f=this.fitMode==="contain"?c:u;a.scale=f}catch{}}trimClip(a,t,o){const i=this.clips.get(a);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(a){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),d=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),c=l+d;if(a>=l&&a<c){const u=a-l;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const sb=["src"],lb={class:"preview-controls"},db=["aria-label"],cb={class:"time-display"},ub={class:"current-time"},mb={class:"total-time"},pb={key:2,class:"loading-overlay"},fb={key:3,class:"error-overlay"},hb=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),d=e.ref("Initializing..."),c=e.ref(null),u=e.ref(!1),f=e.ref(0),m=e.ref(0);let p=null;const h=e.computed(()=>!!t.enableEngine&&!!t.recipe),v=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),k=e.computed(()=>{var x,F;return(x=t.media)!=null&&x.url?t.media.url:(((F=t.media)==null?void 0:F.file)instanceof File,"")});async function V(){var x,F,b;if(!(!r.value||!t.recipe))try{l.value=!0,d.value="Initializing video engine...";const R=((x=t.recipe.source)==null?void 0:x.original_width)||1920,P=((F=t.recipe.source)==null?void 0:F.original_height)||1080,O=((b=t.recipe.output)==null?void 0:b.fps)||30;p=new pm(R,P,O,{fitMode:t.fitMode}),p.attachPlayer(r.value),d.value="Loading composition...",await p.loadFromRecipe(t.recipe),m.value=p.durationInSeconds,o("duration-change",m.value),B(),l.value=!1,o("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(R){const P=R instanceof Error?R.message:String(R);c.value=`Failed to initialize: ${P}`,l.value=!1}}function B(){if(!p)return;const x=setInterval(()=>{p&&u.value&&(f.value=p.currentTimeInSeconds,o("time-update",f.value))},100);Z.value=x}function _(){h.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 g(x){const F=Math.floor(x/60),b=Math.floor(x%60);return`${F}:${b.toString().padStart(2,"0")}`}function E(){c.value=null,h.value&&V()}function C(){!h.value&&s.value&&(m.value=s.value.duration,o("duration-change",m.value))}function N(){!h.value&&s.value&&(f.value=s.value.currentTime,o("time-update",f.value))}function S(){u.value=!1,o("play-state-change",!1)}function A(x){c.value="Failed to load video",o("error",c.value)}e.onMounted(()=>{h.value&&t.recipe&&V()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),Z.value&&(clearInterval(Z.value),Z.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async x=>{if(h.value&&x)if(x.timeline,p)try{await p.loadFromRecipe(x),m.value=p.durationInSeconds,o("duration-change",m.value)}catch{}else await V()}),e.watch(()=>t.enableEngine,async x=>{x?(await e.nextTick(),await V()):p&&(Z.value&&(clearInterval(Z.value),Z.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async x=>{if(!(!h.value||!p))try{p.setFitMode(x||"contain")}catch{}});const Z=e.ref(null);return(x,F)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[h.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:k.value,onLoadedmetadata:C,onTimeupdate:N,onEnded:S,onError:A,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:v.value}),playsinline:"",controls:""},null,44,sb)),e.createElementVNode("div",lb,[e.createElementVNode("button",{class:"play-button",onClick:_,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(W.IonIcon),{icon:u.value?e.unref(Bu):e.unref(Iu)},null,8,["icon"])],8,db),e.createElementVNode("div",cb,[e.createElementVNode("span",ub,e.toDisplayString(g(f.value)),1),F[0]||(F[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",mb,e.toDisplayString(g(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",pb,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(d.value),1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",fb,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(jl)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(c.value),1),e.createElementVNode("button",{onClick:E},"Retry")])):e.createCommentVNode("",!0)],512))}}),gl=Be(hb,[["__scopeId","data-v-e199ac48"]]),vb=["aria-label"],gb=["aria-label"],yb={class:"clip-content"},bb={key:0,class:"clip-thumbnail"},wb=["src","alt"],kb=["src"],_b=["data-visual-mode"],Eb={class:"clip-info"},xb={class:"clip-label"},Sb={class:"clip-duration"},Cb={key:3,class:"filter-indicators"},Vb={key:4,class:"speed-indicator"},Nb=["aria-label","data-testid"],Tb={key:1,class:"selection-overlay"},Mb=420,Bb=8,Ib=48,Fb=32,vc=1,$b=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1}},emits:["select","delete","long-press","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null),r=e.ref(!1),s=e.ref(null),l=e.ref(0),d=e.ref(0),c=e.ref(0),u=e.ref(0),f=e.ref(!1),m=e.ref(!1),p=e.ref(null),h=e.computed(()=>{const j=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${j}px`}}),v=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),k=e.computed(()=>{const D=t.clip.timelineEnd-t.clip.timelineStart;return N(D)}),V=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),B=e.computed(()=>t.clip.filters||[]),_=e.computed(()=>t.clip.waveformSamples??[]),g=e.computed(()=>t.clip.filmstripFrames??[]),E=e.computed(()=>_.value.length>0),C=e.computed(()=>g.value.length>0);function N(D){if(D<1)return`${Math.round(D*30)}f`;if(D<60)return`${D.toFixed(1)}s`;{const j=Math.floor(D/60),q=Math.floor(D%60);return`${j}:${q.toString().padStart(2,"0")}`}}function S(D){return!D||typeof D!="string"?Jd:D.includes("color")||D.includes("brightness")?pn:D.includes("blur")?gh:D.includes("style")?Ko:D.includes("effect")?mn:Jd}function A(){r.value||o("select")}function Z(D){D.button===0&&(b("move",D.clientX),D.preventDefault())}function x(D){if(D.touches.length!==1)return;const j=D.touches[0];if(!t.isMobile){b("move",j.clientX),D.preventDefault();return}c.value=j.clientX,u.value=j.clientY,f.value=!1,m.value=!1,R(),P(),p.value=window.setTimeout(()=>{m.value=!0,P(),t.selected||o("select"),o("long-press")},Mb),document.addEventListener("touchmove",O),document.addEventListener("touchend",U),document.addEventListener("touchcancel",U),D.preventDefault()}function F(D,j){const q="touches"in j?j.touches[0].clientX:j.clientX;s.value=D==="start"?"trim-start":"trim-end",b(s.value,q),j.preventDefault(),j.stopPropagation()}function b(D,j){R(),P(),r.value=!0,s.value=D,l.value=j,D==="move"?d.value=t.clip.timelineStart:D==="trim-start"?d.value=t.clip.sourceIn:D==="trim-end"&&(d.value=t.clip.sourceOut),document.addEventListener("mousemove",M),document.addEventListener("mouseup",z),document.addEventListener("touchmove",I),document.addEventListener("touchend",z),t.selected||o("select")}function R(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function P(){document.removeEventListener("touchmove",O),document.removeEventListener("touchend",U),document.removeEventListener("touchcancel",U)}function O(D){if(D.touches.length!==1)return;const j=D.touches[0],q=j.clientX-c.value,te=j.clientY-u.value;Math.hypot(q,te)<Bb||(f.value=!0,R(),P(),b("move",j.clientX),M(D),D.preventDefault())}function U(){const D=!f.value&&!m.value&&!r.value;R(),P(),f.value=!1,m.value=!1,D&&o("select")}function M(D){if(!r.value||!s.value)return;const j="touches"in D?D.touches[0].clientX:D.clientX,q="touches"in D?D.touches[0].clientY:D.clientY,ce=j-l.value;s.value==="move"?(o("drag",ce),o("drag-abs",j,q)):s.value==="trim-start"?(o("trim-start",ce),o("trim-start-abs",j)):s.value==="trim-end"&&(o("trim-end",ce),o("trim-end-abs",j))}function I(D){M(D)}function z(){r.value=!1,s.value=null,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",I),document.removeEventListener("touchend",z)}function X(){e.nextTick(()=>{ve()})}function le(D){var ge,Te;const j=Math.max(0,t.clip.timelineEnd-t.clip.timelineStart),q=Math.max(1,Math.round(j*t.scale)),te=t.isMobile?Fb:Ib,ce=Math.max(1,Math.round(D.clientWidth||((ge=D.parentElement)==null?void 0:ge.clientWidth)||q)),me=Math.max(1,Math.round(D.clientHeight||((Te=D.parentElement)==null?void 0:Te.clientHeight)||te));return{width:ce,height:me}}function ve(){if(C.value||!i.value)return;const D=i.value,j=D.getContext("2d");if(!j)return;const{width:q,height:te}=le(D),ce=window.devicePixelRatio||1;if(D.width=Math.max(1,Math.round(q*ce)),D.height=Math.max(1,Math.round(te*ce)),j.setTransform(ce,0,0,ce,0,0),j.clearRect(0,0,q,te),_.value.length>0){ne(j,q,te,_.value);return}ie(j,q,te)}function ie(D,j,q){const te=q/2;D.strokeStyle="rgba(255, 255, 255, 0.3)",D.lineWidth=1,D.beginPath(),D.moveTo(0,te),D.lineTo(j,te);for(let ce=0;ce<j;ce+=4){const me=Math.sin(ce*.05)*(q*.3);D.moveTo(ce,te-me),D.lineTo(ce,te+me)}D.stroke()}function ne(D,j,q,te){const ce=t.clip.sourceIn,me=t.clip.sourceOut,ge=Math.max(.001,me-ce),Te=te.filter(Ne=>Ne.endTime>=ce&&Ne.time<=me);if(Te.length===0){ie(D,j,q);return}const he=q/2,ye=q*.44,Se=q*.32;D.fillStyle="rgba(255, 255, 255, 0.26)",Te.forEach(Ne=>{const at=Math.max(Ne.time,ce),et=Math.min(Ne.endTime,me),gt=(at-ce)/ge*j,Ct=Math.max(vc,(et-at)/ge*j),yt=L(Ne.rms)*Se;D.fillRect(gt,he-yt,Ct,yt*2)}),D.fillStyle="rgba(255, 255, 255, 0.72)",Te.forEach(Ne=>{const at=Math.max(Ne.time,ce),et=Math.min(Ne.endTime,me),gt=(at-ce)/ge*j,Ct=Math.max(vc,(et-at)/ge*j),yt=L(Ne.peak)*ye;D.fillRect(gt,he-yt,Ct,yt*2)})}function L(D){return Math.min(1,Math.max(0,D))}return e.watch(()=>[t.clip.id,t.clip.timelineStart,t.clip.timelineEnd,t.clip.sourceIn,t.clip.sourceOut,t.clip.waveformSamples,t.clip.filmstripFrames,t.scale,t.isMobile],X,{deep:!0,flush:"post"}),e.onMounted(()=>{X(),window.addEventListener("resize",ve)}),e.onUnmounted(()=>{z(),R(),P(),window.removeEventListener("resize",ve)}),(D,j)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:D.selected,mobile:D.isMobile,"has-filters":V.value}]),style:e.normalizeStyle(h.value),onClick:A,onMousedown:Z,onTouchstart:x},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:j[0]||(j[0]=e.withModifiers(q=>F("start",q),["stop"])),onTouchstart:j[1]||(j[1]=e.withModifiers(q=>F("start",q),["stop"])),"aria-label":`Trim start of ${D.clip.label||"clip"}`},[...j[7]||(j[7]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,vb),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:j[2]||(j[2]=e.withModifiers(q=>F("end",q),["stop"])),onTouchstart:j[3]||(j[3]=e.withModifiers(q=>F("end",q),["stop"])),"aria-label":`Trim end of ${D.clip.label||"clip"}`},[...j[8]||(j[8]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,gb),e.createElementVNode("div",yb,[D.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",bb,[e.createElementVNode("img",{src:D.clip.thumbnail,alt:D.clip.label||"Video clip"},null,8,wb)])):e.createCommentVNode("",!0),C.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["clip-analysis-strip clip-filmstrip",{compact:D.isMobile}]),"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,q=>(e.openBlock(),e.createElementBlock("img",{key:q.id,class:"clip-filmstrip-frame",src:q.uri,alt:"",draggable:"false"},null,8,kb))),128))],2)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["clip-analysis-strip clip-waveform",{compact:D.isMobile}]),"data-visual-mode":E.value?"waveform":"placeholder","aria-hidden":"true"},[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)],10,_b)),e.createElementVNode("div",Eb,[e.createElementVNode("span",xb,e.toDisplayString(v.value),1),e.createElementVNode("span",Sb,e.toDisplayString(k.value),1)]),V.value?(e.openBlock(),e.createElementBlock("div",Cb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,q=>(e.openBlock(),e.createBlock(e.unref(W.IonIcon),{key:q.id||q.filterId,icon:S(q.filterId||q.id),title:`Filter: ${q.filterId||q.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),D.clip.speed&&D.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Vb,e.toDisplayString(D.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),D.selected&&D.canDelete?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"clip-delete-button","aria-label":`Delete ${D.clip.label||"clip"}`,"data-testid":`timeline-clip-delete-${D.clip.id}`,title:"Delete clip",onClick:j[4]||(j[4]=e.withModifiers(q=>o("delete"),["stop"])),onMousedown:j[5]||(j[5]=e.withModifiers(()=>{},["stop"])),onTouchstart:j[6]||(j[6]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(wr)},null,8,["icon"])],40,Nb)):e.createCommentVNode("",!0),D.selected?(e.openBlock(),e.createElementBlock("div",Tb)):e.createCommentVNode("",!0)],38))}}),gc=Be($b,[["__scopeId","data-v-deeaa999"]]),Db={class:"timeline-track-header__meta"},Rb=["data-testid"],Ab=["data-testid","value","aria-label","onKeydown"],Lb={class:"timeline-track-header__type"},Pb=["aria-label"],Ob=["aria-pressed","aria-label"],Ub=["aria-pressed","aria-label"],zb=["aria-pressed","aria-label"],jb=["aria-pressed","aria-label"],Wb={class:"timeline-track-header__menu-row"},Zb=["data-testid","aria-label","aria-expanded"],Hb=["aria-label"],Xb=["data-testid"],Gb=["data-testid"],Jb=["data-testid"],Kb=["data-testid"],qb=e.defineComponent({__name:"TimelineTrackHeader",props:{track:{}},emits:["toggle-lock","toggle-hidden","toggle-muted","toggle-solo","rename-track","delete-track","reorder-track"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(!1),r=e.ref(!1),s=e.ref(""),l=e.ref(null);function d(){i.value=!i.value}function c(){i.value=!1}function u(){c(),f()}async function f(){var V,B;s.value=t.track.name,r.value=!0,await e.nextTick(),(V=l.value)==null||V.focus(),(B=l.value)==null||B.select()}function m(V){const B=V.target;B&&(s.value=B.value)}function p(){if(!r.value)return;const V=s.value.trim();r.value=!1,!(V===""||V===t.track.name)&&o("rename-track",t.track.id,V)}function h(){r.value=!1}function v(V){c(),o("reorder-track",t.track.id,V)}function k(){c(),o("delete-track",t.track.id)}return(V,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-track-header",{"is-hidden":V.track.hidden===!0}])},[e.createElementVNode("div",Db,[r.value?(e.openBlock(),e.createElementBlock("input",{key:1,ref_key:"renameInput",ref:l,class:"timeline-track-header__rename-input","data-testid":`timeline-track-rename-${V.track.id}`,value:s.value,"aria-label":`Rename ${V.track.name}`,onInput:m,onKeydown:[e.withKeys(e.withModifiers(p,["prevent"]),["enter"]),e.withKeys(e.withModifiers(h,["prevent"]),["escape"])],onBlur:p},null,40,Ab)):(e.openBlock(),e.createElementBlock("span",{key:0,class:"timeline-track-header__name","data-testid":`timeline-track-name-${V.track.id}`,onDblclick:f},e.toDisplayString(V.track.name),41,Rb)),e.createElementVNode("span",Lb,e.toDisplayString(V.track.type),1)]),e.createElementVNode("div",{class:"timeline-track-header__actions","aria-label":`Track controls for ${V.track.name}`},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":V.track.locked===!0}]),"aria-pressed":V.track.locked===!0,"aria-label":V.track.locked===!0?`Unlock ${V.track.name}`:`Lock ${V.track.name}`,title:"Lock",onClick:B[0]||(B[0]=_=>o("toggle-lock",V.track.id))}," Lock ",10,Ob),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":V.track.hidden===!0}]),"aria-pressed":V.track.hidden===!0,"aria-label":V.track.hidden===!0?`Show ${V.track.name}`:`Hide ${V.track.name}`,title:"Hide",onClick:B[1]||(B[1]=_=>o("toggle-hidden",V.track.id))}," Hide ",10,Ub),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":V.track.muted===!0}]),"aria-pressed":V.track.muted===!0,"aria-label":V.track.muted===!0?`Unmute ${V.track.name}`:`Mute ${V.track.name}`,title:"Mute",onClick:B[2]||(B[2]=_=>o("toggle-muted",V.track.id))}," Mute ",10,zb),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":V.track.solo===!0}]),"aria-pressed":V.track.solo===!0,"aria-label":V.track.solo===!0?`Disable solo for ${V.track.name}`:`Solo ${V.track.name}`,title:"Solo",onClick:B[3]||(B[3]=_=>o("toggle-solo",V.track.id))}," Solo ",10,jb)],8,Pb),e.createElementVNode("div",Wb,[e.createElementVNode("button",{type:"button",class:"timeline-track-header__menu-button","data-testid":`timeline-track-menu-${V.track.id}`,"aria-label":`More actions for ${V.track.name}`,"aria-expanded":i.value,"aria-haspopup":!0,onClick:d}," ⋯ ",8,Zb),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-header__menu",role:"menu","aria-label":`${V.track.name} actions`},[e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-rename-action-${V.track.id}`,onClick:u}," Rename ",8,Xb),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-move-up-${V.track.id}`,onClick:B[4]||(B[4]=_=>v("up"))}," Move up ",8,Gb),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-move-down-${V.track.id}`,onClick:B[5]||(B[5]=_=>v("down"))}," Move down ",8,Jb),e.createElementVNode("button",{type:"button",role:"menuitem",class:"timeline-track-header__menu-button--danger","data-testid":`timeline-track-delete-${V.track.id}`,onClick:k}," Delete track ",8,Kb)],8,Hb)):e.createCommentVNode("",!0)])],2))}}),Yb=Be(qb,[["__scopeId","data-v-54e2bc6a"]]);class fm{constructor(a=30){this.fps=30,this.fps=a}setFps(a){this.fps=a}async convertTimelineClipToEngine(a,t){const o=new fl(t,{muted:a.muted||!1,scale:a.scale||1,position:"center"});if(a.sourceIn!==void 0||a.sourceOut!==void 0){const i=this.secondsToFrames(a.sourceIn||0),r=a.sourceOut?this.secondsToFrames(a.sourceOut):o.duration.frames;o.subclip(i,r)}return a.timelineStart&&a.timelineStart>0&&o.offsetBy(this.secondsToFrames(a.timelineStart)),a.transform&&this.applyTransformations(o,a.transform),o}convertEngineClipToTimeline(a,t,o){const i=this.framesToSeconds(a.duration.frames),r=a.offset?this.framesToSeconds(a.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:a.muted||!1,scale:a.scale.x||1}}async buildCompositionFromRecipe(a,t){var o;(o=t.clear)==null||o.call(t);for(const i of a.timeline)try{if(!i.url)continue;const r=await An.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}a.duration&&(t.duration=Ie.fromFrames(this.secondsToFrames(a.duration)))}extractTimelineFromComposition(a){const t=[];return(a.clips||[]).forEach((i,r)=>{var s,l;i instanceof fl&&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(a,t){(t.x!==void 0||t.y!==void 0)&&(a.x=t.x||0,a.y=t.y||0),t.rotation!==void 0&&(a.rotation=t.rotation),t.opacity!==void 0&&(a.alpha=t.opacity),t.scale!==void 0&&(a.scale={x:t.scale,y:t.scale})}secondsToFrames(a){return Math.round(a*this.fps)}framesToSeconds(a){return a/this.fps}framesToTime(a){const t=this.framesToSeconds(a),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(a){const t=Math.floor(a/3600),o=Math.floor(a%3600/60),i=Math.floor(a%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(a){const t=a.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(a);return o}timeToFrames(a){const t=a.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(a);return this.secondsToFrames(o)}}const Qb={class:"time-markers"},e1=["data-track-id"],t1=["data-track-id"],a1=["aria-label","title"],n1={key:0,class:"timeline-scrollbar"},yc=152,bc=80,o1=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},tracks:{},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-delete","clip-move","clip-long-press","snap-state-change","toggle-frame-mode","toggle-lock","toggle-hidden","toggle-muted","toggle-solo","rename-track","delete-track","reorder-track"],setup(n,{expose:a,emit:t}){const o=n,i=e.computed(()=>o.isMobile===!0),r=t,s=e.ref(),l=e.ref(o.selectedClipId||null),d=e.ref(!1),c=e.ref(0),u=e.ref(),f=e.ref(0),m=e.computed(()=>o.selectedClipId??l.value);e.watch(()=>o.selectedClipId,Q=>{Q!==void 0&&(l.value=Q)});const p=new fm(o.fps);e.watch(()=>o.fps,Q=>{p.setFps(Q)});const h=e.ref(!1),v=e.ref(null),k=e.ref(0),V=e.ref(0),B=e.ref(null),_=e.ref(null),g=e.ref(0),E=e.ref(0),C=e.ref(0),N=e.ref(!1),S=e.ref(0),A=e.ref(o.zoomLevel),Z=e.computed(()=>o.zoomLevel),x=e.computed(()=>o.tracks!==void 0&&o.tracks.length>0&&!i.value),F=e.computed(()=>x.value?yc:0),b=e.computed(()=>Math.max(0,L.value-F.value));function R(Q){return Q.trackId??`legacy-track-${Q.track??0}`}function P(Q,ue){return{id:Q,type:"video",name:`Track ${ue+1}`,order:ue}}const O=e.computed(()=>{const Q=new Map;for(const ue of o.clips){const oe=R(ue),ae=Q.get(oe);if(ae){ae.push(ue);continue}Q.set(oe,[ue])}return Q}),U=e.computed(()=>{if(!x.value)return[];const Q=[...o.tracks??[]].sort((ae,xe)=>ae.order-xe.order),ue=new Set(Q.map(ae=>ae.id)),oe=[];for(const ae of O.value.keys())ue.has(ae)||oe.push(P(ae,Q.length+oe.length));return[...Q,...oe].map(ae=>({track:ae,clips:O.value.get(ae.id)??[],height:ae.height??bc}))}),M=e.computed(()=>new Set(U.value.filter(Q=>Q.track.locked===!0).map(Q=>Q.track.id)));function I(Q){const ue=o.clips.find(oe=>oe.id===Q);return ue?!M.value.has(R(ue)):!1}function z(Q){const ue=o.clips.find(xe=>xe.id===Q);if(!ue)return null;const oe=R(ue),ae=o.clips.filter(xe=>xe.id!==Q&&R(xe)===oe&&xe.timelineStart>=ue.timelineEnd-1e-9).map(xe=>xe.timelineStart);return ae.length?Math.min(...ae):null}function X(Q){const ue=Q.sourceMaxOut??o.duration,oe=Q.timelineStart+(ue-Q.sourceIn),ae=z(Q.id),xe=ae!=null?Math.max(Q.timelineStart,ae):1/0;return Math.min(oe,xe)}function le(Q,ue=bc){const oe=Q.sourceMinIn??0,xe=(Q.sourceMaxOut??o.duration)-oe,Le=Q.sourceIn-oe;return{left:`${(Q.timelineStart-Le)*Z.value-c.value}px`,width:`${xe*Z.value}px`,top:"0px",height:`${ue}px`,opacity:m.value===Q.id?.25:.15}}const ve=e.computed(()=>o.useFrameMode?o.zoomLevel:o.zoomLevel/o.fps),ie=e.computed(()=>p.secondsToFrames(o.duration)),ne=e.computed(()=>o.useFrameMode?ie.value*ve.value:o.duration*Z.value),L=e.computed(()=>{var Q;return f.value||((Q=s.value)==null?void 0:Q.clientWidth)||800}),D=e.computed(()=>ne.value>b.value),j=e.computed(()=>Math.max(0,ne.value-b.value)),q=e.computed(()=>c.value>0),te=e.computed(()=>c.value<j.value),ce=e.computed(()=>o.useFrameMode?p.secondsToFrames(o.playhead)*ve.value-c.value:o.playhead*Z.value-c.value),me=e.computed(()=>B.value===null?null:o.useFrameMode?p.secondsToFrames(B.value)*ve.value-c.value:B.value*Z.value-c.value),ge=e.computed(()=>{const Q=b.value,ue=Math.max(50,Q/ne.value*Q),oe=c.value/j.value*(Q-ue);return{width:`${ue}px`,left:`${oe}px`}}),Te=e.computed(()=>{const Q=[],ue=he();for(let oe=0;oe<=o.duration;oe+=ue){const ae=oe*Z.value-c.value;ae>=-50&&ae<=b.value+50&&Q.push({position:ae+F.value,label:ye(oe),time:oe})}return Q});function he(){const ue=80/Z.value;return ue<=1?1:ue<=5?5:ue<=10?10:ue<=30?30:ue<=60?60:Math.ceil(ue/60)*60}function ye(Q){if(o.useFrameMode)return`F${p.secondsToFrames(Q)}`;{const ue=Math.floor(Q/60),oe=Math.floor(Q%60),ae=Math.floor(Q%1*o.fps);return Z.value>100?`${ue}:${oe.toString().padStart(2,"0")}:${ae.toString().padStart(2,"0")}`:`${ue}:${oe.toString().padStart(2,"0")}`}}function Se(Q){const ue=s.value.getBoundingClientRect();let ae=(Q.clientX-ue.left-F.value+c.value)/Z.value;const xe=o.clips.find(Le=>ae>=Le.timelineStart&&ae<=Le.timelineEnd);if(xe)ae=Math.max(xe.timelineStart,Math.min(xe.timelineEnd,ae));else if(o.selectedClipId){const Le=o.clips.find(Ke=>Ke.id===o.selectedClipId);if(Le){const Ke=Math.abs(ae-Le.timelineStart),pt=Math.abs(ae-Le.timelineEnd);ae=Ke<pt?Le.timelineStart:Le.timelineEnd}}else ae=Math.max(0,Math.min(ae,o.duration));r("update:playhead",ae)}function Ne(Q){if(!D.value)return;const ue=Math.abs(Q.deltaX)>Math.abs(Q.deltaY)?Q.deltaX:Q.deltaY;ue!==0&&(Q.preventDefault(),c.value=Math.max(0,Math.min(j.value,c.value+ue)))}function at(Q){return[...Q===void 0?o.clips:o.clips.filter(oe=>R(oe)===Q)].sort((oe,ae)=>oe.timelineStart-ae.timelineStart)}function et(Q){const ue=o.clips.find(xe=>xe.id===Q),oe=at(ue?R(ue):void 0),ae=oe.findIndex(xe=>xe.id===Q);return{previous:ae>0?oe[ae-1]:null,next:ae!==-1&&ae<oe.length-1?oe[ae+1]:null}}function gt(Q){const ue=Q.timelineEnd-Q.timelineStart,{previous:oe,next:ae}=et(Q.id),xe=oe?oe.timelineEnd:0,Le=ae?ae.timelineStart-ue:Math.max(Q.timelineStart,o.duration-ue);return{minStart:xe,maxStart:Math.max(xe,Le)}}function Ct(){return 12/Math.max(Z.value,1)}function yt(Q){return Array.from(new Set(Q.filter(ue=>typeof ue=="number"&&Number.isFinite(ue))))}function mt(Q,ue,oe,ae){const xe=Math.max(oe,Math.min(Q,ae));if(!o.snapEnabled)return{value:xe,guideTime:null};const Le=Ct();let Ke=xe,pt=null,Vt=Number.POSITIVE_INFINITY;for(const ft of yt(ue)){if(ft<oe||ft>ae)continue;const ht=Math.abs(ft-xe);ht<=Le&&ht<Vt&&(Ke=ft,pt=ft,Vt=ht)}return{value:Ke,guideTime:pt}}function ot(Q){if(Q.touches.length===2){N.value=!0;const ue=Q.touches[0],oe=Q.touches[1];S.value=Math.hypot(oe.clientX-ue.clientX,oe.clientY-ue.clientY),A.value=o.zoomLevel}else Q.touches.length===1&&(g.value=Q.touches[0].clientX,E.value=Q.touches[0].clientY,C.value=g.value)}function kt(Q){if(N.value&&Q.touches.length===2){const ue=Q.touches[0],oe=Q.touches[1],xe=Math.hypot(oe.clientX-ue.clientX,oe.clientY-ue.clientY)/S.value;Math.max(10,Math.min(200,A.value*xe)),r("update:playhead",o.playhead)}else if(Q.touches.length===1&&!N.value){const ue=Q.touches[0],oe=C.value-ue.clientX;Math.abs(oe)>Math.abs(ue.clientY-E.value)&&(Q.preventDefault(),c.value=Math.max(0,Math.min(j.value,c.value+oe)),C.value=ue.clientX)}}function xt(){N.value=!1}function we(Q){const ue=Q.target;if(ue.closest(".playhead-handle"))return;const oe=Q.button===1,ae=!!ue.closest(".video-track");(oe||!ae&&D.value)&&Ce(Q)}function Ce(Q){h.value=!0,v.value="pan",k.value=Q.clientX,V.value=c.value,document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",ze)}function $e(Q){Q.preventDefault(),Q.stopPropagation(),h.value=!0,v.value="playhead";const ue="touches"in Q?Q.touches[0].clientX:Q.clientX;k.value=ue,V.value=o.playhead,"touches"in Q?(document.addEventListener("touchmove",Xe),document.addEventListener("touchend",ze)):(document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",ze))}function Ye(Q){Q.preventDefault(),Q.stopPropagation(),h.value=!0,v.value="scrollbar";const ue="touches"in Q?Q.touches[0].clientX:Q.clientX;k.value=ue,V.value=c.value,"touches"in Q?(document.addEventListener("touchmove",Xe),document.addEventListener("touchend",ze)):(document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",ze))}function Xe(Q){if(!h.value)return;const oe=("touches"in Q?Q.touches[0].clientX:Q.clientX)-k.value;if(v.value==="playhead"){const ae=oe/Z.value;let xe=V.value+ae;if(o.selectedClipId){const Le=o.clips.find(Ke=>Ke.id===o.selectedClipId);Le?xe=Math.max(Le.timelineStart,Math.min(Le.timelineEnd,xe)):xe=Math.max(0,Math.min(o.duration,xe))}else{const Le=o.clips.find(Ke=>o.playhead>=Ke.timelineStart&&o.playhead<=Ke.timelineEnd);Le?xe=Math.max(Le.timelineStart,Math.min(Le.timelineEnd,xe)):xe=Math.max(0,Math.min(o.duration,xe))}r("update:playhead",xe)}else if(v.value==="scrollbar"){const ae=oe/b.value*ne.value;c.value=Math.max(0,Math.min(j.value,V.value+ae))}else if(v.value==="pan"){const ae=V.value-oe;c.value=Math.max(0,Math.min(j.value,ae))}}function ze(){h.value=!1,v.value=null,B.value=null,_.value=null,document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",ze),document.removeEventListener("touchmove",Xe),document.removeEventListener("touchend",ze)}function _t(Q){l.value=l.value===Q?null:Q,r("clip-select",l.value)}function ct(Q){I(Q)&&(l.value=Q,r("clip-select",Q),r("clip-long-press",Q))}function Zt(Q){!I(Q)||o.clips.length<=1||(l.value=Q,r("clip-select",Q),r("clip-delete",Q))}function ta(Q,ue){if(!I(Q))return;const oe=o.clips.find(xe=>xe.id===Q);if(!oe||Math.abs(ue)<2)return;const ae=ue/Z.value*o.sensitivity;if(o.useFrameMode){const xe=p.secondsToFrames(oe.sourceIn),Le=p.secondsToFrames(ae),Ke=Math.max(0,xe+Le),pt=p.framesToSeconds(Ke);r("trim",Q,"start",pt)}else{const xe=Math.max(0,oe.sourceIn+ae);r("trim",Q,"start",xe)}}function aa(Q,ue){if(!I(Q))return;const oe=o.clips.find(Nt=>Nt.id===Q);if(!oe||!s.value)return;const ae=s.value.getBoundingClientRect(),xe=ue-ae.left-F.value,Le=80;xe<Le?c.value=Math.max(0,c.value-8):xe>ae.width-F.value-Le&&(c.value=Math.min(j.value,c.value+8));const Ke=xe+c.value,pt=1/o.fps;let Vt=Ke/Z.value;const{previous:ft}=et(oe.id),ht=mt(Vt,[0,ft==null?void 0:ft.timelineEnd,o.playhead],0,oe.timelineEnd-pt);Vt=ht.value,B.value=ht.guideTime;let Ot=oe.sourceIn+(Vt-oe.timelineStart);Ot=Math.round(Ot*o.fps)/o.fps,r("trim",Q,"start",Ot)}function ia(Q,ue){if(!I(Q))return;const oe=o.clips.find(Ut=>Ut.id===Q);if(!oe||!s.value)return;const ae=s.value.getBoundingClientRect(),xe=ue-ae.left-F.value,Le=80;xe<Le?c.value=Math.max(0,c.value-8):xe>ae.width-F.value-Le&&(c.value=Math.min(j.value,c.value+8));const Ke=xe+c.value,pt=1/o.fps,Vt=X(oe);let ft=Ke/Z.value;const{next:ht}=et(oe.id),Ot=mt(ft,[ht==null?void 0:ht.timelineStart,o.playhead],oe.timelineStart+pt,Vt);ft=Ot.value,B.value=Ot.guideTime;let Nt=oe.sourceIn+(ft-oe.timelineStart);Nt=Math.round(Nt*o.fps)/o.fps,r("trim",Q,"end",Nt)}function wa(Q){var oe;if(!x.value||!s.value)return null;const ue=Array.from(s.value.querySelectorAll(".timeline-track-lane__body"));for(const ae of ue){const xe=ae.getBoundingClientRect();if(Q>=xe.top&&Q<=xe.bottom){const Le=ae.getAttribute("data-track-id");if(!Le)continue;return((oe=o.tracks)==null?void 0:oe.find(pt=>pt.id===Le))??null}}return null}function Sa(Q,ue,oe){if(!I(Q))return;const ae=o.clips.find(Ut=>Ut.id===Q);if(!ae||!s.value)return;const xe=s.value.getBoundingClientRect(),Le=ue-xe.left-F.value,Ke=80;Le<Ke?c.value=Math.max(0,c.value-8):Le>xe.width-F.value-Ke&&(c.value=Math.min(j.value,c.value+8));const pt=Le+c.value,Vt=ae.timelineEnd-ae.timelineStart,ft=gt(ae);let ht=pt/Z.value;const Ot=mt(ht,[ft.minStart,ft.maxStart,o.playhead,o.playhead-Vt],ft.minStart,ft.maxStart);ht=Ot.value,B.value=Ot.guideTime,ht=Math.round(ht*o.fps)/o.fps;let Nt;if(typeof oe=="number"){const Ut=wa(oe);_.value=(Ut==null?void 0:Ut.id)??null,Ut&&Ut.id!==(ae.trackId??null)&&Ut.locked!==!0&&(Nt=Ut.id)}Nt!==void 0?r("clip-move",Q,ht,Nt):r("clip-move",Q,ht)}function ka(Q,ue){if(!I(Q))return;const oe=o.clips.find(Le=>Le.id===Q);if(!oe||Math.abs(ue)<2)return;const ae=ue/Z.value*o.sensitivity,xe=Le=>Math.max(0,Math.round(Le*o.fps)/o.fps);if(o.useFrameMode){const Le=p.secondsToFrames(oe.sourceOut),Ke=p.secondsToFrames(ae),pt=X(oe),Vt=oe.sourceIn+(pt-oe.timelineStart),ft=p.secondsToFrames(Vt),ht=Math.min(ft,Le+Ke),Ot=p.framesToSeconds(ht);r("trim",Q,"end",Ot)}else{const Le=X(oe),Ke=oe.sourceIn+(Le-oe.timelineStart),pt=Math.min(Ke,oe.sourceOut+ae),Vt=xe(pt);r("trim",Q,"end",Vt)}}function an(Q,ue){if(!I(Q))return;const oe=o.clips.find(Le=>Le.id===Q);if(!oe||Math.abs(ue)<2)return;const ae=ue/Z.value*o.sensitivity,xe=Le=>Math.max(0,Math.round(Le*o.fps)/o.fps);if(o.useFrameMode){const Le=p.secondsToFrames(oe.timelineStart),Ke=p.secondsToFrames(ae),pt=Math.max(0,Le+Ke),Vt=p.framesToSeconds(pt);r("clip-move",Q,Vt)}else{const Le=Math.max(0,oe.timelineStart+ae),Ke=xe(Le);r("clip-move",Q,Ke)}}return a({handleTrimStart:ta,handleTrimEnd:ka,handleClipDrag:an,handleTrimStartAbs:aa,handleTrimEndAbs:ia,handleClipDragAbs:Sa,handleClipLongPress:ct}),e.watch(()=>o.playhead,Q=>{const ue=Q*Z.value;ue<c.value+50?c.value=Math.max(0,ue-50):ue>c.value+b.value-50&&(c.value=Math.min(j.value,ue-b.value+50))}),e.onMounted(()=>{const Q=new ResizeObserver(ue=>{ue[0]&&(f.value=Math.round(ue[0].contentRect.width))});s.value&&Q.observe(s.value),e.onUnmounted(()=>Q.disconnect())}),e.onUnmounted(()=>{ze()}),e.watch([ne,L],()=>{c.value>j.value&&(c.value=j.value)}),e.watch(B,(Q,ue)=>{const oe=Q!==null;oe!==(ue!==null)&&r("snap-state-change",oe)}),(Q,ue)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:Ne},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Se},[e.createElementVNode("div",Qb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Te.value,oe=>(e.openBlock(),e.createElementBlock("span",{key:oe.position,class:"time-marker",style:e.normalizeStyle({left:`${oe.position}px`})},e.toDisplayString(oe.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":D.value,"is-panning":h.value&&v.value==="pan","overflow-left":q.value,"overflow-right":te.value}]),onTouchstart:ot,onTouchmove:kt,onTouchend:xt,onMousedown:we},[x.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-lanes",style:e.normalizeStyle({"--timeline-track-header-width":`${yc}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,oe=>(e.openBlock(),e.createElementBlock("div",{key:oe.track.id,class:e.normalizeClass(["timeline-track-lane",{"timeline-track-lane--locked":oe.track.locked,"timeline-track-lane--hidden":oe.track.hidden,"timeline-track-lane--drop-target":_.value===oe.track.id&&oe.track.locked!==!0,"timeline-track-lane--drop-rejected":_.value===oe.track.id&&oe.track.locked===!0}]),style:e.normalizeStyle({height:`${oe.height}px`}),"data-track-id":oe.track.id},[e.createVNode(Yb,{class:"timeline-track-lane__header",track:oe.track,onToggleLock:ue[0]||(ue[0]=ae=>r("toggle-lock",ae)),onToggleHidden:ue[1]||(ue[1]=ae=>r("toggle-hidden",ae)),onToggleMuted:ue[2]||(ue[2]=ae=>r("toggle-muted",ae)),onToggleSolo:ue[3]||(ue[3]=ae=>r("toggle-solo",ae)),onRenameTrack:ue[4]||(ue[4]=(ae,xe)=>r("rename-track",ae,xe)),onDeleteTrack:ue[5]||(ue[5]=ae=>r("delete-track",ae)),onReorderTrack:ue[6]||(ue[6]=(ae,xe)=>r("reorder-track",ae,xe))},null,8,["track"]),e.createElementVNode("div",{class:"video-track timeline-track-lane__body","data-track-id":oe.track.id},[oe.track.hidden?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oe.clips,ae=>(e.openBlock(),e.createElementBlock("div",{key:`${ae.id}-extent`,class:"clip-extent",style:e.normalizeStyle(le(ae,oe.height)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oe.clips,ae=>(e.openBlock(),e.createBlock(gc,{key:ae.id,clip:ae,scale:Z.value,"scroll-offset":c.value,selected:m.value===ae.id,"is-mobile":i.value,"can-delete":o.clips.length>1&&I(ae.id),"data-locked":oe.track.locked===!0?"true":void 0,onSelect:xe=>_t(ae.id),onDelete:xe=>Zt(ae.id),onLongPress:xe=>ct(ae.id),onTrimStartAbs:xe=>aa(ae.id,xe),onTrimEndAbs:xe=>ia(ae.id,xe),onDragAbs:(xe,Le)=>Sa(ae.id,xe,Le)},null,8,["clip","scale","scroll-offset","selected","is-mobile","can-delete","data-locked","onSelect","onDelete","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],64))],8,t1)],14,e1))),128))],4)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.clips,oe=>(e.openBlock(),e.createElementBlock("div",{key:`${oe.id}-extent`,class:"clip-extent",style:e.normalizeStyle(le(oe)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.clips,oe=>(e.openBlock(),e.createBlock(gc,{key:oe.id,clip:oe,scale:Z.value,"scroll-offset":c.value,selected:m.value===oe.id,"is-mobile":i.value,"can-delete":o.clips.length>1&&I(oe.id),onSelect:ae=>_t(oe.id),onDelete:ae=>Zt(oe.id),onLongPress:ae=>ct(oe.id),onTrimStartAbs:ae=>aa(oe.id,ae),onTrimEndAbs:ae=>ia(oe.id,ae),onDragAbs:(ae,xe)=>Sa(oe.id,ae,xe)},null,8,["clip","scale","scroll-offset","selected","is-mobile","can-delete","onSelect","onDelete","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512)),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${F.value+ce.value}px`}),onMousedown:$e,onTouchstart:$e},[...ue[8]||(ue[8]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"split-indicator",style:e.normalizeStyle({left:`${F.value+ce.value}px`})},null,4)):e.createCommentVNode("",!0),me.value!==null?(e.openBlock(),e.createElementBlock("div",{key:3,class:"snap-guide",style:e.normalizeStyle({left:`${F.value+me.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:4,class:"frame-mode-toggle",onClick:ue[7]||(ue[7]=oe=>Q.$emit("toggle-frame-mode")),"aria-label":Q.useFrameMode?"Switch to time mode":"Switch to frame mode",title:Q.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(Q.useFrameMode?"F":"T"),9,a1))],34),D.value?(e.openBlock(),e.createElementBlock("div",n1,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(ge.value),onMousedown:Ye,onTouchstart:Ye},null,36)])):e.createCommentVNode("",!0)],34))}}),yl=Be(o1,[["__scopeId","data-v-2484f443"]]),i1={key:0,class:"control-group primary-controls"},r1=["disabled"],s1=["disabled"],l1=["disabled"],d1=["disabled"],c1=["disabled"],u1=["disabled"],m1={key:1,class:"control-group mobile-action-controls"},p1=["aria-expanded"],f1={key:0,class:"mobile-action-menu",role:"menu","aria-label":"Clip actions","data-testid":"timeline-mobile-action-menu"},h1=["disabled"],v1=["disabled"],g1=["disabled"],y1=["disabled"],b1=["disabled"],w1=["disabled"],k1={class:"control-group zoom-controls"},_1={class:"zoom-slider"},E1=["value"],x1={class:"control-group playback-controls"},S1=["aria-label"],C1={key:2,class:"control-group speed-control"},V1=["value"],N1=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},canAddTrack:{type:Boolean,default:!0},showAddTrack:{type:Boolean,default:!1},canUndo:{type:Boolean,default:!1},canRedo:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","add-track","undo","redo","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(n,{emit:a}){const t=a,o=e.ref(!1);function i(m){switch(m){case"split":t("split");break;case"delete":t("delete");break;case"duplicate":t("duplicate");break;case"add-track":t("add-track");break;case"undo":t("undo");break;case"redo":t("redo");break}o.value=!1}function r(m){const p=m.target;t("zoom-change",Number(p.value))}function s(){t("fit-to-window")}function l(){t("frame-forward")}function d(){t("frame-backward")}function c(){t("skip-to-start")}function u(){t("skip-to-end")}function f(m){const p=m.target;t("speed-change",Number(p.value))}return(m,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:m.isMobile}])},[m.isMobile?(e.openBlock(),e.createElementBlock("div",m1,[e.createElementVNode("button",{class:"control-button","data-testid":"timeline-btn-mobile-actions","aria-expanded":o.value?"true":"false","aria-label":"Clip actions",onClick:p[6]||(p[6]=h=>o.value=!o.value)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(fh)},null,8,["icon"]),p[20]||(p[20]=e.createElementVNode("span",{class:"control-label"},"Actions",-1))],8,p1),o.value?(e.openBlock(),e.createElementBlock("div",f1,[m.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",role:"menuitem",disabled:!m.canAddTrack,"data-testid":"timeline-mobile-btn-add-track",onClick:p[7]||(p[7]=h=>i("add-track"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(rr)},null,8,["icon"]),p[21]||(p[21]=e.createTextVNode(" Add Track ",-1))],8,h1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canUndo,"data-testid":"timeline-mobile-btn-undo",onClick:p[8]||(p[8]=h=>i("undo"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(jd)},null,8,["icon"]),p[22]||(p[22]=e.createTextVNode(" Undo ",-1))],8,v1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canRedo,"data-testid":"timeline-mobile-btn-redo",onClick:p[9]||(p[9]=h=>i("redo"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zd)},null,8,["icon"]),p[23]||(p[23]=e.createTextVNode(" Redo ",-1))],8,g1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canSplit,"data-testid":"timeline-mobile-btn-split",onClick:p[10]||(p[10]=h=>i("split"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(br)},null,8,["icon"]),p[24]||(p[24]=e.createTextVNode(" Split ",-1))],8,y1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.selectedClip,"data-testid":"timeline-mobile-btn-duplicate",onClick:p[11]||(p[11]=h=>i("duplicate"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(el)},null,8,["icon"]),p[25]||(p[25]=e.createTextVNode(" Duplicate ",-1))],8,b1),e.createElementVNode("button",{type:"button",role:"menuitem",class:"danger-menu-item",disabled:!m.canDelete,"data-testid":"timeline-mobile-btn-delete",onClick:p[12]||(p[12]=h=>i("delete"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(wr)},null,8,["icon"]),p[26]||(p[26]=e.createTextVNode(" Delete ",-1))],8,w1)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",i1,[m.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-button",disabled:!m.canAddTrack,"data-testid":"timeline-btn-add-track","aria-label":"Add video track",title:"Add Track",onClick:p[0]||(p[0]=h=>m.$emit("add-track"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(rr)},null,8,["icon"]),p[16]||(p[16]=e.createElementVNode("span",{class:"control-label"},"Add Track",-1))],8,r1)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-button",disabled:!m.canUndo,"data-testid":"timeline-btn-undo","aria-label":"Undo",title:"Undo",onClick:p[1]||(p[1]=h=>m.$emit("undo"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(jd)},null,8,["icon"])],8,s1),e.createElementVNode("button",{class:"control-button",disabled:!m.canRedo,"data-testid":"timeline-btn-redo","aria-label":"Redo",title:"Redo",onClick:p[2]||(p[2]=h=>m.$emit("redo"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zd)},null,8,["icon"])],8,l1),e.createElementVNode("button",{class:"control-button",disabled:!m.canSplit,"data-testid":"timeline-btn-split","aria-label":"Split selected clip at playhead",title:"Split",onClick:p[3]||(p[3]=h=>m.$emit("split"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(br)},null,8,["icon"]),p[17]||(p[17]=e.createElementVNode("span",{class:"control-label"},"Split",-1))],8,d1),e.createElementVNode("button",{class:"control-button",disabled:!m.selectedClip,"data-testid":"timeline-btn-duplicate","aria-label":"Duplicate selected clip",title:"Duplicate",onClick:p[4]||(p[4]=h=>m.$emit("duplicate"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(el)},null,8,["icon"]),p[18]||(p[18]=e.createElementVNode("span",{class:"control-label"},"Duplicate",-1))],8,c1),e.createElementVNode("button",{class:"control-button danger-button",disabled:!m.canDelete,"data-testid":"timeline-btn-delete","aria-label":"Delete selected clip",title:"Delete",onClick:p[5]||(p[5]=h=>m.$emit("delete"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(wr)},null,8,["icon"]),p[19]||(p[19]=e.createElementVNode("span",{class:"control-label"},"Delete",-1))],8,u1)])),e.createElementVNode("div",k1,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[13]||(p[13]=h=>m.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Ih)},null,8,["icon"])]),e.createElementVNode("div",_1,[e.createElementVNode("input",{type:"range",value:m.zoomLevel,onInput:r,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,E1)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[14]||(p[14]=h=>m.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(rr)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(vh)},null,8,["icon"]),p[27]||(p[27]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",x1,[e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to start"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Mh)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:d,"aria-label":"Previous frame"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Ch)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:p[15]||(p[15]=h=>m.$emit("play-pause")),"aria-label":m.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(W.IonIcon),{icon:m.isPlaying?e.unref(Wl):e.unref(Zl)},null,8,["icon"])],8,S1),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Next frame"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Th)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:u,"aria-label":"Skip to end"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Bh)},null,8,["icon"])])]),m.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",C1,[p[29]||(p[29]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:m.playbackSpeed,onChange:f,class:"speed-select","aria-label":"Playback speed"},[...p[28]||(p[28]=[e.createStaticVNode('<option value="0.25" data-v-c7b0395a>0.25x</option><option value="0.5" data-v-c7b0395a>0.5x</option><option value="1" data-v-c7b0395a>1x</option><option value="1.5" data-v-c7b0395a>1.5x</option><option value="2" data-v-c7b0395a>2x</option>',5)])],40,V1)]))],2))}}),bl=Be(N1,[["__scopeId","data-v-c7b0395a"]]),T1={key:0,class:"category-section"},M1={class:"category-carousel-wrapper"},B1=["disabled"],I1=["onClick","data-testid","aria-label"],F1={class:"category-name"},$1=["disabled"],D1={class:"filter-section"},R1={class:"filter-carousel-wrapper"},A1=["disabled"],L1=["onClick","onKeydown","data-testid","aria-label"],P1=["onClick"],O1={class:"filter-preview"},U1={class:"filter-placeholder"},z1={class:"filter-name"},j1=["disabled"],W1={class:"carousel-pagination"},Z1=["onClick"],H1={key:1,class:"filter-adjustments"},X1={class:"adjustment-header"},G1={class:"adjustment-actions"},J1={key:0},K1={key:0,class:"slider-control"},q1={class:"control-label"},Y1={class:"slider-wrapper"},Q1={class:"slider-value"},ew={key:1,class:"color-control"},tw={class:"control-label"},aw={class:"color-wrapper"},nw=["value","onInput","disabled"],ow={class:"color-value"},iw={key:2,class:"toggle-control"},rw={class:"control-label"},sw={key:3,class:"select-control"},lw={class:"control-label"},dw=["value","onChange","disabled"],cw=["value"],uw={key:1,class:"no-params"},mw=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(n,{emit:a}){const t=n,o=a,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),d=e.ref(new Map),c=e.ref(),u=e.ref(),f={all:mn,adjust:jo,color:pn,blur:Wi,light:Wo,effects:Ms,stylize:Ko,advanced:mn,distortion:qo,transform:qo};function m(M){return M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(M){return M.replace(/[-_]/g," ").replace(/\b\w/g,I=>I.toUpperCase())}function h(M){return f[M.toLowerCase()]??mn}const v=e.computed(()=>{const M=Array.from(new Set(t.filters.map(I=>I.category).filter(I=>typeof I=="string"&&I.length>0))).sort((I,z)=>I.localeCompare(z));return[{id:"all",name:"All",icon:mn},...M.map(I=>({id:I,name:p(I),icon:h(I)}))]}),k=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(M=>M.category===i.value));e.watch(v,M=>{new Set(M.map(X=>X.id)).has(i.value)||(i.value="all");const z=Math.max(0,M.length-3);s.value>z&&(s.value=z)},{immediate:!0});function V(M){var I;return((I=t.activeFilters)==null?void 0:I.has(M))||!1}function B(M){if(r.value=M,!V(M.id)&&(o("apply-filter",M),M.params&&M.params.length>0)){const I=new Map;M.params.forEach(z=>{I.set(z.id,z.default)}),d.value.set(M.id,I)}o("preview-filter",M)}function _(M){var I;o("remove-filter",M),d.value.delete(M),((I=r.value)==null?void 0:I.id)===M&&(r.value=null)}function g(M){if(typeof M=="number"&&Number.isFinite(M))return M;if(typeof M=="string"){const I=Number(M);return Number.isFinite(I)?I:null}return null}function E(M,I){var L;const z=t.filters.find(D=>D.id===M),X=z==null?void 0:z.params.find(D=>D.id===I),le=(X==null?void 0:X.default)??0,ve=D=>typeof le=="number"?g(D)??le:typeof le=="boolean"?typeof D=="boolean"?D:le:typeof D=="string"?D:le,ie=(L=t.activeFilters)==null?void 0:L.get(M);if(ie&&ie.params){const D=ie.params[I];if(D!=null)return ve(D)}const ne=d.value.get(M);if(ne){const D=ne.get(I);if(D!=null)return ve(D)}return le}function C(M,I,z){var X;d.value.has(M)||d.value.set(M,new Map),(X=d.value.get(M))==null||X.set(I,z),o("update-param",M,I,z)}function N(M){if(typeof M=="boolean")return M?"On":"Off";if(typeof M=="string"){const z=g(M);return z===null?"0":Number.isInteger(z)?z.toString():z.toFixed(2)}const I=g(M);return I===null?"0":Number.isInteger(I)?I.toString():I.toFixed(2)}function S(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const M=new Map;r.value.params.forEach(I=>{M.set(I.id,I.default)}),d.value.set(r.value.id,M)}}function A(M){const I=t.filters.find(z=>z.id===M);I&&I.params&&I.params.forEach(z=>{C(M,z.id,z.default)})}function Z(M){return{basic:jo,color:pn,blur:Wi,light:Wo,effects:Ms,stylize:Ko,adjustment:jo,"color-matrix":pn,glow:mn,distortion:qo}[M]||mn}function x(M){return{adjustment:jo,brightness:Wo,contrast:jo,saturation:pn,blur:Wi,"gaussian-blur":Wi,"color-matrix":pn,grayscale:Ko,sepia:Ko,vignette:qo,glow:mn,glitch:Ms,godray:Wo,lightmap:Wo}[M.id]||Z(M.category)}function F(){s.value>0&&(s.value--,U(c.value,s.value))}function b(){s.value<v.value.length-3&&(s.value++,U(c.value,s.value))}function R(){l.value>0&&(l.value--,U(u.value,l.value))}function P(){l.value<k.value.length-4&&(l.value++,U(u.value,l.value))}function O(M){l.value=M*4,U(u.value,l.value)}function U(M,I){var z;if(M){const X=((z=M.querySelector(".category-chip, .filter-card"))==null?void 0:z.clientWidth)||100;M.scrollTo({left:I*(X+8),behavior:"smooth"})}}return(M,I)=>{var z;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:M.compact}])},[M.showCategories?(e.openBlock(),e.createElementBlock("div",T1,[e.createElementVNode("div",M1,[e.createElementVNode("button",{onClick:F,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Wd)},null,8,["icon"])],8,B1),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:c,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,X=>(e.openBlock(),e.createElementBlock("button",{key:X.id,onClick:le=>i.value=X.id,class:e.normalizeClass(["category-chip",{active:i.value===X.id}]),"data-testid":`btn-filter-category-${m(X.id)}`,"aria-label":`Filter category ${X.name}`},[e.createVNode(e.unref(W.IonIcon),{icon:X.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",F1,e.toDisplayString(X.name),1)],10,I1))),128))],512),e.createElementVNode("button",{onClick:b,class:"carousel-nav carousel-nav-right",disabled:s.value>=v.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Zd)},null,8,["icon"])],8,$1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",D1,[e.createElementVNode("div",R1,[e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Wd)},null,8,["icon"])],8,A1),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,X=>{var le;return e.openBlock(),e.createElementBlock("div",{key:X.id,class:e.normalizeClass(["filter-card",{active:V(X.id),selected:((le=r.value)==null?void 0:le.id)===X.id}]),onClick:ve=>B(X),onKeydown:[e.withKeys(ve=>B(X),["enter"]),e.withKeys(e.withModifiers(ve=>B(X),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${m(X.id)}`,"aria-label":`Select filter ${X.name}`},[V(X.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ve=>_(X.id),["stop"])},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Tu)},null,8,["icon"])],8,P1)):e.createCommentVNode("",!0),e.createElementVNode("div",O1,[e.createElementVNode("div",U1,[e.createVNode(e.unref(W.IonIcon),{icon:x(X),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",z1,e.toDisplayString(X.name),1)],42,L1)}),128))],512),e.createElementVNode("button",{onClick:P,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,k.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Zd)},null,8,["icon"])],8,j1)]),e.createElementVNode("div",W1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(k.value.length/4),(X,le)=>(e.openBlock(),e.createElementBlock("span",{key:le,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===le}]),onClick:ve=>O(le)},null,10,Z1))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",H1,[e.createElementVNode("div",X1,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",G1,[V(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:S,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),V(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:I[0]||(I[0]=X=>_(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),V(r.value.id)&&((z=r.value.params)==null?void 0:z.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:I[1]||(I[1]=X=>A(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",J1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,X=>(e.openBlock(),e.createElementBlock("div",{key:X.id,class:"adjustment-control"},[!X.type||X.type==="slider"?(e.openBlock(),e.createElementBlock("div",K1,[e.createElementVNode("label",q1,e.toDisplayString(X.label||X.id),1),e.createElementVNode("div",Y1,[e.createVNode(e.unref(W.IonRange),{value:E(r.value.id,X.id),onIonChange:le=>C(r.value.id,X.id,le.detail.value),min:X.min,max:X.max,step:X.step||.01,color:"primary",class:"compact-slider",disabled:!V(r.value.id),"data-testid":`range-filter-${m(r.value.id)}-${m(X.id)}`,"aria-label":`Adjust ${X.label||X.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Q1,e.toDisplayString(N(E(r.value.id,X.id))),1)])])):X.type==="color"?(e.openBlock(),e.createElementBlock("div",ew,[e.createElementVNode("label",tw,e.toDisplayString(X.label||X.id),1),e.createElementVNode("div",aw,[e.createElementVNode("input",{type:"color",value:E(r.value.id,X.id),onInput:le=>C(r.value.id,X.id,le.target.value),disabled:!V(r.value.id),class:"color-input"},null,40,nw),e.createElementVNode("span",ow,e.toDisplayString(E(r.value.id,X.id)),1)])])):X.type==="toggle"?(e.openBlock(),e.createElementBlock("div",iw,[e.createElementVNode("label",rw,e.toDisplayString(X.label||X.id),1),e.createVNode(e.unref(W.IonToggle),{checked:!!E(r.value.id,X.id),onIonChange:le=>C(r.value.id,X.id,le.detail.checked),disabled:!V(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):X.type==="select"?(e.openBlock(),e.createElementBlock("div",sw,[e.createElementVNode("label",lw,e.toDisplayString(X.label||X.id),1),e.createElementVNode("select",{value:E(r.value.id,X.id),onChange:le=>C(r.value.id,X.id,le.target.value),disabled:!V(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.options,le=>(e.openBlock(),e.createElementBlock("option",{key:String(le.value),value:le.value},e.toDisplayString(le.label),9,cw))),128))],40,dw)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",uw," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),wl=Be(mw,[["__scopeId","data-v-9efd15d9"]]);class pw{constructor(a){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=a}setComposition(a){this.composition=a}mapMediablesToPIXI(a){switch(a.filterId){case"blur":return this.createBlurFilter(a.params);case"brightness":return this.createBrightnessFilter(a.params);case"contrast":return this.createContrastFilter(a.params);case"saturation":return this.createSaturationFilter(a.params);case"hue":return this.createHueFilter(a.params);case"vintage":return this.createVintageFilter(a.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(a){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=a.intensity||5,r.quality=a.quality||4,r}catch{return null}}createBrightnessFilter(a){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(a.value||1,!1),r}catch{return null}}createContrastFilter(a){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(a.value||1,!1),r}catch{return null}}createSaturationFilter(a){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(a.value||1,!1),r}catch{return null}}createHueFilter(a){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(a.rotation||0,!1),r}catch{return null}}createVintageFilter(a){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),a.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var a,t;try{const o=(t=(a=window.PIXI)==null?void 0:a.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var a,t;try{const o=(t=(a=window.PIXI)==null?void 0:a.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(a){if(this.composition){this.clearFilters();for(const t of a){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(a,t){try{this.composition.applyFilter&&await this.composition.applyFilter(a,t)}catch{}}updateFilterParams(a,t){var i;const o=this.pixiFilters.get(a);o&&(this.filterParams.set(a,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(a){return this.filterParams.get(a)||{}}removeFilter(a){var t;this.pixiFilters.delete(a),this.filterParams.delete(a),this.filterTypes.delete(a),this.filterIntensity.delete(a),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(a)}clearFilters(){var a;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(a=this.composition)!=null&&a.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const a=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;a.push({id:o,filterId:r,params:i,intensity:s})}),a}async importFilterConfig(a){await this.applyFilters(a)}destroy(){this.clearFilters(),this.composition=null}}const fw={class:"video-filter-preview"},hw={class:"preview-title"},vw={class:"filter-controls"},gw={class:"control-input"},yw=["value","onInput","min","max","step"],bw={class:"param-value"},ww={class:"preview-container"},kw={key:0,class:"filter-presets"},_w=["onClick"],Ew={class:"preview-actions"},xw=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,d,c=null,u=null;const f=e.computed(()=>{var S;return((S=t.filter)==null?void 0:S.paramRanges)||{}}),m=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 h(){var S;if(i.value){t.useVideoEngine&&t.composition&&(u=new pw(t.composition));try{if(l=new Dt.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(S=t.currentFrame)!=null&&S.dataUrl){const A=await Dt.Assets.load(t.currentFrame.dataUrl);d=new Dt.Sprite(A);const Z=Math.min(l.screen.width/d.texture.width,l.screen.height/d.texture.height);d.scale.set(Z),d.anchor.set(.5),d.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(d)}v()}catch{}}}function v(){if(!(!d||!t.filter))if(t.useVideoEngine&&u){const S={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([S]).then(()=>{}).catch(A=>{}),c&&(c.destroy(),c=null),c=k(t.filter.id,s.value),c&&(d.filters=r.value?null:[c])}else c&&(c.destroy(),c=null),c=k(t.filter.id,s.value),c&&(d.filters=r.value?null:[c])}function k(S,A){switch(S){case"brightness":{const Z=new Dt.ColorMatrixFilter,x=1+(A.value??0);return typeof Z.brightness=="function"&&Z.brightness(x,!1),Z}case"contrast":{const Z=new Dt.ColorMatrixFilter,x=A.value??1;return typeof Z.contrast=="function"&&Z.contrast(x,!1),Z}case"saturation":{const Z=new Dt.ColorMatrixFilter,x=A.value??1;return typeof Z.saturate=="function"&&Z.saturate(x,!1),Z}case"hue":{const Z=new Dt.ColorMatrixFilter,x=A.value??0;return typeof Z.hue=="function"&&Z.hue(x,!1),Z}case"gaussian-blur":{const Z=A.value??5;return new Dt.BlurFilter({strength:Z,quality:4})}case"sepia":{const Z=new Dt.ColorMatrixFilter;return typeof Z.sepia=="function"&&Z.sepia(!1),Z}case"grayscale":{const Z=new Dt.ColorMatrixFilter;return typeof Z.desaturate=="function"&&Z.desaturate(),Z}default:return null}}function V(S,A){const Z=A.target,x=Number.parseFloat(Z.value),F=Number.isFinite(x)?x:0;s.value={...s.value,[S]:F},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),v()}function B(S){return S.charAt(0).toUpperCase()+S.slice(1).replace(/_/g," ")}function _(S,A){var x;const Z=typeof S=="number"?S:Number(S);return Number.isFinite(Z)?A==="hue"||A==="angle"?`${Z}°`:A==="value"&&((x=t.filter)==null?void 0:x.id)==="brightness"?`${Math.round((1+Z)*100)}%`:Number.isInteger(Z)?Z.toString():Z.toFixed(2):"0"}function g(){var S;s.value=((S=t.filter)==null?void 0:S.defaultParams)||{},o("update-params",s.value),v()}function E(S){s.value={...S.params},o("update-params",s.value),v()}function C(S){return JSON.stringify(S.params)===JSON.stringify(s.value)}function N(){o("apply")}return e.watch(()=>t.filter,S=>{S&&(s.value={...S.defaultParams},v())}),e.watch(()=>t.currentFrame,async S=>{if(S!=null&&S.dataUrl&&d){const A=await Dt.Assets.load(S.dataUrl);d.texture=A}}),e.watch(r,v),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),h()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),c&&c.destroy(),u&&u.destroy()}),(S,A)=>{var Z;return e.openBlock(),e.createElementBlock("div",fw,[e.createElementVNode("h4",hw,e.toDisplayString((Z=S.filter)==null?void 0:Z.name)+" Settings",1),e.createElementVNode("div",vw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(x,F)=>(e.openBlock(),e.createElementBlock("div",{key:F,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(B(F)),1),e.createElementVNode("div",gw,[e.createElementVNode("input",{type:"range",value:s.value[F],onInput:b=>V(F,b),min:x.min,max:x.max,step:x.step,class:"param-slider"},null,40,yw),e.createElementVNode("span",bw,e.toDisplayString(_(s.value[F],F)),1)])]))),128))]),e.createElementVNode("div",ww,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:A[0]||(A[0]=x=>r.value=!0),onMouseup:A[1]||(A[1]=x=>r.value=!1),onTouchstart:A[2]||(A[2]=x=>r.value=!0),onTouchend:A[3]||(A[3]=x=>r.value=!1)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(qo)},null,8,["icon"]),A[4]||(A[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),m.value?(e.openBlock(),e.createElementBlock("div",kw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.name,class:e.normalizeClass(["preset-button",{active:C(x)}]),onClick:F=>E(x)},e.toDisplayString(x.name),11,_w))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",Ew,[e.createElementVNode("button",{class:"action-button",onClick:g},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),A[5]||(A[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:N},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Mu)},null,8,["icon"]),A[6]||(A[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),kl=Be(xw,[["__scopeId","data-v-3de3dd04"]]),hm={id:"mobile-share",label:"Mobile share",description:"Fast H.264 MP4 export for short social clips and mobile uploads.",settings:{format:"mp4",codec:"h264",quality:"720p",fps:30,bitrate:45e5,routePreference:"client",maxClientDurationSeconds:90,mobileSuitable:!0,advancedVisibility:"standard"}},vm={id:"hd-web",label:"HD web",description:"Balanced 1080p H.264 MP4 export for web playback.",settings:{format:"mp4",codec:"h264",quality:"1080p",fps:30,bitrate:8e6,routePreference:"auto",maxClientDurationSeconds:180,mobileSuitable:!0,advancedVisibility:"standard"}},gm={id:"original",label:"Original",description:"Server-rendered MP4 export that preserves the editor output quality target.",settings:{format:"mp4",codec:"h264",quality:"1080p",fps:30,routePreference:"server",maxClientDurationSeconds:null,mobileSuitable:!1,advancedVisibility:"standard"}},ym={id:"server-master",label:"Server master",description:"High-bitrate master render for archival and downstream transcodes.",settings:{format:"mov",codec:"h265",quality:"2160p",fps:60,bitrate:32e6,routePreference:"server",maxClientDurationSeconds:null,mobileSuitable:!1,advancedVisibility:"advanced"}},bm=[hm,vm,gm,ym],dd={"mobile-share":hm,"hd-web":vm,original:gm,"server-master":ym},Sw=["mobile-share","hd-web"],Cw=["hd-web","original","mobile-share"],Vw=["server-master","hd-web","original","mobile-share"];function es(n){return typeof n=="string"?dd[n]:n}function Nw(n){const{bitrate:a,codec:t,format:o,fps:i,quality:r}=es(n).settings,s={format:o,codec:t,quality:r,fps:i};return typeof a=="number"&&(s.bitrate=a),s}function Tw(n){const a=es(n);return a.settings.mobileSuitable&&a.settings.advancedVisibility==="standard"}function Mw(n=bm){return n.filter(a=>Tw(a))}function Bw(n,a){const t=es(n).settings.maxClientDurationSeconds;return t!==null&&Number.isFinite(a)&&a>=0&&a<=t}function Iw(n,a){const t=es(n),o=a.endpoints.client&&Bw(t,a.durationSeconds),i=a.endpoints.server;return t.settings.routePreference==="client"?o?"client":i?"server":null:t.settings.routePreference==="server"?i?"server":o?"client":null:o?"client":i?"server":null}function Fw(n,a){return Iw(n,a)!==null}function $w(n){const a=Dw(n);for(const t of a){const o=dd[t];if(Rw(o,n.includeAdvanced===!0)&&!(n.device==="mobile"&&!o.settings.mobileSuitable)&&Fw(o,n))return o}return null}function Dw(n){return n.device==="mobile"?Sw:n.includeAdvanced===!0?Vw:Cw}function Rw(n,a){return n.settings.advancedVisibility==="hidden"?!1:n.settings.advancedVisibility==="standard"||a}const Aw={class:"export-settings"},Lw={class:"setting-group preset-setting"},Pw={class:"setting-copy"},Ow={class:"setting-description"},Uw=["value"],zw={key:0,class:"advanced-toggle","data-testid":"export-advanced-toggle"},jw={class:"preset-summary","data-testid":"export-preset-summary"},Ww={class:"estimated-size"},Zw={key:0,class:"export-progress"},Hw={class:"progress-header"},Xw={class:"progress-percentage"},Gw={class:"progress-time"},Jw={class:"action-buttons"},Kw=["disabled"],qw=["disabled"],Yw=["disabled"],Qw={class:"export-options"},ek="hd-web",tk=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(n,{emit:a}){const t=n,o=a,i={client:!0,server:!0},r=bm,s={"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35},l=e.ref(!1),d=e.ref(g()),c=e.ref(!0),u=e.ref(!1),f=e.ref(0),m=e.ref(0),p=e.ref(0);let h=null;const v=e.computed(()=>t.isMobile?Mw():r.filter(x=>x.settings.advancedVisibility==="hidden"?!1:x.settings.advancedVisibility==="standard"||l.value)),k=e.computed(()=>v.value.find(x=>x.id===d.value)??dd[g()]),V=e.computed(()=>Nw(k.value)),B=e.computed(()=>{const x=V.value,F=[x.quality,x.format.toUpperCase(),x.codec.toUpperCase(),`${x.fps} fps`],b=E(x.bitrate);return b!==null&&F.push(b),F.join(" / ")}),_=e.computed(()=>{const x=V.value,b=(typeof x.bitrate=="number"?x.bitrate/1e6:s[x.quality])*t.duration/8;return b<1e3?`~${Math.round(b)} MB`:`~${(b/1e3).toFixed(1)} GB`});function g(){var x;return((x=$w({durationSeconds:t.duration,device:t.isMobile?"mobile":"desktop",endpoints:i,includeAdvanced:l.value}))==null?void 0:x.id)??ek}function E(x){return typeof x!="number"?null:`${Number((x/1e6).toFixed(1))} Mbps`}function C(){t.isExporting?(o("cancel-export"),A()):N()}function N(){const x=V.value,F={quality:x.quality,format:x.format,optimizeForWeb:c.value,includeWatermark:u.value,presetId:k.value.id,codec:x.codec,fps:x.fps};typeof x.bitrate=="number"&&(F.bitrate=x.bitrate),o("export",F),S()}function S(){f.value=Date.now(),m.value=0,h=window.setInterval(()=>{if(m.value=Math.floor((Date.now()-f.value)/1e3),t.exportProgress>0){const x=m.value/t.exportProgress*100;p.value=Math.max(0,x-m.value)}},1e3)}function A(){h&&(clearInterval(h),h=null)}function Z(x){const F=Math.floor(x/60),b=Math.floor(x%60);return`${F}:${b.toString().padStart(2,"0")}`}return e.watch([()=>t.isMobile,()=>l.value],()=>{v.value.some(F=>F.id===d.value)||(d.value=g())},{immediate:!0}),e.watch(()=>t.isExporting,x=>{x||A()}),e.onUnmounted(()=>{A()}),(x,F)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:x.isMobile}])},[e.createElementVNode("div",Aw,[F[8]||(F[8]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",Lw,[e.createElementVNode("div",Pw,[F[6]||(F[6]=e.createElementVNode("label",{for:"export-preset-select"},"Preset",-1)),e.createElementVNode("span",Ow,e.toDisplayString(k.value.description),1)]),e.withDirectives(e.createElementVNode("select",{id:"export-preset-select","onUpdate:modelValue":F[0]||(F[0]=b=>d.value=b),class:"setting-select preset-select","data-testid":"export-preset-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,b=>(e.openBlock(),e.createElementBlock("option",{key:b.id,value:b.id},e.toDisplayString(b.label),9,Uw))),128))],512),[[e.vModelSelect,d.value]])]),x.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("label",zw,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":F[1]||(F[1]=b=>l.value=b),type:"checkbox","data-testid":"export-advanced-toggle-input"},null,512),[[e.vModelCheckbox,l.value]]),F[7]||(F[7]=e.createElementVNode("span",null,"Advanced presets",-1))])),e.createElementVNode("div",jw,e.toDisplayString(B.value),1),e.createElementVNode("div",Ww,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(wh)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(_.value),1)])]),x.isExporting?(e.openBlock(),e.createElementBlock("div",Zw,[e.createElementVNode("div",Hw,[F[9]||(F[9]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",Xw,e.toDisplayString(x.exportProgress??0)+"%",1)]),e.createVNode(e.unref(W.IonProgressBar),{value:(x.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",Gw,[e.createElementVNode("span",null,e.toDisplayString(Z(m.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(Z(p.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Jw,[e.createElementVNode("button",{class:"control-button secondary",onClick:F[2]||(F[2]=b=>x.$emit("save-draft")),disabled:!x.canExport||x.isExporting},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Pr)},null,8,["icon"]),F[10]||(F[10]=e.createTextVNode(" Save Draft ",-1))],8,Kw),e.createElementVNode("button",{class:"control-button secondary",onClick:F[3]||(F[3]=b=>x.$emit("reset")),disabled:x.isExporting},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),F[11]||(F[11]=e.createTextVNode(" Reset ",-1))],8,qw),e.createElementVNode("button",{class:"control-button primary",onClick:C,disabled:!x.canExport&&!x.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(W.IonIcon),{icon:x.isExporting?e.unref(Un):e.unref(vo)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(x.isExporting?"Cancel":"Export Video"),1)],8,Yw)]),e.createElementVNode("div",Qw,[e.createVNode(e.unref(W.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonCheckbox),{modelValue:c.value,"onUpdate:modelValue":F[4]||(F[4]=b=>c.value=b)},null,8,["modelValue"]),e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...F[12]||(F[12]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(W.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonCheckbox),{modelValue:u.value,"onUpdate:modelValue":F[5]||(F[5]=b=>u.value=b)},null,8,["modelValue"]),e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...F[13]||(F[13]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),_l=Be(tk,[["__scopeId","data-v-d26ca1bc"]]),ak={class:"thumbnail-picker"},nk={class:"thumbnail-grid"},ok=["onClick"],ik=["src","alt"],rk={key:1,class:"thumbnail-placeholder"},sk={class:"thumbnail-time"},lk={class:"custom-selector"},dk={class:"time-input-group"},ck=["max"],uk={class:"time-value"},mk=["disabled"],pk={class:"picker-actions"},fk=["disabled"],hk=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(n,{emit:a}){const t=n,o=a,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function d(){const V=[];if(t.duration<=10)for(let _=0;_<Math.min(9,t.duration);_++)V.push(_);else{const _=t.duration/10;for(let g=1;g<=9;g++)V.push(_*g)}return V}async function c(V){try{const B=document.createElement("video");return B.crossOrigin="anonymous",B.src=await u(),new Promise(_=>{B.addEventListener("loadedmetadata",()=>{B.currentTime=V}),B.addEventListener("seeked",()=>{const g=document.createElement("canvas");g.width=B.videoWidth,g.height=B.videoHeight;const E=g.getContext("2d");E?(E.drawImage(B,0,0),_(g.toDataURL("image/jpeg",.8))):_(null),B.remove()}),B.addEventListener("error",()=>{_(null),B.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function f(){const V=d();i.value=V.map(_=>({time:_,loading:!0}));const B=3;for(let _=0;_<i.value.length;_+=B){const g=i.value.slice(_,_+B);await Promise.all(g.map(async E=>{const C=await c(E.time);C&&(E.dataUrl=C),E.loading=!1}))}}function m(V){r.value=V,s.value=i.value[V].time}function p(){r.value=-1}async function h(){l.value=!0;try{const V=await c(s.value);if(V){const B=i.value.findIndex(_=>Math.abs(_.time-s.value)<.1);B>=0?(i.value[B].dataUrl=V,r.value=B):(i.value.push({time:s.value,dataUrl:V}),r.value=i.value.length-1,i.value.sort((_,g)=>_.time-g.time),r.value=i.value.findIndex(_=>_.time===s.value))}}finally{l.value=!1}}function v(){const V=r.value>=0?i.value[r.value].time:s.value;o("select",V)}function k(V){const B=Math.floor(V/60),_=Math.floor(V%60),g=Math.floor(V%1*100);return B>0?`${B}:${_.toString().padStart(2,"0")}.${g.toString().padStart(2,"0")}`:`${_}.${g.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),(V,B)=>(e.openBlock(),e.createElementBlock("div",ak,[B[5]||(B[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",nk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(_,g)=>(e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass(["thumbnail-item",{selected:r.value===g}]),onClick:E=>m(g)},[_.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:_.dataUrl,alt:`Frame at ${k(_.time)}`},null,8,ik)):(e.openBlock(),e.createElementBlock("div",rk,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",sk,e.toDisplayString(k(_.time)),1)],10,ok))),128))]),e.createElementVNode("div",lk,[B[3]||(B[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",dk,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":B[0]||(B[0]=_=>s.value=_),min:0,max:V.duration,step:.1,onInput:p,class:"time-slider"},null,40,ck),[[e.vModelText,s.value]]),e.createElementVNode("span",uk,e.toDisplayString(k(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:h,disabled:l.value},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(lh)},null,8,["icon"]),B[2]||(B[2]=e.createTextVNode(" Capture Frame ",-1))],8,mk)]),e.createElementVNode("div",pk,[e.createElementVNode("button",{class:"action-button",onClick:B[1]||(B[1]=_=>V.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:v,disabled:r.value===-1},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Mu)},null,8,["icon"]),B[4]||(B[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,fk)])]))}}),vk=Be(hk,[["__scopeId","data-v-336c322c"]]),gk={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},yk={class:"mb-4"},bk={class:"space-y-2 max-h-64 overflow-y-auto"},wk={class:"flex items-center justify-between"},kk={class:"flex-1"},_k={class:"font-medium text-gray-900 dark:text-white"},Ek={class:"text-sm text-gray-500 dark:text-gray-400"},xk={class:"flex items-center space-x-2"},Sk=["onClick"],Ck=["onClick"],Vk={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Nk={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Tk={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Mk={class:"space-y-4"},Bk={class:"grid grid-cols-2 gap-4"},Ik={class:"grid grid-cols-2 gap-4"},Fk={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},$k={class:"grid grid-cols-2 gap-3"},Dk={class:"flex justify-end space-x-3 mt-6"},Rk=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(n,{emit:a}){const t=a,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(m){Object.assign(s,m),i.value=m}function d(){o.value=!1,i.value=null,Object.assign(s,r())}function c(){const m={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(m.animation={type:s.animationType},s.animationDuration!==void 0&&(m.animation.duration=s.animationDuration),s.animationEasing&&(m.animation.easing=s.animationEasing),m.animation))switch(s.animationType){case"rotate":m.animation.rotation={from:0,to:360};break;case"scale":m.animation.scale={from:.5,to:1};break;case"slide":m.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,m):t("add-overlay",m),d()}function u(m){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",m)}function f(m){const p=Math.floor(m/60),h=Math.floor(m%60);return`${p}:${h.toString().padStart(2,"0")}`}return(m,p)=>(e.openBlock(),e.createElementBlock("div",gk,[e.createElementVNode("div",yk,[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]=h=>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",bk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.overlays,h=>(e.openBlock(),e.createElementBlock("div",{key:h.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",wk,[e.createElementVNode("div",kk,[e.createElementVNode("div",_k,e.toDisplayString(h.text.substring(0,30))+e.toDisplayString(h.text.length>30?"...":""),1),e.createElementVNode("div",Ek,e.toDisplayString(f(h.startTime??0))+" - "+e.toDisplayString(f((h.startTime||0)+(h.duration||5))),1)]),e.createElementVNode("div",xk,[e.createElementVNode("button",{onClick:v=>l(h),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,Sk),e.createElementVNode("button",{onClick:v=>u(h.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,Ck)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Vk," 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(d,["self"])},[e.createElementVNode("div",Nk,[e.createElementVNode("h4",Tk,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Mk,[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]=h=>s.text=h),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",Bk,[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]=h=>s.fontSize=h),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]=h=>s.color=h),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]=h=>s.position=h),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",Ik,[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]=h=>s.startTime=h),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]=h=>s.duration=h),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]=h=>s.animationType=h),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",Fk,[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",$k,[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]=h=>s.animationDuration=h),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]=h=>s.animationEasing=h),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",Dk,[e.createElementVNode("button",{onClick:d,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:c,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)]))}}),El=Be(Rk,[["__scopeId","data-v-f86e688c"]]),Ak={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Lk={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Pk=["onClick"],Ok={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"},Uk={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},zk={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},jk={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},Wk={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"},Zk={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"},Hk={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"},Xk={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},Gk={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Jk={class:"space-y-3"},Kk={class:"flex items-center space-x-2"},qk=["disabled"],Yk=["disabled"],Qk={key:1,class:"mt-4"},e2={class:"space-y-2 max-h-32 overflow-y-auto"},t2={class:"text-sm text-gray-700 dark:text-gray-300"},a2=["onClick"],n2=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(hi.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),l=e.ref("linear"),d=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function c(h){r.value=h}function u(){if(!r.value||!d.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};o("apply-transition",h),r.value=null}function f(){if(!r.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};o("preview-transition",h)}function m(h){o("remove-transition",h)}function p(h){return["fade","wipe","slide","zoom"].some(v=>h.includes(v))}return(h,v)=>(e.openBlock(),e.createElementBlock("div",Ak,[v[9]||(v[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",Lk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>{var V;return e.openBlock(),e.createElementBlock("div",{key:k.type,onClick:B=>c(k),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((V=r.value)==null?void 0:V.type)===k.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",Ok,[p(k.type)?(e.openBlock(),e.createElementBlock("svg",Uk,[k.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",zk)):k.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",jk)):k.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",Wk)):k.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",Zk)):(e.openBlock(),e.createElementBlock("path",Hk))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Xk,e.toDisplayString(k.name),1)],10,Pk)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",Gk,[v[6]||(v[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",Jk,[e.createElementVNode("div",null,[v[3]||(v[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",Kk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[0]||(v[0]=k=>s.value=k),type:"range",min:"0.1",max:"3",step:"0.1",class:"flex-1"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[1]||(v[1]=k=>s.value=k),type:"number",min:"0.1",max:"3",step:"0.1",class:"w-16 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[v[5]||(v[5]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":v[2]||(v[2]=k=>l.value=k),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...v[4]||(v[4]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("button",{onClick:u,disabled:!d.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",d.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,qk),e.createElementVNode("button",{onClick:f,disabled:!r.value,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"}," Preview ",8,Yk)])])):e.createCommentVNode("",!0),h.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Qk,[v[8]||(v[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",e2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.appliedTransitions,(k,V)=>(e.openBlock(),e.createElementBlock("div",{key:V,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",t2,e.toDisplayString(k.name)+" ("+e.toDisplayString(k.duration)+"s) ",1),e.createElementVNode("button",{onClick:B=>m(V),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...v[7]||(v[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,a2)]))),128))])])):e.createCommentVNode("",!0),v[10]||(v[10]=e.createElementVNode("div",{class:"mt-4 text-xs text-gray-500 dark:text-gray-400"},[e.createElementVNode("p",null,"Select clips in the timeline, then choose a transition to apply between them.")],-1))]))}}),xl=Be(n2,[["__scopeId","data-v-ffcc612d"]]),o2={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},i2={class:"mb-4"},r2={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},s2={class:"flex items-center justify-between mb-2"},l2={class:"text-sm text-gray-600 dark:text-gray-400"},d2={class:"flex items-center space-x-2"},c2={class:"space-y-3 max-h-64 overflow-y-auto"},u2={class:"flex items-center justify-between mb-2"},m2={class:"font-medium text-gray-900 dark:text-white"},p2={class:"flex items-center space-x-2"},f2=["onClick","title"],h2={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},v2={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},g2=["onClick"],y2=["onClick"],b2={class:"flex items-center space-x-2"},w2={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},k2=["value","onInput","disabled"],_2={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},E2={key:0,class:"ml-2"},x2={key:1,class:"ml-2"},S2={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},C2={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},V2={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},N2={class:"space-y-4"},T2={class:"space-y-2"},M2={class:"flex items-center"},B2={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},I2={class:"grid grid-cols-2 gap-4"},F2={class:"grid grid-cols-2 gap-4"},$2={class:"flex items-center"},D2={class:"flex justify-end space-x-3 mt-6"},R2=["disabled"],A2=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(n,{emit:a}){const t=n,o=a,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}),d=e.reactive(l()),c=e.computed(()=>d.sourceUrl||d.sourceFile);function u(_){const g=_.target;g.files&&g.files[0]&&(d.sourceFile=g.files[0],d.name=d.name||g.files[0].name.replace(/\.[^/.]+$/,""))}function f(_){Object.assign(d,_),r.value=_}function m(){i.value=!1,r.value=null,Object.assign(d,l())}function p(){if(!c.value)return;const _={source:d.sourceFile??d.sourceUrl??"",name:d.name,volume:d.volume,startTime:d.startTime,loop:d.loop};d.duration!==void 0&&(_.duration=d.duration),d.fadeIn>0&&(_.fadeIn=d.fadeIn),d.fadeOut>0&&(_.fadeOut=d.fadeOut),r.value?o("update-track",r.value.id,_):o("add-track",_),m()}function h(_){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",_)}function v(_,g){const E=g.target,C=parseFloat(E.value);o("update-volume",_.id,C)}function k(_){o("toggle-mute",_.id,!_.muted)}function V(){o("update-master-volume",s.value)}function B(_){const g=Math.floor(_/60),E=Math.floor(_%60);return`${g}:${E.toString().padStart(2,"0")}`}return(_,g)=>(e.openBlock(),e.createElementBlock("div",o2,[e.createElementVNode("div",i2,[g[11]||(g[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:g[0]||(g[0]=E=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...g[10]||(g[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",r2,[e.createElementVNode("div",s2,[g[12]||(g[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",l2,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",d2,[g[13]||(g[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":g[1]||(g[1]=E=>s.value=E),onInput:V,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),g[14]||(g[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",c2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.audioLayers,E=>(e.openBlock(),e.createElementBlock("div",{key:E.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",u2,[e.createElementVNode("div",m2,e.toDisplayString(E.name),1),e.createElementVNode("div",p2,[e.createElementVNode("button",{onClick:C=>k(E),class:e.normalizeClass(["p-1 rounded",E.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:E.muted?"Unmute":"Mute"},[E.muted?(e.openBlock(),e.createElementBlock("svg",v2,[...g[16]||(g[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",h2,[...g[15]||(g[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,f2),e.createElementVNode("button",{onClick:C=>f(E),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...g[17]||(g[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,g2),e.createElementVNode("button",{onClick:C=>h(E.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...g[18]||(g[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,y2)])]),e.createElementVNode("div",b2,[e.createElementVNode("span",w2,e.toDisplayString(Math.round((E.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:E.volume||1,onInput:C=>v(E,C),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:E.muted},null,40,k2)]),e.createElementVNode("div",_2,[e.createTextVNode(e.toDisplayString(B(E.startTime||0))+" - "+e.toDisplayString(B((E.startTime||0)+(E.duration||0)))+" ",1),E.fadeIn?(e.openBlock(),e.createElementBlock("span",E2,"Fade In: "+e.toDisplayString(E.fadeIn)+"s",1)):e.createCommentVNode("",!0),E.fadeOut?(e.openBlock(),e.createElementBlock("span",x2,"Fade Out: "+e.toDisplayString(E.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),_.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",S2," 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(m,["self"])},[e.createElementVNode("div",C2,[e.createElementVNode("h4",V2,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",N2,[e.createElementVNode("div",null,[g[20]||(g[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",T2,[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",M2,[g[19]||(g[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":g[2]||(g[2]=E=>d.sourceUrl=E),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,d.sourceUrl]])])])]),e.createElementVNode("div",null,[g[21]||(g[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":g[3]||(g[3]=E=>d.name=E),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,d.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",B2," Volume: "+e.toDisplayString(Math.round(d.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[4]||(g[4]=E=>d.volume=E),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,d.volume,void 0,{number:!0}]])]),e.createElementVNode("div",I2,[e.createElementVNode("div",null,[g[22]||(g[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":g[5]||(g[5]=E=>d.startTime=E),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,d.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[g[23]||(g[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":g[6]||(g[6]=E=>d.duration=E),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,d.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",F2,[e.createElementVNode("div",null,[g[24]||(g[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":g[7]||(g[7]=E=>d.fadeIn=E),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,d.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[g[25]||(g[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":g[8]||(g[8]=E=>d.fadeOut=E),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,d.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",$2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[9]||(g[9]=E=>d.loop=E),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,d.loop]]),g[26]||(g[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",D2,[e.createElementVNode("button",{onClick:m,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:p,disabled:!c.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",c.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,R2)])])])):e.createCommentVNode("",!0)]))}}),Sl=Be(A2,[["__scopeId","data-v-593719ac"]]);function nt(n,a={},...t){const o=document.createElement(n);for(const[i,r]of Object.entries(a))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 wc(n){return typeof n=="boolean"?n?"On":"Off":typeof n=="number"?Number.isInteger(n)?String(n):n.toFixed(2):String(n??"")}let kc=!1;function L2(){if(kc)return;kc=!0;const n=`
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
+ `,a=document.createElement("style");a.textContent=n,document.head.appendChild(a)}class P2{constructor({filters:a=[],callbacks:t={}}){L2(),this._filters=a,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(a){return this._root=nt("div",{className:"mvfp"}),this._catRow=nt("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=nt("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=nt("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),a.appendChild(this._root),this._root}setFilters(a){this._filters=a,this._renderCategories(),this._renderFilters()}setActiveFilters(a){this._activeFilters.clear(),a&&a.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 a;this.closeDrawer(),(a=this._root)==null||a.remove(),this._root=null}_getCategories(){const a=new Map;a.set("all","All");for(const t of this._filters){const o=t.category||"other";a.has(o)||a.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return a}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=nt("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(a=>(a.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const a of this._currentFilters()){const t=this._activeFilters.has(a.id),o=this._selectedFilterId===a.id,i=nt("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(a)});if(t){const r=nt("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(a.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(nt("span",{},a.name)),this._filterRow.appendChild(i)}}_selectFilter(a){var t,o,i,r;this._selectedFilterId=a.id,this._activeFilters.has(a.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,a),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,a),this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(a.id)}_removeFilter(a){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,a),this._selectedFilterId===a&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(nt("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((a,t)=>{const o=this._filters.find(d=>d.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=nt("div",{className:`mvfp-achip${i?" selected":""}`}),s=nt("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),l=nt("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:d=>{d.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=nt("div",{className:"mvfp-drawer"});const a=nt("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=nt("span",{className:"mvfp-drawer-title"},"Filter");const t=nt("div",{className:"mvfp-drawer-actions"});t.appendChild(nt("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(nt("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=nt("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),a.appendChild(this._drawerTitle),a.appendChild(t),this._drawer.appendChild(a),this._drawerBody=nt("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(a){const t=this._filters.find(o=>o.id===a);if(t&&(this._drawerFilterId=a,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(a){if(this._drawerBody.innerHTML="",!a.params||a.params.length===0){this._drawerBody.appendChild(nt("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(a.id),o=(t==null?void 0:t.params)||{};for(const i of a.params){const r=o[i.id]??i.default,s=nt("div",{className:"mvfp-ctl"}),l=nt("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const d=i.type||"slider";if(d==="slider"||d==="range"){const c=nt("div",{className:"mvfp-slider-row"}),u=nt("span",{className:"mvfp-range-val"},wc(r)),f=nt("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:m=>{var h,v;const p=parseFloat(m.target.value);u.textContent=wc(p),(v=(h=this._cb).onUpdateParam)==null||v.call(h,a.id,i.id,p)}});c.appendChild(f),c.appendChild(u),s.appendChild(c)}else if(d==="toggle"||d==="checkbox"){const c=nt("div",{className:"mvfp-toggle-row"}),u=nt("input",{type:"checkbox",checked:r?"checked":void 0,onChange:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.checked)}});c.appendChild(u),s.appendChild(c)}else if(d==="color"){const c=nt("div",{className:"mvfp-color-row"}),u=nt("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.value)}});c.appendChild(u),s.appendChild(c)}else if(d==="select"||d==="dropdown"){const c=nt("div",{className:"mvfp-select-row"}),u=nt("select",{className:"mvfp-select",onChange:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.value)}});for(const f of i.options||[]){const m=nt("option",{value:f.value},f.label||String(f.value));f.value===r&&(m.selected=!0),u.appendChild(m)}c.appendChild(u),s.appendChild(c)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const a=this._filters.find(i=>i.id===this._drawerFilterId);if(a!=null&&a.params){for(const i of a.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(a)}}}const O2=[200,500,1e3];function U2(n){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[n??""]??[1920,1080]}function _c(n){if(!n)return null;const a=n.duration;if(typeof a=="number"&&Number.isFinite(a)&&a>0)return a;if(a&&typeof a=="object"&&"value"in a){const t=a.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null}function z2(n){return new Promise(a=>{window.setTimeout(a,n)})}async function Ec(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-CZ20kvpH.cjs"))}function xc(n,a=0){var r;const t=n.timeline[0],o=t?Math.max(0,t.sourceIn):0,i=(t==null?void 0:t.sourceOut)??((r=n.source)==null?void 0:r.duration)??a;return Math.max(0,i-o)}function wm(n){let a=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await Ec();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,s)=>{var p,h,v,k;const l=i.timeline[0],d=l?Math.max(0,l.sourceIn):0,c=l?l.sourceOut:void 0,[u,f]=U2((r==null?void 0:r.quality)??((p=i.output)==null?void 0:p.quality)),m=((h=i.output)==null?void 0:h.fps)||30;n.setPlaying(!1),n.forcePixiPreview.value=!0,await e.nextTick();try{let V=!1;for(const R of O2){await z2(R);const P=n.getPreviewRef();if(!(!P||typeof P.captureFrameAt!="function")){if(typeof P.ensureReadyForCapture=="function"){if(V=await P.ensureReadyForCapture(),V)break;continue}V=!0;break}}const B=n.getPreviewRef();if(!B||typeof B.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!V)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:_,isWebCodecsSupported:g}=await Ec();if(!g())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");a=new AbortController;const E={width:u,height:f,fps:m,trimStart:d,signal:a.signal};c!==void 0&&(E.trimEnd=c),s&&(E.onProgress=s);const C=n.getSourceUrl();C!==""&&(E.sourceUrl=C);const N=_c(B)??((v=i.source)==null?void 0:v.duration)??c??0,S=await _({captureFrameAt:R=>{var P;return((P=B.captureFrameAt)==null?void 0:P.call(B,R))??Promise.resolve(null)},duration:{value:N}},E),A=new File([S],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),Z=_c(B),x=((k=i.source)==null?void 0:k.duration)??0,b=Math.max(0,(c??Z??x)-d);return{file:A,recipe:i,meta:{duration:b,width:u,height:f,format:"mp4",sizeBytes:A.size,size_bytes:A.size}}}finally{n.forcePixiPreview.value=!1,a=null}},cancelClientExport:()=>{a==null||a.abort(),a=null},resetClientExport:()=>{a=null}}}const wo="default-video-track",hn="default-media-source";function km(n){var r,s;const a=W2(n),t=Z2(n),o=H2(n.timeline,((r=t[0])==null?void 0:r.id)??wo,((s=a[0])==null?void 0:s.id)??hn),i={version:n.version,source:{...n.source},mediaSources:a,tracks:X2(t,o),clips:o,markers:n.markers?n.markers.map(l=>({...l})):[],transitions:n.transitions?n.transitions.map(xm):[],filters:n.filters.map(l=>({...l,params:{...l.params}})),audio:{...n.audio},output:{...n.output}};return typeof n.duration=="number"&&(i.duration=n.duration),n.snapSettings&&(i.snapSettings={...n.snapSettings}),n.textOverlays&&(i.textOverlays=[...n.textOverlays]),n.captionTracks&&(i.captionTracks=n.captionTracks.map(Sm)),n.visualLayers&&(i.visualLayers=n.visualLayers.map(Cm)),n.audioTracks&&(i.audioTracks=[...n.audioTracks]),n.posterFrame&&(i.posterFrame=n.posterFrame),n.metadata&&(i.metadata={...n.metadata}),i}function j2(n){const a={version:"1.0",source:{...n.source},timeline:n.clips.map(t=>({...t})),mediaSources:n.mediaSources.map(_m),tracks:n.tracks.map(Em),markers:n.markers.map(t=>({...t})),transitions:n.transitions.map(xm),filters:n.filters.map(t=>({...t,params:{...t.params}})),audio:{...n.audio},output:{...n.output}};return typeof n.duration=="number"&&(a.duration=n.duration),n.snapSettings&&(a.snapSettings={...n.snapSettings}),n.textOverlays&&(a.textOverlays=[...n.textOverlays]),n.captionTracks&&(a.captionTracks=n.captionTracks.map(Sm)),n.visualLayers&&(a.visualLayers=n.visualLayers.map(Cm)),n.audioTracks&&(a.audioTracks=[...n.audioTracks]),n.posterFrame&&(a.posterFrame=n.posterFrame),n.metadata&&(a.metadata={...n.metadata}),a}function W2(n){var t,o;if(n.mediaSources&&n.mediaSources.length>0)return n.mediaSources.map(_m);const a={id:((t=n.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??hn,type:"media",mediaUuid:n.source.media_uuid,duration:n.source.duration,width:n.source.original_width,height:n.source.original_height};return(o=n.metadata)!=null&&o.source_url&&(a.url=n.metadata.source_url),[a]}function Z2(n){var a;return n.tracks&&n.tracks.length>0?n.tracks.map(Em):[{id:((a=n.timeline.find(t=>t.trackId))==null?void 0:a.trackId)??wo,type:"video",name:"Video",order:0}]}function H2(n,a,t){return n.map(o=>{const i={...o,trackId:o.trackId??a,sourceRefId:o.sourceRefId??t};return o.filters&&(i.filters=o.filters.map(r=>({...r,params:{...r.params}}))),o.transform&&(i.transform={...o.transform}),o.keyframes&&(i.keyframes=o.keyframes.map(r=>({...r}))),i})}function X2(n,a){return n.map(t=>{const o=a.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:o}})}function _m(n){const a={...n};return n.metadata&&(a.metadata={...n.metadata}),a}function Em(n){const a={...n};return n.clipIds&&(a.clipIds=[...n.clipIds]),a}function xm(n){const a={...n};return n.params&&(a.params={...n.params}),a}function Sm(n){return{...n,segments:n.segments.map(t=>{const o={...t};return t.words&&(o.words=t.words.map(i=>({...i}))),o})}}function Cm(n){return{...n,transform:{...n.transform,position:{...n.transform.position},anchor:{...n.transform.anchor},scale:{...n.transform.scale}},keyframes:n.keyframes?n.keyframes.map(a=>({...a})):void 0}}const Vm="video-project-draft-snapshot:v1",Cl="mediables:video-project-drafts",G2=(n,a={})=>{var m,p;const t=en(a.now)??Date.now(),o=en(a.createdAt)??t,i=en(a.updatedAt)??t,r=r_(n),s={id:Ea(a.id)??c_(i),payloadKind:r,createdAt:new Date(o).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:a.deviceKind??"unknown"},l=Ea(a.projectId),d=Ea(a.sourceMediaUuid)??Ea(n.source.media_uuid),c=Vl(a.durationSeconds)??s_(n),u=Ea(a.editorVersion)??Ea((m=n.metadata)==null?void 0:m.editor_version),f=Ea(a.title)??Ea((p=n.metadata)==null?void 0:p.title);return l!==null&&(s.projectId=l),d!==null&&(s.sourceMediaUuid=d),c!==null&&(s.durationSeconds=c),u!==null&&(s.editorVersion=u),f!==null&&(s.title=f),a.saveReason!==void 0&&(s.saveReason=a.saveReason),{schemaVersion:Vm,metadata:s,payload:n}},Nm=(n,a=Cl)=>{const t=Ea(a)??Cl,o=Tc(n.metadata.projectId??"unsaved-project"),i=Tc(n.metadata.id);return`${t}:${o}:${i}`},J2=n=>JSON.stringify(n),K2=n=>{if(typeof n!="string"||n.trim().length===0)return null;try{const a=JSON.parse(n);return n_(a)?a:null}catch{return null}},q2=n=>{const a=[];for(const t of n){const o=Ea(t.key),i=K2(t.value);o===null||i===null||a.push({key:o,snapshot:i})}return li(a)},Y2=(n,a)=>{const t=d_(a.maxCount),o=en(a.now)??Date.now(),i=Fm(a.maxAgeMs),r=[],s=[];let l=0;for(const d of li(n)){if(!Bm(d,a.projectId)){r.push(d);continue}if(Im(d.snapshot,o,i)||l>=t){s.push(d);continue}r.push(d),l+=1}return{retained:li(r),removed:li(s)}},Q2=(n,a={})=>{const t={key:Nm(n),snapshot:n};if(!Bm(t,a.projectId))return!1;const o=en(a.now)??Date.now(),i=Fm(a.maxAgeMs);if(Im(n,o,i))return!1;const r=a.savedAt===null?null:en(a.savedAt);return r===null?!0:Nr(n)>r},e_=(n,a={})=>li(n).filter(t=>Q2(t.snapshot,a)),t_=(n,a,t={})=>{const o=e_(n,t);if(a==="mobile"){const i=o[0]??null;return i===null?[]:[i]}return o},a_=async(n,a,t=Nm(a))=>(await n.setItem(t,J2(a)),{key:t,snapshot:a}),Sc=async(n,a=Cl)=>{const t=await n.listKeys(a),o=[];for(const i of t)o.push({key:i,value:await n.getItem(i)});return q2(o)},Cc=async(n,a)=>{for(const t of a)await n.removeItem(t.key)},n_=n=>!tn(n)||n.schemaVersion!==Vm||!o_(n.metadata)?!1:n.metadata.payloadKind==="project"?Tm(n.payload):i_(n.payload),o_=n=>tn(n)?cd(n.id)&&m_(n.payloadKind)&&Nc(n.createdAt)&&Nc(n.updatedAt)&&p_(n.deviceKind)&&Ki(n.projectId)&&Ki(n.sourceMediaUuid)&&u_(n.durationSeconds)&&Ki(n.editorVersion)&&Ki(n.title)&&f_(n.saveReason):!1,i_=n=>tn(n)?n.version==="1.0"&&Mm(n.source)&&Array.isArray(n.timeline)&&Array.isArray(n.filters)&&tn(n.audio)&&tn(n.output):!1,Tm=n=>tn(n)?n.version==="1.0"&&Mm(n.source)&&Array.isArray(n.mediaSources)&&Array.isArray(n.tracks)&&Array.isArray(n.clips)&&Array.isArray(n.markers)&&Array.isArray(n.filters)&&tn(n.audio)&&tn(n.output):!1,Mm=n=>tn(n)?cd(n.media_uuid)&&di(n.duration)&&di(n.original_width)&&di(n.original_height):!1,r_=n=>Tm(n)?"project":"recipe",s_=n=>Vl(n.duration)??Vl(n.source.duration),Bm=(n,a)=>{const t=Ea(a);return t===null?!0:n.snapshot.metadata.projectId===t},Im=(n,a,t)=>t===null?!1:a-Nr(n)>t,li=n=>[...n].sort(l_),l_=(n,a)=>{const t=Nr(a.snapshot)-Nr(n.snapshot);if(t!==0)return t;const o=Vc(a.snapshot)-Vc(n.snapshot);return o!==0?o:n.snapshot.metadata.id.localeCompare(a.snapshot.metadata.id)},Nr=n=>en(n.metadata.updatedAt)??0,Vc=n=>en(n.metadata.createdAt)??0,d_=n=>!Number.isFinite(n)||n<0?0:Math.floor(n),Fm=n=>n===void 0||!Number.isFinite(n)||n<0?null:Math.floor(n),en=n=>{if(n==null)return null;if(n instanceof Date)return Number.isFinite(n.getTime())?n.getTime():null;if(typeof n=="number")return Number.isFinite(n)?n:null;const a=n.trim();if(a.length===0)return null;const t=Date.parse(a);return Number.isFinite(t)?t:null},Nc=n=>typeof n=="string"&&en(n)!==null,c_=n=>{var t;const a=typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,12);return`draft-${n}-${a}`},Tc=n=>encodeURIComponent(n.trim()),Ea=n=>{if(typeof n!="string")return null;const a=n.trim();return a.length>0?a:null},cd=n=>Ea(n)!==null,Ki=n=>n===void 0||cd(n),Vl=n=>{if(!di(n))return null;const a=Number(n.toFixed(6));return Object.is(a,-0)?0:a},di=n=>typeof n=="number"&&Number.isFinite(n)&&n>=0,u_=n=>n===void 0||di(n),m_=n=>n==="recipe"||n==="project",p_=n=>n==="desktop"||n==="mobile"||n==="tablet"||n==="unknown",f_=n=>n===void 0||n==="autosave"||n==="manual"||n==="before-export"||n==="before-close",tn=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),h_=1,v_="master",vi=-60,Nl=12,ud=0,vn=-90,Tr=6,g_=4,$m=8;function Dm(){return{mobile:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!1,canViewMeters:!0,canEditEffectSlots:!1,canEditRouting:!1,canEditAutomation:!1,meterMode:"basic",maxEffectSlots:0},desktop:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!0,canViewMeters:!0,canEditEffectSlots:!0,canEditRouting:!0,canEditAutomation:!0,meterMode:"full",maxEffectSlots:$m}}}function y_(n,a=Dm()){return Ml(a[n])}function Rm(n){return Number.isNaN(n)?ud:n<=0||n===Number.NEGATIVE_INFINITY?vi:gi(20*Math.log10(n))}function Tl(n){const a=gi(n);return a<=vi?0:yn(Math.pow(10,a/20),6)}function gi(n){return Number.isNaN(n)?ud:n===Number.NEGATIVE_INFINITY?vi:n===Number.POSITIVE_INFINITY?Nl:yn(Ni(n,vi,Nl),3)}function Am(n){return Number.isFinite(n)?yn(Ni(n,-1,1),3):0}function b_(n,a=!1){const t=n.some(o=>o.controls.solo);return n.map(o=>{const i=o.controls.muted,r=t&&!o.controls.solo,s=a||i||r,l=s?0:o.controls.fader.linearGain;return{trackId:o.id,soloed:o.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:a,effectivelyMuted:s,audible:!s,effectiveGainLinear:l}})}function w_(n,a={}){const t=B_(a.effectSlotCount),o=new Set;return{schemaVersion:h_,capabilities:a.capabilities?D_(a.capabilities):Dm(),tracks:n.map((i,r)=>__(i,r,t,o)),master:E_(a.master,t)}}function Lm(n){const a=gi(n);return{valueDb:a,minDb:vi,maxDb:Nl,unityDb:ud,linearGain:Tl(a)}}function k_(n,a="constant-power"){return{value:Am(n),mode:a}}function Pm(n=vn,a=vn,t=n){const o=Ps(n),i=Ps(a),r=Ps(t);return{peakDb:o,rmsDb:i,peakHoldDb:r,clipping:o>=0||r>=0}}function Om(n){const a=jm(n);return{id:`empty-effect-slot-${a}`,index:a,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function __(n,a,t,o){const i=zm(n.id),s={id:M_(i??`legacy-audio-track-${a+1}`,o),kind:"legacy-url",name:V_(n.name,a),order:a,source:x_(n.source),controls:{fader:Lm(n.faderDb??Rm(n.volume??1)),pan:k_(n.pan??0),muted:n.muted??!1,solo:n.solo??!1,meter:Pm(n.peakDb,n.rmsDb,n.peakHoldDb)},timeline:S_(n),effectSlots:Um(n.effectSlots,t)};return i!==void 0&&(s.legacyTrackId=i),s}function E_(n,a){return{id:v_,name:N_(n==null?void 0:n.name),fader:Lm((n==null?void 0:n.faderDb)??Rm((n==null?void 0:n.volume)??1)),muted:(n==null?void 0:n.muted)??!1,meter:Pm(n==null?void 0:n.peakDb,n==null?void 0:n.rmsDb,n==null?void 0:n.peakHoldDb),effectSlots:Um(n==null?void 0:n.effectSlots,a)}}function x_(n){const a=n.trim();return a===""?{type:"missing"}:{type:"url",url:a}}function S_(n){const a={startTime:F_(n.startTime??0),loop:n.loop??!1},t=I_(n.duration);t!==void 0&&(a.duration=t);const o=Mc(n.fadeIn);o!==void 0&&(a.fadeIn=o);const i=Mc(n.fadeOut);return i!==void 0&&(a.fadeOut=i),a}function Um(n,a){const t=new Map;for(const o of n??[]){const i=C_(o,a);t.set(i.index,i)}return Array.from({length:a},(o,i)=>t.get(i)??Om(i))}function C_(n,a){const t=jm(n.index),o=a>0?Math.min(t,a-1):0,i=n.kind;return i==="empty"?Om(o):{id:zm(n.id)??`${i}-effect-slot-${o}`,index:o,kind:i,label:T_(n.label,i),enabled:n.enabled,bypassed:n.bypassed,wetMix:$_(n.wetMix),parameters:{...n.parameters}}}function V_(n,a){const t=n==null?void 0:n.trim();return t&&t!==""?t:`Audio ${a+1}`}function N_(n){const a=n==null?void 0:n.trim();return a&&a!==""?a:"Master"}function T_(n,a){const t=n.trim();return t!==""?t:a}function M_(n,a){if(!a.has(n))return a.add(n),n;let t=2,o=`${n}-${t}`;for(;a.has(o);)t+=1,o=`${n}-${t}`;return a.add(o),o}function zm(n){const a=n==null?void 0:n.trim();if(!(!a||a===""))return a}function B_(n){return n===void 0||!Number.isFinite(n)?g_:Math.trunc(Ni(n,0,$m))}function jm(n){return!Number.isFinite(n)||n<0?0:Math.trunc(n)}function I_(n){if(!(n===void 0||!Number.isFinite(n)||n<=0))return yn(n,3)}function Mc(n){if(!(n===void 0||!Number.isFinite(n)||n<0))return yn(n,3)}function F_(n){return!Number.isFinite(n)||n<0?0:yn(n,3)}function $_(n){return Number.isFinite(n)?yn(Ni(n,0,1),3):1}function Ps(n){return Number.isNaN(n)||n===Number.NEGATIVE_INFINITY?vn:n===Number.POSITIVE_INFINITY?Tr:yn(Ni(n,vn,Tr),3)}function D_(n){return{mobile:Ml(n.mobile),desktop:Ml(n.desktop)}}function Ml(n){return{...n}}function Ni(n,a,t){return Math.min(t,Math.max(a,n))}function yn(n,a){const t=10**a;return Math.round(n*t)/t}const R_=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,A_=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,L_="srt-cue";class gn extends Error{constructor(a,t,o={}){super(t),this.name="CaptionSrtError",this.code=a,this.context=o}}function P_(n,a={}){var s,l;const t=O_(a.idPrefix),o=n.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
337
+ `).split(`
338
+ `),i=[];let r=0;for(;r<o.length;){for(;r<o.length&&Dc(o[r]);)r+=1;if(r>=o.length)break;const d=r+1,c=U_(((s=o[r])==null?void 0:s.trim())??"",d);if(r+=1,r>=o.length)throw new gn("missing-timing",`Cue ${c} is missing its timing line.`,{cueIndex:i.length,cueNumber:c,lineNumber:d});const u=r+1,f=z_(((l=o[r])==null?void 0:l.trim())??"",c,u);r+=1;const m=[];for(;r<o.length&&!Dc(o[r]);)m.push(o[r]??""),r+=1;i.push({cueNumber:c,id:`${t}-${i.length+1}`,startTime:f.startTime,endTime:f.endTime,text:m.join(`
339
+ `)})}return Wm(i),i}function Bc(n){return Wm(n),n.length===0?"":`${n.map((a,t)=>W_(a,t+1)).join(`
340
+
341
+ `)}
342
+ `}function Wm(n){const a=n.map((t,o)=>{const i=$c(t,o),r=Bl(t.startTime,"startTime",i),s=Bl(t.endTime,"endTime",i);if(s<=r)throw new gn("invalid-duration",`Caption cue "${t.id}" must end after it starts.`,i);return{cue:t,cueIndex:o,startMilliseconds:r,endMilliseconds:s}}).sort((t,o)=>t.startMilliseconds-o.startMilliseconds||t.cueIndex-o.cueIndex);for(let t=1;t<a.length;t+=1){const o=a[t-1],i=a[t];if(!(o===void 0||i===void 0)&&i.startMilliseconds<o.endMilliseconds)throw new gn("overlapping-cues",`Caption cue "${i.cue.id}" overlaps cue "${o.cue.id}".`,$c(i.cue,i.cueIndex))}}function Ic(n){const a=Bl(n,"timestamp",{}),t=Math.floor(a/36e5),o=Math.floor(a%36e5/6e4),i=Math.floor(a%6e4/1e3),r=a%1e3;return[t.toString().padStart(2,"0"),o.toString().padStart(2,"0"),i.toString().padStart(2,"0")].join(":")+`,${r.toString().padStart(3,"0")}`}function O_(n){return n===void 0||n.trim()===""?L_:n.trim()}function U_(n,a){if(!/^[1-9]\d*$/.test(n))throw new gn("invalid-cue-number",`Invalid SRT cue number at line ${a}.`,{lineNumber:a});return Number.parseInt(n,10)}function z_(n,a,t){const o=R_.exec(n),i=o==null?void 0:o[1],r=o==null?void 0:o[2];if(i===void 0||r===void 0)throw new gn("invalid-timing",`Invalid SRT timing line for cue ${a} at line ${t}.`,{cueNumber:a,lineNumber:t});return{startTime:Fc(i,a,t),endTime:Fc(r,a,t)}}function Fc(n,a,t){const o=A_.exec(n),i=o==null?void 0:o[1],r=o==null?void 0:o[2],s=o==null?void 0:o[3],l=o==null?void 0:o[4];if(i===void 0||r===void 0||s===void 0||l===void 0)throw new gn("invalid-time",`Invalid SRT timestamp for cue ${a} at line ${t}.`,{cueNumber:a,lineNumber:t});const d=Number.parseInt(i,10),c=Number.parseInt(r,10),u=Number.parseInt(s,10),f=Number.parseInt(l,10);return d*60*60+c*60+u+f/1e3}function Bl(n,a,t){if(!Number.isFinite(n)||n<0)throw new gn("invalid-time",`Caption cue ${a} must be a finite, non-negative number.`,t);return Math.round(n*1e3)}function $c(n,a){const t={cueIndex:a,segmentId:n.id},o=j_(n);return o!==void 0&&(t.cueNumber=o),t}function j_(n){if(!(!("cueNumber"in n)||typeof n.cueNumber!="number"))return n.cueNumber}function W_(n,a){return[a.toString(),`${Ic(n.startTime)} --> ${Ic(n.endTime)}`,Z_(n.text)].join(`
343
+ `)}function Z_(n){return n.replace(/\r\n?/g,`
344
+ `)}function Dc(n){return n===void 0||n.trim()===""}const H_=["linear","ease-in","ease-out","ease-in-out"];class Mr extends Error{constructor(a,t="Invalid keyframe automation."){super(t),this.name="KeyframeAutomationError",this.issues=a}}const X_={opacity:{min:0,max:1},scale:{min:0,max:10},x:{min:0,max:1},y:{min:0,max:1},rotation:{},audioVolume:{min:0,max:1}};function G_(n){return typeof n=="string"&&H_.includes(n)}function J_(n){return n==="mobile"?{platform:n,editingMode:"preset-only",canApplyPresets:!0,canEditKeyframes:!1}:{platform:n,editingMode:"detailed",canApplyPresets:!0,canEditKeyframes:!0}}function K_(n){return[...n].sort((a,t)=>a.target!==t.target?a.target.localeCompare(t.target):a.time!==t.time?a.time-t.time:a.id.localeCompare(t.id))}function Zm(n,a={}){const t=[],o=new Set,i={...X_,...a.ranges};return n.forEach((r,s)=>{if(r.id.trim()===""&&t.push({code:"empty-id",message:"Keyframe id cannot be empty.",index:s,target:r.target,time:r.time}),a.target!==void 0&&r.target!==a.target&&t.push({code:"target-mismatch",message:`Expected ${a.target} keyframe target but received ${r.target}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),!Number.isFinite(r.time)||r.time<(a.minTime??0))t.push({code:"invalid-time",message:"Keyframe time must be a finite non-negative number.",index:s,keyframeId:r.id,target:r.target,time:r.time});else if(a.maxTime!==void 0&&r.time>a.maxTime)t.push({code:"invalid-time",message:`Keyframe time must be less than or equal to ${a.maxTime}.`,index:s,keyframeId:r.id,target:r.target,time:r.time});else{const l=`${r.target}:${r.time}`;o.has(l)&&t.push({code:"duplicate-time",message:`Keyframe target ${r.target} already has a point at ${r.time}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),o.add(l)}if(!Number.isFinite(r.value))t.push({code:"invalid-value",message:"Keyframe value must be a finite number.",index:s,keyframeId:r.id,target:r.target,time:r.time});else{const l=i[r.target];l.min!==void 0&&r.value<l.min&&t.push({code:"invalid-value",message:`Keyframe value for ${r.target} must be greater than or equal to ${l.min}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),l.max!==void 0&&r.value>l.max&&t.push({code:"invalid-value",message:`Keyframe value for ${r.target} must be less than or equal to ${l.max}.`,index:s,keyframeId:r.id,target:r.target,time:r.time})}G_(r.easing)||t.push({code:"invalid-easing",message:`Unsupported keyframe easing "${String(r.easing)}".`,index:s,keyframeId:r.id,target:r.target,time:r.time})}),{valid:t.length===0,issues:t}}function q_(n,a={}){const t=K_(n),o=Zm(t,a);if(!o.valid)throw new Mr(o.issues);return t}function Y_(n={}){return md({id:"fade-in",label:"Fade in",target:"opacity",startValue:n.fromOpacity??0,endValue:n.toOpacity??1,timing:pd(n,"ease-out")})}function Q_(n={}){return md({id:"fade-out",label:"Fade out",target:"opacity",startValue:n.fromOpacity??1,endValue:n.toOpacity??0,timing:pd(n,"ease-in")})}function eE(n={}){return md({id:"zoom-in",label:"Zoom in",target:"scale",startValue:n.fromScale??1,endValue:n.toScale??1.1,timing:pd(n,"ease-out")})}function md(n){const a=[{id:`${n.id}:start`,target:n.target,time:n.timing.startTime,value:n.startValue,easing:"linear"},{id:`${n.id}:end`,target:n.target,time:n.timing.endTime,value:n.endValue,easing:n.timing.easing}],t=Zm(a,{target:n.target});if(!t.valid)throw new Mr(t.issues);return{id:n.id,label:n.label,target:n.target,editingMode:"preset-only",keyframes:a}}function pd(n,a){const t=n.startTime??0,o=n.duration??1;if(!Number.isFinite(t)||t<0)throw new Mr([{code:"invalid-time",message:"Preset start time must be a finite non-negative number.",time:t}]);if(!Number.isFinite(o)||o<=0)throw new Mr([{code:"invalid-time",message:"Preset duration must be a finite number greater than zero."}]);return{startTime:t,endTime:t+o,easing:n.easing??a}}class jn extends Error{constructor(a,t){super(t),this.name="VisualLayerSchemaError",this.code=a}}function tE(n){hd(n.id,"caption track id");const a={id:n.id,source:n.source,stylePreset:n.stylePreset??"default",animation:n.animation??"none",segments:aE(n.segments)};return n.language!==void 0&&(a.language=n.language),a}function aE(n){const a=n.map(t=>{hd(t.id,"caption segment id");const o=fd(t.startTime,"caption segment startTime"),i=Hm(t.endTime,"caption segment endTime");if(i<=o)throw new jn("invalid-caption-segment",`Caption segment "${t.id}" must end after it starts.`);const r={id:t.id,startTime:o,endTime:i,text:t.text};return t.words!==void 0&&(r.words=nE(t.id,t.words)),r}).sort((t,o)=>t.startTime-o.startTime);for(let t=1;t<a.length;t+=1){const o=a[t-1],i=a[t];if(!(o===void 0||i===void 0)&&i.startTime<o.endTime)throw new jn("invalid-caption-segment",`Caption segment "${i.id}" overlaps segment "${o.id}".`)}return a}function nE(n,a){return a.map(t=>{hd(t.id,"caption word id");const o=fd(t.startTime,"caption word startTime"),i=Hm(t.endTime,"caption word endTime");if(i<=o)throw new jn("invalid-caption-segment",`Caption word "${t.id}" in segment "${n}" must end after it starts.`);return{id:t.id,startTime:o,endTime:i,text:t.text}}).sort((t,o)=>t.startTime-o.startTime)}function fd(n,a){const t=oE(n,a);if(t<0)throw new jn("invalid-time",`${a} must be non-negative.`);return Math.round(t*1e3)/1e3}function Hm(n,a){const t=fd(n,a);if(t<=0)throw new jn("invalid-duration",`${a} must be greater than zero.`);return t}function oE(n,a){if(!iE(n))throw new jn("invalid-time",`${a} must be a finite number.`);return n}function hd(n,a){if(n.trim()==="")throw new jn("empty-id",`${a} cannot be empty.`)}function iE(n){return Number.isFinite(n)}function Rc(n){var f,m,p,h;rE(n);const a=dE(n),t=cE(n),o=((f=a[0])==null?void 0:f.id)??hn,i=((m=t[0])==null?void 0:m.id)??wo,r=sE(n.clips,i,o),s=uE(t,r),l=[],d=hE(n),c=vE(n),u={version:"1.0",source:{media_uuid:n.mediaUuid,duration:n.originalDuration,original_width:((p=n.media)==null?void 0:p.width)||1920,original_height:((h=n.media)==null?void 0:h.height)||1080},timeline:r,mediaSources:a,tracks:s,filters:l,audio:d,output:c,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return n.textOverlays&&(u.textOverlays=n.textOverlays),n.captionTracks&&(u.captionTracks=n.captionTracks.map(v=>({...v,segments:v.segments.map(k=>{const V={...k};return k.words&&(V.words=k.words.map(B=>({...B}))),V})}))),n.visualLayers&&(u.visualLayers=n.visualLayers.map(v=>({...v}))),n.audioTracks&&(u.audioTracks=n.audioTracks.filter(v=>typeof v.source=="string")),n.transitions&&(u.transitions=n.transitions.map(fE)),u}function rE(n){if(!n.mediaUuid)throw new Error("Media UUID is required");if(!n.clips||n.clips.length===0)throw new Error("At least one clip is required");const a=new Map;for(const t of n.clips){const o=lE(t),i=a.get(o)??[];i.push(t),a.set(o,i)}for(const t of a.values()){t.sort((o,i)=>o.timelineStart-i.timelineStart);for(let o=1;o<t.length;o++){const i=t[o],r=t[o-1];if(i.timelineStart<r.timelineEnd)throw new Error(`Clips ${r.id} and ${i.id} overlap on timeline`)}}}function sE(n,a,t){return n.map(o=>{const i=o.speed||1,r=typeof o.sourceIn=="number"&&!Number.isNaN(o.sourceIn),s=typeof o.sourceOut=="number"&&!Number.isNaN(o.sourceOut),l=Math.max(0,o.timelineEnd-o.timelineStart),d=o,c=d.sourceOffset??d.trimStart??0;let u=Number(r?o.sourceIn:c),f=s?Number(o.sourceOut):Number(c)+l/i;f>u||(f=u+Math.max(.033,l/Math.max(1e-6,i)));const m={id:o.id,type:o.type??"clip",trackId:o.trackId??a,sourceRefId:o.sourceRefId??t,timelineStart:o.timelineStart,timelineEnd:o.timelineEnd,sourceIn:u,sourceOut:f,speed:i,filters:o.filters?[...o.filters]:[]};return o.keyframes&&(m.keyframes=o.keyframes.map(p=>({...p}))),m})}function lE(n){return n.trackId??`legacy-track-${n.track??0}`}function dE(n){var t,o,i,r,s,l,d,c;if(n.mediaSources&&n.mediaSources.length>0)return n.mediaSources.map(mE);const a={id:((t=n.clips.find(u=>u.sourceRefId))==null?void 0:t.sourceRefId)??hn,type:"media",mediaUuid:n.mediaUuid,duration:n.originalDuration,width:((o=n.media)==null?void 0:o.width)??1920,height:((i=n.media)==null?void 0:i.height)??1080};return(r=n.media)!=null&&r.filename&&(a.filename=n.media.filename),(s=n.media)!=null&&s.mime_type&&(a.mimeType=n.media.mime_type),typeof((l=n.media)==null?void 0:l.frame_rate)=="number"&&(a.frameRate=n.media.frame_rate),typeof((d=n.media)==null?void 0:d.has_audio)=="boolean"&&(a.hasAudio=n.media.has_audio),(c=n.media)!=null&&c.thumbnail_url&&(a.thumbnailUrl=n.media.thumbnail_url),[a]}function cE(n){var a;return n.tracks&&n.tracks.length>0?n.tracks.map(pE):[{id:((a=n.clips.find(t=>t.trackId))==null?void 0:a.trackId)??wo,type:"video",name:"Video",order:0}]}function uE(n,a){return n.map(t=>({...t,clipIds:a.filter(o=>o.trackId===t.id).map(o=>o.id)}))}function mE(n){const a={...n};return n.metadata&&(a.metadata={...n.metadata}),a}function pE(n){const a={...n};return n.clipIds&&(a.clipIds=[...n.clipIds]),a}function fE(n){const a={...n};return n.params&&(a.params={...n.params}),a}function hE(n){const a={volume:n.audioVolume,muted:n.audioVolume===0};return n.audioFadeIn>0&&(a.fadeIn=n.audioFadeIn),n.audioFadeOut>0&&(a.fadeOut=n.audioFadeOut),a}function vE(n){var r;const a={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=a[n.exportQuality]||a["1080p"],o=(r=n.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:n.exportFormat||"mp4",codec:"h264",quality:n.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function Pa(n){return arguments.length===0?{ok:!0,value:void 0}:{ok:!0,value:n}}function It(n,a){return{ok:!1,reason:n,message:a}}const gE={last_clip:"Can't delete the last clip — leave the timeline empty or use Reset.",no_selection:"Select a clip first.",track_locked:"Target track is locked. Unlock it or pick another track.",track_missing:"That track no longer exists.",track_type_mismatch:"Clip can't be placed on that track type.",overlap:"No room on this track. Move neighboring clips or use a different track.",asset_not_ready:"Asset is still uploading or processing.",invariant_violation:"Editor state would be invalid — change rejected.",source_not_found:"Asset source not found.",source_in_use:"This asset is in use on the timeline. Remove its clips before deleting."};function Yt(n){return gE[n]}const ci=1e-6;function Os(n){if(!Number.isFinite(n.desiredDuration)||n.desiredDuration<=0)return{ok:!1};const a=Math.max(0,n.preferredStart),t=[...n.trackClips].filter(i=>i.id!==n.ignoreClipId).sort((i,r)=>i.timelineStart-r.timelineStart);if(t.length===0)return{ok:!0,start:a};if(yE(a,n.desiredDuration,t))return{ok:!0,start:a};let o=a;for(const i of t)if(!(i.timelineEnd<=o+ci)){if(i.timelineStart-o>=n.desiredDuration-ci&&o+ci>=a)return{ok:!0,start:o};o=Math.max(o,i.timelineEnd)}return{ok:!0,start:o}}function yE(n,a,t){const o=n+a;for(const i of t)if(!(i.timelineEnd<=n+ci)&&!(i.timelineStart>=o-ci))return!1;return!0}const bE={video:new Set(["clip","video","image"]),image:new Set(["image"]),audio:new Set(["audio"]),text:new Set(["text"]),graphics:new Set(["graphics"]),caption:new Set([])};function Ac(n,a){return bE[a].has(n)}function wE(n){const a=new Set;for(const t of n.clips)typeof t.sourceRefId=="string"&&t.sourceRefId!==""&&a.add(t.sourceRefId);return a}function kE(n,a){return wE(n).has(a)}function qi(n,a=30){const t=typeof n=="number"?n:Number(n);return Number.isFinite(t)&&t>0?t:a}function Xm(n,a,t){var lt,Ht,Na;const o=typeof n=="string"&&n.trim()!==""?n.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([]),d=e.ref(void 0);let c=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),f=qi(((lt=a==null?void 0:a.output)==null?void 0:lt.fps)??(t==null?void 0:t.frame_rate)),m=e.shallowRef(null),p=new fm(f),h=e.ref(f),v=e.ref(!1),k=e.ref(!1);a&&a.timeline&&a.timeline.length>0?(F(a),(Ht=a.output)!=null&&Ht.fps&&(h.value=qi(a.output.fps,h.value),p.setFps(h.value))):(E(),a&&((Na=a.output)!=null&&Na.fps&&(h.value=qi(a.output.fps,h.value),p.setFps(h.value)),a.audio&&(i.audioVolume=a.audio.volume||1,i.audioFadeIn=a.audio.fadeIn||0,i.audioFadeOut=a.audio.fadeOut||0),a.output&&(i.exportFormat=a.output.format||"mp4",i.exportQuality=a.output.quality||"1080p")));const V=e.ref(1),B=e.computed(()=>i.selectedClipId?i.clips.find(H=>H.id===i.selectedClipId)??null:null);e.watch(B,H=>{V.value=(H==null?void 0:H.speed)??1},{immediate:!0});const _=e.computed(()=>s.value.length>0),g=e.computed(()=>l.value.length>0);function E(){const H=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=H,i.totalDuration=H;const G=wa();i.mediaSources=[C(H)],i.tracks=[N([G])];const re={id:G,type:"clip",trackId:wo,sourceRefId:hn,timelineStart:0,timelineEnd:H,sourceIn:0,sourceOut:H,sourceMinIn:0,sourceMaxOut:H,speed:1};i.clips=[re],i.selectedClipId=G,d.value=G,!(t||o.startsWith("temp-"))&&(async()=>{try{const de=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!de.ok)throw new Error(`Failed to fetch media: ${de.status}`);const ke=await de.json(),Pe=typeof ke=="object"&&ke!==null&&"data"in ke?ke.data:ke;if(!Pe||typeof Pe!="object")throw new Error("Failed to parse media payload");const Ge=Pe;i.media=Ge,a||(h.value=qi(Ge.frame_rate,h.value),p.setFps(h.value));const De=typeof Ge.duration=="number"&&Ge.duration>0?Ge.duration:H;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==G)return;i.originalDuration=De,i.totalDuration=De,i.mediaSources=[C(De,Ge)],i.tracks=[N([G])];const Ze=i.clips[0];Ze.timelineStart=0,Ze.timelineEnd=De,Ze.sourceIn=0,Ze.sourceOut=De,Ze.sourceMinIn=0,Ze.sourceMaxOut=De,Ce(),c=!0}catch{}})()}function C(H,G=t){const re={id:hn,type:"media",mediaUuid:o,duration:H,width:(G==null?void 0:G.width)??1920,height:(G==null?void 0:G.height)??1080};return G!=null&&G.filename&&(re.filename=G.filename),G!=null&&G.mime_type&&(re.mimeType=G.mime_type),typeof(G==null?void 0:G.frame_rate)=="number"&&(re.frameRate=G.frame_rate),typeof(G==null?void 0:G.has_audio)=="boolean"&&(re.hasAudio=G.has_audio),G!=null&&G.thumbnail_url&&(re.thumbnailUrl=G.thumbnail_url),re}function N(H){return{id:wo,type:"video",name:"Video",order:0,clipIds:H}}function S(H){return`track-${H}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function A(H,G){const re=H.charAt(0).toUpperCase()+H.slice(1),de=G.filter(ke=>ke.type===H).length;return de===0?re:`${re} ${de+1}`}function Z(H,G){if(H.originalDuration!==1)return;H.originalDuration=G,H.totalDuration===1&&(H.totalDuration=G);const re=H.clips[0],de=!a&&H.clips.length===1&&re!==void 0&&re.timelineStart===0&&re.timelineEnd===1&&re.sourceIn===0&&re.sourceOut===1;for(const ke of H.clips)(ke.sourceMaxOut===1||ke.sourceMaxOut===void 0)&&(ke.sourceMaxOut=G);if(H.mediaSources)for(const ke of H.mediaSources)ke.id===hn&&(ke.duration===1||ke.duration===void 0)&&(ke.duration=G);de&&re!==void 0&&(re.sourceOut=G,re.timelineEnd=G)}function x(H){if(!Number.isFinite(H)||H<=0||c)return;const G=i.hasChanges;i.originalDuration=H,i.totalDuration=Math.max(i.totalDuration,H),i.media&&(i.media.duration=H);for(const ke of i.clips)ke.sourceMaxOut=H;if(i.mediaSources)for(const ke of i.mediaSources)(ke.id===hn||ke.mediaUuid===o)&&(ke.duration=H);const re=i.clips[0];!a&&i.clips.length===1&&re!==void 0&&re.timelineStart===0&&re.timelineEnd===1&&re.sourceIn===0&&re.sourceOut===1&&re!==void 0&&(re.sourceOut=H,re.timelineEnd=re.timelineStart+(re.sourceOut-re.sourceIn)),Ce();for(const ke of s.value)Z(ke,H);for(const ke of l.value)Z(ke,H);c=!0,e.nextTick(()=>{G||(i.hasChanges=!1)})}function F(H){const G=km(H);i.mediaSources=G.mediaSources,i.tracks=G.tracks,i.transitions=G.transitions,i.clips=G.clips.map(re=>({...re,sourceMinIn:re.sourceMinIn??0,sourceMaxOut:re.sourceMaxOut??H.source.duration})),i.filters=[],i.audioVolume=H.audio.volume,i.audioFadeIn=H.audio.fadeIn||0,i.audioFadeOut=H.audio.fadeOut||0,i.exportFormat=H.output.format,i.exportQuality=H.output.quality,i.originalDuration=H.source.duration,i.textOverlays=H.textOverlays?[...H.textOverlays]:[],i.audioTracks=H.audioTracks?[...H.audioTracks]:[],i.captionTracks=H.captionTracks?H.captionTracks.map(nn):[],i.visualLayers=H.visualLayers?H.visualLayers.map(re=>({...re})):[],i.clips.length>0?(i.selectedClipId=i.clips[0].id,d.value=i.selectedClipId):(delete i.selectedClipId,d.value=void 0),Ce()}function b(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function R(){if(!_.value)return;const H=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function P(){if(!g.value)return;const H=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function O(H,G,re){b();const de=i.clips.find(De=>De.id===H);if(!de)return;const ke=1/h.value,Pe=de.sourceMinIn??0,Ge=de.sourceMaxOut??i.originalDuration;if(G==="start"){const De=de.sourceIn,Ze=Math.max(Pe,Math.min(re,de.sourceOut-ke));de.sourceIn=Ze;const it=Ze-De;de.timelineStart+=it}else{const De=Math.max(de.sourceIn+ke,Math.min(re,Ge));de.sourceOut=De;const Ze=de.sourceOut-de.sourceIn;de.timelineEnd=de.timelineStart+Ze}Ce(),m.value&&m.value.trimClip(H,de.sourceIn,de.sourceOut)}function U(H){b();const G=i.clips.find(Ge=>H>Ge.timelineStart&&H<Ge.timelineEnd);if(!G)return;const re=H-G.timelineStart,de=G.sourceIn+re,ke={id:wa(),type:"clip",timelineStart:H,timelineEnd:G.timelineEnd,sourceIn:de,sourceOut:G.sourceOut,speed:G.speed??1,sourceMinIn:G.sourceMinIn??0,sourceMaxOut:G.sourceMaxOut??i.originalDuration,filters:[...G.filters||[]]};G.trackId&&(ke.trackId=G.trackId),G.sourceRefId&&(ke.sourceRefId=G.sourceRefId),G.timelineEnd=H,G.sourceOut=de;const Pe=i.clips.indexOf(G);i.clips.splice(Pe+1,0,ke),ie(),i.selectedClipId=ke.id}function M(){U(i.playheadPosition)}function I(H){var re;const G=H??i.selectedClipId??d.value??((re=i.clips[0])==null?void 0:re.id);G&&(i.selectedClipId=G,d.value=G)}function z(){return i.selectedClipId?X(i.selectedClipId):It("no_selection",Yt("no_selection"))}function X(H){const G=i.clips.findIndex(re=>re.id===H);return G===-1?It("source_not_found","Clip not found."):(b(),i.clips.splice(G,1),ie(),le(G),Ce(),Pa())}function le(H){if(!i.clips.length){delete i.selectedClipId,d.value=void 0;return}const G=Math.max(0,Math.min(H,i.clips.length-1)),re=i.clips[G];re&&(i.selectedClipId=re.id,d.value=re.id)}function ve(H){return H.trackId??`legacy-track-${H.track??0}`}function ie(){const H=i.tracks;if(H)for(const G of H)G.clipIds=i.clips.filter(re=>ve(re)===G.id).map(re=>re.id)}function ne(H="video"){b();const G=i.tracks??[],re=G.reduce((ke,Pe)=>Math.max(ke,Pe.order),-1),de={id:S(H),type:H,name:A(H,G),order:re+1,clipIds:[]};return i.tracks=[...G,de],i.hasChanges=!0,de}function L(H){if(H.length===0)return;const G=new Set(H),re=i.clips.findIndex(de=>G.has(de.id));i.clips=i.clips.filter(de=>!G.has(de.id)),i.transitions&&i.transitions.length>0&&(i.transitions=i.transitions.filter(de=>!G.has(de.fromClipId)&&!G.has(de.toClipId))),ie(),i.selectedClipId!==void 0&&G.has(i.selectedClipId)&&le(re>=0?re:0),Ce()}function D(H){const G=i.tracks??[],re=G.find(ke=>ke.id===H);if(!re)return It("track_missing",Yt("track_missing"));if(G.length<=1)return It("invariant_violation","Can't delete the last remaining track. Add another track first.");b();const de=i.clips.filter(ke=>ve(ke)===re.id).map(ke=>ke.id);return L(de),i.tracks=G.filter(ke=>ke.id!==re.id),i.hasChanges=!0,Pa()}function j(H,G){const de=(i.tracks??[]).find(Pe=>Pe.id===H);if(!de)return It("track_missing",Yt("track_missing"));const ke=G.trim();return ke===""?It("invariant_violation","Track name cannot be empty."):(de.name===ke||(b(),de.name=ke,i.hasChanges=!0),Pa())}function q(H,G){const re=i.tracks??[],de=re.find(it=>it.id===H);if(!de)return It("track_missing",Yt("track_missing"));const ke=[...re].sort((it,We)=>it.order-We.order),Pe=ke.findIndex(it=>it.id===de.id),Ge=G==="up"?Pe+1:Pe-1,De=ke[Ge];if(!De)return It("invariant_violation","Track is already at the edge.");b();const Ze=de.order;return de.order=De.order,De.order=Ze,i.hasChanges=!0,Pa()}function te(H){let G=i.tracks??[];if(G.length===0){const de=N([]);i.tracks=[de],G=i.tracks}if(H){const de=G.find(ke=>ke.id===H);return de?de.locked===!0?{ok:!1,reason:"track_locked"}:{ok:!0,track:de}:{ok:!1,reason:"track_missing"}}const re=G.find(de=>de.type==="video"&&de.locked!==!0)??G.find(de=>de.locked!==!0);return re?{ok:!0,track:re}:{ok:!1,reason:"no_editable_track"}}function ce(H){const G=1/h.value;return typeof H.duration=="number"&&Number.isFinite(H.duration)&&H.duration>G?H.duration:i.originalDuration>G?i.originalDuration:Math.max(G,i.totalDuration)}function me(H){const G=i.clips.filter(re=>ve(re)===H);return G.length>0?G.reduce((re,de)=>Math.max(re,de.timelineEnd),0):Math.max(0,Math.min(i.playheadPosition,i.totalDuration))}function ge(H){const G=i.mediaSources??[],re=G.find(de=>de.id===H.id);return re||(i.mediaSources=[...G,H],i.hasChanges=!0,H)}function Te(H,G){return ye(H,"clip",G)}function he(H,G){if(!(i.mediaSources??[]).find(ke=>ke.id===H))return It("source_not_found",Yt("source_not_found"));let de=G;if(!de){const ke=(i.tracks??[]).find(Pe=>Pe.type==="audio"&&Pe.locked!==!0);de=(ke==null?void 0:ke.id)??ne("audio").id}return ye(H,"audio",de)}function ye(H,G,re){const de=(i.mediaSources??[]).find(wt=>wt.id===H);if(!de)return It("source_not_found",Yt("source_not_found"));const ke=te(re);if(!ke.ok){const wt=ke.reason==="no_editable_track"?"track_missing":ke.reason;return It(wt,Yt(wt))}const Pe=ke.track;if(!Ac(G,Pe.type))return It("track_type_mismatch",Yt("track_type_mismatch"));const Ge=i.clips.filter(wt=>ve(wt)===Pe.id),De=ce(de),Ze=me(Pe.id),it=Os({trackClips:Ge,desiredDuration:De,preferredStart:Ze});if(!it.ok)return It("overlap",Yt("overlap"));b();const We=wa(),Mt={id:We,type:G,trackId:Pe.id,sourceRefId:de.id,timelineStart:it.start,timelineEnd:it.start+De,sourceIn:0,sourceOut:De,sourceMinIn:0,sourceMaxOut:De,speed:1};return i.clips.push(Mt),i.selectedClipId=We,d.value=We,ie(),Ce(),Pa(Mt)}function Se(H){const G=B.value,re=(i.mediaSources??[]).find(De=>De.id===H);if(!G||!re)return!1;b();const de=1/h.value,ke=ce(re),Pe=Math.max(de,G.timelineEnd-G.timelineStart),Ge=Math.max(de,Math.min(Pe,ke));return G.sourceRefId=re.id,G.sourceIn=0,G.sourceOut=Ge,G.sourceMinIn=0,G.sourceMaxOut=ke,G.timelineEnd=G.timelineStart+Ge,Ce(),!0}function Ne(H){const G=i.mediaSources??[];return G.length<=1||kE({clips:i.clips},H)?!1:(b(),i.mediaSources=G.filter(re=>re.id!==H),!0)}function at(H,G){const re=(i.tracks??[]).find(de=>de.id===H);return re?(b(),re[G]=re[G]!==!0,!0):!1}function et(H){return at(H,"locked")}function gt(H){return at(H,"hidden")}function Ct(H){return at(H,"muted")}function yt(H){return at(H,"solo")}function mt(H){if(i.clips.length<=1)return!1;const G=i.clips.findIndex(Pe=>Pe.id===H),re=G===-1?void 0:i.clips[G];if(!re)return!1;const de=Math.max(0,re.timelineEnd-re.timelineStart),ke=ve(re);if(b(),i.clips.splice(G,1),ie(),de>0)for(const Pe of i.clips)ve(Pe)!==ke||Pe.timelineStart<re.timelineEnd||(Pe.timelineStart=Math.max(0,Pe.timelineStart-de),Pe.timelineEnd=Math.max(Pe.timelineStart,Pe.timelineEnd-de));return i.playheadPosition>=re.timelineEnd?i.playheadPosition=Math.max(0,i.playheadPosition-de):i.playheadPosition>re.timelineStart&&(i.playheadPosition=re.timelineStart),le(G),Ce(),i.hasChanges=!0,!0}function ot(){return i.selectedClipId?mt(i.selectedClipId):!1}function kt(){return[...i.clips].sort((H,G)=>H.timelineStart-G.timelineStart)}function xt(H){const G=i.clips.find(Mt=>Mt.id===H);if(!G)return null;const re=ve(G),de=kt().filter(Mt=>ve(Mt)===re),ke=de.findIndex(Mt=>Mt.id===H);if(ke===-1)return null;const Pe=de[ke],Ge=Pe.timelineEnd-Pe.timelineStart,De=ke>0?de[ke-1]:null,Ze=ke<de.length-1?de[ke+1]:null,it=De?De.timelineEnd:0,We=Ze?Ze.timelineStart-Ge:Math.max(Pe.timelineStart,i.totalDuration-Ge);return{minStart:it,maxStart:Math.max(it,We)}}function we(H,G,re){const de=i.clips.find(We=>We.id===H);if(!de)return It("source_not_found","Clip not found.");if(re===void 0||re===de.trackId){const We=xt(H),Mt=We?Math.min(We.maxStart,Math.max(We.minStart,G)):Math.max(0,G);if(Mt===de.timelineStart)return Pa();b();const wt=Mt-de.timelineStart;return de.timelineStart=Mt,de.timelineEnd+=wt,Ce(),m.value&&m.value.moveClip(H,Mt),Pa()}const Pe=(i.tracks??[]).find(We=>We.id===re);if(!Pe)return It("track_missing",Yt("track_missing"));if(Pe.locked===!0)return It("track_locked",Yt("track_locked"));if(!Ac(de.type,Pe.type))return It("track_type_mismatch",Yt("track_type_mismatch"));const Ge=i.clips.filter(We=>ve(We)===Pe.id&&We.id!==de.id),De=de.timelineEnd-de.timelineStart,Ze=Os({trackClips:Ge,desiredDuration:De,preferredStart:Math.max(0,G),ignoreClipId:de.id});if(!Ze.ok)return It("overlap",Yt("overlap"));b(),de.trackId=Pe.id;const it=de.timelineStart;return de.timelineStart=Ze.start,de.timelineEnd=Ze.start+De,ie(),Ce(),m.value&&it!==Ze.start&&m.value.moveClip(H,Ze.start),Pa()}function Ce(){if(i.clips.length===0){i.totalDuration=0;return}const H=i.clips.reduce((G,re)=>re.timelineEnd>G.timelineEnd?re:G);i.totalDuration=H.timelineEnd}function $e(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function Ye(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function Xe(H){i.zoomLevel=Math.max(10,Math.min(600,Math.round(H)))}function ze(){i.isPlaying=!i.isPlaying}function _t(H){i.isPlaying=H}function ct(H){i.playheadPosition=Math.max(0,Math.min(H,i.totalDuration))}function Zt(){const H=Rc(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(H))}catch{}return H}function ta(){i.hasChanges=!1}function aa(){return confirm("Are you sure you want to reset all changes?")?(b(),E(),i.hasChanges=!1,!0):!1}function ia(){return Rc(i)}function wa(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function Sa(H=1920,G=1080){if(u.value)try{m.value=new pm(H,G,h.value),await ka()}catch{m.value=null}}async function ka(){if(!(!m.value||k.value)){k.value=!0;try{const H=ia();await m.value.loadFromRecipe(H);const G=p.secondsToFrames(i.playheadPosition);m.value.seek(G)}catch{}finally{k.value=!1}}}function an(H){}function Q(H){return p.secondsToFrames(H)}function ue(H){return p.framesToSeconds(H)}function oe(H){const G=ue(H);ct(G),m.value&&m.value.seek(H)}function ae(){v.value=!v.value}function xe(){ka()}function Le(H){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&ka()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&ka()},{deep:!0}),e.watch(()=>i.clips.map(H=>H.id),()=>{var G;if(!i.clips.length){delete i.selectedClipId,d.value=void 0;return}if(!i.clips.some(re=>re.id===i.selectedClipId)){const re=d.value&&((G=i.clips.find(de=>de.id===d.value))==null?void 0:G.id);i.selectedClipId=re??i.clips[0].id,d.value=i.selectedClipId}},{deep:!0});function Ke(H){const G=i.selectedClipId?i.clips.find(re=>re.id===i.selectedClipId):i.clips[0];G&&(G.filters=[...H],i.hasChanges=!0)}function pt(H){i.textOverlays=[...H]}function Vt(H){i.audioTracks=[...H]}function ft(H){i.captionTracks=H.map(nn),i.hasChanges=!0}function ht(H){i.visualLayers=H.map(G=>({...G})),i.hasChanges=!0}function Ot(H){i.transitions=H.map(G=>{const re={...G};return G.params&&(re.params={...G.params}),re}),i.hasChanges=!0}function Nt(H,G){const re=i.clips.find(de=>de.id===H);re&&(re.keyframes=G.map(de=>({...de})),i.hasChanges=!0)}function Ut(H){b(),F(H),i.hasChanges=!0}function nn(H){return{...H,segments:H.segments.map(G=>{const re={...G};return G.words&&(re.words=G.words.map(de=>({...de}))),re})}}e.watch(u,H=>{H?Sa():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(h,H=>{p.setFps(H)});function Da(){if(!i.selectedClipId)return It("no_selection",Yt("no_selection"));const H=i.clips.find(De=>De.id===i.selectedClipId);if(!H)return It("no_selection",Yt("no_selection"));const G=ve(H),re=i.clips.filter(De=>ve(De)===G),de=H.timelineEnd-H.timelineStart,ke=Os({trackClips:re,desiredDuration:de,preferredStart:H.timelineEnd});if(!ke.ok)return It("overlap",Yt("overlap"));b();const Pe={...H,id:wa(),timelineStart:ke.start,timelineEnd:ke.start+de,filters:[...H.filters||[]]},Ge=i.clips.indexOf(H);return i.clips.splice(Ge+1,0,Pe),ie(),i.selectedClipId=Pe.id,i.hasChanges=!0,Pa(Pe)}function Ca(H){const G=H??800,re=i.totalDuration;if(re<=0){i.zoomLevel=50;return}const de=G*.8/re;i.zoomLevel=Math.max(10,Math.min(600,Math.round(de)))}function Va(){const H=1/h.value;ct(Math.min(i.playheadPosition+H,i.totalDuration))}function Gt(){const H=1/h.value;ct(Math.max(i.playheadPosition-H,0))}function Tt(){ct(0)}function bt(){ct(i.totalDuration)}function ra(H){if(!Number.isFinite(H)||H<=0)return;const G=B.value??i.clips[0];if(!G){V.value=H;return}const re=G.speed??1;if(re===H){V.value=H;return}b();const de=Math.max(1/h.value,G.sourceOut-G.sourceIn),ke=de/re,Pe=de/H,Ge=Pe-ke;G.speed=H,G.timelineEnd=G.timelineStart+Pe;const De=i.clips.findIndex(Ze=>Ze.id===G.id);if(De!==-1&&Ge!==0)for(let Ze=De+1;Ze<i.clips.length;Ze+=1){const it=i.clips[Ze];it.timelineStart+=Ge,it.timelineEnd+=Ge}Ce(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,V.value=H}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),tracks:e.computed(()=>i.tracks??[]),mediaSources:e.computed(()=>i.mediaSources??[]),transitions:e.computed(()=>i.transitions??[]),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:B,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:V,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:h,useFrameMode:v,handleTrim:O,handleSplit:U,handleClipSelect:I,splitAtPlayhead:M,deleteSelectedClip:z,deleteClip:X,rippleDeleteClip:mt,rippleDeleteSelectedClip:ot,duplicateSelectedClip:Da,addTimelineTrack:ne,deleteTimelineTrack:D,renameTimelineTrack:j,reorderTimelineTrack:q,appendMediaSourceToTimeline:Te,appendAudioSourceToTimeline:he,registerMediaSource:ge,replaceSelectedClipSource:Se,removeMediaSource:Ne,toggleTrackLock:et,toggleTrackHidden:gt,toggleTrackMuted:Ct,toggleTrackSolo:yt,setFilters:Ke,setTextOverlays:pt,setAudioTracks:Vt,setCaptionTracks:ft,setVisualLayers:ht,setTransitions:Ot,setClipKeyframes:Nt,loadRecipe:Ut,moveClip:we,saveDraft:Zt,clearHasChanges:ta,resetChanges:aa,generateRecipe:ia,zoomIn:$e,zoomOut:Ye,setZoomLevel:Xe,fitToWindow:Ca,togglePlayback:ze,setPlaying:_t,seekTo:ct,frameForward:Va,frameBackward:Gt,skipToStart:Tt,skipToEnd:bt,setPlaybackSpeed:ra,updateSourceDuration:x,undo:R,redo:P,canUndo:_,canRedo:g,initializeComposition:Sa,syncCompositionWithState:ka,syncWithComposition:an,convertToFrames:Q,convertToSeconds:ue,seekToFrame:oe,toggleFrameMode:ae,onCompositionReady:xe,onCompositionError:Le}}const _E=[{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}}}],EE={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function ts(n){return typeof n=="object"&&n!==null}function xE(n,a){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return a}function as(n){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean")return n}function SE(n){const a={id:n.id,type:n.type,label:n.label};n.property!==void 0&&(a.property=n.property),n.min!==void 0&&(a.min=n.min),n.max!==void 0&&(a.max=n.max),n.step!==void 0&&(a.step=n.step);const t=as(n.default);return t!==void 0&&(a.default=t),n.options!==void 0&&(a.options=n.options),a}function Gm(n,a,t){const o=be.getFilter(n),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&ts(r))for(const[s,l]of Object.entries(r))i[s]=as(l)??null;for(const s of a){const l=s.property??s.id;i[l]===void 0&&s.default!==void 0&&(i[l]=s.default)}return i}function Jm(n){const a={};for(const t of n){if(t.type!=="slider")continue;const o=t.property??t.id;a[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return a}function CE(n,a,t,o){const i=o.map(SE);return{id:n,name:a,category:t,controls:i,params:i,defaultParams:Gm(n,i),paramRanges:Jm(i)}}function VE(n){const a=n.paramRanges??{},t=Object.entries(a).map(([o,i])=>{var l;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,d=>d.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=as((l=n.defaultParams)==null?void 0:l[o]);return s!==void 0&&(r.default=s),r});return{id:n.id,name:n.name,category:n.category,controls:t,params:t,defaultParams:Gm(n.id,t,n.defaultParams),paramRanges:Jm(t)}}function NE(n,a){return a.toLowerCase()==="unlisted"?!1:be.isFilterCompatibleWithMedia(n,"video")}function Us(n){return EE[n]??n}function ei(n){const a=xE(n,1);return Math.max(0,Math.min(1,a))}function ti(n){if(!ts(n))return{};const a={};for(const[t,o]of Object.entries(n))a[t]=as(o)??null;return a}function TE(n){return!ts(n)||typeof n.filterId!="string"?null:{filterId:n.filterId,params:ti(n.params),intensity:ei(n.intensity)}}function ME(n){if(!ts(n)||typeof n.id!="string"||typeof n.name!="string")return null;const t=(Array.isArray(n.filters)?n.filters:[]).map(i=>TE(i)).filter(i=>i!==null),o=typeof n.created_at=="string"?n.created_at:new Date().toISOString();return{id:n.id,name:n.name,filters:t,created_at:o}}function Km(){be.initializeFilterRegistry();const n=e.ref([]),a=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const b=new Map,R=be.getRegisteredFilters();for(const P of R)NE(P.id,P.category)&&b.set(P.id,CE(P.id,P.name,P.category,P.controls));for(const P of _E)b.has(P.id)||b.set(P.id,VE(P));return Array.from(b.values())}),l=e.computed(()=>{const b=new Map;for(const R of s.value)b.set(R.id,R);return b}),d=e.computed(()=>n.value.length>0),c=e.computed(()=>{const b={};for(const R of s.value)b[R.category]||(b[R.category]=[]),b[R.category].push(R);return b});function u(b){const R=l.value.get(b);if(R)return R;const P=Us(b);return l.value.get(P)??null}function f(b){const R=l.value.get(b);if(R)return R.id;const P=Us(b),O=l.value.get(P);return O?O.id:null}function m(b){const R=b?u(b):a.value;if(!R)return;const P=R.defaultParams||{},O={id:A(),filterId:R.id,params:{...P},intensity:1};return n.value.push(O),i.value=O.id,a.value=R,Object.keys(r).forEach(U=>delete r[U]),Object.assign(r,O.params),t.value=null,O}function p(b){const R=u(b);if(!R)return;a.value=R;const P=R.defaultParams||x(b);Object.assign(r,P),t.value={id:"preview",filterId:R.id,params:{...P},intensity:1}}function h(b){if(Object.assign(r,b),t.value&&(t.value.params={...r}),i.value){const R=n.value.find(P=>P.id===i.value);R&&(R.params={...r})}}function v(b){const R=n.value.findIndex(P=>P.id===b);R!==-1&&n.value.splice(R,1)}function k(b,R){if(b<0||b>=n.value.length||R<0||R>=n.value.length)return;const[P]=n.value.splice(b,1);n.value.splice(R,0,P)}function V(b,R){const P=n.value.find(O=>O.id===b);P&&(P.intensity=Math.max(0,Math.min(1,R)))}function B(b){const R=n.value.find(P=>P.id===b);R&&(R.intensity=R.intensity>0?0:1)}function _(){n.value=[],t.value=null,a.value=null,i.value=null,Object.keys(r).forEach(b=>delete r[b])}function g(b){const R={id:Z(),name:b,filters:n.value.map(O=>({filterId:O.filterId,params:ti(O.params),intensity:ei(O.intensity)})),created_at:new Date().toISOString()};o.value.push(R);const P=o.value.map(O=>({...O}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),R}function E(b){const R=o.value.find(P=>P.id===b);if(R){_();for(const P of R.filters){const O=u(P.filterId);O&&n.value.push({id:A(),filterId:O.id,params:{...P.params},intensity:ei(P.intensity)})}}}function C(b){const R=o.value.findIndex(P=>P.id===b);R!==-1&&(o.value.splice(R,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function N(){try{const b=localStorage.getItem("video-filter-presets");if(!b)return;const R=JSON.parse(b);if(!Array.isArray(R))return;o.value=R.map(P=>ME(P)).filter(P=>P!==null)}catch{}}function S(){if(n.value.length===0)return"No filters applied";const b=n.value.map(R=>{const P=F(R.filterId);return(P==null?void 0:P.name)||R.filterId});return b.length===1?b[0]:b.length===2?`${b[0]} + ${b[1]}`:`${b[0]} + ${b.length-1} more`}function A(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function Z(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function x(b){const R=u(b);return R?R.defaultParams||{}:{}}function F(b){return u(b)}return N(),{videoCompatibleFilters:s,activeFilters:n,selectedFilter:a,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:d,filtersByCategory:c,applyFilter:m,previewFilterEffect:p,updateFilterParams:h,removeFilter:v,reorderFilters:k,updateFilterIntensity:V,toggleFilter:B,clearAllFilters:_,saveFilterPreset:g,loadFilterPreset:E,deleteFilterPreset:C,getFilterSummary:S,setActiveFilters(b){var P;const R=[];for(const O of b){const U=f(O.filterId);if(!U){const M=Us(O.filterId);R.push({...O,filterId:M,params:ti(O.params),intensity:ei(O.intensity)});continue}R.push({...O,filterId:U,params:ti(O.params),intensity:ei(O.intensity)})}n.value=R,i.value=((P=n.value[0])==null?void 0:P.id)??null,Object.keys(r).forEach(O=>delete r[O]),n.value[0]&&Object.assign(r,ti(n.value[0].params))}}}class qm{constructor(a){this.textClips=new Map,this.overlayConfigs=new Map,this.fonts=new Map,this.nextId=0,this.composition=a,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new Qt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new Qt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new Qt({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(a,t,o,i="400"){const r=new Qt({source:t,family:o,weight:i});this.fonts.set(a,r)}loadLocalFont(a,t,o="400"){const i=new Qt({source:`local('${t}')`,family:t,weight:o});this.fonts.set(a,i)}async addTextOverlay(a){const t=`text-overlay-${this.nextId++}`,o=this.buildTextClipConfig(a),i=new _o(o);return await this.composition.add(i),this.textClips.set(t,i),this.overlayConfigs.set(t,{...a}),t}buildTextClipConfig(a){const t={text:a.text,fontSize:a.fontSize||24,fillStyle:a.color||"#ffffff",textAlign:a.textAlign||"center",textBaseline:a.textBaseline||"middle"},o=a.fontFamily||"default",i=this.fonts.get(o)||this.fonts.get("default");if(i&&(t.font=i),this.applyPosition(t,a.position),a.startTime!==void 0&&(t.start=Ie.fromSeconds(a.startTime)),a.duration!==void 0){const r=a.startTime||0;t.stop=Ie.fromSeconds(r+a.duration)}return a.animation&&this.applyAnimation(t,a.animation,a),t}applyPosition(a,t){if(!t){a.position="center";return}if(typeof t!="string"){a.x=t.x,a.y=t.y;return}switch(t){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}}applyAnimation(a,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,d=t.easing||"linear";switch(t.type){case"fade-in":a.alpha=new Oe([i,l],[0,1],{easing:d});break;case"fade-out":a.alpha=new Oe([i,l],[1,0],{easing:d});break;case"rotate":t.rotation&&(a.rotation=new Oe([i,l],[t.rotation.from,t.rotation.to],{easing:d}));break;case"scale":t.scale&&(a.scale=new Oe([i,l],[t.scale.from,t.scale.to],{easing:d}));break;case"slide":t.translate&&(a.translate={x:new Oe([i,l],[t.translate.fromX,t.translate.toX],{easing:d}),y:new Oe([i,l],[t.translate.fromY,t.translate.toY],{easing:d})});break;case"typewriter":a.alpha=new Oe([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(a.rotation=new Oe([i,l],[t.rotation.from,t.rotation.to],{easing:d})),t.scale&&(a.scale=new Oe([i,l],[t.scale.from,t.scale.to],{easing:d})),t.translate&&(a.translate={x:new Oe([i,l],[t.translate.fromX,t.translate.toX],{easing:d}),y:new Oe([i,l],[t.translate.fromY,t.translate.toY],{easing:d})});break}}async updateTextOverlay(a,t){const o=this.textClips.get(a);if(!o)throw new Error(`Text overlay with id ${a} not found`);const i=this.overlayConfigs.get(a);if(!i)throw new Error(`Text overlay with id ${a} is missing config`);const r={...i,...t};o.set(this.buildTextClipConfig(r)),this.overlayConfigs.set(a,r)}async removeTextOverlay(a){const t=this.textClips.get(a);if(!t)throw new Error(`Text overlay with id ${a} 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(a),this.overlayConfigs.delete(a)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const a=Array.from(this.textClips.keys());for(const t of a)await this.removeTextOverlay(t)}getOverlays(){return Array.from(this.overlayConfigs.entries()).map(([a,t])=>({id:a,config:{...t}}))}async addCaptions(a,t="classic",o){var d;const r={classic:Si,cascade:Jr,guinea:Gr,solar:Kr,spotlight:Ci,whisper:Vi}[t],s=await this.composition.createTrack("caption"),l=new zr({transcript:a});if(await s.add(l),await((d=s.generate)==null?void 0:d.call(s,r)),o&&s.clips.length>0){const c=s.clips[0];c==null||c.set(o)}}}class Ym{constructor(a){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=a}async loadAudioSource(a,t){try{const o=await fn.from(a),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(a){return this.addAudioTrack({...a,name:a.name||"Background Music"})}async addAudioTrack(a){const t=`audio-track-${this.nextId++}`,o=await this.resolveAudioSource(a.source),i=this.createAudioClipConfig(a,o),r=new si(i);let s=this.findAudioTrack();s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:a.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:a};return this.audioLayers.set(t,l),t}async resolveAudioSource(a){try{if(a instanceof fn)return a;if(typeof a=="string"&&a.trim()!=="")return await fn.from(a);if(a instanceof File)return await fn.from(URL.createObjectURL(a));throw new Error("Invalid audio source")}catch(t){throw t instanceof Error?t:new Error("Failed to create audio source")}}createAudioClipConfig(a,t){const o={source:t,volume:(a.volume??1)*this.masterVolume};if(a.startTime!==void 0&&(o.start=Ie.fromSeconds(a.startTime)),a.duration!==void 0){const i=a.startTime||0;o.stop=Ie.fromSeconds(i+a.duration)}return(a.fadeIn||a.fadeOut)&&(o.volume=this.createVolumeKeyframes(a)),o}findAudioTrack(){return this.composition.tracks.find(a=>a.kind==="audio")}removeClipFromTrack(a,t){const o=a.clips.indexOf(t);o!==-1&&a.clips.splice(o,1)}createVolumeKeyframes(a){const t=(a.volume??1)*this.masterVolume,o=a.startTime?Math.round(a.startTime*30):0,i=a.duration,r=[],s=[];if(a.fadeIn){const l=Math.round(a.fadeIn*30);r.push(o,o+l),s.push(0,t)}else r.push(o),s.push(t);if(a.fadeOut&&i){const l=o+Math.round(i*30),d=Math.round(a.fadeOut*30);a.fadeIn||(r.push(l-d),s.push(t)),r.push(l),s.push(0)}return new Oe(r,s,{easing:"linear"})}async updateVolume(a,t){const o=this.audioLayers.get(a);if(!o)throw new Error(`Audio track with id ${a} not found`);const i=Math.max(0,Math.min(1,t));o.config.volume=i,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async updateAudioTrack(a,t){const o=this.audioLayers.get(a);if(!o)throw new Error(`Audio track with id ${a} not found`);const i={...o.config,...t,source:t.source??o.config.source},r=await this.resolveAudioSource(i.source),s=new si(this.createAudioClipConfig(i,r));this.removeClipFromTrack(o.track,o.clip),await o.track.add(s),o.clip=s,o.config=i,o.name=i.name||o.name}async applyFadeIn(a,t){const o=this.audioLayers.get(a);if(!o)throw new Error(`Audio track with id ${a} not found`);o.config.fadeIn=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async applyFadeOut(a,t){const o=this.audioLayers.get(a);if(!o)throw new Error(`Audio track with id ${a} not found`);o.config.fadeOut=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async removeAudioTrack(a){const t=this.audioLayers.get(a);if(!t)throw new Error(`Audio track with id ${a} not found`);this.removeClipFromTrack(t.track,t.clip),this.audioLayers.delete(a)}async muteTrack(a,t){const o=this.audioLayers.get(a);if(!o)throw new Error(`Audio track with id ${a} not found`);t?o.clip.set({volume:0}):o.clip.set({volume:this.resolveLayerVolume(o.config)})}setMasterVolume(a){this.masterVolume=Math.max(0,Math.min(1,a));for(const t of this.audioLayers.values())t.clip.set({volume:this.resolveLayerVolume(t.config)})}resolveLayerVolume(a){return a.fadeIn||a.fadeOut?this.createVolumeKeyframes(a):(a.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(a){return this.audioLayers.get(a)}async clearAllAudioTracks(){const a=Array.from(this.audioLayers.keys());for(const t of a)await this.removeAudioTrack(t)}async syncWithVideo(a,t){for(const o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-a;if(i+r>t){o.config.duration=t-i;const s=new si(this.createAudioClipConfig(o.config,o.clip.source)),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(a=>({id:a.id,name:a.name,config:{...a.config,source:a.config.source&&typeof a.config.source=="object"&&"type"in a.config.source?"[AudioSource]":a.config.source}}))}async importConfiguration(a){for(const{name:t,config:o}of a)await this.addAudioTrack({...o,name:t})}}function Qm(n,a){return function(){return n.apply(a,arguments)}}const{toString:BE}=Object.prototype,{getPrototypeOf:vd}=Object,{iterator:ns,toStringTag:ep}=Symbol,os=(n=>a=>{const t=BE.call(a);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),$a=n=>(n=n.toLowerCase(),a=>os(a)===n),is=n=>a=>typeof a===n,{isArray:So}=Array,yi=is("undefined");function Ti(n){return n!==null&&!yi(n)&&n.constructor!==null&&!yi(n.constructor)&&ca(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const tp=$a("ArrayBuffer");function IE(n){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(n):a=n&&n.buffer&&tp(n.buffer),a}const FE=is("string"),ca=is("function"),ap=is("number"),Mi=n=>n!==null&&typeof n=="object",$E=n=>n===!0||n===!1,fr=n=>{if(os(n)!=="object")return!1;const a=vd(n);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(ep in n)&&!(ns in n)},DE=n=>{if(!Mi(n)||Ti(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},RE=$a("Date"),AE=$a("File"),LE=$a("Blob"),PE=$a("FileList"),OE=n=>Mi(n)&&ca(n.pipe),UE=n=>{let a;return n&&(typeof FormData=="function"&&n instanceof FormData||ca(n.append)&&((a=os(n))==="formdata"||a==="object"&&ca(n.toString)&&n.toString()==="[object FormData]"))},zE=$a("URLSearchParams"),[jE,WE,ZE,HE]=["ReadableStream","Request","Response","Headers"].map($a),XE=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bi(n,a,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let o,i;if(typeof n!="object"&&(n=[n]),So(n))for(o=0,i=n.length;o<i;o++)a.call(null,n[o],o,n);else{if(Ti(n))return;const r=t?Object.getOwnPropertyNames(n):Object.keys(n),s=r.length;let l;for(o=0;o<s;o++)l=r[o],a.call(null,n[l],l,n)}}function np(n,a){if(Ti(n))return null;a=a.toLowerCase();const t=Object.keys(n);let o=t.length,i;for(;o-- >0;)if(i=t[o],a===i.toLowerCase())return i;return null}const Ln=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,op=n=>!yi(n)&&n!==Ln;function Il(){const{caseless:n}=op(this)&&this||{},a={},t=(o,i)=>{const r=n&&np(a,i)||i;fr(a[r])&&fr(o)?a[r]=Il(a[r],o):fr(o)?a[r]=Il({},o):So(o)?a[r]=o.slice():a[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&Bi(arguments[o],t);return a}const GE=(n,a,t,{allOwnKeys:o}={})=>(Bi(a,(i,r)=>{t&&ca(i)?n[r]=Qm(i,t):n[r]=i},{allOwnKeys:o}),n),JE=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),KE=(n,a,t,o)=>{n.prototype=Object.create(a.prototype,o),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:a.prototype}),t&&Object.assign(n.prototype,t)},qE=(n,a,t,o)=>{let i,r,s;const l={};if(a=a||{},n==null)return a;do{for(i=Object.getOwnPropertyNames(n),r=i.length;r-- >0;)s=i[r],(!o||o(s,n,a))&&!l[s]&&(a[s]=n[s],l[s]=!0);n=t!==!1&&vd(n)}while(n&&(!t||t(n,a))&&n!==Object.prototype);return a},YE=(n,a,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=a.length;const o=n.indexOf(a,t);return o!==-1&&o===t},QE=n=>{if(!n)return null;if(So(n))return n;let a=n.length;if(!ap(a))return null;const t=new Array(a);for(;a-- >0;)t[a]=n[a];return t},ex=(n=>a=>n&&a instanceof n)(typeof Uint8Array<"u"&&vd(Uint8Array)),tx=(n,a)=>{const o=(n&&n[ns]).call(n);let i;for(;(i=o.next())&&!i.done;){const r=i.value;a.call(n,r[0],r[1])}},ax=(n,a)=>{let t;const o=[];for(;(t=n.exec(a))!==null;)o.push(t);return o},nx=$a("HTMLFormElement"),ox=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Lc=(({hasOwnProperty:n})=>(a,t)=>n.call(a,t))(Object.prototype),ix=$a("RegExp"),ip=(n,a)=>{const t=Object.getOwnPropertyDescriptors(n),o={};Bi(t,(i,r)=>{let s;(s=a(i,r,n))!==!1&&(o[r]=s||i)}),Object.defineProperties(n,o)},rx=n=>{ip(n,(a,t)=>{if(ca(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=n[t];if(ca(o)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},sx=(n,a)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return So(n)?o(n):o(String(n).split(a)),t},lx=()=>{},dx=(n,a)=>n!=null&&Number.isFinite(n=+n)?n:a;function cx(n){return!!(n&&ca(n.append)&&n[ep]==="FormData"&&n[ns])}const ux=n=>{const a=new Array(10),t=(o,i)=>{if(Mi(o)){if(a.indexOf(o)>=0)return;if(Ti(o))return o;if(!("toJSON"in o)){a[i]=o;const r=So(o)?[]:{};return Bi(o,(s,l)=>{const d=t(s,i+1);!yi(d)&&(r[l]=d)}),a[i]=void 0,r}}return o};return t(n,0)},mx=$a("AsyncFunction"),px=n=>n&&(Mi(n)||ca(n))&&ca(n.then)&&ca(n.catch),rp=((n,a)=>n?setImmediate:a?((t,o)=>(Ln.addEventListener("message",({source:i,data:r})=>{i===Ln&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),Ln.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ca(Ln.postMessage)),fx=typeof queueMicrotask<"u"?queueMicrotask.bind(Ln):typeof process<"u"&&process.nextTick||rp,hx=n=>n!=null&&ca(n[ns]),se={isArray:So,isArrayBuffer:tp,isBuffer:Ti,isFormData:UE,isArrayBufferView:IE,isString:FE,isNumber:ap,isBoolean:$E,isObject:Mi,isPlainObject:fr,isEmptyObject:DE,isReadableStream:jE,isRequest:WE,isResponse:ZE,isHeaders:HE,isUndefined:yi,isDate:RE,isFile:AE,isBlob:LE,isRegExp:ix,isFunction:ca,isStream:OE,isURLSearchParams:zE,isTypedArray:ex,isFileList:PE,forEach:Bi,merge:Il,extend:GE,trim:XE,stripBOM:JE,inherits:KE,toFlatObject:qE,kindOf:os,kindOfTest:$a,endsWith:YE,toArray:QE,forEachEntry:tx,matchAll:ax,isHTMLForm:nx,hasOwnProperty:Lc,hasOwnProp:Lc,reduceDescriptors:ip,freezeMethods:rx,toObjectSet:sx,toCamelCase:ox,noop:lx,toFiniteNumber:dx,findKey:np,global:Ln,isContextDefined:op,isSpecCompliantForm:cx,toJSONObject:ux,isAsyncFn:mx,isThenable:px,setImmediate:rp,asap:fx,isIterable:hx};function He(n,a,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",a&&(this.code=a),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}se.inherits(He,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:se.toJSONObject(this.config),code:this.code,status:this.status}}});const sp=He.prototype,lp={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{lp[n]={value:n}});Object.defineProperties(He,lp);Object.defineProperty(sp,"isAxiosError",{value:!0});He.from=(n,a,t,o,i,r)=>{const s=Object.create(sp);return se.toFlatObject(n,s,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),He.call(s,n.message,a,t,o,i),s.cause=n,s.name=n.name,r&&Object.assign(s,r),s};const vx=null;function Fl(n){return se.isPlainObject(n)||se.isArray(n)}function dp(n){return se.endsWith(n,"[]")?n.slice(0,-2):n}function Pc(n,a,t){return n?n.concat(a).map(function(i,r){return i=dp(i),!t&&r?"["+i+"]":i}).join(t?".":""):a}function gx(n){return se.isArray(n)&&!n.some(Fl)}const yx=se.toFlatObject(se,{},null,function(a){return/^is[A-Z]/.test(a)});function rs(n,a,t){if(!se.isObject(n))throw new TypeError("target must be an object");a=a||new FormData,t=se.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,k){return!se.isUndefined(k[v])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,d=(t.Blob||typeof Blob<"u"&&Blob)&&se.isSpecCompliantForm(a);if(!se.isFunction(i))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(se.isDate(h))return h.toISOString();if(se.isBoolean(h))return h.toString();if(!d&&se.isBlob(h))throw new He("Blob is not supported. Use a Buffer instead.");return se.isArrayBuffer(h)||se.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,v,k){let V=h;if(h&&!k&&typeof h=="object"){if(se.endsWith(v,"{}"))v=o?v:v.slice(0,-2),h=JSON.stringify(h);else if(se.isArray(h)&&gx(h)||(se.isFileList(h)||se.endsWith(v,"[]"))&&(V=se.toArray(h)))return v=dp(v),V.forEach(function(_,g){!(se.isUndefined(_)||_===null)&&a.append(s===!0?Pc([v],g,r):s===null?v:v+"[]",c(_))}),!1}return Fl(h)?!0:(a.append(Pc(k,v,r),c(h)),!1)}const f=[],m=Object.assign(yx,{defaultVisitor:u,convertValue:c,isVisitable:Fl});function p(h,v){if(!se.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(h),se.forEach(h,function(V,B){(!(se.isUndefined(V)||V===null)&&i.call(a,V,se.isString(B)?B.trim():B,v,m))===!0&&p(V,v?v.concat(B):[B])}),f.pop()}}if(!se.isObject(n))throw new TypeError("data must be an object");return p(n),a}function Oc(n){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(o){return a[o]})}function gd(n,a){this._pairs=[],n&&rs(n,this,a)}const cp=gd.prototype;cp.append=function(a,t){this._pairs.push([a,t])};cp.toString=function(a){const t=a?function(o){return a.call(this,o,Oc)}:Oc;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function bx(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function up(n,a,t){if(!a)return n;const o=t&&t.encode||bx;se.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(a,t):r=se.isURLSearchParams(a)?a.toString():new gd(a,t).toString(o),r){const s=n.indexOf("#");s!==-1&&(n=n.slice(0,s)),n+=(n.indexOf("?")===-1?"?":"&")+r}return n}class Uc{constructor(){this.handlers=[]}use(a,t,o){return this.handlers.push({fulfilled:a,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){se.forEach(this.handlers,function(o){o!==null&&a(o)})}}const mp={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wx=typeof URLSearchParams<"u"?URLSearchParams:gd,kx=typeof FormData<"u"?FormData:null,_x=typeof Blob<"u"?Blob:null,Ex={isBrowser:!0,classes:{URLSearchParams:wx,FormData:kx,Blob:_x},protocols:["http","https","file","blob","url","data"]},yd=typeof window<"u"&&typeof document<"u",$l=typeof navigator=="object"&&navigator||void 0,xx=yd&&(!$l||["ReactNative","NativeScript","NS"].indexOf($l.product)<0),Sx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cx=yd&&window.location.href||"http://localhost",Vx=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yd,hasStandardBrowserEnv:xx,hasStandardBrowserWebWorkerEnv:Sx,navigator:$l,origin:Cx},Symbol.toStringTag,{value:"Module"})),ea={...Vx,...Ex};function Nx(n,a){return rs(n,new ea.classes.URLSearchParams,{visitor:function(t,o,i,r){return ea.isNode&&se.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...a})}function Tx(n){return se.matchAll(/\w+|\[(\w*)]/g,n).map(a=>a[0]==="[]"?"":a[1]||a[0])}function Mx(n){const a={},t=Object.keys(n);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],a[r]=n[r];return a}function pp(n){function a(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),d=r>=t.length;return s=!s&&se.isArray(i)?i.length:s,d?(se.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!l):((!i[s]||!se.isObject(i[s]))&&(i[s]=[]),a(t,o,i[s],r)&&se.isArray(i[s])&&(i[s]=Mx(i[s])),!l)}if(se.isFormData(n)&&se.isFunction(n.entries)){const t={};return se.forEachEntry(n,(o,i)=>{a(Tx(o),i,t,0)}),t}return null}function Bx(n,a,t){if(se.isString(n))try{return(a||JSON.parse)(n),se.trim(n)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(n)}const Ii={transitional:mp,adapter:["xhr","http","fetch"],transformRequest:[function(a,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=se.isObject(a);if(r&&se.isHTMLForm(a)&&(a=new FormData(a)),se.isFormData(a))return i?JSON.stringify(pp(a)):a;if(se.isArrayBuffer(a)||se.isBuffer(a)||se.isStream(a)||se.isFile(a)||se.isBlob(a)||se.isReadableStream(a))return a;if(se.isArrayBufferView(a))return a.buffer;if(se.isURLSearchParams(a))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let l;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return Nx(a,this.formSerializer).toString();if((l=se.isFileList(a))||o.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return rs(l?{"files[]":a}:a,d&&new d,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Bx(a)):a}],transformResponse:[function(a){const t=this.transitional||Ii.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(se.isResponse(a)||se.isReadableStream(a))return a;if(a&&se.isString(a)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(a)}catch(l){if(s)throw l.name==="SyntaxError"?He.from(l,He.ERR_BAD_RESPONSE,this,null,this.response):l}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ea.classes.FormData,Blob:ea.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};se.forEach(["delete","get","head","post","put","patch"],n=>{Ii.headers[n]={}});const Ix=se.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"]),Fx=n=>{const a={};let t,o,i;return n&&n.split(`
345
+ `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||a[t]&&Ix[t])&&(t==="set-cookie"?a[t]?a[t].push(o):a[t]=[o]:a[t]=a[t]?a[t]+", "+o:o)}),a},zc=Symbol("internals");function Ho(n){return n&&String(n).trim().toLowerCase()}function hr(n){return n===!1||n==null?n:se.isArray(n)?n.map(hr):String(n)}function $x(n){const a=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(n);)a[o[1]]=o[2];return a}const Dx=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function zs(n,a,t,o,i){if(se.isFunction(o))return o.call(this,a,t);if(i&&(a=t),!!se.isString(a)){if(se.isString(o))return a.indexOf(o)!==-1;if(se.isRegExp(o))return o.test(a)}}function Rx(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,t,o)=>t.toUpperCase()+o)}function Ax(n,a){const t=se.toCamelCase(" "+a);["get","set","has"].forEach(o=>{Object.defineProperty(n,o+t,{value:function(i,r,s){return this[o].call(this,a,i,r,s)},configurable:!0})})}let ua=class{constructor(a){a&&this.set(a)}set(a,t,o){const i=this;function r(l,d,c){const u=Ho(d);if(!u)throw new Error("header name must be a non-empty string");const f=se.findKey(i,u);(!f||i[f]===void 0||c===!0||c===void 0&&i[f]!==!1)&&(i[f||d]=hr(l))}const s=(l,d)=>se.forEach(l,(c,u)=>r(c,u,d));if(se.isPlainObject(a)||a instanceof this.constructor)s(a,t);else if(se.isString(a)&&(a=a.trim())&&!Dx(a))s(Fx(a),t);else if(se.isObject(a)&&se.isIterable(a)){let l={},d,c;for(const u of a){if(!se.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(d=l[c])?se.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}s(l,t)}else a!=null&&r(t,a,o);return this}get(a,t){if(a=Ho(a),a){const o=se.findKey(this,a);if(o){const i=this[o];if(!t)return i;if(t===!0)return $x(i);if(se.isFunction(t))return t.call(this,i,o);if(se.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,t){if(a=Ho(a),a){const o=se.findKey(this,a);return!!(o&&this[o]!==void 0&&(!t||zs(this,this[o],o,t)))}return!1}delete(a,t){const o=this;let i=!1;function r(s){if(s=Ho(s),s){const l=se.findKey(o,s);l&&(!t||zs(o,o[l],l,t))&&(delete o[l],i=!0)}}return se.isArray(a)?a.forEach(r):r(a),i}clear(a){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!a||zs(this,this[r],r,a,!0))&&(delete this[r],i=!0)}return i}normalize(a){const t=this,o={};return se.forEach(this,(i,r)=>{const s=se.findKey(o,r);if(s){t[s]=hr(i),delete t[r];return}const l=a?Rx(r):String(r).trim();l!==r&&delete t[r],t[l]=hr(i),o[l]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const t=Object.create(null);return se.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=a&&se.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,t])=>a+": "+t).join(`
346
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...t){const o=new this(a);return t.forEach(i=>o.set(i)),o}static accessor(a){const o=(this[zc]=this[zc]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=Ho(s);o[l]||(Ax(i,s),o[l]=!0)}return se.isArray(a)?a.forEach(r):r(a),this}};ua.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);se.reduceDescriptors(ua.prototype,({value:n},a)=>{let t=a[0].toUpperCase()+a.slice(1);return{get:()=>n,set(o){this[t]=o}}});se.freezeMethods(ua);function js(n,a){const t=this||Ii,o=a||t,i=ua.from(o.headers);let r=o.data;return se.forEach(n,function(l){r=l.call(t,r,i.normalize(),a?a.status:void 0)}),i.normalize(),r}function fp(n){return!!(n&&n.__CANCEL__)}function Co(n,a,t){He.call(this,n??"canceled",He.ERR_CANCELED,a,t),this.name="CanceledError"}se.inherits(Co,He,{__CANCEL__:!0});function hp(n,a,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?n(t):a(new He("Request failed with status code "+t.status,[He.ERR_BAD_REQUEST,He.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Lx(n){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return a&&a[1]||""}function Px(n,a){n=n||10;const t=new Array(n),o=new Array(n);let i=0,r=0,s;return a=a!==void 0?a:1e3,function(d){const c=Date.now(),u=o[r];s||(s=c),t[i]=d,o[i]=c;let f=r,m=0;for(;f!==i;)m+=t[f++],f=f%n;if(i=(i+1)%n,i===r&&(r=(r+1)%n),c-s<a)return;const p=u&&c-u;return p?Math.round(m*1e3/p):void 0}}function Ox(n,a){let t=0,o=1e3/a,i,r;const s=(c,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),n(...c)};return[(...c)=>{const u=Date.now(),f=u-t;f>=o?s(c,u):(i=c,r||(r=setTimeout(()=>{r=null,s(i)},o-f)))},()=>i&&s(i)]}const Br=(n,a,t=3)=>{let o=0;const i=Px(50,250);return Ox(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,d=s-o,c=i(d),u=s<=l;o=s;const f={loaded:s,total:l,progress:l?s/l:void 0,bytes:d,rate:c||void 0,estimated:c&&l&&u?(l-s)/c:void 0,event:r,lengthComputable:l!=null,[a?"download":"upload"]:!0};n(f)},t)},jc=(n,a)=>{const t=n!=null;return[o=>a[0]({lengthComputable:t,total:n,loaded:o}),a[1]]},Wc=n=>(...a)=>se.asap(()=>n(...a)),Ux=ea.hasStandardBrowserEnv?((n,a)=>t=>(t=new URL(t,ea.origin),n.protocol===t.protocol&&n.host===t.host&&(a||n.port===t.port)))(new URL(ea.origin),ea.navigator&&/(msie|trident)/i.test(ea.navigator.userAgent)):()=>!0,zx=ea.hasStandardBrowserEnv?{write(n,a,t,o,i,r){const s=[n+"="+encodeURIComponent(a)];se.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),se.isString(o)&&s.push("path="+o),se.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(n){const a=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return a?decodeURIComponent(a[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jx(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Wx(n,a){return a?n.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):n}function vp(n,a,t){let o=!jx(a);return n&&(o||t==!1)?Wx(n,a):a}const Zc=n=>n instanceof ua?{...n}:n;function Wn(n,a){a=a||{};const t={};function o(c,u,f,m){return se.isPlainObject(c)&&se.isPlainObject(u)?se.merge.call({caseless:m},c,u):se.isPlainObject(u)?se.merge({},u):se.isArray(u)?u.slice():u}function i(c,u,f,m){if(se.isUndefined(u)){if(!se.isUndefined(c))return o(void 0,c,f,m)}else return o(c,u,f,m)}function r(c,u){if(!se.isUndefined(u))return o(void 0,u)}function s(c,u){if(se.isUndefined(u)){if(!se.isUndefined(c))return o(void 0,c)}else return o(void 0,u)}function l(c,u,f){if(f in a)return o(c,u);if(f in n)return o(void 0,c)}const d={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:(c,u,f)=>i(Zc(c),Zc(u),f,!0)};return se.forEach(Object.keys({...n,...a}),function(u){const f=d[u]||i,m=f(n[u],a[u],u);se.isUndefined(m)&&f!==l||(t[u]=m)}),t}const gp=n=>{const a=Wn({},n);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=a;a.headers=s=ua.from(s),a.url=up(vp(a.baseURL,a.url,a.allowAbsoluteUrls),n.params,n.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(se.isFormData(t)){if(ea.hasStandardBrowserEnv||ea.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((d=s.getContentType())!==!1){const[c,...u]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([c||"multipart/form-data",...u].join("; "))}}if(ea.hasStandardBrowserEnv&&(o&&se.isFunction(o)&&(o=o(a)),o||o!==!1&&Ux(a.url))){const c=i&&r&&zx.read(r);c&&s.set(i,c)}return a},Zx=typeof XMLHttpRequest<"u",Hx=Zx&&function(n){return new Promise(function(t,o){const i=gp(n);let r=i.data;const s=ua.from(i.headers).normalize();let{responseType:l,onUploadProgress:d,onDownloadProgress:c}=i,u,f,m,p,h;function v(){p&&p(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let k=new XMLHttpRequest;k.open(i.method.toUpperCase(),i.url,!0),k.timeout=i.timeout;function V(){if(!k)return;const _=ua.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),E={data:!l||l==="text"||l==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:_,config:n,request:k};hp(function(N){t(N),v()},function(N){o(N),v()},E),k=null}"onloadend"in k?k.onloadend=V:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(V)},k.onabort=function(){k&&(o(new He("Request aborted",He.ECONNABORTED,n,k)),k=null)},k.onerror=function(){o(new He("Network Error",He.ERR_NETWORK,n,k)),k=null},k.ontimeout=function(){let g=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const E=i.transitional||mp;i.timeoutErrorMessage&&(g=i.timeoutErrorMessage),o(new He(g,E.clarifyTimeoutError?He.ETIMEDOUT:He.ECONNABORTED,n,k)),k=null},r===void 0&&s.setContentType(null),"setRequestHeader"in k&&se.forEach(s.toJSON(),function(g,E){k.setRequestHeader(E,g)}),se.isUndefined(i.withCredentials)||(k.withCredentials=!!i.withCredentials),l&&l!=="json"&&(k.responseType=i.responseType),c&&([m,h]=Br(c,!0),k.addEventListener("progress",m)),d&&k.upload&&([f,p]=Br(d),k.upload.addEventListener("progress",f),k.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=_=>{k&&(o(!_||_.type?new Co(null,n,k):_),k.abort(),k=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const B=Lx(i.url);if(B&&ea.protocols.indexOf(B)===-1){o(new He("Unsupported protocol "+B+":",He.ERR_BAD_REQUEST,n));return}k.send(r||null)})},Xx=(n,a)=>{const{length:t}=n=n?n.filter(Boolean):[];if(a||t){let o=new AbortController,i;const r=function(c){if(!i){i=!0,l();const u=c instanceof Error?c:this.reason;o.abort(u instanceof He?u:new Co(u instanceof Error?u.message:u))}};let s=a&&setTimeout(()=>{s=null,r(new He(`timeout ${a} of ms exceeded`,He.ETIMEDOUT))},a);const l=()=>{n&&(s&&clearTimeout(s),s=null,n.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),n=null)};n.forEach(c=>c.addEventListener("abort",r));const{signal:d}=o;return d.unsubscribe=()=>se.asap(l),d}},Gx=function*(n,a){let t=n.byteLength;if(t<a){yield n;return}let o=0,i;for(;o<t;)i=o+a,yield n.slice(o,i),o=i},Jx=async function*(n,a){for await(const t of Kx(n))yield*Gx(t,a)},Kx=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const a=n.getReader();try{for(;;){const{done:t,value:o}=await a.read();if(t)break;yield o}}finally{await a.cancel()}},Hc=(n,a,t,o)=>{const i=Jx(n,a);let r=0,s,l=d=>{s||(s=!0,o&&o(d))};return new ReadableStream({async pull(d){try{const{done:c,value:u}=await i.next();if(c){l(),d.close();return}let f=u.byteLength;if(t){let m=r+=f;t(m)}d.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(d){return l(d),i.return()}},{highWaterMark:2})},ss=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",yp=ss&&typeof ReadableStream=="function",qx=ss&&(typeof TextEncoder=="function"?(n=>a=>n.encode(a))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),bp=(n,...a)=>{try{return!!n(...a)}catch{return!1}},Yx=yp&&bp(()=>{let n=!1;const a=new Request(ea.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!a}),Xc=64*1024,Dl=yp&&bp(()=>se.isReadableStream(new Response("").body)),Ir={stream:Dl&&(n=>n.body)};ss&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(a=>{!Ir[a]&&(Ir[a]=se.isFunction(n[a])?t=>t[a]():(t,o)=>{throw new He(`Response type '${a}' is not supported`,He.ERR_NOT_SUPPORT,o)})})})(new Response);const Qx=async n=>{if(n==null)return 0;if(se.isBlob(n))return n.size;if(se.isSpecCompliantForm(n))return(await new Request(ea.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(se.isArrayBufferView(n)||se.isArrayBuffer(n))return n.byteLength;if(se.isURLSearchParams(n)&&(n=n+""),se.isString(n))return(await qx(n)).byteLength},eS=async(n,a)=>{const t=se.toFiniteNumber(n.getContentLength());return t??Qx(a)},tS=ss&&(async n=>{let{url:a,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:d,responseType:c,headers:u,withCredentials:f="same-origin",fetchOptions:m}=gp(n);c=c?(c+"").toLowerCase():"text";let p=Xx([i,r&&r.toAbortSignal()],s),h;const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let k;try{if(d&&Yx&&t!=="get"&&t!=="head"&&(k=await eS(u,o))!==0){let E=new Request(a,{method:"POST",body:o,duplex:"half"}),C;if(se.isFormData(o)&&(C=E.headers.get("content-type"))&&u.setContentType(C),E.body){const[N,S]=jc(k,Br(Wc(d)));o=Hc(E.body,Xc,N,S)}}se.isString(f)||(f=f?"include":"omit");const V="credentials"in Request.prototype;h=new Request(a,{...m,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:V?f:void 0});let B=await fetch(h,m);const _=Dl&&(c==="stream"||c==="response");if(Dl&&(l||_&&v)){const E={};["status","statusText","headers"].forEach(A=>{E[A]=B[A]});const C=se.toFiniteNumber(B.headers.get("content-length")),[N,S]=l&&jc(C,Br(Wc(l),!0))||[];B=new Response(Hc(B.body,Xc,N,()=>{S&&S(),v&&v()}),E)}c=c||"text";let g=await Ir[se.findKey(Ir,c)||"text"](B,n);return!_&&v&&v(),await new Promise((E,C)=>{hp(E,C,{data:g,headers:ua.from(B.headers),status:B.status,statusText:B.statusText,config:n,request:h})})}catch(V){throw v&&v(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new He("Network Error",He.ERR_NETWORK,n,h),{cause:V.cause||V}):He.from(V,V&&V.code,n,h)}}),Rl={http:vx,xhr:Hx,fetch:tS};se.forEach(Rl,(n,a)=>{if(n){try{Object.defineProperty(n,"name",{value:a})}catch{}Object.defineProperty(n,"adapterName",{value:a})}});const Gc=n=>`- ${n}`,aS=n=>se.isFunction(n)||n===null||n===!1,wp={getAdapter:n=>{n=se.isArray(n)?n:[n];const{length:a}=n;let t,o;const i={};for(let r=0;r<a;r++){t=n[r];let s;if(o=t,!aS(t)&&(o=Rl[(s=String(t)).toLowerCase()],o===void 0))throw new He(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build"));let s=a?r.length>1?`since :
347
+ `+r.map(Gc).join(`
348
+ `):" "+Gc(r[0]):"as no adapter specified";throw new He("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:Rl};function Ws(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Co(null,n)}function Jc(n){return Ws(n),n.headers=ua.from(n.headers),n.data=js.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),wp.getAdapter(n.adapter||Ii.adapter)(n).then(function(o){return Ws(n),o.data=js.call(n,n.transformResponse,o),o.headers=ua.from(o.headers),o},function(o){return fp(o)||(Ws(n),o&&o.response&&(o.response.data=js.call(n,n.transformResponse,o.response),o.response.headers=ua.from(o.response.headers))),Promise.reject(o)})}const kp="1.11.0",ls={};["object","boolean","number","function","string","symbol"].forEach((n,a)=>{ls[n]=function(o){return typeof o===n||"a"+(a<1?"n ":" ")+n}});const Kc={};ls.transitional=function(a,t,o){function i(r,s){return"[Axios v"+kp+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,l)=>{if(a===!1)throw new He(i(s," has been removed"+(t?" in "+t:"")),He.ERR_DEPRECATED);return t&&!Kc[s]&&(Kc[s]=!0),a?a(r,s,l):!0}};ls.spelling=function(a){return(t,o)=>!0};function nS(n,a,t){if(typeof n!="object")throw new He("options must be an object",He.ERR_BAD_OPTION_VALUE);const o=Object.keys(n);let i=o.length;for(;i-- >0;){const r=o[i],s=a[r];if(s){const l=n[r],d=l===void 0||s(l,r,n);if(d!==!0)throw new He("option "+r+" must be "+d,He.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new He("Unknown option "+r,He.ERR_BAD_OPTION)}}const vr={assertOptions:nS,validators:ls},Oa=vr.validators;let On=class{constructor(a){this.defaults=a||{},this.interceptors={request:new Uc,response:new Uc}}async request(a,t){try{return await this._request(a,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+=`
349
+ `+r):o.stack=r}catch{}}throw o}}_request(a,t){typeof a=="string"?(t=t||{},t.url=a):t=a||{},t=Wn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&vr.assertOptions(o,{silentJSONParsing:Oa.transitional(Oa.boolean),forcedJSONParsing:Oa.transitional(Oa.boolean),clarifyTimeoutError:Oa.transitional(Oa.boolean)},!1),i!=null&&(se.isFunction(i)?t.paramsSerializer={serialize:i}:vr.assertOptions(i,{encode:Oa.function,serialize:Oa.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),vr.assertOptions(t,{baseUrl:Oa.spelling("baseURL"),withXsrfToken:Oa.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&se.merge(r.common,r[t.method]);r&&se.forEach(["delete","get","head","post","put","patch","common"],h=>{delete r[h]}),t.headers=ua.concat(s,r);const l=[];let d=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(d=d&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let u,f=0,m;if(!d){const h=[Jc.bind(this),void 0];for(h.unshift(...l),h.push(...c),m=h.length,u=Promise.resolve(t);f<m;)u=u.then(h[f++],h[f++]);return u}m=l.length;let p=t;for(f=0;f<m;){const h=l[f++],v=l[f++];try{p=h(p)}catch(k){v.call(this,k);break}}try{u=Jc.call(this,p)}catch(h){return Promise.reject(h)}for(f=0,m=c.length;f<m;)u=u.then(c[f++],c[f++]);return u}getUri(a){a=Wn(this.defaults,a);const t=vp(a.baseURL,a.url,a.allowAbsoluteUrls);return up(t,a.params,a.paramsSerializer)}};se.forEach(["delete","get","head","options"],function(a){On.prototype[a]=function(t,o){return this.request(Wn(o||{},{method:a,url:t,data:(o||{}).data}))}});se.forEach(["post","put","patch"],function(a){function t(o){return function(r,s,l){return this.request(Wn(l||{},{method:a,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}On.prototype[a]=t(),On.prototype[a+"Form"]=t(!0)});let oS=class _p{constructor(a){if(typeof a!="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},a(function(r,s,l){o.reason||(o.reason=new Co(r,s,l),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const t=this._listeners.indexOf(a);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const a=new AbortController,t=o=>{a.abort(o)};return this.subscribe(t),a.signal.unsubscribe=()=>this.unsubscribe(t),a.signal}static source(){let a;return{token:new _p(function(i){a=i}),cancel:a}}};function iS(n){return function(t){return n.apply(null,t)}}function rS(n){return se.isObject(n)&&n.isAxiosError===!0}const Al={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(Al).forEach(([n,a])=>{Al[a]=n});function Ep(n){const a=new On(n),t=Qm(On.prototype.request,a);return se.extend(t,On.prototype,a,{allOwnKeys:!0}),se.extend(t,a,null,{allOwnKeys:!0}),t.create=function(i){return Ep(Wn(n,i))},t}const Ft=Ep(Ii);Ft.Axios=On;Ft.CanceledError=Co;Ft.CancelToken=oS;Ft.isCancel=fp;Ft.VERSION=kp;Ft.toFormData=rs;Ft.AxiosError=He;Ft.Cancel=Ft.CanceledError;Ft.all=function(a){return Promise.all(a)};Ft.spread=iS;Ft.isAxiosError=rS;Ft.mergeConfig=Wn;Ft.AxiosHeaders=ua;Ft.formToJSON=n=>pp(se.isHTMLForm(n)?new FormData(n):n);Ft.getAdapter=wp.getAdapter;Ft.HttpStatusCode=Al;Ft.default=Ft;const{Axios:jD,AxiosError:WD,CanceledError:ZD,isCancel:HD,CancelToken:XD,VERSION:GD,all:JD,Cancel:KD,isAxiosError:qD,spread:YD,toFormData:QD,AxiosHeaders:eR,HttpStatusCode:tR,formToJSON:aR,getAdapter:nR,mergeConfig:oR}=Ft;class ds{constructor(a="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Ft.create({baseURL:a,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(a){try{const t=await this.api.post("/video/jobs",a);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(a){try{const t=await this.api.post("/video/jobs/render",a);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(a,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const d=setInterval(async()=>{try{const c=await this.getJob(a);t==null||t(c.progress,c.status),c.status==="completed"?(clearInterval(d),s(c)):c.status==="failed"?(clearInterval(d),l(new Error(c.error_message??"Render job failed"))):c.status==="cancelled"?(clearInterval(d),l(new Error("Render job cancelled"))):Date.now()-r>i&&(clearInterval(d),l(new Error("Render job timed out")))}catch(c){clearInterval(d),l(c)}},o)})}async getJob(a){try{const t=await this.api.get(`/video/jobs/${a}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(a){try{return(await this.api.get("/video/jobs",{params:a})).data}catch(t){throw t}}async cancelJob(a){try{const t=await this.api.delete(`/video/jobs/${a}`);return this.unsubscribeFromProgress(a),this.normalizeJob(t.data.data)}catch(t){throw t}}async retryJob(a){try{const t=await this.api.post(`/video/jobs/${a}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(a,t){this.progressCallbacks.set(a,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(a)}unsubscribeFromProgress(a){this.progressCallbacks.delete(a),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const a=this.getAuthToken(),t=`/api/v1/video/jobs/events${a?`?token=${a}`:""}`;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(a){const t=setInterval(async()=>{try{const o=await this.getJob(a),i=this.progressCallbacks.get(a);i&&i(o.progress),(o.status==="completed"||o.status==="failed"||o.status==="cancelled")&&(clearInterval(t),this.unsubscribeFromProgress(a))}catch{clearInterval(t)}},2e3)}getAuthToken(){const a=localStorage.getItem("auth_token");if(a)return a;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(a){try{return(await this.api.get(`/video/jobs/${a}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(a,t=0){try{const o=await this.api.get(`/video/jobs/${a}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(a){const t=a,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.progress_message??t.progressMessage;typeof s=="string"&&s!==""&&(o.progress_message=s);const l=t.progress_detail??t.progressDetail;l&&typeof l=="object"&&(o.progress_detail=l);const d=t.started_at??t.startedAt;typeof d=="string"&&d!==""&&(o.started_at=d);const c=t.completed_at??t.completedAt;typeof c=="string"&&c!==""&&(o.completed_at=c);const u=t.cancelled_at??t.cancelledAt;return typeof u=="string"&&u!==""&&(o.cancelled_at=u),o}}new ds;const sS={key:0,class:"mobile-layout"},lS={class:"mobile-toolbar"},dS={class:"mobile-toolbar-left"},cS=["aria-label"],uS={class:"mobile-toolbar-right"},mS=["disabled"],pS=["disabled"],fS={class:"preview-section"},hS={key:0,class:"mobile-export-overlay"},vS={class:"mobile-export-progress"},gS={class:"mobile-export-bar"},yS={class:"mobile-timeline-zoom"},bS={class:"mobile-edit-strip"},wS={class:"mobile-selection-summary"},kS={class:"mobile-selection-title"},_S={class:"mobile-selection-meta"},ES={class:"mobile-readout-row"},xS=["disabled"],SS={class:"mobile-readout-grid"},CS={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},VS={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},NS={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},TS={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},MS=["disabled"],BS={class:"mobile-speed-strip"},IS={class:"mobile-speed-chips"},FS=["data-testid","onClick"],$S={class:"mobile-edit-actions"},DS=["disabled"],RS=["disabled"],AS=["disabled"],LS=["disabled"],PS=["disabled"],OS={class:"mobile-action-sheet-header"},US={class:"mobile-action-sheet-title"},zS={class:"mobile-action-sheet-subtitle"},jS={class:"mobile-action-sheet-actions"},WS=["disabled"],ZS=["disabled"],HS=["disabled"],XS=["disabled"],GS=["disabled"],JS={key:1,class:"desktop-layout"},KS={class:"desktop-main-row"},qS={class:"preview-panel"},YS={class:"fit-toggle"},QS={class:"editor-content"},eC={class:"editor-tabs"},tC={class:"tab-header"},aC=["onClick"],nC={class:"tab-content-area"},oC={class:"filter-controls"},iC={class:"text-controls"},rC={class:"transition-controls"},sC={class:"audio-controls"},lC={class:"adjustments-controls"},dC={key:1,class:"no-filter-selected"},cC={class:"export-controls"},uC={key:0,"data-testid":"video-export-status-completed"},mC={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},pC={class:"desktop-timeline-row"},fC={class:"timeline-zoom"},hC=["value"],vC={class:"zoom-readout"},gC={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},yC={class:"dev-editor-row"},bC={class:"dev-editor-field"},wC={class:"dev-editor-field"},kC=["disabled"],_C=["disabled"],EC=["disabled"],xC={class:"dev-editor-row"},SC={class:"dev-editor-field dev-editor-field--wide"},CC=["value"],VC=["disabled"],NC=["disabled"],TC=["disabled"],MC=["disabled"],BC=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(n,{expose:a,emit:t}){const o=n,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const w=o.media.uuid??o.media.id;return typeof w=="string"&&w.trim()!==""?w.trim():void 0}),s=e.computed(()=>{const w=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return w!==""?w:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),d=e.ref("filters"),c=e.ref("filters"),u=e.computed(()=>{const w=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},$=o.featureFlags;return $?{filters:typeof $.filters=="boolean"?$.filters:w.filters,adjustments:typeof $.adjustments=="boolean"?$.adjustments:w.adjustments,text:typeof $.text=="boolean"?$.text:w.text,transitions:typeof $.transitions=="boolean"?$.transitions:w.transitions,audio:typeof $.audio=="boolean"?$.audio:w.audio,export:typeof $.export=="boolean"?$.export:w.export}:w}),f=e.computed(()=>l.value?d.value:c.value),m=e.computed(()=>f.value==="filters"||k.value),p=e.computed(()=>f.value!=="filters"&&!k.value),h=e.ref(null),v=e.ref(null),k=e.ref(!1),V=e.computed(()=>l.value?h.value:v.value);function B(w){return w==="contain"||w==="cover"||w==="none"}function _(w){if(!(w!=null&&w.metadata))return null;const $=w.metadata.fit_mode;return B($)?$:null}const g=e.shallowRef(null),E=e.ref(null),C=e.ref(_(o.initialRecipe)??"contain"),N=e.ref(null),S=e.ref(null),A=e.ref(null),Z=e.ref(!1),x=new Map,F=e.ref([]),b=e.ref([]),R=e.ref([]),P=e.ref([]),O=e.ref(1),U=()=>{l.value=window.innerWidth<768},M=[{id:"filters",label:"Filters",icon:pn},{id:"adjustments",label:"Adjust",icon:kh},{id:"text",label:"Text",icon:"text-outline"},{id:"transitions",label:"Transitions",icon:"swap-horizontal-outline"},{id:"audio",label:"Audio",icon:"musical-notes-outline"},{id:"export",label:"Export",icon:vo}],I=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],z=e.computed(()=>M.filter(w=>u.value[w.id])),X=e.computed(()=>I.filter(w=>u.value[w.id])),le=e.computed(()=>{var w,$;return((w=X.value[0])==null?void 0:w.id)??(($=z.value[0])==null?void 0:$.id)??"filters"});e.watch(u,w=>{w[d.value]||(d.value=le.value),w[c.value]||(c.value=le.value)},{immediate:!0,deep:!0}),e.watch(le,w=>{u.value[d.value]||(d.value=w),u.value[c.value]||(c.value=w)},{immediate:!0}),e.watch(u,w=>{w.export||(d.value==="export"&&(d.value=le.value),c.value==="export"&&(c.value=le.value))},{immediate:!0,deep:!0});const ve=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),ie=Du(),{currentFrame:ne,playheadPosition:L,timelineClips:D,totalDuration:j,hasChanges:q,isPlaying:te,selectedClip:ce,zoomLevel:me,playbackSpeed:ge,fps:Te,handleTrim:he,handleSplit:ye,handleClipSelect:Se,splitAtPlayhead:Ne,deleteSelectedClip:at,duplicateSelectedClip:et,setZoomLevel:gt,moveClip:Ct,setFilters:yt,setTextOverlays:mt,setAudioTracks:ot,saveDraft:kt,clearHasChanges:xt,resetChanges:we,generateRecipe:Ce,zoomIn:$e,zoomOut:Ye,fitToWindow:Xe,togglePlayback:ze,setPlaying:_t,seekTo:ct,frameForward:Zt,frameBackward:ta,skipToStart:aa,skipToEnd:ia,setPlaybackSpeed:wa,updateSourceDuration:Sa,undo:ka,redo:an,canUndo:Q,canRedo:ue}=Xm(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:oe,activeFilters:ae,selectedFilter:xe,previewFilter:Le,previewFilterEffect:Ke,applyFilter:pt,updateFilterParams:Vt,removeFilter:ft,clearAllFilters:ht,setActiveFilters:Ot}=Km();function Nt(w){var ee,pe;const $=((ee=ce.value)==null?void 0:ee.id)??((pe=D.value[0])==null?void 0:pe.id);$&&(Z.value=!0,typeof w=="object"&&w.id?pt(w.id):typeof w=="string"&&pt(w),yt(ae.value),g.value?g.value.setClipFilters($,ae.value):x.set($,[...ae.value]),Se($),Z.value=!1,La())}function Ut(){var $,ee;const w=(($=ce.value)==null?void 0:$.id)??((ee=D.value[0])==null?void 0:ee.id);w&&Se(w)}function nn(w){const $=ae.value.find(ee=>ee.filterId===w);$&&ft($.id)}const Da=e.computed(()=>oe.value.map($=>{var pe;const ee=[];if($.controls&&$.controls.length>0)for(const Ve of $.controls){const _e=Ve.type;if(_e==="button"||_e==="text"||_e==="range")continue;const Ee={id:Ve.property||Ve.id,label:Ve.label||Ve.id,type:_e,default:Ve.default??(_e==="toggle"?!1:_e==="color"?"#ffffff":0)};_e==="slider"&&(Ee.min=Ve.min??0,Ee.max=Ve.max??1,Ee.step=Ve.step??.01),_e==="select"&&Ve.options&&(Ee.options=Ve.options),ee.push(Ee)}else if($.paramRanges){const Ve=Object.entries($.paramRanges);for(const[_e,Ee]of Ve){const dt=_e.replace(/[-_]/g," ").replace(/\b\w/g,Tn=>Tn.toUpperCase()),fa=(pe=$.defaultParams)==null?void 0:pe[_e],ro=(Ee.min+Ee.max)/2;ee.push({id:_e,label:dt,min:Ee.min,max:Ee.max,step:Ee.step??.01,default:typeof fa=="number"?fa:ro})}}return{id:$.id,name:$.name,category:$.category,params:ee}})),Ca=e.ref("0.00"),Va=e.ref("0.00"),Gt=e.ref("");e.watch(Da,w=>{if(w.length===0){Gt.value="";return}w.some(ee=>ee.id===Gt.value)||(Gt.value=w[0].id)},{immediate:!0});const Tt=e.ref(!1),bt=e.ref(0),ra=e.ref(!1),lt=e.ref(null),Ht=e.ref(null);let Na=null,H=!1;const G=e.computed(()=>{const w=new Map;return ae.value.forEach($=>w.set($.filterId,$)),w}),re=e.computed(()=>{var w,$;return ne.value?ne.value:((w=o.media)==null?void 0:w.thumbnail_url)||(($=o.media)==null?void 0:$.url)}),de=e.ref("");e.watch(()=>{var w,$;return{file:(w=o.media)==null?void 0:w.file,url:($=o.media)==null?void 0:$.url}},(w,$,ee)=>{var Ve,_e;const pe=de.value;ee(()=>{pe&&pe.startsWith("blob:")&&URL.revokeObjectURL(pe)}),(Ve=o.media)!=null&&Ve.file?de.value=URL.createObjectURL(o.media.file):(_e=o.media)!=null&&_e.url?de.value=o.media.url:de.value=""},{immediate:!0}),e.onUnmounted(()=>{de.value&&de.value.startsWith("blob:")&&URL.revokeObjectURL(de.value)});const ke=e.computed(()=>de.value),Pe=wm({forcePixiPreview:k,getPreviewRef:()=>V.value,getSourceUrl:()=>de.value,setPlaying:_t}),Ge=e.computed(()=>{if(!o.media)return null;const{file:w,...$}=o.media;return{...$,url:de.value}}),De=e.computed(()=>{var $;const w=($=o.media)==null?void 0:$.url;return!!(w&&/^https?:/i.test(w))}),Ze=e.computed(()=>ae.value),it=e.computed(()=>L.value),We=e.computed(()=>!!ce.value&&L.value>0),Mt=e.computed(()=>!!ce.value&&D.value.length>1),wt=e.computed(()=>!!ce.value),sa=e.ref(!0),Vo=[.5,1,1.5,2],qn=e.computed(()=>{const w=new Set([0,la.value]);for(const $ of D.value)w.add($.timelineStart),w.add($.timelineEnd);return Array.from(w).filter($=>Number.isFinite($)).sort(($,ee)=>$-ee)}),on=e.computed(()=>qn.value.some(w=>w<L.value-.001)),ps=e.computed(()=>qn.value.some(w=>w>L.value+.001)),bn=e.ref(!1),wn=e.ref(null);function Ta(w){if(!Number.isFinite(w)||w<0)return"0:00";const $=Math.floor(w/60),ee=Math.floor(w%60);return`${$}:${ee.toString().padStart(2,"0")}`}const fs=e.computed(()=>{var ee;const w=ce.value??D.value[0];if(!w)return"No clip selected";const $=(ee=w.label)==null?void 0:ee.trim();return $&&$.length>0?$:`Clip ${w.id.slice(-4)}`}),hs=e.computed(()=>{const w=ce.value??D.value[0];if(!w)return"Tap a clip to start editing";const $=Math.max(0,w.timelineEnd-w.timelineStart);return`${Ta(w.timelineStart)} - ${Ta(w.timelineEnd)} • ${$.toFixed(1)}s`});function Fi(w){return!Number.isFinite(w)||w<0?"0.0s":w<60?`${w.toFixed(1)}s`:Ta(w)}const No=e.computed(()=>Ta(L.value)),$i=e.computed(()=>{const w=ce.value??D.value[0];return w?Ta(w.sourceIn):"0:00"}),vs=e.computed(()=>{const w=ce.value??D.value[0];return w?Ta(w.sourceOut):"0:00"}),gs=e.computed(()=>{const w=ce.value??D.value[0];return w?Fi(w.timelineEnd-w.timelineStart):"0.0s"}),To=e.computed(()=>wn.value===null?ce.value??D.value[0]??null:D.value.find(w=>w.id===wn.value)??null),ys=e.computed(()=>{var ee;const w=To.value;if(!w)return"Clip actions";const $=(ee=w.label)==null?void 0:ee.trim();return $&&$.length>0?$:`Clip ${w.id.slice(-4)}`}),Mo=e.computed(()=>{const w=To.value;return w?`${Ta(w.timelineStart)} - ${Ta(w.timelineEnd)} • ${Fi(w.timelineEnd-w.timelineStart)}`:"Choose an action"}),Bo=e.ref(0),la=e.computed(()=>{try{const w=j.value??j;return w&&typeof w=="number"&&w>0?w:Bo.value}catch{return Bo.value}}),rn=e.ref(),Io=e.ref(),sn=e.ref(),Fo=e.ref(),Yn=e.ref(0),Ga=e.ref(!1);let Jt=null,pa=null;e.watch(la,w=>{var ee;if(Ga.value||!w||w<=0)return;const $=Yn.value||((ee=rn.value)==null?void 0:ee.clientWidth)||0;$>0&&(Ga.value=!0,Xe($))}),e.watch(Yn,w=>{if(Ga.value||!w||w<=0)return;la.value>0&&(Ga.value=!0,Xe(w))}),e.watch(l,w=>{w||Lt()}),e.watch(()=>{var w;return(w=To.value)==null?void 0:w.id},w=>{bn.value&&!w&&Lt()});function ln(w){return Number.isFinite(w)?w.toFixed(2):"0.00"}function zt(w){const $=Number(w);return Number.isFinite($)?$:null}function kn(w){w&&(Ca.value=ln(w.sourceIn),Va.value=ln(w.sourceOut))}e.watch(()=>{var w,$,ee;return[(w=ce.value)==null?void 0:w.id,($=ce.value)==null?void 0:$.sourceIn,(ee=ce.value)==null?void 0:ee.sourceOut]},()=>{kn(ce.value)},{immediate:!0});function Ma(w){const $=ce.value;if(!$)return;const ee=1/30,pe=$.sourceMinIn??0,Ve=$.sourceMaxOut??la.value,_e=$.sourceIn+(L.value-$.timelineStart);if(w==="start"){const dt=Math.max(pe,Math.min(_e,$.sourceOut-ee));Ca.value=ln(dt);return}const Ee=Math.max($.sourceIn+ee,Math.min(_e,Ve));Va.value=ln(Ee)}function St(){const w=ce.value;if(!w)return;const $=zt(Ca.value),ee=zt(Va.value);if($===null||ee===null)return;const pe=1/30,Ve=w.sourceMinIn??0,_e=w.sourceMaxOut??la.value,Ee=Math.max(Ve,Math.min($,_e-pe)),dt=Math.max(Ee+pe,Math.min(ee,_e));he(w.id,"start",Ee),he(w.id,"end",dt),Ca.value=ln(Ee),Va.value=ln(dt),ce.value&&ct(ce.value.timelineStart)}function Ja(){Gt.value.trim()!==""&&Nt(Gt.value)}function $o(){var w;ht(),yt(ae.value),(w=ce.value)!=null&&w.id&&(g.value?g.value.setClipFilters(ce.value.id,ae.value):x.set(ce.value.id,[...ae.value])),La()}function _n(w,$,ee){var Ve,_e;const pe=ae.value.find(Ee=>Ee.filterId===w);pe?(pe.params={...pe.params,[$]:ee},yt(ae.value),g.value&&((Ve=ce.value)!=null&&Ve.id)?g.value.setClipFilters(ce.value.id,ae.value):(_e=ce.value)!=null&&_e.id&&x.set(ce.value.id,[...ae.value]),La(),Ut()):Le.value&&Le.value.filterId===w&&(Le.value.params={...Le.value.params||{},[$]:ee})}function Ra(w){ct(w)}function Do(w){!w||!Number.isFinite(w.timestamp)||ct(w.timestamp)}function Di(w){_t(w)}function En(w){!Number.isFinite(w)||w<=0||(Bo.value=w,Sa(w))}function Lt(){bn.value=!1,wn.value=null}function bs(w){l.value&&(wn.value=w,bn.value=!0)}function Ro(w){var pe,Ve,_e,Ee;const $=((pe=ce.value)==null?void 0:pe.id)??((Ve=D.value[0])==null?void 0:Ve.id)??null;Se(w),(((_e=ce.value)==null?void 0:_e.id)??((Ee=D.value[0])==null?void 0:Ee.id)??null)!==$&&ie.selection()}function xn(w){Ro(w),bs(w)}function Qn(w){w&&ie.selection()}function Aa(){sa.value=!sa.value,ie.selection()}function Ri(){const w=qn.value.filter(ee=>ee<L.value-.001),$=w.length>0?w[w.length-1]:0;ct($)}function Ao(){const w=qn.value.find($=>$>L.value+.001);ct(w??la.value)}function eo(){ka()}function Sn(){an()}function Cn(){const w=D.value.length;Ne(),D.value.length>w&&(ie.success(),Lt())}function to(w){const $=D.value.length;ye(w),D.value.length>$&&ie.success()}function ao(){const w=D.value.length;et(),D.value.length>w&&(ie.selection(),Lt())}function Ka(){const w=D.value.length;at(),D.value.length<w&&(ie.error(),Lt())}function no(w){const $=ge.value;wa(w),ge.value!==$&&ie.selection()}function Vn(w){return w instanceof HTMLElement?w.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Lo(w){if(l.value||Vn(w.target))return;const $=w.key.toLowerCase(),ee=w.metaKey||w.ctrlKey;if(w.code==="Space"){w.preventDefault(),ze();return}if(!ee&&$==="s"){w.preventDefault(),Cn();return}if($==="arrowleft"){w.preventDefault(),ta();return}if($==="arrowright"){w.preventDefault(),Zt();return}if($==="home"){w.preventDefault(),aa();return}if($==="end"){w.preventDefault(),ia();return}if(!ee&&$==="["){w.preventDefault(),Ri();return}if(!ee&&$==="]"){w.preventDefault(),Ao();return}if(ee&&$==="z"&&w.shiftKey){w.preventDefault(),Sn();return}ee&&$==="z"&&(w.preventDefault(),eo())}function ws(){var $;const w=Yn.value||(($=rn.value)==null?void 0:$.clientWidth)||800;Xe(w)}function Ai(w){Ga.value=!0,gt(w)}function Md(){Ga.value=!0,$e()}function oo(){Ga.value=!0,Ye()}function Li(w){const $=w.target,ee=Number($.value);Ai(ee)}function Pi(w){const $=Math.min(600,Math.max(10,me.value+w));Ai($)}function Po(){pa==null||pa(),pa=null;const w=sn.value,$=Fo.value;if(!l.value||!w||!$)return;const ee=()=>{Pi(-20)},pe=()=>{Pi(20)};w.addEventListener("click",ee),$.addEventListener("click",pe),pa=()=>{w.removeEventListener("click",ee),$.removeEventListener("click",pe)}}e.watch([l,sn,Fo],()=>{Po()},{flush:"post"});function Oo(w){var $;g.value=w,($=g.value)!=null&&$.composition&&(N.value=new qm(g.value.composition),S.value=new hi(g.value.composition),A.value=new Ym(g.value.composition));try{x.size&&(x.forEach((ee,pe)=>{g.value.setClipFilters(pe,ee)}),x.clear(),g.value.composition.computeFrame())}catch{}}function Oi(w){w!=null&&w.id&&Ke(w.id)}function Ui(w){Vt(w),La()}async function zi(w){if(!N.value)return;const $=await N.value.addTextOverlay(w);F.value.push({id:$,...w})}async function y(w,$){if(!N.value)return;await N.value.updateTextOverlay(w,$);const ee=F.value.findIndex(pe=>pe.id===w);ee!==-1&&(F.value[ee]={...F.value[ee],...$})}async function T(w){N.value&&(await N.value.removeTextOverlay(w),F.value=F.value.filter($=>$.id!==w))}async function K(w){if(!S.value||P.value.length<2)return;const[$,ee]=P.value,pe=await S.value.applyTransition($,ee,w);b.value.push({id:pe,...w,name:w.type})}function fe(w){if(!S.value)return;const $=b.value[w];$&&(S.value.removeTransition($.id),b.value.splice(w,1))}function Fe(w){}async function Re(w){if(!A.value)return;const $=await A.value.addAudioTrack(w);R.value.push({id:$,...w})}async function qe(w,$){if(!A.value)return;const ee=R.value.findIndex(pe=>pe.id===w);ee!==-1&&(R.value[ee]={...R.value[ee],...$})}async function ut(w){A.value&&(await A.value.removeAudioTrack(w),R.value=R.value.filter($=>$.id!==w))}async function $t(w,$){if(!A.value)return;await A.value.updateVolume(w,$);const ee=R.value.find(pe=>pe.id===w);ee&&(ee.volume=$)}async function na(w,$){if(!A.value)return;await A.value.muteTrack(w,$);const ee=R.value.find(pe=>pe.id===w);ee&&(ee.muted=$)}function io(w){A.value&&(A.value.setMasterVolume(w),O.value=w)}function sf(w){i("thumbnail-selected",w)}function dn(){Na!==null&&(clearInterval(Na),Na=null)}function lf(w,$){return $?{...w,output:{...w.output,format:$.format,quality:$.quality}}:w}function Uo(w){var $;return w.metadata||(w.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),w.metadata.fit_mode=C.value,($=o.media)!=null&&$.url&&/^https?:/i.test(o.media.url)?w.metadata.source_url=o.media.url:delete w.metadata.source_url,w}function Bt(w,$,ee){return Math.min(ee,Math.max($,w))}function ks(w,$){if(typeof w=="number"&&Number.isFinite(w))return w;if(typeof w=="string"){const ee=Number(w);if(Number.isFinite(ee))return ee}return $}function Kt(w,$,ee){for(const pe of $)if(pe in w)return ks(w[pe],ee);return ee}function df(w){const $=typeof w.params=="object"&&w.params!==null?w.params:{};switch(w.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Bt(Kt($,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Bt(Kt($,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Bt(Kt($,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Bt(Kt($,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Bt(Kt($,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const pe=Bt(Kt($,["brightness"],1)-1,-1,1),Ve=Bt(Kt($,["contrast"],1),.1,3),_e=Bt(Kt($,["saturation"],1),0,3);return[{type:"brightness",value:pe},{type:"contrast",value:Ve},{type:"saturation",value:_e}]}default:return[]}}function cf(w){const $=w.timeline[0],ee=Array.isArray($==null?void 0:$.filters)?$.filters:[],pe=[];for(const _e of ee)if(pe.push(...df(_e)),pe.length>=12)break;const Ve={...w,filters:pe.slice(0,12)};if(w.timeline.length===1&&$){const _e=Math.max(0,ks($.sourceIn,0)),Ee=ks($.sourceOut,_e);Ee>_e&&(Ve.trim={start:_e,end:Ee})}return Ve}async function Bd(w,$,ee){return Pe.renderRecipeWithPixi(w,$,ee)}async function uf(w,$){var zo;dn(),H=!1,Pe.resetClientExport(),Ht.value=null,lt.value=null,ra.value=!1,bt.value=0;const ee=Uo(w??Ce()),pe=Ld(ee),Ve=Array.isArray(pe.filters)&&pe.filters.length>0,_e=xs(pe);if(!(q.value||Ve||_e))return xt(),i("video-exported",null),null;const dt=pe.timeline[0],fa=dt?Math.max(0,dt.sourceIn):0,Tn=((dt==null?void 0:dt.sourceOut)??((zo=pe.source)==null?void 0:zo.duration)??la.value)-fa,Vs=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&Tn>o.clientExportThreshold;if(Vs){Tt.value=!0;try{return await mf(pe),null}catch(qt){const ha=qt instanceof Error?qt.message:"Server render failed";throw lt.value=ha,i("server-render-failed",ha),qt}finally{Tt.value=!1}}if(o.maxDuration>0&&Tn>o.maxDuration&&!Vs){const qt=`This video is too long for in-browser export (${Math.round(Tn)}s). Server rendering is not available. Try a shorter clip.`;return lt.value=qt,i("video-exported",null),null}Tt.value=!0;try{const qt=await Bd(pe,$,ha=>{H||(bt.value=ha)});return H?(lt.value="Export canceled.",bt.value=0,i("video-exported",null),null):(xt(),i("recipe-generated",pe),i("video-exported",qt),bt.value=100,ra.value=!0,qt)}catch(qt){if(H)return lt.value="Export canceled.",bt.value=0,i("video-exported",null),null;const ha=qt instanceof Error?qt.message:"Local WebGL export failed.";throw lt.value=ha,new Error(`Video export failed: ${ha}`)}finally{Tt.value=!1}}function ji(){return new ds(o.serverRenderEndpoint??"/api/v1")}async function mf(w){const $=ji();lt.value="Starting server render...",bt.value=0;const ee=await $.createRenderJob({source_media_uuid:s.value,recipe:w});Ht.value=ee.id,i("server-render-started",ee.id),i("export-started",ee.id),lt.value="Rendering on server...";const pe=await $.pollRenderJob(ee.id,(_e,Ee)=>{bt.value=_e,Ee==="processing"&&(lt.value=`Server rendering: ${_e}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);bt.value=100,ra.value=!0,lt.value="Server render complete!",xt(),i("recipe-generated",w);const Ve={id:pe.id};typeof pe.output_media_id=="string"&&pe.output_media_id!==""&&(Ve.output_media_id=pe.output_media_id),i("server-render-completed",Ve)}async function Id(){if(!Tt.value)return;H=!0,k.value=!1,Pe.cancelClientExport(),dn();const w=Ht.value;if(w)try{await ji().cancelJob(w)}catch($){const ee=$ instanceof Error?$.message:"Failed to cancel export";lt.value=ee,Tt.value=!1,Ht.value=null;return}Tt.value=!1,bt.value=0,ra.value=!1,Ht.value=null,lt.value="Export canceled."}async function Fd(w){dn(),H=!1,Pe.resetClientExport(),Ht.value=null,lt.value=null,ra.value=!1,Tt.value=!0,bt.value=0;try{const $=Uo(lf(Ce(),w));i("recipe-generated",$);const ee=s.value.startsWith("temp-"),pe=$.timeline[0],Ve=Array.isArray(pe==null?void 0:pe.filters)?pe.filters:[],_e=!0,Ee=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(_e)try{const ha=await Bd($,w,Sf=>{H||(bt.value=Sf)});if(H){lt.value="Export canceled.",Tt.value=!1,bt.value=0;return}i("video-exported",ha);const Od=URL.createObjectURL(ha.file),Ns=document.createElement("a");Ns.href=Od,Ns.download=`edited-video-${Date.now()}.mp4`,Ns.click(),setTimeout(()=>URL.revokeObjectURL(Od),100),Tt.value=!1,bt.value=100,ra.value=!0;return}catch(ha){if(H){lt.value="Export canceled.",Tt.value=!1,bt.value=0;return}if(ee||!Ee)throw ha;bt.value=0,lt.value="Local filter export failed, falling back to server render."}const dt={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},fa=(w==null?void 0:w.quality)??$.output.quality,ro=dt[fa]??"high",Tn={...cf($),export:{format:(w==null?void 0:w.format)??$.output.format,quality:ro,resolution:fa,framerate:$.output.fps}},zo=await ji().createJob({source_media_id:s.value,recipe:Tn}),qt=typeof zo.id=="string"?zo.id:null;if(!qt)throw new Error("Export failed: missing job id");Ht.value=qt,i("export-started",qt),Ef(qt)}catch($){if(k.value=!1,Pe.resetClientExport(),H){lt.value="Export canceled.",Tt.value=!1,bt.value=0,Ht.value=null;return}try{const ee=Uo(Ce()),pe=new Blob([JSON.stringify(ee,null,2)],{type:"application/json"}),Ve=URL.createObjectURL(pe),_e=document.createElement("a");_e.href=Ve,_e.download=`video-recipe-${Date.now()}.json`,_e.click(),setTimeout(()=>URL.revokeObjectURL(Ve),100)}finally{Tt.value=!1,bt.value=0,Ht.value=null,lt.value=$ instanceof Error?$.message:"Export failed"}}}const _s=async w=>{await new Promise($=>{window.setTimeout($,w)})},Es=w=>{if(!w||w.width<=0||w.height<=0)return null;try{return w.toDataURL("image/jpeg",.85)}catch{return null}},pf=w=>{if(!w||typeof w!="object")return null;const ee=w.pixiCanvas;if(ee&&typeof ee=="object"&&"value"in ee){const pe=ee.value;return pe instanceof HTMLCanvasElement?pe:null}return ee instanceof HTMLCanvasElement?ee:null},ff=w=>{if(!w||typeof w!="object")return null;const $=w.duration;if(typeof $=="number"&&Number.isFinite($))return $;if($&&typeof $=="object"&&"value"in $){const ee=$.value;if(typeof ee=="number"&&Number.isFinite(ee))return ee}return null},hf=w=>{if(!w||typeof w!="object")return null;const ee=w.videoElement;if(ee&&typeof ee=="object"&&"value"in ee){const pe=ee.value;return pe instanceof HTMLVideoElement?pe:null}return ee instanceof HTMLVideoElement?ee:null},$d=w=>typeof w.params=="object"&&w.params!==null?w.params:{},vf=w=>{const $=[];for(const ee of w){const pe=$d(ee),Ve=ee.filterId.trim().toLowerCase();if(Ve==="brightness"){const Ee=(Bt(Kt(pe,["value","brightness"],0),-1,1)+1)*100;$.push(`brightness(${Ee.toFixed(2)}%)`);continue}if(Ve==="contrast"){const _e=Bt(Kt(pe,["value","contrast"],1),.1,4);$.push(`contrast(${(_e*100).toFixed(2)}%)`);continue}if(Ve==="saturation"||Ve==="saturate"){const _e=Bt(Kt(pe,["value","saturation"],1),0,4);$.push(`saturate(${(_e*100).toFixed(2)}%)`);continue}if(Ve==="grayscale"){$.push("grayscale(100%)");continue}if(Ve==="sepia"){$.push("sepia(100%)");continue}if(Ve==="blur"||Ve==="gaussian-blur"||Ve==="kawase-blur"){const _e=Bt(Kt(pe,["value","blur","radius"],0),0,30);_e>.01&&$.push(`blur(${_e.toFixed(2)}px)`);continue}if(Ve==="adjustment"){const _e=Kt(pe,["brightness"],1),Ee=Kt(pe,["contrast"],1),dt=Kt(pe,["saturation"],1);Math.abs(_e-1)>.01&&$.push(`brightness(${(Bt(_e,0,5)*100).toFixed(2)}%)`),Math.abs(Ee-1)>.01&&$.push(`contrast(${(Bt(Ee,.1,5)*100).toFixed(2)}%)`),Math.abs(dt-1)>.01&&$.push(`saturate(${(Bt(dt,0,5)*100).toFixed(2)}%)`);continue}if(Ve==="cinematic"){$.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(Ve==="dramatic"){$.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(Ve==="dreamy"){$.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return $.join(" ")},gf=w=>{const $=w.find(Ve=>Ve.filterId.trim().toLowerCase()==="noise");if(!$)return 0;const ee=$d($),pe=Kt(ee,["noise","value","amount","intensity"],.2);return pe<=1?Bt(pe,0,1):Bt(pe/100,0,1)},yf=(w,$,ee,pe)=>{if(pe<=0)return;const Ve=w.getImageData(0,0,$,ee),_e=255*pe;for(let Ee=0;Ee<Ve.data.length;Ee+=4){const dt=(Math.random()*2-1)*_e;Ve.data[Ee]=Bt(Ve.data[Ee]+dt,0,255),Ve.data[Ee+1]=Bt(Ve.data[Ee+1]+dt,0,255),Ve.data[Ee+2]=Bt(Ve.data[Ee+2]+dt,0,255)}w.putImageData(Ve,0,0)},Dd=async w=>{w.readyState>=2&&w.videoWidth>0&&w.videoHeight>0||await new Promise($=>{let ee=!1,pe=0;const Ve=()=>{ee||(ee=!0,w.removeEventListener("loadedmetadata",_e),w.removeEventListener("loadeddata",_e),w.removeEventListener("canplay",_e),window.clearTimeout(pe),$())},_e=()=>{Ve()};w.addEventListener("loadedmetadata",_e),w.addEventListener("loadeddata",_e),w.addEventListener("canplay",_e),pe=window.setTimeout(()=>Ve(),800),w.play().catch(()=>{})})},bf=async(w,$)=>{await new Promise(ee=>{let pe=!1,Ve=0;const _e=()=>{pe||(pe=!0,w.removeEventListener("seeked",Ee),window.clearTimeout(Ve),ee())},Ee=()=>{_e()};if(Math.abs(w.currentTime-$)<.016){requestAnimationFrame(()=>_e());return}w.addEventListener("seeked",Ee),Ve=window.setTimeout(()=>_e(),700),w.currentTime=$})},Rd=async(w,$)=>{await Dd(w);const ee=Math.floor(w.videoWidth),pe=Math.floor(w.videoHeight);if(ee<=0||pe<=0)return null;const Ve=Number.isFinite(w.duration)&&w.duration>0?w.duration:0,_e=Ve>0?Bt($,0,Ve):0;await bf(w,_e);const Ee=document.createElement("canvas");Ee.width=ee,Ee.height=pe;const dt=Ee.getContext("2d");if(!dt)return null;const fa=vf(ae.value);fa!==""&&(dt.filter=fa);try{dt.drawImage(w,0,0,ee,pe)}catch{return null}const ro=gf(ae.value);return yf(dt,ee,pe,ro),Es(Ee)},wf=async(w,$)=>{const ee=document.createElement("video");ee.src=w,ee.muted=!0,ee.playsInline=!0,ee.preload="auto",w.startsWith("blob:")||(ee.crossOrigin="anonymous");try{return await Dd(ee),await Rd(ee,$)}catch{return null}finally{ee.pause(),ee.removeAttribute("src"),ee.load()}},kf=async w=>{const $=V.value,ee=Es(pf($));if(ee)return ee;if($!=null&&$.captureFrameAt)for(let _e=0;_e<4;_e+=1){const Ee=ff($);if(Ee!==null&&Ee<=0&&_e<2){await _s(80);continue}const dt=await Promise.race([$.captureFrameAt(w),_s(450).then(()=>null)]),fa=Es(dt);if(fa)return fa;await _s(80)}const pe=hf($);if(pe){const _e=await Rd(pe,w);if(_e)return _e}const Ve=ke.value.trim();if(Ve!==""){const _e=await wf(Ve,w);if(_e)return _e}return null},Ad=w=>w.map($=>({...$,params:$.params&&typeof $.params=="object"?{...$.params}:$.params}));function Ld(w){const $=Ad(ae.value);if(!xs(w)&&$.length>0&&Array.isArray(w.timeline)&&w.timeline.length>0){const pe=w.timeline[0];pe&&(w.timeline=[{...pe,filters:$},...w.timeline.slice(1)])}return w}const xs=w=>Array.isArray(w.timeline)?w.timeline.some($=>Array.isArray($.filters)&&$.filters.length>0):!1,_f=w=>{if(!w||typeof w!="object")return null;const $=w.posterFrame;if(typeof $!="string")return null;const ee=$.trim();return ee!==""?ee:null};async function Ss(){const w=Uo(Ld(kt())),$=Ad(ae.value),ee=xs(w)||$.length>0,pe=_f(o.initialRecipe);if(ee){const Ve=L.value>0?L.value:.1;try{const _e=await kf(Ve);_e?w.posterFrame=_e:pe&&(w.posterFrame=pe)}catch{pe&&(w.posterFrame=pe)}}else delete w.posterFrame;return xt(),i("draft-saved",w),w}function Pd(){we()&&(ht(),La())}async function Ef(w){dn();const $=ji();Na=window.setInterval(async()=>{try{if(H){dn();return}const ee=await $.getJob(w),pe=Number(ee.progress??0);if(bt.value=Number.isFinite(pe)?pe:0,ee.status==="completed"||ee.status==="failed"||ee.status==="cancelled")if(dn(),Tt.value=!1,Ht.value=null,ee.status==="completed")bt.value=100,ra.value=!0,lt.value=null;else{const Ve=ee.status==="cancelled"||typeof ee.error_message=="string"&&/cancel/i.test(ee.error_message);lt.value=Ve?"Export canceled.":typeof ee.error_message=="string"&&ee.error_message.trim()!==""?ee.error_message:"Export failed"}}catch(ee){dn(),Tt.value=!1,Ht.value=null,lt.value=ee instanceof Error?ee.message:"Failed to check export progress"}},2e3)}function Cs(){const w=Uo(Ce());try{const $=w.timeline??[]}catch{}E.value=w}let Nn=null;function La(){Nn&&clearTimeout(Nn),Nn=setTimeout(()=>{Cs(),Nn=null},200)}e.watch(()=>D.value,La,{deep:!0}),e.watch(()=>ce.value,w=>{if(Z.value||!w)return;const $=(w==null?void 0:w.filters)??[];Ot($)},{immediate:!0}),e.watch(()=>ae.value,w=>{yt(w),La()},{deep:!0}),e.watch(()=>F.value,w=>{mt(w),La()},{deep:!0}),e.watch(()=>R.value,w=>{const $=w.map(ee=>({...ee,source:typeof ee.source=="string"?ee.source:void 0}));ot($),La()},{deep:!0}),e.watch(()=>L.value,La),a({saveDraft:Ss,exportForUpload:uf}),Cs(),e.onUnmounted(()=>{dn(),H=!0,Pe.cancelClientExport(),Nn&&(clearTimeout(Nn),Nn=null),g.value&&(g.value.destroy(),g.value=null),N.value=null,S.value=null,A.value=null});function xf(){Jt||!Io.value||(Jt=new P2({filters:Da.value,callbacks:{onApplyFilter:w=>{Nt(w.id)},onRemoveFilter:w=>{nn(w)},onUpdateParam:(w,$,ee)=>{_n(w,$,ee)},onPreviewFilter:w=>{Ke(w.id)}}}),Jt.mount(Io.value),Jt.setActiveFilters(G.value))}e.watch(G,w=>{Jt==null||Jt.setActiveFilters(w)},{deep:!0}),e.watch(Da,w=>{Jt==null||Jt.setFilters(w)});let cn=null;return e.onMounted(()=>{window.addEventListener("resize",U),window.addEventListener("keydown",Lo);const w=()=>{!rn.value||cn||(cn=new ResizeObserver($=>{$[0]&&(Yn.value=Math.round($[0].contentRect.width))}),cn.observe(rn.value))};w(),cn||e.nextTick(w),l.value&&(Po(),pa||e.nextTick(Po)),o.media&&Cs(),l.value&&e.nextTick(()=>{xf()}),e.nextTick(()=>{const $=document.querySelector(".video-editor");$&&$.getBoundingClientRect();const ee=document.querySelector(".mobile-layout");ee&&ee.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",U),window.removeEventListener("keydown",Lo),cn==null||cn.disconnect(),cn=null,pa==null||pa(),pa=null,Jt==null||Jt.destroy(),Jt=null}),(w,$)=>{var ee,pe,Ve,_e;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",sS,[e.createElementVNode("div",lS,[e.createElementVNode("div",dS,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(te)}]),onClick:$[0]||($[0]=(...Ee)=>e.unref(ze)&&e.unref(ze)(...Ee)),"aria-label":e.unref(te)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(te)?e.unref(Wl):e.unref(Zl)},null,8,["icon"])],10,cS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:Pd,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn)},null,8,["icon"])])]),e.createElementVNode("div",uS,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Ss,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(q)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Pr)},null,8,["icon"]),$[13]||($[13]=e.createElementVNode("span",null,"Save",-1))],8,mS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:$[1]||($[1]=Ee=>Fd()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:Tt.value||!e.unref(q)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(vo)},null,8,["icon"])],8,pS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:$[2]||($[2]=Ee=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Un)},null,8,["icon"])])])]),e.createElementVNode("div",fS,[e.withDirectives(e.createVNode(tl,{ref_key:"pixiPreviewMobileRef",ref:h,"aria-hidden":!m.value,class:"preview-host-child",source:ke.value,"fallback-duration":la.value,filters:Ze.value,playhead:it.value,"is-playing":e.unref(te),"fit-mode":C.value,active:m.value,onPlayPause:e.unref(ze),onFrameUpdate:Do,onDurationChange:En},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(gl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:E.value,media:Ge.value,"enable-engine":p.value&&De.value,"fit-mode":C.value,onTimeUpdate:Ra,onPlayStateChange:Di,onDurationChange:En,onEngineReady:Oo},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),Tt.value?(e.openBlock(),e.createElementBlock("div",hS,[e.createElementVNode("div",vS,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(bt.value)+"%",1),e.createElementVNode("div",gS,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:bt.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Id},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:rn,class:"timeline-section"},[e.createElementVNode("div",yS,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:sn,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...$[14]||($[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:Fo,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...$[15]||($[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(yl,{playhead:e.unref(L),clips:e.unref(D),"selected-clip-id":((ee=e.unref(ce))==null?void 0:ee.id)??((pe=e.unref(D)[0])==null?void 0:pe.id)??null,duration:la.value,fps:e.unref(Te),"zoom-level":e.unref(me),"snap-enabled":sa.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(ct),onTrim:e.unref(he),onSplit:to,onClipSelect:Ro,onClipMove:e.unref(Ct),onClipLongPress:xn,onSnapStateChange:Qn},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",bS,[e.createElementVNode("div",wS,[e.createElementVNode("span",kS,e.toDisplayString(fs.value),1),e.createElementVNode("span",_S,e.toDisplayString(hs.value),1)]),e.createElementVNode("div",ES,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!on.value,onClick:Ri}," Prev Cut ",8,xS),e.createElementVNode("div",SS,[e.createElementVNode("span",CS,"Playhead "+e.toDisplayString(No.value),1),e.createElementVNode("span",VS,"In "+e.toDisplayString($i.value),1),e.createElementVNode("span",NS,"Out "+e.toDisplayString(vs.value),1),e.createElementVNode("span",TS,"Duration "+e.toDisplayString(gs.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:!ps.value,onClick:Ao}," Next Cut ",8,MS)]),e.createElementVNode("div",BS,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:sa.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:Aa},e.toDisplayString(sa.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",IS,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(Vo,Ee=>e.createElementVNode("button",{key:Ee,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(ge)===Ee}]),"data-testid":`btn-mobile-speed-${String(Ee).replace(".","-")}`,onClick:dt=>no(Ee)},e.toDisplayString(Ee)+"x ",11,FS)),64))])]),e.createElementVNode("div",$S,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(Q),onClick:eo}," Undo ",8,DS),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(ue),onClick:Sn}," Redo ",8,RS),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!We.value,onClick:Cn}," Split ",8,AS),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!wt.value,onClick:ao}," Duplicate ",8,LS),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!Mt.value,onClick:Ka}," Delete ",8,PS)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Io,class:"controls-section mobile-controls"},null,512),bn.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:Lt},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:$[3]||($[3]=e.withModifiers(()=>{},["stop"]))},[$[16]||($[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",OS,[e.createElementVNode("span",US,e.toDisplayString(ys.value),1),e.createElementVNode("span",zS,e.toDisplayString(Mo.value),1)]),e.createElementVNode("div",jS,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(Q),onClick:eo},"Undo",8,WS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(ue),onClick:Sn},"Redo",8,ZS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!We.value,onClick:Cn},"Split",8,HS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!wt.value,onClick:ao},"Duplicate",8,XS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!Mt.value,onClick:Ka},"Delete",8,GS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:Lt},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",JS,[e.createElementVNode("div",KS,[e.createElementVNode("div",qS,[e.createElementVNode("div",YS,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":$[4]||($[4]=Ee=>C.value=Ee),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...$[17]||($[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,C.value]])])]),e.withDirectives(e.createVNode(tl,{ref_key:"pixiPreviewDesktopRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:ke.value,"fallback-duration":la.value,filters:Ze.value,playhead:it.value,"is-playing":e.unref(te),"fit-mode":C.value,active:m.value,onPlayPause:e.unref(ze),onFrameUpdate:Do,onDurationChange:En},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(gl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:E.value,media:Ge.value,"enable-engine":p.value&&De.value,"fit-mode":C.value,onTimeUpdate:Ra,onPlayStateChange:Di,onDurationChange:En,onEngineReady:Oo},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),w.showThumbnailPicker?(e.openBlock(),e.createBlock(vk,{key:0,"media-uuid":s.value,duration:la.value,onSelect:sf},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",QS,[e.createElementVNode("div",eC,[e.createElementVNode("div",tC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.value,Ee=>(e.openBlock(),e.createElementBlock("button",{key:Ee.id,class:e.normalizeClass(["tab-btn",{active:c.value===Ee.id}]),onClick:dt=>c.value=Ee.id},e.toDisplayString(Ee.label),11,aC))),128))]),e.createElementVNode("div",nC,[e.withDirectives(e.createElementVNode("div",oC,[e.createVNode(wl,{filters:Da.value,"active-filters":G.value,"thumbnail-url":re.value,onApplyFilter:Nt,onRemoveFilter:nn,onUpdateParam:_n,onPreviewFilter:Oi},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,c.value==="filters"]]),e.withDirectives(e.createElementVNode("div",iC,[e.createVNode(El,{overlays:F.value,onAddOverlay:zi,onUpdateOverlay:y,onRemoveOverlay:T},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",rC,[e.createVNode(xl,{"selected-clips":P.value,"applied-transitions":b.value,onApplyTransition:K,onRemoveTransition:fe,onPreviewTransition:Fe},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,c.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",sC,[e.createVNode(Sl,{"audio-layers":R.value,"master-volume":O.value,onAddTrack:Re,onUpdateTrack:qe,onRemoveTrack:ut,onUpdateVolume:$t,onToggleMute:na,onUpdateMasterVolume:io},null,8,["audio-layers","master-volume"])],512),[[e.vShow,c.value==="audio"]]),e.withDirectives(e.createElementVNode("div",lC,[e.unref(xe)?(e.openBlock(),e.createBlock(kl,{key:0,filter:e.unref(xe),"current-frame":e.unref(ne),onUpdateParams:Ui},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",dC,[...$[18]||($[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",cC,[e.createVNode(_l,{"can-export":e.unref(q),"is-exporting":Tt.value,"export-progress":bt.value,onExport:Fd,onCancelExport:Id,onSaveDraft:Ss,onReset:Pd},null,8,["can-export","is-exporting","export-progress"]),ra.value?(e.openBlock(),e.createElementBlock("div",uC," Export complete ")):e.createCommentVNode("",!0),lt.value&&!ra.value?(e.openBlock(),e.createElementBlock("div",mC,e.toDisplayString(lt.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])]),e.createElementVNode("div",pC,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:rn,class:"timeline-container"},[e.createElementVNode("div",fC,[e.createElementVNode("label",null,[$[19]||($[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(me),onInput:$[5]||($[5]=Ee=>Li(Ee))},null,40,hC)]),e.createElementVNode("span",vC,e.toDisplayString(Math.round(e.unref(me)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:sa.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:Aa},e.toDisplayString(sa.value?"Snap On":"Snap Off"),3)]),e.createVNode(yl,{playhead:e.unref(L),clips:e.unref(D),"selected-clip-id":((Ve=e.unref(ce))==null?void 0:Ve.id)??((_e=e.unref(D)[0])==null?void 0:_e.id)??null,duration:la.value,fps:e.unref(Te),"zoom-level":e.unref(me),"snap-enabled":sa.value,sensitivity:.25,"onUpdate:playhead":e.unref(ct),onTrim:e.unref(he),onSplit:to,onClipSelect:Ro,onClipMove:e.unref(Ct),onClipLongPress:xn,onSnapStateChange:Qn},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(bl,{"selected-clip":e.unref(ce),"can-split":We.value,"can-delete":Mt.value,"is-playing":e.unref(te),"zoom-level":e.unref(me),"playback-speed":e.unref(ge),onSplit:Cn,onDelete:Ka,onDuplicate:ao,onZoomIn:Md,onZoomOut:oo,onZoomChange:Ai,onFitToWindow:ws,onPlayPause:e.unref(ze),onFrameForward:e.unref(Zt),onFrameBackward:e.unref(ta),onSkipToStart:e.unref(aa),onSkipToEnd:e.unref(ia),onSpeedChange:e.unref(wa)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),ve.value?(e.openBlock(),e.createElementBlock("div",gC,[e.createElementVNode("div",yC,[e.createElementVNode("label",bC,[$[20]||($[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[6]||($[6]=Ee=>Ca.value=Ee),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Ca.value]])]),e.createElementVNode("label",wC,[$[21]||($[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[7]||($[7]=Ee=>Va.value=Ee),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Va.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(ce),onClick:$[8]||($[8]=Ee=>Ma("start"))}," Start = Playhead ",8,kC),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(ce),onClick:$[9]||($[9]=Ee=>Ma("end"))}," End = Playhead ",8,_C),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(ce),onClick:St}," Apply Trim ",8,EC)]),e.createElementVNode("div",xC,[e.createElementVNode("label",SC,[$[22]||($[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":$[10]||($[10]=Ee=>Gt.value=Ee),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Da.value,Ee=>(e.openBlock(),e.createElementBlock("option",{key:Ee.id,value:Ee.id},e.toDisplayString(Ee.name),9,CC))),128))],512),[[e.vModelSelect,Gt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(ce)||Gt.value==="",onClick:Ja}," Apply Filter ",8,VC),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(ae).length===0,onClick:$o}," Clear Filters ",8,NC),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(ce),onClick:$[11]||($[11]=Ee=>Nt("noise"))}," QA: Noise ",8,TC),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(ce),onClick:$[12]||($[12]=Ee=>Nt("grayscale"))}," QA: Grayscale ",8,MC)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),xp=Be(BC,[["__scopeId","data-v-1bb4247b"]]),IC={key:0,class:"video-editor-v2-toolbar"},FC={class:"video-editor-v2-body"},$C={key:0,class:"video-editor-v2-assets","data-testid":"v2-assets-panel"},DC={class:"video-editor-v2-main"},RC={class:"video-editor-v2-canvas"},AC={key:1,class:"video-editor-v2-timeline"},LC=["aria-expanded"],PC=["aria-hidden","inert"],OC="(max-width: 900px)",UC=e.defineComponent({__name:"SplitPanelLayout",setup(n,{expose:a}){const t=e.ref(!1),o=e.ref(!1);let i=null,r=null;const s=c=>{t.value=c,c&&(o.value=!1)},l=()=>{o.value=!0},d=()=>{o.value=!1};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(i=window.matchMedia(OC),s(i.matches),r=c=>s(c.matches),i.addEventListener?i.addEventListener("change",r):"addListener"in i&&i.addListener(r))}),e.onBeforeUnmount(()=>{!i||!r||(i.removeEventListener?i.removeEventListener("change",r):"removeListener"in i&&i.removeListener(r),i=null,r=null)}),a({isMobile:t}),(c,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor-v2",{"is-mobile":t.value,"is-desktop":!t.value}]),"data-testid":"video-editor-v2-shell"},[c.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",IC,[e.renderSlot(c.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",FC,[!t.value&&c.$slots.assets?(e.openBlock(),e.createElementBlock("aside",$C,[e.renderSlot(c.$slots,"assets",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",DC,[e.createElementVNode("div",RC,[e.renderSlot(c.$slots,"canvas",{},void 0,!0)])])]),c.$slots.timeline?(e.openBlock(),e.createElementBlock("div",AC,[e.renderSlot(c.$slots,"timeline",{isMobile:t.value},void 0,!0)])):e.createCommentVNode("",!0),!t.value&&c.$slots.inspector?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"video-editor-v2-tools-tab",type:"button","data-testid":"v2-tools-drawer-open","aria-label":"Open editor tools","aria-controls":"v2-editor-tools-drawer","aria-expanded":o.value?"true":"false",onClick:l}," Tools ",8,LC)),o.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-editor-v2-drawer-backdrop","data-testid":"v2-tools-drawer-backdrop",onClick:d})):e.createCommentVNode("",!0),e.createElementVNode("aside",{id:"v2-editor-tools-drawer",class:e.normalizeClass(["video-editor-v2-side",{"is-open":o.value}]),"data-testid":"v2-side-panel","aria-hidden":o.value?"false":"true",inert:!o.value},[e.createElementVNode("div",{class:"video-editor-v2-side-header"},[u[0]||(u[0]=e.createElementVNode("span",null,"Tools",-1)),e.createElementVNode("button",{class:"video-editor-v2-side-close",type:"button","data-testid":"v2-tools-drawer-close","aria-label":"Close editor tools",onClick:d}," x ")]),e.renderSlot(c.$slots,"inspector",{},void 0,!0)],10,PC)],64)):e.createCommentVNode("",!0),t.value?e.renderSlot(c.$slots,"drawer",{key:3},void 0,!0):e.createCommentVNode("",!0)],2))}}),zC=Be(UC,[["__scopeId","data-v-aaf8ad3f"]]),jC=["aria-selected"],WC={class:"asset-rail-item__main"},ZC={class:"asset-rail-item__type","data-testid":"asset-rail-item-type"},HC={class:"asset-rail-item__label","data-testid":"asset-rail-item-label"},XC={key:0,class:"asset-rail-item__details","data-testid":"asset-rail-item-details"},GC={class:"asset-rail-item__actions","aria-label":"Asset actions"},JC=e.defineComponent({__name:"AssetRailItem",props:{source:{},selected:{type:Boolean}},emits:["add","replaceSelected","remove"],setup(n,{emit:a}){const t=n,o=a,i=e.computed(()=>t.source.label??t.source.name??t.source.filename??t.source.id),r=e.computed(()=>{if(typeof t.source.duration!="number"||!Number.isFinite(t.source.duration))return null;const c=Math.max(0,Math.round(t.source.duration)),u=Math.floor(c/60),f=c%60;return`${u}:${f.toString().padStart(2,"0")}`}),s=e.computed(()=>typeof t.source.width!="number"||typeof t.source.height!="number"||!Number.isFinite(t.source.width)||!Number.isFinite(t.source.height)?null:`${Math.round(t.source.width)}x${Math.round(t.source.height)}`),l=e.computed(()=>[r.value,s.value].filter(c=>c!==null)),d=c=>{if(c==="add"){o("add",t.source.id);return}if(c==="replaceSelected"){o("replaceSelected",t.source.id);return}o("remove",t.source.id)};return(c,u)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["asset-rail-item",{"is-selected":c.selected}]),"aria-selected":c.selected?"true":"false","data-testid":"asset-rail-item"},[e.createElementVNode("div",WC,[e.createElementVNode("span",ZC,e.toDisplayString(c.source.type),1),e.createElementVNode("span",HC,e.toDisplayString(i.value),1),l.value.length>0?(e.openBlock(),e.createElementBlock("span",XC,e.toDisplayString(l.value.join(" / ")),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",GC,[e.createElementVNode("button",{class:"asset-rail-item__action",type:"button",title:"Add to timeline","aria-label":"Add to timeline","data-testid":"asset-rail-item-add",onClick:u[0]||(u[0]=f=>d("add"))}," + "),e.createElementVNode("button",{class:"asset-rail-item__action",type:"button",title:"Replace selected","aria-label":"Replace selected","data-testid":"asset-rail-item-replace",onClick:u[1]||(u[1]=f=>d("replaceSelected"))}," R "),e.createElementVNode("button",{class:"asset-rail-item__action asset-rail-item__action--danger",type:"button",title:"Remove asset","aria-label":"Remove asset","data-testid":"asset-rail-item-remove",onClick:u[2]||(u[2]=f=>d("remove"))}," - ")])],10,jC))}}),KC=Be(JC,[["__scopeId","data-v-3ba2fd25"]]),qC={class:"asset-rail__header"},YC={key:0,class:"asset-rail__list","data-testid":"asset-rail-list"},QC={key:1,class:"asset-rail__empty","data-testid":"asset-rail-empty"},eV=e.defineComponent({__name:"AssetRail",props:{sources:{},selectedSourceId:{},uploadsEnabled:{type:Boolean}},emits:["add","replaceSelected","remove","importFiles"],setup(n,{emit:a}){const t=a,o=e.ref(null),i=e.ref(!1),r=(f,m)=>{if(f==="add"){t("add",m);return}if(f==="replaceSelected"){t("replaceSelected",m);return}t("remove",m)},s=()=>{var f;(f=o.value)==null||f.click()},l=f=>{const m=f.target;if(!(m!=null&&m.files)||m.files.length===0)return;const p=Array.from(m.files);t("importFiles",p),m.value=""},d=f=>{f.preventDefault(),f.dataTransfer&&(f.dataTransfer.dropEffect="copy"),i.value=!0},c=()=>{i.value=!1},u=f=>{var p;f.preventDefault(),i.value=!1;const m=Array.from(((p=f.dataTransfer)==null?void 0:p.files)??[]);m.length!==0&&t("importFiles",m)};return(f,m)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["asset-rail",{"asset-rail--drag-over":i.value&&f.uploadsEnabled}]),"aria-label":"Assets","data-testid":"asset-rail",onDragover:d,onDragleave:c,onDrop:u},[e.createElementVNode("div",qC,[m[3]||(m[3]=e.createElementVNode("h2",{class:"asset-rail__title"},"Assets",-1)),f.uploadsEnabled?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"asset-rail__upload","data-testid":"asset-rail-upload","aria-label":"Upload media files",onClick:s}," Upload ")):e.createCommentVNode("",!0),f.uploadsEnabled?(e.openBlock(),e.createElementBlock("input",{key:1,ref_key:"fileInput",ref:o,class:"asset-rail__file-input",type:"file",accept:"video/mp4,video/webm,video/quicktime,image/png,image/jpeg,image/webp,audio/mpeg,audio/aac,audio/wav",multiple:"","data-testid":"asset-rail-file-input",onChange:l},null,544)):e.createCommentVNode("",!0)]),f.sources.length>0?(e.openBlock(),e.createElementBlock("div",YC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.sources,p=>(e.openBlock(),e.createBlock(KC,{key:p.id,source:p,selected:p.id===f.selectedSourceId,onAdd:m[0]||(m[0]=h=>r("add",h)),onReplaceSelected:m[1]||(m[1]=h=>r("replaceSelected",h)),onRemove:m[2]||(m[2]=h=>r("remove",h))},null,8,["source","selected"]))),128))])):(e.openBlock(),e.createElementBlock("p",QC,e.toDisplayString(f.uploadsEnabled?"Drop files here or click Upload to add media.":"No assets"),1))],34))}}),tV=Be(eV,[["__scopeId","data-v-3db665c6"]]),aV={class:"audio-mixer-panel__tracks","data-testid":"audio-mixer-tracks"},nV={key:0,class:"audio-mixer-panel__empty","data-testid":"audio-mixer-empty"},oV=["data-testid"],iV={class:"audio-mixer-strip__header"},rV={class:"audio-mixer-strip__identity"},sV={class:"audio-mixer-strip__kind"},lV=["data-testid"],dV=["data-testid"],cV=["data-testid"],uV={class:"audio-mixer-meter__rail","aria-hidden":"true"},mV={class:"audio-mixer-meter__value"},pV={class:"audio-mixer-strip__controls"},fV=["for"],hV=["id","min","max","value","data-testid","onInput"],vV={class:"audio-mixer-control__value"},gV={class:"audio-mixer-buttons"},yV=["aria-pressed","aria-label","data-testid","onClick"],bV=["aria-pressed","aria-label","data-testid","onClick"],wV=["for"],kV=["id","value","data-testid","onInput"],_V={class:"audio-mixer-control__value"},EV=["data-testid"],xV={key:0},SV={key:1},CV=["data-testid"],VV=["data-testid"],NV=["data-testid"],TV={class:"audio-mixer-routing__target"},MV={class:"audio-mixer-strip__header"},BV={class:"audio-mixer-strip__identity"},IV={class:"audio-mixer-strip__name","data-testid":"audio-mixer-master-name"},FV={class:"audio-mixer-meter__rail","aria-hidden":"true"},$V={class:"audio-mixer-meter__value"},DV={class:"audio-mixer-strip__controls"},RV={key:0,class:"audio-mixer-control audio-mixer-control--fader",for:"audio-mixer-master-fader"},AV=["min","max","value"],LV={class:"audio-mixer-control__value"},PV={class:"audio-mixer-buttons"},OV=["aria-pressed","aria-label"],UV={key:1,class:"audio-mixer-effects","data-testid":"audio-mixer-master-effects"},zV=["data-testid"],jV=e.defineComponent({__name:"AudioMixerPanel",props:{state:{},deviceClass:{}},emits:["update"],setup(n,{emit:a}){const t=n,o=a,i=e.computed(()=>y_(t.deviceClass,t.state.capabilities)),r=e.computed(()=>t.deviceClass==="desktop"),s=e.computed(()=>[...t.state.tracks].sort((O,U)=>O.order-U.order)),l=e.computed(()=>{const O=new Map(b_(s.value,t.state.master.muted).map(U=>[U.trackId,U]));return s.value.map(U=>({track:U,effectiveState:O.get(U.id)??null}))}),d=e.computed(()=>i.value.canAdjustTrackFaders),c=e.computed(()=>i.value.canAdjustMasterFader),u=e.computed(()=>i.value.canMuteTracks),f=e.computed(()=>r.value&&i.value.canSoloTracks),m=e.computed(()=>r.value&&i.value.canAdjustPan),p=e.computed(()=>i.value.canViewMeters&&i.value.meterMode!=="off"),h=e.computed(()=>r.value&&i.value.canEditEffectSlots&&i.value.maxEffectSlots>0),v=e.computed(()=>r.value&&i.value.canEditRouting),k=O=>{if(!(O.target instanceof HTMLInputElement))return null;const U=Number(O.target.value);return Number.isFinite(U)?U:null},V=(O,U)=>{if(!d.value)return;const M=k(U);M!==null&&o("update",{type:"track-fader-db",trackId:O.id,valueDb:gi(M)})},B=O=>{u.value&&o("update",{type:"track-mute",trackId:O.id,muted:!O.controls.muted})},_=O=>{f.value&&o("update",{type:"track-solo",trackId:O.id,solo:!O.controls.solo})},g=(O,U)=>{if(!m.value)return;const M=k(U);M!==null&&o("update",{type:"track-pan",trackId:O.id,pan:Am(M)})},E=O=>{if(!c.value)return;const U=k(O);U!==null&&o("update",{type:"master-fader-db",valueDb:gi(U)})},C=O=>{u.value&&o("update",{type:"master-mute",muted:!O.muted})},N=O=>{const U=Math.round(O*10)/10;return U>0?`+${U.toFixed(U%1===0?0:1)} dB`:`${U.toFixed(U%1===0?0:1)} dB`},S=O=>O===0?"C":`${O<0?"L":"R"} ${Math.round(Math.abs(O)*100)}`,A=O=>{if(O===void 0)return"";const U=Math.round(O*10)/10;return`${U.toFixed(U%1===0?0:1)}s`},Z=O=>N(O),x=O=>{if(!Number.isFinite(O))return 0;const U=Math.min(Tr,Math.max(vn,O)),M=Tr-vn;return Math.round((U-vn)/M*100)},F=O=>O.slice(0,i.value.maxEffectSlots),b=O=>h.value&&F(O).length>0,R=O=>O.timeline.fadeIn!==void 0||O.timeline.fadeOut!==void 0,P=O=>O===null?"Unknown":O.mutedByMaster?"Master muted":O.mutedByTrack?"Muted":O.mutedBySolo?"Muted by solo":O.soloed?"Solo active":"Audible";return(O,U)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["audio-mixer-panel",`audio-mixer-panel--${O.deviceClass}`]),"data-testid":"audio-mixer-panel","aria-label":"Audio mixer"},[e.createElementVNode("div",aV,[l.value.length===0?(e.openBlock(),e.createElementBlock("p",nV," No audio tracks ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,({track:M,effectiveState:I})=>(e.openBlock(),e.createElementBlock("article",{key:M.id,class:e.normalizeClass(["audio-mixer-strip",{"is-muted":(I==null?void 0:I.effectivelyMuted)===!0,"is-soloed":M.controls.solo}]),"data-testid":`audio-mixer-track-${M.id}`},[e.createElementVNode("header",iV,[e.createElementVNode("div",rV,[e.createElementVNode("span",sV,e.toDisplayString(M.kind),1),e.createElementVNode("h3",{class:"audio-mixer-strip__name","data-testid":`audio-mixer-track-name-${M.id}`},e.toDisplayString(M.name),9,lV)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":(I==null?void 0:I.audible)===!0}]),"data-testid":`audio-mixer-track-status-${M.id}`},e.toDisplayString(P(I)),11,dV)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":M.controls.meter.clipping}]),"data-testid":`audio-mixer-track-meter-${M.id}`,"aria-label":"Track meter"},[e.createElementVNode("span",uV,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${x(M.controls.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",mV,e.toDisplayString(Z(M.controls.meter.peakDb)),1)],10,cV)):e.createCommentVNode("",!0),e.createElementVNode("div",pV,[d.value?(e.openBlock(),e.createElementBlock("label",{key:0,class:"audio-mixer-control audio-mixer-control--fader",for:`audio-mixer-track-fader-${M.id}`},[U[2]||(U[2]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:`audio-mixer-track-fader-${M.id}`,type:"range",class:"audio-mixer-control__range",min:M.controls.fader.minDb,max:M.controls.fader.maxDb,value:M.controls.fader.valueDb,step:"0.5","data-testid":`audio-mixer-track-fader-${M.id}`,onInput:z=>V(M,z)},null,40,hV),e.createElementVNode("span",vV,e.toDisplayString(N(M.controls.fader.valueDb)),1)],8,fV)):e.createCommentVNode("",!0),e.createElementVNode("div",gV,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":M.controls.muted}]),"aria-pressed":M.controls.muted?"true":"false","aria-label":M.controls.muted?`Unmute ${M.name}`:`Mute ${M.name}`,"data-testid":`audio-mixer-track-mute-${M.id}`,onClick:z=>B(M)}," M ",10,yV)):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["audio-mixer-button audio-mixer-button--solo",{"is-active":M.controls.solo}]),"aria-pressed":M.controls.solo?"true":"false","aria-label":M.controls.solo?`Clear solo on ${M.name}`:`Solo ${M.name}`,"data-testid":`audio-mixer-track-solo-${M.id}`,onClick:z=>_(M)}," S ",10,bV)):e.createCommentVNode("",!0)])]),m.value?(e.openBlock(),e.createElementBlock("label",{key:1,class:"audio-mixer-control audio-mixer-control--pan",for:`audio-mixer-track-pan-${M.id}`},[U[3]||(U[3]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Pan",-1)),e.createElementVNode("input",{id:`audio-mixer-track-pan-${M.id}`,type:"range",class:"audio-mixer-control__range",min:"-1",max:"1",step:"0.01",value:M.controls.pan.value,"data-testid":`audio-mixer-track-pan-${M.id}`,onInput:z=>g(M,z)},null,40,kV),e.createElementVNode("span",_V,e.toDisplayString(S(M.controls.pan.value)),1)],8,wV)):e.createCommentVNode("",!0),R(M)?(e.openBlock(),e.createElementBlock("div",{key:2,class:"audio-mixer-strip__fades","data-testid":`audio-mixer-track-fades-${M.id}`},[M.timeline.fadeIn!==void 0?(e.openBlock(),e.createElementBlock("span",xV," In "+e.toDisplayString(A(M.timeline.fadeIn)),1)):e.createCommentVNode("",!0),M.timeline.fadeOut!==void 0?(e.openBlock(),e.createElementBlock("span",SV," Out "+e.toDisplayString(A(M.timeline.fadeOut)),1)):e.createCommentVNode("",!0)],8,EV)):e.createCommentVNode("",!0),b(M.effectSlots)?(e.openBlock(),e.createElementBlock("div",{key:3,class:"audio-mixer-effects","data-testid":`audio-mixer-track-effects-${M.id}`},[U[4]||(U[4]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F(M.effectSlots),z=>(e.openBlock(),e.createElementBlock("span",{key:z.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":z.kind==="empty","is-bypassed":z.bypassed,"is-enabled":z.enabled&&!z.bypassed}]),"data-testid":`audio-mixer-track-effect-${M.id}-${z.index}`},e.toDisplayString(z.label),11,VV))),128))],8,CV)):e.createCommentVNode("",!0),v.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"audio-mixer-routing","data-testid":`audio-mixer-track-routing-${M.id}`},[U[5]||(U[5]=e.createElementVNode("span",{class:"audio-mixer-routing__label"},"Route",-1)),e.createElementVNode("span",TV,e.toDisplayString(O.state.master.name),1)],8,NV)):e.createCommentVNode("",!0)],10,oV))),128))]),e.createElementVNode("article",{class:e.normalizeClass(["audio-mixer-strip audio-mixer-strip--master",{"is-muted":O.state.master.muted}]),"data-testid":"audio-mixer-master-strip"},[e.createElementVNode("header",MV,[e.createElementVNode("div",BV,[U[6]||(U[6]=e.createElementVNode("span",{class:"audio-mixer-strip__kind"},"master",-1)),e.createElementVNode("h3",IV,e.toDisplayString(O.state.master.name),1)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":!O.state.master.muted}]),"data-testid":"audio-mixer-master-status"},e.toDisplayString(O.state.master.muted?"Muted":"Active"),3)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":O.state.master.meter.clipping}]),"data-testid":"audio-mixer-master-meter","aria-label":"Master meter"},[e.createElementVNode("span",FV,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${x(O.state.master.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",$V,e.toDisplayString(Z(O.state.master.meter.peakDb)),1)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",DV,[c.value?(e.openBlock(),e.createElementBlock("label",RV,[U[7]||(U[7]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:"audio-mixer-master-fader",type:"range",class:"audio-mixer-control__range",min:O.state.master.fader.minDb,max:O.state.master.fader.maxDb,value:O.state.master.fader.valueDb,step:"0.5","data-testid":"audio-mixer-master-fader",onInput:U[0]||(U[0]=M=>E(M))},null,40,AV),e.createElementVNode("span",LV,e.toDisplayString(N(O.state.master.fader.valueDb)),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",PV,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":O.state.master.muted}]),"aria-pressed":O.state.master.muted?"true":"false","aria-label":O.state.master.muted?`Unmute ${O.state.master.name}`:`Mute ${O.state.master.name}`,"data-testid":"audio-mixer-master-mute",onClick:U[1]||(U[1]=M=>C(O.state.master))}," M ",10,OV)):e.createCommentVNode("",!0)])]),b(O.state.master.effectSlots)?(e.openBlock(),e.createElementBlock("div",UV,[U[8]||(U[8]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F(O.state.master.effectSlots),M=>(e.openBlock(),e.createElementBlock("span",{key:M.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":M.kind==="empty","is-bypassed":M.bypassed,"is-enabled":M.enabled&&!M.bypassed}]),"data-testid":`audio-mixer-master-effect-${M.index}`},e.toDisplayString(M.label),11,zV))),128))])):e.createCommentVNode("",!0)],2)],2))}}),qc=Be(jV,[["__scopeId","data-v-e5c785e8"]]),WV={class:"caption-srt-panel__header"},ZV={class:"caption-srt-panel__title-group"},HV={class:"caption-srt-panel__title"},XV=["id"],GV={key:0,class:"caption-srt-panel__stats","data-testid":"caption-srt-desktop-stats"},JV={key:0,class:"caption-srt-panel__desktop-controls","data-testid":"caption-srt-desktop-controls"},KV={class:"caption-srt-panel__field"},qV={class:"caption-srt-panel__field"},YV=["for"],QV=["id","aria-describedby","aria-invalid"],eN=["id"],tN=["id"],aN={key:3,class:"caption-srt-panel__cue-summary","data-testid":"caption-srt-cue-summary","aria-label":"Current caption cue summary"},nN={key:0,class:"caption-srt-panel__cue-list"},oN={class:"caption-srt-panel__cue-time"},iN={class:"caption-srt-panel__cue-text"},rN={key:1,class:"caption-srt-panel__empty"},sN=e.defineComponent({__name:"CaptionSrtPanel",props:{captionTrack:{default:null},segments:{default:null},layout:{default:"desktop"},trackId:{default:"caption-track-srt"},idPrefix:{default:"srt-cue"},panelId:{default:"caption-srt-panel"},title:{default:"Caption SRT"},textareaLabel:{default:"SRT caption text"}},emits:["import","update:captionTrack","update:segments","export","clear"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(""),r=e.ref(null),s=e.ref(null),l=e.ref(""),d=e.ref(""),c=e.ref(!1),u=e.computed(()=>t.layout==="mobile"),f=e.computed(()=>`${t.panelId}-textarea`),m=e.computed(()=>`${t.panelId}-helper`),p=e.computed(()=>`${t.panelId}-error`),h=e.computed(()=>`${t.panelId}-status`),v=e.computed(()=>{const b=[m.value,h.value];return r.value!==null&&b.push(p.value),b.join(" ")}),k=e.computed(()=>t.captionTrack!==null?t.captionTrack.segments:t.segments??[]),V=e.computed(()=>{try{return{text:Bc(k.value),errorMessage:null}}catch(b){return{text:"",errorMessage:Z(b)}}}),B=e.computed(()=>k.value.length),_=e.computed(()=>k.value.reduce((b,R)=>Math.max(b,R.endTime),0)),g=e.computed(()=>k.value.slice(0,5));e.watch(()=>{var b,R;return[(b=t.captionTrack)==null?void 0:b.id,(R=t.captionTrack)==null?void 0:R.language,t.trackId]},([b,R,P])=>{l.value=b??P,d.value=R??""},{immediate:!0}),e.watch(V,b=>{if(b.errorMessage!==null){r.value=b.errorMessage;return}c.value||(i.value=b.text)},{immediate:!0});const E=()=>{c.value=!0,s.value=null,r.value!==null&&(r.value=null)},C=()=>{const b=i.value;if(r.value=null,s.value=null,b.trim()===""){r.value="Paste SRT text before importing captions.";return}try{const R=P_(b,{idPrefix:t.idPrefix}),P=tE(A(R)),O=Bc(P.segments);i.value=O,c.value=!1,s.value=`Imported ${x(P.segments.length)}.`,o("update:captionTrack",P),o("update:segments",P.segments),o("import",{track:P,segments:P.segments,sourceText:b})}catch(R){r.value=Z(R)}},N=()=>{const b=V.value;if(r.value=b.errorMessage,b.errorMessage!==null){s.value=null;return}i.value=b.text,c.value=!1,s.value=b.text===""?"No captions to export.":`Exported ${x(B.value)}.`,o("export",b.text)},S=()=>{i.value="",c.value=!0,r.value=null,s.value="SRT text cleared.",o("clear")};function A(b){var O,U;const R={id:l.value.trim(),source:"srt-import",stylePreset:((O=t.captionTrack)==null?void 0:O.stylePreset)??"default",animation:((U=t.captionTrack)==null?void 0:U.animation)??"none",segments:b},P=d.value.trim();return P!==""&&(R.language=P),R}function Z(b){return b instanceof gn||b instanceof Error?b.message:"Unable to process SRT captions."}function x(b){return b===1?"1 cue":`${b} cues`}function F(b){const R=Math.floor(b/60),P=Math.floor(b%60);return`${R}:${P.toString().padStart(2,"0")}`}return(b,R)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["caption-srt-panel",{"caption-srt-panel--mobile":u.value}]),"data-testid":"caption-srt-panel","aria-label":"SRT caption import and export"},[e.createElementVNode("header",WV,[e.createElementVNode("div",ZV,[e.createElementVNode("h2",HV,e.toDisplayString(b.title),1),e.createElementVNode("p",{id:m.value,class:"caption-srt-panel__helper"}," Paste SRT, import it as captions, or export the current caption track. ",8,XV)]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",GV,[e.createElementVNode("span",null,e.toDisplayString(x(B.value)),1),e.createElementVNode("span",null,e.toDisplayString(F(_.value)),1)]))]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",JV,[e.createElementVNode("label",KV,[R[3]||(R[3]=e.createElementVNode("span",null,"Track ID",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[0]||(R[0]=P=>l.value=P),class:"caption-srt-panel__input",type:"text",autocomplete:"off","data-testid":"caption-srt-track-id"},null,512),[[e.vModelText,l.value]])]),e.createElementVNode("label",qV,[R[4]||(R[4]=e.createElementVNode("span",null,"Language",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[1]||(R[1]=P=>d.value=P),class:"caption-srt-panel__input",type:"text",autocomplete:"off",placeholder:"en","data-testid":"caption-srt-language"},null,512),[[e.vModelText,d.value]])])])),e.createElementVNode("label",{class:"caption-srt-panel__textarea-label",for:f.value},e.toDisplayString(b.textareaLabel),9,YV),e.withDirectives(e.createElementVNode("textarea",{id:f.value,"onUpdate:modelValue":R[2]||(R[2]=P=>i.value=P),class:e.normalizeClass(["caption-srt-panel__textarea",{"has-error":r.value!==null}]),spellcheck:"false","aria-describedby":v.value,"aria-invalid":r.value!==null?"true":"false","data-testid":"caption-srt-textarea",onInput:E},null,42,QV),[[e.vModelText,i.value]]),r.value!==null?(e.openBlock(),e.createElementBlock("p",{key:1,id:p.value,class:"caption-srt-panel__error",role:"alert","data-testid":"caption-srt-error"},e.toDisplayString(r.value),9,eN)):(e.openBlock(),e.createElementBlock("p",{key:2,id:h.value,class:"caption-srt-panel__status","aria-live":"polite","data-testid":"caption-srt-status"},e.toDisplayString(s.value??"Ready for caption import or export."),9,tN)),e.createElementVNode("div",{class:"caption-srt-panel__actions","aria-label":"SRT caption actions"},[e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button caption-srt-panel__button--primary","data-testid":"caption-srt-import",onClick:C}," Import "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-export",onClick:N}," Export "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-clear",onClick:S}," Clear ")]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",aN,[R[5]||(R[5]=e.createElementVNode("p",{class:"caption-srt-panel__cue-summary-title"},"Cue summary",-1)),g.value.length>0?(e.openBlock(),e.createElementBlock("ol",nN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,P=>(e.openBlock(),e.createElementBlock("li",{key:P.id,class:"caption-srt-panel__cue"},[e.createElementVNode("span",oN,e.toDisplayString(F(P.startTime))+"-"+e.toDisplayString(F(P.endTime)),1),e.createElementVNode("span",iN,e.toDisplayString(P.text),1)]))),128))])):(e.openBlock(),e.createElementBlock("p",rN," No captions loaded. "))]))],2))}}),Yc=Be(sN,[["__scopeId","data-v-1d5fdb3b"]]),lN=["aria-label"],dN={class:"draft-recovery-banner__header"},cN={class:"draft-recovery-banner__heading"},uN={class:"draft-recovery-banner__title"},mN={class:"draft-recovery-banner__summary","data-testid":"draft-recovery-summary"},pN={key:0,class:"draft-recovery-banner__list","data-testid":"draft-recovery-list"},fN={class:"draft-recovery-banner__record-copy"},hN={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},vN={class:"draft-recovery-banner__record-meta"},gN={"data-testid":"draft-recovery-record-updated"},yN={"data-testid":"draft-recovery-record-reason"},bN={class:"draft-recovery-banner__actions"},wN=["onClick"],kN=["onClick"],_N={key:1,class:"draft-recovery-banner__mobile-prompt","data-testid":"draft-recovery-mobile-prompt"},EN={class:"draft-recovery-banner__record-copy"},xN={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},SN={class:"draft-recovery-banner__record-meta"},CN={"data-testid":"draft-recovery-record-updated"},VN={"data-testid":"draft-recovery-record-reason"},NN={class:"draft-recovery-banner__actions draft-recovery-banner__actions--mobile"},TN={key:2,class:"draft-recovery-banner__empty","data-testid":"draft-recovery-empty"},MN=e.defineComponent({__name:"DraftRecoveryBanner",props:{records:{},surface:{},projectId:{},savedAt:{},maxAgeMs:{},now:{},maxDesktopItems:{default:3}},emits:["restore","dismiss"],setup(n,{emit:a}){const t=n,o=a,i={autosave:"Autosaved",manual:"Manual save","before-export":"Before export","before-close":"Before close"},r=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),s=e.computed(()=>{const C={};return t.projectId!==void 0&&(C.projectId=t.projectId),t.savedAt!==void 0&&(C.savedAt=t.savedAt),t.maxAgeMs!==void 0&&(C.maxAgeMs=t.maxAgeMs),t.now!==void 0&&(C.now=t.now),C}),l=e.computed(()=>{const C=t.maxDesktopItems;return!Number.isFinite(C)||C<1?1:Math.floor(C)}),d=e.computed(()=>t_(t.records,t.surface,s.value)),c=e.computed(()=>t.surface==="mobile"?d.value:d.value.slice(0,l.value)),u=e.computed(()=>t.surface==="mobile"),f=e.computed(()=>c.value.length>0),m=e.computed(()=>u.value?c.value[0]??null:null),p=e.computed(()=>u.value?"Unsaved video draft":"Unsaved video drafts"),h=e.computed(()=>f.value?u.value?"A newer draft is available on this device.":`${c.value.length} recoverable draft${c.value.length===1?"":"s"} found.`:"No recoverable video drafts"),v=C=>{var N;return((N=C.snapshot.metadata.title)==null?void 0:N.trim())||"Untitled video draft"},k=C=>{const N=C.snapshot.metadata.saveReason;return N===void 0?"Saved draft":i[N]},V=C=>{const N=new Date(C.snapshot.metadata.updatedAt);return Number.isFinite(N.getTime())?r.format(N):"Updated time unavailable"},B=C=>{o("restore",C)},_=C=>{C.length!==0&&o("dismiss",C)},g=C=>{_([C])},E=()=>{_(c.value)};return(C,N)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["draft-recovery-banner",{"draft-recovery-banner--mobile":u.value,"draft-recovery-banner--empty":!f.value}]),"data-testid":"draft-recovery-banner","aria-live":"polite","aria-label":p.value},[e.createElementVNode("header",dN,[e.createElementVNode("div",cN,[N[2]||(N[2]=e.createElementVNode("p",{class:"draft-recovery-banner__eyebrow"},"Draft recovery",-1)),e.createElementVNode("h2",uN,e.toDisplayString(p.value),1),e.createElementVNode("p",mN,e.toDisplayString(h.value),1)]),!u.value&&c.value.length>1?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"draft-recovery-banner__ghost-action","data-testid":"draft-recovery-dismiss-all",onClick:E}," Dismiss all ")):e.createCommentVNode("",!0)]),!u.value&&f.value?(e.openBlock(),e.createElementBlock("ul",pN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>(e.openBlock(),e.createElementBlock("li",{key:S.key,class:"draft-recovery-banner__record","data-testid":"draft-recovery-record"},[e.createElementVNode("div",fN,[e.createElementVNode("h3",hN,e.toDisplayString(v(S)),1),e.createElementVNode("p",vN,[e.createElementVNode("span",gN,"Updated "+e.toDisplayString(V(S)),1),N[3]||(N[3]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",yN,e.toDisplayString(k(S)),1)])]),e.createElementVNode("div",bN,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:A=>B(S)}," Restore ",8,wN),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:A=>g(S)}," Dismiss ",8,kN)])]))),128))])):m.value?(e.openBlock(),e.createElementBlock("article",_N,[e.createElementVNode("div",EN,[e.createElementVNode("h3",xN,e.toDisplayString(v(m.value)),1),e.createElementVNode("p",SN,[e.createElementVNode("span",CN,"Updated "+e.toDisplayString(V(m.value)),1),N[4]||(N[4]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",VN,e.toDisplayString(k(m.value)),1)])]),e.createElementVNode("div",NN,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:N[0]||(N[0]=S=>B(m.value))}," Restore "),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:N[1]||(N[1]=S=>g(m.value))}," Dismiss ")])])):(e.openBlock(),e.createElementBlock("p",TN," No recoverable drafts "))],10,lN))}}),Qc=Be(MN,[["__scopeId","data-v-3ed3c273"]]),BN={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},IN=["aria-selected","data-testid","onClick"],FN=["aria-labelledby"],$N={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},DN=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(n,{emit:a}){const t=n,o=a,i=e.computed(()=>t.tabs.filter(s=>s.enabled)),r=s=>{s!==t.activeTab&&o("update:activeTab",s)};return(s,l)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["inspector-panel",{"inspector-panel--compact":s.compact}]),"data-testid":"v2-inspector-panel"},[e.createElementVNode("nav",BN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("button",{key:d.id,type:"button",role:"tab",class:e.normalizeClass(["inspector-tab",{"is-active":s.activeTab===d.id}]),"aria-selected":s.activeTab===d.id?"true":"false","data-testid":`v2-inspector-tab-${d.id}`,onClick:c=>r(d.id)},e.toDisplayString(d.label),11,IN))),128))]),e.createElementVNode("div",{class:"inspector-body",role:"tabpanel","aria-labelledby":`v2-inspector-tab-${s.activeTab}`},[e.renderSlot(s.$slots,s.activeTab,{},()=>[e.createElementVNode("div",$N,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,FN)],2))}}),RN=Be(DN,[["__scopeId","data-v-7f5b0e50"]]),AN={class:"keyframe-preset-panel__header"},LN={class:"keyframe-preset-panel__target","data-testid":"keyframe-preset-target"},PN={key:0,class:"keyframe-preset-panel__notice","data-testid":"keyframe-preset-invalid-duration"},ON={class:"keyframe-preset-panel__grid","data-testid":"keyframe-preset-buttons"},UN=["disabled","aria-disabled","data-testid","onClick"],zN={class:"keyframe-preset-panel__preset-label"},jN={class:"keyframe-preset-panel__preset-summary"},WN={key:1,class:"keyframe-preset-panel__compact-summary","data-testid":"keyframe-preset-mobile-summary"},ZN={key:2,class:"keyframe-preset-panel__desktop-summary","data-testid":"keyframe-preset-desktop-summary"},HN={class:"keyframe-preset-panel__summary-list"},XN=["data-testid"],GN={key:0,class:"keyframe-preset-panel__summary-empty","data-testid":"keyframe-preset-summary-empty"},JN=e.defineComponent({__name:"KeyframePresetPanel",props:{duration:{},target:{},deviceClass:{}},emits:["apply-preset"],setup(n,{emit:a}){const t=n,o=a,i={all:"All targets",opacity:"Opacity",scale:"Scale",x:"Pan X",y:"Pan Y",rotation:"Rotation",audioVolume:"Audio"},r=[{id:"fade-in",label:"Fade in",target:"opacity",summary:"Opacity 0 -> 100%",create:C=>{const N=Y_({duration:E(C)});return V("fade-in","Fade in",N,C)}},{id:"fade-out",label:"Fade out",target:"opacity",summary:"Opacity 100 -> 0%",create:C=>{const N=E(C),S=Q_({startTime:C-N,duration:N});return V("fade-out","Fade out",S,C)}},{id:"push-in",label:"Push in",target:"scale",summary:"Scale 100 -> 108%",create:C=>{const N=eE({duration:C,fromScale:1,toScale:1.08,easing:"ease-out"});return V("push-in","Push in",N,C)}},{id:"push-out",label:"Push out",target:"scale",summary:"Scale 108 -> 100%",create:C=>_({id:"push-out",label:"Push out",target:"scale",duration:C,startValue:1.08,endValue:1,easing:"ease-in"})},{id:"pan-x-left",label:"Pan left",target:"x",summary:"X 55 -> 45%",create:C=>_({id:"pan-x-left",label:"Pan left",target:"x",duration:C,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-x-right",label:"Pan right",target:"x",summary:"X 45 -> 55%",create:C=>_({id:"pan-x-right",label:"Pan right",target:"x",duration:C,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"pan-y-up",label:"Pan up",target:"y",summary:"Y 55 -> 45%",create:C=>_({id:"pan-y-up",label:"Pan up",target:"y",duration:C,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-y-down",label:"Pan down",target:"y",summary:"Y 45 -> 55%",create:C=>_({id:"pan-y-down",label:"Pan down",target:"y",duration:C,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",summary:"Volume 0 -> 100%",create:C=>_({id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",duration:E(C),startValue:0,endValue:1,easing:"ease-out"})},{id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",summary:"Volume 100 -> 0%",create:C=>{const N=E(C);return _({id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",duration:N,startTime:C-N,startValue:1,endValue:0,easing:"ease-in"})}}],s=e.computed(()=>J_(t.deviceClass)),l=e.computed(()=>s.value.platform==="mobile"),d=e.computed(()=>Number.isFinite(t.duration)&&t.duration>0),c=e.computed(()=>t.target==="all"?r:r.filter(C=>C.target===t.target)),u=e.computed(()=>d.value?c.value.map(C=>({definition:C,automation:C.create(t.duration)})):[]),f=e.computed(()=>i[t.target]),m=e.computed(()=>{const C=c.value.length,N=C===1?"preset":"presets";return d.value?`${C} ${N} - ${h(t.duration)} clip.`:`${C} ${N} available when duration is set.`}),p=C=>{if(!d.value)return;const N=C.create(t.duration);o("apply-preset",{presetId:N.id,target:N.target,keyframes:N.keyframes,automation:N})},h=C=>{const N=Math.round(C*100)/100;return`${N.toFixed(N%1===0?0:2)}s`},v=(C,N)=>C==="opacity"||C==="audioVolume"?`${Math.round(N*100)}%`:C==="scale"?`${Math.round(N*100)}%`:C==="x"||C==="y"?`${Math.round(N*100)}%`:`${Math.round(N*100)/100}`,k=C=>{const[N,S]=C.keyframes;return`${h(N.time)} ${v(C.target,N.value)} -> ${h(S.time)} ${v(C.target,S.value)}`};function V(C,N,S,A){return B({id:C,label:N,target:S.target,duration:A,keyframes:S.keyframes})}function B(C){const N=q_(C.keyframes,{target:C.target,minTime:0,maxTime:C.duration}),S=N[0],A=N[1];if(N.length!==2||S===void 0||A===void 0)throw new Error("Keyframe preset panel presets must generate exactly two keyframes.");return{id:C.id,label:C.label,target:C.target,editingMode:"preset-only",keyframes:[S,A]}}function _(C){const N=C.startTime??0,S=[g(`${C.id}:start`,C.target,N,C.startValue,"linear"),g(`${C.id}:end`,C.target,N+C.duration,C.endValue,C.easing)];return B({id:C.id,label:C.label,target:C.target,duration:N+C.duration,keyframes:S})}function g(C,N,S,A,Z){return{id:C,target:N,time:S,value:A,easing:Z}}function E(C){return Math.min(C,1)}return(C,N)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["keyframe-preset-panel",{"keyframe-preset-panel--mobile":l.value}]),"data-testid":"keyframe-preset-panel","aria-label":"Keyframe presets"},[e.createElementVNode("header",AN,[N[0]||(N[0]=e.createElementVNode("div",{class:"keyframe-preset-panel__heading"},[e.createElementVNode("p",{class:"keyframe-preset-panel__eyebrow"},"Presets"),e.createElementVNode("h3",{class:"keyframe-preset-panel__title"},"Keyframe automation")],-1)),e.createElementVNode("span",LN,e.toDisplayString(f.value),1)]),d.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",PN," Set a valid clip duration to apply automation presets. ")),e.createElementVNode("div",ON,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>(e.openBlock(),e.createElementBlock("button",{key:S.id,type:"button",class:"keyframe-preset-panel__preset",disabled:!d.value,"aria-disabled":d.value?void 0:"true","data-testid":`keyframe-preset-button-${S.id}`,onClick:A=>p(S)},[e.createElementVNode("span",zN,e.toDisplayString(S.label),1),e.createElementVNode("span",jN,e.toDisplayString(S.summary),1)],8,UN))),128))]),l.value?(e.openBlock(),e.createElementBlock("p",WN,e.toDisplayString(m.value),1)):(e.openBlock(),e.createElementBlock("div",ZN,[N[1]||(N[1]=e.createElementVNode("p",{class:"keyframe-preset-panel__summary-title"},"Generated keyframes",-1)),e.createElementVNode("ul",HN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,S=>(e.openBlock(),e.createElementBlock("li",{key:S.definition.id,class:"keyframe-preset-panel__summary-row","data-testid":`keyframe-preset-summary-${S.definition.id}`},[e.createElementVNode("span",null,e.toDisplayString(S.definition.label),1),e.createElementVNode("span",null,e.toDisplayString(k(S.automation)),1)],8,XN))),128))]),u.value.length===0?(e.openBlock(),e.createElementBlock("p",GN," No generated keyframes until duration is valid. ")):e.createCommentVNode("",!0)]))],2))}}),eu=Be(JN,[["__scopeId","data-v-79615683"]]),KN={class:"mobile-clip-summary__main"},qN={class:"mobile-clip-summary__title","data-testid":"v2-mobile-clip-label"},YN={class:"mobile-clip-summary__stats","aria-label":"Selected clip timing"},QN={class:"mobile-clip-summary__stat"},eT={"data-testid":"v2-mobile-clip-start"},tT={class:"mobile-clip-summary__stat"},aT={"data-testid":"v2-mobile-clip-end"},nT={class:"mobile-clip-summary__stat"},oT={"data-testid":"v2-mobile-clip-duration"},iT={key:1,class:"mobile-clip-summary__empty","data-testid":"v2-mobile-no-clip"},rT=e.defineComponent({__name:"MobileClipSummary",props:{selectedClip:{}},emits:["open-actions"],setup(n,{emit:a}){const t=n,o=a,i=f=>f===void 0||!Number.isFinite(f)?null:f,r=e.computed(()=>{var f,m,p;return((m=(f=t.selectedClip)==null?void 0:f.label)==null?void 0:m.trim())||((p=t.selectedClip)==null?void 0:p.id)||""}),s=e.computed(()=>t.selectedClip?i(t.selectedClip.timelineStart)??i(t.selectedClip.startTime):null),l=e.computed(()=>t.selectedClip?i(t.selectedClip.timelineEnd)??i(t.selectedClip.endTime):null),d=e.computed(()=>{const f=s.value,m=l.value;return f!==null&&m!==null?Math.max(0,m-f):t.selectedClip?i(t.selectedClip.duration):null}),c=f=>{if(f===null)return"--";const m=Math.round(f*100)/100;return`${m.toFixed(m%1===0?0:2)}s`},u=()=>{t.selectedClip&&o("open-actions",t.selectedClip.id)};return(f,m)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["mobile-clip-summary",{"mobile-clip-summary--empty":!f.selectedClip}]),"data-testid":"v2-mobile-clip-summary","aria-live":"polite"},[f.selectedClip?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",KN,[m[0]||(m[0]=e.createElementVNode("p",{class:"mobile-clip-summary__eyebrow"},"Selected clip",-1)),e.createElementVNode("h2",qN,e.toDisplayString(r.value),1)]),e.createElementVNode("dl",YN,[e.createElementVNode("div",QN,[m[1]||(m[1]=e.createElementVNode("dt",null,"Start",-1)),e.createElementVNode("dd",eT,e.toDisplayString(c(s.value)),1)]),e.createElementVNode("div",tT,[m[2]||(m[2]=e.createElementVNode("dt",null,"End",-1)),e.createElementVNode("dd",aT,e.toDisplayString(c(l.value)),1)]),e.createElementVNode("div",nT,[m[3]||(m[3]=e.createElementVNode("dt",null,"Duration",-1)),e.createElementVNode("dd",oT,e.toDisplayString(c(d.value)),1)])]),e.createElementVNode("button",{type:"button",class:"mobile-clip-summary__actions","aria-label":"Open selected clip actions","data-testid":"v2-mobile-clip-actions",onClick:u}," Actions ")],64)):(e.openBlock(),e.createElementBlock("p",iT," No clip selected "))],2))}}),sT=Be(rT,[["__scopeId","data-v-433c7812"]]),lT=["aria-label"],dT=["aria-pressed","data-testid","onClick"],cT={class:"mobile-tool-picker__label"},uT=e.defineComponent({__name:"MobileToolPicker",props:{modelValue:{},ariaLabel:{default:"Mobile editor tools"}},emits:["update:modelValue"],setup(n,{emit:a}){const t=[{id:"look",label:"Look"},{id:"trim",label:"Trim"},{id:"text",label:"Text"},{id:"audio",label:"Audio"},{id:"export",label:"Export"},{id:"more",label:"More"}],o=n,i=a,r=s=>{s!==o.modelValue&&i("update:modelValue",s)};return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"mobile-tool-picker",role:"group","aria-label":s.ariaLabel,"data-testid":"v2-mobile-tool-picker"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,d=>e.createElementVNode("button",{key:d.id,type:"button",class:e.normalizeClass(["mobile-tool-picker__button",{"is-active":s.modelValue===d.id}]),"aria-pressed":s.modelValue===d.id?"true":"false","data-testid":`v2-mobile-tool-${d.id}`,onClick:c=>r(d.id)},[e.createElementVNode("span",cT,e.toDisplayString(d.label),1)],10,dT)),64))],8,lT))}}),mT=Be(uT,[["__scopeId","data-v-ec597c70"]]),pT=["aria-label","data-snap"],fT=["aria-expanded"],hT={class:"drawer-header"},vT={class:"drawer-body"},gT=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(n,{expose:a,emit:t}){const o=["collapsed","half","full"],i=n,r=t,s=e.ref(null),l=e.ref(null),d=e.ref(i.initialSnap);let c=!1,u=!1,f=null,m=0,p=0,h=0;const v=A=>{const Z=h||(typeof window<"u"?window.innerHeight:600);switch(A){case"collapsed":return 80;case"half":return Math.round(Z*.45);case"full":return Math.round(Z*.85)}},k=(A,{animate:Z=!0}={})=>{var b;if(!s.value)return;const x=d.value;d.value=A;const F=typeof window<"u"&&((b=window.matchMedia)==null?void 0:b.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=Z&&!F?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${v(A)}px`,A!==x&&r("snap-change",A,x)},V=A=>{let Z=o[0],x=1/0;for(const F of o){const b=Math.abs(v(F)-A);b<x&&(x=b,Z=F)}return Z},B=()=>{const A=o.indexOf(d.value);k(o[(A+1)%o.length])},_=A=>{if(u){u=!1,A.preventDefault();return}B()},g=A=>{var Z,x,F;if(A.button===0){c=!0,u=!1,f=A.pointerId,m=A.clientY,p=((Z=s.value)==null?void 0:Z.offsetHeight)??0;try{(F=(x=l.value)==null?void 0:x.setPointerCapture)==null||F.call(x,A.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},E=A=>{if(!c||A.pointerId!==f)return;const Z=A.clientY-m,x=p-Z,F=v("collapsed"),b=v("full"),R=Math.max(F,Math.min(b,x));s.value&&(s.value.style.height=`${R}px`),Math.abs(Z)>4&&(u=!0),A.preventDefault()},C=A=>{var x,F,b;if(!c)return;c=!1;try{(F=(x=l.value)==null?void 0:x.releasePointerCapture)==null||F.call(x,A.pointerId)}catch{}f=null;const Z=((b=s.value)==null?void 0:b.offsetHeight)??0;k(V(Z))},N=(A,Z={})=>{o.includes(A)&&k(A,{animate:Z.animate!==!1})},S=A=>{h=Math.max(0,Number(A)||0),k(d.value,{animate:!1})};return e.watch(()=>i.containerHeight,A=>{A>0&&S(A)}),e.onMounted(()=>{i.containerHeight>0&&(h=i.containerHeight),k(d.value,{animate:!1})}),e.onBeforeUnmount(()=>{c=!1,f=null}),a({snapTo:N,updateContainerHeight:S,snap:d}),(A,Z)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":A.ariaLabel,"data-snap":d.value,"data-testid":"v2-video-bottom-drawer"},[e.createElementVNode("button",{ref_key:"handleEl",ref:l,type:"button",class:"drawer-handle","aria-label":"Drag to resize editor drawer","aria-expanded":d.value==="full"?"true":"false","data-testid":"v2-video-drawer-handle",onClick:_,onPointerdown:g,onPointermove:E,onPointerup:C,onPointercancel:C},[...Z[0]||(Z[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,fT),e.createElementVNode("div",hT,[e.renderSlot(A.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",vT,[e.renderSlot(A.$slots,"default",{},void 0,!0)])],8,pT))}}),yT=Be(gT,[["__scopeId","data-v-4ebedbf7"]]),bT=new Set(["INPUT","TEXTAREA","SELECT"]);function wT(n){return n instanceof HTMLElement?!!(bT.has(n.tagName)||n.isContentEditable):!1}function kT(n,a={}){const t=o=>{var l,d,c,u,f,m,p,h,v,k,V,B,_,g,E,C,N;if(a.enabled&&a.enabled()===!1||wT(o.target))return;const i=o.ctrlKey||o.metaKey,r=o.shiftKey,s=o.key;if(i&&(s==="z"||s==="Z")){r?(l=n.redo)==null||l.call(n):(d=n.undo)==null||d.call(n),o.preventDefault();return}if(i&&(s==="s"||s==="S")){(c=n.save)==null||c.call(n),o.preventDefault();return}if(i&&(s==="e"||s==="E")){(u=n.exportNow)==null||u.call(n),o.preventDefault();return}switch(s){case" ":case"Spacebar":(f=n.playPause)==null||f.call(n),o.preventDefault();return;case"ArrowLeft":r?(m=n.secondBackward)==null||m.call(n):(p=n.frameBackward)==null||p.call(n),o.preventDefault();return;case"ArrowRight":r?(h=n.secondForward)==null||h.call(n):(v=n.frameForward)==null||v.call(n),o.preventDefault();return;case"Home":(k=n.skipToStart)==null||k.call(n),o.preventDefault();return;case"End":(V=n.skipToEnd)==null||V.call(n),o.preventDefault();return;case"[":(B=n.prevClip)==null||B.call(n),o.preventDefault();return;case"]":(_=n.nextClip)==null||_.call(n),o.preventDefault();return;case"s":case"S":i||((g=n.splitAtPlayhead)==null||g.call(n),o.preventDefault());return;case"Delete":case"Backspace":r?(E=n.rippleDeleteSelected)==null||E.call(n):(C=n.deleteSelected)==null||C.call(n),o.preventDefault();return;case"?":(N=n.showShortcutsOverlay)==null||N.call(n),o.preventDefault();return}};e.onMounted(()=>{window.addEventListener("keydown",t)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",t)})}const Sp=["video/mp4","video/webm","video/quicktime"],Cp=["image/png","image/jpeg","image/jpg","image/webp"],_T=["audio/mpeg","audio/mp3","audio/aac","audio/wav","audio/x-wav","audio/wave"],ET=new Set([...Sp,...Cp,..._T]),xT=2*1024*1024*1024,ST=60*60;function tu(n,a){const t=n.type.toLowerCase();return ET.has(t)?n.size>xT?{ok:!1,reason:"oversize",message:`File is too large (${(n.size/(1024*1024*1024)).toFixed(2)} GiB). Limit is 2 GiB.`}:typeof a=="number"&&Number.isFinite(a)&&a>ST?{ok:!1,reason:"duration_exceeded",message:`Clip is too long (${Math.round(a)}s). Limit is 1 hour.`}:{ok:!0,kind:Sp.includes(t)?"video":Cp.includes(t)?"image":"audio"}:{ok:!1,reason:"unsupported_mime",message:`Unsupported file type: ${t||"unknown"}.`}}const CT="mediables-asset-blobs",Ua="blobs",VT=1;class NT{constructor(){this.dbPromise=null}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((a,t)=>{if(typeof indexedDB>"u"){t(new Error("IndexedDB is not available in this environment."));return}const o=indexedDB.open(CT,VT);o.onupgradeneeded=()=>{const i=o.result;i.objectStoreNames.contains(Ua)||i.createObjectStore(Ua)},o.onsuccess=()=>{a(o.result)},o.onerror=()=>{t(o.error??new Error("Failed to open IndexedDB."))}}),this.dbPromise)}async put(a,t){const o=await this.openDb();await new Promise((i,r)=>{const d=o.transaction(Ua,"readwrite").objectStore(Ua).put(t,a);d.onsuccess=()=>{i()},d.onerror=()=>{r(d.error??new Error("Failed to write blob."))}})}async get(a){const t=await this.openDb();return new Promise((o,i)=>{const l=t.transaction(Ua,"readonly").objectStore(Ua).get(a);l.onsuccess=()=>{const d=l.result;d==null?o(null):d instanceof Blob?o(d):o(null)},l.onerror=()=>{i(l.error??new Error("Failed to read blob."))}})}async delete(a){const t=await this.openDb();await new Promise((o,i)=>{const l=t.transaction(Ua,"readwrite").objectStore(Ua).delete(a);l.onsuccess=()=>{o()},l.onerror=()=>{i(l.error??new Error("Failed to delete blob."))}})}async clear(){const a=await this.openDb();await new Promise((t,o)=>{const s=a.transaction(Ua,"readwrite").objectStore(Ua).clear();s.onsuccess=()=>{t()},s.onerror=()=>{o(s.error??new Error("Failed to clear cache."))}})}}let Zs=null;function TT(){return Zs===null&&(Zs=new NT),Zs}class MT{constructor(){this.store=new Map}async put(a,t){this.store.set(a,t)}async get(a){return this.store.get(a)??null}async delete(a){this.store.delete(a)}async clear(){this.store.clear()}}function BT(){return`asset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}async function IT(n,a){if(a<=0)return{};if(typeof URL>"u"||typeof document>"u")return{};const t=URL.createObjectURL(n),o=async()=>n.type.startsWith("video/")?new Promise(i=>{const r=document.createElement("video");r.preload="metadata",r.src=t,r.onloadedmetadata=()=>{i({durationSeconds:r.duration,width:r.videoWidth,height:r.videoHeight})},r.onerror=()=>{i({})}}):n.type.startsWith("audio/")?new Promise(i=>{const r=document.createElement("audio");r.preload="metadata",r.src=t,r.onloadedmetadata=()=>{i({durationSeconds:r.duration})},r.onerror=()=>{i({})}}):n.type.startsWith("image/")?new Promise(i=>{const r=new Image;r.src=t,r.onload=()=>{i({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{i({})}}):{};try{return await Promise.race([o(),new Promise(i=>{setTimeout(()=>i({}),a)})])}finally{URL.revokeObjectURL(t)}}function FT(n){const a=e.reactive(new Map),t=n.blobCache??$T();async function o(u,f){try{await t.put(u,f)}catch{}}async function i(u){try{await t.delete(u)}catch{}}async function r(u,f,m){var p,h,v;try{f.status="uploading",f.uploadProgress=0,a.set(f.assetId,f);const k=await n.uploader.upload({file:u},({assetId:V,progress:B,status:_})=>{if(V!==f.assetId)return;const g=a.get(V);g&&(g.uploadProgress=B,g.status=_,a.set(V,g))});return a.set(f.assetId,k),k.status==="ready"?(i(f.assetId),(p=n.onReady)==null||p.call(n,k)):k.status==="failed"&&((h=n.onFailure)==null||h.call(n,k)),{ok:!0,record:k}}catch(k){const V=k instanceof Error?k.message:"Upload failed.",B={...f,status:"failed",failureMessage:V};return a.set(f.assetId,B),(v=n.onFailure)==null||v.call(n,B),{ok:!1,reason:"upload",message:V}}}const s=n.probeTimeoutMs??1500;async function l(u){const f=await IT(u,s),m=tu(u,f.durationSeconds);if(!m.ok)return{ok:!1,reason:"preflight",message:m.message};const p=BT(),h={assetId:p,filename:u.name,mime:u.type,sizeBytes:u.size,status:"local-selected"};return f.durationSeconds!==void 0&&(h.durationSeconds=f.durationSeconds),f.width!==void 0&&(h.width=f.width),f.height!==void 0&&(h.height=f.height),a.set(p,h),await o(p,u),r(u,h)}async function d(u){const f=a.get(u);if(!f)return{ok:!1,reason:"unknown",message:"Unknown asset."};const m=await t.get(u);if(!m)return{ok:!1,reason:"unknown",message:"Original file is no longer cached."};const p=m instanceof File?m:new File([m],f.filename,{type:f.mime}),h=tu(p,f.durationSeconds);return h.ok?r(p,f):{ok:!1,reason:"preflight",message:h.message}}async function c(u){a.delete(u),await i(u)}return{records:e.readonly(a),importFile:l,retry:d,remove:c}}function $T(){return typeof indexedDB<"u"?TT():new MT}const DT={class:"v2-toolbar-group"},RT=["aria-label"],AT=["disabled"],LT={class:"v2-toolbar-group"},PT={class:"v2-toolbar-fit"},OT=["disabled"],UT=["aria-label","title","disabled"],zT={class:"v2-assets"},jT={key:0,class:"v2-asset-rail-status","data-testid":"v2-asset-rail-status",role:"status"},WT={class:"v2-preview-host"},ZT={class:"v2-timeline-topbar"},HT={class:"v2-timeline-heading"},XT={class:"v2-timeline-meta","data-testid":"v2-timeline-meta"},GT={class:"v2-timeline-zoom"},JT=["value"],KT={class:"v2-timeline-zoom-readout"},qT={key:0,class:"v2-timeline-track-actions"},YT={key:0,class:"v2-timeline-track-target"},QT=["value"],e4=["value"],t4=["aria-pressed"],a4={key:0,class:"v2-editor-status","data-testid":"v2-editor-status",role:"status","aria-live":"polite"},n4={key:1,class:"v2-timeline-empty","data-testid":"v2-timeline-empty"},o4={key:1,class:"v2-empty-state"},i4={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},r4={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},s4={key:1,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-look"},l4={class:"v2-mobile-panel-section"},d4={class:"v2-mobile-panel-section v2-mobile-panel-section--compact"},c4={key:1,class:"v2-empty-state"},u4={key:2,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-trim"},m4={key:3,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-text"},p4={key:4,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-audio"},f4={key:5,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-export"},h4={key:0,class:"v2-export-status"},v4={key:1,class:"v2-export-status"},g4={key:6,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-more"},y4={class:"v2-mobile-secondary-controls"},b4={class:"v2-mobile-secondary-field"},w4=["aria-pressed"],k4=["disabled"],_4=["disabled"],E4={key:0,class:"v2-mobile-secondary-details","data-testid":"v2-mobile-transitions"},x4={class:"v2-mobile-secondary-details","data-testid":"v2-mobile-keyframes"},S4={class:"v2-shortcuts-overlay__panel"},C4={class:"v2-shortcuts-overlay__header"},V4=e.defineComponent({__name:"VideoEditorV2",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},assetUploader:{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(n,{expose:a,emit:t}){var Oo,Oi,Ui,zi;const o=n,i=t,r=e.computed(()=>{var K;const y=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";if(y!=="")return y;const T=(K=o.media)==null?void 0:K.uuid;return typeof T=="string"&&T.trim()!==""?T.trim():`temp-${Date.now()}`}),s=Xm(r.value,o.initialRecipe,o.media),l=Km(),d=e.ref("filters"),c=e.ref("look"),u=e.computed(()=>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}),f=e.computed(()=>{const y=o.featureFlags??{},T=["filters","adjustments","text","transitions","audio","export"],K={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return T.map(fe=>({id:fe,label:K[fe],enabled:typeof y[fe]=="boolean"?y[fe]:u.value[fe]}))}),m=y=>f.value.some(T=>T.id===y&&T.enabled),p={look:"filters",text:"text",audio:"audio",export:"export"},h=e.computed(()=>{var y;return((y=o.featureFlags)==null?void 0:y.transitions)===!0});e.watch(c,y=>{if(y==="trim"||y==="more")return;const T=p[y];m(T)&&(d.value=T)});const v=e.ref(!1),k=e.computed(()=>d.value),V=e.computed(()=>k.value==="filters"||v.value),B=e.computed(()=>k.value!=="filters"&&!v.value),_=e.ref(null),g=e.computed(()=>_.value),E=["contain","cover","none"],C=y=>typeof y=="string"&&E.includes(y),N=y=>{var K;const T=(K=y==null?void 0:y.metadata)==null?void 0:K.fit_mode;return C(T)?T:null},S=e.ref(N(o.initialRecipe)??"contain"),A=e.ref("");e.watch(()=>{var y,T;return{file:(y=o.media)==null?void 0:y.file,url:(T=o.media)==null?void 0:T.url}},(y,T,K)=>{var Fe,Re;const fe=A.value;K(()=>{fe&&fe.startsWith("blob:")&&URL.revokeObjectURL(fe)}),(Fe=o.media)!=null&&Fe.file?A.value=URL.createObjectURL(o.media.file):(Re=o.media)!=null&&Re.url?A.value=o.media.url:A.value=""},{immediate:!0});const Z=e.computed(()=>A.value),x=e.computed(()=>l.activeFilters.value),F=e.computed(()=>s.playheadPosition.value),b=wm({forcePixiPreview:v,getPreviewRef:()=>g.value,getSourceUrl:()=>A.value,setPlaying:s.setPlaying}),R=e.computed(()=>{if(!o.media)return null;const{file:y,...T}=o.media;return{...T,url:A.value}}),P=e.computed(()=>{var T;const y=(T=o.media)==null?void 0:T.url;return!!(y&&/^https?:/i.test(y))}),O=e.ref(0),U=e.computed(()=>{var T;if(s.totalDuration.value>0)return s.totalDuration.value;if(O.value>0)return O.value;const y=Number((T=o.media)==null?void 0:T.duration);return Number.isFinite(y)&&y>0?y:0}),M=y=>{!Number.isFinite(y)||y<=0||(O.value=y,s.updateSourceDuration(y))},I=y=>{y&&typeof y.time=="number"&&Number.isFinite(y.time)&&s.seekTo(y.time)},z=y=>{Number.isFinite(y)&&s.seekTo(y)},X=y=>{s.setPlaying(y)},le=e.computed(()=>l.videoCompatibleFilters.value.map(T=>{var fe;const K=[];if(T.controls&&T.controls.length>0)for(const Fe of T.controls){const Re=Fe.type;if(Re==="button"||Re==="text"||Re==="range")continue;const qe={id:Fe.property||Fe.id,label:Fe.label||Fe.id,type:Re,default:Fe.default??(Re==="toggle"?!1:Re==="color"?"#ffffff":0)};Re==="slider"&&(qe.min=Fe.min??0,qe.max=Fe.max??1,qe.step=Fe.step??.01),Re==="select"&&Fe.options&&(qe.options=Fe.options),K.push(qe)}else if(T.paramRanges){const Fe=Object.entries(T.paramRanges);for(const[Re,qe]of Fe){const ut=Re.replace(/[-_]/g," ").replace(/\b\w/g,io=>io.toUpperCase()),$t=(fe=T.defaultParams)==null?void 0:fe[Re],na=(qe.min+qe.max)/2;K.push({id:Re,label:ut,min:qe.min,max:qe.max,step:qe.step??.01,default:typeof $t=="number"?$t:na})}}return{id:T.id,name:T.name,category:T.category,params:K}})),ve=e.computed(()=>{const y=new Map;return l.activeFilters.value.forEach(T=>y.set(T.filterId,T)),y}),ie=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const y=o.media;return(y==null?void 0:y.thumbnail_url)??(y==null?void 0:y.url)}),ne=e.shallowRef(null),L=e.ref(null),D=e.ref(null),j=e.ref(null),q=e.ref(!1),te=new Map,ce=(y,T)=>{const K={id:y.id??`text-overlay-recipe-${T}`,text:y.content};return y.fontFamily!==void 0&&(K.fontFamily=y.fontFamily),y.fontSize!==void 0&&(K.fontSize=y.fontSize),y.fontWeight!==void 0&&(K.fontWeight=y.fontWeight),y.color!==void 0&&(K.color=y.color),y.position!==void 0&&(K.position=y.position),y.startTime!==void 0&&(K.startTime=y.startTime),y.duration!==void 0&&(K.duration=y.duration),y.animation!==void 0&&(K.animation=y.animation),y.textAlign!==void 0&&(K.textAlign=y.textAlign),y.textBaseline!==void 0&&(K.textBaseline=y.textBaseline),K},me=y=>{const T={id:y.id,content:y.text};return y.fontFamily!==void 0&&(T.fontFamily=y.fontFamily),y.fontSize!==void 0&&(T.fontSize=y.fontSize),y.fontWeight!==void 0&&(T.fontWeight=y.fontWeight),y.color!==void 0&&(T.color=y.color),y.position!==void 0&&(T.position=y.position),y.startTime!==void 0&&(T.startTime=y.startTime),y.duration!==void 0&&(T.duration=y.duration),y.animation!==void 0&&(T.animation=y.animation),y.textAlign!==void 0&&(T.textAlign=y.textAlign),y.textBaseline!==void 0&&(T.textBaseline=y.textBaseline),T},ge=(y,T)=>{const K={id:y.id??`audio-track-recipe-${T}`,source:y.source};return y.volume!==void 0&&(K.volume=y.volume),y.startTime!==void 0&&(K.startTime=y.startTime),y.duration!==void 0&&(K.duration=y.duration),y.fadeIn!==void 0&&(K.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(K.fadeOut=y.fadeOut),y.loop!==void 0&&(K.loop=y.loop),y.name!==void 0&&(K.name=y.name),K},Te=y=>{if(typeof y.source!="string")return null;const T={id:y.id,source:y.source};return y.volume!==void 0&&(T.volume=y.volume),y.startTime!==void 0&&(T.startTime=y.startTime),y.duration!==void 0&&(T.duration=y.duration),y.fadeIn!==void 0&&(T.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(T.fadeOut=y.fadeOut),y.loop!==void 0&&(T.loop=y.loop),y.name!==void 0&&(T.name=y.name),T},he=y=>{const T={id:y.id,source:typeof y.source=="string"?y.source:""};return y.volume!==void 0&&(T.volume=y.volume),y.startTime!==void 0&&(T.startTime=y.startTime),y.duration!==void 0&&(T.duration=y.duration),y.fadeIn!==void 0&&(T.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(T.fadeOut=y.fadeOut),y.loop!==void 0&&(T.loop=y.loop),y.name!==void 0&&(T.name=y.name),y.muted!==void 0&&(T.muted=y.muted),y.solo!==void 0&&(T.solo=y.solo),y.pan!==void 0&&(T.pan=y.pan),y.faderDb!==void 0&&(T.faderDb=y.faderDb),T},ye=y=>({...y,segments:y.segments.map(T=>{const K={...T};return T.words&&(K.words=T.words.map(fe=>({...fe}))),K})}),Se=e.ref((((Oo=o.initialRecipe)==null?void 0:Oo.textOverlays)??[]).map(ce)),Ne=y=>{switch(y){case"crossfade":return"cross-fade";case"zoom":return"zoom-in";case"cut":return"fade";default:return y}},at=y=>{switch(y){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}},et=y=>{switch(y){case"cross-fade":case"dissolve":return"crossfade";case"zoom-in":case"zoom-out":return"zoom";case"dip-to-white":return"fade";case"wipe-up":case"wipe-down":return"wipe-left";case"slide-up":case"slide-down":return"slide-left";default:return y}},gt=y=>{switch(y){case"easeIn":return"ease-in";case"easeOut":return"ease-out";case"easeInOut":return"ease-in-out";case"linear":default:return"linear"}},Ct=y=>({id:y.id,type:Ne(y.type),duration:y.duration,easing:at(y.easing),name:y.type,fromClipId:y.fromClipId,toClipId:y.toClipId,cutTime:y.cutTime??0}),yt=y=>({id:y.id,type:et(y.type),fromClipId:y.fromClipId,toClipId:y.toClipId,duration:y.duration,easing:gt(y.easing),cutTime:y.cutTime}),mt=e.ref((((Oi=o.initialRecipe)==null?void 0:Oi.transitions)??[]).map(Ct)),ot=e.ref((((Ui=o.initialRecipe)==null?void 0:Ui.audioTracks)??[]).map(ge)),kt=e.ref(1),xt=e.ref(!1),we=e.ref((((zi=o.initialRecipe)==null?void 0:zi.captionTracks)??[]).map(ye)),Ce=e.ref([]),$e=e.ref(null),Ye=e.computed(()=>r.value),Xe=e.computed(()=>Ce.value),ze=e.computed(()=>we.value[0]??null),_t=e.computed(()=>{const y=s.selectedClip.value??s.timelineClips.value[0];return y?Math.max(0,y.timelineEnd-y.timelineStart):U.value}),ct=e.computed(()=>w_(ot.value.map(he),{master:{volume:kt.value,muted:xt.value}})),Zt=e.computed(()=>{const y=[...s.timelineClips.value].sort((qe,ut)=>qe.timelineStart-ut.timelineStart),T=s.selectedClip.value??y[0];if(!T)return[];const K=y.findIndex(qe=>qe.id===T.id);if(K===-1)return[];const fe=qe=>(qe.trackId??null)===(T.trackId??null),Fe=y.slice(K+1).find(fe);if(Fe)return[T,Fe];const Re=[...y.slice(0,K)].reverse().find(fe);return Re?[Re,T]:[]}),ta=y=>{ne.value=y,y!=null&&y.composition&&(D.value=new qm(y.composition),j.value=new Ym(y.composition));try{te.size&&ne.value&&(te.forEach((T,K)=>{ne.value.setClipFilters(K,T)}),te.clear(),ne.value.composition.computeFrame())}catch{}},aa=y=>{ne.value?ne.value.setClipFilters(y,l.activeFilters.value):te.set(y,[...l.activeFilters.value])},ia=y=>{var K,fe;const T=((K=s.selectedClip.value)==null?void 0:K.id)??((fe=s.timelineClips.value[0])==null?void 0:fe.id);T&&(q.value=!0,typeof y=="object"&&y!==null&&"id"in y?l.applyFilter(y.id):typeof y=="string"&&l.applyFilter(y),s.setFilters(l.activeFilters.value),aa(T),s.handleClipSelect(T),q.value=!1,De())},wa=y=>{var fe,Fe;const T=l.activeFilters.value.find(Re=>Re.filterId===y);T&&l.removeFilter(T.id),s.setFilters(l.activeFilters.value);const K=((fe=s.selectedClip.value)==null?void 0:fe.id)??((Fe=s.timelineClips.value[0])==null?void 0:Fe.id);K&&aa(K),De()},Sa=(y,T,K)=>{var Re,qe;const fe=l.activeFilters.value.find(ut=>ut.filterId===y);if(fe){fe.params={...fe.params??{},[T]:K},s.setFilters(l.activeFilters.value);const ut=((Re=s.selectedClip.value)==null?void 0:Re.id)??((qe=s.timelineClips.value[0])==null?void 0:qe.id);ut&&aa(ut),De();return}const Fe=l.previewFilter.value;Fe&&Fe.filterId===y&&(Fe.params={...Fe.params??{},[T]:K})},ka=y=>{y&&typeof y.id=="string"&&y.id!==""&&l.previewFilterEffect(y.id)},an=y=>{l.updateFilterParams(y),s.setFilters(l.activeFilters.value),De()},Q=async y=>{if(!D.value)return;const T=await D.value.addTextOverlay(y);Se.value.push({id:T,...y})},ue=async(y,T)=>{if(!D.value)return;await D.value.updateTextOverlay(y,T);const K=Se.value.findIndex(fe=>fe.id===y);K!==-1&&(Se.value[K]={...Se.value[K],...T})},oe=async y=>{D.value&&(await D.value.removeTextOverlay(y),Se.value=Se.value.filter(T=>T.id!==y))},ae=async y=>{const[T,K]=Zt.value;if(!T||!K)return;const fe={id:`transition-${T.id}-${K.id}-${Date.now()}`,...y,name:y.type,fromClipId:T.id,toClipId:K.id,cutTime:T.timelineEnd};mt.value.push(fe),s.setTransitions(mt.value.map(yt)),De()},xe=y=>{mt.value[y]&&(mt.value.splice(y,1),s.setTransitions(mt.value.map(yt)),De())},Le=y=>{},Ke=async y=>{if(!j.value)return;const T=await j.value.addAudioTrack(y);ot.value.push({id:T,...y});const K=typeof y.source=="string"?y.source:y.source instanceof File?URL.createObjectURL(y.source):null;if(!K)return;const fe={id:`audio-source-${T}`,type:"url",url:K,duration:typeof y.duration=="number"&&y.duration>0?y.duration:0,width:0,height:0};typeof y.name=="string"&&(fe.filename=y.name),s.registerMediaSource(fe);const Fe=s.appendAudioSourceToTimeline(fe.id);if(!Fe.ok){We.value=Fe.message;return}We.value=`Audio added to ${Fe.value.trackId??"timeline"}.`,De()},pt=async(y,T)=>{if(!j.value)return;await j.value.updateAudioTrack(y,T);const K=ot.value.findIndex(fe=>fe.id===y);K!==-1&&(ot.value[K]={...ot.value[K],...T})},Vt=async y=>{j.value&&(await j.value.removeAudioTrack(y),ot.value=ot.value.filter(T=>T.id!==y))},ft=async(y,T)=>{if(!j.value)return;await j.value.updateVolume(y,T);const K=ot.value.find(fe=>fe.id===y);K&&(K.volume=T)},ht=async(y,T)=>{if(!j.value)return;await j.value.muteTrack(y,T);const K=ot.value.find(fe=>fe.id===y);K&&(K.muted=T)},Ot=y=>{j.value&&(j.value.setMasterVolume(y),kt.value=y)},Nt=(y,T)=>{const K=ot.value.findIndex(Fe=>Fe.id===y);if(K===-1)return null;const fe={...ot.value[K],...T};return ot.value[K]=fe,fe},Ut=y=>{switch(y.type){case"track-fader-db":{const T=Tl(y.valueDb);Nt(y.trackId,{faderDb:y.valueDb,volume:T}),j.value&&j.value.updateVolume(y.trackId,T);break}case"track-mute":Nt(y.trackId,{muted:y.muted}),j.value&&j.value.muteTrack(y.trackId,y.muted);break;case"track-solo":Nt(y.trackId,{solo:y.solo});break;case"track-pan":Nt(y.trackId,{pan:y.pan});break;case"master-fader-db":{kt.value=Tl(y.valueDb),j.value&&j.value.setMasterVolume(xt.value?0:kt.value);break}case"master-mute":xt.value=y.muted,j.value&&j.value.setMasterVolume(xt.value?0:kt.value);break}},nn=y=>{we.value=[ye(y.track)],s.setCaptionTracks(we.value),De()},Da=y=>{we.value=[ye(y)],s.setCaptionTracks(we.value),De()},Ca=()=>{we.value=[],s.setCaptionTracks([]),De()},Va=y=>{const T=s.selectedClip.value??s.timelineClips.value[0];if(!T)return;const fe=[...(T.keyframes??[]).filter(Fe=>Fe.target!==y.target),...y.keyframes].sort((Fe,Re)=>{const qe=Fe.time-Re.time;return qe===0?Fe.id.localeCompare(Re.id):qe});s.setClipKeyframes(T.id,fe),De()},Gt=y=>{var T;return y.metadata||(y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),y.metadata.fit_mode=S.value,(T=o.media)!=null&&T.url&&/^https?:/i.test(o.media.url)?y.metadata.source_url=o.media.url:delete y.metadata.source_url,y.captionTracks=we.value.map(ye),y},Tt=(y,T)=>T?{...y,output:{...y.output,format:T.format,quality:T.quality,codec:T.codec??y.output.codec,fps:T.fps??y.output.fps,...typeof T.bitrate=="number"?{bitrate:T.bitrate}:{}}}:y,bt=y=>y.map(T=>({...T,params:T.params&&typeof T.params=="object"?{...T.params}:T.params})),ra=y=>y.timeline.some(T=>Array.isArray(T.filters)&&T.filters.length>0),lt=y=>{const T=bt(l.activeFilters.value);if(!ra(y)&&T.length>0&&y.timeline.length>0){const fe=y.timeline[0];fe&&(y.timeline=[{...fe,filters:T},...y.timeline.slice(1)])}return y},Ht=()=>{const y=lt(Gt(s.saveDraft()));try{localStorage.setItem(`video-draft-${r.value}`,JSON.stringify(y))}catch{}return G(y,"manual",!0),y},Na=()=>typeof localStorage>"u"?null:{getItem:y=>localStorage.getItem(y),setItem:(y,T)=>{localStorage.setItem(y,T)},removeItem:y=>{localStorage.removeItem(y)},listKeys:y=>{const T=[];for(let K=0;K<localStorage.length;K+=1){const fe=localStorage.key(K);fe!=null&&fe.startsWith(y)&&T.push(fe)}return T}},H=async()=>{const y=Na();if(y===null){Ce.value=[];return}Ce.value=await Sc(y)},G=async(y,T,K)=>{var na,io;const fe=Na();if(fe===null)return;const Fe=new Date().toISOString(),Re={projectId:Ye.value,sourceMediaUuid:r.value,durationSeconds:U.value,editorVersion:((na=y.metadata)==null?void 0:na.editor_version)??"2.0.0",saveReason:T,now:Fe};((io=y.metadata)==null?void 0:io.title)!==void 0&&(Re.title=y.metadata.title);const qe=G2(km(y),Re);await a_(fe,qe);const ut=await Sc(fe),$t=Y2(ut,{maxCount:5,projectId:Ye.value,now:Fe});await Cc(fe,$t.removed),Ce.value=[...$t.retained],K&&($e.value=Fe)},re=y=>y.snapshot.metadata.payloadKind==="project"?j2(y.snapshot.payload):y.snapshot.payload,de=y=>{const T=re(y);s.loadRecipe(T),Se.value=(T.textOverlays??[]).map(ce),ot.value=(T.audioTracks??[]).map(ge),we.value=(T.captionTracks??[]).map(ye),mt.value=(T.transitions??[]).map(Ct);const K=N(T);K!==null&&(S.value=K),Pe()},ke=y=>{const T=Na();Ce.value=Ce.value.filter(K=>!y.some(fe=>fe.key===K.key)),T!==null&&Cc(T,y)},Pe=()=>{L.value=Gt(s.generateRecipe())};let Ge=null;const De=()=>{Ge&&clearTimeout(Ge),Ge=setTimeout(()=>{Pe(),Ge=null},200)};if(e.watch(()=>s.timelineClips.value,De,{deep:!0}),e.watch(()=>s.selectedClip.value,y=>{if(q.value||!y)return;const T=(y==null?void 0:y.filters)??[];l.setActiveFilters(T)},{immediate:!0}),e.watch(()=>l.activeFilters.value,y=>{s.setFilters(y),De()},{deep:!0}),e.watch(()=>Se.value,y=>{s.setTextOverlays(y.map(me)),De()},{deep:!0}),e.watch(()=>ot.value,y=>{const T=y.map(Te).filter(K=>K!==null);s.setAudioTracks(T),De()},{deep:!0}),e.watch(()=>we.value,y=>{s.setCaptionTracks(y.map(ye)),De()},{deep:!0}),Se.value.length>0&&s.setTextOverlays(Se.value.map(me)),ot.value.length>0){const y=ot.value.map(Te).filter(T=>T!==null);s.setAudioTracks(y)}we.value.length>0&&s.setCaptionTracks(we.value.map(ye)),e.watch(()=>s.playheadPosition.value,De),Pe();const Ze=e.ref(!0),it=e.ref(null),We=e.ref(null);let Mt=null;e.watch(We,y=>{Mt!==null&&(clearTimeout(Mt),Mt=null),!(y===null||y==="")&&(Mt=setTimeout(()=>{We.value=null},4e3))});const wt=e.ref(null),sa=e.computed(()=>s.tracks.value),Vo=e.computed(()=>s.mediaSources.value),qn=e.computed(()=>{var y,T;return((y=s.selectedClip.value)==null?void 0:y.sourceRefId)??((T=Vo.value[0])==null?void 0:T.id)}),on=e.computed(()=>sa.value.filter(y=>y.locked!==!0&&y.type==="video")),ps=e.computed(()=>wt.value?sa.value.find(y=>y.id===wt.value)??null:null),bn=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),wn=e.computed(()=>!!s.selectedClip.value),Ta=e.computed(()=>s.timelineClips.value.length>0&&s.hasChanges.value),fs=e.computed(()=>s.selectedClip.value??s.timelineClips.value[0]??null),hs=y=>{const T=Number.isFinite(y)&&y>0?Math.round(y):0,K=Math.floor(T/60),fe=T%60;return`${K}:${fe.toString().padStart(2,"0")}`},Fi=e.computed(()=>{const y=s.timelineClips.value.length,T=sa.value.length,K=y===1?"1 clip":`${y} clips`,fe=T===1?"1 track":`${T} tracks`;return`${K} / ${fe} / ${hs(U.value)}`});e.watch(()=>sa.value.map(y=>`${y.id}:${y.locked===!0?"locked":"open"}`).join("|"),()=>{var y;wt.value&&on.value.some(T=>T.id===wt.value)||(wt.value=((y=on.value[0])==null?void 0:y.id)??null)},{immediate:!0}),e.watch(()=>{var y;return(y=s.selectedClip.value)==null?void 0:y.trackId},y=>{y&&on.value.some(T=>T.id===y)&&(wt.value=y)},{immediate:!0});const No=y=>{const T=Vo.value.find(K=>K.id===y);return T?T.filename??T.mediaUuid??T.url??T.id:"Asset"},$i=o.assetUploader?FT({uploader:o.assetUploader,onReady:y=>{if(!y.mediaUrl&&!y.mediaUuid)return;const T={id:`imported-${y.assetId}`,type:y.mediaUuid?"media":"url",filename:y.filename,mimeType:y.mime,duration:y.durationSeconds??0,width:y.width??0,height:y.height??0};y.mediaUuid!==void 0&&(T.mediaUuid=y.mediaUuid),y.mediaUrl!==void 0&&(T.url=y.mediaUrl),s.registerMediaSource(T),We.value=`${y.filename} ready.`},onFailure:y=>{We.value=y.failureMessage??`Upload of ${y.filename} failed.`}}):null,vs=async y=>{if(!$i){We.value="Asset import is not configured for this editor host.";return}for(const T of y){const K=await $i.importFile(T);K.ok||(We.value=K.message)}},gs=y=>{var Fe;const T=s.appendMediaSourceToTimeline(y,wt.value);if(!T.ok){it.value=T.message;return}const K=T.value;K.trackId&&(wt.value=K.trackId),s.handleClipSelect(K.id);const fe=((Fe=ps.value)==null?void 0:Fe.name)??"timeline";it.value=`${No(y)} added to ${fe}.`,De()},To=y=>{if(!s.replaceSelectedClipSource(y)){it.value="Select a clip before replacing its source.";return}it.value=`${No(y)} replaced the selected clip.`,De()},ys=y=>{const T=No(y);if(!s.removeMediaSource(y)){it.value="Remove timeline clips before deleting this asset.";return}it.value=`${T} removed.`,De()},Mo=(y="video")=>{const T=s.addTimelineTrack(y);wt.value=T.id,it.value=`${T.name} added. New assets will be placed on that track.`,De()},Bo=y=>{const T=y.target;T&&(wt.value=T.value||null)},la=y=>{var K;s.handleClipSelect(y);const T=(K=s.selectedClip.value)==null?void 0:K.trackId;T&&on.value.some(fe=>fe.id===T)&&(wt.value=T)},rn=(y,T,K)=>{const fe=s.moveClip(y,T,K);if(!fe.ok){We.value=fe.message;return}De()},Io=y=>{const T=s.deleteClip(y);if(!T.ok){We.value=T.message;return}We.value="Clip deleted.",De()},sn=(y,T)=>{T(y)&&De()},Fo=(y,T)=>{const K=s.renameTimelineTrack(y,T);if(!K.ok){We.value=K.message;return}We.value=`Track renamed to "${T}".`,De()},Yn=y=>{const T=s.deleteTimelineTrack(y);if(!T.ok){We.value=T.message;return}wt.value===y&&(wt.value=null),We.value="Track deleted.",De()},Ga=(y,T)=>{const K=s.reorderTimelineTrack(y,T);if(!K.ok){We.value=K.message;return}We.value=`Track moved ${T}.`,De()},Jt=y=>{Ze.value=y},pa=()=>{Ze.value=!Ze.value},ln=y=>{const T=y.target;if(!T)return;const K=Number(T.value);Number.isFinite(K)&&s.setZoomLevel(K)},zt=e.ref(!1),kn=e.ref(0),Ma=e.ref(!1),St=e.ref(null),Ja=e.ref(null),$o=e.ref("preparing");let _n=null,Ra=!1;const Do={preparing:"Preparing export...",rendering:"Rendering frames...","encoding-video":"Encoding video...","encoding-audio":"Encoding audio...",muxing:"Muxing output...",storing:"Storing export...",complete:"Export complete"},Di=y=>typeof y=="string"&&y in Do,En=(y,T)=>{$o.value=y,St.value=typeof T=="string"&&T.trim()!==""?T.trim():Do[y]},Lt=(y,T,K)=>{const fe=Number.isFinite(y)?Math.max(0,Math.min(100,y)):0;kn.value=fe,T&&En(T,K)},bs=y=>{if(Di(y.phase))return y.phase;switch(y.status){case"pending":return"preparing";case"processing":return"rendering";case"completed":return"complete";default:return $o.value}},Ro=y=>typeof y.progress_message=="string"&&y.progress_message.trim()!==""?y.progress_message.trim():void 0,xn=(y,T,K={allowClient:!0})=>{if(!Number.isFinite(T)||T<=0||y.timeline.length===0)return{route:"unsupported",exportDuration:T,message:"Export unavailable: the recipe has no renderable duration."};if(o.maxDuration>0&&T>o.maxDuration)return{route:"unsupported",exportDuration:T,message:`Export unavailable: duration exceeds the ${o.maxDuration}s limit.`};if(K.allowClient&&o.clientExportThreshold>0&&T<=o.clientExportThreshold)return{route:"client",exportDuration:T};const Fe=!!o.serverRenderEndpoint,Re=r.value.startsWith("temp-");return Fe&&!Re?{route:"server-render",exportDuration:T}:{route:"recipe-download",exportDuration:T,message:Re?"Local media — downloaded recipe.json. Client-side PIXI export is unavailable on this device.":"No server render endpoint configured — downloaded recipe.json."}},Qn=()=>new ds(o.serverRenderEndpoint??"/api/v1"),Aa=()=>{_n!==null&&(clearInterval(_n),_n=null)},Ri=y=>{Aa();const T=Qn();_n=setInterval(async()=>{if(Ra){Aa();return}try{const K=await T.getJob(y),fe=Number(K.progress??0);if(Lt(fe,bs(K),Ro(K)),i("server-render-progress",kn.value),K.status==="completed"||K.status==="failed"||K.status==="cancelled")if(Aa(),zt.value=!1,Ja.value=null,K.status==="completed"){Lt(100,"complete"),Ma.value=!0,St.value=null;const Fe=typeof K.output_media_id=="string"?K.output_media_id:void 0,Re={id:y};Fe!==void 0&&(Re.output_media_id=Fe),i("server-render-completed",Re)}else{const Fe=K.status==="cancelled"||typeof K.error_message=="string"&&/cancel/i.test(K.error_message),Re=Fe?"Export canceled.":typeof K.error_message=="string"&&K.error_message.trim()!==""?K.error_message:"Export failed";St.value=Re,Fe||i("server-render-failed",Re)}}catch(K){Aa(),zt.value=!1,Ja.value=null;const fe=K instanceof Error?K.message:"Failed to check export progress";St.value=fe,i("server-render-failed",fe)}},2e3)},Ao=y=>{const T=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),K=URL.createObjectURL(T),fe=document.createElement("a");fe.href=K,fe.download=`video-recipe-${Date.now()}.json`,fe.click(),setTimeout(()=>URL.revokeObjectURL(K),100)},eo=()=>{Aa(),Ra=!1,b.resetClientExport(),Ja.value=null,St.value=null,Ma.value=!1,kn.value=0,$o.value="preparing"},Sn=async y=>{Lt(0,"preparing");const K=await Qn().createRenderJob({source_media_uuid:r.value,recipe:y}),fe=typeof K.id=="string"?K.id:null;if(!fe)throw new Error("Export failed: missing job id");Ja.value=fe,i("export-started",fe),i("server-render-started",fe),Lt(1,"rendering"),Ri(fe)},Cn=async(y,T)=>{if(!await b.canExportClientSide())return null;const K=await b.renderRecipeWithPixi(y,T,fe=>{Ra||Lt(fe,"rendering")});return Ra?(St.value="Export canceled.",Lt(0),i("video-exported",null),null):(s.clearHasChanges(),i("recipe-generated",y),i("video-exported",K),Lt(100,"complete"),Ma.value=!0,K)},to=async y=>{eo(),zt.value=!0,En("preparing");try{const T=Gt(lt(Tt(s.generateRecipe(),y)));G(T,"before-export",!1),i("recipe-generated",T);const K=xc(T,U.value),fe=xn(T,K);if(fe.route==="unsupported"){zt.value=!1,St.value=fe.message??"Export unavailable.",i("server-render-failed",St.value);return}if(fe.route==="client"){const Re=await Cn(T,y);if(Re!==null){const qe=URL.createObjectURL(Re.file),ut=document.createElement("a");ut.href=qe,ut.download=`edited-video-${Date.now()}.mp4`,ut.click(),setTimeout(()=>URL.revokeObjectURL(qe),100),zt.value=!1;return}}const Fe=fe.route==="client"?xn(T,K,{allowClient:!1}):fe;if(Fe.route==="unsupported"){zt.value=!1,St.value=Fe.message??"Export unavailable.",i("server-render-failed",St.value);return}if(Fe.route==="recipe-download"){Ao(T),zt.value=!1,Lt(100,"complete"),Ma.value=!0,St.value=Fe.message??"Downloaded recipe.json.";return}await Sn(T)}catch(T){const K=Gt(s.generateRecipe());Ao(K);const fe=T instanceof Error?T.message:"Export failed";zt.value=!1,Lt(0),Ja.value=null,St.value=fe,i("server-render-failed",fe)}},ao=async()=>{Ra=!0,v.value=!1,b.cancelClientExport();const y=Ja.value;if(Aa(),zt.value=!1,Lt(0),St.value="Export canceled.",Ja.value=null,y&&o.serverRenderEndpoint)try{await Qn().cancelJob(y)}catch{}},Ka=()=>{s.togglePlayback()},no=()=>{s.resetChanges()},Vn=()=>{const y=Ht();i("draft-saved",y)},Lo=()=>{to()},ws=()=>{i("close")};a({saveDraft:async()=>{const y=Ht();return i("draft-saved",y),y},exportForUpload:async y=>{eo();const T=Gt(y??s.generateRecipe()),K=lt(T),fe=Array.isArray(K.filters)&&K.filters.length>0,Fe=ra(K);if(!(s.hasChanges.value||fe||Fe))return s.clearHasChanges(),i("video-exported",null),null;const qe=xc(K,U.value),ut=xn(K,qe);if(ut.route==="unsupported"){const $t=ut.message??"Export unavailable.";throw St.value=$t,new Error(`Video export failed: ${$t}`)}if(ut.route==="server-render")return zt.value=!0,await Sn(K),null;zt.value=!0;try{if(ut.route==="client"){const na=await Cn(K);if(na!==null)return na}const $t=ut.route==="client"?xn(K,qe,{allowClient:!1}):ut;if($t.route==="server-render")return await Sn(K),null;if($t.route==="unsupported"){const na=$t.message??"Export unavailable.";throw St.value=na,new Error(`Video export failed: ${na}`)}return St.value=$t.message??"Export unavailable for upload.",i("video-exported",null),null}catch($t){if(Ra)return St.value="Export canceled.",Lt(0),i("video-exported",null),null;const na=$t instanceof Error?$t.message:"Local WebGL export failed.";throw St.value=na,new Error(`Video export failed: ${na}`)}finally{zt.value=!1}}});const oo=e.ref(!1),Li=y=>{var Re,qe;const T=[...s.timelineClips.value].sort((ut,$t)=>ut.timelineStart-$t.timelineStart);if(T.length===0)return;const K=s.selectedClip.value;if(!K){s.handleClipSelect(((Re=T[0])==null?void 0:Re.id)??null);return}const fe=T.findIndex(ut=>ut.id===K.id);if(fe===-1){s.handleClipSelect(((qe=T[0])==null?void 0:qe.id)??null);return}const Fe=y==="next"?T[Math.min(fe+1,T.length-1)]:T[Math.max(fe-1,0)];Fe&&s.handleClipSelect(Fe.id)},Pi=()=>{s.seekTo(Math.min(s.totalDuration.value,s.playheadPosition.value+1))},Po=()=>{s.seekTo(Math.max(0,s.playheadPosition.value-1))};return kT({playPause:Ka,frameForward:s.frameForward,frameBackward:s.frameBackward,secondForward:Pi,secondBackward:Po,skipToStart:s.skipToStart,skipToEnd:s.skipToEnd,prevClip:()=>Li("prev"),nextClip:()=>Li("next"),splitAtPlayhead:s.splitAtPlayhead,deleteSelected:()=>{const y=s.deleteSelectedClip();y.ok?We.value="Clip deleted.":We.value=y.message},rippleDeleteSelected:()=>{s.rippleDeleteSelectedClip()?We.value="Clip removed and gap closed.":We.value="Nothing to ripple-delete."},undo:s.undo,redo:s.redo,save:Vn,exportNow:()=>{if(s.timelineClips.value.length===0){We.value="Add media to export.";return}Lo()},showShortcutsOverlay:()=>{oo.value=!0}}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2"),H()}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Aa(),Ra=!0,b.cancelClientExport(),Ge&&(clearTimeout(Ge),Ge=null),ne.value&&(ne.value.destroy(),ne.value=null),D.value=null,j.value=null}),(y,T)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(zC,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",DT,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn",{"is-active":e.unref(s).isPlaying.value}]),"data-testid":"v2-btn-play","aria-label":e.unref(s).isPlaying.value?"Pause":"Play",onClick:Ka},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(Wl):e.unref(Zl),"aria-hidden":"true"},null,8,["icon"])],10,RT),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-reset","aria-label":"Reset all changes",disabled:!e.unref(s).hasChanges.value,onClick:no},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn),"aria-hidden":"true"},null,8,["icon"])],8,AT)]),T[20]||(T[20]=e.createElementVNode("div",{class:"v2-toolbar-title","aria-live":"polite"},[e.createElementVNode("span",{class:"v2-toolbar-badge"},"V2"),e.createTextVNode(" Video Editor ")],-1)),e.createElementVNode("div",LT,[e.createElementVNode("label",PT,[T[18]||(T[18]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":T[0]||(T[0]=K=>S.value=K),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...T[17]||(T[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,S.value]])]),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-save","aria-label":"Save draft",disabled:!e.unref(s).hasChanges.value,onClick:Vn},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Pr),"aria-hidden":"true"},null,8,["icon"]),T[19]||(T[19]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,OT),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":e.unref(s).timelineClips.value.length===0?"Export disabled — add media first":"Export",title:e.unref(s).timelineClips.value.length===0?"Add media to export":void 0,disabled:zt.value||e.unref(s).timelineClips.value.length===0,onClick:Lo},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(vo),"aria-hidden":"true"},null,8,["icon"])],8,UT),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:ws},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Un),"aria-hidden":"true"},null,8,["icon"])])])]),assets:e.withCtx(()=>[e.createElementVNode("div",zT,[e.createVNode(tV,{sources:Vo.value,"selected-source-id":qn.value,"uploads-enabled":!!y.assetUploader,onAdd:gs,onReplaceSelected:To,onRemove:ys,onImportFiles:vs},null,8,["sources","selected-source-id","uploads-enabled"]),it.value?(e.openBlock(),e.createElementBlock("p",jT,e.toDisplayString(it.value),1)):e.createCommentVNode("",!0)])]),canvas:e.withCtx(()=>[e.createElementVNode("div",WT,[e.withDirectives(e.createVNode(tl,{ref_key:"pixiPreviewRef",ref:_,class:"v2-preview-child","aria-hidden":!V.value,source:Z.value,"fallback-duration":U.value,filters:x.value,playhead:F.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":S.value,active:V.value,onPlayPause:Ka,onFrameUpdate:I,onDurationChange:M},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,V.value]]),e.withDirectives(e.createVNode(gl,{class:"v2-preview-child","aria-hidden":!B.value,"media-uuid":r.value,recipe:L.value,media:R.value,"enable-engine":B.value&&P.value,"fit-mode":S.value,onTimeUpdate:z,onPlayStateChange:X,onDurationChange:M,onEngineReady:ta},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,B.value]])])]),timeline:e.withCtx(({isMobile:K})=>{var fe,Fe;return[e.createElementVNode("div",{class:e.normalizeClass(["v2-timeline",{"is-mobile":!!K}])},[e.createElementVNode("div",ZT,[e.createElementVNode("div",HT,[T[21]||(T[21]=e.createElementVNode("span",{class:"v2-timeline-title","data-testid":"v2-timeline-title"},"Timeline",-1)),e.createElementVNode("span",XT,e.toDisplayString(Fi.value),1)]),e.createElementVNode("label",GT,[T[22]||(T[22]=e.createElementVNode("span",null,"Zoom",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(s).zoomLevel.value,"aria-label":"Timeline zoom","data-testid":"v2-timeline-zoom",onInput:ln},null,40,JT),e.createElementVNode("span",KT,e.toDisplayString(Math.round(e.unref(s).zoomLevel.value))+" px/s",1)]),K?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",qT,[e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn v2-toolbar-btn--ghost","data-testid":"v2-btn-add-track",onClick:T[1]||(T[1]=Re=>Mo("video"))},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(rr)},null,8,["icon"]),T[23]||(T[23]=e.createTextVNode(" Add Track ",-1))]),on.value.length>0?(e.openBlock(),e.createElementBlock("label",YT,[T[24]||(T[24]=e.createElementVNode("span",null,"Place clips in",-1)),e.createElementVNode("select",{value:wt.value??"","data-testid":"v2-select-target-track","aria-label":"Target track for added assets",onChange:Bo},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(on.value,Re=>(e.openBlock(),e.createElementBlock("option",{key:Re.id,value:Re.id},e.toDisplayString(Re.name),9,e4))),128))],40,QT)])):e.createCommentVNode("",!0)])),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn v2-toolbar-btn--ghost",{"is-active":Ze.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":Ze.value?"true":"false",onClick:pa},e.toDisplayString(Ze.value?"Snap On":"Snap Off"),11,t4)]),We.value?(e.openBlock(),e.createElementBlock("p",a4,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0),e.unref(s).timelineClips.value.length===0?(e.openBlock(),e.createElementBlock("div",n4,[...T[25]||(T[25]=[e.createElementVNode("p",{class:"v2-timeline-empty-title"},"Your timeline is empty",-1),e.createElementVNode("p",{class:"v2-timeline-empty-hint"}," Add a clip from the Assets panel or upload media to get started. Export is disabled until the timeline has at least one clip. ",-1)])])):(e.openBlock(),e.createBlock(yl,{key:2,playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,tracks:sa.value,"selected-clip-id":((fe=e.unref(s).selectedClip.value)==null?void 0:fe.id)??((Fe=e.unref(s).timelineClips.value[0])==null?void 0:Fe.id)??null,duration:U.value,fps:e.unref(s).fps.value,"is-mobile":!!K,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":Ze.value,sensitivity:.25,"onUpdate:playhead":T[2]||(T[2]=Re=>e.unref(s).seekTo(Re)),onTrim:T[3]||(T[3]=(Re,qe,ut)=>e.unref(s).handleTrim(Re,qe,ut)),onSplit:T[4]||(T[4]=Re=>e.unref(s).handleSplit(Re)),onClipSelect:la,onClipDelete:Io,onClipMove:rn,onSnapStateChange:Jt,onToggleLock:T[5]||(T[5]=Re=>sn(Re,e.unref(s).toggleTrackLock)),onToggleHidden:T[6]||(T[6]=Re=>sn(Re,e.unref(s).toggleTrackHidden)),onToggleMuted:T[7]||(T[7]=Re=>sn(Re,e.unref(s).toggleTrackMuted)),onToggleSolo:T[8]||(T[8]=Re=>sn(Re,e.unref(s).toggleTrackSolo)),onRenameTrack:Fo,onDeleteTrack:Yn,onReorderTrack:Ga},null,8,["playhead","clips","tracks","selected-clip-id","duration","fps","is-mobile","zoom-level","snap-enabled"])),e.createVNode(bl,{"selected-clip":e.unref(s).selectedClip.value,"can-split":bn.value,"can-delete":wn.value,"can-undo":e.unref(s).canUndo.value,"can-redo":e.unref(s).canRedo.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,"is-mobile":!!K,"show-add-track":!!K,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onAddTrack:T[9]||(T[9]=Re=>Mo("video")),onDuplicate:e.unref(s).duplicateSelectedClip,onUndo:e.unref(s).undo,onRedo:e.unref(s).redo,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:Ka,onFrameForward:e.unref(s).frameForward,onFrameBackward:e.unref(s).frameBackward,onSkipToStart:e.unref(s).skipToStart,onSkipToEnd:e.unref(s).skipToEnd,onSpeedChange:e.unref(s).setPlaybackSpeed},null,8,["selected-clip","can-split","can-delete","can-undo","can-redo","is-playing","zoom-level","playback-speed","is-mobile","show-add-track","onSplit","onDelete","onDuplicate","onUndo","onRedo","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])],2)]}),inspector:e.withCtx(()=>[Xe.value.length>0?(e.openBlock(),e.createBlock(Qc,{key:0,class:"v2-draft-recovery",records:Xe.value,surface:"desktop","project-id":Ye.value,"saved-at":$e.value,onRestore:de,onDismiss:ke},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(RN,{"active-tab":d.value,"onUpdate:activeTab":T[10]||(T[10]=K=>d.value=K),tabs:f.value},{filters:e.withCtx(()=>[e.createVNode(wl,{filters:le.value,"active-filters":ve.value,"thumbnail-url":ie.value,onApplyFilter:ia,onRemoveFilter:wa,onUpdateParam:Sa,onPreviewFilter:ka},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(kl,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:an},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",o4,[...T[26]||(T[26]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])])),e.createVNode(eu,{class:"v2-keyframe-panel",duration:_t.value,target:"all","device-class":"desktop",onApplyPreset:Va},null,8,["duration"])]),text:e.withCtx(()=>[e.createVNode(El,{overlays:Se.value,onAddOverlay:Q,onUpdateOverlay:ue,onRemoveOverlay:oe},null,8,["overlays"]),e.createVNode(Yc,{class:"v2-caption-panel","caption-track":ze.value,layout:"desktop",onImport:nn,"onUpdate:captionTrack":Da,onClear:Ca},null,8,["caption-track"])]),transitions:e.withCtx(()=>[e.createVNode(xl,{"selected-clips":Zt.value,"applied-transitions":mt.value,onApplyTransition:ae,onRemoveTransition:xe,onPreviewTransition:Le},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Sl,{"audio-layers":ot.value,"master-volume":kt.value,onAddTrack:Ke,onUpdateTrack:pt,onRemoveTrack:Vt,onUpdateVolume:ft,onToggleMute:ht,onUpdateMasterVolume:Ot},null,8,["audio-layers","master-volume"]),e.createVNode(qc,{class:"v2-audio-mixer",state:ct.value,"device-class":"desktop",onUpdate:Ut},null,8,["state"])]),export:e.withCtx(()=>[e.createVNode(_l,{"can-export":Ta.value,"is-exporting":zt.value,"export-progress":kn.value,onExport:to,onCancelExport:ao,onSaveDraft:Vn,onReset:no},null,8,["can-export","is-exporting","export-progress"]),Ma.value?(e.openBlock(),e.createElementBlock("div",i4," Export complete ")):e.createCommentVNode("",!0),St.value&&!Ma.value?(e.openBlock(),e.createElementBlock("div",r4,e.toDisplayString(St.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(yT,{"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[Xe.value.length>0?(e.openBlock(),e.createBlock(Qc,{key:0,class:"v2-draft-recovery",records:Xe.value,surface:"mobile","project-id":Ye.value,"saved-at":$e.value,onRestore:de,onDismiss:ke},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(sT,{"selected-clip":fs.value,onOpenActions:T[11]||(T[11]=K=>c.value="trim")},null,8,["selected-clip"]),e.createVNode(mT,{modelValue:c.value,"onUpdate:modelValue":T[12]||(T[12]=K=>c.value=K)},null,8,["modelValue"]),c.value==="look"?(e.openBlock(),e.createElementBlock("section",s4,[e.createElementVNode("div",l4,[e.createVNode(wl,{filters:le.value,"active-filters":ve.value,"thumbnail-url":ie.value,onApplyFilter:ia,onRemoveFilter:wa,onUpdateParam:Sa,onPreviewFilter:ka},null,8,["filters","active-filters","thumbnail-url"])]),e.createElementVNode("div",d4,[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(kl,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:an},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",c4,[...T[27]||(T[27]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))])])):c.value==="trim"?(e.openBlock(),e.createElementBlock("section",u4,[e.createVNode(bl,{"selected-clip":e.unref(s).selectedClip.value,"can-split":bn.value,"can-delete":wn.value,"can-undo":e.unref(s).canUndo.value,"can-redo":e.unref(s).canRedo.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,"is-mobile":"","show-add-track":"",onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onAddTrack:T[13]||(T[13]=K=>Mo("video")),onDuplicate:e.unref(s).duplicateSelectedClip,onUndo:e.unref(s).undo,onRedo:e.unref(s).redo,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:Ka,onFrameForward:e.unref(s).frameForward,onFrameBackward:e.unref(s).frameBackward,onSkipToStart:e.unref(s).skipToStart,onSkipToEnd:e.unref(s).skipToEnd,onSpeedChange:e.unref(s).setPlaybackSpeed},null,8,["selected-clip","can-split","can-delete","can-undo","can-redo","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onUndo","onRedo","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])])):c.value==="text"?(e.openBlock(),e.createElementBlock("section",m4,[e.createVNode(El,{overlays:Se.value,onAddOverlay:Q,onUpdateOverlay:ue,onRemoveOverlay:oe},null,8,["overlays"]),e.createVNode(Yc,{"caption-track":ze.value,layout:"mobile",onImport:nn,"onUpdate:captionTrack":Da,onClear:Ca},null,8,["caption-track"])])):c.value==="audio"?(e.openBlock(),e.createElementBlock("section",p4,[e.createVNode(Sl,{"audio-layers":ot.value,"master-volume":kt.value,onAddTrack:Ke,onUpdateTrack:pt,onRemoveTrack:Vt,onUpdateVolume:ft,onToggleMute:ht,onUpdateMasterVolume:Ot},null,8,["audio-layers","master-volume"]),e.createVNode(qc,{state:ct.value,"device-class":"mobile",onUpdate:Ut},null,8,["state"])])):c.value==="export"?(e.openBlock(),e.createElementBlock("section",f4,[e.createVNode(_l,{"can-export":Ta.value,"is-exporting":zt.value,"export-progress":kn.value,"is-mobile":"",onExport:to,onCancelExport:ao,onSaveDraft:Vn,onReset:no},null,8,["can-export","is-exporting","export-progress"]),Ma.value?(e.openBlock(),e.createElementBlock("div",h4,"Export complete")):e.createCommentVNode("",!0),St.value&&!Ma.value?(e.openBlock(),e.createElementBlock("div",v4,e.toDisplayString(St.value),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("section",g4,[e.createElementVNode("div",y4,[e.createElementVNode("label",b4,[T[29]||(T[29]=e.createElementVNode("span",null,"Fit",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":T[14]||(T[14]=K=>S.value=K),"aria-label":"Mobile fit mode"},[...T[28]||(T[28]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,S.value]])]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-mobile-secondary-button",{"is-active":Ze.value}]),"aria-pressed":Ze.value?"true":"false","data-testid":"v2-mobile-btn-snap-toggle",onClick:pa},e.toDisplayString(Ze.value?"Snap On":"Snap Off"),11,w4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-reset",disabled:!e.unref(s).hasChanges.value,onClick:no}," Reset ",8,k4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-save",disabled:!e.unref(s).hasChanges.value,onClick:Vn}," Save ",8,_4)]),h.value?(e.openBlock(),e.createElementBlock("details",E4,[T[30]||(T[30]=e.createElementVNode("summary",null,"Transitions",-1)),e.createVNode(xl,{"selected-clips":Zt.value,"applied-transitions":mt.value,onApplyTransition:ae,onRemoveTransition:xe,onPreviewTransition:Le},null,8,["selected-clips","applied-transitions"])])):e.createCommentVNode("",!0),e.createElementVNode("details",x4,[T[31]||(T[31]=e.createElementVNode("summary",null,"Keyframe presets",-1)),e.createVNode(eu,{duration:_t.value,target:"all","device-class":"mobile",onApplyPreset:Va},null,8,["duration"])])]))]),_:1})]),_:1}),oo.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"v2-shortcuts-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts","data-testid":"v2-shortcuts-overlay",onClick:T[16]||(T[16]=e.withModifiers(K=>oo.value=!1,["self"]))},[e.createElementVNode("div",S4,[e.createElementVNode("div",C4,[T[32]||(T[32]=e.createElementVNode("h2",null,"Keyboard shortcuts",-1)),e.createElementVNode("button",{type:"button",class:"v2-shortcuts-overlay__close","aria-label":"Close shortcuts overlay","data-testid":"v2-shortcuts-overlay-close",onClick:T[15]||(T[15]=K=>oo.value=!1)},"×")]),T[33]||(T[33]=e.createStaticVNode('<dl class="v2-shortcuts-overlay__list" data-v-f6c1af64><div data-v-f6c1af64><dt data-v-f6c1af64>Space</dt><dd data-v-f6c1af64>Play / pause</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>← / →</dt><dd data-v-f6c1af64>Frame back / forward</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Shift + ← / →</dt><dd data-v-f6c1af64>1 second back / forward</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Home / End</dt><dd data-v-f6c1af64>Skip to start / end</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>[ / ]</dt><dd data-v-f6c1af64>Previous / next clip</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>S</dt><dd data-v-f6c1af64>Split at playhead</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Delete</dt><dd data-v-f6c1af64>Delete selected clip</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Shift + Delete</dt><dd data-v-f6c1af64>Ripple delete (closes the gap)</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Cmd / Ctrl + Z</dt><dd data-v-f6c1af64>Undo</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Cmd / Ctrl + Shift + Z</dt><dd data-v-f6c1af64>Redo</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Cmd / Ctrl + S</dt><dd data-v-f6c1af64>Save draft</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>Cmd / Ctrl + E</dt><dd data-v-f6c1af64>Export</dd></div><div data-v-f6c1af64><dt data-v-f6c1af64>?</dt><dd data-v-f6c1af64>This overlay</dd></div></dl>',1))])])):e.createCommentVNode("",!0)],64))}}),N4=Be(V4,[["__scopeId","data-v-f6c1af64"]]),Fa=n=>n===null||typeof n!="object"||Array.isArray(n)?null:n,rt=n=>{if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const a=Number(n);return Number.isFinite(a)?a:null}return null},T4=(n,a)=>{if(a===null)return;const t=Fa(n.source)??{},o=rt(t.duration);if(!(o!==null&&o>0&&o<=1&&a>o))return;t.duration=a,n.source=t;const r=Array.isArray(n.timeline)?n.timeline:[];if(r.length===1){const d=Fa(r[0]);if(d!==null){const c=rt(d.sourceIn)??0,u=rt(d.sourceOut)??rt(d.end)??rt(d.timelineEnd);if(c===0&&u!==null&&u>0&&u<=1){d.sourceOut=a;const m=rt(d.end);m!==null&&m>0&&m<=1&&(d.end=a);const p=rt(d.timelineEnd);p!==null&&p>0&&p<=1&&(d.timelineEnd=a)}}}const s=rt(n.trimEnd)??rt(n.trim_end);s!==null&&s>0&&s<=1&&(n.trimEnd=a);const l=Fa(n.trim);if(l!==null){const d=rt(l.end);d!==null&&d>0&&d<=1&&(l.end=a,n.trim=l)}},M4=(n,a)=>{if(!n)return!1;const t=Fa(n);if(t===null)return!1;const o=Fa(t.trim),i=Fa(t.source),s=rt(i==null?void 0:i.duration)??a,l=Array.isArray(n.filters)&&n.filters.length>0;let d=!1;if(Array.isArray(n.timeline)&&n.timeline.length===1){const p=n.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(d=!0)}let c=!1;const u=rt(t.trimStart)??rt(t.trim_start)??rt(o==null?void 0:o.start),f=rt(t.trimEnd)??rt(t.trim_end)??rt(o==null?void 0:o.end);if(u!==null&&u>0&&(c=!0),f!==null&&s!==void 0&&f<s&&(c=!0),!c&&Array.isArray(n.timeline)&&n.timeline.length===1){const p=n.timeline[0];if(p){const h=rt(p.sourceIn),v=rt(p.sourceOut);h!==null&&h>0&&(c=!0),v!==null&&s!==void 0&&v<s&&(c=!0)}}let m=!1;if(Array.isArray(n.timeline)&&n.timeline.length===1){const p=n.timeline[0];if(p){const h=rt(p.speed);m=h!==null&&h!==1}}return l||d||c||m},Vp=n=>{if(!n)return!1;const a=Fa(n);return a===null?!1:!!(Array.isArray(a.textOverlays)&&a.textOverlays.length>0||Array.isArray(a.transitions)&&a.transitions.length>0||Array.isArray(n.timeline)&&n.timeline.length>1)},B4=(n,a={})=>{var m,p;const t=JSON.parse(JSON.stringify(n)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?Fa(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 h=rt(i.sourceIn),v=rt(i.sourceOut);h!==null&&t.trimStart===void 0&&(t.trimStart=h),v!==null&&t.trimEnd===void 0&&(t.trimEnd=v)}const l=Fa(t.trim);if(t.trimStart===void 0){const h=rt(l==null?void 0:l.start);h!==null&&(t.trimStart=h)}if(t.trimEnd===void 0){const h=rt(l==null?void 0:l.end);h!==null&&(t.trimEnd=h)}const d=Fa(t.source),c=rt(t.width)??rt(d==null?void 0:d.original_width)??rt((m=a.exportMeta)==null?void 0:m.width);c!==null&&(t.width=c);const u=rt(t.height)??rt(d==null?void 0:d.original_height)??rt((p=a.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const f=Fa(t.output);return t.fps=rt(t.fps)??rt(f==null?void 0:f.fps)??30,T4(t,a.mediaDuration??null),t},I4={key:0},F4=["data-testid"],$4={class:"ve-mobile-header"},D4=["data-testid"],R4={class:"ve-mobile-title"},A4=["data-testid","disabled"],L4={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},P4={class:"ve-body"},O4=["data-testid"],U4=["aria-label"],z4={class:"ve-header"},j4={class:"ve-title"},W4=["data-testid"],Z4={class:"ve-body"},H4={class:"ve-footer"},X4=["data-testid"],G4=["data-testid","disabled"],J4=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"},editorVersion:{}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(n,{expose:a,emit:t}){const o=n,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),l=e.computed(()=>o.saveImmediate===!1),d=e.computed(()=>o.closeText),c=e.computed(()=>f.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),f=e.ref(!1),m=e.ref(!1),p=e.ref(null),h=`temp-${Date.now()}`,v=e.computed(()=>{var M;const U=(M=o.featureFlags)==null?void 0:M.export;return typeof U=="boolean"?U:o.workflowMode==="full"}),k=e.computed(()=>{if(o.editorVersion==="v1"||o.editorVersion==="v2")return o.editorVersion;if(typeof window>"u")return"v2";try{const U=new URLSearchParams(window.location.search),M=U.get("editor")??U.get("video-editor");if(M==="v1")return"v1";if(M==="v2")return"v2"}catch{}return"v2"}),V=e.computed(()=>k.value==="v2"?N4:xp),B=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():h),_=e.computed(()=>{const U={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&(U.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&(U.initialRecipe=o.initialRecipe),o.media!==void 0&&(U.media=o.media),U}),g=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",g)}),e.onUnmounted(()=>{window.removeEventListener("resize",g)}),e.onErrorCaptured(()=>(m.value=!0,!1));const E=U=>{const M=Array.isArray(U.timeline)?U.timeline:[];if(M.length===0)return 0;let I=0;for(const z of M){const X=Number(z.sourceIn),le=Number(z.sourceOut),ve=Number(z.speed??1),ie=Number.isFinite(ve)&&ve>0?ve:1;if(Number.isFinite(X)&&Number.isFinite(le)&&le>X){I+=(le-X)/ie;continue}const ne=Number(z.timelineStart),L=Number(z.timelineEnd);Number.isFinite(ne)&&Number.isFinite(L)&&L>ne&&(I+=L-ne)}return I},C=(U,M,I)=>{let z=null;const X=new Promise((le,ve)=>{z=setTimeout(()=>ve(new Error(`${I} timed out after ${M}ms`)),M)});return Promise.race([U,X]).finally(()=>{z!==null&&clearTimeout(z)})},N=()=>{var X;const I=(X=o.media)==null?void 0:X.duration;if(typeof I!="number"||!Number.isFinite(I)||I<=0)return 12e3;const z=Math.round(I*1e3);return Math.min(45e3,Math.max(12e3,z))},S=()=>{i("close"),i("update:open",!1)},A=()=>{f.value=!1,S()},Z=U=>{i("recipe-generated",U)},x=U=>{i("export-started",U),i("save-started",U)},F=U=>{i("video-exported",U)},b=U=>{i("thumbnail-selected",U)},R=(U,M,I)=>{i("save-recipe",U);const z={recipe:U,exportPayload:M};I!==void 0&&(z.toastDescription=I),i("save-complete",z),S()},P=U=>{f.value||(i("draft-saved",U),R(U,null))},O=async()=>{var U;if(!f.value){if(m.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),S();return}f.value=!0;try{const M=await C(p.value.saveDraft(),N(),"saveDraft");let I=null,z=!1,X;const le=E(M),ve=le>0?le:((U=o.media)==null?void 0:U.duration)??0;if(v.value&&ve>0&&ve<=o.clientExportThreshold&&typeof p.value.exportForUpload=="function"){z=!0;const ne=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{I=await C(p.value.exportForUpload(M),ne,"exportForUpload")}catch{I=null}}if(Vp(M)&&I===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}z&&I===null&&(X="Video edits saved. Final render will happen when you share."),R(M,I,X)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),S()}finally{f.value=!1}}};return a({saveDraft:O}),(U,M)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",I4,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",$4,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:A},e.toDisplayString(d.value),9,D4),e.createElementVNode("h2",R4,e.toDisplayString(U.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:f.value,onClick:O},e.toDisplayString(c.value),9,A4)):(e.openBlock(),e.createElementBlock("span",L4))]),e.createElementVNode("section",P4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(V.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":B.value,"data-editor-version":k.value},_.value,{onClose:A,onDraftSaved:P,onExportStarted:x,onRecipeGenerated:Z,onThumbnailSelected:b,onVideoExported:F}),null,16,["media-uuid","data-editor-version"]))])],8,F4)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(A,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":U.title,"aria-modal":"true"},[e.createElementVNode("header",z4,[e.createElementVNode("h2",j4,e.toDisplayString(U.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:A}," ✕ ",8,W4)]),e.createElementVNode("section",Z4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(V.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":B.value,"data-editor-version":k.value},_.value,{onClose:A,onDraftSaved:P,onExportStarted:x,onRecipeGenerated:Z,onThumbnailSelected:b,onVideoExported:F}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",H4,[e.renderSlot(U.$slots,"footer",{close:A,isSaving:f.value,save:O},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:A},e.toDisplayString(d.value),9,X4),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:f.value,onClick:O},e.toDisplayString(c.value),9,G4)):e.createCommentVNode("",!0)],!0)])],8,U4)],8,O4))])):e.createCommentVNode("",!0)]))}}),K4=Be(J4,[["__scopeId","data-v-3cc6e078"]]),q4={class:"video-editor-modal"},Y4={class:"video-preview-container"},Q4=["src"],e3={class:"video-overlay-controls"},t3=["aria-label"],a3={class:"time-display"},n3={class:"timeline-container"},o3={class:"clip-name"},i3={class:"timeline-time-labels"},r3={class:"tool-tabs"},s3=["onClick"],l3={class:"tool-panel"},d3={key:0,class:"trim-panel"},c3={class:"trim-controls"},u3={key:1,class:"filters-panel"},m3={class:"filter-grid"},p3=["onClick"],f3={key:2,class:"text-panel"},h3={key:3,class:"transitions-panel"},v3={class:"transition-grid"},g3=["onClick"],y3={class:"action-buttons"},b3=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),d=e.ref(0),c=e.ref("video-1"),u=e.ref(0),f=e.ref(0),m=e.ref(null),p=e.ref("trim"),h=e.ref(null),v=e.ref(""),k=[{id:"trim",label:"Trim",icon:br},{id:"filters",label:"Filters",icon:uh},{id:"text",label:"Text",icon:Fu},{id:"transitions",label:"Transitions",icon:bh}],V=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],B=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],_=e.ref();e.onMounted(()=>{var M,I;(M=t.media)!=null&&M.url?r.value=t.media.url:(I=t.media)!=null&&I.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var M;(M=t.media)!=null&&M.file&&r.value&&URL.revokeObjectURL(r.value)});function g(){i.value&&(d.value=i.value.duration,f.value=d.value)}function E(){i.value&&(l.value=i.value.currentTime)}function C(){s.value=!1}function N(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function S(M){if(!M||isNaN(M))return"00:00";const I=Math.floor(M/60),z=Math.floor(M%60);return`${I.toString().padStart(2,"0")}:${z.toString().padStart(2,"0")}`}function A(M){if(!i.value||!_.value)return;const I=_.value.getBoundingClientRect(),le=(M.clientX-I.left)/I.width*d.value;i.value.currentTime=Math.max(0,Math.min(le,d.value))}function Z(){u.value=l.value}function x(){f.value=l.value}function F(){u.value=0,f.value=d.value}function b(M){m.value=M;const I=X=>{if(!m.value||!_.value)return;const le=_.value.getBoundingClientRect(),ne=(X.clientX-le.left)/le.width*d.value;m.value==="start"?u.value=Math.max(0,Math.min(ne,f.value-1)):f.value=Math.max(u.value+1,Math.min(ne,d.value))},z=()=>{m.value=null,document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",z)}function R(M){if(h.value=M,!i.value)return;const I={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=I[M]||"none"}function P(){}function O(M){}function U(){const M={timeline:[{id:c.value,url:r.value,startTime:0,endTime:d.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:h.value?[{type:h.value}]:[],textOverlays:v.value?[{content:v.value}]:[],duration:f.value-u.value};o("save",M)}return(M,I)=>(e.openBlock(),e.createElementBlock("div",q4,[e.createElementVNode("div",Y4,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:g,onTimeupdate:E,onEnded:C,controls:""},null,40,Q4),e.createElementVNode("div",e3,[e.createElementVNode("button",{class:"play-pause-btn",onClick:N,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(W.IonIcon),{icon:s.value?e.unref(Eh):e.unref(Vh)},null,8,["icon"])],8,t3),e.createElementVNode("div",a3,e.toDisplayString(S(l.value))+" / "+e.toDisplayString(S(d.value)),1)])]),e.createElementVNode("div",n3,[e.createElementVNode("div",{class:"timeline-track",onClick:A,ref_key:"timelineTrack",ref:_},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/d.value*100}%`,right:`${100-f.value/d.value*100}%`})},[e.createElementVNode("span",o3,e.toDisplayString(c.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/d.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/d.value*100}%`}),onMousedown:I[0]||(I[0]=z=>b("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:`${f.value/d.value*100}%`}),onMousedown:I[1]||(I[1]=z=>b("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",i3,[e.createElementVNode("span",null,e.toDisplayString(S(0)),1),e.createElementVNode("span",null,e.toDisplayString(S(d.value)),1)])]),e.createElementVNode("div",r3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(k,z=>e.createElementVNode("button",{key:z.id,class:e.normalizeClass(["tool-tab",{active:p.value===z.id}]),onClick:X=>p.value=z.id},[e.createVNode(e.unref(W.IonIcon),{icon:z.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(z.label),1)],10,s3)),64))]),e.createElementVNode("div",l3,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",d3,[I[7]||(I[7]=e.createElementVNode("h3",null,"Trim Video",-1)),I[8]||(I[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",c3,[e.createElementVNode("button",{class:"btn-trim",onClick:Z},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xd)},null,8,["icon"]),I[4]||(I[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:x},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xd)},null,8,["icon"]),I[5]||(I[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:F},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),I[6]||(I[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",u3,[I[9]||(I[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",m3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(V,z=>e.createElementVNode("button",{key:z.id,class:e.normalizeClass(["filter-option",{active:h.value===z.id}]),onClick:X=>R(z.id)},e.toDisplayString(z.name),11,p3)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",f3,[I[10]||(I[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[2]||(I[2]=z=>v.value=z),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,v.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:P},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",h3,[I[11]||(I[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",v3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(B,z=>e.createElementVNode("button",{key:z.id,class:"transition-option",onClick:X=>(z.id,void 0)},e.toDisplayString(z.name),9,g3)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",y3,[e.createElementVNode("button",{class:"btn-cancel",onClick:I[3]||(I[3]=z=>M.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:U},"SAVE")])]))}}),w3=Be(b3,[["__scopeId","data-v-b933f33b"]]),k3={class:"time-label"},_3=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(n){const a=n,t=e.computed(()=>({width:`${a.duration*a.zoom*100}px`})),o=e.computed(()=>{const s=[],l=i(a.duration,a.zoom);for(let d=0;d<=a.duration;d+=l){const c=`${d/a.duration*100}%`,u=r(d),f=d%(l*5)===0;s.push({time:d,position:c,label:u,major:f})}return s});function i(s,l){const d=s/(10*l);return d<=1?1:d<=5?5:d<=10?10:d<=30?30:d<=60?60:Math.ceil(d/60)*60}function r(s){const l=Math.floor(s/60),d=Math.floor(s%60);return l===0?`${d}s`:d===0?`${l}m`:`${l}:${d.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,d=>(e.openBlock(),e.createElementBlock("div",{key:d.time,class:"time-mark",style:e.normalizeStyle({left:d.position})},[e.createElementVNode("span",k3,e.toDisplayString(d.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:d.major}])},null,2)],4))),128))],4))}}),E3=Be(_3,[["__scopeId","data-v-0ef9c910"]]),x3=["data-track-index"],S3={class:"track-header"},C3={class:"track-label"},V3={class:"track-controls"},N3=["data-testid","aria-label"],T3=["data-testid","onMousedown","onClick"],M3={class:"clip-content"},B3={class:"clip-name"},I3={key:0,class:"clip-thumbnail"},F3=["src","alt"],$3=["onMousedown","aria-label"],D3=["onMousedown","aria-label"],R3=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(null),d=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function c(k){const V=k.timelineEnd-k.timelineStart,B=k.timelineStart/t.duration*100,_=V/t.duration*100;return{left:`${B}%`,width:`${_}%`,backgroundColor:u(k)}}function u(k){const V=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],B=parseInt(k.id.replace(/\D/g,""))%V.length;return V[B]}function f(k){return k.label?k.label:k.url?(k.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${k.id.slice(-4)}`}function m(k){i.value=k.id,o("clip-select",k.id)}function p(){r.value=!r.value}function h(k,V){if(l.value)return;s.value=!0;const B=V.clientX,_=k.timelineStart,g=C=>{if(!s.value)return;const N=C.clientX-B,S=parseFloat(d.value.width),A=N/(t.zoom*100)*(t.duration/S),Z=Math.max(0,_+A);o("clip-move",k.id,Z)},E=()=>{s.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",E)}function v(k,V,B){l.value=V;const _=B.clientX,g=k.sourceIn,E=k.sourceOut,C=S=>{if(!l.value)return;const A=S.clientX-_,Z=parseFloat(d.value.width),x=A/(t.zoom*100)*(t.duration/Z);if(l.value==="start"){const F=Math.max(0,g+x);o("clip-trim",k.id,F,E)}else{const F=Math.max(g+1,E+x);o("clip-trim",k.id,g,F)}},N=()=>{l.value=null,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",N)}return(k,V)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":k.trackIndex},[e.createElementVNode("div",S3,[e.createElementVNode("span",C3,"Track "+e.toDisplayString(k.trackIndex+1),1),e.createElementVNode("div",V3,[k.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${k.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${k.trackIndex+1}`,onClick:p},[e.createVNode(e.unref(W.IonIcon),{icon:r.value?e.unref(Uh):e.unref(Ph)},null,8,["icon"])],8,N3)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.clips,B=>(e.openBlock(),e.createElementBlock("div",{key:B.id,class:e.normalizeClass(["timeline-clip",{selected:B.id===i.value}]),style:e.normalizeStyle(c(B)),"data-testid":`clip-${B.id}`,onMousedown:_=>h(B,_),onClick:_=>m(B)},[e.createElementVNode("div",M3,[e.createElementVNode("span",B3,e.toDisplayString(f(B)),1),B.thumbnail?(e.openBlock(),e.createElementBlock("div",I3,[e.createElementVNode("img",{src:B.thumbnail,alt:f(B)},null,8,F3)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(_=>v(B,"start",_),["stop"]),"aria-label":`Trim start of ${f(B)}`},null,40,$3),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(_=>v(B,"end",_),["stop"]),"aria-label":`Trim end of ${f(B)}`},null,40,D3)],46,T3))),128))],4)],8,x3))}}),A3=Be(R3,[["__scopeId","data-v-48e480d2"]]),L3={class:"video-timeline"},P3={class:"timeline-tracks"},O3=["aria-label","aria-valuenow","aria-valuemax"],U3={class:"timeline-controls"},z3={class:"zoom-level"},j3=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),d=e.computed(()=>{const _=Math.max(0,...t.clips.map(g=>g.track||0));return Array(_+1).fill(null)}),c=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(_){return t.clips.filter(g=>(g.track||0)===_)}function f(_){const g=Math.floor(_/60),E=Math.floor(_%60);return`${g}:${E.toString().padStart(2,"0")}`}function m(_,g){o("clip-move",_,g)}function p(_,g,E){o("clip-trim",_,g,E)}function h(_){r.value=_}function v(){i.value=Math.min(i.value*1.2,5)}function k(){i.value=Math.max(i.value/1.2,.5)}function V(){s.value=!0;const _=E=>{if(!s.value||!l.value)return;const C=l.value.getBoundingClientRect(),A=Math.max(0,Math.min(E.clientX-C.left,C.width))/C.width*t.duration;o("seek",A)},g=()=>{s.value=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",g)}function B(_){let g=t.currentTime;switch(_.key){case"ArrowLeft":g=Math.max(0,t.currentTime-1);break;case"ArrowRight":g=Math.min(t.duration,t.currentTime+1);break;case"Home":g=0;break;case"End":g=t.duration;break;default:return}_.preventDefault(),o("seek",g)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(_,g)=>(e.openBlock(),e.createElementBlock("div",L3,[e.createVNode(E3,{duration:_.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",P3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(E,C)=>(e.openBlock(),e.createBlock(A3,{key:`track-${C}`,"data-testid":`track-${C}`,clips:u(C),"track-index":C,zoom:i.value,duration:_.duration,onClipMove:m,onClipTrim:p,onClipSelect:h},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:c.value}),onMousedown:V,"data-testid":"playhead","aria-label":`Playhead at ${f(_.currentTime)}`,role:"slider","aria-valuenow":_.currentTime,"aria-valuemax":_.duration,tabindex:"0",onKeydown:B},null,44,O3),e.createElementVNode("div",U3,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:v},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zl)},null,8,["icon"])]),e.createElementVNode("span",z3,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:k},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Fh)},null,8,["icon"])])])]))}}),W3=Be(j3,[["__scopeId","data-v-001df415"]]),Z3={class:"video-filters-panel"},H3={class:"filter-controls"},X3=["for"],G3={class:"filter-slider-group"},J3=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],K3={class:"filter-value"},q3={class:"filter-actions"},Y3={key:0,class:"filter-presets"},Q3={class:"preset-list"},eM=["data-testid","aria-label","onClick"],tM=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(n,{emit:a}){const t=a,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((m,p)=>(m[p.type]=p.default,m),{})),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(m,p){switch(m){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(m){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(m)}function d(m){if(!l(m))return;const p={id:`filter-${m}`,filterId:m,params:{value:i[m]},intensity:1};t("filter-change",p)}function c(){o.forEach(m=>{i[m.type]=m.default,d(m.type)})}function u(){const m=prompt("Enter preset name:");if(!m)return;const p={id:`custom-${Date.now()}`,name:m,values:{...i}};r.value.push(p)}function f(m){Object.entries(m.values).forEach(([p,h])=>{i[p]=h,d(p)})}return(m,p)=>(e.openBlock(),e.createElementBlock("div",Z3,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",H3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,h=>e.createElementVNode("div",{key:h.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${h.type}`},e.toDisplayString(h.label),9,X3),e.createElementVNode("div",G3,[e.withDirectives(e.createElementVNode("input",{id:`filter-${h.type}`,"onUpdate:modelValue":v=>i[h.type]=v,type:"range",min:h.min,max:h.max,step:h.step,class:"filter-slider","data-testid":`filter-${h.type}`,"aria-label":`${h.label} filter`,"aria-valuenow":i[h.type],"aria-valuemin":h.min,"aria-valuemax":h.max,onInput:v=>d(h.type)},null,40,J3),[[e.vModelText,i[h.type],void 0,{number:!0}]]),e.createElementVNode("span",K3,e.toDisplayString(s(h.type,i[h.type])),1)])])),64))]),e.createElementVNode("div",q3,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:c},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn)},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(W.IonIcon),{icon:e.unref(Pr)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",Y3,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",Q3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,h=>(e.openBlock(),e.createElementBlock("button",{key:h.id,class:"preset-btn","data-testid":`preset-${h.id}`,"aria-label":`Apply ${h.name} preset`,onClick:v=>f(h)},e.toDisplayString(h.name),9,eM))),128))])])):e.createCommentVNode("",!0)]))}}),aM=Be(tM,[["__scopeId","data-v-5ad2ac63"]]),nM={class:"video-text-panel"},oM={class:"text-input-group"},iM={class:"text-options"},rM={class:"option-row"},sM={class:"option-row"},lM={class:"option-row"},dM={class:"option-row"},cM={class:"checkbox-label"},uM={class:"option-row"},mM={class:"text-overlay-list"},pM={key:0,class:"empty-state"},fM=["data-testid"],hM={class:"overlay-preview"},vM={class:"overlay-controls"},gM=["data-testid","aria-label","onClick"],yM=["data-testid","aria-label","onClick"],bM=["data-testid","aria-label","onClick"],wM=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(n,{emit:a}){const t=a,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 c={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&&(c.backgroundColor=i.backgroundColor),i.animation!=="none"&&(c.animation=i.animation),o.value.push(c),t("text-add",c),i.text=""}function s(c){const u=o.value.findIndex(f=>f.id===c);u!==-1&&(o.value.splice(u,1),t("text-remove",c))}function l(c){i.text=c.text,i.fontFamily=c.fontFamily||"Arial",i.fontSize=c.fontSize,i.color=c.color,i.backgroundColor=c.backgroundColor||"#000000",i.hasBackground=!!c.backgroundColor,i.animation=c.animation||"none",s(c.id)}function d(c){const u={...c,id:`text-${Date.now()}`,x:c.x+10,y:c.y+10};o.value.push(u),t("text-add",u)}return(c,u)=>(e.openBlock(),e.createElementBlock("div",nM,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",oM,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=f=>i.text=f),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zl)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",iM,[e.createElementVNode("div",rM,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=f=>i.fontFamily=f),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,i.fontFamily]])]),e.createElementVNode("div",sM,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=f=>i.fontSize=f),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",lM,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=f=>i.color=f),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",dM,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=f=>i.backgroundColor=f),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",cM,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=f=>i.hasBackground=f),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",uM,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=f=>i.animation=f),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,i.animation]])])]),e.createElementVNode("div",mM,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",pM," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(f,m)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${m}`},[e.createElementVNode("div",hM,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:f.fontFamily,fontSize:`${Math.min(f.fontSize/4,16)}px`,color:f.color})},e.toDisplayString(f.text),5)]),e.createElementVNode("div",vM,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${f.text}`,onClick:p=>l(f)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(ph)},null,8,["icon"])],8,gM),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:p=>d(f)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(el)},null,8,["icon"])],8,yM),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${f.text}`,onClick:p=>s(f.id)},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(wr)},null,8,["icon"])],8,bM)])],8,fM))),128))])]))}}),kM=Be(wM,[["__scopeId","data-v-4d240e1e"]]),_M={class:"video-tools-panel"},EM={class:"tool-tabs"},xM=["data-testid","aria-label","aria-selected","onClick"],SM={class:"tool-content"},CM={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},VM={class:"trim-actions"},NM={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},TM={class:"transition-types"},MM=["data-testid","aria-label","onClick"],BM={class:"transition-preview"},IM=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(n){const a=[{id:"trim",name:"Trim",icon:br},{id:"filters",name:"Filters",icon:pn},{id:"text",name:"Text",icon:Fu},{id:"transitions",name:"Transitions",icon:Kd}],t=[{id:"fade",name:"Fade",icon:Is},{id:"slide-left",name:"Slide Left",icon:rh},{id:"slide-right",name:"Slide Right",icon:sh},{id:"dissolve",name:"Dissolve",icon:Is},{id:"wipe",name:"Wipe",icon:Kd},{id:"zoom",name:"Zoom",icon:Is}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",_M,[e.createElementVNode("div",EM,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,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(W.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,xM)),64))]),e.createElementVNode("div",SM,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",CM,[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",VM,[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(W.IonIcon),{icon:e.unref(Gd)},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(W.IonIcon),{icon:e.unref(Gd)},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(W.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(aM,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(kM,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",NM,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",TM,[(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",BM,[e.createVNode(e.unref(W.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,MM)),64))])])):e.createCommentVNode("",!0)])]))}}),FM=Be(IM,[["__scopeId","data-v-fc135306"]]),$M={class:"video-export-panel"},DM={class:"export-presets"},RM=["value"],AM={key:0,class:"preset-details"},LM={class:"detail-row"},PM={class:"detail-row"},OM={class:"detail-row"},UM={class:"advanced-options"},zM={class:"options-content"},jM={class:"option-group"},WM={class:"option-group"},ZM={class:"option-group"},HM=["disabled"],XM={key:1,class:"export-progress"},GM={class:"progress-message"},JM={class:"progress-bar"},KM=["aria-valuenow"],qM={class:"progress-percentage"},YM=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(n,{emit:a}){const t=n,o=a,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(c=>c.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 d(){s.value&&o("export",{...s.value,options:{...r}})}return(c,u)=>(e.openBlock(),e.createElementBlock("div",$M,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",DM,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=f=>i.value=f),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,RM))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",AM,[e.createElementVNode("div",LM,[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",PM,[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",OM,[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",UM,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",zM,[e.createElementVNode("div",jM,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=f=>r.quality=f),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,r.quality]])]),e.createElementVNode("div",WM,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=f=>r.bitrate=f),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",ZM,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=f=>r.includeAudio=f),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:c.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:d},[c.isExporting?(e.openBlock(),e.createBlock(e.unref(W.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(vo)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,HM),c.isExporting?(e.openBlock(),e.createElementBlock("div",XM,[e.createElementVNode("div",GM,e.toDisplayString(l.value),1),e.createElementVNode("div",JM,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${c.exportProgress}%`}),role:"progressbar","aria-valuenow":c.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,KM)]),e.createElementVNode("div",qM,e.toDisplayString(c.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),QM=Be(YM,[["__scopeId","data-v-5caf8fe6"]]),eB=["data-testid"],tB={class:"progress-header"},aB={class:"file-info"},nB={class:"file-details"},oB={class:"file-name"},iB={class:"file-meta"},rB={class:"file-size"},sB={key:0,class:"separator"},lB={key:1,class:"upload-speed"},dB={key:2,class:"separator"},cB={key:3,class:"time-remaining"},uB={class:"progress-actions"},mB={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},pB={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},fB={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},hB=["aria-valuenow","aria-label"],vB={class:"progress-bar"},gB={class:"progress-percent"},yB={key:1,class:"error-message","data-testid":"video-upload-error"},bB={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},wB=["src","alt"],kB={key:0,class:"video-duration"},_B=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(n){const a=n,t=e.computed(()=>({"is-uploading":a.upload.status==="uploading","is-processing":a.upload.status==="processing","is-completed":a.upload.status==="completed","is-error":a.upload.status==="error","is-pending":a.upload.status==="pending"})),o=e.computed(()=>$u),i=e.computed(()=>["uploading","processing"].includes(a.upload.status)),r=e.computed(()=>(a.upload.status==="processing",a.upload.progress||0)),s=e.computed(()=>{if(!a.upload.timeRemaining||a.upload.status!=="uploading")return null;const m=a.upload.timeRemaining;if(m<60)return`${Math.round(m)}s`;const p=Math.floor(m/60);return p<60?`${p}m ${Math.round(m%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),l=e.computed(()=>{var m;return a.upload.status==="completed"&&((m=a.upload.media)!=null&&m.thumbnail_url)?a.upload.media.thumbnail_url:null}),d=e.computed(()=>{var m;return(m=a.upload.media)==null?void 0:m.duration});function c(m){if(m===0)return"0 B";const p=["B","KB","MB","GB","TB"],h=1024,v=Math.floor(Math.log(m)/Math.log(h));return`${(m/Math.pow(h,v)).toFixed(1)} ${p[v]}`}function u(m){if(m===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],h=1024,v=Math.floor(Math.log(m)/Math.log(h));return`${(m/Math.pow(h,v)).toFixed(1)} ${p[v]}`}function f(m){const p=Math.floor(m/3600),h=Math.floor(m%3600/60),v=Math.floor(m%60);return p>0?`${p}:${h.toString().padStart(2,"0")}:${v.toString().padStart(2,"0")}`:`${h}:${v.toString().padStart(2,"0")}`}return(m,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${m.upload.id}`},[e.createElementVNode("div",tB,[e.createElementVNode("div",aB,[e.createVNode(e.unref(W.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",nB,[e.createElementVNode("h4",oB,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",iB,[e.createElementVNode("span",rB,e.toDisplayString(c(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",sB,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",lB,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",dB,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",cB,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",uB,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",mB,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Tu)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",pB,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(ih),"aria-hidden":"true"},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",fB,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=h=>m.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Un),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=h=>m.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=h=>m.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Un),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":m.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",vB,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",gB,e.toDisplayString(Math.round(r.value))+"%",1)],8,hB)):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",yB,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zh)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(m.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",bB,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,wB),d.value?(e.openBlock(),e.createElementBlock("div",kB,e.toDisplayString(f(d.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,eB))}}),EB=Be(_B,[["__scopeId","data-v-9eacbf91"]]),Hs=4,xB=500,SB=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function cs(n){return typeof n=="object"&&n!==null}function au(n){return cs(n)?typeof n.upload_url=="string"&&typeof n.upload_id=="string"&&typeof n.media_uuid=="string"&&typeof n.expires_at=="string":!1}function CB(n){if(au(n))return n;if(cs(n)&&au(n.data))return n.data;throw new Error("Invalid upload response from backend")}function nu(n){return cs(n)?typeof n.uuid=="string"&&typeof n.processing_status=="string":!1}function VB(n){if(nu(n))return n;if(cs(n)&&nu(n.data))return n.data;throw new Error("Invalid media response from backend")}function Yi(n){return n?{...n}:{}}function ou(n,a="PUT"){return typeof n.method=="string"&&n.method.trim()!==""?n.method.trim().toUpperCase():a}function NB(n){return n.resumable===!0?!0:/tusupload/i.test(n.upload_url)}function TB(n){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(n)))}catch{return btoa(n)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function MB(n,a){return[["filename",n.filename],["filetype",n.file.type||"application/octet-stream"],["uploadid",a.upload_id],["mediauuid",a.media_uuid]].map(([o,i])=>`${o} ${TB(i)}`).join(",")}function Qi(n,a){const t=Math.max(n.bytesTotal,1);n.bytesUploaded=a,n.progress=Math.min(100,a/t*100);const o=Math.max((Date.now()-n.startedAt.getTime())/1e3,.001);n.uploadSpeed=a/o;const i=Math.max(t-a,0);n.timeRemaining=i/Math.max(n.uploadSpeed,1)}function BB(n,a){return n instanceof Error?n:new Error(a)}function IB(n){if(!(n instanceof Error))return!1;const a=n.message.toLowerCase();return a.includes("failed to fetch")||a.includes("networkerror")||a.includes("network request failed")||a.includes("err_ssl_")}function iu(n){const a=Math.max(0,n-1),t=xB*Math.pow(2,a);return Math.min(5e3,t)}function ru(n){return new Promise(a=>{window.setTimeout(a,n)})}async function su(n,a){for(let t=1;t<=Hs;t+=1)try{const o=await a();if(o.ok||!SB.has(o.status)||t>=Hs)return o;await ru(iu(t))}catch(o){if(!IB(o)||t>=Hs)throw o;await ru(iu(t))}throw new Error(`${n} failed after retry attempts`)}function FB(n={}){const a=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(a.value.values())),d=e.computed(()=>{const x=Array.from(a.value.values());return x.length===0?0:x.reduce((b,R)=>b+R.progress,0)/x.length});function c(x){o.value=x}function u(){}async function f(x){var b;const F=x.filter(R=>m(R));if(F.length!==0&&((b=n.onFilesSelected)==null||b.call(n,F),n.autoUpload!==!1))for(const R of F)await p(R)}function m(x){return!(n.maxFileSize&&x.size>n.maxFileSize||n.allowedFormats&&n.allowedFormats.length>0&&!n.allowedFormats.includes(x.type))}async function p(x){var R,P,O;const F=Z(x);if(a.value.has(F)){const U=a.value.get(F);if((U==null?void 0:U.status)==="uploading")return}const b={id:F,file:x,filename:x.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:x.size,bytesUploaded:0};a.value.set(b.id,b),t.value.add(b.id);try{b.status="uploading",(R=n.onUploadStart)==null||R.call(n,b);const U=await h(x);n.resumable===!0||U.resumable===!0?await k(b,U):await v(b,U),b.status="processing",b.progress=100;const I=await E(U.media_uuid);b.status="completed",b.media=I,(P=n.onUploadComplete)==null||P.call(n,I)}catch(U){if(b.status!=="cancelled"){const M=BB(U,"Upload failed");b.status="error",b.error=M.message,(O=n.onUploadError)==null||O.call(n,M,b)}}finally{t.value.delete(b.id),i.delete(b.id),r.delete(b.id)}}async function h(x){if(!o.value)throw new Error("API client not configured");const F={collection:n.collection||"videos",filename:x.name,size:x.size,mime_type:x.type,...n.ownerUuid!==void 0?{ownerUuid:n.ownerUuid}:{},...n.ownerType!==void 0?{ownerType:n.ownerType}:{}},b=await o.value.post("/api/v1/video/upload",F);return CB(b)}async function v(x,F){const b=new XMLHttpRequest,R=ou(F),P=Yi(F.headers);return new Promise((O,U)=>{b.upload.addEventListener("progress",M=>{var I;M.lengthComputable&&(Qi(x,M.loaded),(I=n.onUploadProgress)==null||I.call(n,x))}),b.addEventListener("load",()=>{i.delete(x.id),b.status>=200&&b.status<300?O():U(new Error(`Upload failed with status ${b.status}`))}),b.addEventListener("error",()=>{i.delete(x.id),U(new Error("Upload failed"))}),b.addEventListener("abort",()=>{i.delete(x.id),U(new Error("Upload cancelled"))}),b.open(R,F.upload_url),Object.entries(P).forEach(([M,I])=>{b.setRequestHeader(M,I)}),!Object.keys(P).some(M=>M.toLowerCase()==="content-type")&&x.file.type&&b.setRequestHeader("Content-Type",x.file.type),i.set(x.id,b),b.send(x.file)})}async function k(x,F){var U;if(NB(F)){await V(x,F);return}const b=n.chunkSize||5*1024*1024,R=B(x.file,b),P=new AbortController;r.set(x.id,P);const O=await g(F.upload_id);O&&(R.forEach(M=>{M.end<=O.bytesUploaded&&(M.uploaded=!0)}),Qi(x,O.bytesUploaded));for(const M of R)M.uploaded||(await _(x,F,M,P),Qi(x,M.end),(U=n.onUploadProgress)==null||U.call(n,x))}async function V(x,F){var z;const b=new AbortController;r.set(x.id,b);const R={...Yi(F.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(x.file.size),"Upload-Metadata":MB(x,F)},P=await su("Resumable upload initialization",()=>fetch(F.upload_url,{method:"POST",headers:R,signal:b.signal}));if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const O=P.headers.get("Location");if(!O)throw new Error("Resumable upload endpoint did not return upload location");const U=new URL(O,F.upload_url).toString(),M=n.chunkSize||5*1024*1024;let I=0;for(;I<x.file.size;){const X=Math.min(I+M,x.file.size),le=x.file.slice(I,X),ve={...Yi(F.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(I),"Content-Type":"application/offset+octet-stream"},ie=await su("Resumable chunk upload",()=>fetch(U,{method:"PATCH",headers:ve,body:le,signal:b.signal}));if(ie.status===409){const L=Number(ie.headers.get("Upload-Offset")??"-1");if(Number.isFinite(L)&&L>=0){I=L;continue}}if(!ie.ok)throw new Error(`Resumable chunk upload failed: ${ie.status}`);const ne=Number(ie.headers.get("Upload-Offset")??String(X));I=Number.isFinite(ne)&&ne>I?ne:X,Qi(x,I),(z=n.onUploadProgress)==null||z.call(n,x)}}function B(x,F){const b=[];let R=0,P=0;for(;R<x.size;){const O=Math.min(R+F,x.size);b.push({start:R,end:O,blob:x.slice(R,O),index:P,uploaded:!1}),R=O,P++}return b}async function _(x,F,b,R){const P={...Yi(F.headers),"Content-Range":`bytes ${b.start}-${b.end-1}/${x.file.size}`,"Content-Type":x.file.type||"application/octet-stream"},O=await fetch(F.upload_url,{method:ou(F),headers:P,body:b.blob,signal:R.signal});if(!O.ok)throw new Error(`Chunk upload failed: ${O.status}`);b.uploaded=!0}async function g(x){return null}async function E(x){if(!o.value)throw new Error("API client not configured");const F=60;let b=0;for(;b<F;){const R=await o.value.get(`/api/v1/video/${x}`),P=VB(R),O=String(P.processing_status);if(O==="ready")return P;if(O==="failed"||O==="error")throw new Error("Video processing failed");await new Promise(U=>{window.setTimeout(U,5e3)}),b++}throw new Error("Video processing timeout")}function C(x){const F=a.value.get(x);if(!F)return;const b=i.get(x);b&&(b.abort(),i.delete(x));const R=r.get(x);R&&(R.abort(),r.delete(x)),F.status="cancelled",F.error="Upload cancelled",t.value.delete(x)}async function N(x){const F=a.value.get(x);F&&(F.status="pending",F.error="",F.progress=0,F.bytesUploaded=0,await p(F.file))}function S(x){a.value.delete(x),t.value.delete(x),i.delete(x),r.delete(x)}function A(){Array.from(a.value.entries()).forEach(([x,F])=>{F.status==="completed"&&a.value.delete(x)})}function Z(x){return`${x.name}-${x.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:d,openFilePicker:u,handleFileSelect:f,validateFile:m,startUpload:p,cancelUpload:C,retryUpload:N,removeUpload:S,clearCompleted:A,setApiClient:c}}const $B=["accept","multiple"],DB={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},RB=["onKeydown"],AB={key:1,class:"upload-list","data-testid":"video-upload-list"},LB={class:"drag-content"},PB=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:d,cancelUpload:c,retryUpload:u,removeUpload:f,setApiClient:m}=FB({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:g=>o("upload-start",g),onUploadProgress:g=>o("upload-progress",g),onUploadComplete:g=>o("upload-complete",g),onUploadError:(g,E)=>o("upload-error",g,E),onFilesSelected:g=>o("files-selected",g)});t.apiClient&&m(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),h=e.computed(()=>t.multiple||s.value.length===0);function v(){i.value&&i.value.click()}function k(g){const E=g.target,C=Array.from(E.files||[]);C.length>0&&(d(C),E.value="")}function V(g){var N;g.preventDefault(),r.value=!1;const C=Array.from(((N=g.dataTransfer)==null?void 0:N.files)||[]).filter(S=>S.type.startsWith("video/"));C.length>0&&d(C)}function B(g){var E;g.preventDefault(),(E=g.dataTransfer)!=null&&E.types.includes("Files")&&(r.value=!0)}function _(g){g.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",B),document.addEventListener("dragleave",_),document.addEventListener("drop",g=>g.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",B),document.removeEventListener("dragleave",_),document.removeEventListener("drop",g=>g.preventDefault())}),(g,E)=>(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:g.multiple,onChange:k,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,$B),!e.unref(l)||h.value?(e.openBlock(),e.createElementBlock("div",DB,[e.renderSlot(g.$slots,"trigger",{open:v},()=>[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:v,onKeydown:[e.withKeys(v,["enter"]),e.withKeys(e.withModifiers(v,["prevent"]),["space"])]},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref($u),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(g.label),1),e.createElementVNode("p",null,e.toDisplayString(g.description),1),e.createVNode(e.unref(W.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(zl),slot:"start","aria-hidden":"true"},null,8,["icon"]),E[2]||(E[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,RB)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",AB,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),C=>(e.openBlock(),e.createBlock(EB,{key:C.id,upload:C,onCancel:N=>e.unref(c)(C.id),onRetry:N=>e.unref(u)(C.id),onRemove:N=>e.unref(f)(C.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:V,onDragover:E[0]||(E[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:E[1]||(E[1]=C=>r.value=!1)},[e.createElementVNode("div",LB,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(vo),"aria-hidden":"true"},null,8,["icon"]),E[3]||(E[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),OB=Be(PB,[["__scopeId","data-v-ea7587f7"]]),UB=["aria-valuenow","aria-valuemax","aria-label"],zB={class:"progress-bar"},jB={class:"time-display","data-testid":"video-time-display"},WB={class:"current-time"},ZB={class:"duration"},HB={class:"control-buttons"},XB={class:"controls-left"},GB=["aria-label"],JB={class:"controls-center"},KB={key:0,class:"volume-controls"},qB=["aria-label"],YB=["value"],QB={class:"controls-right"},e5={key:0,class:"quality-selector"},t5=["aria-expanded"],a5={class:"quality-label"},n5={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},o5=["data-testid","aria-label","onClick"],i5=["aria-label"],r5=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(!0),r=e.ref(!1),s=e.ref(),l=W.isPlatform("mobile"),d="pictureInPictureEnabled"in document,c=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),f=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let g=0;g<t.buffered.length;g++){const E=t.buffered.start(g),C=t.buffered.end(g);if(t.currentTime>=E&&t.currentTime<=C)return{width:`${C/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),m=e.computed(()=>t.muted||t.volume===0?Oh:t.volume<33?Ah:t.volume<66?Lh:Rh);let p=null;function h(){i.value=!0,v()}function v(){p&&clearTimeout(p),t.playing&&!l&&(p=setTimeout(()=>{i.value=!1},3e3))}function k(g){if(!s.value||t.isLive)return;const E=s.value.getBoundingClientRect(),N=(g.clientX-E.left)/E.width*t.duration;o("seek",Math.max(0,Math.min(N,t.duration)))}function V(g){const E=g.target;o("setVolume",parseInt(E.value))}function B(g){o("selectQuality",g),r.value=!1}function _(g){if(!isFinite(g))return"0:00";const E=Math.floor(g/3600),C=Math.floor(g%3600/60),N=Math.floor(g%60);return E>0?`${E}:${C.toString().padStart(2,"0")}:${N.toString().padStart(2,"0")}`:`${C}:${N.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",h),v()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",h),p&&clearTimeout(p)}),(g,E)=>(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(g.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(g.duration),"aria-label":g.isLive?"Live stream":"Video progress",tabindex:"0",onClick:k},[e.createElementVNode("div",zB,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(c.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",jB,[e.createElementVNode("span",WB,e.toDisplayString(_(g.currentTime)),1),E[7]||(E[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",ZB,e.toDisplayString(g.isLive?"LIVE":_(g.duration)),1)])],8,UB),e.createElementVNode("div",HB,[e.createElementVNode("div",XB,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:E[0]||(E[0]=C=>g.$emit("play-pause")),"aria-label":g.playing?"Pause":"Play"},[e.createVNode(e.unref(W.IonIcon),{icon:g.playing?e.unref(_h):e.unref(xh),"aria-hidden":"true"},null,8,["icon"])],8,GB),g.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:E[1]||(E[1]=C=>g.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Sh),"aria-hidden":"true"},null,8,["icon"]),E[8]||(E[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),g.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:E[2]||(E[2]=C=>g.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Nh),"aria-hidden":"true"},null,8,["icon"]),E[9]||(E[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",JB,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",KB,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:E[3]||(E[3]=C=>g.$emit("toggleMute")),"aria-label":g.muted?"Unmute":"Mute"},[e.createVNode(e.unref(W.IonIcon),{icon:m.value,"aria-hidden":"true"},null,8,["icon"])],8,qB),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:g.muted?0:g.volume,onInput:V,"aria-label":"Volume"},null,40,YB)]))]),e.createElementVNode("div",QB,[g.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",e5,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:E[4]||(E[4]=C=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref($h),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",a5,e.toDisplayString(g.currentQuality),1)],8,t5),r.value?(e.openBlock(),e.createElementBlock("div",n5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.qualityLevels,C=>(e.openBlock(),e.createElementBlock("button",{key:C.label,class:e.normalizeClass(["quality-option",{active:C.label===g.currentQuality}]),"data-testid":`btn-video-quality-${C.label}`,"aria-label":`Set quality to ${C.label}`,role:"menuitem",onClick:N=>B(C)},e.toDisplayString(C.label),11,o5))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&d?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:E[5]||(E[5]=C=>g.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Dh),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:E[6]||(E[6]=C=>g.$emit("toggleFullscreen")),"aria-label":g.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(W.IonIcon),{icon:g.fullscreen?e.unref(mh):e.unref(hh),"aria-hidden":"true"},null,8,["icon"])],8,i5)])])],2))}}),s5=Be(r5,[["__scopeId","data-v-2ae77c13"]]);function l5(n={}){var le,ve,ie;const a=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(n.muted||!1),d=e.ref(!1),c=e.ref(),u=e.ref(1),f=e.ref(!1),m=e.ref(null),p=e.ref("idle"),h=e.ref(n.playbackUrl||((le=n.media)==null?void 0:le.playback_url)||((ve=n.media)==null?void 0:ve.url)||""),v=e.ref(null),k=e.ref(n.isLive||!1),V=e.ref(null),B=e.ref(null);function _(ne){B.value=ne}if((ie=n.media)!=null&&ie.token_expires_at){const ne=new Date(n.media.token_expires_at);v.value=Number.isNaN(ne.getTime())?null:ne}async function g(){var L;const ne=k.value?t.value:a.value;if(ne)try{await ne.play(),o.value=!0,p.value=k.value?"live":"playing",(L=n.onPlay)==null||L.call(n)}catch{m.value="Failed to play video",p.value="error"}}function E(){var L;const ne=k.value?t.value:a.value;ne&&(ne.pause(),o.value=!1,p.value="paused",(L=n.onPause)==null||L.call(n))}function C(){o.value?E():g()}function N(ne){const L=k.value?t.value:a.value;if(!L||k.value)return;const D=Number.isFinite(L.duration)?L.duration:ne;L.currentTime=Math.max(0,Math.min(ne,D)),i.value=L.currentTime}function S(ne=10){const L=a.value;!L||k.value||N(L.currentTime+ne)}function A(ne=10){const L=a.value;!L||k.value||N(L.currentTime-ne)}function Z(){const ne=k.value?t.value:a.value;ne&&(ne.muted=!ne.muted,l.value=ne.muted)}function x(ne){const L=k.value?t.value:a.value;if(!L)return;const D=Math.max(0,Math.min(100,ne));L.volume=D/100,s.value=D,D>0&&L.muted&&(L.muted=!1,l.value=!1)}function F(ne){const L=a.value;!L||k.value||(L.playbackRate=ne,u.value=ne)}async function b(){const ne=document.querySelector(".video-player-container");if(ne)try{document.fullscreenElement?(await document.exitFullscreen(),d.value=!1):(await ne.requestFullscreen(),d.value=!0)}catch{}}async function R(){const ne=k.value?t.value:a.value;if(ne)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ne.requestPictureInPicture()}catch{}}async function P(){var L;m.value=null,p.value="loading",(L=n.media)!=null&&L.provider&&n.media.provider!=="local"&&await O();const ne=k.value?t.value:a.value;ne&&(ne.load(),await g())}async function O(){if(!(!B.value||!n.media))try{f.value=!0;const ne=await B.value.get(`/api/v1/video/${n.media.uuid}/playback`);h.value=ne.playback_url,v.value=new Date(ne.token_expires_at);const L=k.value?t.value:a.value;if(L&&L.src!==h.value){const D=!L.paused,j=L.currentTime;L.src=h.value,k.value||(L.currentTime=j),D&&await g()}}catch{m.value="Failed to refresh playback token",p.value="error"}finally{f.value=!1}}async function U(ne){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ne;return}try{t.value.src=ne}catch{m.value="Live streaming not supported in this browser",p.value="error"}}}function M(){V.value&&(V.value.destroy(),V.value=null)}function I(){var L;const ne=k.value?t.value:a.value;ne&&(i.value=ne.currentTime,r.value=ne.duration,(L=n.onTimeUpdate)==null||L.call(n,ne.currentTime))}const z=e.computed(()=>{if(!c.value||c.value.length===0||!r.value)return 0;for(let ne=0;ne<c.value.length;ne++){const L=c.value.start(ne),D=c.value.end(ne);if(i.value>=L&&i.value<=D)return D/r.value*100}return 0});function X(){if(!v.value)return!1;const ne=new Date;return v.value.getTime()-ne.getTime()<5*60*1e3}return e.watch([a,t],([ne,L])=>{const D=k.value?L:ne;D&&(D.addEventListener("timeupdate",I),D.addEventListener("loadedmetadata",()=>{r.value=D.duration,p.value="ready"}),D.addEventListener("progress",()=>{c.value=D.buffered}),D.addEventListener("ended",()=>{var j;o.value=!1,p.value="ended",(j=n.onEnded)==null||j.call(n)}),D.addEventListener("error",j=>{var q;p.value="error",(q=n.onError)==null||q.call(n,"Video playback error")}),D.volume=s.value/100,D.muted=l.value)}),e.onUnmounted(()=>{M();const ne=k.value?t.value:a.value;ne&&ne.removeEventListener("timeupdate",I)}),{videoEl:a,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:d,bufferedRanges:c,bufferedPercent:z,playbackRate:u,isLoading:f,error:m,status:p,currentPlaybackUrl:h,tokenExpiresAt:v,play:g,pause:E,togglePlayPause:C,seek:N,skipForward:S,skipBackward:A,toggleMute:Z,setVolume:x,setPlaybackRate:F,toggleFullscreen:b,togglePiP:R,retry:P,refreshToken:O,setupLiveStream:U,setApiClient:_,shouldRefreshToken:X}}const d5=["src","poster","controls","autoplay","muted","loop","preload"],c5={key:1,ref:"livePlayerEl",class:"live-player"},u5=["controls","muted"],m5={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},p5={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},f5={key:3,class:"video-error","data-testid":"video-error",role:"alert"},h5={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},v5=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(n,{emit:a}){const t=n,o=a,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:d,volume:c,muted:u,isFullscreen:f,bufferedRanges:m,isLoading:p,error:h,status:v,currentPlaybackUrl:k,tokenExpiresAt:V,play:B,pause:_,seek:g,toggleMute:E,setVolume:C,toggleFullscreen:N,togglePlayPause:S,skipForward:A,skipBackward:Z,retry:x,refreshToken:F,setApiClient:b,shouldRefreshToken:R,setupLiveStream:P}=l5({...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 O(){await F()}const U=e.computed(()=>{const q=["video-player-container"];return t.className&&q.push(t.className),f.value&&q.push("fullscreen"),t.isLive&&q.push("is-live"),s.value&&q.push("is-playing"),p.value&&q.push("is-loading"),q}),M=e.computed(()=>{var q,te;if(t.poster)return t.poster;if((q=t.media)!=null&&q.poster_url)return t.media.poster_url;if((te=t.media)!=null&&te.thumbnail_url)return t.media.thumbnail_url});function I(q){const te=q.target;o("loadedmetadata",{duration:te.duration,width:te.videoWidth,height:te.videoHeight})}function z(q){const te=q.target;l.value=te.currentTime,o("timeupdate",te.currentTime)}function X(){s.value=!0,o("play")}function le(){s.value=!1,o("pause")}function ve(){s.value=!1,o("ended")}function ie(q){const te=q.target;let ce="Failed to load video";if(te.error)switch(te.error.code){case te.error.MEDIA_ERR_ABORTED:ce="Video playback aborted";break;case te.error.MEDIA_ERR_NETWORK:ce="Network error while loading video";break;case te.error.MEDIA_ERR_DECODE:ce="Video decoding error";break;case te.error.MEDIA_ERR_SRC_NOT_SUPPORTED:ce="Video format not supported";break}h.value=ce,o("error",ce)}function ne(q){const te=q.target;m.value=te.buffered,o("progress",te.buffered)}function L(){p.value=!0}function D(){p.value=!1}e.watch(()=>t.apiClient,q=>{q&&b(q)},{immediate:!0}),e.watch(()=>t.playbackUrl,q=>{typeof q=="string"&&q.length>0&&(k.value=q)},{immediate:!0}),e.watch(()=>{var q;return(q=t.media)==null?void 0:q.token_expires_at},q=>{if(!q){V.value=null;return}const te=new Date(q);V.value=Number.isNaN(te.getTime())?null:te},{immediate:!0}),e.watch(()=>{var q;return(q=t.media)==null?void 0:q.playback_url},async(q,te)=>{if(t.playbackUrl||!q||q===te)return;const ce=i.value;if(!ce||t.isLive){k.value=q;return}const me=!ce.paused,ge=ce.currentTime;k.value=q,await e.nextTick();try{ce.currentTime=ge}catch{}me&&await B()},{immediate:!0});let j=null;return e.watch(()=>t.isLive,async q=>{var ce;if(!q)return;const te=t.playbackUrl||((ce=t.media)==null?void 0:ce.playback_url)||"";te&&await P(te)},{immediate:!0}),e.onMounted(()=>{var q;(q=t.media)!=null&&q.provider&&t.media.provider!=="local"&&(j=setInterval(()=>{R()&&O()},3e4)),W.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{j&&clearInterval(j)}),(q,te)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",U.value]),"data-testid":"video-player"},[q.isLive?(e.openBlock(),e.createElementBlock("div",c5,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:q.controls&&!q.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:X,onPause:le,onError:ie,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,u5),e.unref(v)==="live"?(e.openBlock(),e.createElementBlock("div",m5,[...te[3]||(te[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(k),poster:M.value,controls:q.controls&&!q.showCustomControls,autoplay:q.autoplay,muted:e.unref(u),loop:q.loop,preload:q.preload,onLoadedmetadata:I,onTimeupdate:z,onPlay:X,onPause:le,onEnded:ve,onError:ie,onProgress:ne,onWaiting:L,onCanplay:D,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,d5)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",p5,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",f5,[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(jl),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(h)),1),e.createVNode(e.unref(W.IonButton),{size:"small",onClick:e.unref(x),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{icon:e.unref(Xn),slot:"start","aria-hidden":"true"},null,8,["icon"]),te[4]||(te[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),q.showCustomControls&&!e.unref(h)?(e.openBlock(),e.createBlock(s5,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(d),buffered:e.unref(m),volume:e.unref(c),muted:e.unref(u),fullscreen:e.unref(f),isLive:q.isLive,onPlay:e.unref(B),onPause:e.unref(_),onSeek:e.unref(g),onToggleMute:e.unref(E),onSetVolume:e.unref(C),onToggleFullscreen:e.unref(N),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),q.enableGestures&&!e.unref(h)?(e.openBlock(),e.createElementBlock("div",h5,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:te[0]||(te[0]=(...ce)=>e.unref(Z)&&e.unref(Z)(...ce))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:te[1]||(te[1]=(...ce)=>e.unref(S)&&e.unref(S)(...ce))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:te[2]||(te[2]=(...ce)=>e.unref(A)&&e.unref(A)(...ce))},null,32)])):e.createCommentVNode("",!0)],2))}}),Np=Be(v5,[["__scopeId","data-v-b8db4951"]]),g5=Lr.defineStore("video",()=>{const n=e.ref(new Map),a=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(n.value.values())),s=e.computed(()=>Array.from(a.value.values())),l=e.computed(()=>s.value.filter(P=>P.status==="live")),d=e.computed(()=>r.value.filter(P=>P.processing_status==="processing"));function c(P){n.value.set(P.uuid,P)}function u(P,O){const U=n.value.get(P);U&&n.value.set(P,{...U,...O})}function f(P){n.value.delete(P)}function m(P){return n.value.get(P)}function p(P){a.value.set(P.id,P)}function h(P,O){const U=a.value.get(P);U&&a.value.set(P,{...U,...O})}function v(P,O){const U=a.value.get(P);U&&a.value.set(P,{...U,status:O.status,viewer_count:O.viewer_count,peak_viewers:O.peak_viewers})}function k(P){a.value.delete(P)}function V(P){return a.value.get(P)}function B(P){return s.value.find(O=>O.media_uuid===P)}function _(P){t.value.set(P.id,P)}function g(P,O){const U=t.value.get(P);U&&t.value.set(P,{...U,...O})}function E(P){t.value.delete(P)}function C(P){return t.value.get(P)}function N(P){return Array.from(t.value.values()).filter(O=>O.media_uuid===P)}function S(P){o.value=P}function A(P){o.value&&(o.value={...o.value,...P})}function Z(){o.value=null}function x(P){i.value=P}function F(){n.value.clear(),a.value.clear(),t.value.clear(),o.value=null,i.value=!1}function b(P){n.value.clear(),P.forEach(O=>{n.value.set(O.uuid,O)})}function R(P){a.value.clear(),P.forEach(O=>{a.value.set(O.id,O)})}return{videos:n,liveStreams:a,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:d,setVideo:c,updateVideo:u,removeVideo:f,getVideo:m,setLiveStream:p,updateLiveStream:h,updateLiveStreamStats:v,removeLiveStream:k,getLiveStream:V,getLiveStreamByMedia:B,addExportJob:_,updateExportJob:g,removeExportJob:E,getExportJob:C,getExportJobsByMedia:N,setEditorState:S,updateEditorState:A,clearEditorState:Z,setProcessing:x,clearAll:F,loadVideos:b,loadLiveStreams:R}});let $n=null;function y5(n){$n=n}const er={post:async(n,a)=>{if(!$n)throw new Error("HTTP client not configured");return await $n(`/api/v1/video${n}`,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"}})},get:async n=>{if(!$n)throw new Error("HTTP client not configured");return await $n(`/api/v1/video${n}`)},delete:async n=>{if(!$n)throw new Error("HTTP client not configured");return await $n(`/api/v1/video${n}`,{method:"DELETE"})}};function tr(n,a=null){const t=typeof n.id=="string"&&n.id!==""?n.id:typeof n.stream_id=="string"&&n.stream_id!==""?n.stream_id:a==null?void 0:a.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:n.media_uuid??(a==null?void 0:a.media_uuid)??"",stream_key:n.stream_key??(a==null?void 0:a.stream_key)??"",rtmp_url:n.rtmp_url??(a==null?void 0:a.rtmp_url)??"",status:n.status??(a==null?void 0:a.status)??"idle",viewer_count:n.viewer_count??(a==null?void 0:a.viewer_count)??0,peak_viewers:n.peak_viewers??(a==null?void 0:a.peak_viewers)??0,auto_record:n.auto_record??(a==null?void 0:a.auto_record)??!0,low_latency:n.low_latency??(a==null?void 0:a.low_latency)??!1},i=n.playback_url??(a==null?void 0:a.playback_url);i!==void 0&&(o.playback_url=i);const r=n.started_at??(a==null?void 0:a.started_at);r!==void 0&&(o.started_at=r);const s=n.ended_at??(a==null?void 0:a.ended_at);return s!==void 0&&(o.ended_at=s),(a==null?void 0:a.metadata)!==void 0&&(o.metadata=a.metadata),(a==null?void 0:a.vod_media_uuid)!==void 0&&(o.vod_media_uuid=a.vod_media_uuid),o}function Xs(n,a){return n instanceof Error&&n.message?n.message:a}function b5(n){const a=g5(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),d=e.ref(null),c=e.ref(null),u=e.ref(0),f=e.ref(0);let m;const p=e.computed(()=>c.value?Math.floor((new Date().getTime()-c.value.getTime())/1e3):0),h=e.computed(()=>{var Z;if(!((Z=t.value)!=null&&Z.playback_url))return null;const A=new URL(t.value.playback_url);return A.searchParams.set("live","true"),o.value&&A.searchParams.set("latency","low"),A.toString()}),v=e.computed(()=>{var A;return((A=t.value)==null?void 0:A.status)==="live"}),k=e.computed(()=>{var A;return((A=t.value)==null?void 0:A.status)==="idle"}),V=e.computed(()=>{var A;return((A=t.value)==null?void 0:A.status)==="ended"});async function B(A={}){s.value=!0,d.value=null;try{const Z=await er.post("/live",{title:r.value||A.title||"Live Stream",low_latency:A.low_latency??o.value,auto_record:A.auto_record??i.value,...A}),x=tr(Z);return t.value=x,a.setLiveStream(x),C(),x}catch(Z){throw d.value=Xs(Z,"Failed to create stream"),Z instanceof Error?Z:new Error(d.value)}finally{s.value=!1}}async function _(){if(!t.value)throw new Error("No active stream");l.value=!0,d.value=null;try{const A=await er.post(`/live/${t.value.id}/end`),Z=tr(A,t.value);return t.value=Z,a.setLiveStream(Z),N(),Z}catch(A){throw d.value=Xs(A,"Failed to end stream"),A instanceof Error?A:new Error(d.value)}finally{l.value=!1}}async function g(){if(t.value)try{const A=await er.get(`/live/${t.value.id}`),Z=tr(A,t.value);u.value=Z.viewer_count,f.value=Z.peak_viewers,t.value=Z;const x={status:Z.status,viewer_count:Z.viewer_count,peak_viewers:Z.peak_viewers};Z.started_at&&(x.started_at=Z.started_at),Z.ended_at&&(x.ended_at=Z.ended_at),a.updateLiveStreamStats(Z.id,x),Z.status==="live"&&!c.value&&Z.started_at&&(c.value=new Date(Z.started_at)),Z.status==="ended"&&N()}catch{}}async function E(A){try{const Z=await er.get(`/live/${A}`),x=tr(Z,t.value);return{rtmp_url:x.rtmp_url,stream_key:x.stream_key,playback_url:x.playback_url||""}}catch(Z){throw d.value=Xs(Z,"Failed to get stream credentials"),Z instanceof Error?Z:new Error(d.value)}}function C(A=5e3){N(),m=window.setInterval(()=>{g()},A)}function N(){m!==void 0&&(clearInterval(m),m=void 0)}async function S(){if(!n)return;const A=a.getLiveStreamByMedia(n);A&&(t.value=A,u.value=A.viewer_count,f.value=A.peak_viewers,A.status==="live"&&(C(),A.started_at&&(c.value=new Date(A.started_at))))}return n&&S(),e.onUnmounted(()=>{N()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:d,streamDuration:p,viewerCount:u,peakViewers:f,playbackUrl:h,isLive:v,isIdle:k,hasEnded:V,createStream:B,endStream:_,refreshStreamStatus:g,getStreamCredentials:E,startStatusPolling:C,stopStatusPolling:N}}const w5={class:"stream-status"},k5={class:"flex items-center justify-between"},_5={class:"flex items-center gap-3"},E5={key:0,class:"flex items-center"},x5={key:2,class:"text-sm text-gray-600"},S5={key:0,class:"flex items-center gap-2"},C5={class:"text-sm font-medium text-gray-700"},V5={key:0,class:"text-xs text-gray-500"},N5=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(n){const a=n,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[a.status]||a.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[a.status]||s.idle}`}),i=e.computed(()=>{if(!a.duration)return null;const r=Math.floor(a.duration/3600),s=Math.floor(a.duration%3600/60),l=a.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",w5,[e.createElementVNode("div",k5,[e.createElementVNode("div",_5,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",E5,[...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",x5,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",S5,[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",C5,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",V5," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),T5=Be(N5,[["__scopeId","data-v-1d09c19f"]]),M5={class:"stream-credentials"},B5={class:"space-y-3"},I5={class:"credential-field"},F5={class:"flex gap-2"},$5=["value"],D5={class:"credential-field"},R5={class:"flex gap-2"},A5=["value","type"],L5=["aria-label"],P5={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},O5={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},U5={key:0,class:"mt-2 text-sm text-green-600"},z5=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.value)return t.streamKey;if(t.streamKey.length>8){const c=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${c}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){i.value=!i.value}async function d(c,u){try{await navigator.clipboard.writeText(c),r.value=u,o("copy",c,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(c,u)=>(e.openBlock(),e.createElementBlock("div",M5,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",B5,[e.createElementVNode("div",I5,[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",F5,[e.createElementVNode("input",{value:c.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,$5),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>d(c.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",D5,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",R5,[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,A5),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",O5,[...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",P5,[...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,L5),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>d(c.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",U5,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),j5=Be(z5,[["__scopeId","data-v-306d92f6"]]),W5={class:"live-stream-manager","data-testid":"live-stream-manager"},Z5={key:0,class:"stream-setup"},H5={class:"space-y-4"},X5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},G5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},J5=["disabled"],K5={key:0},q5={key:1,class:"flex items-center justify-center"},Y5={key:1,class:"stream-active space-y-6"},Q5={key:1,class:"video-preview"},eI={key:2,class:"analytics-panel"},tI={class:"grid grid-cols-2 gap-4"},aI={class:"bg-gray-50 p-3 rounded"},nI={class:"text-2xl font-bold text-gray-900"},oI={class:"bg-gray-50 p-3 rounded"},iI={class:"text-2xl font-bold text-gray-900"},rI={class:"stream-controls flex gap-3"},sI=["disabled"],lI={key:0},dI={key:1},cI={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},uI={class:"text-red-600 text-sm"},mI=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(n,{emit:a}){const t=n,o=a;t.httpClient&&y5(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:d,isEnding:c,error:u,createStream:f,endStream:m,streamDuration:p,playbackUrl:h,refreshStreamStatus:v}=b5(t.mediaUuid),k=e.ref(!1);async function V(){var C;try{const N=await f({title:l.value,low_latency:r.value,auto_record:s.value});o("stream-created",N),(C=t.onStreamCreated)==null||C.call(t,N)}catch(N){o("error",N)}}async function B(){var C;try{const N=await m();o("stream-ended",N),(C=t.onStreamEnded)==null||C.call(t,N)}catch(N){o("error",N)}}function _(){i.value=null,l.value="",k.value=!1,u.value=null}async function g(C,N){try{await navigator.clipboard.writeText(C)}catch{}}let E;return e.onMounted(()=>{var C;((C=i.value)==null?void 0:C.status)==="live"&&(E=window.setInterval(()=>{v()},5e3))}),e.onUnmounted(()=>{E&&clearInterval(E)}),(C,N)=>(e.openBlock(),e.createElementBlock("div",W5,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",Y5,[e.createVNode(T5,{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(j5,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:g},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",Q5,[N[9]||(N[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Np,{"playback-url":e.unref(h),"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",eI,[N[12]||(N[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",tI,[e.createElementVNode("div",aI,[e.createElementVNode("div",nI,e.toDisplayString(e.unref(i).viewer_count),1),N[10]||(N[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",oI,[e.createElementVNode("div",iI,e.toDisplayString(e.unref(i).peak_viewers),1),N[11]||(N[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",rI,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[3]||(N[3]=S=>k.value=!k.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(k.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:B,disabled:e.unref(c),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(c)?(e.openBlock(),e.createElementBlock("span",dI,"Ending...")):(e.openBlock(),e.createElementBlock("span",lI,"End Stream"))],8,sI)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:_,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",Z5,[N[8]||(N[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",H5,[e.createElementVNode("div",X5,[N[4]||(N[4]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Low Latency Mode"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," 5-7 second delay (vs 15-20s standard) ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[0]||(N[0]=S=>e.isRef(r)?r.value=S: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",G5,[N[5]||(N[5]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Auto-Record Stream"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," Save stream as VOD for later viewing ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[1]||(N[1]=S=>e.isRef(s)?s.value=S:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[N[6]||(N[6]=e.createElementVNode("label",{for:"stream-title",class:"block text-sm font-medium text-gray-700 mb-2"}," Stream Title (optional) ",-1)),e.withDirectives(e.createElementVNode("input",{id:"stream-title","onUpdate:modelValue":N[2]||(N[2]=S=>e.isRef(l)?l.value=S: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:V,disabled:e.unref(d),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(d)?(e.openBlock(),e.createElementBlock("span",q5,[...N[7]||(N[7]=[e.createElementVNode("svg",{class:"animate-spin h-5 w-5 mr-2",viewBox:"0 0 24 24"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1),e.createTextVNode(" Creating... ",-1)])])):(e.openBlock(),e.createElementBlock("span",K5,"Create Stream"))],8,J5)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",cI,[e.createElementVNode("p",uI,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),pI=Be(mI,[["__scopeId","data-v-26291f6f"]]),fI={class:"album-tree-node"},hI=["data-album-id","draggable","aria-selected","aria-expanded"],vI={key:1,class:"album-node__chevron-placeholder"},gI={key:2,"data-testid":"media-count",class:"album-node__count"},yI={key:0,class:"album-tree-node__children",role:"group"},bI=16,wI=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(n,{emit:a}){const t=n,o=a,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),d=e.computed(()=>`${t.depth*bI}px`),c=e.computed(()=>{var _;return((_=t.dragState)==null?void 0:_.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var _;return((_=t.dragState)==null?void 0:_.dropTargetId)===t.album.id}),f=e.computed(()=>{var _;return(_=t.dragState)!=null&&_.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const _=["album-node"];return r.value&&_.push("album-node--selected"),s.value&&_.push("album-node--focused"),t.compact&&_.push("album-node--compact"),c.value&&_.push("album-node--dragging"),u.value&&_.push("album-node--drop-target"),f.value&&_.push("album-node--invalid-drop"),_});function p(){o("select",t.album)}function h(_){_.stopPropagation(),o("toggle-expand",t.album.id)}function v(_){t.draggable&&(_.dataTransfer&&(_.dataTransfer.setData("text/plain",t.album.id),_.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function k(_){t.draggable&&(_.preventDefault(),_.dataTransfer&&(_.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function V(){o("drag-leave",t.album.id)}function B(_){t.draggable&&(_.preventDefault(),o("drop",t.album.id))}return(_,g)=>{var C;const E=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",fI,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":_.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:d.value}),draggable:_.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:v,onDragover:k,onDragleave:V,onDrop:B},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:h},[e.createVNode(e.unref(W.IonIcon),{icon:i.value?e.unref(dh):e.unref(ch)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",vI)),e.createVNode(e.unref(W.IonIcon),{icon:e.unref(yh),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(_.album.name),1),_.showMediaCount?(e.openBlock(),e.createElementBlock("span",gI,e.toDisplayString(_.album.media_count),1)):e.createCommentVNode("",!0)],46,hI),i.value&&((C=_.album.children)!=null&&C.length)?(e.openBlock(),e.createElementBlock("div",yI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.album.children,N=>(e.openBlock(),e.createBlock(E,{key:N.id,album:N,depth:_.depth+1,"selected-id":_.selectedId,"expanded-ids":_.expandedIds,"focused-id":_.focusedId,draggable:_.draggable,"show-media-count":_.showMediaCount,compact:_.compact,onSelect:g[0]||(g[0]=S=>o("select",S)),onToggleExpand:g[1]||(g[1]=S=>o("toggle-expand",S))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),kI=Be(wI,[["__scopeId","data-v-76be65a6"]]),us=Lr.defineStore("albums",()=>{const n=e.ref([]),a=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const g=new Map;return n.value.forEach(E=>g.set(E.id,E)),g}),s=e.computed(()=>n.value.filter(g=>g.parent_id===null));async function l(g){t.value=!0,o.value=null;try{const E=(g==null?void 0:g.parent_id)??null,C=E?`/api/v1/albums?parent_id=${E}`:"/api/v1/albums?parent_id=null",N=await fetch(C);if(!N.ok)throw new Error("Failed to fetch albums");((await N.json()).data||[]).forEach(Z=>{const x=n.value.findIndex(F=>F.id===Z.id);x>=0?n.value[x]=Z:n.value.push(Z)}),E!==null&&i.value.add(E)}catch(E){o.value=E instanceof Error?E.message:"Unknown error"}finally{t.value=!1}}async function d(g){t.value=!0,o.value=null;try{const E=await fetch(`/api/v1/albums/${g}`);if(!E.ok)throw new Error("Failed to fetch album");const N=(await E.json()).data,S=n.value.findIndex(A=>A.id===N.id);return S>=0?n.value[S]=N:n.value.push(N),N}catch(E){throw o.value=E instanceof Error?E.message:"Unknown error",E}finally{t.value=!1}}async function c(g){t.value=!0,o.value=null;try{const E=await fetch(`/api/v1/albums/${g}/media`);if(!E.ok)throw new Error("Failed to fetch album media");const N=(await E.json()).data||[];return a.value.set(g,N),N}catch(E){throw o.value=E instanceof Error?E.message:"Unknown error",E}finally{t.value=!1}}async function u(g,E){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${g}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:E})})).ok)throw new Error("Failed to reorder album media");const N=a.value.get(g)||[],S=E.map(A=>N.find(Z=>Z.uuid===A)).filter(A=>A!==void 0);a.value.set(g,S)}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function f(g){t.value=!0,o.value=null;try{const E=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(g)});if(!E.ok)throw new Error("Failed to create album");const N=(await E.json()).data;return n.value.push(N),N}catch(E){throw o.value=E instanceof Error?E.message:"Unknown error",E}finally{t.value=!1}}async function m(g,E){t.value=!0,o.value=null;try{const C=await fetch(`/api/v1/albums/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(E)});if(!C.ok)throw new Error("Failed to update album");const S=(await C.json()).data,A=n.value.findIndex(Z=>Z.id===S.id);return A>=0&&(n.value[A]=S),S}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function p(g){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${g}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const C=n.value.findIndex(N=>N.id===g);C>=0&&n.value.splice(C,1),a.value.delete(g)}catch(E){throw o.value=E instanceof Error?E.message:"Unknown error",E}finally{t.value=!1}}function h(g){return n.value.filter(E=>E.parent_id===g)}function v(g){return i.value.has(g)}function k(g){return a.value.get(g)||[]}async function V(g,E){const C=n.value.findIndex(S=>S.id===g);if(C<0)return;const N=n.value[C];n.value[C]={...N,parent_id:E};try{if(!(await fetch(`/api/v1/albums/${g}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:E})})).ok)throw new Error("Failed to move album")}catch(S){throw n.value[C]=N,o.value=S instanceof Error?S.message:"Unknown error",S instanceof Error?S:new Error("Failed to move album")}}function B(g){n.value=g}function _(){n.value=[],a.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:n,albumMedia:a,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:d,fetchAlbumMedia:c,reorderAlbumMedia:u,createAlbum:f,updateAlbum:m,deleteAlbum:p,getChildrenOf:h,childrenLoaded:v,getAlbumMedia:k,moveAlbum:V,setAlbums:B,reset:_}});function Tp(){const n=us(),{albums:a,albumsById:t,rootAlbums:o,loading:i,error:r}=Lr.storeToRefs(n);async function s(u){await n.fetchAlbums(u)}function l(u){return n.getChildrenOf(u)}function d(u){return n.childrenLoaded(u)}async function c(u,f){await n.moveAlbum(u,f)}return{albums:a,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:d,moveAlbum:c}}function Mp(n){const{childrenByParentId:a,onMove:t}=n,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(f,m){if(f===m)return!0;const p=new Set,h=[f];for(;h.length>0;){const v=h.shift();if(!v||p.has(v))continue;p.add(v);const k=a.get(v)||[];for(const V of k){if(V===m)return!0;h.push(V)}}return!1}function r(f,m){return f===m?!1:m===null?!0:!i(f,m)}function s(f){o.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function l(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function d(f){o.value.dropTargetId=f}function c(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:m}=o.value;if(!f){l();return}if(!r(f,m)){l();return}try{await t(f,m)}finally{l()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:d,clearDropTarget:c,executeDrop:u}}const _I={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},EI={key:1,"data-testid":"error-state",class:"album-tree__error"},xI={key:2,"data-testid":"empty-state",class:"album-tree__empty"},SI={key:3,class:"album-tree__content",role:"group"},CI=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(n,{expose:a,emit:t}){const o=n,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),l=e.computed(()=>o.compact===!0),{albums:d,rootAlbums:c,loading:u,error:f,fetchAlbums:m,getChildrenOf:p,childrenLoaded:h,moveAlbum:v}=Tp(),k=e.shallowRef(new Set(o.expandedIds)),V=e.ref(o.modelValue??null),B=e.ref(null),_=new Map,g=new Map;function E(L){_.clear(),g.clear();for(const D of L){_.set(D.id,D);const j=D.parent_id??null,q=g.get(j)??[];q.push(D.id),g.set(j,q)}}e.watch(d,L=>{E(L)},{immediate:!0});const{dragState:C,canDropOn:N,startDrag:S,endDrag:A,setDropTarget:Z,clearDropTarget:x,executeDrop:F}=Mp({childrenByParentId:g,onMove:async(L,D)=>{await v(L,D),i("album-moved",{albumId:L,newParentId:D})}});e.watch(()=>o.modelValue,L=>{V.value=L??null}),e.watch(()=>o.expandedIds,L=>{k.value=new Set(L)}),e.onMounted(async()=>{await m({parent_id:null})});const b=e.computed(()=>c.value.map(L=>R(L)));function R(L){if(!k.value.has(L.id))return L;const D=p(L.id);return{...L,children:D.map(j=>R(j))}}const P=e.computed(()=>{const L=[];function D(j){var q;for(const te of j)L.push(te),k.value.has(te.id)&&((q=te.children)!=null&&q.length)&&D(te.children)}return D(b.value),L});function O(L){var q;if(!P.value.length)return;const D=B.value?P.value.findIndex(te=>te.id===B.value):-1,j=D>=0?P.value[D]:null;switch(L.key){case"ArrowDown":L.preventDefault(),D<P.value.length-1?B.value=P.value[D+1].id:D===-1&&P.value.length>0&&(B.value=P.value[0].id);break;case"ArrowUp":L.preventDefault(),D>0&&(B.value=P.value[D-1].id);break;case"ArrowRight":L.preventDefault(),j&&(j.children_count>0&&!k.value.has(j.id)?U(j.id):k.value.has(j.id)&&((q=j.children)!=null&&q.length)&&(B.value=j.children[0].id));break;case"ArrowLeft":L.preventDefault(),j&&(k.value.has(j.id)&&j.children_count>0?U(j.id):j.parent_id&&(B.value=j.parent_id));break;case"Enter":case" ":L.preventDefault(),j&&M(j);break;case"Home":L.preventDefault(),P.value.length>0&&(B.value=P.value[0].id);break;case"End":L.preventDefault(),P.value.length>0&&(B.value=P.value[P.value.length-1].id);break}}async function U(L){k.value.has(L)?(k.value.delete(L),i("album-collapsed",L)):(h(L)||await m({parent_id:L}),k.value.add(L),i("album-expanded",L))}function M(L){V.value=L.id,i("update:modelValue",L.id),i("album-selected",L)}function I(L){o.draggable&&S(L)}function z(L){var j;if(!o.draggable)return;const D=(j=C.value)==null?void 0:j.draggedAlbumId;D&&(Z(L),N(D,L))}function X(){o.draggable&&x()}async function le(L){o.draggable&&(Z(L),await F())}function ve(L){o.draggable&&(L.preventDefault(),Z(null))}async function ie(L){o.draggable&&(L.preventDefault(),Z(null),await F())}function ne(){A()}return a({focusedId:B}),(L,D)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:O,onDragover:ve,onDrop:ie,onDragend:ne},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",_I,[e.createVNode(e.unref(W.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",EI,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(c).length?(e.openBlock(),e.createElementBlock("div",SI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,j=>(e.openBlock(),e.createBlock(kI,{key:j.id,album:j,depth:0,"selected-id":V.value,"expanded-ids":k.value,"focused-id":B.value,draggable:r.value,"drag-state":r.value?e.unref(C):null,"show-media-count":s.value,compact:l.value,onSelect:M,onToggleExpand:U,onDragStart:I,onDragOver:z,onDragLeave:X,onDrop:le},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",xI,[D[0]||(D[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(L.$slots,"empty-action",{},void 0,!0)]))],32))}}),Bp=Be(CI,[["__scopeId","data-v-ae3dea7a"]]),VI=300,NI=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(n,{emit:a}){const t=n,o=a,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 d=e.computed(()=>r.value!==null);function c(p){const h=Date.now();if(l.value===p.id&&h-s.value<VI){o("confirm",p);return}s.value=h,l.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&o("confirm",r.value)}function f(){o("close")}function m(){o("close")}return(p,h)=>(e.openBlock(),e.createBlock(e.unref(W.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:m},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(W.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{"data-testid":"cancel-button",onClick:f},{default:e.withCtx(()=>[...h[1]||(h[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(W.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Bp,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=v=>i.value=v),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:c},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(W.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...h[2]||(h[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(W.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!d.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Ip=Be(NI,[["__scopeId","data-v-21676ec1"]]),TI={class:"ion-padding-start text-sm"},MI={class:"ion-padding-start text-sm"},BI={key:1},II={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},FI={class:"flex items-center justify-between gap-3 pb-3"},$I={class:"text-base font-semibold text-gray-900"},DI={class:"ion-padding-start text-sm"},RI={class:"ion-padding-start text-sm"},AI={class:"flex justify-between pt-2"},LI={key:1},Xo=255,Go=1e3,PI=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(n,{emit:a}){const t=n,o=a,i=us(),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"),d=e.ref({name:"",description:"",parent_id:t.parentId}),c=e.ref({name:!1,description:!1}),u=e.ref(null),f=e.ref(!1),m=e.ref(null),p=e.ref(!1),h=e.ref(!1),v=e.computed(()=>c.value.name?d.value.name.trim()?d.value.name.length>Xo?`Name must be ${Xo} characters or less`:null:"Name is required":null),k=e.computed(()=>c.value.description&&d.value.description.length>Go?`Description must be ${Go} characters or less`:null),V=e.computed(()=>{const O=d.value.name.trim().length>0,U=d.value.name.length<=Xo,M=d.value.description.length<=Go;return O&&U&&M&&!p.value}),B=e.computed(()=>{var O;return((O=u.value)==null?void 0:O.name)??"None (Root)"}),_=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),g=e.computed(()=>m.value?m.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":m.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${m.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await E()});async function E(){if(t.albumId)try{const O=await i.fetchAlbum(t.albumId);m.value=O,d.value={name:O.name,description:O.description??"",parent_id:O.parent_id},O.parent_id&&(u.value={id:O.parent_id,name:"Parent Album"})}catch(O){o("error",O)}}function C(){c.value.name=!0}function N(){c.value.description=!0}function S(){f.value=!0}function A(O){u.value={id:O.id,name:O.name},d.value.parent_id=O.id,f.value=!1}function Z(){f.value=!1}function x(){o("close")}function F(){o("close")}async function b(){if(c.value.name=!0,c.value.description=!0,!(!V.value||p.value)){p.value=!0;try{const O={name:d.value.name.trim(),description:d.value.description.trim(),parent_id:d.value.parent_id};if(r.value&&t.albumId){const U=await i.updateAlbum(t.albumId,O);o("updated",U)}else{const U=await i.createAlbum(O);o("created",U)}o("close")}catch(O){o("error",O)}finally{p.value=!1}}}function R(){_.value&&(h.value=!0)}async function P(O){var M;if((((M=O.detail)==null?void 0:M.role)??"")!=="confirm"){h.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(I){o("error",I)}finally{p.value=!1,h.value=!1}}}return(O,U)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[O.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(W.IonModal),{key:0,"is-open":O.isOpen,class:"album-manager-modal",onDidDismiss:F},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(W.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:x},{default:e.withCtx(()=>[...U[4]||(U[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(W.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(b,["prevent"])},[e.createVNode(e.unref(W.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...U[5]||(U[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(W.IonInput),{modelValue:d.value.name,"onUpdate:modelValue":U[0]||(U[0]=M=>d.value.name=M),"data-testid":"name-input",maxlength:Xo,onIonBlur:C},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(W.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",TI,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...U[6]||(U[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(W.IonTextarea),{modelValue:d.value.description,"onUpdate:modelValue":U[1]||(U[1]=M=>d.value.description=M),"data-testid":"description-input",maxlength:Go,onIonBlur:N},null,8,["modelValue"])]),_:1}),k.value?(e.openBlock(),e.createBlock(e.unref(W.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",MI,e.toDisplayString(k.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonItem),{button:"","data-testid":"parent-selector",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...U[7]||(U[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(W.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(B.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(W.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!_.value,title:_.value?void 0:g.value,onClick:R},{default:e.withCtx(()=>[...U[8]||(U[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(W.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!V.value,onClick:b},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(W.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",BI,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",II,[e.createElementVNode("div",FI,[e.createElementVNode("h2",$I,e.toDisplayString(s.value),1),e.createVNode(e.unref(W.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:x},{default:e.withCtx(()=>[...U[9]||(U[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(b,["prevent"])},[e.createVNode(e.unref(W.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...U[10]||(U[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(W.IonInput),{modelValue:d.value.name,"onUpdate:modelValue":U[2]||(U[2]=M=>d.value.name=M),"data-testid":"name-input",maxlength:Xo,onIonBlur:C},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(W.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",DI,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...U[11]||(U[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(W.IonTextarea),{modelValue:d.value.description,"onUpdate:modelValue":U[3]||(U[3]=M=>d.value.description=M),"data-testid":"description-input",maxlength:Go,onIonBlur:N},null,8,["modelValue"])]),_:1}),k.value?(e.openBlock(),e.createBlock(e.unref(W.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",RI,e.toDisplayString(k.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonItem),{button:"","data-testid":"parent-selector",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonLabel),null,{default:e.withCtx(()=>[...U[12]||(U[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(W.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(B.value),1)]),_:1})]),_:1}),e.createElementVNode("div",AI,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(W.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!_.value,title:_.value?void 0:g.value,onClick:R},{default:e.withCtx(()=>[...U[13]||(U[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(W.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!V.value,onClick:b},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(W.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",LI,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Ip,{"is-open":f.value,"selected-album-id":d.value.parent_id,title:"Select Parent Album",onClose:Z,onConfirm:A},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(W.IonAlert),{"is-open":h.value,header:"Delete Album?",message:g.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),OI=Be(PI,[["__scopeId","data-v-22083f3a"]]),UI={class:"album-media-grid"},zI={class:"aspect-square"},jI={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},WI={class:"text-gray-500"},ZI=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],HI={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},XI={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},GI={class:"aspect-square relative"},JI=["src","alt"],KI={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},qI=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(n,{emit:a}){const t=n,o=a,i=us(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),d=e.ref(null),c=e.ref(null),u=e.computed(()=>t.isLoading||s.value),f=e.computed(()=>!u.value&&r.value.length===0),m=e.computed(()=>{const F=t.columns;return["grid","gap-4",`grid-cols-${F.mobile??2}`,`sm:grid-cols-${F.sm??3}`,`md:grid-cols-${F.md??4}`,`lg:grid-cols-${F.lg??5}`,`xl:grid-cols-${F.xl??6}`]}),p=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await h()}),e.watch(()=>t.albumId,async()=>{await h()});async function h(){s.value=!0;try{const F=await i.fetchAlbumMedia(t.albumId);r.value=F}catch{r.value=[]}finally{s.value=!1}}function v(F){return t.selectedItems.includes(F)}function k(F){o("toggle-select",F);const b=v(F.uuid)?t.selectedItems.filter(R=>R!==F.uuid):[...t.selectedItems,F.uuid];o("selection-change",b)}function V(F){if(F.conversions&&typeof F.conversions=="object"){const b=F.conversions.thumb;if(typeof b=="string")return b}return F.original_url}function B(F){l.value=F}function _(){l.value=null}function g(F){o("preview",F)}function E(F){o("edit",F)}function C(F){o("detach",F.uuid)}function N(){o("add")}function S(F,b){t.reorderable&&(d.value=b,F.dataTransfer&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",String(b))))}function A(F,b){!t.reorderable||d.value===null||(F.preventDefault(),c.value=b)}function Z(F,b){if(!t.reorderable||d.value===null)return;F.preventDefault();const R=d.value;if(R!==b){const P=[...r.value],[O]=P.splice(R,1);P.splice(b,0,O),r.value=P;const U=P.map(M=>M.uuid);o("reorder",U),i.reorderAlbumMedia(t.albumId,U).catch(()=>{h()})}d.value=null,c.value=null}function x(){d.value=null,c.value=null}return(F,b)=>(e.openBlock(),e.createElementBlock("div",UI,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,R=>(e.openBlock(),e.createBlock(e.unref(W.IonCard),{key:R,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",zI,[e.createVNode(e.unref(W.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",jI,[e.createVNode(e.unref(W.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",WI,e.toDisplayString(F.emptyText),1),e.createVNode(e.unref(W.IonButton),{"data-testid":"add-media-btn",onClick:N},{default:e.withCtx(()=>[...b[0]||(b[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(R,P)=>(e.openBlock(),e.createElementBlock("div",{key:R.uuid,"data-media-id":R.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":d.value===P,"ring-2 ring-primary":c.value===P&&d.value!==P}]),draggable:F.reorderable,onDragstart:O=>S(O,P),onDragover:O=>A(O,P),onDrop:O=>Z(O,P),onDragend:x,onMouseenter:O=>B(R.uuid),onMouseleave:_},[c.value===P&&d.value!==P&&F.reorderable?(e.openBlock(),e.createElementBlock("div",HI)):e.createCommentVNode("",!0),F.reorderable?(e.openBlock(),e.createElementBlock("div",XI,[e.createVNode(e.unref(W.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),F.selectionMode?(e.openBlock(),e.createBlock(e.unref(W.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:v(R.uuid),class:"absolute top-2 left-2 z-20",onIonChange:O=>k(R)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(W.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",GI,[e.createElementVNode("img",{src:V(R),alt:R.file_name,class:"w-full h-full object-cover"},null,8,JI),F.showActions&&l.value===R.uuid?(e.openBlock(),e.createElementBlock("div",KI,[e.createVNode(e.unref(W.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:O=>g(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(W.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:O=>E(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(W.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:O=>C(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(W.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,ZI))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:N},[e.createVNode(e.unref(W.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),b[1]||(b[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),YI=Be(qI,[["__scopeId","data-v-d84b796a"]]),QI={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},e8={class:"media-album-inline-create__field"},t8={class:"media-album-inline-create__field"},a8=["value"],n8={key:1,class:"media-album-inline-create__autocomplete"},o8={class:"media-album-inline-create__autocomplete-input-wrap"},i8={key:0,class:"media-album-inline-create__autocomplete-list"},r8=["onMousedown"],s8={key:1,class:"media-album-inline-create__autocomplete-empty"},l8={class:"media-album-inline-create__actions"},d8=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(""),r=e.ref(""),s=e.ref(""),l=e.ref(!1),d=e.computed(()=>t.albums.length>5),c=e.computed(()=>{if(s.value.trim()==="")return t.albums;const k=s.value.toLowerCase();return t.albums.filter(V=>V.name.toLowerCase().includes(k))}),u=e.computed(()=>{if(r.value==="")return"";const k=t.albums.find(V=>V.id===r.value);return(k==null?void 0:k.name)??""}),f=k=>{r.value=k.id,s.value=k.name,l.value=!1},m=()=>{r.value="",s.value="",l.value=!1},p=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},h=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},v=()=>{i.value.trim()!==""&&(o("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(k,V)=>k.open?(e.openBlock(),e.createElementBlock("section",QI,[V[7]||(V[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",e8,[e.createElementVNode("span",null,e.toDisplayString(k.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[0]||(V[0]=B=>i.value=B),type:"text",class:"media-album-inline-create__input",placeholder:"e.g. Marbles, Pendants","data-testid":"input-media-album-name"},null,512),[[e.vModelText,i.value]])]),e.createElementVNode("label",t8,[V[6]||(V[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),d.value?(e.openBlock(),e.createElementBlock("div",n8,[e.createElementVNode("div",o8,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[2]||(V[2]=B=>s.value=B),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:p,onBlur:h},null,544),[[e.vModelText,s.value]]),r.value!==""?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-album-inline-create__autocomplete-clear","aria-label":"Clear parent album",onMousedown:e.withModifiers(m,["prevent"])},[...V[5]||(V[5]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],32)):e.createCommentVNode("",!0)]),l.value?(e.openBlock(),e.createElementBlock("ul",i8,[r.value!==""?(e.openBlock(),e.createElementBlock("li",{key:0,class:"media-album-inline-create__autocomplete-option media-album-inline-create__autocomplete-option--none",onMousedown:e.withModifiers(m,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,B=>(e.openBlock(),e.createElementBlock("li",{key:B.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":B.id===r.value}]),onMousedown:e.withModifiers(_=>f(B),["prevent"])},e.toDisplayString(B.name),43,r8))),128)),c.value.length===0?(e.openBlock(),e.createElementBlock("li",s8," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":V[1]||(V[1]=B=>r.value=B),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[V[4]||(V[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.albums,B=>(e.openBlock(),e.createElementBlock("option",{key:B.id,value:B.id},e.toDisplayString(B.name),9,a8))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",l8,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:V[3]||(V[3]=B=>o("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:v}," Create ")])])):e.createCommentVNode("",!0)}}),Fp=Be(d8,[["__scopeId","data-v-a85162fe"]]),c8={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},u8=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(n,{emit:a}){const t=a;return(o,i)=>(e.openBlock(),e.createElementBlock("section",c8,[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)]))}}),$p=Be(u8,[["__scopeId","data-v-04620e64"]]);/*!
350
+ * tabbable 6.2.0
351
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
352
+ */var Dp=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Fr=Dp.join(","),Rp=typeof Element>"u",Zn=Rp?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,$r=!Rp&&Element.prototype.getRootNode?function(n){var a;return n==null||(a=n.getRootNode)===null||a===void 0?void 0:a.call(n)}:function(n){return n==null?void 0:n.ownerDocument},Dr=function n(a,t){var o;t===void 0&&(t=!0);var i=a==null||(o=a.getAttribute)===null||o===void 0?void 0:o.call(a,"inert"),r=i===""||i==="true",s=r||t&&a&&n(a.parentNode);return s},m8=function(a){var t,o=a==null||(t=a.getAttribute)===null||t===void 0?void 0:t.call(a,"contenteditable");return o===""||o==="true"},Ap=function(a,t,o){if(Dr(a))return[];var i=Array.prototype.slice.apply(a.querySelectorAll(Fr));return t&&Zn.call(a,Fr)&&i.unshift(a),i=i.filter(o),i},Lp=function n(a,t,o){for(var i=[],r=Array.from(a);r.length;){var s=r.shift();if(!Dr(s,!1))if(s.tagName==="SLOT"){var l=s.assignedElements(),d=l.length?l:s.children,c=n(d,!0,o);o.flatten?i.push.apply(i,c):i.push({scopeParent:s,candidates:c})}else{var u=Zn.call(s,Fr);u&&o.filter(s)&&(t||!a.includes(s))&&i.push(s);var f=s.shadowRoot||typeof o.getShadowRoot=="function"&&o.getShadowRoot(s),m=!Dr(f,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(s));if(f&&m){var p=n(f===!0?s.children:f.children,!0,o);o.flatten?i.push.apply(i,p):i.push({scopeParent:s,candidates:p})}else r.unshift.apply(r,s.children)}}return i},Pp=function(a){return!isNaN(parseInt(a.getAttribute("tabindex"),10))},Rn=function(a){if(!a)throw new Error("No node provided");return a.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(a.tagName)||m8(a))&&!Pp(a)?0:a.tabIndex},p8=function(a,t){var o=Rn(a);return o<0&&t&&!Pp(a)?0:o},f8=function(a,t){return a.tabIndex===t.tabIndex?a.documentOrder-t.documentOrder:a.tabIndex-t.tabIndex},Op=function(a){return a.tagName==="INPUT"},h8=function(a){return Op(a)&&a.type==="hidden"},v8=function(a){var t=a.tagName==="DETAILS"&&Array.prototype.slice.apply(a.children).some(function(o){return o.tagName==="SUMMARY"});return t},g8=function(a,t){for(var o=0;o<a.length;o++)if(a[o].checked&&a[o].form===t)return a[o]},y8=function(a){if(!a.name)return!0;var t=a.form||$r(a),o=function(l){return t.querySelectorAll('input[type="radio"][name="'+l+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=o(window.CSS.escape(a.name));else try{i=o(a.name)}catch{return!1}var r=g8(i,a.form);return!r||r===a},b8=function(a){return Op(a)&&a.type==="radio"},w8=function(a){return b8(a)&&!y8(a)},k8=function(a){var t,o=a&&$r(a),i=(t=o)===null||t===void 0?void 0:t.host,r=!1;if(o&&o!==a){var s,l,d;for(r=!!((s=i)!==null&&s!==void 0&&(l=s.ownerDocument)!==null&&l!==void 0&&l.contains(i)||a!=null&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(a));!r&&i;){var c,u,f;o=$r(i),i=(c=o)===null||c===void 0?void 0:c.host,r=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i))}}return r},lu=function(a){var t=a.getBoundingClientRect(),o=t.width,i=t.height;return o===0&&i===0},_8=function(a,t){var o=t.displayCheck,i=t.getShadowRoot;if(getComputedStyle(a).visibility==="hidden")return!0;var r=Zn.call(a,"details>summary:first-of-type"),s=r?a.parentElement:a;if(Zn.call(s,"details:not([open]) *"))return!0;if(!o||o==="full"||o==="legacy-full"){if(typeof i=="function"){for(var l=a;a;){var d=a.parentElement,c=$r(a);if(d&&!d.shadowRoot&&i(d)===!0)return lu(a);a.assignedSlot?a=a.assignedSlot:!d&&c!==a.ownerDocument?a=c.host:a=d}a=l}if(k8(a))return!a.getClientRects().length;if(o!=="legacy-full")return!0}else if(o==="non-zero-area")return lu(a);return!1},E8=function(a){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(a.tagName))for(var t=a.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var o=0;o<t.children.length;o++){var i=t.children.item(o);if(i.tagName==="LEGEND")return Zn.call(t,"fieldset[disabled] *")?!0:!i.contains(a)}return!0}t=t.parentElement}return!1},Rr=function(a,t){return!(t.disabled||Dr(t)||h8(t)||_8(t,a)||v8(t)||E8(t))},Ll=function(a,t){return!(w8(t)||Rn(t)<0||!Rr(a,t))},x8=function(a){var t=parseInt(a.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},S8=function n(a){var t=[],o=[];return a.forEach(function(i,r){var s=!!i.scopeParent,l=s?i.scopeParent:i,d=p8(l,s),c=s?n(i.candidates):l;d===0?s?t.push.apply(t,c):t.push(l):o.push({documentOrder:r,tabIndex:d,item:i,isScope:s,content:c})}),o.sort(f8).reduce(function(i,r){return r.isScope?i.push.apply(i,r.content):i.push(r.content),i},[]).concat(t)},C8=function(a,t){t=t||{};var o;return t.getShadowRoot?o=Lp([a],t.includeContainer,{filter:Ll.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:x8}):o=Ap(a,t.includeContainer,Ll.bind(null,t)),S8(o)},V8=function(a,t){t=t||{};var o;return t.getShadowRoot?o=Lp([a],t.includeContainer,{filter:Rr.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):o=Ap(a,t.includeContainer,Rr.bind(null,t)),o},lo=function(a,t){if(t=t||{},!a)throw new Error("No node provided");return Zn.call(a,Fr)===!1?!1:Ll(t,a)},N8=Dp.concat("iframe").join(","),Gs=function(a,t){if(t=t||{},!a)throw new Error("No node provided");return Zn.call(a,N8)===!1?!1:Rr(t,a)};/*!
353
+ * focus-trap 7.6.5
354
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
355
+ */function Pl(n,a){(a==null||a>n.length)&&(a=n.length);for(var t=0,o=Array(a);t<a;t++)o[t]=n[t];return o}function T8(n){if(Array.isArray(n))return Pl(n)}function M8(n,a,t){return(a=D8(a))in n?Object.defineProperty(n,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[a]=t,n}function B8(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function I8(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
356
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function du(n,a){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);a&&(o=o.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,o)}return t}function cu(n){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?du(Object(t),!0).forEach(function(o){M8(n,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):du(Object(t)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(t,o))})}return n}function F8(n){return T8(n)||B8(n)||R8(n)||I8()}function $8(n,a){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var o=t.call(n,a);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function D8(n){var a=$8(n,"string");return typeof a=="symbol"?a:a+""}function R8(n,a){if(n){if(typeof n=="string")return Pl(n,a);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Pl(n,a):void 0}}var uu={activateTrap:function(a,t){if(a.length>0){var o=a[a.length-1];o!==t&&o._setPausedState(!0)}var i=a.indexOf(t);i===-1||a.splice(i,1),a.push(t)},deactivateTrap:function(a,t){var o=a.indexOf(t);o!==-1&&a.splice(o,1),a.length>0&&!a[a.length-1]._isManuallyPaused()&&a[a.length-1]._setPausedState(!1)}},A8=function(a){return a.tagName&&a.tagName.toLowerCase()==="input"&&typeof a.select=="function"},L8=function(a){return(a==null?void 0:a.key)==="Escape"||(a==null?void 0:a.key)==="Esc"||(a==null?void 0:a.keyCode)===27},ui=function(a){return(a==null?void 0:a.key)==="Tab"||(a==null?void 0:a.keyCode)===9},P8=function(a){return ui(a)&&!a.shiftKey},O8=function(a){return ui(a)&&a.shiftKey},mu=function(a){return setTimeout(a,0)},Jo=function(a){for(var t=arguments.length,o=new Array(t>1?t-1:0),i=1;i<t;i++)o[i-1]=arguments[i];return typeof a=="function"?a.apply(void 0,o):a},ar=function(a){return a.target.shadowRoot&&typeof a.composedPath=="function"?a.composedPath()[0]:a.target},U8=[],z8=function(a,t){var o=(t==null?void 0:t.document)||document,i=(t==null?void 0:t.trapStack)||U8,r=cu({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:P8,isKeyBackward:O8},t),s={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},l,d=function(b,R,P){return b&&b[R]!==void 0?b[R]:r[P||R]},c=function(b,R){var P=typeof(R==null?void 0:R.composedPath)=="function"?R.composedPath():void 0;return s.containerGroups.findIndex(function(O){var U=O.container,M=O.tabbableNodes;return U.contains(b)||(P==null?void 0:P.includes(U))||M.find(function(I){return I===b})})},u=function(b){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},P=R.hasFallback,O=P===void 0?!1:P,U=R.params,M=U===void 0?[]:U,I=r[b];if(typeof I=="function"&&(I=I.apply(void 0,F8(M))),I===!0&&(I=void 0),!I){if(I===void 0||I===!1)return I;throw new Error("`".concat(b,"` was specified but was not a node, or did not return a node"))}var z=I;if(typeof I=="string"){try{z=o.querySelector(I)}catch(X){throw new Error("`".concat(b,'` appears to be an invalid selector; error="').concat(X.message,'"'))}if(!z&&!O)throw new Error("`".concat(b,"` as selector refers to no known node"))}return z},f=function(){var b=u("initialFocus",{hasFallback:!0});if(b===!1)return!1;if(b===void 0||b&&!Gs(b,r.tabbableOptions))if(c(o.activeElement)>=0)b=o.activeElement;else{var R=s.tabbableGroups[0],P=R&&R.firstTabbableNode;b=P||u("fallbackFocus")}else b===null&&(b=u("fallbackFocus"));if(!b)throw new Error("Your focus-trap needs to have at least one focusable element");return b},m=function(){if(s.containerGroups=s.containers.map(function(b){var R=C8(b,r.tabbableOptions),P=V8(b,r.tabbableOptions),O=R.length>0?R[0]:void 0,U=R.length>0?R[R.length-1]:void 0,M=P.find(function(X){return lo(X)}),I=P.slice().reverse().find(function(X){return lo(X)}),z=!!R.find(function(X){return Rn(X)>0});return{container:b,tabbableNodes:R,focusableNodes:P,posTabIndexesFound:z,firstTabbableNode:O,lastTabbableNode:U,firstDomTabbableNode:M,lastDomTabbableNode:I,nextTabbableNode:function(le){var ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ie=R.indexOf(le);return ie<0?ve?P.slice(P.indexOf(le)+1).find(function(ne){return lo(ne)}):P.slice(0,P.indexOf(le)).reverse().find(function(ne){return lo(ne)}):R[ie+(ve?1:-1)]}}}),s.tabbableGroups=s.containerGroups.filter(function(b){return b.tabbableNodes.length>0}),s.tabbableGroups.length<=0&&!u("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(s.containerGroups.find(function(b){return b.posTabIndexesFound})&&s.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},p=function(b){var R=b.activeElement;if(R)return R.shadowRoot&&R.shadowRoot.activeElement!==null?p(R.shadowRoot):R},h=function(b){if(b!==!1&&b!==p(document)){if(!b||!b.focus){h(f());return}b.focus({preventScroll:!!r.preventScroll}),s.mostRecentlyFocusedNode=b,A8(b)&&b.select()}},v=function(b){var R=u("setReturnFocus",{params:[b]});return R||(R===!1?!1:b)},k=function(b){var R=b.target,P=b.event,O=b.isBackward,U=O===void 0?!1:O;R=R||ar(P),m();var M=null;if(s.tabbableGroups.length>0){var I=c(R,P),z=I>=0?s.containerGroups[I]:void 0;if(I<0)U?M=s.tabbableGroups[s.tabbableGroups.length-1].lastTabbableNode:M=s.tabbableGroups[0].firstTabbableNode;else if(U){var X=s.tabbableGroups.findIndex(function(D){var j=D.firstTabbableNode;return R===j});if(X<0&&(z.container===R||Gs(R,r.tabbableOptions)&&!lo(R,r.tabbableOptions)&&!z.nextTabbableNode(R,!1))&&(X=I),X>=0){var le=X===0?s.tabbableGroups.length-1:X-1,ve=s.tabbableGroups[le];M=Rn(R)>=0?ve.lastTabbableNode:ve.lastDomTabbableNode}else ui(P)||(M=z.nextTabbableNode(R,!1))}else{var ie=s.tabbableGroups.findIndex(function(D){var j=D.lastTabbableNode;return R===j});if(ie<0&&(z.container===R||Gs(R,r.tabbableOptions)&&!lo(R,r.tabbableOptions)&&!z.nextTabbableNode(R))&&(ie=I),ie>=0){var ne=ie===s.tabbableGroups.length-1?0:ie+1,L=s.tabbableGroups[ne];M=Rn(R)>=0?L.firstTabbableNode:L.firstDomTabbableNode}else ui(P)||(M=z.nextTabbableNode(R))}}else M=u("fallbackFocus");return M},V=function(b){var R=ar(b);if(!(c(R,b)>=0)){if(Jo(r.clickOutsideDeactivates,b)){l.deactivate({returnFocus:r.returnFocusOnDeactivate});return}Jo(r.allowOutsideClick,b)||b.preventDefault()}},B=function(b){var R=ar(b),P=c(R,b)>=0;if(P||R instanceof Document)P&&(s.mostRecentlyFocusedNode=R);else{b.stopImmediatePropagation();var O,U=!0;if(s.mostRecentlyFocusedNode)if(Rn(s.mostRecentlyFocusedNode)>0){var M=c(s.mostRecentlyFocusedNode),I=s.containerGroups[M].tabbableNodes;if(I.length>0){var z=I.findIndex(function(X){return X===s.mostRecentlyFocusedNode});z>=0&&(r.isKeyForward(s.recentNavEvent)?z+1<I.length&&(O=I[z+1],U=!1):z-1>=0&&(O=I[z-1],U=!1))}}else s.containerGroups.some(function(X){return X.tabbableNodes.some(function(le){return Rn(le)>0})})||(U=!1);else U=!1;U&&(O=k({target:s.mostRecentlyFocusedNode,isBackward:r.isKeyBackward(s.recentNavEvent)})),h(O||s.mostRecentlyFocusedNode||f())}s.recentNavEvent=void 0},_=function(b){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;s.recentNavEvent=b;var P=k({event:b,isBackward:R});P&&(ui(b)&&b.preventDefault(),h(P))},g=function(b){(r.isKeyForward(b)||r.isKeyBackward(b))&&_(b,r.isKeyBackward(b))},E=function(b){L8(b)&&Jo(r.escapeDeactivates,b)!==!1&&(b.preventDefault(),l.deactivate())},C=function(b){var R=ar(b);c(R,b)>=0||Jo(r.clickOutsideDeactivates,b)||Jo(r.allowOutsideClick,b)||(b.preventDefault(),b.stopImmediatePropagation())},N=function(){if(s.active)return uu.activateTrap(i,l),s.delayInitialFocusTimer=r.delayInitialFocus?mu(function(){h(f())}):h(f()),o.addEventListener("focusin",B,!0),o.addEventListener("mousedown",V,{capture:!0,passive:!1}),o.addEventListener("touchstart",V,{capture:!0,passive:!1}),o.addEventListener("click",C,{capture:!0,passive:!1}),o.addEventListener("keydown",g,{capture:!0,passive:!1}),o.addEventListener("keydown",E),l},S=function(){if(s.active)return o.removeEventListener("focusin",B,!0),o.removeEventListener("mousedown",V,!0),o.removeEventListener("touchstart",V,!0),o.removeEventListener("click",C,!0),o.removeEventListener("keydown",g,!0),o.removeEventListener("keydown",E),l},A=function(b){var R=b.some(function(P){var O=Array.from(P.removedNodes);return O.some(function(U){return U===s.mostRecentlyFocusedNode})});R&&h(f())},Z=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(A):void 0,x=function(){Z&&(Z.disconnect(),s.active&&!s.paused&&s.containers.map(function(b){Z.observe(b,{subtree:!0,childList:!0})}))};return l={get active(){return s.active},get paused(){return s.paused},activate:function(b){if(s.active)return this;var R=d(b,"onActivate"),P=d(b,"onPostActivate"),O=d(b,"checkCanFocusTrap");O||m(),s.active=!0,s.paused=!1,s.nodeFocusedBeforeActivation=p(o),R==null||R();var U=function(){O&&m(),N(),x(),P==null||P()};return O?(O(s.containers.concat()).then(U,U),this):(U(),this)},deactivate:function(b){if(!s.active)return this;var R=cu({onDeactivate:r.onDeactivate,onPostDeactivate:r.onPostDeactivate,checkCanReturnFocus:r.checkCanReturnFocus},b);clearTimeout(s.delayInitialFocusTimer),s.delayInitialFocusTimer=void 0,S(),s.active=!1,s.paused=!1,x(),uu.deactivateTrap(i,l);var P=d(R,"onDeactivate"),O=d(R,"onPostDeactivate"),U=d(R,"checkCanReturnFocus"),M=d(R,"returnFocus","returnFocusOnDeactivate");P==null||P();var I=function(){mu(function(){M&&h(v(s.nodeFocusedBeforeActivation)),O==null||O()})};return M&&U?(U(v(s.nodeFocusedBeforeActivation)).then(I,I),this):(I(),this)},pause:function(b){return s.active?(s.manuallyPaused=!0,this._setPausedState(!0,b)):this},unpause:function(b){return s.active?(s.manuallyPaused=!1,i[i.length-1]!==this?this:this._setPausedState(!1,b)):this},updateContainerElements:function(b){var R=[].concat(b).filter(Boolean);return s.containers=R.map(function(P){return typeof P=="string"?o.querySelector(P):P}),s.active&&m(),x(),this}},Object.defineProperties(l,{_isManuallyPaused:{value:function(){return s.manuallyPaused}},_setPausedState:{value:function(b,R){if(s.paused===b)return this;if(s.paused=b,b){var P=d(R,"onPause"),O=d(R,"onPostPause");P==null||P(),S(),x(),O==null||O()}else{var U=d(R,"onUnpause"),M=d(R,"onPostUnpause");U==null||U(),m(),N(),x(),M==null||M()}return this}}}),l.updateContainerElements(a),l};const j8=["aria-labelledby"],W8={class:"media-preview-sheet__header"},Z8=["id"],H8=["aria-label"],X8=["src","alt"],G8=["src"],J8={class:"media-preview-sheet__actions"},K8=["disabled","aria-label"],q8=["aria-label","aria-pressed"],Y8=["disabled","aria-label"],Q8=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},closeLabel:{default:"Close"},previousLabel:{default:"Previous"},nextLabel:{default:"Next"},selectLabel:{default:"Select"},deselectLabel:{default:"Deselect"}},emits:["close","previous","next","toggleSelect"],setup(n,{emit:a}){const t=n,o=a,i=e.useId(),r=e.ref(null),s=e.ref(null);let l=null,d=null;const c=e.computed(()=>{var E;return((E=t.media)==null?void 0:E.mime_type.startsWith("image/"))===!0}),u=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:""),f=e.computed(()=>t.media?`Preview ${t.media.file_name}`:"Media preview"),m=e.computed(()=>t.media?`Close preview of ${t.media.file_name}`:"Close preview"),p=e.computed(()=>t.canGoPrevious?"Previous media":"No previous media"),h=e.computed(()=>t.canGoNext?"Next media":"No next media"),v=e.computed(()=>{const E=t.selected?t.deselectLabel:t.selectLabel;return t.media?t.selected?`${t.deselectLabel} ${t.media.file_name}`:`${t.selectLabel} ${t.media.file_name}`:E}),k=e.computed(()=>t.selected?t.deselectLabel:t.selectLabel),V=()=>{t.media&&o("toggleSelect",t.media)},B=E=>{if(E.key==="Escape"){E.preventDefault(),o("close");return}if(E.key==="ArrowLeft"&&t.canGoPrevious){E.preventDefault(),o("previous");return}E.key==="ArrowRight"&&t.canGoNext&&(E.preventDefault(),o("next"))},_=()=>{if(l){try{l.deactivate({returnFocus:!1})}catch{}l=null}},g=()=>{const E=d;d=null,E&&typeof E.focus=="function"&&e.nextTick(()=>{E.focus()})};return e.watch(()=>t.open&&t.media!==null,async E=>{var C;if(E){d=document.activeElement instanceof HTMLElement?document.activeElement:null,await e.nextTick();const N=r.value;if(N)try{l=z8(N,{initialFocus:()=>s.value??N,escapeDeactivates:!1,clickOutsideDeactivates:!1,returnFocusOnDeactivate:!1,allowOutsideClick:!0}),l.activate()}catch{(C=s.value)==null||C.focus()}}else _(),g()},{immediate:!0}),e.onBeforeUnmount(()=>{_()}),(E,C)=>E.open&&E.media?(e.openBlock(),e.createElementBlock("section",{key:0,ref_key:"sheetRef",ref:r,class:"media-preview-sheet",role:"dialog","aria-modal":"true","aria-labelledby":e.unref(i),tabindex:"-1","data-testid":"media-preview-sheet",onKeydown:B},[e.createElementVNode("header",W8,[e.createElementVNode("strong",{id:e.unref(i),"data-testid":"media-preview-sheet-title"},e.toDisplayString(f.value),9,Z8),e.createElementVNode("button",{ref_key:"closeButtonRef",ref:s,type:"button",class:"media-preview-sheet__close","aria-label":m.value,"data-testid":"btn-media-preview-close",onClick:C[0]||(C[0]=N=>o("close"))},e.toDisplayString(E.closeLabel),9,H8)]),c.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:u.value,alt:E.media.file_name},null,8,X8)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:u.value,controls:""},null,8,G8)),e.createElementVNode("div",J8,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!E.canGoPrevious,"aria-label":p.value,"data-testid":"btn-media-preview-previous",onClick:C[1]||(C[1]=N=>o("previous"))},e.toDisplayString(E.previousLabel),9,K8),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select","aria-label":v.value,"aria-pressed":E.selected,"data-testid":"btn-media-preview-select",onClick:V},e.toDisplayString(k.value),9,q8),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!E.canGoNext,"aria-label":h.value,"data-testid":"btn-media-preview-next",onClick:C[2]||(C[2]=N=>o("next"))},e.toDisplayString(E.nextLabel),9,Y8)])],40,j8)):e.createCommentVNode("",!0)}}),Up=Be(Q8,[["__scopeId","data-v-0ca8008b"]]),e6={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},t6={class:"media-album-grid__items"},a6={class:"media-album-grid__card-name"},n6={class:"media-album-grid__card-name"},o6=["data-testid","onClick"],i6={class:"media-album-grid__card-name"},r6={key:0,class:"media-album-grid__card-meta"},s6={key:0,class:"media-album-grid__empty"},l6=e.defineComponent({__name:"MediaSourceSheet",props:{open:{type:Boolean,default:!1},currentView:{},albums:{},viewLibraryLabel:{default:"Library"},browseAlbumsLabel:{default:"Albums"},createAlbumLabel:{default:"Create album"},enableAlbumCreation:{type:Boolean,default:!1}},emits:["close","selectLibrary","selectAlbum","createAlbum"],setup(n,{emit:a}){const t=a;return(o,i)=>o.open?(e.openBlock(),e.createElementBlock("section",e6,[e.createElementVNode("div",t6,[o.enableAlbumCreation?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-album-grid__card media-album-grid__card--create","data-testid":"btn-media-source-create-album",onClick:i[0]||(i[0]=r=>t("createAlbum"))},[i[2]||(i[2]=e.createElementVNode("div",{class:"media-album-grid__card-icon"},[e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})])],-1)),e.createElementVNode("span",a6,e.toDisplayString(o.createAlbumLabel),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":o.currentView.scope==="library"}]),"data-testid":"btn-media-source-library",onClick:i[1]||(i[1]=r=>t("selectLibrary"))},[i[3]||(i[3]=e.createStaticVNode('<div class="media-album-grid__card-icon" data-v-129f67b1><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-129f67b1><rect x="3" y="3" width="7" height="7" data-v-129f67b1></rect><rect x="14" y="3" width="7" height="7" data-v-129f67b1></rect><rect x="14" y="14" width="7" height="7" data-v-129f67b1></rect><rect x="3" y="14" width="7" height="7" data-v-129f67b1></rect></svg></div>',1)),e.createElementVNode("span",n6,e.toDisplayString(o.viewLibraryLabel),1),i[4]||(i[4]=e.createElementVNode("span",{class:"media-album-grid__card-meta"},"All media",-1))],2),(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-album-grid__card",{"is-active":o.currentView.scope==="album"&&o.currentView.albumId===r.id}]),"data-testid":`btn-media-source-album-${r.id}`,onClick:s=>t("selectAlbum",r)},[i[5]||(i[5]=e.createElementVNode("div",{class:"media-album-grid__card-icon"},[e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})])],-1)),e.createElementVNode("span",i6,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",r6,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,o6))),128))]),o.albums.length===0?(e.openBlock(),e.createElementBlock("p",s6," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),zp=Be(l6,[["__scopeId","data-v-129f67b1"]]),d6={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},c6={class:"media-upload-sheet__dropzone-text"},u6={key:0,class:"media-upload-sheet__dropzone-helper","data-testid":"text-media-upload-sheet-helper"},m6={class:"media-upload-sheet__sr-only"},p6=["accept","aria-label"],f6=["aria-label"],h6={class:"media-upload-sheet__queue-info"},v6={class:"media-upload-sheet__queue-status"},g6=["aria-valuenow","aria-label","data-testid"],y6=["aria-label"],b6=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"},dropzoneLabel:{default:"Drop files here or browse"},dropzoneHelperText:{default:""},fileInputLabel:{default:"Choose media files"},closeButtonAriaLabel:{default:"Close upload panel"},closeButtonLabel:{default:"Done"},progressAriaLabel:{}},emits:["close","filesSelected"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(!1),r=m=>{var h;return t.progressAriaLabel!==void 0?t.progressAriaLabel(m):`Uploading ${((h=m.file)==null?void 0:h.name)??"file"}`},s=m=>{const p=Number.isFinite(m.progress)?m.progress:0;return p<0?0:p>100?100:Math.round(p)},l=e.computed(()=>t.queue.length===0?"":`${t.queue.length} upload${t.queue.length===1?"":"s"} in progress`),d=m=>{const p=m.target;!(p instanceof HTMLInputElement)||p.files===null||(o("filesSelected",Array.from(p.files)),p.value="")},c=m=>{m.preventDefault(),i.value=!0},u=()=>{i.value=!1},f=m=>{var p;m.preventDefault(),i.value=!1,(p=m.dataTransfer)!=null&&p.files&&m.dataTransfer.files.length>0&&o("filesSelected",Array.from(m.dataTransfer.files))};return(m,p)=>m.open?(e.openBlock(),e.createElementBlock("section",d6,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":i.value}]),onDragover:c,onDragleave:u,onDrop:f},[p[1]||(p[1]=e.createStaticVNode('<div class="media-upload-sheet__dropzone-icon" data-v-89997025><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-89997025><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" data-v-89997025></path><polyline points="17 8 12 3 7 8" data-v-89997025></polyline><line x1="12" y1="3" x2="12" y2="15" data-v-89997025></line></svg></div>',1)),e.createElementVNode("span",c6,e.toDisplayString(m.dropzoneLabel),1),m.dropzoneHelperText?(e.openBlock(),e.createElementBlock("span",u6,e.toDisplayString(m.dropzoneHelperText),1)):e.createCommentVNode("",!0),e.createElementVNode("span",m6,e.toDisplayString(m.fileInputLabel),1),e.createElementVNode("input",{type:"file",accept:m.accept,multiple:"",class:"media-upload-sheet__file-input","data-testid":"input-media-upload-sheet","aria-label":m.fileInputLabel,onChange:d},null,40,p6)],34),m.queue.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:"media-upload-sheet__queue","aria-live":"polite","aria-label":l.value,"data-testid":"list-media-upload-sheet-queue"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.queue,h=>(e.openBlock(),e.createElementBlock("li",{key:h.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("div",h6,[e.createElementVNode("strong",null,e.toDisplayString(h.file.name),1),e.createElementVNode("span",v6,e.toDisplayString(h.status),1)]),e.createElementVNode("div",{class:"media-upload-sheet__progress-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":s(h),"aria-label":r(h),"data-testid":`progress-media-upload-sheet-${h.id}`},[e.createElementVNode("div",{class:"media-upload-sheet__progress-fill",style:e.normalizeStyle({width:`${s(h)}%`})},null,4)],8,g6)]))),128))],8,f6)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close-btn","aria-label":m.closeButtonAriaLabel,"data-testid":"btn-close-upload-sheet",onClick:p[0]||(p[0]=h=>o("close"))},e.toDisplayString(m.closeButtonLabel),9,y6)])):e.createCommentVNode("",!0)}}),jp=Be(b6,[["__scopeId","data-v-89997025"]]),w6=["aria-label","aria-pressed","data-testid"],k6=["src","alt"],_6={key:1,class:"media-thumbnail-cell__video"},E6={class:"media-thumbnail-cell__video-name"},x6={key:2,class:"media-thumbnail-cell__selected-badge"},S6={key:3,class:"media-thumbnail-cell__status-badge"},C6=["aria-label"],V6=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(n,{emit:a}){const t=n,o=a,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}`}),d=()=>{o("toggle",t.media)},c=()=>{o("preview",t.media)};return(u,f)=>(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:d},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,k6)):(e.openBlock(),e.createElementBlock("div",_6,[f[0]||(f[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",E6,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",x6," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",S6,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,w6),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:c}," Preview ",8,C6)],2))}}),Wp=Be(V6,[["__scopeId","data-v-edd4f0ad"]]),N6={class:"virtual-media-grid"},T6={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},M6={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},B6={key:2,class:"virtual-media-grid__items"},I6=["disabled"],F6=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"},loadingMessage:{default:"Loading media..."},loadMoreLabel:{default:"Load more"},loadingMoreLabel:{default:"Loading…"}},emits:["toggle","preview","loadMore"],setup(n,{emit:a}){const t=n,o=a;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",N6,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",T6,e.toDisplayString(r.loadingMessage),1)):r.items.length===0?(e.openBlock(),e.createElementBlock("div",M6,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",B6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var d,c;return e.openBlock(),e.createBlock(Wp,{key:l.uuid,media:l,selected:((d=i(l.uuid))==null?void 0:d.status)==="ready",status:(c=i(l.uuid))==null?void 0:c.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?r.loadingMoreLabel:r.loadMoreLabel),9,I6)):e.createCommentVNode("",!0)]))}}),Zp=Be(F6,[["__scopeId","data-v-34667f65"]]);function Ar(n){if(n===0)return"0 Bytes";const a=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(n)/Math.log(a));return parseFloat((n/Math.pow(a,o)).toFixed(2))+" "+t[o]}function Hp(n){var t;const a=n.split(".");return a.length>1?`.${(t=a.pop())==null?void 0:t.toLowerCase()}`:""}function bd(n){return n.type.startsWith("image/")}async function Xp(n){return bd(n)?new Promise(a=>{const t=new Image,o=URL.createObjectURL(n);t.onload=()=>{URL.revokeObjectURL(o),a({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),a(null)},t.src=o}):null}async function Gp(n,a){const t=[];if(a.maxFileSize&&n.size>a.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Ar(a.maxFileSize)}`,code:"MAX_FILE_SIZE"}),a.minFileSize&&n.size<a.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Ar(a.minFileSize)}`,code:"MIN_FILE_SIZE"}),a.acceptedMimeTypes&&a.acceptedMimeTypes.length>0&&(a.acceptedMimeTypes.some(i=>i.endsWith("/*")?n.type.startsWith(i.slice(0,-1)):n.type===i)||t.push({field:"type",message:`File type "${n.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),a.acceptedExtensions&&a.acceptedExtensions.length>0){const o=Hp(n.name);a.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if(bd(n)&&(a.maxDimensions||a.minDimensions)){const o=await Xp(n);o&&(a.maxDimensions&&(o.width>a.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${a.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>a.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${a.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),a.minDimensions&&(o.width<a.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${a.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<a.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${a.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(a.customValidator){const o=await a.customValidator(n);t.push(...o)}return{valid:t.length===0,errors:t}}function wd(n={}){const a=e.ref(n.rules||{});function t(d){a.value=d}async function o(d){return Gp(d,a.value)}async function i(d){const c=new Map;return await Promise.all(d.map(async u=>{const f=await o(u);c.set(u,f)})),c}function r(d,c){return a.value.maxItems?c+d<=a.value.maxItems:!0}const s=e.computed(()=>{const d=[];return a.value.acceptedMimeTypes&&d.push(...a.value.acceptedMimeTypes),a.value.acceptedExtensions&&d.push(...a.value.acceptedExtensions),d.join(",")});function l(d){return!a.value.acceptedMimeTypes||a.value.acceptedMimeTypes.length===0?!0:a.value.acceptedMimeTypes.some(c=>c.endsWith("/*")?d.startsWith(c.slice(0,-1)):d===c)}return{rules:a,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function $6(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function D6(n){if(n.type.startsWith("image/"))return URL.createObjectURL(n)}function kd(n){const{adapter:a,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:d,onQueueComplete:c,postUpload:u}=n,f=e.ref(new Map),m=e.ref(new Set),p=o?{rules:o}:{},{validateFile:h}=wd(p);async function v(){if(m.value.size>=t)return;const F=Array.from(f.value.entries()).find(([P,O])=>O.status==="pending"&&!m.value.has(P));if(!F){Array.from(f.value.values()).every(O=>O.status==="completed"||O.status==="error")&&f.value.size>0&&(c==null||c());return}const[b,R]=F;await k(b,R)}async function k(F,b){m.value.add(F),b.status="uploading",b.abortController=new AbortController,f.value.set(F,{...b}),r==null||r(b);try{const R={onProgress:O=>{b.progress=O,f.value.set(F,{...b}),s==null||s(b)},signal:b.abortController.signal};i&&(R.collection=i);const P=await a.upload(b.file,R);u&&(b.status="attaching",f.value.set(F,{...b}),s==null||s(b),await u(b,P.media,a)),b.status="completed",b.progress=100,b.media=P.media,f.value.set(F,{...b}),l==null||l(b,P.media)}catch(R){R.name==="AbortError"?f.value.delete(F):(b.status="error",b.error=R.message,f.value.set(F,{...b}),d==null||d(b,R))}finally{m.value.delete(F),delete b.abortController,v()}}async function V(F){var P;const b=Array.from(F),R=[];for(const O of b){const U=await h(O),M=$6(),I=D6(O),z={id:M,file:O,progress:0,status:U.valid?"pending":"error"};!U.valid&&((P=U.errors[0])!=null&&P.message)&&(z.error=U.errors[0].message),I&&(z.previewUrl=I),f.value.set(M,z);const X={media:null,clientId:M,name:O.name,order:0,upload:z,errors:U.errors};R.push(X)}for(let O=0;O<t;O++)v();return R}function B(F){const b=f.value.get(F);b&&(b.abortController&&b.abortController.abort(),b.previewUrl&&URL.revokeObjectURL(b.previewUrl),f.value.delete(F),m.value.delete(F),v())}async function _(F){const b=f.value.get(F);!b||b.status!=="error"||(b.status="pending",b.progress=0,delete b.error,f.value.set(F,{...b}),v())}function g(){for(const[F,b]of f.value.entries())(b.status==="completed"||b.status==="error")&&(b.previewUrl&&URL.revokeObjectURL(b.previewUrl),f.value.delete(F))}function E(){for(const F of f.value.values())F.abortController&&F.abortController.abort(),F.previewUrl&&URL.revokeObjectURL(F.previewUrl);f.value.clear(),m.value.clear()}function C(F){return f.value.get(F)}const N=e.computed(()=>m.value.size>0),S=e.computed(()=>m.value.size),A=e.computed(()=>Array.from(f.value.values()).filter(F=>F.status==="pending").length),Z=e.computed(()=>f.value.size===0?!0:Array.from(f.value.values()).every(F=>F.status==="completed"||F.status==="error")),x=e.computed(()=>Array.from(f.value.values()));return{uploads:f,isUploading:N,activeCount:S,pendingCount:A,isComplete:Z,addFiles:V,cancelUpload:B,retryUpload:_,clearCompleted:g,clearAll:E,getUpload:C,uploadsArray:x}}function Hn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function bi(n){return typeof n=="string"?n:null}function pu(n){return typeof n=="number"?n:null}function R6(n){return typeof n=="boolean"?n:null}function Jp(n){return Hn(n)&&typeof n.uuid=="string"&&typeof n.file_name=="string"&&typeof n.mime_type=="string"&&(typeof n.original_url=="string"||n.original_url===null)&&typeof n.size=="number"&&typeof n.disk=="string"&&typeof n.created_at=="string"&&typeof n.updated_at=="string"}function A6(n){return!Hn(n)||typeof n.id!="string"||typeof n.status!="string"?null:n.status==="ready"?Jp(n.media)?{id:n.id,status:"ready",media:n.media}:null:n.status==="missing"||n.status==="forbidden"?{id:n.id,status:n.status}:null}function L6(n){return Hn(n)?{next_cursor:bi(n.next_cursor),previous_cursor:bi(n.previous_cursor),has_more:R6(n.has_more)??!1,per_page:pu(n.per_page),count:pu(n.count)}:null}function fu(n){const a=Hn(n)?n:{},t=Array.isArray(a.data)?a.data.filter(Jp):[],o=Hn(a.meta)?a.meta:{},i=L6(o.pagination),r=(i==null?void 0:i.next_cursor)??bi(o.next_cursor)??bi(o.cursor),s=(i==null?void 0:i.has_more)??o.has_more===!0,l=Array.isArray(a.hydrated)?a.hydrated.map(A6).filter(c=>c!==null):[],d={cursor:r,has_more:s};return i!==null&&(d.pagination=i),{data:t,meta:d,hydrated:l}}function hu(n,a,t,o,i){const r={view:n.scope==="album"?{scope:"album",album_id:n.albumId}:{scope:"library"},per_page:t,sort:a.sort??"newest"};return a.query&&a.query.trim()!==""&&(r.query=a.query.trim()),a.kinds&&a.kinds.length>0&&(r.kinds=a.kinds),o!==null&&(r.cursor=o),i&&i.length>0&&(r.hydrate_ids=i),r}function vu(n){const a=new Set,t=[];for(const o of n)a.has(o.uuid)||(a.add(o.uuid),t.push(o));return t}function P6(n){var t;if(!(n instanceof Error))return null;const a=(t=n.response)==null?void 0:t.status;return typeof a=="number"?a:null}function O6(n){var a;return n instanceof Error?((a=n.response)==null?void 0:a.data)??null:null}function U6(n){if(!Hn(n))return[];const a=[];for(const t of Object.values(n)){if(typeof t=="string"&&t.trim()!==""){a.push(t.trim());continue}if(Array.isArray(t))for(const o of t){if(typeof o!="string")continue;const i=o.trim();i!==""&&a.push(i)}}return Array.from(new Set(a))}function z6(n){var r;const a=O6(n),t=Hn(a)?a:null,o=((r=bi(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=U6(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(" "):n instanceof Error?n.message:"Failed to load media."}function gu(n,a){const t=z6(a),o=P6(a);return{code:o===403?"permission_denied":n,message:t,retriable:o!==403,cause:a}}function _d(n){const a=n.perPage??40,t=e.ref([]),o=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),d=e.ref(!1),c=e.ref(null);let u=null,f=0;const m=async v=>{f+=1;const k=f;u==null||u.abort();const V=new AbortController;u=V,v?l.value=!0:s.value=!0,c.value=null,d.value=!1;try{const B=await n.httpClient.get("/v1/media/library",{params:hu(n.view.value,n.filters.value,a,v?i.value:null),signal:V.signal});if(k!==f)return;const _=fu(B);t.value=v?vu([...t.value,..._.data]):_.data,o.value=_.hydrated,i.value=_.meta.cursor,r.value=_.meta.has_more}catch(B){if(V.signal.aborted||k!==f)return;const _=gu(v?"load_more_failed":"query_failed",B);c.value=_,d.value=_.code==="permission_denied",v||(t.value=[],i.value=null,r.value=!1)}finally{k===f&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:o,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:d,error:c,loadInitial:async()=>{i.value=null,await m(!1)},loadMore:async()=>{!r.value||l.value||await m(!0)},refresh:async()=>{i.value=null,await m(!1)},hydrateSelection:async v=>{if(v.length===0)return o.value=[],[];try{const k=await n.httpClient.get("/v1/media/library",{params:hu(n.view.value,n.filters.value,1,null,v)}),V=fu(k);return o.value=V.hydrated,V.hydrated}catch(k){return c.value=gu("hydration_failed",k),[]}},prepend:v=>{t.value=vu([v,...t.value])}}}const j6="mediables.media-library.";function W6(n){return!n||n.key.trim()===""?null:`${j6}${n.key}`}function Js(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function Z6(n,a){const t=Date.parse(n);return Number.isFinite(t)?Date.now()-t>a*60*1e3:!0}function Kp(n){const a=W6(n),t=(n==null?void 0:n.ttlMinutes)??30,o=`${(n==null?void 0:n.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(a===null)return null;const l=Js();if(l===null)return null;const d=l.getItem(a);if(d===null)return null;let c;try{c=JSON.parse(d)}catch{return l.removeItem(a),null}if(typeof c!="object"||c===null||Array.isArray(c))return l.removeItem(a),null;const u=c;if(u.version!==1||typeof u.savedAt!="string"||Z6(u.savedAt,t))return l.removeItem(a),null;const f={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(m=>typeof m=="string"&&m.trim()!==""):[]};return((n==null?void 0:n.restoreView)??!0)&&u.view&&(f.view=u.view),u.filters&&(f.filters=u.filters),f},save:l=>{if(a===null)return;const d=Js();if(d===null)return;const c={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((n==null?void 0:n.restoreView)??!0)&&l.view&&(c.view=l.view),l.filters&&(c.filters=l.filters),d.setItem(a,JSON.stringify(c))},clear:()=>{if(a===null)return;const l=Js();l==null||l.removeItem(a)},sessionId:o}}function qp(n){const a=e.ref(n);return{state:a,transition:o=>{a.value=o}}}function Yp(n){return{emitMetric:(t,o)=>{const i={name:t,timestamp:new Date().toISOString()};o!==void 0&&(i.payload=o),n==null||n(i)}}}function fo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function H6(n){const a=fo(n)?n:{};return(Array.isArray(a.data)?a.data:fo(a.data)&&Array.isArray(a.data.data)?a.data.data:Array.isArray(n)?n:[]).map(o=>{if(!fo(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 X6(n){const a=fo(n)?n:{},t=fo(a.data)?a.data:fo(n)?n: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 G6(n){return n==="ready"||n==="uploading"||n==="failed"}function nr(n,a="ready"){return{id:n.uuid,media:n,status:a,countsTowardMax:G6(a)}}function J6(n,a){return n.scope==="library"?!0:a.type==="album"&&a.albumId===n.albumId}function K6(n,a){return n.scope==="library"?a.type==="library"||a.type==="album":a.type==="album"&&a.albumId===n.albumId}function Ks(n){return{code:"configuration_error",message:n,retriable:!1}}function q6(n){return typeof n!="string"||n.length===0?"document":n.startsWith("image/")?"image":n.startsWith("video/")?"video":n.startsWith("audio/")?"audio":"document"}function Y6(n,a){return a.length===0||n===null?!0:a.includes(q6(n.mime_type))}function Qp(n){var ne,L,D;const a=n.selectionMode??"multiple",t=n.maxSelection,o=n.uploadBehavior??"adapter",i=e.ref(n.initialView??{scope:"library"}),r=((ne=n.initialFilters)==null?void 0:ne.kinds)??(n.allowedMediaKinds&&n.allowedMediaKinds.length>0?[...n.allowedMediaKinds]:void 0),s=e.ref({sort:((L=n.initialFilters)==null?void 0:L.sort)??"newest",...(D=n.initialFilters)!=null&&D.query?{query:n.initialFilters.query}:{},...r?{kinds:r}:{}}),l=n.allowedMediaKinds?[...n.allowedMediaKinds]:[],d=e.ref([]),c=e.ref([]),u=e.ref(null),f=e.ref(null),m=Kp(n.sessionPolicy),{emitMetric:p}=Yp(n.telemetry),h=qp("idle"),v=_d({httpClient:n.deps.httpClient,view:i,filters:s}),k=e.computed(()=>c.value.map(j=>j.id)),V=e.computed(()=>{const j=u.value;return j===null?null:v.items.value[j]??null}),B=e.computed(()=>n.uploadTarget??{type:"library"}),_=kd({adapter:n.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:j=>j.original_url,getThumbnailUrl:j=>j.thumbnail_url??j.preview_url??j.original_url},postUpload:async(j,q,te)=>{const ce=B.value;ce.type!=="album"||!ce.albumId||await te.attach(q.uuid,{modelType:"album",modelId:ce.albumId})},onUploadComplete:(j,q)=>{const te=B.value;J6(i.value,te)&&v.prepend(q),n.autoSelectUploaded&&K6(i.value,te)&&A(q),p("upload-complete",{mediaId:q.uuid,targetType:te.type,targetAlbumId:te.albumId})},onUploadError:(j,q)=>{f.value={code:"upload_failed",message:q.message,retriable:!0,cause:q}}}),g=e.computed(()=>_.isUploading.value),E=()=>{m.save({selectedIds:[...k.value],view:i.value,filters:s.value})},C=async j=>{const q=await v.hydrateSelection(j);c.value=q.map(te=>te.status==="ready"&&te.media?nr(te.media):{id:te.id,media:null,status:te.status,countsTowardMax:!1})},N=e.computed(()=>c.value.filter(j=>j.countsTowardMax).length),S=()=>a==="single"||t===void 0?!0:N.value<t,A=j=>{if(c.value.findIndex(te=>te.id===j.uuid)>=0){a==="multiple"?c.value=c.value.filter(te=>te.id!==j.uuid):c.value=[nr(j)],E();return}if(!S()){f.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}a==="single"?c.value=[nr(j)]:c.value=[...c.value,nr(j)],f.value=null,E()},Z=async()=>{var q;h.transition("restoring");const j=m.restore();if(j===null){h.transition("ready");return}j.view&&(i.value=j.view),j.filters&&(s.value={sort:j.filters.sort??"newest",...j.filters.query?{query:j.filters.query}:{},...j.filters.kinds?{kinds:j.filters.kinds}:{}}),await v.loadInitial(),(((q=n.sessionPolicy)==null?void 0:q.restoreSelection)??!0)&&await C(j.selectedIds),h.transition("ready")};e.watch(()=>v.error.value,j=>{j!==null&&(f.value=j,h.transition("error"))});const x=async()=>{f.value=null,h.transition("idle"),await Z(),v.items.value.length===0&&!v.loading.value&&!v.permissionDenied.value&&await v.loadInitial();const j=n.defaultSelectedIds??[];c.value.length===0&&j.length>0&&await C(j),h.transition("ready")},F=async(j,q="user")=>{const te=i.value;i.value=j,q==="user"&&n.preserveSelectionOnViewChange===!1&&(c.value=[]),p("view-change",{from:te.scope,to:j.scope,reason:q}),await v.loadInitial(),E()},b=async()=>{const j=await n.deps.httpClient.get("/v1/albums");d.value=H6(j)},R=async(j,q)=>{try{const te={name:j,visibility:"private"};q&&q.trim()!==""&&(te.parent_id=q);const ce=await n.deps.httpClient.post("/v1/albums",te),me=X6(ce);return me===null?Ks("Album creation response was invalid."):(d.value=[me,...d.value.filter(ge=>ge.id!==me.id)],await F({scope:"album",albumId:me.id,albumName:me.name},"inline-album-created"),me)}catch(te){const ce={code:"album_create_failed",message:te instanceof Error?te.message:"Album creation failed.",retriable:!0,cause:te};return f.value=ce,ce}},P=async j=>{if(!n.enableUpload){f.value=Ks("Uploads are not enabled for this picker.");return}if(o!=="delegate"){if(!n.deps.uploadAdapter){f.value=Ks("Uploads require a configured upload adapter.");return}await _.addFiles(j)}},O=()=>{var te;if(l.length>0&&c.value.find(me=>me.media!==null&&!Y6(me.media,l))){const ge={code:"selection_invalid",message:`Selected media is not allowed here. Choose one of: ${l.join(", ")}.`,retriable:!0};return f.value=ge,ge}const j=((te=n.validateSelection)==null?void 0:te.call(n,c.value))??null;if(j!==null){const ce={code:"selection_invalid",message:j,retriable:!0};return f.value=ce,ce}if(c.value.filter(ce=>ce.status==="ready"&&ce.media!==null).length===0){const ce={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return f.value=ce,ce}return{orderedIds:k.value,items:[...c.value],view:i.value,filters:s.value,dirty:!0,sessionId:m.sessionId}},U=j=>{const q=v.items.value.findIndex(te=>te.uuid===j.uuid);u.value=q>=0?q:null},M=()=>{u.value=null},I=()=>{u.value===null||u.value<=0||(u.value-=1)},z=()=>{u.value===null||u.value>=v.items.value.length-1||(u.value+=1)},X=j=>{c.value=c.value.filter(q=>q.id!==j),E()},le=async()=>{await v.refresh()},ve=async j=>{s.value={...s.value,...j&&j.trim()!==""?{query:j.trim()}:{}},(!j||j.trim()==="")&&delete s.value.query,await v.loadInitial(),E()},ie=async()=>{await F({scope:"library"},"permission-unavailable")};return{view:i,filters:s,albums:d,selectedItems:c,orderedIds:k,queryItems:v.items,cursor:v.cursor,hasMore:v.hasMore,loading:v.loading,loadingMore:v.loadingMore,permissionDenied:v.permissionDenied,error:f,uploadQueue:_.uploadsArray,isUploading:g,previewIndex:u,previewItem:V,initialize:x,refresh:le,loadMore:v.loadMore,setQuery:ve,setView:F,toggleSelection:A,removeSelected:X,confirmSelection:O,openPreview:U,closePreview:M,showPreviousPreview:I,showNextPreview:z,loadAlbums:b,createAlbum:R,addUploadFiles:P,goToLibrary:ie,sessionId:m.sessionId}}const Q6=["data-testid"],eF={class:"mlp-location-bar"},tF={class:"mlp-location-bar__left"},aF={class:"mlp-location-bar__label"},nF={class:"mlp-tabs","data-testid":"media-picker-tabs"},oF={key:0,class:"mlp-search-row"},iF=["placeholder"],rF={key:2,class:"mlp-overlay-panel"},sF={key:0,class:"mlp-error","data-testid":"media-picker-error"},lF={key:5,class:"mlp-bottom-bar"},dF={key:0,class:"mlp-bottom-bar__selection"},cF={class:"mlp-bottom-bar__count"},uF={class:"mlp-bottom-bar__thumbs"},mF=["src","alt"],pF={key:1,class:"mlp-bottom-bar__thumb-placeholder"},fF=["aria-label","onClick"],hF={class:"mlp-bottom-bar__actions"},vF=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:()=>({})},showFooter:{type:Boolean,default:!0},testIdPrefix:{default:"media-picker"},telemetry:{}},emits:["update:modelValue","confirm","cancel","selection-change","view-change","error","metric","request-upload-files"],setup(n,{expose:a,emit:t}){const o=n,i=t,r=e.computed(()=>{var I,z,X,le,ve,ie,ne,L,D,j,q,te,ce,me,ge,Te,he,ye,Se,Ne,at,et,gt,Ct,yt,mt,ot,kt,xt,we,Ce,$e;return{title:((I=o.labels)==null?void 0:I.title)??"Media library",searchPlaceholder:((z=o.labels)==null?void 0:z.searchPlaceholder)??"Search your media",viewLibrary:((X=o.labels)==null?void 0:X.viewLibrary)??"Library",browseAlbums:((le=o.labels)==null?void 0:le.browseAlbums)??"Albums",createAlbum:((ve=o.labels)==null?void 0:ve.createAlbum)??"Create album",createAlbumNameLabel:((ie=o.labels)==null?void 0:ie.createAlbumNameLabel)??"Album name",emptyLibrary:((ne=o.labels)==null?void 0:ne.emptyLibrary)??"No media found in your library.",emptyAlbum:((L=o.labels)==null?void 0:L.emptyAlbum)??"No media found in this album.",networkError:((D=o.labels)==null?void 0:D.networkError)??"Unable to load media right now.",retry:((j=o.labels)==null?void 0:j.retry)??"Retry",selectedCount:((q=o.labels)==null?void 0:q.selectedCount)??(Ye=>`${Ye} selected`),confirmAction:((te=o.labels)==null?void 0:te.confirmAction)??"Attach selected",cancel:((ce=o.labels)==null?void 0:ce.cancel)??"Cancel",dismiss:((me=o.labels)==null?void 0:me.dismiss)??"Remove",uploadLabel:((ge=o.labels)==null?void 0:ge.uploadLabel)??"Upload",albumUnavailableTitle:((Te=o.labels)==null?void 0:Te.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((he=o.labels)==null?void 0:he.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((ye=o.labels)==null?void 0:ye.goToLibrary)??"Go to library",allMediaTab:((Se=o.labels)==null?void 0:Se.allMediaTab)??"All Media",loadingMedia:((Ne=o.labels)==null?void 0:Ne.loadingMedia)??"Loading media…",loadMore:((at=o.labels)==null?void 0:at.loadMore)??"Load more",loadingMore:((et=o.labels)==null?void 0:et.loadingMore)??"Loading…",uploadDropzone:((gt=o.labels)==null?void 0:gt.uploadDropzone)??"Drop files here or browse",uploadDropzoneHelper:((Ct=o.labels)==null?void 0:Ct.uploadDropzoneHelper)??"",uploadDone:((yt=o.labels)==null?void 0:yt.uploadDone)??"Done",uploadDoneAria:((mt=o.labels)==null?void 0:mt.uploadDoneAria)??"Close upload panel",uploadFileInputLabel:((ot=o.labels)==null?void 0:ot.uploadFileInputLabel)??"Choose media files",previewClose:((kt=o.labels)==null?void 0:kt.previewClose)??"Close preview",previewPrevious:((xt=o.labels)==null?void 0:xt.previewPrevious)??"Previous media",previewNext:((we=o.labels)==null?void 0:we.previewNext)??"Next media",previewSelect:((Ce=o.labels)==null?void 0:Ce.previewSelect)??"Select media",previewDeselect:(($e=o.labels)==null?void 0:$e.previewDeselect)??"Deselect media"}}),s={deps:o.deps,selectionMode:o.selectionMode,initialView:o.initialView,initialFilters:o.initialFilters,...o.maxSelection!==void 0?{maxSelection:o.maxSelection}:{},...o.modelValue.length>0||o.defaultSelectedIds.length>0?{defaultSelectedIds:o.modelValue.length>0?o.modelValue:o.defaultSelectedIds}:{},...o.sessionPolicy?{sessionPolicy:o.sessionPolicy}:{},...o.enableUpload?{enableUpload:!0}:{},uploadBehavior:o.uploadBehavior,...o.uploadTarget?{uploadTarget:o.uploadTarget}:{},...o.autoSelectUploaded?{autoSelectUploaded:!0}:{},...o.validateSelection?{validateSelection:o.validateSelection}:{},...o.allowedMediaKinds&&o.allowedMediaKinds.length>0?{allowedMediaKinds:o.allowedMediaKinds}:{},preserveSelectionOnViewChange:o.preserveSelectionOnViewChange,telemetry:I=>{var z;(z=o.telemetry)==null||z.call(o,I),i("metric",I)}},l=Qp(s),d=e.ref(o.initialFilters.query??""),c=e.ref(o.enableUpload?"upload":"media"),u=e.ref(!1),f=JSON.stringify(o.modelValue.length>0?o.modelValue:o.defaultSelectedIds);let m=null;const p=e.computed(()=>JSON.stringify(l.orderedIds.value)!==f),h=e.computed(()=>l.view.value.scope==="album"?r.value.emptyAlbum:r.value.emptyLibrary),v=e.computed(()=>r.value.selectedCount(l.selectedItems.value.length)),k=e.computed(()=>l.view.value.scope==="album"?l.view.value.albumName??"Album":r.value.viewLibrary),V=e.computed(()=>l.view.value.scope==="album"),B=()=>{m!==null&&(window.clearTimeout(m),m=null)},_=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:p.value})},g=I=>{I!==null&&i("error",I)},E=I=>typeof I.code=="string",C=I=>typeof I=="object"&&I!==null&&"code"in I&&typeof I.code=="string",N=()=>{const I=l.confirmSelection();if(E(I)){g(I);return}i("confirm",{...I,dirty:p.value})},S=(I="user")=>{i("cancel",{dirty:p.value,reason:I,sessionId:l.sessionId})},A=async()=>{c.value="albums",await l.loadAlbums()},Z=async()=>{await l.goToLibrary(),c.value="albums",await l.loadAlbums()},x=I=>{l.setView({scope:"album",albumId:I.id,albumName:I.name}),c.value="media"},F=async(I,z)=>{const X=l.view.value,le=await l.createAlbum(I,z);if(C(le)){g(le);return}u.value=!1,c.value="media",i("view-change",{from:X,to:{scope:"album",albumId:le.id,albumName:le.name},reason:"inline-album-created",restoredFromSession:!1})},b=async I=>{if(o.uploadBehavior==="delegate"){i("request-upload-files",{files:[...I],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(I)};function R(I){var z;return I?I.thumbnail_url??((z=I.conversion_urls)==null?void 0:z.thumb)??I.preview_url??I.original_url??I.url??null:null}function P(I){return I!=null&&I.mime_type?I.mime_type.startsWith("image/"):!1}e.watch(()=>d.value,I=>{B(),m=window.setTimeout(()=>{l.setQuery(I)},250)}),e.watch(()=>l.selectedItems.value,()=>{_()},{deep:!0}),e.watch(()=>l.error.value,I=>{g(I)}),e.watch(()=>o.enableUpload,I=>{!I&&c.value==="upload"&&(c.value="media")}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{B()}),a({refresh:l.refresh});function O(I){if(I==="albums"){A();return}if(I==="upload"&&!o.enableUpload){c.value="media";return}c.value=I}const U=e.computed(()=>({activeTab:c.value,setActiveTab:O,enableUpload:o.enableUpload,labels:{uploadLabel:r.value.uploadLabel,allMediaTab:r.value.allMediaTab,browseAlbums:r.value.browseAlbums}})),M=e.computed(()=>({query:d.value,setQuery:I=>{d.value=I},placeholder:r.value.searchPlaceholder}));return(I,z)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":I.testIdPrefix},[e.createElementVNode("header",eF,[e.createElementVNode("div",tF,[V.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mlp-location-bar__back","aria-label":"Back to library","data-testid":"btn-media-picker-back",onClick:Z},[...z[8]||(z[8]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",aF,e.toDisplayString(k.value),1)])]),e.renderSlot(I.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(U.value)),()=>[e.createElementVNode("nav",nF,[I.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="upload"}]),"data-testid":"tab-media-picker-upload",onClick:z[0]||(z[0]=X=>c.value="upload")},e.toDisplayString(r.value.uploadLabel),3)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="media"}]),"data-testid":"tab-media-picker-all",onClick:z[1]||(z[1]=X=>c.value="media")},e.toDisplayString(r.value.allMediaTab),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="albums"}]),"data-testid":"tab-media-picker-albums",onClick:A},e.toDisplayString(r.value.browseAlbums),3)])],!0),c.value==="media"||c.value==="albums"?(e.openBlock(),e.createElementBlock("div",oF,[e.renderSlot(I.$slots,"search",e.normalizeProps(e.guardReactiveProps(M.value)),()=>[z[9]||(z[9]=e.createElementVNode("svg",{class:"mlp-search-row__icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("circle",{cx:"11",cy:"11",r:"8"}),e.createElementVNode("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[2]||(z[2]=X=>d.value=X),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,iF),[[e.vModelText,d.value]])],!0)])):e.createCommentVNode("",!0),I.enableUpload&&c.value==="upload"?(e.openBlock(),e.createBlock(jp,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:I.accept,"upload-label":r.value.uploadLabel,"dropzone-label":r.value.uploadDropzone,"dropzone-helper-text":r.value.uploadDropzoneHelper,"file-input-label":r.value.uploadFileInputLabel,"close-button-label":r.value.uploadDone,"close-button-aria-label":r.value.uploadDoneAria,onClose:z[3]||(z[3]=X=>c.value="media"),onFilesSelected:b},null,8,["queue","accept","upload-label","dropzone-label","dropzone-helper-text","file-input-label","close-button-label","close-button-aria-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",rF,[e.createVNode(Fp,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:z[4]||(z[4]=X=>u.value=!1),onCreate:F},null,8,["open","name-label","albums"])])):e.createCommentVNode("",!0),e.unref(l).permissionDenied.value&&e.unref(l).view.value.scope==="album"?(e.openBlock(),e.createBlock($p,{key:3,title:r.value.albumUnavailableTitle,body:r.value.albumUnavailableBody,"action-label":r.value.goToLibrary,onGoToLibrary:e.unref(l).goToLibrary},null,8,["title","body","action-label","onGoToLibrary"])):e.createCommentVNode("",!0),!e.unref(l).permissionDenied.value||e.unref(l).view.value.scope!=="album"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:4},[e.unref(l).error.value?(e.openBlock(),e.createElementBlock("div",sF,[e.createElementVNode("p",null,e.toDisplayString(e.unref(l).error.value.message||r.value.networkError),1),e.createElementVNode("button",{type:"button",class:"mlp-error__retry",onClick:z[5]||(z[5]=(...X)=>e.unref(l).refresh&&e.unref(l).refresh(...X))},e.toDisplayString(r.value.retry),1)])):e.createCommentVNode("",!0),c.value==="media"?(e.openBlock(),e.createBlock(Zp,{key:1,items:e.unref(l).queryItems.value,"selected-items":e.unref(l).selectedItems.value,loading:e.unref(l).loading.value,"loading-more":e.unref(l).loadingMore.value,"has-more":e.unref(l).hasMore.value,"empty-message":h.value,"loading-message":r.value.loadingMedia,"load-more-label":r.value.loadMore,"loading-more-label":r.value.loadingMore,"test-id-prefix":`${I.testIdPrefix}-item`,onToggle:e.unref(l).toggleSelection,onPreview:e.unref(l).openPreview,onLoadMore:e.unref(l).loadMore},null,8,["items","selected-items","loading","loading-more","has-more","empty-message","loading-message","load-more-label","loading-more-label","test-id-prefix","onToggle","onPreview","onLoadMore"])):c.value==="albums"?(e.openBlock(),e.createBlock(zp,{key:2,open:!0,"current-view":e.unref(l).view.value,albums:e.unref(l).albums.value,"view-library-label":r.value.viewLibrary,"browse-albums-label":r.value.browseAlbums,"create-album-label":r.value.createAlbum,"enable-album-creation":I.enableAlbumCreation,onSelectLibrary:Z,onSelectAlbum:x,onCreateAlbum:z[6]||(z[6]=X=>u.value=!0)},null,8,["current-view","albums","view-library-label","browse-albums-label","create-album-label","enable-album-creation"])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),I.showFooter?(e.openBlock(),e.createElementBlock("footer",lF,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",dF,[e.createElementVNode("span",cF,e.toDisplayString(v.value),1),e.createElementVNode("div",uF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,X=>{var le,ve,ie;return e.openBlock(),e.createElementBlock("div",{key:X.id,class:"mlp-bottom-bar__thumb-item"},[P(X.media)&&R(X.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:R(X.media),alt:((le=X.media)==null?void 0:le.alt_text)??((ve=X.media)==null?void 0:ve.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,mF)):(e.openBlock(),e.createElementBlock("div",pF,[...z[10]||(z[10]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[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)])])),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__thumb-remove","aria-label":`${r.value.dismiss} ${((ie=X.media)==null?void 0:ie.file_name)??X.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:ne=>e.unref(l).removeSelected(X.id)},[...z[11]||(z[11]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,fF)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",hF,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:z[7]||(z[7]=X=>S())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:N},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),I.enablePreview?(e.openBlock(),e.createBlock(Up,{key:6,open:e.unref(l).previewItem.value!==null,media:e.unref(l).previewItem.value,"can-go-previous":e.unref(l).previewIndex.value!==null&&e.unref(l).previewIndex.value>0,"can-go-next":e.unref(l).previewIndex.value!==null&&e.unref(l).previewIndex.value<e.unref(l).queryItems.value.length-1,selected:e.unref(l).previewItem.value!==null&&e.unref(l).orderedIds.value.includes(e.unref(l).previewItem.value.uuid),"close-label":r.value.previewClose,"previous-label":r.value.previewPrevious,"next-label":r.value.previewNext,"select-label":r.value.previewSelect,"deselect-label":r.value.previewDeselect,onClose:e.unref(l).closePreview,onPrevious:e.unref(l).showPreviousPreview,onNext:e.unref(l).showNextPreview,onToggleSelect:e.unref(l).toggleSelection},null,8,["open","media","can-go-previous","can-go-next","selected","close-label","previous-label","next-label","select-label","deselect-label","onClose","onPrevious","onNext","onToggleSelect"])):e.createCommentVNode("",!0)],8,Q6))}}),ef=Be(vF,[["__scopeId","data-v-68a73e25"]]),gF={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},yF={class:"media-library-picker-modal__panel"},bF=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:{},showFooter:{type:Boolean},testIdPrefix:{},telemetry:{},isOpen:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0}},emits:["update:modelValue","confirm","cancel","close"],setup(n,{emit:a}){const t=n,o=a,i=()=>{t.closeOnBackdrop&&o("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",gF,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",yF,[e.createVNode(ef,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)}}),wF=Be(bF,[["__scopeId","data-v-a92e8703"]]),kF={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},_F={class:"media-selection-tray__header"},EF={class:"media-selection-tray__title"},xF={class:"media-selection-tray__items"},SF={class:"media-selection-tray__item-preview"},CF=["src","alt"],VF={key:1,class:"media-selection-tray__file-icon"},NF={class:"media-selection-tray__item-copy"},TF=["aria-label","onClick"],MF=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(n,{emit:a}){const t=a;function o(r){var s;return r?r.thumbnail_url??((s=r.conversion_urls)==null?void 0:s.thumb)??r.preview_url??r.original_url??r.url??null:null}function i(r){return r!=null&&r.mime_type?r.mime_type.startsWith("image/"):!1}return(r,s)=>r.items.length>0?(e.openBlock(),e.createElementBlock("section",kF,[e.createElementVNode("header",_F,[e.createElementVNode("h3",EF,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",xF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var d,c,u,f;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",SF,[i(l.media)&&o(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:o(l.media),alt:((d=l.media)==null?void 0:d.alt_text)??((c=l.media)==null?void 0:c.file_name)??"Selected media",class:"media-selection-tray__thumb"},null,8,CF)):(e.openBlock(),e.createElementBlock("div",VF,[...s[0]||(s[0]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[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)])]))]),e.createElementVNode("div",NF,[e.createElementVNode("strong",null,e.toDisplayString(((u=l.media)==null?void 0:u.file_name)??l.id),1),e.createElementVNode("span",null,e.toDisplayString(l.status),1)]),e.createElementVNode("button",{type:"button",class:"media-selection-tray__remove","aria-label":`${r.dismissLabel} ${((f=l.media)==null?void 0:f.file_name)??l.id}`,onClick:m=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,TF)])}),128))])])):e.createCommentVNode("",!0)}}),BF=Be(MF,[["__scopeId","data-v-f2a3d69d"]]);function Ed(n={}){const a=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),d=e.computed(()=>l.value!==null),c=V=>{if(r.value++,l.value=null,i.value=null,t.value=!1,V!=null&&typeof V=="object"&&!(V instanceof Blob)&&("image"in V||"state"in V||"sessionKey"in V)){const B=V;o.value=B.image??null,s.value=B.state??null}else o.value=V??null,s.value=null;a.value=!0},u=()=>{a.value=!1,o.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},f=async V=>{try{return t.value=!0,i.value=V,n.onSave&&await n.onSave(V),u(),V}catch(B){const _=B;throw l.value=_,n.onError&&n.onError(_),_}finally{t.value=!1}},m=()=>{n.onCancel&&n.onCancel(),u()},p=V=>{l.value=V,n.onError&&n.onError(V)},h=()=>{l.value=null},v=()=>i.value,k=e.computed(()=>a.value&&i.value!==null&&!t.value);return{isOpen:a,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:d,hasUnsavedChanges:k,open:c,close:u,handleSave:f,handleCancel:m,handleError:p,clearError:h,getEditedImage:v}}let qs=null;function IF(n){return qs||(qs=Ed(n)),qs}function FF(n){return a=>new Promise((t,o)=>{Ed({...n,onSave:async r=>{n!=null&&n.onSave&&await n.onSave(r),t(r)},onError:r=>{n!=null&&n.onError&&n.onError(r),o(r)},onCancel:()=>{n!=null&&n.onCancel&&n.onCancel(),o(new Error("User cancelled"))}}).open(a)})}function xd(n){return n.filter(a=>a.media&&!a.markedForRemoval).map((a,t)=>{const o={uuid:a.media.uuid,name:a.name,order:t};return a.customProperties&&(o.custom_properties=a.customProperties),o})}function Ol(n){return n.map((a,t)=>{const o={media:a,clientId:a.uuid,name:a.name||a.file_name,order:t};return a.custom_properties&&(o.customProperties=a.custom_properties),o})}function Sd(n){if(n){const t={};n.apiBaseUrl!==void 0&&(t.apiBaseUrl=n.apiBaseUrl),n.isAdmin!==void 0&&(t.isAdmin=n.isAdmin),ho(t)}return{name:"mediables",async upload(t,o){const r=await va().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 va().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await va().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await va().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await va().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await va().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return va().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 va().deleteMedia(t)},async update(t,o){const r=await va().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),ho(o)}}}let gr=null;function $F(){return gr||(gr=Sd()),gr}function DF(){gr=null}const RF={apiBaseUrl:"/media-library-pro"};function or(){var n;return typeof document>"u"?null:((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))||null}function Ys(n){const a={uuid:n.uuid,file_name:n.fileName||n.name,mime_type:`application/${n.extension}`,size:n.size,disk:"public",original_url:n.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return n.name&&(a.name=n.name),n.original_url&&(a.url=n.original_url),n.preview_url&&(a.thumbnail_url=n.preview_url,a.preview_url=n.preview_url),n.custom_properties&&(a.custom_properties=n.custom_properties),a}function Cd(n){const a={...RF,...n};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",...a.headers},l=a.csrfToken||or();l&&(s["X-CSRF-TOKEN"]=l);const d={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(d.signal=i.signal);const c=await fetch(`${a.apiBaseUrl}/uploads`,d);if(!c.ok){const m=await c.json().catch(()=>({message:"Upload failed"}));throw new Error(m.message||`HTTP ${c.status}`)}const u=await c.json(),f=Ys(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:f,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...a.headers},r=a.csrfToken||or();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(`${a.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(Ys)}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",...a.headers},r=a.csrfToken||or();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${a.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",...a.headers},s=a.csrfToken||or();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${a.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const c=await l.json().catch(()=>({message:"Update failed"}));throw new Error(c.message||`HTTP ${l.status}`)}const d=await l.json();return Ys(d)},configure(o){Object.assign(a,o)}}}let yr=null;function AF(){return yr||(yr=Cd()),yr}function LF(){yr=null}function tf(n,a){switch(n){case"mediables":return Sd(a);case"spatie":return Cd(a);default:throw new Error(`Unknown adapter: ${n}`)}}function af(n={}){const{enabled:a=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=n,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),d=e.ref(!1);let c=null;function u(B,_,g){a&&("dataTransfer"in B&&B.dataTransfer&&(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",String(g))),c=B.target,c&&c.classList.add(r),l.value={isDragging:!0,dragIndex:g,dropIndex:g,draggedItem:_},d.value=!0,o==null||o(_,g))}function f(B,_){var g;if(!(!a||!l.value.isDragging)&&(B.preventDefault(),l.value.dropIndex!==_)){const E=document.querySelector(`.${s}`);E==null||E.classList.remove(s);const C=(g=B.target)==null?void 0:g.closest("[data-index]");C==null||C.classList.add(s),l.value.dropIndex=_}}function m(){if(!l.value.isDragging)return;const{dragIndex:B,dropIndex:_,draggedItem:g}=l.value;c&&c.classList.remove(r);const E=document.querySelector(`.${s}`);E==null||E.classList.remove(s),B!==null&&_!==null&&B!==_&&g&&(t==null||t({fromIndex:B,toIndex:_,item:g})),h(),i==null||i()}function p(){c&&c.classList.remove(r);const B=document.querySelector(`.${s}`);B==null||B.classList.remove(s),h(),i==null||i()}function h(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},d.value=!1,c=null}function v(B,_,g){const E=[...B],[C]=E.splice(_,1);return E.splice(g,0,C),E.map((N,S)=>({...N,order:S}))}function k(B,_){return{draggable:a,"data-index":_,onDragstart:g=>u(g,B,_),onDragover:g=>f(g,_),onDragend:()=>m(),onDrop:g=>{g.preventDefault(),m()}}}function V(B){B.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",V)}),e.onUnmounted(()=>{document.removeEventListener("keydown",V),p()}),{dragState:l,isDragging:d,startDrag:u,handleDragOver:f,endDrag:m,cancelDrag:p,reorderItems:v,getDragProps:k}}function ms(n={}){const{initialItems:a=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:d=!0,disabled:c=!1,rules:u={},adapterType:f="mediables",adapter:m,maxConcurrentUploads:p=3,onChange:h,onUpload:v,onUploadComplete:k,onUploadError:V,onRemove:B,onReorder:_,onError:g,onReadyToSubmitChange:E}=n,C={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},N=m||tf(f),S=e.ref([]),A=e.ref(!1),Z=e.ref([]);function x(he){if(he.length===0)return[];const ye=he[0];return"media"in ye&&"clientId"in ye?he:Ol(he)}S.value=x(a);const{acceptString:F,canAddFiles:b}=wd({rules:C}),R=kd({adapter:N,maxConcurrent:p,rules:C,collection:i,onUploadStart:he=>{v==null||v(he)},onUploadComplete:(he,ye)=>{const Se=S.value.findIndex(Ne=>Ne.clientId===he.id);Se!==-1&&(S.value[Se]={...S.value[Se],media:ye,name:ye.name||ye.file_name,upload:{...he,status:"completed"}}),k==null||k(ye)},onUploadError:(he,ye)=>{const Se=S.value.findIndex(Ne=>Ne.clientId===he.id);Se!==-1&&(S.value[Se]={...S.value[Se],upload:{...he,status:"error",error:ye.message},errors:[{field:"upload",message:ye.message,code:"UPLOAD_ERROR"}]}),V==null||V({file:he.file,message:ye.message})},onQueueComplete:()=>{h==null||h(S.value)}}),{dragState:P,getDragProps:O,reorderItems:U}=af({enabled:d&&!c,onReorder:he=>{S.value=U(S.value,he.fromIndex,he.toIndex),_==null||_(S.value),h==null||h(S.value)}}),M=e.computed(()=>R.isUploading.value),I=e.computed(()=>!R.isUploading.value&&R.pendingCount.value===0),z=e.computed(()=>r?S.value.length>=r:!1),X=e.computed(()=>xd(S.value)),le=e.computed(()=>S.value.length),ve=e.computed(()=>r?Math.max(0,r-S.value.length):1/0);e.watch(I,he=>{E==null||E(he)});function ie(he){S.value=x(he),h==null||h(S.value)}async function ne(he){if(c)return;const ye=Array.from(he);if(!b(ye.length,S.value.length)){const et={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};Z.value=[et],g==null||g([et]);return}const Se=await R.addFiles(ye),Ne=S.value.length,at=Se.map((et,gt)=>({...et,order:Ne+gt}));S.value=[...S.value,...at],h==null||h(S.value)}function L(he){c||(he.upload&&(he.upload.status==="uploading"||he.upload.status==="pending")&&R.cancelUpload(he.clientId),S.value=S.value.filter(ye=>ye.clientId!==he.clientId),S.value=S.value.map((ye,Se)=>({...ye,order:Se})),B==null||B(he),h==null||h(S.value))}function D(he){const ye=S.value.find(Se=>Se.clientId===he);ye&&L(ye)}function j(){c||(R.clearAll(),S.value=[],h==null||h(S.value))}function q(he,ye){c||!d||(S.value=U(S.value,he,ye),_==null||_(S.value),h==null||h(S.value))}function te(he,ye){if(c)return;const Se=S.value.findIndex(Ne=>Ne.clientId===he);Se!==-1&&(S.value[Se]={...S.value[Se],...ye},h==null||h(S.value))}function ce(he){R.cancelUpload(he),D(he)}async function me(he){await R.retryUpload(he)}async function ge(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const he={modelType:t,modelId:o,collection:i},ye=S.value.filter(Se=>Se.media&&!Se.markedForRemoval).map(Se=>Se.media.uuid);A.value=!0;try{await N.attachMany(ye,he),await N.reorder(he,ye)}finally{A.value=!1}}async function Te(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const he={modelType:t,modelId:o,collection:i};A.value=!0;try{const ye=await N.fetchModelMedia(he);S.value=Ol(ye),h==null||h(S.value)}finally{A.value=!1}}return e.onMounted(()=>{t&&o&&a.length===0&&Te().catch(console.error)}),e.onUnmounted(()=>{R.clearAll()}),{items:S,setItems:ie,addFiles:ne,removeItem:L,removeItemById:D,clearAll:j,reorderItems:q,updateItem:te,cancelUpload:ce,retryUpload:me,save:ge,load:Te,isLoading:A,isUploading:M,isReadyToSubmit:I,isAtMaxItems:z,errors:Z,dragState:P,getDragProps:O,adapter:N,formValues:X,acceptString:F,count:le,remainingSlots:ve}}const PF=["aria-disabled"],OF=["accept","multiple","disabled"],UF={class:"media-dropzone__content"},zF={class:"media-dropzone__title"},jF={class:"media-dropzone__subtitle"},WF=["disabled"],ZF={key:0,class:"media-dropzone__helper"},HF=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(n,{emit:a}){const t=n,o=a,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 v=[];return t.maxFileSize&&v.push(`Max size: ${Ar(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&v.push(`Max files: ${t.maxItems}`),v.join(" • ")});function d(v){v.preventDefault(),!t.disabled&&(i.value=!0)}function c(v){v.preventDefault(),i.value=!1}function u(v){v.preventDefault()}function f(v){var V;if(v.preventDefault(),i.value=!1,t.disabled)return;const k=(V=v.dataTransfer)==null?void 0:V.files;k&&k.length>0&&o("files",k)}function m(){var v;t.disabled||(v=r.value)==null||v.click()}function p(v){const k=v.target,V=k.files;V&&V.length>0&&o("files",V),k.value=""}function h(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m())}return(v,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":v.disabled,"aria-label":"Upload files",onClick:m,onKeydown:h,onDragenter:d,onDragleave:c,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:v.accept,multiple:v.multiple,disabled:v.disabled,class:"media-dropzone__input",onChange:p},null,40,OF),e.createElementVNode("div",UF,[e.renderSlot(v.$slots,"icon",{},()=>[k[0]||(k[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",zF,[e.renderSlot(v.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(v.title),1)],!0)]),e.createElementVNode("p",jF,[e.renderSlot(v.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(v.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:v.disabled,onClick:e.withModifiers(m,["stop"])},[e.renderSlot(v.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(v.buttonText),1)],!0)],8,WF),l.value?(e.openBlock(),e.createElementBlock("p",ZF,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,PF))}}),Vd=Be(HF,[["__scopeId","data-v-b1366c1e"]]),XF=["data-index"],GF={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},JF={class:"media-item__thumbnail"},KF=["src","alt"],qF={key:1,class:"media-item__file-icon"},YF={key:2,class:"media-item__progress-overlay"},QF={class:"media-item__progress-text"},e$={key:3,class:"media-item__processing-overlay"},t$={key:4,class:"media-item__error-overlay"},a$={class:"media-item__info"},n$=["title"],o$={key:0,class:"media-item__size"},i$={key:1,class:"media-item__error-message"},r$={class:"media-item__actions"},s$=["disabled"],l$=["disabled"],d$=["disabled"],c$=["disabled"],u$=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(!1),r=e.computed(()=>{var _;return(_=t.item.upload)!=null&&_.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var _,g,E;return((_=t.item.upload)==null?void 0:_.status)==="uploading"||((g=t.item.upload)==null?void 0:g.status)==="pending"||((E=t.item.upload)==null?void 0:E.status)==="queued"}),l=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.status)==="processing"}),d=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.status)==="error"||t.item.errors&&t.item.errors.length>0}),c=e.computed(()=>{var _;return(_=t.item.upload)!=null&&_.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.progress)||0}),f=e.computed(()=>{var _;return t.item.name||((_=t.item.media)==null?void 0:_.file_name)||"Unknown file"}),m=e.computed(()=>{var N,S;const _=((N=t.item.media)==null?void 0:N.size)||((S=t.item.upload)==null?void 0:S.file.size);if(!_)return"";const g=1024,E=["Bytes","KB","MB","GB"],C=Math.floor(Math.log(_)/Math.log(g));return parseFloat((_/Math.pow(g,C)).toFixed(2))+" "+E[C]}),p=e.computed(()=>{var g,E;const _=((g=t.item.media)==null?void 0:g.mime_type)||((E=t.item.upload)==null?void 0:E.file.type);return _==null?void 0:_.startsWith("image/")}),h=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.value,"media-item--error":d.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function v(){t.disabled||o("remove",t.item)}function k(){t.disabled||o("edit",t.item)}function V(){t.disabled||o("retry",t.item)}function B(){t.disabled||o("cancel",t.item)}return(_,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),"data-index":_.index,onMouseenter:g[0]||(g[0]=E=>i.value=!0),onMouseleave:g[1]||(g[1]=E=>i.value=!1)},[_.sortable&&!_.disabled?(e.openBlock(),e.createElementBlock("div",GF,[...g[2]||(g[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",JF,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:f.value,class:"media-item__image"},null,8,KF)):(e.openBlock(),e.createElementBlock("div",qF,[...g[3]||(g[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",YF,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",QF,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",e$,[...g[4]||(g[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",t$,[...g[5]||(g[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",a$,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,n$),m.value?(e.openBlock(),e.createElementBlock("span",o$,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",i$,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",r$,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:_.disabled,"aria-label":"Cancel upload",onClick:B},[...g[6]||(g[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,s$)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:_.disabled,"aria-label":"Retry upload",onClick:V},[...g[7]||(g[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,l$)):e.createCommentVNode("",!0),_.showEdit&&_.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:_.disabled,"aria-label":"Edit",onClick:k},[...g[8]||(g[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,d$)):e.createCommentVNode("",!0),_.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:_.disabled,"aria-label":"Remove",onClick:v},[...g[9]||(g[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,c$)):e.createCommentVNode("",!0)])],42,XF))}}),Nd=Be(u$,[["__scopeId","data-v-ff81c9ec"]]),m$=["aria-label"],p$=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],f$={key:0,class:"media-collection__footer"},h$={class:"media-collection__count"},v$={key:0},g$={key:0,class:"media-collection__uploading"},y$=["name","value"],b$=["name","value"],w$=["name","value"],k$=["name","value"],_$={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},E$=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(n,{emit:a}){const t=n,o=a,i={initialItems:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxItems:t.maxItems,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,sortable:t.sortable,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:M=>{o("update:modelValue",M),o("change",M)},onUpload:M=>{o("upload",M)},onUploadComplete:M=>{o("upload-complete",M)},onUploadError:M=>{o("upload-error",M)},onRemove:M=>{o("remove",M)},onReorder:M=>{o("reorder",M)},onError:M=>{o("validation-error",M)},onReadyToSubmitChange:M=>{o("is-ready-to-submit-change",M)}},{items:r,setItems:s,addFiles:l,removeItem:d,reorderItems:c,cancelUpload:u,retryUpload:f,isLoading:m,isUploading:p,isAtMaxItems:h,errors:v,dragState:k,getDragProps:V,adapter:B,formValues:_,acceptString:g,count:E,remainingSlots:C}=ms(i);e.provide("mediaAdapter",B),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:d,reorderItems:c}),e.watch(()=>t.modelValue,M=>{M!==r.value&&s(M)},{deep:!0});const N=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),S=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":m.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":k.value.isDragging}));function A(M){l(M)}function Z(M){d(M)}function x(M){f(M.clientId)}function F(M){u(M.clientId)}function b(M){}function R(M,I,z){if(!t.sortable||t.disabled)return;const X=V(I,z);X.onDragstart&&X.onDragstart(M)}function P(M,I){if(!t.sortable||t.disabled)return;M.preventDefault();const z=r.value[I],X=V(z,I);X.onDragover&&X.onDragover(M)}function O(M,I){const z=V(M,I);z.onDragend&&z.onDragend()}function U(M,I){M.preventDefault();const z=r.value[I],X=V(z,I);X.onDrop&&X.onDrop(M)}return(M,I)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(S.value)},[e.renderSlot(M.$slots,"dropzone",{addFiles:e.unref(l)},()=>[N.value?(e.openBlock(),e.createBlock(Vd,{key:0,accept:e.unref(g),multiple:M.maxItems!==1,disabled:M.disabled,"max-file-size":M.maxFileSize,"max-items":e.unref(C),onFiles:A},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(E)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(z,X)=>e.renderSlot(M.$slots,"item",{key:z.clientId,item:z,index:X,remove:()=>Z(z)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(k).dropIndex===X}]),draggable:M.sortable&&!M.disabled,"data-index":X,onDragstart:le=>R(le,z,X),onDragover:le=>P(le,X),onDragend:le=>O(z,X),onDrop:le=>U(le,X)},[e.createVNode(Nd,{item:z,adapter:e.unref(B),disabled:M.disabled,sortable:M.sortable,"show-remove":!M.readonly,"show-edit":!1,index:X,onRemove:Z,onRetry:x,onCancel:F,onEdit:b},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,p$)],!0)),128))],8,m$)):N.value?e.createCommentVNode("",!0):e.renderSlot(M.$slots,"empty",{key:1},()=>[I[0]||(I[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(M.$slots,"footer",{count:e.unref(E),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",f$,[e.createElementVNode("span",h$,[e.createTextVNode(e.toDisplayString(e.unref(E))+" "+e.toDisplayString(e.unref(E)===1?"file":"files")+" ",1),M.maxItems?(e.openBlock(),e.createElementBlock("span",v$," / "+e.toDisplayString(M.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",g$," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),M.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(z,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${z.uuid}`,type:"hidden",name:`${M.name}[${X}][uuid]`,value:z.uuid},null,8,y$))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(z,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${z.uuid}-name`,type:"hidden",name:`${M.name}[${X}][name]`,value:z.name},null,8,b$))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(z,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${z.uuid}-order`,type:"hidden",name:`${M.name}[${X}][order]`,value:z.order},null,8,w$))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(z,X)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${M.name}-${z.uuid}-props`},[z.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${M.name}[${X}][custom_properties]`,value:JSON.stringify(z.custom_properties)},null,8,k$)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",_$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),z=>(e.openBlock(),e.createElementBlock("p",{key:z.code||z.message,class:"media-collection__error"},e.toDisplayString(z.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),x$=Be(E$,[["__scopeId","data-v-10a5bfff"]]);function Td(n={}){const{initialItem:a,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:d,onReadyToSubmitChange:c,...u}=n,m={...u,initialItems:a?[a]:[],maxItems:1,sortable:!1,onChange:N=>{t==null||t(N[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:d,onReadyToSubmitChange:c},p=ms(m),h=e.computed(()=>p.items.value[0]||null),v=e.computed(()=>h.value!==null),k=e.computed(()=>p.formValues.value[0]||null);function V(N){N===null?p.clearAll():p.setItems([N])}async function B(N){const S=h.value;S&&p.removeItem(S),await p.addFiles([N])}function _(){h.value&&p.removeItem(h.value)}async function g(N){const S=h.value;S&&p.removeItem(S),await p.addFiles([N]);const A=p.items.value[0];A&&(o==null||o(S,A))}function E(){var N;(N=h.value)!=null&&N.upload&&p.cancelUpload(h.value.clientId)}async function C(){var N,S;((S=(N=h.value)==null?void 0:N.upload)==null?void 0:S.status)==="error"&&await p.retryUpload(h.value.clientId)}return{item:h,setItem:V,addFile:B,removeItem:_,replaceItem:g,cancelUpload:E,retryUpload:C,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:v,errors:p.errors,adapter:p.adapter,formValue:k,acceptString:p.acceptString}}const S$=["accept","disabled"],C$={class:"media-attachment__preview"},V$=["name","value"],N$=["name","value"],T$=["name","value"],M$=["name","value"],B$={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},I$=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(n,{emit:a}){const t=n,o=a,i=e.ref(null),r={initialItem:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:x=>{o("update:modelValue",x),o("change",x)},onUpload:x=>{o("upload",x)},onUploadComplete:x=>{o("upload-complete",x)},onUploadError:x=>{o("upload-error",x)},onRemove:x=>{o("remove",x)},onReplace:(x,F)=>{o("replace",F)},onError:x=>{o("validation-error",x)},onReadyToSubmitChange:x=>{o("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,hasItem:h,errors:v,adapter:k,formValue:V,acceptString:B}=Td(r);e.provide("mediaAdapter",k),e.watch(()=>t.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const _=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),g=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":h.value}));function E(x){x.length>0&&d(x[0])}function C(){var x;(x=i.value)==null||x.click()}function N(x){const F=x.target,b=F.files;b&&b.length>0&&u(b[0]),F.value=""}function S(x){c()}function A(x){m()}function Z(x){f()}return(x,F)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(g.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(B),disabled:x.disabled,class:"media-attachment__hidden-input",onChange:N},null,40,S$),_.value?e.renderSlot(x.$slots,"dropzone",{key:0,addFile:e.unref(d)},()=>[e.createVNode(Vd,{accept:e.unref(B),multiple:!1,disabled:x.disabled,"max-file-size":x.maxFileSize,onFiles:E},null,8,["accept","disabled","max-file-size"])],!0):e.unref(h)&&e.unref(s)?e.renderSlot(x.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(c),replace:C},()=>[e.createElementVNode("div",C$,[e.createVNode(Nd,{item:e.unref(s),adapter:e.unref(k),disabled:x.disabled,sortable:!1,"show-remove":!x.readonly,"show-edit":!1,onRemove:S,onRetry:A,onCancel:Z},null,8,["item","adapter","disabled","show-remove"]),x.showReplaceButton&&!x.readonly&&!x.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:C},[...F[0]||(F[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(x.$slots,"empty",{key:2},()=>[F[1]||(F[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),x.generateFormFields&&e.unref(V)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${x.name}[uuid]`,value:e.unref(V).uuid},null,8,V$),e.createElementVNode("input",{type:"hidden",name:`${x.name}[name]`,value:e.unref(V).name},null,8,N$),e.createElementVNode("input",{type:"hidden",name:`${x.name}[order]`,value:e.unref(V).order},null,8,T$),e.unref(V).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${x.name}[custom_properties]`,value:JSON.stringify(e.unref(V).custom_properties)},null,8,M$)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",B$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),b=>(e.openBlock(),e.createElementBlock("p",{key:b.code||b.message,class:"media-attachment__error"},e.toDisplayString(b.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),F$=Be(I$,[["__scopeId","data-v-26911174"]]),nf={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"}},$$=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(n,{expose:a,emit:t}){const o=n,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:x=>{i("update:modelValue",x),i("change",x)},onUpload:x=>{i("upload",x)},onUploadComplete:x=>{i("upload-complete",x)},onUploadError:x=>{i("upload-error",x)},onRemove:x=>{i("remove",x)},onReorder:x=>{i("reorder",x)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{items:s,setItems:l,addFiles:d,removeItem:c,reorderItems:u,updateItem:f,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:k,isAtMaxItems:V,errors:B,dragState:_,getDragProps:g,adapter:E,formValues:C,acceptString:N}=ms(r);e.provide("mediaAdapter",E),e.provide("mediaCollection",{items:s,addFiles:d,removeItem:c,reorderItems:u}),e.watch(()=>o.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const S=e.computed(()=>({...nf,...o.labels})),A=e.computed(()=>({accept:N.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||V.value})),Z=e.computed(()=>({items:s.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:k.value,isAtMaxItems:V.value,errors:B.value,addFiles:d,removeItem:c,reorderItems:u,clearAll:()=>{s.value.forEach(x=>c(x))},cancelUpload:m,retryUpload:p,labels:S.value,dropzoneProps:A.value}));return a({items:s,addFiles:d,removeItem:c,reorderItems:u,updateItem:f,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:k,isAtMaxItems:V,errors:B,dragState:_,getDragProps:g,adapter:E,formValues:C,acceptString:N}),(x,F)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(Z.value)))}}),D$=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(n,{expose:a,emit:t}){const o=n,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: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)},onReplace:(S,A)=>{i("replace",A)},onError:S=>{i("validation-error",S)},onReadyToSubmitChange:S=>{i("is-ready-to-submit-change",S)}},{item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,isUploading:h,isReadyToSubmit:v,hasItem:k,errors:V,adapter:B,formValue:_,acceptString:g}=Td(r);e.provide("mediaAdapter",B),e.watch(()=>o.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const E=e.computed(()=>({...nf,...o.labels})),C=e.computed(()=>({accept:g.value,multiple:!1,disabled:o.disabled||o.readonly||k.value})),N=e.computed(()=>({item:s.value,hasItem:k.value,isLoading:p.value,isUploading:h.value,isReadyToSubmit:v.value,errors:V.value,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,labels:E.value,dropzoneProps:C.value}));return a({item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,isUploading:h,isReadyToSubmit:v,hasItem:k,errors:V,adapter:B,formValue:_,acceptString:g}),(S,A)=>e.renderSlot(S.$slots,"default",e.normalizeProps(e.guardReactiveProps(N.value)))}}),R$=["name","value"],A$=["name","value"],L$=["name","value"],P$=["name","value"],O$=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(n){const a=n,t=e.computed(()=>a.item?[a.item]:a.items),o=e.computed(()=>xd(t.value));function i(l,d){var u;const c=((u=o.value[l])==null?void 0:u.uuid)||"";return`${a.name}[${c}][${d}]`}function r(l,d){return`${a.name}[${l}][${d}]`}function s(l,d){return a.format==="spatie"?i(l,d):r(l,d)}return(l,d)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(c,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:c.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:c.uuid},null,8,R$),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:c.name},null,8,A$),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:c.order},null,8,L$),c.custom_properties&&Object.keys(c.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:s(u,"custom_properties"),value:JSON.stringify(c.custom_properties)},null,8,P$)):e.createCommentVNode("",!0)],64))),128))}}),U$=["data-testid"],z$=["data-testid"],j$=["id"],W$=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],Z$=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:(n,a)=>`${n.type==="video"?"video":"photo"} ${a+1}`}},emits:["update:items"],setup(n,{emit:a}){const t=n,o=a;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&o("update:items",t.items.map((d,c)=>c!==r?d:{...d,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,d)=>(e.openBlock(),e.createElementBlock("div",{key:l._key??l.id??`${l.url}:${d}`,class:"media-attachment-metadata-fields__row","data-testid":`${r.testIdPrefix}-${d}`},[e.createElementVNode("p",{id:`${r.testIdPrefix}-label-${d}`,class:"media-attachment-metadata-fields__label"},e.toDisplayString(r.label)+" for "+e.toDisplayString(r.getItemLabel(l,d)),9,j$),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-${d}`,placeholder:r.placeholder,"data-testid":`input-${r.testIdPrefix}-${d}`,onInput:c=>i(d,c)},null,40,W$)],8,z$))),128))],8,U$)):e.createCommentVNode("",!0)}}),H$=Be(Z$,[["__scopeId","data-v-a153768a"]]),X$="/v1/media/deletion/check",G$="/v1/media/deletion/delete",ir=100;function yu(n){const a=new Set,t=[];for(const o of n){const i=o.trim().toLowerCase();i===""||a.has(i)||(a.add(i),t.push(i))}return t.sort()}function of(n){const a=n.checkEndpoint??X$,t=n.deleteEndpoint??G$,o=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function d(f){l.value=null;const m=yu(f);if(m.length===0)return r.value=[],[];if(m.length>ir){const p=new Error(`Cannot check more than ${ir} media items at once.`);throw l.value=p,p}o.value=!0;try{const p=await n.httpClient.post(a,{uuids:m}),h=((p==null?void 0:p.data)??[]).map(v=>{var k,V,B,_;return{uuid:v.uuid,canDelete:((k=v.report)==null?void 0:k.canDelete)??!1,blocks:Array.isArray((V=v.report)==null?void 0:V.blocks)?v.report.blocks:[],cascade:Array.isArray((B=v.report)==null?void 0:B.cascade)?v.report.cascade:[],variantCount:typeof((_=v.report)==null?void 0:_.variantCount)=="number"?v.report.variantCount:0}});return r.value=h,h}catch(p){throw l.value=p instanceof Error?p:new Error(String(p)),l.value}finally{o.value=!1}}async function c(f,m={}){l.value=null;const p=yu(f);if(p.length===0){const h={results:[],summary:{}};return s.value=h,h}if(p.length>ir){const h=new Error(`Cannot delete more than ${ir} media items at once.`);throw l.value=h,h}i.value=!0;try{const h=await n.httpClient.post(t,{uuids:p,force:m.force===!0}),v={results:Array.isArray(h==null?void 0:h.results)?h.results:[],summary:(h==null?void 0:h.summary)??{}};return s.value=v,v}catch(h){throw l.value=h instanceof Error?h:new Error(String(h)),l.value}finally{i.value=!1}}function u(){r.value=null,s.value=null,l.value=null}return{isChecking:o,isDeleting:i,lastReport:r,lastResponse:s,error:l,checkDependencies:d,deleteMany:c,reset:u}}const J$="/v1/user/media/trash";function K$(n){return`/v1/user/media/${encodeURIComponent(n)}/restore`}function rf(n){const a=n.listEndpoint??J$,t=n.buildRestoreEndpoint??K$,o=n.perPage??50,i=e.ref([]),r=e.ref(0),s=e.ref(1),l=e.ref(!1),d=e.ref(!1),c=e.ref(null);async function u(p=1){var h,v;c.value=null,l.value=!0;try{const k=await n.httpClient.get(a,{params:{page:p,per_page:o}});i.value=Array.isArray(k==null?void 0:k.data)?k.data:[],r.value=typeof((h=k==null?void 0:k.meta)==null?void 0:h.total)=="number"?k.meta.total:0,s.value=typeof((v=k==null?void 0:k.meta)==null?void 0:v.current_page)=="number"?k.meta.current_page:p}catch(k){throw c.value=k instanceof Error?k:new Error(String(k)),c.value}finally{l.value=!1}}async function f(p){c.value=null,d.value=!0;try{const h=await n.httpClient.post(t(p)),v={status:(h==null?void 0:h.status)??"failed",data:(h==null?void 0:h.data)??null,duplicate_uuid:(h==null?void 0:h.duplicate_uuid)??null};return typeof(h==null?void 0:h.message)=="string"&&(v.message=h.message),v.status==="restored"&&(i.value=i.value.filter(k=>k.uuid!==p),r.value=Math.max(0,r.value-1)),v}catch(h){const v=q$(h);if(v&&typeof v.status=="string"){const k={status:v.status,duplicate_uuid:typeof v.duplicate_uuid=="string"?v.duplicate_uuid:null};return typeof v.message=="string"&&(k.message=v.message),k}throw c.value=h instanceof Error?h:new Error(String(h)),c.value}finally{d.value=!1}}function m(){i.value=[],r.value=0,s.value=1,c.value=null}return{items:i,total:r,currentPage:s,isLoading:l,isRestoring:d,error:c,fetch:u,restore:f,reset:m}}function q$(n){var t;if(typeof n!="object"||n===null)return null;const a=n;return(t=a.response)!=null&&t.data&&typeof a.response.data=="object"?a.response.data:null}const Y$={class:"media-management-view","data-testid":"media-management-view"},Q$={class:"media-management-view__header"},eD={class:"media-management-view__title"},tD={class:"media-management-view__actions"},aD={key:0,class:"media-management-view__badge"},nD={key:0,class:"media-management-view__panel","data-testid":"panel-library"},oD={key:0,class:"media-management-view__status","data-testid":"library-loading"},iD={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},rD={key:2,class:"media-management-view__empty","data-testid":"library-empty"},sD={class:"media-management-view__empty-state"},lD={class:"media-management-view__empty-title","data-testid":"library-empty-title"},dD={class:"media-management-view__empty-description","data-testid":"library-empty-description"},cD={key:3,class:"media-management-view__grid","data-testid":"library-grid"},uD=["data-testid"],mD=["data-testid","aria-pressed","onClick"],pD=["src","alt"],fD={key:1,class:"media-management-view__item-placeholder"},hD={class:"media-management-view__item-meta"},vD={class:"media-management-view__item-name"},gD=["data-testid"],yD={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},bD={class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},wD={"data-testid":"bulk-count"},kD=["disabled"],_D={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},ED={key:0,class:"media-management-view__status","data-testid":"trash-loading"},xD={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},SD={class:"media-management-view__empty-state"},CD={class:"media-management-view__empty-title","data-testid":"trash-empty-title"},VD={class:"media-management-view__empty-description","data-testid":"trash-empty-description"},ND={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},TD=["data-testid"],MD={class:"media-management-view__item-thumb"},BD=["src","alt"],ID={class:"media-management-view__item-meta"},FD={class:"media-management-view__item-name"},$D={key:0,class:"media-management-view__item-meta-line"},DD=["data-testid","disabled","onClick"],RD=["data-testid"],AD=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},confirmBulkDelete:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","error"],setup(n,{expose:a,emit:t}){const o=n,i=t,r=e.computed(()=>({showTrash:!0,allowBulkDelete:!0,showOwner:!1,...o.capabilities})),s=e.computed(()=>{var ie,ne,L,D,j,q,te,ce,me,ge,Te,he,ye,Se,Ne,at,et;return{title:((ie=o.labels)==null?void 0:ie.title)??"My Media",libraryTab:((ne=o.labels)==null?void 0:ne.libraryTab)??"Library",trashTab:((L=o.labels)==null?void 0:L.trashTab)??"Trash",loading:((D=o.labels)==null?void 0:D.loading)??"Loading…",emptyLibrary:((j=o.labels)==null?void 0:j.emptyLibrary)??"No media yet — upload your first creation.",emptyLibraryTitle:((q=o.labels)==null?void 0:q.emptyLibraryTitle)??"Your media library is ready",emptyLibraryDescription:((te=o.labels)==null?void 0:te.emptyLibraryDescription)??"Images and videos you upload for creations are saved here so you can reuse them later.",emptyTrash:((ce=o.labels)==null?void 0:ce.emptyTrash)??"Trash is empty.",emptyTrashTitle:((me=o.labels)==null?void 0:me.emptyTrashTitle)??"No media in trash",emptyTrashDescription:((ge=o.labels)==null?void 0:ge.emptyTrashDescription)??"Deleted files appear here for 30 days before permanent removal.",orphanedBadge:((Te=o.labels)==null?void 0:Te.orphanedBadge)??"Not in use",selectedCount:((he=o.labels)==null?void 0:he.selectedCount)??(gt=>`${gt} selected`),deleteButton:((ye=o.labels)==null?void 0:ye.deleteButton)??"Delete",restoreButton:((Se=o.labels)==null?void 0:Se.restoreButton)??"Restore",restoreUnavailable:((Ne=o.labels)==null?void 0:Ne.restoreUnavailable)??"Restore unavailable",purgeAfter:((at=o.labels)==null?void 0:at.purgeAfter)??(gt=>`Purges ${gt}`),ownerLabel:((et=o.labels)==null?void 0:et.ownerLabel)??(gt=>`User ${gt.user_id??""}`)}}),l=e.computed(()=>s.value.title),d=e.computed(()=>s.value.libraryTab),c=e.computed(()=>s.value.trashTab),u=e.computed(()=>s.value.loading),f=e.computed(()=>s.value.emptyLibraryTitle),m=e.computed(()=>s.value.emptyLibraryDescription),p=e.computed(()=>s.value.emptyTrashTitle),h=e.computed(()=>s.value.emptyTrashDescription),v=e.computed(()=>s.value.orphanedBadge),k=e.computed(()=>s.value.deleteButton),V=e.computed(()=>s.value.restoreButton),B=e.computed(()=>s.value.restoreUnavailable);function _(ie){const ne=r.value.canRestore;return ne?ne(ie):!0}const g=e.ref("library"),E=e.ref({scope:"library"}),C=e.ref({}),N=_d({httpClient:o.httpClient,view:E,filters:C,perPage:50}),S=e.computed(()=>N.items.value),A=e.computed(()=>N.loading.value),Z=e.computed(()=>{var ie;return((ie=N.error.value)==null?void 0:ie.message)??null}),x=Ru(S),F=of({httpClient:o.httpClient}),b=rf({httpClient:o.httpClient});function R(ie){return s.value.selectedCount(ie)}function P(ie){return s.value.purgeAfter(ie)}function O(ie){return s.value.ownerLabel(ie)}async function U(){const ie=x.selectedItems.value;if(ie.length===0)return;const ne=r.value.canDelete?ie.filter(L=>r.value.canDelete(L)):ie;if(ne.length!==0&&!(o.confirmBulkDelete&&!await o.confirmBulkDelete(ne)))try{const L=ne.map(q=>q.uuid),j=(await F.deleteMany(L)).results.filter(q=>q.status==="trashed"||q.status==="already_trashed").map(q=>q.uuid);if(j.length>0){for(const q of j)x.deselect(q);i("deleted",j),await N.refresh(),r.value.showTrash!==!1&&await b.fetch(b.currentPage.value).catch(()=>{})}}catch(L){i("error",L instanceof Error?L:new Error(String(L)))}}async function M(ie){var L;const ne=b.items.value.find(D=>D.uuid===ie);if(!(ne&&!_(ne)))try{const D=await b.restore(ie);if(D.status==="restored"){i("restored",ie),await N.refresh().catch(()=>{});return}if(D.status==="duplicate_conflict"){i("restore-conflict",{uuid:ie,duplicateUuid:D.duplicate_uuid??null}),(L=o.onRestoreCollision)==null||L.call(o,ie,D.duplicate_uuid??null);return}}catch(D){i("error",D instanceof Error?D:new Error(String(D)))}}async function I(){g.value="trash",b.items.value.length===0&&!b.isLoading.value&&await b.fetch().catch(ie=>{i("error",ie instanceof Error?ie:new Error(String(ie)))})}function z(ie){if(ie==="trash"){I();return}g.value=ie}const X=e.computed(()=>({activeTab:g.value,setActiveTab:z,trashCount:b.total.value,showTrash:r.value.showTrash!==!1,labels:{libraryTab:s.value.libraryTab,trashTab:s.value.trashTab}})),le=e.computed(()=>({selectedCount:x.selectedCount.value,isDeleting:F.isDeleting.value,onBulkDelete:U,labels:{deleteButton:s.value.deleteButton,selectedCount:s.value.selectedCount}}));function ve(ie){return{media:ie,canRestore:_(ie),isRestoring:b.isRestoring.value,onRestore:()=>M(ie.uuid),labels:{restoreButton:s.value.restoreButton,restoreUnavailable:s.value.restoreUnavailable}}}return e.watch(g,async ie=>{ie==="library"&&S.value.length===0&&!A.value&&await N.refresh().catch(()=>{})}),e.onMounted(async()=>{await N.refresh().catch(ie=>{i("error",ie instanceof Error?ie:new Error(String(ie)))}),r.value.showTrash!==!1&&b.fetch().catch(()=>{})}),a({refresh:()=>N.refresh(),refreshTrash:()=>b.fetch(),selection:x,deletion:F,trash:b}),(ie,ne)=>(e.openBlock(),e.createElementBlock("div",Y$,[e.createElementVNode("header",Q$,[e.createElementVNode("h2",eD,e.toDisplayString(l.value),1),e.createElementVNode("div",tD,[e.renderSlot(ie.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(X.value)),()=>[r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":g.value==="library"}]),"data-testid":"tab-library",onClick:ne[0]||(ne[0]=L=>g.value="library")},e.toDisplayString(d.value),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":g.value==="trash"}]),"data-testid":"tab-trash",onClick:I},[e.createTextVNode(e.toDisplayString(c.value)+" ",1),e.unref(b).total.value>0?(e.openBlock(),e.createElementBlock("span",aD,e.toDisplayString(e.unref(b).total.value),1)):e.createCommentVNode("",!0)],2)],64)):e.createCommentVNode("",!0)],!0)])]),g.value==="library"?(e.openBlock(),e.createElementBlock("section",nD,[A.value?(e.openBlock(),e.createElementBlock("div",oD,e.toDisplayString(u.value),1)):Z.value?(e.openBlock(),e.createElementBlock("div",iD,e.toDisplayString(Z.value),1)):S.value.length===0?(e.openBlock(),e.createElementBlock("div",rD,[e.renderSlot(ie.$slots,"empty-library",{},()=>[e.createElementVNode("div",sD,[e.createElementVNode("p",lD,e.toDisplayString(f.value),1),e.createElementVNode("p",dD,e.toDisplayString(m.value),1)])],!0)])):(e.openBlock(),e.createElementBlock("ul",cD,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,L=>(e.openBlock(),e.createElementBlock("li",{key:L.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(x).isSelected(L.uuid)}]),"data-testid":`media-item-${L.uuid}`},[e.createElementVNode("button",{type:"button",class:"media-management-view__item-thumb","data-testid":`btn-select-${L.uuid}`,"aria-pressed":e.unref(x).isSelected(L.uuid),onClick:D=>e.unref(x).toggle(L.uuid)},[L.thumbnail_url||L.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:L.thumbnail_url||L.original_url,alt:L.alt_text||L.file_name,loading:"lazy"},null,8,pD)):(e.openBlock(),e.createElementBlock("span",fD,e.toDisplayString(L.file_name),1))],8,mD),e.createElementVNode("div",hD,[e.createElementVNode("span",vD,e.toDisplayString(L.file_name),1),r.value.showOwner&&L.user_id?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__item-owner","data-testid":`owner-${L.uuid}`},e.toDisplayString(O(L)),9,gD)):e.createCommentVNode("",!0),L.is_orphaned?(e.openBlock(),e.createElementBlock("span",yD,e.toDisplayString(v.value),1)):e.createCommentVNode("",!0)])],10,uD))),128))])),e.unref(x).selectedCount.value>0&&r.value.allowBulkDelete!==!1?e.renderSlot(ie.$slots,"bulk-actions",e.normalizeProps(e.mergeProps({key:4},le.value)),()=>[e.createElementVNode("footer",bD,[e.createElementVNode("span",wD,e.toDisplayString(R(e.unref(x).selectedCount.value)),1),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(F).isDeleting.value,onClick:U},e.toDisplayString(k.value),9,kD)])],!0):e.createCommentVNode("",!0)])):g.value==="trash"?(e.openBlock(),e.createElementBlock("section",_D,[e.unref(b).isLoading.value?(e.openBlock(),e.createElementBlock("div",ED,e.toDisplayString(u.value),1)):e.unref(b).items.value.length===0?(e.openBlock(),e.createElementBlock("div",xD,[e.renderSlot(ie.$slots,"empty-trash",{},()=>[e.createElementVNode("div",SD,[e.createElementVNode("p",CD,e.toDisplayString(p.value),1),e.createElementVNode("p",VD,e.toDisplayString(h.value),1)])],!0)])):(e.openBlock(),e.createElementBlock("ul",ND,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b).items.value,L=>(e.openBlock(),e.createElementBlock("li",{key:L.uuid,class:"media-management-view__item is-trashed","data-testid":`trash-item-${L.uuid}`},[e.createElementVNode("div",MD,[L.thumbnail_url||L.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:L.thumbnail_url||L.original_url,alt:L.alt_text||L.file_name,loading:"lazy"},null,8,BD)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ID,[e.createElementVNode("span",FD,e.toDisplayString(L.file_name),1),L.purge_after?(e.openBlock(),e.createElementBlock("span",$D,e.toDisplayString(P(L.purge_after)),1)):e.createCommentVNode("",!0)]),e.renderSlot(ie.$slots,"trash-action",e.mergeProps({ref_for:!0},ve(L)),()=>[_(L)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-management-view__btn-restore","data-testid":`btn-restore-${L.uuid}`,disabled:e.unref(b).isRestoring.value,onClick:D=>M(L.uuid)},e.toDisplayString(V.value),9,DD)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__btn-restore is-unavailable","data-testid":`btn-restore-${L.uuid}-unavailable`,"aria-disabled":!0},e.toDisplayString(B.value),9,RD))],!0)],8,TD))),128))]))])):e.createCommentVNode("",!0)]))}}),LD=Be(AD,[["__scopeId","data-v-e83127cb"]]);exports.AlbumBrowser=Ip;exports.AlbumManager=OI;exports.AlbumMediaGrid=YI;exports.AlbumTree=Bp;exports.ArrayBufferTarget=Jl;exports.ExistingMediaSelector=Vg;exports.ImageEditor=Vu;exports.ImageEditorModal=Nu;exports.LiveStreamManager=pI;exports.ManagedMediaGallery=oh;exports.MediaAlbumInlineCreate=Fp;exports.MediaAlbumUnavailableState=$p;exports.MediaAttachment=F$;exports.MediaAttachmentMetadataFields=H$;exports.MediaCollection=x$;exports.MediaCollectionDropzone=Vd;exports.MediaCollectionItem=Nd;exports.MediaLibraryPicker=ef;exports.MediaLibraryPickerModal=wF;exports.MediaManagementView=LD;exports.MediaPreviewSheet=Up;exports.MediaSelectionTray=BF;exports.MediaSourceSheet=zp;exports.MediaThumbnailCell=Wp;exports.MediaUploadSheet=jp;exports.MediaWorkspace=eh;exports.ModelMediaManager=Jv;exports.Muxer=Yu;exports.VideoEditor=xp;exports.VideoEditorDialog=K4;exports.VideoEditorSimple=w3;exports.VideoExportPanel=QM;exports.VideoJobClient=ds;exports.VideoPlayer=Np;exports.VideoTimeline=W3;exports.VideoToolsPanel=FM;exports.VideoUploader=OB;exports.VirtualMediaGrid=Zp;exports._sfc_main=$$;exports._sfc_main$1=D$;exports._sfc_main$2=O$;exports.applyTemporaryMediaStoreConfig=_u;exports.configureMediaStore=ho;exports.createAdapter=tf;exports.createEmptyEditorState=$f;exports.createImageEditor=FF;exports.createMediablesAdapter=Sd;exports.createSpatieAdapter=Cd;exports.deserializeEditorState=Ff;exports.formatFileSize=Ar;exports.fromMediaArray=Ol;exports.getFileExtension=Hp;exports.getImageDimensions=Xp;exports.getMediablesAdapter=$F;exports.getSpatieAdapter=AF;exports.isImageFile=bd;exports.normalizeEditorState=Ul;exports.normalizeRecipeForServerRender=B4;exports.recipeHasServerRenderableEdits=M4;exports.recipeHasUnsupportedServerEdits=Vp;exports.resetMediablesAdapter=DF;exports.resetSpatieAdapter=LF;exports.restoreMediaStoreConfig=ku;exports.serializeEditorState=bu;exports.snapshotMediaStoreConfig=wu;exports.toFormValues=xd;exports.useAdminMediaStore=Eu;exports.useAlbumDragDrop=Mp;exports.useAlbumStore=us;exports.useAlbums=Tp;exports.useGlobalImageEditor=IF;exports.useImageEditorModal=Ed;exports.useMediaAttachment=Td;exports.useMediaCollection=ms;exports.useMediaDeletion=of;exports.useMediaDragSort=af;exports.useMediaLibraryPickerController=Qp;exports.useMediaLibraryQuery=_d;exports.useMediaLibrarySession=Kp;exports.useMediaLibraryStateMachine=qp;exports.useMediaLibraryTelemetry=Yp;exports.useMediaStore=va;exports.useMediaTrash=rf;exports.useMediaUploadQueue=kd;exports.useMediaValidation=wd;exports.validateFile=Gp;
357
+ //# sourceMappingURL=index-CeeQFiXM.cjs.map