@codingfactory/mediables-vue 2.9.2 → 2.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-CUlCdDi7.cjs → PixiFrameExporter-6l-tVJXc.cjs} +2 -2
- package/dist/{PixiFrameExporter-CUlCdDi7.cjs.map → PixiFrameExporter-6l-tVJXc.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-zsVyDi1A.js → PixiFrameExporter-DiX2TyR3.js} +2 -2
- package/dist/{PixiFrameExporter-zsVyDi1A.js.map → PixiFrameExporter-DiX2TyR3.js.map} +1 -1
- package/dist/composables/useVideoEditor.d.ts +6 -4
- package/dist/{index-DwIO7GBg.js → index--jjdabLj.js} +10623 -10461
- package/dist/{index-DwIO7GBg.js.map → index--jjdabLj.js.map} +1 -1
- package/dist/index-Dvqt7Fr6.cjs +350 -0
- package/dist/{index-DeXGbdCM.cjs.map → index-Dvqt7Fr6.cjs.map} +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index-DeXGbdCM.cjs +0 -350
package/dist/index-DeXGbdCM.cjs
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
"use strict";var jp=Object.defineProperty;var Wp=(a,n,t)=>n in a?jp(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var J=(a,n,t)=>Wp(a,typeof n!="symbol"?n+"":n,t);const nr=require("pinia"),e=require("vue"),ct=require("pixi.js"),pe=require("./editor-BTwIhrcA.cjs"),U=require("@ionic/vue"),Zp=require("pixi-filters");function Hp(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Ct=Hp(ct),hs=1,Xp=new Set(["free","square","circle"]);function Gp(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function Jp(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function nl(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==hs)return null;const t=n.crop,o=t&&Jp(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Xp.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,l=[];if(Array.isArray(s))for(const c of s){if(!c||typeof c!="object")continue;const d=c;if(typeof d.id!="string")continue;const u={},f=d.values;if(f&&typeof f=="object"&&!Array.isArray(f))for(const[p,m]of Object.entries(f))Gp(m)&&(u[p]=m);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:hs,crop:{rect:o,aspectRatio:r,shape:i},filters:l}}function Nd(a){const n=nl(a);return n?JSON.stringify(n):null}function Kp(a){try{const n=JSON.parse(a);return nl(n)}catch{return null}}function Yp(){return{version:hs,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let mn={apiBaseUrl:"/api/v1",isAdmin:!1};function Ya(a){mn={...mn,...a}}function Td(){return{...mn}}function Md(a){mn={...a}}function Bd(a){const n=Td();return Ya(a),()=>{Md(n)}}const qp=async(a,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),o={Accept:"application/json",...n.headers};t&&(o["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:n.method||"GET",headers:o,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(a,r);if(!s.ok){const c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},dn=nr.defineStore("media",()=>{const a=e.ref([]),n=e.ref([]),t=e.ref(!1),o=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),f=e.ref(new Map),p=e.ref(new Map),m=e.ref(new Set),h=e.ref(new Map),g=e.ref({}),w=5*60*1e3,F=e.computed(()=>{if(mn.apiScope)return mn.apiScope;if(mn.isAdmin)return"admin"}),D=e.computed(()=>F.value==="admin");function E(){return mn.httpClient||qp}function v(ue){const ge=mn.apiBaseUrl||"/api/v1",Ne=F.value?`/${F.value}`:"";return`${ge}${Ne}${ue}`}function S(ue,ge){return`${F.value??"default"}-${ue}-${JSON.stringify(ge)}`}function C(ue){return Date.now()-ue<w}function V(){h.value.clear(),g.value={}}function x(ue){if(!ue||!ue.data)return;const ge={};ue.data.forEach(Ne=>{const fe=`${Ne.file_name}-${Ne.collection_name||"default"}`,me=ge[fe];(!me||Object.keys(Ne.generated_conversions||{}).length>Object.keys(me.generated_conversions||{}).length)&&(ge[fe]=Ne)}),a.value=Object.values(ge),ue.meta&&(i.value=ue.meta.current_page,r.value=Math.ceil(ue.meta.total/ue.meta.per_page))}async function N(ue=1,ge={}){const Ne=S(ue,ge),fe=h.value.get(Ne);if(fe&&C(fe.timestamp)){const me=fe.data;return x(me),me}t.value=!0,o.value=null;try{const me=new URLSearchParams;me.append("page",ue.toString()),me.append("per_page",s.value.toString()),D.value&&me.append("linked","1");for(const dt in ge)if(Object.prototype.hasOwnProperty.call(ge,dt)){const st=ge[dt];st!=null&&st!==""&&me.append(dt,String(st))}const Te=await E()(v(`/media?${me}`));return h.value.set(Ne,{data:Te,timestamp:Date.now()}),x(Te),Te}catch(me){throw o.value=me instanceof Error?me.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function j(ue,ge){t.value=!0,o.value=null;const Ne=`${ue.name}-${Date.now()}`,fe={file:ue,progress:0,status:"uploading"};f.value.set(Ne,fe);try{const me=new FormData;me.append("file",ue),me.append("collection",ge.collection),ge.ownerUuid&&(me.append("owner_uuid",ge.ownerUuid),me.append("owner_type",ge.ownerType||"")),ge.usageUuid&&(me.append("usage_uuid",ge.usageUuid),me.append("usage_type",ge.usageType||""),me.append("usage_purpose",ge.usagePurpose||"")),ge.customProperties&&me.append("custom_properties",JSON.stringify(ge.customProperties));const Te=await E()(v("/media"),{method:"POST",body:me});return fe.status="completed",fe.progress=100,fe.media=Te==null?void 0:Te.data,i.value===1&&(Te!=null&&Te.data)&&(a.value=[Te.data,...a.value]),V(),(Te==null?void 0:Te.data)||null}catch(me){throw fe.status="error",fe.error=me instanceof Error?me.message:"Upload failed",o.value=fe.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{f.value.delete(Ne)},5e3)}}async function _(ue){t.value=!0,o.value=null;const ge=a.value.findIndex(fe=>fe.uuid===ue);let Ne;ge!==-1&&(Ne=a.value.splice(ge,1)[0]);try{return await E()(v(`/media/${ue}`),{method:"DELETE"}),m.value.delete(ue),V(),!0}catch(fe){throw Ne&&ge!==-1&&a.value.splice(ge,0,Ne),o.value=fe instanceof Error?fe.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function R(ue,ge){t.value=!0,o.value=null;try{const fe=await E()(v(`/media/${ue}`),{method:"PATCH",body:ge,data:ge});if(fe!=null&&fe.data){const me=a.value.findIndex(Ee=>Ee.uuid===ue);return me!==-1&&(a.value[me]={...a.value[me],...fe.data}),V(),fe.data}return null}catch(Ne){throw o.value=Ne instanceof Error?Ne.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function T(){t.value=!0,o.value=null;try{const ge=await E()(v("/media/collections"));return n.value=(ge==null?void 0:ge.data)||[],n.value}catch(ue){throw o.value=ue instanceof Error?ue.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function z(ue,ge,Ne="images",fe){d.value=!0,u.value=null;try{const me=new URLSearchParams;me.append("collection",Ne),fe&&me.append("search",fe);const Te=await E()(v(`/media/model/${ue}/${ge}?${me}`));return Te!=null&&Te.data?(c.value=Te.data,Te.data):[]}catch(me){throw u.value=me instanceof Error?me.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function P(ue,ge,Ne,fe="images"){d.value=!0,u.value=null;const me=[...c.value];try{const Te=await E()(v(`/media/model/${ue}/${ge}/attach`),{method:"POST",body:{media_uuids:Ne,collection:fe}});return await z(ue,ge,fe),(Te==null?void 0:Te.data)||[]}catch(Ee){throw c.value=me,u.value=Ee instanceof Error?Ee.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function M(ue,ge,Ne,fe="images"){d.value=!0,u.value=null;const me=[...c.value];c.value=c.value.filter(Ee=>Ee.uuid!==Ne);try{return await E()(v(`/media/model/${ue}/${ge}/detach`),{method:"POST",body:{media_uuid:Ne,collection:fe}}),!0}catch(Ee){throw c.value=me,u.value=Ee instanceof Error?Ee.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function L(ue,ge,Ne,fe="images"){d.value=!0,u.value=null;const me=[...c.value],Ee=new Map(c.value.map(Te=>[Te.uuid,Te]));c.value=Ne.map(Te=>Ee.get(Te)).filter(Te=>Te!==void 0);try{return await E()(v(`/media/model/${ue}/${ge}/reorder`),{method:"POST",body:{media_uuids:Ne,collection:fe}}),!0}catch(Te){throw c.value=me,u.value=Te instanceof Error?Te.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function k(ue,ge,Ne={}){const fe=E(),me=mn.apiBaseUrl||"/api/v1",Ee=new FormData,Te=ge.imageData,dt=Te.match(/^data:(image\/\w+);base64,/),st=dt?dt[1]:"image/png",Dt=Te.replace(/^data:image\/\w+;base64,/,""),pt=atob(Dt),ft=new Uint8Array(pt.length);for(let gt=0;gt<pt.length;gt++)ft[gt]=pt.charCodeAt(gt);const _t=new Blob([ft],{type:st});Ee.append("image_file",_t,`edited.${st==="image/jpeg"?"jpg":"png"}`);const ot=Nd(ge.state);ot&&Ee.append("editor_state",ot),ge.metadata&&(Ee.append("filters",JSON.stringify(ge.metadata.filters)),ge.metadata.cropRect&&Ee.append("crop_data",JSON.stringify(ge.metadata.cropRect))),Ee.append("save_as_new","true"),Ne.asVariant&&Ee.append("as_variant","true"),Ne.name!==void 0&&Ee.append("name",Ne.name);const bt=await fe(`${me}/editor/${ue}/save`,{method:"POST",body:Ee});if("media"in bt&&bt.media)return bt.media;if("status_url"in bt&&bt.status_url)return O(fe,bt.status_url,Ne.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function O(ue,ge,Ne){const fe=Date.now(),me=2e3;for(;Date.now()-fe<Ne;){await new Promise(Te=>setTimeout(Te,me));const Ee=await ue(ge);if(Ee.status==="completed"&&Ee.media)return Ee.media;if(Ee.status==="failed")throw new Error(Ee.error??"Image processing failed")}throw new Error("Image processing timed out")}function W(ue,ge,Ne){l.value=Ne!==void 0?{type:ue,uuid:ge,collection:Ne}:{type:ue,uuid:ge},g.value[`${ue}-${ge}`]={timestamp:Date.now()}}function G(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function ie(){if(!l.value.type||!l.value.uuid)return;const ue=await z(l.value.type,l.value.uuid,l.value.collection||"images");c.value=ue||[]}function we(){a.value.forEach(ue=>m.value.add(ue.uuid))}function _e(){m.value.clear()}function oe(ue){m.value.has(ue)?m.value.delete(ue):m.value.add(ue)}function $(ue){return m.value.has(ue)}function B(){return Array.from(f.value.values()).some(ue=>ue.status==="uploading")}function Z(ue){return f.value.get(ue)||p.value.get(ue)}function ee(){return[...Array.from(f.value.values()),...Array.from(p.value.values())]}async function ne(){const ue=Array.from(m.value);let ge=0;for(const Ne of ue)try{await _(Ne),ge++}catch{}return _e(),ge}function de(ue,ge){var Ne;return ge&&((Ne=ue.conversion_urls)!=null&&Ne[ge])?ue.conversion_urls[ge]||"":ue.original_url||ue.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:D,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:m,uploadProgress:f,uploadQueue:p,cachedResponses:g,fetchMedia:N,uploadFile:j,deleteMedia:_,updateMedia:R,clearCache:V,fetchCollections:T,fetchModelMedia:z,attachMedia:P,detachMedia:M,reorderMedia:L,saveEditedImage:k,setModelContext:W,clearModelContext:G,refreshModelMedia:ie,selectAllItems:we,clearSelection:_e,toggleSelection:oe,isSelected:$,deleteSelectedItems:ne,getHttpClient:E,getApiUrl:v,hasActiveUploads:B,getUploadProgress:Z,getAllUploadProgress:ee,getMediaUrl:de}}),Id=()=>((mn.apiScope!=="admin"||mn.isAdmin!==!0)&&Ya({...mn,apiScope:"admin",isAdmin:!0}),dn());class Fd{constructor(n,t){this.state=n,this.editor=t,this.element=null,this._tabs=new Map,this._unsubscribers=[],this._onSelect=null}render({onSelect:n}={}){return this._onSelect=n,this.element=pe.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),pe.EDITOR_CATEGORIES.forEach(t=>{const o=pe.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=pe.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,o.appendChild(i)}o.appendChild(pe.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(n){const t=this.state.get("selectedCategory");return n==="crop"?this.state.get("mode")==="crop":t===n&&this.state.get("mode")!=="crop"}_selectCategory(n){var o;this.state.set("selectedCategory",n);const t=this.state.get("mode");n==="crop"?t!=="crop"&&this.editor.setMode("crop"):t!=="filters"&&this.editor.setMode("filters"),this._refreshActive(),(o=this._onSelect)==null||o.call(this,n)}_refreshActive(){this._tabs.forEach((n,t)=>{const o=this._isSelected(t);n.classList.toggle("active",o),n.setAttribute("aria-selected",o?"true":"false")})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._tabs.clear(),(n=this.element)==null||n.remove(),this.element=null}}class $d{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onToggle=null,this._onSelect=null}render({onToggle:n,onSelect:t}={}){return this._onToggle=n,this._onSelect=t,this.element=pe.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 n=this.state.get("selectedCategory");if(!n||n==="crop")return;const t=this.filterManager.getFiltersByCategory(n),o=this.state.get("activeFilters"),i=this.state.get("selectedFilter");t.forEach(r=>{var c;const s=((c=o==null?void 0:o.has)==null?void 0:c.call(o,r.id))??!1,l=i===r.id;this.element.appendChild(this._renderRow(r,s,l))})}_renderRow(n,t,o){const i=pe.el("button",{type:"button",className:`filter-row ${o?"selected":""}`,role:"option","aria-selected":o?"true":"false","data-filter":n.id,"data-testid":`v2-filter-${n.id}`,onClick:()=>{var d;return(d=this._onSelect)==null?void 0:d.call(this,n.id)}}),r=pe.el("button",{type:"button",className:`filter-row-toggle ${t?"active":""}`,"aria-label":`${t?"Disable":"Enable"} ${n.name}`,"aria-pressed":t?"true":"false","data-testid":`v2-filter-toggle-${n.id}`,onClick:d=>{var f,p,m,h;d.stopPropagation();const u=!((p=(f=this.state.get("activeFilters"))==null?void 0:f.has)!=null&&p.call(f,n.id));(m=this._onToggle)==null||m.call(this,n.id,u),u&&((h=this._onSelect)==null||h.call(this,n.id))}});t&&(r.innerHTML=pe.checkmark),i.appendChild(r);const s=pe.el("div",{className:"filter-row-body"});s.appendChild(pe.el("span",{className:"filter-row-name"},n.name));const l=this._buildSummary(n,t);l&&s.appendChild(pe.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const c=pe.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=pe.chevronRight,i.appendChild(c),i}_buildSummary(n,t){if(!t)return n.description||"";const o=this.state.getFilterValues(n.id);if(!o||Object.keys(o).length===0)return n.description||"Active";const i=[];for(const r of(n.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(n,t){return n.type==="toggle"?n.label:typeof t=="number"?(n.max??1)<=1&&(n.min??0)>=0?`${n.label} ${Math.round(t*100)}%`:Number.isInteger(t)?`${n.label} ${t}`:`${n.label} ${t.toFixed(2)}`:typeof t=="string"?`${n.label}`:n.label}_refreshSummaries(){var i;const n=this.state.get("selectedCategory");if(!n||n==="crop")return;const t=this.filterManager.getFiltersByCategory(n),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,c=this._buildSummary(r,l),d=s.querySelector(".filter-row-summary");if(c&&d)d.textContent=c;else if(c&&!d){const u=s.querySelector(".filter-row-body");u==null||u.appendChild(pe.el("span",{className:"filter-row-summary"},c))}else!c&&d&&d.remove()}}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}class Dd{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onChange=null,this._onReset=null,this._onAction=null}render({onChange:n,onReset:t,onAction:o}={}){return this._onChange=n,this._onReset=t,this._onAction=o,this.element=pe.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 n=this.state.get("selectedFilter");if(!n){this.element.appendChild(pe.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(n);if(!t){this.element.appendChild(pe.el("div",{className:"no-filter-selected"},"Filter not found"));return}const o=pe.el("div",{className:"controls-header"});o.appendChild(pe.el("span",{className:"controls-title"},t.name)),o.appendChild(pe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(n)})),this.element.appendChild(o);const i=pe.el("div",{className:"controls-grid"}),r=this.state.getFilterValues(n);(t.controls||[]).forEach(l=>{if(l.hidden)return;const c=this._createControl(n,l,r[l.id]??l.default);c&&i.appendChild(c)});const s=this.filterManager.getInstance(n);if(s&&typeof s.getDynamicControls=="function"){let l=[];try{l=s.getDynamicControls()||[]}catch{}l.forEach(c=>{const d=c.property||c.id,u=r[d]??c.default,f=this._createControl(n,c,u);f&&i.appendChild(f)})}this.element.appendChild(i)}_createControl(n,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 pe.createSlider({id:`v2-${n}-${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 c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"toggle":return pe.createToggle({id:`v2-${n}-${t.id}`,label:i,checked:!!o,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"color":return pe.createColorPicker({id:`v2-${n}-${t.id}`,label:i,value:typeof o=="string"&&o.startsWith("#")?o:t.default||"#000000",onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"select":{const l=(t.options||[]).map(c=>typeof c=="object"&&c.value!==void 0?{value:c.value,label:c.label||String(c.value)}:{value:c,label:String(c)});return pe.createSelect({id:`v2-${n}-${t.id}`,label:i,options:l,value:o??t.default,onChange:c=>{var d;return(d=this._onChange)==null?void 0:d.call(this,n,s,c)}})}case"text":return pe.createTextInput({id:`v2-${n}-${t.id}`,label:i,value:typeof o=="string"?o:t.default??"",placeholder:t.placeholder||"",onCommit:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"button":{const l=pe.el("div",{className:"button-control"});return l.appendChild(pe.createButton({label:i,className:"btn-secondary",onClick:()=>{var c;(c=this._onAction)==null||c.call(this,n,t.action||t.id),this._renderControls()}})),l}default:return null}}_normalizeControlType(n){return{slider:"slider",range:"slider",toggle:"toggle",checkbox:"toggle",color:"color",select:"select",dropdown:"select",button:"button",text:"text"}[n]||n}_handleReset(n){var t;(t=this._onReset)==null||t.call(this,n),this._renderControls()}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}class Qp{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onRemove=null,this._onSelect=null,this._onClearAll=null}render({onRemove:n,onSelect:t,onClearAll:o}={}){return this._onRemove=n,this._onSelect=t,this._onClearAll=o,this.element=pe.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 n=this.state.get("activeFilters"),t=(n==null?void 0:n.size)??0,o=pe.el("div",{className:"panel-section-title"});if(o.appendChild(pe.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&o.appendChild(pe.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(pe.el("div",{className:"active-empty"},"No filters applied"));return}const i=pe.el("div",{className:"active-stack"}),r=this.state.get("selectedFilter");for(const s of n){const l=this.filterManager.getFilterDef(s);l&&i.appendChild(this._renderChip(l,s===r))}this.element.appendChild(i)}_renderChip(n,t){const o=pe.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-active-${n.id}`});o.appendChild(pe.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${n.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,n.id)}},n.name));const i=pe.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${n.name}`,"data-testid":`v2-active-remove-${n.id}`,onClick:()=>{var r;return(r=this._onRemove)==null?void 0:r.call(this,n.id)}});return i.innerHTML=pe.close,o.appendChild(i),o}_refreshSelection(){var o;const n=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===n)})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}const Za=["collapsed","half","full"];class ef{constructor(n={}){this._onSnapChange=n.onSnapChange||null,this._ariaLabel=n.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:n,body:t}={}){this.element=pe.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=pe.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=pe.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=pe.el("div",{className:"drawer-header"}),n&&this._headerSlot.appendChild(n),this.element.appendChild(this._headerSlot),this._body=pe.el("div",{className:"drawer-body"}),t&&this._body.appendChild(t),this.element.appendChild(this._body),this.element}updateContainerHeight(n){this._containerHeight=Math.max(0,Number(n)||0),this._applySnap(this._snap,{animate:!1})}snapTo(n,t={}){Za.includes(n)&&this._applySnap(n,{animate:t.animate!==!1})}get snap(){return this._snap}setBodyContent(n){this._body&&(this._body.innerHTML="",n&&this._body.appendChild(n))}setHeaderContent(n){this._headerSlot&&(this._headerSlot.innerHTML="",n&&this._headerSlot.appendChild(n))}_onPointerDown(n){var t,o,i;if(!(n.button!==void 0&&n.button!==0)){this._dragging=!0,this._wasDragging=!1,this._dragPointerId=n.pointerId,this._dragStartY=n.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,n.pointerId)}catch{}this.element&&(this.element.style.transition="none")}}_onPointerMove(n){if(!this._dragging||n.pointerId!==this._dragPointerId)return;const t=n.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),n.preventDefault()}_onPointerEnd(n){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,n.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 n=Za.indexOf(this._snap),t=Za[(n+1)%Za.length];this._applySnap(t,{animate:!0})}_heightForSnap(n){const t=this._containerHeight||window.innerHeight||600;switch(n){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(n){let t=Za[0],o=1/0;for(const i of Za){const r=this._heightForSnap(i),s=Math.abs(r-n);s<o&&(o=s,t=i)}return t}_applySnap(n,{animate:t}){var r,s;if(!this.element)return;const o=this._snap;this._snap=n;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(n)}px`,this.element.dataset.snap=n,this._handle&&this._handle.setAttribute("aria-expanded",n==="full"?"true":"false"),n!==o&&((s=this._onSnapChange)==null||s.call(this,n,o))}destroy(){var n;(n=this.element)==null||n.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}class tf{constructor(n,t,o){this.state=n,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(n){return this._callbacks=n,this._onNavigate=n.onViewChange||null,this.element=pe.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=pe.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=pe.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 Fd(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new $d(this.state,this.filterManager),this._filterListEl=this._filterListView.render({onToggle:(n,t)=>this._callbacks.onFilterToggle(n,t),onSelect:n=>{this._callbacks.onFilterSelect(n),this.navigateTo("controls")}}),this._filterControlsView=new Dd(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(n,t,o)=>this._callbacks.onFilterChange(n,t,o),onReset:n=>this._callbacks.onFilterReset(n),onAction:(n,t)=>this._callbacks.onFilterAction(n,t)})}navigateTo(n){var o;if(!this.element)return;this._view=n,this._renderHeader(),this._bodyEl.innerHTML="";let t=null;switch(n){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,n)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const o=pe.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});o.innerHTML=pe.chevronLeft,this._headerEl.appendChild(o)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(pe.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const o=this.state.get("selectedFilter");o&&this._headerEl.appendChild(pe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(o)}))}}_titleForView(n){switch(n){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(n){var t;return n&&((t=pe.EDITOR_CATEGORIES.find(o=>o.id===n))==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 n,t,o,i;this._unsubscribers.forEach(r=>r()),this._unsubscribers=[],(n=this._categoryTabs)==null||n.destroy(),(t=this._filterListView)==null||t.destroy(),(o=this._filterControlsView)==null||o.destroy(),(i=this.element)==null||i.remove(),this.element=null}}class nf{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._onSelect=null,this._onRemove=null,this._unsubscribers=[]}render({onSelect:n,onRemove:t}={}){return this._onSelect=n,this._onRemove=t,this.element=pe.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 n=this.state.get("activeFilters");if(((n==null?void 0:n.size)??0)===0){this.element.style.display="none";return}this.element.style.display="";const o=pe.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter");for(const r of n){const s=this.filterManager.getFilterDef(r);s&&o.appendChild(this._renderChip(s,r===i))}this.element.appendChild(o)}_renderChip(n,t){const o=pe.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-mobile-chip-${n.id}`});o.appendChild(pe.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${n.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,n.id)}},n.name));const i=pe.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${n.name}`,"data-testid":`v2-mobile-chip-remove-${n.id}`,onClick:r=>{var s;r.stopPropagation(),(s=this._onRemove)==null||s.call(this,n.id)}});return i.innerHTML=pe.close,o.appendChild(i),o}_refreshSelection(){var o;const n=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===n)})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}const ac="(max-width: 900px)";let af=class{constructor(n,t,o){this.state=n,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(n){var t;return this._callbacks=n,this.root=pe.el("div",{className:"editor-v2-body"}),this.canvasSection=pe.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=pe.el("div",{className:"canvas-container"}),this.cropOverlay=pe.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,ac).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(ac),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(n){this._cropControlsEl=n,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=pe.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new Fd(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const n=pe.el("div",{className:"panel-body"});this._desktopFilterListSection=pe.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(pe.el("div",{className:"panel-section-title"},pe.el("span",{},"Filters"))),this._filterListView=new $d(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,o)=>this._callbacks.onFilterToggle(t,o),onSelect:t=>this._callbacks.onFilterSelect(t)})),n.appendChild(this._desktopFilterListSection),this._filterControlsView=new Dd(this.state,this.filterManager),n.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=pe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),n.appendChild(this._desktopCropWrapper),this._activeStack=new Qp(this.state,this.filterManager),n.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(n),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new nf(this.state,this.filterManager);const n=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(n),this._mobileDrawer=new ef({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new tf(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=pe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const o=pe.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 n=()=>{const t=this.root.getBoundingClientRect().height;this._mobileDrawer.updateContainerHeight(t)};n(),this._resizeObserver=new ResizeObserver(()=>n()),this._resizeObserver.observe(this.root)}_destroyDesktopShell(){var n,t,o,i,r,s,l;(n=this._categoryTabs)==null||n.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 n,t,o,i,r;(n=this._resizeObserver)==null||n.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(n){n!==this._isMobile&&(this._isMobile=n,n?(this._destroyDesktopShell(),this._buildMobileShell()):(this._destroyMobileShell(),this._buildDesktopShell()))}_mountCropControlsInActiveShell(){if(!this._cropControlsEl)return;this._cropControlsEl.remove();const n=this._isMobile?this._mobileCropWrapper:this._desktopCropWrapper;n==null||n.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(n){var o,i,r;const t=n==="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 n;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(),(n=this.root)==null||n.remove(),this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null}};class of extends pe.EventEmitter{constructor(n,t={}){var r,s,l;if(super(),!n)throw new Error("VanillaImageEditorV2: container element is required");this._container=n,this._destroyed=!1,this._loadVersion=0,this._objectUrls=new Set;const o=t.preset?pe.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=pe.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 pe.PixiRenderer,this._filterManager=new pe.FilterManager(this._state,this._renderer),this._cropManager=new pe.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new pe.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=pe.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=pe.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new af(this._state,this._filterManager,this);const{root:n,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(n),this._fileInput=pe.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 pe.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new pe.CropControls(this._state,this._cropManager);const n=this._cropControls.render();this._layout.mountCropControls(n)}_setupResizeObserver(){if(!this._canvasContainer)return;let n=null;this._resizeObserver=new ResizeObserver(()=>{clearTimeout(n),n=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:n})=>{var t,o;(t=this._editorEl)==null||t.classList.toggle("dark",n),(o=this._editorEl)==null||o.classList.toggle("light",!n)})}async _handleFileSelect(n){var o;const t=(o=n.target.files)==null?void 0:o[0];t&&await this.loadImage(t),this._fileInput.value=""}_handleFilterToggle(n,t){this._filterManager.toggle(n,t),t?this._state.set("selectedFilter",n):this._state.get("selectedFilter")===n&&this._state.set("selectedFilter",null)}_handleFilterSelect(n){var i;const t=this._state.get("activeFilters");(i=t==null?void 0:t.has)!=null&&i.call(t,n)||this._filterManager.toggle(n,!0),this._state.set("selectedFilter",n);const o=this._filterManager.getFilterDef(n);if(typeof(o==null?void 0:o.category)=="string"){const r=pe.REGISTRY_TO_UI[o.category]||o.category;this._state.get("selectedCategory")!==r&&this._state.set("selectedCategory",r)}}_handleFilterChange(n,t,o){this._filterManager.updateValue(n,t,o)||this._filterManager.applyFilters(),this._renderer.render()}_handleFilterReset(n){this._filterManager.resetValues(n),this._filterManager.applyFilters()}_handleFilterAction(n,t){this._filterManager.performFilterAction(n,t)}setFilterRegistry(n){this._filterManager.setRegistry(n)}async loadImage(n,t={}){if(this._destroyed)return;const o=++this._loadVersion;let i=n;this._resetEditorState(),n instanceof Blob&&(i=URL.createObjectURL(n),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(n){if(!(!n||n.version!==1)){if(n.crop){const t=n.crop.shape||"free",o=n.crop.aspectRatio||"free";n.crop.rect&&(this._cropManager.applyFromPixelRect(n.crop.rect,t),this._state.set("crop.appliedRect",{...n.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(n.filters)){let t=null;for(const o of n.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=pe.REGISTRY_TO_UI[o.category]??o.category;this._state.set("selectedCategory",i)}}this._filterManager.applyFilters()}}}openFilePicker(){var n;(n=this._fileInput)==null||n.click()}exportImage(n="png",t=.92,o={}){return this._state.get("crop.rect")&&!this._cropManager.apply()?null:this._renderer.exportImage(n,t,o.maxEdge??0,o.dontUpscale!==!1,o.maxPixels??0)}save(){if(this._state.get("hasImage")){this._state.set("isSaving",!0);try{const n=this.exportImage("png",.92);if(!n)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=n,i.download=`edited-image-${Date.now()}.png`,document.body.appendChild(i),i.click(),document.body.removeChild(i),this.emit("save",{imageData:n,dimensions:o,state:this.getSerializableState()})}catch(n){this.emit("error",{error:n})}finally{this._state.set("isSaving",!1)}}}getSerializableState(){const n=this._state.get("activeFilters"),t=[];if(n)for(const s of n){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(n){this._renderer.setZoom(n)}fitToScreen(){this._renderer.fitToScreen()}resetAll(){this._filterManager.resetAll()}toggleTheme(){const n=this._state.get("isDarkMode");this._state.set("isDarkMode",!n)}setTheme(n){this._state.set("theme",n),this._state.detectTheme()}setMode(n){n==="crop"?this._cropManager.enable():this._cropManager.disable(),this._state.set("mode",n)}getState(){return this._state.getAll()}async removeBackground(n={}){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,n);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(n){var o;if(!this._loadingOverlay)this._loadingOverlay=pe.el("div",{className:"editor-loading-overlay"},pe.el("div",{className:"editor-loading-spinner"}),pe.el("div",{className:"editor-loading-text"},n));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=n)}const t=(o=this._canvasContainer)==null?void 0:o.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var n;(n=this._loadingOverlay)==null||n.remove()}destroy(){var n,t,o,i,r;this._destroyed=!0;for(const s of this._objectUrls)try{URL.revokeObjectURL(s)}catch{}this._objectUrls.clear(),(n=this._resizeObserver)==null||n.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 rf(a,n){try{let t=pe.getFilter(a);if(t||(pe.registerCorePixiFilters(),t=pe.getFilter(a)),!t){try{const r=pe.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const Gr=78e5,sf=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(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function l(){var E;if(!r){o("error",new Error("Editor not initialized"));return}const f=r.exportImage("png",.92,{maxPixels:Gr});if(!f){o("error",new Error("Failed to export image — the image could not be processed"));return}const p=r.getSerializableState(),m=r._renderer,h=((E=m==null?void 0:m.getExportDimensions)==null?void 0:E.call(m))??{width:0,height:0},g=h.width*h.height,w=g>Gr?Math.sqrt(Gr/Math.max(1,g)):1,F={width:Math.max(1,Math.floor(h.width*w)),height:Math.max(1,Math.floor(h.height*w))};o("save",{imageData:f,dimensions:F,state:p})}function c(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Ct,pe.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 p=t.editorVersion==="v2"?of:pe.VanillaImageEditor;r=new p(i.value,f),r.setFilterRegistry({getAllFilters:pe.getAllFilters,getFilter:pe.getFilter,getFiltersByCategory:pe.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",c),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(f=>{const p=f[0];p&&p.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))});const u=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})};return e.watch(()=>t.initialImage,(f,p)=>{!r||!f||f===p||u()}),e.watch(()=>t.sessionKey,(f,p)=>{f!==p&&u()}),e.watch(()=>t.initialState,(f,p)=>{f!==p&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(f,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Ve=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},Rd=Ve(sf,[["__scopeId","data-v-24c46711"]]),lf={class:"editor-modal-panel"},cf={class:"editor-fill"},df=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=g=>{o("error",g)},d=()=>{e.nextTick(()=>{if(i.value){const g=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");g&&g.focus()}})};e.watch(()=>t.modelValue,g=>{r.value=g,g&&(l.value=document.activeElement,d())},{immediate:!0});const u=g=>{try{s.value=!0,o("save",g)}catch(w){c(w)}finally{s.value=!1}},f=()=>{o("cancel"),m()},p=()=>{s.value||m()},m=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},h=g=>{if(g.key==="Escape"&&r.value&&!s.value){m();return}if(g.key==="Tab"&&r.value&&i.value){const w=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(w.length===0)return;const F=w[0],D=w[w.length-1];g.shiftKey&&document.activeElement===F?(g.preventDefault(),D.focus()):!g.shiftKey&&document.activeElement===D&&(g.preventDefault(),F.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(g,w)=>(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(p,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:p}),e.createElementVNode("div",lf,[e.createElementVNode("div",cf,[e.createVNode(Rd,{"initial-image":g.initialImage,"initial-state":g.initialState,"session-key":g.sessionKey,theme:g.theme,"crop-shape":g.cropShape,preset:g.preset,"editor-version":g.editorVersion,"primary-color":g.primaryColor,"secondary-color":g.secondaryColor,"save-button-color":g.saveButtonColor,"download-button-color":g.downloadButtonColor,onSave:u,onCancel:f,onError:c},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)]))}}),Ad=Ve(df,[["__scopeId","data-v-adf95668"]]),uf={class:"media-workspace"},mf={class:"media-workspace-toolbar"},pf={class:"media-workspace-label"},ff=["value"],hf={class:"media-workspace-grid"},vf=["onClick"],gf=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var f;const t=a,o=n,i=dn(),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(p=>p.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=Bd({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var m;const p={};(m=l.value)!=null&&m.collection&&(p.collection=l.value.collection),await i.fetchMedia(1,p),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(m=>m.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,p=>{p&&(o("scope-change",p),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(p,m)=>(e.openBlock(),e.createElementBlock("div",uf,[e.createElementVNode("div",mf,[e.createElementVNode("label",pf,[m[2]||(m[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":m[0]||(m[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,ff))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:m[1]||(m[1]=h=>o("upload"))}," Upload ")]),e.createElementVNode("div",hf,[(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:g=>o("preview",h)},e.toDisplayString(h.file_name),9,vf))),128))])]))}}),yf=Ve(gf,[["__scopeId","data-v-895f26fe"]]),bf={class:"managed-media-gallery"},wf={class:"gallery-grid"},kf=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(a){return(n,t)=>(e.openBlock(),e.createElementBlock("div",bf,[e.createElementVNode("div",wf,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),_f=Ve(kf,[["__scopeId","data-v-10a9b8c5"]]),Ef="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>",al="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>",xf="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>",ol="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>",Sf="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>",Cf="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>",oc="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>",ic="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>",Co="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>",Vf="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>",Ld="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>",Pd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",rc="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>",Nf="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>",Tf="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>",sc="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>",Ca="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>",lc="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>",Mf="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>",na="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>",Bf="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>",wo="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>",vs="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>",If="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>",cc="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>",zi="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>",qa="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>",Ff="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>",$f="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>",Df="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>",Rf="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z'/><path d='M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z'/></svg>",Vo="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dc="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>",Jr="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>",Af="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>",Lf="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>",Kr="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>",Pf="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>",Of="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>",Uf="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>",zf="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>",Od="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>",il="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M176 96h16v320h-16zM320 96h16v320h-16z' class='ionicon-fill-none ionicon-stroke-width'/></svg>",jf="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>",Wf="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>",Zf="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>",Hf="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>",Ud="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path 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>",Xf="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>",Gf="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>",rl="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>",Jf="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>",Kf="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>",Ba="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>",Yf="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>",qf="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>",uc="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>",ar="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>",Qf="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>",Yr="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>",ta="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>",ko="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>",mc="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>",eh="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>",zd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",gs="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>",jd="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>",th="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>",nh="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>",ah="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>",oh="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>",ih="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>",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-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>",sh="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>",hi="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 pc=()=>{};function lh(a,n){function t(...o){return new Promise((i,r)=>{Promise.resolve(a(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})).then(i).catch(r)})}return t}function ch(a,n={}){let t,o,i=pc;const r=c=>{clearTimeout(c),i(),i=pc};let s;return c=>{const d=e.toValue(a),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(c())):new Promise((f,p)=>{i=n.rejectOnCancel?p:f,s=c,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,f(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,f(c())},d)})}}function dh(a,n=200,t={}){return lh(ch(n,t),a)}const _o=new Map;function uh(a){const n=e.getCurrentScope();function t(l){var c;const d=_o.get(a)||new Set;d.add(l),_o.set(a,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function o(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=_o.get(a);c&&(c.delete(l),c.size||r())}function r(){_o.delete(a)}function s(l,c){var d;(d=_o.get(a))==null||d.forEach(u=>u(l,c))}return{on:t,once:o,off:i,emit:s,reset:r}}function Wd(){var r,s;const a=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function Zd(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=uh("media-selection"),r=Wd(),s=e.computed(()=>a.value.filter(S=>n.value.has(S.uuid))),l=e.computed(()=>n.value.size);e.watch(n,S=>{i.emit({type:"selection:changed",count:S.size,selectedIds:Array.from(S)})},{deep:!0});const c=e.computed(()=>a.value.length>0&&a.value.every(S=>n.value.has(S.uuid))),d=e.computed(()=>a.value.some(S=>n.value.has(S.uuid)));function u(S){return n.value.has(S)}function f(S){n.value.has(S)?(n.value.delete(S),t.value===S&&(t.value=null,o.value=-1)):(n.value.add(S),t.value=S,o.value=a.value.findIndex(C=>C.uuid===S),n.value.size===1&&r.selection())}function p(S){n.value.add(S),t.value=S,o.value=a.value.findIndex(C=>C.uuid===S)}function m(S){n.value.delete(S),t.value===S&&(t.value=null,o.value=-1)}function h(){a.value.forEach(S=>n.value.add(S.uuid))}function g(){n.value.clear(),t.value=null,o.value=-1}function w(){c.value?g():h()}function F(S,C){const V=a.value.findIndex(x=>x.uuid===S);if(V!==-1)if(C!=null&&C.shiftKey&&o.value!==-1){const x=Math.min(o.value,V),N=Math.max(o.value,V);for(let j=x;j<=N;j++)n.value.add(a.value[j].uuid)}else f(S)}function D(){if(a.value.length===0)return;let S=o.value+1;S>=a.value.length&&(S=0),g(),p(a.value[S].uuid)}function E(){if(a.value.length===0)return;let S=o.value-1;S<0&&(S=a.value.length-1),g(),p(a.value[S].uuid)}function v(S){switch(S.key){case"ArrowDown":S.preventDefault(),D();break;case"ArrowUp":S.preventDefault(),E();break;case"a":(S.ctrlKey||S.metaKey)&&(S.preventDefault(),h());break;case"Escape":S.preventDefault(),g();break;case" ":t.value&&(S.preventDefault(),f(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:f,select:p,deselect:m,selectAll:h,clear:g,toggleAll:w,rangeSelect:F,selectNext:D,selectPrevious:E,handleKeydown:v,selectionBus:i}}const mh={class:"flex items-center justify-between w-full px-4"},ph={class:"p-4"},fh={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},hh={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},vh=["value"],gh={class:"flex gap-2 mt-4"},yh={class:"flex justify-end mb-4"},bh={key:1,class:"flex justify-center items-center h-64"},wh={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},kh={class:"text-sm text-theme-secondary"},_h={key:0},Eh={class:"mb-4"},xh={class:"mb-4"},Sh={class:"flex gap-2"},Ch={class:"flex items-center justify-between px-4 py-2"},Vh={class:"text-sm text-theme-secondary"},Nh={key:0},Th={key:0},Mh={key:1},Bh={class:"flex gap-2"},Ih=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),f=e.ref(!1),p=e.ref({}),m=e.ref(["images","documents","videos"]),h=e.ref(1),g=e.ref(!0),w=e.ref(!1),F=Id(),D=Zd(c);function E($){var ge;const B=$.conversion_urls||{},Z=$.proxy_url||$.original_url||$.url||"",ee=B.thumb||B.preview||$.preview_url||$.thumbnail_url||Z,ne=$.custom_properties||{},de=ne.width,ue=ne.height;return{...$,uuid:$.uuid,name:$.name||$.file_name,file_name:$.file_name,filename:$.file_name,mime_type:$.mime_type,size:$.size,collection_name:$.collection_name||"images",disk:$.disk,original_url:Z,url:Z,thumbnail_url:ee,conversions:$.conversions||{},conversion_urls:B,generated_conversions:$.generated_conversions||{},custom_properties:ne,caption:$.caption||null,alt_text:$.alt_text||null,created_at:$.created_at,updated_at:$.updated_at,is_image:((ge=$.mime_type)==null?void 0:ge.startsWith("image/"))||!1,...typeof de=="number"?{width:de}:{},...typeof ue=="number"?{height:ue}:{},...$.formatted_size!==void 0?{formatted_size:$.formatted_size}:{}}}e.watch(()=>t.selectedItems,$=>{u.value=new Set($),D.clear(),$.forEach(B=>D.select(B))});const v=e.computed(()=>{var B;let $=c.value;return(B=p.value.types)!=null&&B.length&&($=$.filter(Z=>{var ne,de;const ee=(ne=Z.mime_type)==null?void 0:ne.split("/")[0];return(de=p.value.types)==null?void 0:de.includes(ee)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&($=$.filter(Z=>{const ee=Z.size/1048576;return!(p.value.sizeMin!==void 0&&ee<p.value.sizeMin||p.value.sizeMax!==void 0&&ee>p.value.sizeMax)})),$}),S=e.computed(()=>{var B;let $=0;return p.value.search&&$++,p.value.collection&&$++,(p.value.dateFrom||p.value.dateTo)&&$++,(B=p.value.types)!=null&&B.length&&($+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&$++,$}),C=e.computed(()=>{const $=D.selectedCount.value;return $===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${$} ${$===1?"Item":"Items"}`:"Item"}`}),V=e.computed(()=>{const $=D.selectedCount.value;return!!($===0||t.selectionMode==="single"&&$>1||t.maxSelection&&$>t.maxSelection)}),x=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 N($=!0){$?(l.value=!0,c.value=[],h.value=1,g.value=!0):w.value=!0;try{const B={collection:p.value.collection||t.collection,per_page:24};switch((s.value||p.value.search)&&(B.search=s.value||p.value.search||""),p.value.dateFrom&&(B.from_date=p.value.dateFrom),p.value.dateTo&&(B.to_date=p.value.dateTo),i.value){case"recent":await F.fetchMedia(h.value,B),$?c.value=F.items.map(Z=>E(Z)):c.value=[...c.value,...F.items.map(Z=>E(Z))],g.value=F.currentPage<F.totalPages;break;case"model":if(t.modelType&&t.modelId){const Z=await F.fetchModelMedia(t.modelType,t.modelId,B.collection,B.search);c.value=Z?Z.map(ee=>E(ee)):[],g.value=!1}break;case"library":await F.fetchMedia(h.value,B),$?c.value=F.items.map(Z=>E(Z)):c.value=[...c.value,...F.items.map(Z=>E(Z))],g.value=F.currentPage<F.totalPages;break}}catch{}finally{l.value=!1,w.value=!1}}async function j($){if(!g.value||w.value){$!=null&&$.target&&$.target.complete();return}h.value++,await N(!1),$!=null&&$.target&&($.target.complete(),g.value||($.target.disabled=!0))}function _($){return $==="recent"||$==="model"||$==="library"}function R($){i.value=$,N()}function T($){typeof $=="string"&&_($)&&R($)}async function z($){t.selectionMode==="single"?(D.clear(),D.select($.uuid)):(D.toggle($.uuid),t.maxSelection&&D.selectedCount.value>t.maxSelection&&(D.deselect($.uuid),await(await U.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){o("confirm",D.selectedItems.value)}function M(){o("close")}function L($){}const k=e.ref(null),O=e.ref(!1);function W($){k.value=$,O.value=!0}function G($){const B=c.value.findIndex(ee=>ee.uuid===$.uuid);B!==-1&&(c.value[B]=$);const Z={};$.alt_text!==void 0&&(Z.alt_text=$.alt_text),$.caption!==void 0&&(Z.caption=$.caption),$.custom_properties!==void 0&&(Z.custom_properties=$.custom_properties),F.updateMedia($.uuid,Z)}function ie(){N()}function we(){p.value={},s.value="",N()}const _e=dh(()=>{N(!0)},300);e.watch(s,()=>{t.isOpen&&_e()});async function oe($){try{await(await U.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 F.deleteMedia($),await N()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,$=>{$&&N()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach($=>D.select($))}),($,B)=>{const Z=e.resolveComponent("AdminMediaGrid"),ee=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":$.isOpen,onDidDismiss:M,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{onClick:M},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",mh,[e.createVNode(e.unref(U.IonSegment),{value:i.value,onIonChange:B[0]||(B[0]=ne=>T(ne.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[15]||(B[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(U.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[16]||(B[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[17]||(B[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(U.IonButton),{fill:"clear",size:"small",onClick:B[1]||(B[1]=ne=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[S.value>0?(e.openBlock(),e.createBlock(e.unref(U.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(S.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",ph,[f.value?(e.openBlock(),e.createElementBlock("div",fh,[e.createElementVNode("div",hh,[e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[18]||(B[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":B[2]||(B[2]=ne=>p.value.collection=ne),class:"w-full p-2 border rounded"},[B[19]||(B[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,ne=>(e.openBlock(),e.createElementBlock("option",{key:ne,value:ne},e.toDisplayString(ne),9,vh))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[20]||(B[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[3]||(B[3]=ne=>p.value.dateFrom=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[21]||(B[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[4]||(B[4]=ne=>p.value.dateTo=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",gh,[e.createVNode(e.unref(U.IonButton),{size:"small",onClick:ie},{default:e.withCtx(()=>[...B[22]||(B[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{size:"small",fill:"clear",onClick:we},{default:e.withCtx(()=>[...B[23]||(B[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":B[5]||(B[5]=ne=>s.value=ne),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",yh,[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:B[6]||(B[6]=ne=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(U.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:B[7]||(B[7]=ne=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",bh,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):v.value.length===0?(e.openBlock(),e.createElementBlock("div",wh,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),B[24]||(B[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",kh,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(Z,{key:3,"media-items":v.value,"selected-items":e.unref(D).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:z,onPreview:L,onEdit:W,onDelete:oe},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(U.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,(ne,de)=>(e.openBlock(),e.createBlock(ee,{key:ne.uuid,media:ne,selected:e.unref(D).isSelected(ne.uuid),"selection-mode":!0,index:de,onToggleSelect:z,onPreview:L,onEdit:W,onDelete:oe},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&v.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(U.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:B[8]||(B[8]=ne=>j(ne))},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(U.IonModal),{"is-open":O.value,onDidDismiss:B[14]||(B[14]=ne=>O.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{onClick:B[9]||(B[9]=ne=>O.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[...B[25]||(B[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"p-4"},{default:e.withCtx(()=>[k.value?(e.openBlock(),e.createElementBlock("div",_h,[e.createElementVNode("div",Eh,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[26]||(B[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[10]||(B[10]=ne=>k.value.caption=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,k.value.caption]])]),e.createElementVNode("div",xh,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...B[27]||(B[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[11]||(B[11]=ne=>k.value.alt_text=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,k.value.alt_text]])]),e.createElementVNode("div",Sh,[e.createVNode(e.unref(U.IonButton),{onClick:B[12]||(B[12]=ne=>G(k.value))},{default:e.withCtx(()=>[...B[28]||(B[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:B[13]||(B[13]=ne=>O.value=!1)},{default:e.withCtx(()=>[...B[29]||(B[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Ch,[e.createElementVNode("div",Vh,[e.unref(D).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Nh,[e.createTextVNode(e.toDisplayString(e.unref(D).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Th," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Mh," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Bh,[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:M},{default:e.withCtx(()=>[...B[30]||(B[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{disabled:V.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Fh=Ve(Ih,[["__scopeId","data-v-9a8c0954"]]),$h={key:1,class:"flex flex-col items-center justify-center py-16"},Dh=["draggable","onDragstart","onDragover","onDrop"],Rh={key:0,class:"absolute top-2 left-2 z-20"},Ah=["checked","onChange"],Lh={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Ph=["data-media-id"],Oh={key:0,class:"w-full h-full flex items-center justify-center"},Uh=["src","alt","onError","onLoad"],zh={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},jh={class:"text-center"},Wh={class:"text-4xl text-gray-400 mb-2"},Zh={class:"text-sm font-medium text-gray-500"},Hh={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Xh=["onClick"],Gh=["onClick"],Jh=["onClick"],Kh={class:"p-3"},Yh={class:"text-sm font-medium truncate mb-1"},qh={class:"text-xs text-gray-600 dark:text-gray-400"},Qh={key:0},ev={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},tv=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=V=>t.selectedItems.some(x=>x.uuid===V.uuid),d=e.computed(()=>{const V=t.columns,x=["grid","gap-4"];switch(V.mobile){case 1:x.push("grid-cols-1");break;case 2:x.push("grid-cols-2");break;case 3:x.push("grid-cols-3");break;case 4:x.push("grid-cols-4");break;default:x.push("grid-cols-2");break}switch(V.sm){case 1:x.push("sm:grid-cols-1");break;case 2:x.push("sm:grid-cols-2");break;case 3:x.push("sm:grid-cols-3");break;case 4:x.push("sm:grid-cols-4");break;case 5:x.push("sm:grid-cols-5");break;default:x.push("sm:grid-cols-3");break}switch(V.md){case 2:x.push("md:grid-cols-2");break;case 3:x.push("md:grid-cols-3");break;case 4:x.push("md:grid-cols-4");break;case 5:x.push("md:grid-cols-5");break;case 6:x.push("md:grid-cols-6");break;default:x.push("md:grid-cols-4");break}switch(V.lg){case 3:x.push("lg:grid-cols-3");break;case 4:x.push("lg:grid-cols-4");break;case 5:x.push("lg:grid-cols-5");break;case 6:x.push("lg:grid-cols-6");break;case 7:x.push("lg:grid-cols-7");break;default:x.push("lg:grid-cols-5");break}switch(V.xl){case 4:x.push("xl:grid-cols-4");break;case 5:x.push("xl:grid-cols-5");break;case 6:x.push("xl:grid-cols-6");break;case 7:x.push("xl:grid-cols-7");break;case 8:x.push("xl:grid-cols-8");break;default:x.push("xl:grid-cols-6");break}return x.join(" ")});function u(V,x,N){t.reorderable&&(i.value=x,V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/html","")))}function f(V,x){t.reorderable&&(V.preventDefault(),r.value=x)}function p(){r.value=null}function m(V,x){if(!t.reorderable||!i.value)return;V.preventDefault();const N=[...t.mediaItems],j=N.findIndex(_=>{var R;return _.uuid===((R=i.value)==null?void 0:R.uuid)});if(j!==-1&&j!==x&&i.value){const[_]=N.splice(j,1);N.splice(x,0,_),o("reorder",N)}i.value=null,r.value=null}function h(V){return V<1024?V+" B":V<1024*1024?(V/1024).toFixed(1)+" KB":(V/(1024*1024)).toFixed(1)+" MB"}function g(V){var N;return V.thumbnail_url||((N=V.conversion_urls)==null?void 0:N.thumb)||V.original_url||V.url||""}function w(V){var j,_,R;const x=((j=V.mime_type)==null?void 0:j.startsWith("image/"))||!1,N=!!(V.thumbnail_url||(_=V.conversion_urls)!=null&&_.thumb||(R=V.conversion_urls)!=null&&R.preview||V.original_url||V.url);return x&&N}function F(V){var x;return((x=V.split(".").pop())==null?void 0:x.toUpperCase())||""}function D(V){var N;const x=((N=V.mime_type)==null?void 0:N.toLowerCase())||"";return x.startsWith("image/")?"image":x.startsWith("video/")?"videocam":x.startsWith("audio/")?"musical-notes":x.includes("pdf")?"document-text":x.includes("zip")||x.includes("rar")?"archive":x.includes("sheet")||x.includes("excel")?"grid":x.includes("document")||x.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(V=>{V.forEach(x=>{var N;if(x.isIntersecting){const j=x.target.getAttribute("data-media-id");j&&(s.value.add(j),(N=l.value)==null||N.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function E(V){return!0}function v(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var j;const N=x.getAttribute("data-media-id");N&&!s.value.has(N)&&((j=l.value)==null||j.observe(x))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),v()},{immediate:!0,deep:!0});function S(V,x){const N=V.target;delete N.dataset.fallbackIndex}function C(V,x){const N=V.target,j=N.closest("[data-media-id]"),_=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(R=>R&&R.trim()!==""&&R!==N.src);if(_.length>0&&N.dataset.fallbackIndex){const R=parseInt(N.dataset.fallbackIndex);if(R<_.length){N.dataset.fallbackIndex=(R+1).toString(),N.src=_[R]||"";return}}else if(_.length>0){N.dataset.fallbackIndex="1",N.src=_[0]||"";return}if(N.style.display="none",j&&!j.querySelector(".media-fallback-icon")){const T=document.createElement("div");T.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",T.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${D(x)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${F(x.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,j.appendChild(T)}}return(V,x)=>V.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,N=>e.createElementVNode("div",{key:`skeleton-${N}`,class:"relative"},[...x[1]||(x[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)):!V.mediaItems||!V.mediaItems.length?(e.openBlock(),e.createElementBlock("div",$h,[x[2]||(x[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)),x[3]||(x[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),x[4]||(x[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:x[0]||(x[0]=N=>o("upload")),class:"px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"}," Upload Media ")])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.mediaItems,(N,j)=>(e.openBlock(),e.createElementBlock("div",{key:N.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===j}]),draggable:V.reorderable,onDragstart:_=>u(_,N),onDragover:_=>f(_,j),onDragleave:p,onDrop:_=>m(_,j)},[V.selectionMode?(e.openBlock(),e.createElementBlock("div",Rh,[e.createElementVNode("input",{type:"checkbox",checked:c(N),onChange:_=>o("toggleSelect",N),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,Ah)])):e.createCommentVNode("",!0),V.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",V.selectionMode?"left-10":"left-2"])},[e.renderSlot(V.$slots,"badge",{media:N,index:j},void 0,!0)],2)):e.createCommentVNode("",!0),V.reorderable?(e.openBlock(),e.createElementBlock("div",Lh,[...x[5]||(x[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":c(N)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":N.uuid},[w(N)&&!E(N.uuid)?(e.openBlock(),e.createElementBlock("div",Oh,[...x[6]||(x[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),w(N)&&E(N.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(N),alt:N.alt_text||N.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:_=>C(_,N),onLoad:_=>S(_)},null,40,Uh)):(e.openBlock(),e.createElementBlock("div",zh,[e.createElementVNode("div",jh,[e.createElementVNode("div",Wh,e.toDisplayString(D(N)),1),e.createElementVNode("p",Zh,e.toDisplayString(F(N.file_name)),1)])])),e.createElementVNode("div",Hh,[e.createElementVNode("button",{onClick:_=>o("preview",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...x[7]||(x[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,Xh),V.showEditButton&&w(N)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:_=>o("edit",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...x[8]||(x[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,Gh)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:_=>o("delete",N.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...x[9]||(x[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,Jh)])],8,Ph),e.createElementVNode("div",Kh,[e.createElementVNode("h4",Yh,e.toDisplayString(N.file_name),1),e.createElementVNode("p",qh,[e.createTextVNode(e.toDisplayString(h(N.size))+" ",1),N.width&&N.height?(e.openBlock(),e.createElementBlock("span",Qh," • "+e.toDisplayString(N.width)+"x"+e.toDisplayString(N.height),1)):e.createCommentVNode("",!0)]),N.caption?(e.openBlock(),e.createElementBlock("p",ev,e.toDisplayString(N.caption),1)):e.createCommentVNode("",!0)])],2)],42,Dh))),128))],2))}}),nv=Ve(tv,[["__scopeId","data-v-f0c343b7"]]),av={class:"model-media-manager"},ov=["accept","multiple"],iv={class:"flex items-center justify-between mb-4"},rv={key:0,class:"text-lg font-medium"},sv={class:"flex gap-2"},lv={key:0,class:"flex items-center justify-center py-8"},cv={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"},dv={class:"text-gray-600 dark:text-gray-400"},uv={class:"flex gap-2 mt-4"},mv={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},pv=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(a,{emit:n}){const t=a,o=n,i=dn(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(0),f=e.ref(null),p=e.ref(void 0),m=e.ref(null),h=e.ref(null),g=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),w=e.computed(()=>i.modelMedia.map(O=>O.uuid)),F=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function D(){Ya({isAdmin:t.mode==="admin"})}async function E(O){await(await U.toastController.create({message:O,duration:3e3,color:"danger",position:"bottom"})).present()}async function v(){if(!s.value)if(s.value=!0,D(),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(O){const W=O instanceof Error?O.message:"Failed to fetch media";o("error",{operation:"fetch",message:W,details:O})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,O=>{s.value&&o("update:media",O)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,v()}),e.watch(()=>t.mode,()=>{D()}),e.onMounted(()=>{v()}),e.onUnmounted(()=>{i.clearModelContext()});function S(){return i.modelMedia.length>0}function C(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function V(O){var G,ie,we;if(!((G=O.mime_type)!=null&&G.startsWith("image/")))return null;const W=O.original_url||O.url||((ie=O.conversion_urls)==null?void 0:ie.preview)||((we=O.conversion_urls)==null?void 0:we.thumb)||O.thumbnail_url;return W&&W.trim()!==""?W:null}function x(){l.value=!0}function N(){var O;(O=h.value)==null||O.click()}function j(){l.value=!1}async function _(O){if(!t.allowEdit)return;const W=V(O);if(W){d.value=O,u.value++;try{const G=i.getHttpClient(),ie=i.getApiUrl(""),we=await G(`${ie.replace(/\/$/,"")}/editor/${O.uuid}/edit`);p.value=we.editable_source_url||W,f.value=we.editor_state??null}catch{p.value=W,f.value=null}c.value=!0}}function R(){c.value=!1,d.value=null,p.value=void 0,f.value=null}async function T(O){if(!d.value)throw new Error("No media selected for editing");const W=d.value,G=t.editMode==="variant";try{m.value=null;const ie=await i.saveEditedImage(W.uuid,O,{asVariant:G,name:W.file_name});G||await i.detachMedia(t.mediableType,t.mediableId,W.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[ie.uuid],t.collection),o("edit-complete",{originalMedia:W,editedMedia:ie,mode:t.editMode}),c.value=!1,d.value=null}catch(ie){const we=ie instanceof Error?ie.message:"Failed to save edited image";throw m.value=we,await E(we),ie}}function z(O){if(m.value===O.message){m.value=null;return}E(O.message)}async function P(O){const W=O.target,G=W.files;if(!(!G||G.length===0)){for(let ie=0;ie<G.length;ie++){const we=G[ie];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(we.type)){o("error",{operation:"upload",message:`File type ${we.type} is not accepted`,details:{file:we.name}});continue}if(t.maxFileSize!==void 0&&we.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:we.name,size:we.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:we});try{const _e=await i.uploadFile(we,{collection:t.collection});_e!=null&&_e.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[_e.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:we}),o("attach",[_e]))}catch(_e){const oe=_e instanceof Error?_e.message:"Upload failed";o("error",{operation:"upload",message:oe,details:_e}),o("upload-progress",{status:"error",progress:0,file:we,error:oe})}}W.value=""}}async function M(O){const W=O.map(G=>G.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,W,t.collection),o("reorder",i.modelMedia)}catch(G){const ie=G instanceof Error?G.message:"Failed to reorder media";o("error",{operation:"reorder",message:ie,details:G}),await E(ie)}}async function L(O){const W=i.modelMedia.find(G=>G.uuid===O);try{await i.detachMedia(t.mediableType,t.mediableId,O,t.collection),W&&o("detach",W)}catch(G){const ie=G instanceof Error?G.message:"Failed to detach media";o("error",{operation:"detach",message:ie,details:G}),await E(ie)}}async function k(O){l.value=!1;const W=O.map(we=>we.uuid),G=new Set(w.value);let ie=Array.from(new Set(W)).filter(we=>!G.has(we));if(g.value!==void 0&&ie.length>g.value&&(ie=ie.slice(0,g.value)),ie.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,ie,t.collection);const we=i.modelMedia.filter(_e=>ie.includes(_e.uuid));o("attach",we)}catch(we){const _e=we instanceof Error?we.message:"Failed to attach media";o("error",{operation:"attach",message:_e,details:we})}}return(O,W)=>(e.openBlock(),e.createElementBlock("div",av,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:h,type:"file",accept:F.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:P},null,40,ov),e.createElementVNode("div",iv,[O.title?(e.openBlock(),e.createElementBlock("h3",rv,e.toDisplayString(O.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",sv,[O.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small",disabled:C(),"data-testid":"browse-button",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(Kr)},null,8,["icon"]),W[1]||(W[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),O.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small",disabled:C(),"data-testid":"upload-button",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(lc)},null,8,["icon"]),W[2]||(W[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",lv,[e.createVNode(e.unref(U.IonSpinner),{"data-testid":"spinner"})])):S()?(e.openBlock(),e.createBlock(nv,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!O.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!O.allowEdit,"selection-mode":!1,onReorder:M,onDelete:L,onEdit:_},e.createSlots({_:2},[O.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:G})=>[G===0?(e.openBlock(),e.createElementBlock("div",mv," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",cv,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Kr),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",dv,e.toDisplayString(O.emptyText),1),e.createElementVNode("div",uv,[O.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(Kr)},null,8,["icon"]),W[3]||(W[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),O.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(lc)},null,8,["icon"]),W[4]||(W[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Fh,e.mergeProps({"is-open":l.value,"selected-items":w.value,collection:O.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:k,onClose:j}),null,16,["is-open","selected-items","collection"]),e.createVNode(Ad,{modelValue:c.value,"onUpdate:modelValue":W[0]||(W[0]=G=>c.value=G),"initial-image":p.value,"initial-state":f.value,"session-key":u.value,onSave:T,onCancel:R,onError:z},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),fv=Ve(pv,[["__scopeId","data-v-f68e70ec"]]),hv={class:"existing-media-selector","data-testid":"existing-media-selector"},vv={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},gv=["data-testid"],yv={class:"existing-media-selector__section-header"},bv={class:"existing-media-selector__section-title"},wv=["data-testid","aria-label","onClick"],kv={class:"existing-media-selector__grid"},_v=["data-testid","aria-label","aria-pressed","onClick"],Ev=["src","alt"],xv={key:0,class:"existing-media-selector__selected-badge"},Sv={key:1,class:"existing-media-selector__caption"},Cv={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},Vv={class:"existing-media-selector__section-header"},Nv={class:"existing-media-selector__section-title"},Tv={class:"existing-media-selector__albums"},Mv=["data-testid","aria-label","aria-pressed","onClick"],Bv={class:"existing-media-selector__album-name"},Iv={key:0,class:"existing-media-selector__album-count"},Fv={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},$v={class:"existing-media-selector__section-header"},Dv={class:"existing-media-selector__section-subtitle"},Rv={key:0,class:"existing-media-selector__section-description"},Av={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},Lv={key:1,class:"existing-media-selector__grid"},Pv=["data-testid","aria-label","aria-pressed","onClick"],Ov=["src","alt"],Uv={key:0,class:"existing-media-selector__selected-badge"},zv={key:1,class:"existing-media-selector__caption"},jv={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},Wv={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Zv=e.defineComponent({__name:"ExistingMediaSelector",props:{sections:{default:()=>[]},albums:{default:()=>[]},selectedId:{default:null},activeAlbumId:{default:null},activeAlbumItems:{default:()=>[]},activeAlbumTitle:{},activeAlbumDescription:{},isLoading:{type:Boolean,default:!1},isAlbumLoading:{type:Boolean,default:!1},emptyMessage:{default:"No media available yet."},albumBrowseTitle:{default:"Browse Your Albums"},albumSectionTitle:{default:"Selected Album"},activeAlbumEmptyMessage:{default:"No media available in this album yet."}},emits:["select","update:activeAlbumId"],setup(a,{emit:n}){const t=a,o=n,i=e.reactive({}),r=e.computed(()=>t.sections.filter(v=>v.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),c=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const v=t.albums.find(S=>S.id===t.activeAlbumId);return v!=null&&v.name.trim().length?v.name.trim():t.albumSectionTitle}),d=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const v=t.albums.find(S=>S.id===t.activeAlbumId);return typeof(v==null?void 0:v.description)=="string"&&v.description.trim().length>0?v.description.trim():""});function u(v){const S=v.initialVisibleCount??6;return S>0?S:6}function f(v){return i[v]===!0}function p(v){i[v]=!f(v)}function m(v){return f(v.id)?v.items:v.items.slice(0,u(v))}function h(v){return v.items.length>u(v)}function g(v){o("select",v)}function w(v){o("update:activeAlbumId",v)}function F(v){var C;const S=(C=v.description)==null?void 0:C.trim();return S&&S.length>0?`Select ${S}`:"Select existing media"}function D(v,S){var V;const C=(V=S.description)==null?void 0:V.trim();return typeof S.alt=="string"&&S.alt.trim().length>0?S.alt.trim():C&&C.length>0?C:v.title}function E(v){const S=typeof v.mediaCount=="number"?` with ${v.mediaCount} item${v.mediaCount===1?"":"s"}`:"";return`Browse album ${v.name}${S}`}return(v,S)=>(e.openBlock(),e.createElementBlock("div",hv,[v.isLoading?(e.openBlock(),e.createElementBlock("div",vv," 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",yv,[e.createElementVNode("h3",bv,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:V=>p(C.id)},e.toDisplayString(f(C.id)?"See less":"See more"),9,wv)):e.createCommentVNode("",!0)]),e.createElementVNode("div",kv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m(C),V=>(e.openBlock(),e.createElementBlock("button",{key:V.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":v.selectedId===V.id}]),"data-testid":`existing-media-item-${C.id}-${V.id}`,"aria-label":F(V),"aria-pressed":v.selectedId===V.id?"true":"false",onClick:x=>g(V)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:V.previewUrl,alt:D(C,V)},null,8,Ev),v.selectedId===V.id?(e.openBlock(),e.createElementBlock("div",xv," Selected ")):e.createCommentVNode("",!0),V.description?(e.openBlock(),e.createElementBlock("div",Sv,e.toDisplayString(V.description),1)):e.createCommentVNode("",!0)],10,_v))),128))])],8,gv))),128)),s.value?(e.openBlock(),e.createElementBlock("section",Cv,[e.createElementVNode("div",Vv,[e.createElementVNode("h3",Nv,e.toDisplayString(v.albumBrowseTitle),1)]),e.createElementVNode("div",Tv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.albums,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":v.activeAlbumId===C.id}]),"data-testid":`existing-media-album-${C.id}`,"aria-label":E(C),"aria-pressed":v.activeAlbumId===C.id?"true":"false",onClick:V=>w(C.id)},[e.createElementVNode("span",Bv,e.toDisplayString(C.name),1),typeof C.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",Iv,e.toDisplayString(C.mediaCount),1)):e.createCommentVNode("",!0)],10,Mv))),128))]),e.createElementVNode("div",Fv,[e.createElementVNode("div",$v,[e.createElementVNode("div",null,[e.createElementVNode("h4",Dv,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",Rv,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),v.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",Av," Loading album... ")):v.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",Lv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.activeAlbumItems,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":v.selectedId===C.id}]),"data-testid":`existing-media-item-album-${C.id}`,"aria-label":F(C),"aria-pressed":v.selectedId===C.id?"true":"false",onClick:V=>g(C)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:C.previewUrl,alt:C.alt||C.description||c.value},null,8,Ov),v.selectedId===C.id?(e.openBlock(),e.createElementBlock("div",Uv," Selected ")):e.createCommentVNode("",!0),C.description?(e.openBlock(),e.createElementBlock("div",zv,e.toDisplayString(C.description),1)):e.createCommentVNode("",!0)],10,Pv))),128))])):(e.openBlock(),e.createElementBlock("div",jv,[e.renderSlot(v.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(v.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Wv,[e.renderSlot(v.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(v.emptyMessage),1)],!0)]))],64))]))}}),Hv=Ve(Zv,[["__scopeId","data-v-904abb6b"]]);function vi(a,n,t,o){if(t<=0||o<=0)return!1;try{return n.drawImage(a,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Xv(a,n){return a?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:n,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:n,opacity:"1",pointerEvents:"auto"}}const Gv=["src","crossorigin"],Jv={class:"preview-controls"},Kv=["aria-label"],Yv={class:"time-display"},qv={class:"current-time"},Qv={class:"total-time"},e0={key:0,class:"fps-display"},t0={key:0,class:"loading-overlay"},n0={key:1,class:"error-overlay"},a0=.1,o0=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Ct,r=a,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),f=e.ref(),p=e.ref(0),m=e.ref(0),h=e.ref(!1);let g,w,F=null,D=null,E=null,v=[],S="",C=null,V=0,x=0,N=0,j=0,_=!1,R=0,T=0,z,P=null,M=!1,L=!1,k=0;const O=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),W=e.computed(()=>{const ve=O.value;if(!(!ve||ve.startsWith("blob:")))return"anonymous"}),G=e.computed(()=>Xv(h.value,r.fitMode));function ie(ve){return typeof ve=="number"&&Number.isFinite(ve)&&ve>=0?ve:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function we(ve){const Se=ie(ve.duration);return Se<=0?!1:ve.currentTime>=Math.max(0,Se-a0)}async function _e(){var ve,Se;if(!L&&c.value&&!g&&!(!d.value||d.value.readyState<3)){L=!0;try{f.value=void 0;let Fe=((ve=l.value)==null?void 0:ve.clientWidth)||800,Ke=((Se=l.value)==null?void 0:Se.clientHeight)||450;if((Fe<=0||Ke<=0)&&(Fe=d.value.videoWidth||800,Ke=d.value.videoHeight||450),g=new Ct.Application,await g.init({width:Fe,height:Ke,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(g.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!g&&_e()},100),g&&(g.destroy(!0),g=null);return}if(V=d.value.videoWidth,x=d.value.videoHeight,D=document.createElement("canvas"),D.width=V,D.height=x,E=D.getContext("2d"),!E)throw new Error("Unable to create 2D canvas context for video preview");const We=vi(d.value,E,V,x),ze=Ct.Texture.from(D);F=ze.source,w=new Ct.Sprite(ze),w.visible=!0,w.alpha=1,_t(),g.stage.addChild(w),g.renderer&&!g.renderer.destroyed&&g.render()}Z(),r.targetFps<60?oe():g.ticker.add($),h.value=!0,"ResizeObserver"in window&&(C=new ResizeObserver(We=>{_||(_=!0,requestAnimationFrame(()=>{_=!1;const ze=We[We.length-1],{width:ut,height:Et}=ze.contentRect;if(ut<=0||Et<=0)return;const It=Math.round(ut),Rt=Math.round(Et);It===N&&Rt===j||(N=It,j=Rt,_t())}))}),C.observe(l.value)),r.filters&&r.filters.length>0&&Z(),r.showFps&&dt(),k=0}catch{if(pt(),!M&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&k<2){k+=1,window.setTimeout(()=>{M||_e()},k*150);return}f.value="Failed to initialize video preview",s("error",f.value)}finally{L=!1}}}function oe(){const ve=1e3/r.targetFps;let Se=performance.now();function Fe(){if(M||!g)return;const Ke=performance.now(),We=Ke-Se;We>=ve&&($(),Se=Ke-We%ve),P=requestAnimationFrame(Fe)}P=requestAnimationFrame(Fe)}function $(){if(!(!g||!w||M)&&r.active)try{E&&D&&F&&d.value&&(d.value.readyState>=2&&vi(d.value,E,D.width,D.height)&&F.update(),d.value.paused||s("frame-update",de())),r.showFps&&T++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{M=!0}}function B(){for(const ve of v)try{ve.destroy()}catch{}v=[]}function Z(){if(w){if(!r.filters||r.filters.length===0){w.filters=null,B();return}B(),r.filters.forEach(ve=>{const Se=ee(ve);Se&&v.push(Se)}),w.filters=v.length>0?v:null,S=JSON.stringify(r.filters),g&&g.render()}}function ee(ve){const Se=ve.filterId,Fe=ve.params||{},Ke=pe.getFilter(Se);if(Ke&&!pe.isFilterCompatibleWithMedia(Se,"video"))return null;if(Ke&&Ke.createFilter)try{return Ke.createFilter(Fe)}catch{}const We=(ze,ut,Et)=>Math.min(Et,Math.max(ut,ze));switch(Se){case"brightness":{const ze=new o,ut=We(typeof Fe.brightness=="number"?Fe.brightness:typeof Fe.value=="number"?Fe.value:1,0,5);return ze.brightness(ut,!0),ze}case"contrast":{const ze=new o,ut=We(typeof Fe.contrast=="number"?Fe.contrast:typeof Fe.value=="number"?Fe.value:1,0,5);return ze.contrast(ut,!0),ze}case"saturation":{const ze=new o,ut=We(typeof Fe.saturation=="number"?Fe.saturation:typeof Fe.value=="number"?Fe.value:1,0,5);return ze.saturate(ut,!0),ze}case"hue":{const ze=new o,ut=We(typeof Fe.value=="number"?Fe.value:0,-180,180);return ze.hue(ut,!0),ze}case"gaussian-blur":case"blur":{const ze=We(typeof Fe.blur=="number"?Fe.blur:typeof Fe.value=="number"?Fe.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 Fe.value=="number"?Fe.value:.3;return ne(We(ze,0,1))}default:return null}}function ne(ve){const Se=`
|
|
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 Ct.Filter(void 0,Se,{strength:ve})}function de(){var Se;return!g||!w?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((Se=d.value)==null?void 0:Se.currentTime)||0,width:V||0,height:x||0}}function ue(){var ve;p.value=ie((ve=d.value)==null?void 0:ve.duration),s("duration-change",p.value)}function ge(){u.value=!1,f.value=void 0}function Ne(){u.value&&(u.value=!1),!h.value&&r.active?_e():h.value}function fe(){var Se,Fe,Ke;const ve=((Se=d.value)==null?void 0:Se.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:ve,width:((Fe=d.value)==null?void 0:Fe.videoWidth)||0,height:((Ke=d.value)==null?void 0:Ke.videoHeight)||0})}function me(){d.value&&(d.value.currentTime=0),s("play-pause")}function Ee(ve){var Fe;const Se=ve.target;if(Se!=null&&Se.error)switch(Se.error.code){case Se.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case Se.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case Se.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case Se.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${(Fe=Se.src)==null?void 0:Fe.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 Te(ve){d.value&&(d.value.currentTime=Math.max(0,Math.min(ve,p.value)))}function dt(){z=window.setInterval(()=>{const ve=performance.now(),Se=ve-R;m.value=Math.round(T*1e3/Se),T=0,R=ve},1e3)}function st(ve){if(!Number.isFinite(ve)||ve<0)return"00:00";const Se=Math.floor(ve/60),Fe=Math.floor(ve%60);return`${Se.toString().padStart(2,"0")}:${Fe.toString().padStart(2,"0")}`}function Dt(){f.value=void 0,u.value=!0,k=0,pt(),d.value&&d.value.load()}function pt(){if(C&&(C.disconnect(),C=null),P&&(cancelAnimationFrame(P),P=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove($)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),B(),g=null,w=null,F=null,D=null,E=null,h.value=!1,_=!1,S=""}function ft(){g&&(_||(_=!0,requestAnimationFrame(()=>{_=!1,_t()})))}function _t(){if(!g||!w||!V||!x||!l.value)return;const ve=Math.round(l.value.clientWidth),Se=Math.round(l.value.clientHeight);if(ve<=0||Se<=0)return;g.renderer.resize(ve,Se);const Fe=g.screen.width/V,Ke=g.screen.height/x;let We=1;switch(r.fitMode){case"cover":We=Math.max(Fe,Ke);break;case"none":We=1;break;case"contain":default:We=Math.min(Fe,Ke);break}w.scale.set(We),w.anchor.set(.5),w.position.set(g.screen.width/2,g.screen.height/2),w.visible=!0,w.alpha=1,g.renderer&&!g.renderer.destroyed&&g.render()}e.watch(()=>r.filters,()=>{h.value&&Z()},{deep:!0}),e.watch(()=>r.active,async ve=>{if(ve&&!g&&d.value&&d.value.readyState>=2){await _e();return}g&&(ve&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),w&&E&&D&&F&&(d.value&&d.value.readyState>=2&&vi(d.value,E,D.width,D.height)&&F.update(),_t(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(ve?g.ticker.start():g.ticker.stop()))}),e.watch(O,ve=>{ve?(u.value=!0,f.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0});async function ot(){if(d.value){f.value=void 0,we(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}f.value="Unable to start preview playback",s("error",f.value)}}e.watch(()=>r.isPlaying,ve=>{d.value&&(ve?ot():d.value.pause())}),e.watch(()=>r.playhead,ve=>{d.value&&Math.abs(d.value.currentTime-ve)>.5&&Te(ve)}),e.watch(()=>r.fitMode,()=>{_t()}),e.onMounted(()=>{M=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",ft),R=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!h.value?_e():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(M=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",ft),C&&(C.disconnect(),C=null),z&&clearInterval(z),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove($)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}v.forEach(ve=>{try{ve.destroy()}catch{}}),v=[],w=null,F=null,D=null,E=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function bt(ve){if(!await gt()||!d.value||!E||!D||!F)return null;const Fe=d.value,Ke=Number.isFinite(p.value)&&p.value>0?p.value:Number.isFinite(Fe.duration)&&Fe.duration>0?Fe.duration:0,We=Math.max(0,Math.min(ve,Ke));return await new Promise(ut=>{let Et=!1,It=0;const Rt=()=>{Et||(Et=!0,Fe.removeEventListener("seeked",Xt),window.clearTimeout(It),ut())},Xt=()=>{Rt()},yn=Number.isFinite(Fe.currentTime)?Fe.currentTime:0;if(Math.abs(yn-We)<.016){requestAnimationFrame(()=>Rt());return}Fe.addEventListener("seeked",Xt),It=window.setTimeout(()=>Rt(),700),Fe.currentTime=We}),vi(Fe,E,D.width,D.height)?(F.update(),g.render(),g.canvas):null}async function gt(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await _e()}if(!g||!w||!E||!D||!F)return!1;if(r.filters&&r.filters.length>0){const ve=w.filters,Se=Array.isArray(ve)?ve.length:0,Ke=JSON.stringify(r.filters)!==S;(Se===0||Se!==r.filters.length||Ke)&&Z()}return await e.nextTick(),await new Promise(ve=>{requestAnimationFrame(()=>ve())}),!0}return n({captureFrameAt:bt,ensureReadyForCapture:gt,duration:p,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(ve,Se)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:c},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:O.value,onLoadedmetadata:ue,onLoadeddata:ge,onCanplay:Ne,onTimeupdate:fe,onEnded:me,onError:Ee,style:e.normalizeStyle(G.value),crossorigin:W.value,preload:"auto",playsinline:"",controls:""},null,44,Gv),e.createElementVNode("div",Jv,[e.createElementVNode("button",{class:"play-button",onClick:Se[0]||(Se[0]=Fe=>ve.$emit("play-pause")),"aria-label":ve.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:ve.isPlaying?e.unref(Od):e.unref(Ud)},null,8,["icon"])],8,Kv),e.createElementVNode("div",Yv,[e.createElementVNode("span",qv,e.toDisplayString(st(ve.playhead)),1),Se[1]||(Se[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Qv,e.toDisplayString(st(p.value)),1)]),ve.showFps?(e.openBlock(),e.createElementBlock("div",e0,e.toDisplayString(m.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",t0,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),Se[2]||(Se[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",n0,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ol)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:Dt},"Retry")])):e.createCommentVNode("",!0)],512))}}),ys=Ve(o0,[["__scopeId","data-v-dd1744f4"]]);var sl=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},X=(a,n,t)=>(sl(a,n,"read from private field"),t?t.call(a):n.get(a)),Je=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},$t=(a,n,t,o)=>(sl(a,n,"write to private field"),n.set(a,t),t),i0=(a,n,t,o)=>({set _(i){$t(a,n,i)},get _(){return X(a,n,o)}}),qe=(a,n,t)=>(sl(a,n,"access private method"),t),Qe=new Uint8Array(8),An=new DataView(Qe.buffer),Bt=a=>[(a%256+256)%256],nt=a=>(An.setUint16(0,a,!1),[Qe[0],Qe[1]]),r0=a=>(An.setInt16(0,a,!1),[Qe[0],Qe[1]]),Hd=a=>(An.setUint32(0,a,!1),[Qe[1],Qe[2],Qe[3]]),Ie=a=>(An.setUint32(0,a,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),s0=a=>(An.setInt32(0,a,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),Va=a=>(An.setUint32(0,Math.floor(a/2**32),!1),An.setUint32(4,a,!1),[Qe[0],Qe[1],Qe[2],Qe[3],Qe[4],Qe[5],Qe[6],Qe[7]]),ll=a=>(An.setInt16(0,2**8*a,!1),[Qe[0],Qe[1]]),$n=a=>(An.setInt32(0,2**16*a,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),qr=a=>(An.setInt32(0,2**30*a,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),hn=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},ji=a=>a&&a[a.length-1],cl=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Rn=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},Xd=a=>{let n=a*(Math.PI/180),t=Math.cos(n),o=Math.sin(n);return[t,o,0,-o,t,0,0,0,1]},Gd=Xd(0),Jd=a=>[$n(a[0]),$n(a[1]),qr(a[2]),$n(a[3]),$n(a[4]),qr(a[5]),$n(a[6]),$n(a[7]),qr(a[8])],Io=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(Io):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,Io(t)])),Qa=a=>a>=0&&a<2**32,Nt=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),vt=(a,n,t,o,i)=>Nt(a,[Bt(n),Hd(t),o??[]],i),l0=a=>{let n=512;return a.fragmented?Nt("ftyp",[hn("iso5"),Ie(n),hn("iso5"),hn("iso6"),hn("mp41")]):Nt("ftyp",[hn("isom"),Ie(n),hn("isom"),a.holdsAvc?hn("avc1"):[],hn("mp41")])},bs=a=>({type:"mdat",largeSize:a}),c0=a=>({type:"free",size:a}),Mi=(a,n,t=!1)=>Nt("moov",null,[d0(n,a),...a.map(o=>u0(o,n)),t?z0(a):null]),d0=(a,n)=>{let t=Rn(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=cl(s.samples);return l.presentationTimestamp+l.duration})),_s),o=Math.max(...n.map(s=>s.id))+1,i=!Qa(a)||!Qa(t),r=i?Va:Ie;return vt("mvhd",+i,0,[r(a),r(a),Ie(_s),r(t),$n(1),ll(1),Array(10).fill(0),Jd(Gd),Array(24).fill(0),Ie(o)])},u0=(a,n)=>Nt("trak",null,[m0(a,n),p0(a,n)]),m0=(a,n)=>{let t=cl(a.samples),o=Rn(t?t.presentationTimestamp+t.duration:0,_s),i=!Qa(n)||!Qa(o),r=i?Va:Ie,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?Xd(a.info.rotation):a.info.rotation:s=Gd,vt("tkhd",+i,3,[r(n),r(n),Ie(a.id),Ie(0),r(o),Array(8).fill(0),nt(0),nt(0),ll(a.info.type==="audio"?1:0),nt(0),Jd(s),$n(a.info.type==="video"?a.info.width:0),$n(a.info.type==="video"?a.info.height:0)])},p0=(a,n)=>Nt("mdia",null,[f0(a,n),h0(a.info.type==="video"?"vide":"soun"),v0(a)]),f0=(a,n)=>{let t=cl(a.samples),o=Rn(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Qa(n)||!Qa(o),r=i?Va:Ie;return vt("mdhd",+i,0,[r(n),r(n),Ie(a.timescale),r(o),nt(21956),nt(0)])},h0=a=>vt("hdlr",0,0,[hn("mhlr"),hn(a),Ie(0),Ie(0),Ie(0),hn("mp4-muxer-hdlr",!0)]),v0=a=>Nt("minf",null,[a.info.type==="video"?g0():y0(),b0(),_0(a)]),g0=()=>vt("vmhd",0,1,[nt(0),nt(0),nt(0),nt(0)]),y0=()=>vt("smhd",0,0,[nt(0),nt(0)]),b0=()=>Nt("dinf",null,[w0()]),w0=()=>vt("dref",0,0,[Ie(1)],[k0()]),k0=()=>vt("url ",0,1),_0=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Nt("stbl",null,[E0(a),R0(a),A0(a),L0(a),P0(a),O0(a),n?U0(a):null])},E0=a=>vt("stsd",0,0,[Ie(1)],[a.info.type==="video"?x0(q0[a.info.codec],a):F0(eg[a.info.codec],a)]),x0=(a,n)=>Nt(a,[Array(6).fill(0),nt(1),nt(0),nt(0),Array(12).fill(0),nt(n.info.width),nt(n.info.height),Ie(4718592),Ie(4718592),Ie(0),nt(1),Array(32).fill(0),nt(24),r0(65535)],[Q0[n.info.codec](n),n.info.decoderConfig.colorSpace?N0(n):null]),S0={bt709:1,bt470bg:5,smpte170m:6},C0={bt709:1,smpte170m:6,"iec61966-2-1":13},V0={rgb:0,bt709:1,bt470bg:5,smpte170m:6},N0=a=>Nt("colr",[hn("nclx"),nt(S0[a.info.decoderConfig.colorSpace.primaries]),nt(C0[a.info.decoderConfig.colorSpace.transfer]),nt(V0[a.info.decoderConfig.colorSpace.matrix]),Bt((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),T0=a=>a.info.decoderConfig&&Nt("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),M0=a=>a.info.decoderConfig&&Nt("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),B0=a=>{if(!a.info.decoderConfig)return null;let n=a.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),o=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return vt("vpcC",1,0,[Bt(o),Bt(i),Bt(l),Bt(2),Bt(2),Bt(2),nt(0)])},I0=()=>{let t=(1<<7)+1;return Nt("av1C",[t,0,0,0])},F0=(a,n)=>Nt(a,[Array(6).fill(0),nt(1),nt(0),nt(0),Ie(0),nt(n.info.numberOfChannels),nt(16),nt(0),nt(0),$n(n.info.sampleRate)],[tg[n.info.codec](n)]),$0=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return vt("esds",0,0,[Ie(58753152),Bt(32+n.byteLength),nt(1),Bt(0),Ie(75530368),Bt(18+n.byteLength),Bt(64),Bt(21),Hd(0),Ie(130071),Ie(130071),Ie(92307584),Bt(n.byteLength),...n,Ie(109084800),Bt(1),Bt(2)])},D0=a=>{var i;let n=3840,t=0;const o=(i=a.info.decoderConfig)==null?void 0:i.description;if(o){if(o.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(o)?new DataView(o.buffer,o.byteOffset,o.byteLength):new DataView(o);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return Nt("dOps",[Bt(0),Bt(a.info.numberOfChannels),nt(n),Ie(a.info.sampleRate),ll(t),Bt(0)])},R0=a=>vt("stts",0,0,[Ie(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[Ie(n.sampleCount),Ie(n.sampleDelta)])]),A0=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return vt("stss",0,0,[Ie(n.length),n.map(([t])=>Ie(t+1))])},L0=a=>vt("stsc",0,0,[Ie(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[Ie(n.firstChunk),Ie(n.samplesPerChunk),Ie(1)])]),P0=a=>vt("stsz",0,0,[Ie(0),Ie(a.samples.length),a.samples.map(n=>Ie(n.size))]),O0=a=>a.finalizedChunks.length>0&&ji(a.finalizedChunks).offset>=2**32?vt("co64",0,0,[Ie(a.finalizedChunks.length),a.finalizedChunks.map(n=>Va(n.offset))]):vt("stco",0,0,[Ie(a.finalizedChunks.length),a.finalizedChunks.map(n=>Ie(n.offset))]),U0=a=>vt("ctts",0,0,[Ie(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[Ie(n.sampleCount),Ie(n.sampleCompositionTimeOffset)])]),z0=a=>Nt("mvex",null,a.map(j0)),j0=a=>vt("trex",0,0,[Ie(a.id),Ie(1),Ie(0),Ie(0),Ie(0)]),fc=(a,n)=>Nt("moof",null,[W0(a),...n.map(Z0)]),W0=a=>vt("mfhd",0,0,[Ie(a)]),Kd=a=>{let n=0,t=0,o=0,i=0,r=a.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|o<<8|i},Z0=a=>Nt("traf",null,[H0(a),X0(a),G0(a)]),H0=a=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=a.currentChunk.samples[1]??a.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:Kd(t)};return vt("tfhd",0,n,[Ie(a.id),Ie(o.duration),Ie(o.size),Ie(o.flags)])},X0=a=>vt("tfdt",1,0,[Va(Rn(a.currentChunk.startTimestamp,a.timescale))]),G0=a=>{let n=a.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(g=>g.size),o=a.currentChunk.samples.map(Kd),i=a.currentChunk.samples.map(g=>Rn(g.presentationTimestamp-g.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),l=new Set(o),c=new Set(i),d=l.size===2&&o[0]!==o[1],u=r.size>1,f=s.size>1,p=!d&&l.size>1,m=c.size>1||[...c].some(g=>g!==0),h=0;return h|=1,h|=4*+d,h|=256*+u,h|=512*+f,h|=1024*+p,h|=2048*+m,vt("trun",1,h,[Ie(a.currentChunk.samples.length),Ie(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?Ie(o[0]):[],a.currentChunk.samples.map((g,w)=>[u?Ie(n[w]):[],f?Ie(t[w]):[],p?Ie(o[w]):[],m?s0(i[w]):[]])])},J0=a=>Nt("mfra",null,[...a.map(K0),Y0()]),K0=(a,n)=>vt("tfra",1,0,[Ie(a.id),Ie(63),Ie(a.finalizedChunks.length),a.finalizedChunks.map(o=>[Va(Rn(o.startTimestamp,a.timescale)),Va(o.moofOffset),Ie(n+1),Ie(1),Ie(1)])]),Y0=()=>vt("mfro",0,0,[Ie(0)]),q0={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Q0={avc:T0,hevc:M0,vp9:B0,av1:I0},eg={aac:"mp4a",opus:"Opus"},tg={aac:$0,opus:D0},or=class{},dl=class extends or{constructor(){super(...arguments),this.buffer=null}},Yd=class extends or{constructor(a){if(super(),this.options=a,typeof a!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(a.onData){if(typeof a.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(a.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(a.chunked!==void 0&&typeof a.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},ng=class extends or{constructor(a,n){if(super(),this.stream=a,this.options=n,!(a instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(n!==void 0&&typeof n!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(n&&n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},va,Ha,qd=class{constructor(){this.pos=0,Je(this,va,new Uint8Array(8)),Je(this,Ha,new DataView(X(this,va).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){X(this,Ha).setUint32(0,a,!1),this.write(X(this,va).subarray(0,4))}writeU64(a){X(this,Ha).setUint32(0,Math.floor(a/2**32),!1),X(this,Ha).setUint32(4,a,!1),this.write(X(this,va).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)X(this,Ha).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(X(this,va));a.length%8!==0&&this.write(X(this,va).subarray(0,a.length%8))}writeBox(a){if(this.offsets.set(a,this.pos),a.contents&&!a.children)this.writeBoxHeader(a,a.size??a.contents.byteLength+8),this.write(a.contents);else{let n=this.pos;if(this.writeBoxHeader(a,0),a.contents&&this.write(a.contents),a.children)for(let i of a.children)i&&this.writeBox(i);let t=this.pos,o=a.size??t-n;this.seek(n),this.writeBoxHeader(a,o),this.seek(t)}}writeBoxHeader(a,n){this.writeU32(a.largeSize?1:n),this.writeAscii(a.type),a.largeSize&&this.writeU64(n)}measureBoxHeader(a){return 8+(a.largeSize?8:0)}patchBox(a){let n=this.pos;this.seek(this.offsets.get(a)),this.writeBox(a),this.seek(n)}measureBox(a){if(a.contents&&!a.children)return this.measureBoxHeader(a)+a.contents.byteLength;{let n=this.measureBoxHeader(a);if(a.contents&&(n+=a.contents.byteLength),a.children)for(let t of a.children)t&&(n+=this.measureBox(t));return n}}};va=new WeakMap;Ha=new WeakMap;var Bi,xa,Uo,No,Ii,ws,ag=class extends qd{constructor(a){super(),Je(this,Ii),Je(this,Bi,void 0),Je(this,xa,new ArrayBuffer(2**16)),Je(this,Uo,new Uint8Array(X(this,xa))),Je(this,No,0),$t(this,Bi,a)}write(a){qe(this,Ii,ws).call(this,this.pos+a.byteLength),X(this,Uo).set(a,this.pos),this.pos+=a.byteLength,$t(this,No,Math.max(X(this,No),this.pos))}finalize(){qe(this,Ii,ws).call(this,this.pos),X(this,Bi).buffer=X(this,xa).slice(0,Math.max(X(this,No),this.pos))}};Bi=new WeakMap;xa=new WeakMap;Uo=new WeakMap;No=new WeakMap;Ii=new WeakSet;ws=function(a){let n=X(this,xa).byteLength;for(;n<a;)n*=2;if(n===X(this,xa).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(X(this,Uo),0),$t(this,xa,t),$t(this,Uo,o)};var og=2**24,ig=2,Fo,ga,To,Zn,pn,Wi,ks,ul,Qd,ml,eu,$o,Zi,pl=class extends qd{constructor(a){var n,t;super(),Je(this,Wi),Je(this,ul),Je(this,ml),Je(this,$o),Je(this,Fo,void 0),Je(this,ga,[]),Je(this,To,void 0),Je(this,Zn,void 0),Je(this,pn,[]),$t(this,Fo,a),$t(this,To,((n=a.options)==null?void 0:n.chunked)??!1),$t(this,Zn,((t=a.options)==null?void 0:t.chunkSize)??og)}write(a){X(this,ga).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(X(this,ga).length===0)return;let a=[],n=[...X(this,ga)].sort((i,r)=>i.start-r.start);a.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=a[a.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):a.push({start:s.start,size:s.data.byteLength})}for(let i of a){i.data=new Uint8Array(i.size);for(let r of X(this,ga))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);X(this,To)?(qe(this,Wi,ks).call(this,i.data,i.start),qe(this,$o,Zi).call(this)):(o=(t=X(this,Fo).options).onData)==null||o.call(t,i.data,i.start)}X(this,ga).length=0}finalize(){X(this,To)&&qe(this,$o,Zi).call(this,!0)}};Fo=new WeakMap;ga=new WeakMap;To=new WeakMap;Zn=new WeakMap;pn=new WeakMap;Wi=new WeakSet;ks=function(a,n){let t=X(this,pn).findIndex(l=>l.start<=n&&n<l.start+X(this,Zn));t===-1&&(t=qe(this,ml,eu).call(this,n));let o=X(this,pn)[t],i=n-o.start,r=a.subarray(0,Math.min(X(this,Zn)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(qe(this,ul,Qd).call(this,o,s),o.written[0].start===0&&o.written[0].end===X(this,Zn)&&(o.shouldFlush=!0),X(this,pn).length>ig){for(let l=0;l<X(this,pn).length-1;l++)X(this,pn)[l].shouldFlush=!0;qe(this,$o,Zi).call(this)}r.byteLength<a.byteLength&&qe(this,Wi,ks).call(this,a.subarray(r.byteLength),n+r.byteLength)};ul=new WeakSet;Qd=function(a,n){let t=0,o=a.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);a.written[r].start<=n.start?(t=r+1,i=r):o=r-1}for(a.written.splice(i+1,0,n),(i===-1||a.written[i].end<n.start)&&i++;i<a.written.length-1&&a.written[i].end>=a.written[i+1].start;)a.written[i].end=Math.max(a.written[i].end,a.written[i+1].end),a.written.splice(i+1,1)};ml=new WeakSet;eu=function(a){let t={start:Math.floor(a/X(this,Zn))*X(this,Zn),data:new Uint8Array(X(this,Zn)),written:[],shouldFlush:!1};return X(this,pn).push(t),X(this,pn).sort((o,i)=>o.start-i.start),X(this,pn).indexOf(t)};$o=new WeakSet;Zi=function(a=!1){var n,t;for(let o=0;o<X(this,pn).length;o++){let i=X(this,pn)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=X(this,Fo).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);X(this,pn).splice(o--,1)}}};var rg=class extends pl{constructor(a){var n;super(new Yd({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},_s=1e3,sg=["avc","hevc","vp9","av1"],lg=["aac","opus"],cg=2082844800,dg=["strict","offset","cross-track-offset"],Pe,Ue,Hi,un,Ot,Ft,Xa,Ga,fl,ya,ba,Do,Es,tu,xs,nu,hl,au,Ss,ou,vl,iu,Fi,Cs,Fn,Wn,gl,ru,Ro,Xi,Gi,yl,eo,Go,$i,Vs,su=class{constructor(a){if(Je(this,Es),Je(this,xs),Je(this,hl),Je(this,Ss),Je(this,vl),Je(this,Fi),Je(this,Fn),Je(this,gl),Je(this,Ro),Je(this,Gi),Je(this,eo),Je(this,$i),Je(this,Pe,void 0),Je(this,Ue,void 0),Je(this,Hi,void 0),Je(this,un,void 0),Je(this,Ot,null),Je(this,Ft,null),Je(this,Xa,Math.floor(Date.now()/1e3)+cg),Je(this,Ga,[]),Je(this,fl,1),Je(this,ya,[]),Je(this,ba,[]),Je(this,Do,!1),qe(this,Es,tu).call(this,a),a.video=Io(a.video),a.audio=Io(a.audio),a.fastStart=Io(a.fastStart),this.target=a.target,$t(this,Pe,{firstTimestampBehavior:"strict",...a}),a.target instanceof dl)$t(this,Ue,new ag(a.target));else if(a.target instanceof Yd)$t(this,Ue,new pl(a.target));else if(a.target instanceof ng)$t(this,Ue,new rg(a.target));else throw new Error(`Invalid target: ${a.target}`);qe(this,Ss,ou).call(this),qe(this,xs,nu).call(this)}addVideoChunk(a,n,t,o){if(!(a instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(n&&typeof n!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(o!==void 0&&!Number.isFinite(o))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(a.byteLength);a.copyTo(i),this.addVideoChunkRaw(i,a.type,t??a.timestamp,a.duration,n,o)}addVideoChunkRaw(a,n,t,o,i,r){if(!(a instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(o)||o<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(r!==void 0&&!Number.isFinite(r))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(qe(this,$i,Vs).call(this),!X(this,Pe).video)throw new Error("No video track declared.");if(typeof X(this,Pe).fastStart=="object"&&X(this,Ot).samples.length===X(this,Pe).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${X(this,Pe).fastStart.expectedVideoChunks}).`);let s=qe(this,Fi,Cs).call(this,X(this,Ot),a,n,t,o,i,r);if(X(this,Pe).fastStart==="fragmented"&&X(this,Ft)){for(;X(this,ba).length>0&&X(this,ba)[0].decodeTimestamp<=s.decodeTimestamp;){let l=X(this,ba).shift();qe(this,Fn,Wn).call(this,X(this,Ft),l)}s.decodeTimestamp<=X(this,Ft).lastDecodeTimestamp?qe(this,Fn,Wn).call(this,X(this,Ot),s):X(this,ya).push(s)}else qe(this,Fn,Wn).call(this,X(this,Ot),s)}addAudioChunk(a,n,t){if(!(a instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(n&&typeof n!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let o=new Uint8Array(a.byteLength);a.copyTo(o),this.addAudioChunkRaw(o,a.type,t??a.timestamp,a.duration,n)}addAudioChunkRaw(a,n,t,o,i){if(!(a instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(o)||o<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(qe(this,$i,Vs).call(this),!X(this,Pe).audio)throw new Error("No audio track declared.");if(typeof X(this,Pe).fastStart=="object"&&X(this,Ft).samples.length===X(this,Pe).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${X(this,Pe).fastStart.expectedAudioChunks}).`);let r=qe(this,Fi,Cs).call(this,X(this,Ft),a,n,t,o,i);if(X(this,Pe).fastStart==="fragmented"&&X(this,Ot)){for(;X(this,ya).length>0&&X(this,ya)[0].decodeTimestamp<=r.decodeTimestamp;){let s=X(this,ya).shift();qe(this,Fn,Wn).call(this,X(this,Ot),s)}r.decodeTimestamp<=X(this,Ot).lastDecodeTimestamp?qe(this,Fn,Wn).call(this,X(this,Ft),r):X(this,ba).push(r)}else qe(this,Fn,Wn).call(this,X(this,Ft),r)}finalize(){if(X(this,Do))throw new Error("Cannot finalize a muxer more than once.");if(X(this,Pe).fastStart==="fragmented"){for(let n of X(this,ya))qe(this,Fn,Wn).call(this,X(this,Ot),n);for(let n of X(this,ba))qe(this,Fn,Wn).call(this,X(this,Ft),n);qe(this,Gi,yl).call(this,!1)}else X(this,Ot)&&qe(this,Ro,Xi).call(this,X(this,Ot)),X(this,Ft)&&qe(this,Ro,Xi).call(this,X(this,Ft));let a=[X(this,Ot),X(this,Ft)].filter(Boolean);if(X(this,Pe).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=Mi(a,X(this,Xa)),r=X(this,Ue).measureBox(i);n=X(this,Ue).measureBox(X(this,un));let s=X(this,Ue).pos+r+n;for(let l of X(this,Ga)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(X(this,un).largeSize=!0)}let t=Mi(a,X(this,Xa));X(this,Ue).writeBox(t),X(this,un).size=n,X(this,Ue).writeBox(X(this,un));for(let o of X(this,Ga))for(let i of o.samples)X(this,Ue).write(i.data),i.data=null}else if(X(this,Pe).fastStart==="fragmented"){let n=X(this,Ue).pos,t=J0(a);X(this,Ue).writeBox(t);let o=X(this,Ue).pos-n;X(this,Ue).seek(X(this,Ue).pos-4),X(this,Ue).writeU32(o)}else{let n=X(this,Ue).offsets.get(X(this,un)),t=X(this,Ue).pos-n;X(this,un).size=t,X(this,un).largeSize=t>=2**32,X(this,Ue).patchBox(X(this,un));let o=Mi(a,X(this,Xa));if(typeof X(this,Pe).fastStart=="object"){X(this,Ue).seek(X(this,Hi)),X(this,Ue).writeBox(o);let i=n-X(this,Ue).pos;X(this,Ue).writeBox(c0(i))}else X(this,Ue).writeBox(o)}qe(this,eo,Go).call(this),X(this,Ue).finalize(),$t(this,Do,!0)}};Pe=new WeakMap;Ue=new WeakMap;Hi=new WeakMap;un=new WeakMap;Ot=new WeakMap;Ft=new WeakMap;Xa=new WeakMap;Ga=new WeakMap;fl=new WeakMap;ya=new WeakMap;ba=new WeakMap;Do=new WeakMap;Es=new WeakSet;tu=function(a){if(typeof a!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(a.target instanceof or))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!sg.includes(a.video.codec))throw new TypeError(`Unsupported video codec: ${a.video.codec}`);if(!Number.isInteger(a.video.width)||a.video.width<=0)throw new TypeError(`Invalid video width: ${a.video.width}. Must be a positive integer.`);if(!Number.isInteger(a.video.height)||a.video.height<=0)throw new TypeError(`Invalid video height: ${a.video.height}. Must be a positive integer.`);const n=a.video.rotation;if(typeof n=="number"&&![0,90,180,270].includes(n))throw new TypeError(`Invalid video rotation: ${n}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(n)&&(n.length!==9||n.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${n.join()}`);if(a.video.frameRate!==void 0&&(!Number.isInteger(a.video.frameRate)||a.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${a.video.frameRate}. Must be a positive integer.`)}if(a.audio){if(!lg.includes(a.audio.codec))throw new TypeError(`Unsupported audio codec: ${a.audio.codec}`);if(!Number.isInteger(a.audio.numberOfChannels)||a.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${a.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(a.audio.sampleRate)||a.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${a.audio.sampleRate}. Must be a positive integer.`)}if(a.firstTimestampBehavior&&!dg.includes(a.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${a.firstTimestampBehavior}`);if(typeof a.fastStart=="object"){if(a.video){if(a.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(a.fastStart.expectedVideoChunks)||a.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(a.audio){if(a.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(a.fastStart.expectedAudioChunks)||a.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(a.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(a.minFragmentDuration!==void 0&&(!Number.isFinite(a.minFragmentDuration)||a.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};xs=new WeakSet;nu=function(){var a;if(X(this,Ue).writeBox(l0({holdsAvc:((a=X(this,Pe).video)==null?void 0:a.codec)==="avc",fragmented:X(this,Pe).fastStart==="fragmented"})),$t(this,Hi,X(this,Ue).pos),X(this,Pe).fastStart==="in-memory")$t(this,un,bs(!1));else if(X(this,Pe).fastStart!=="fragmented"){if(typeof X(this,Pe).fastStart=="object"){let n=qe(this,hl,au).call(this);X(this,Ue).seek(X(this,Ue).pos+n)}$t(this,un,bs(!0)),X(this,Ue).writeBox(X(this,un))}qe(this,eo,Go).call(this)};hl=new WeakSet;au=function(){if(typeof X(this,Pe).fastStart!="object")return;let a=0,n=[X(this,Pe).fastStart.expectedVideoChunks,X(this,Pe).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};Ss=new WeakSet;ou=function(){if(X(this,Pe).video&&$t(this,Ot,{id:1,info:{type:"video",codec:X(this,Pe).video.codec,width:X(this,Pe).video.width,height:X(this,Pe).video.height,rotation:X(this,Pe).video.rotation??0,decoderConfig:null},timescale:X(this,Pe).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),X(this,Pe).audio&&($t(this,Ft,{id:X(this,Pe).video?2:1,info:{type:"audio",codec:X(this,Pe).audio.codec,numberOfChannels:X(this,Pe).audio.numberOfChannels,sampleRate:X(this,Pe).audio.sampleRate,decoderConfig:null},timescale:X(this,Pe).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),X(this,Pe).audio.codec==="aac")){let a=qe(this,vl,iu).call(this,2,X(this,Pe).audio.sampleRate,X(this,Pe).audio.numberOfChannels);X(this,Ft).info.decoderConfig={codec:X(this,Pe).audio.codec,description:a,numberOfChannels:X(this,Pe).audio.numberOfChannels,sampleRate:X(this,Pe).audio.sampleRate}}};vl=new WeakSet;iu=function(a,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=a.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=n.toString(2).padStart(24,"0")),s+=r.toString(2).padStart(4,"0");let l=Math.ceil(s.length/8)*8;s=s.padEnd(l,"0");let c=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)c[d/8]=parseInt(s.slice(d,d+8),2);return c};Fi=new WeakSet;Cs=function(a,n,t,o,i,r,s){let l=o/1e6,c=(o-(s??0))/1e6,d=i/1e6,u=qe(this,gl,ru).call(this,l,c,a);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:Rn(d,a.timescale)}};Fn=new WeakSet;Wn=function(a,n){X(this,Pe).fastStart!=="fragmented"&&a.samples.push(n);const t=Rn(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=Rn(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,X(this,Pe).fastStart!=="fragmented"){let s=ji(a.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,a.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=ji(a.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,X(this,Pe).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:Rn(n.duration,a.timescale)}),a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));a.lastSample=n;let o=!1;if(!a.currentChunk)o=!0;else{let i=n.presentationTimestamp-a.currentChunk.startTimestamp;if(X(this,Pe).fastStart==="fragmented"){let r=X(this,Ot)??X(this,Ft);const s=X(this,Pe).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,qe(this,Gi,yl).call(this))}else o=i>=.5}o&&(a.currentChunk&&qe(this,Ro,Xi).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};gl=new WeakSet;ru=function(a,n,t){var s,l;const o=X(this,Pe).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
19
|
-
|
|
20
|
-
If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
|
|
21
|
-
`);if(X(this,Pe).firstTimestampBehavior==="offset"||X(this,Pe).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;X(this,Pe).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=X(this,Ot))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=X(this,Ft))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,a-=c}if(n<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${n*1e6}).`);return t.lastDecodeTimestamp=n,{presentationTimestamp:a,decodeTimestamp:n}};Ro=new WeakSet;Xi=function(a){if(X(this,Pe).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),X(this,Ga).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||ji(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),X(this,Pe).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=X(this,Ue).pos;for(let n of a.currentChunk.samples)X(this,Ue).write(n.data),n.data=null;qe(this,eo,Go).call(this)}};Gi=new WeakSet;yl=function(a=!0){if(X(this,Pe).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[X(this,Ot),X(this,Ft)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=i0(this,fl)._++;if(t===1){let l=Mi(n,X(this,Xa),!0);X(this,Ue).writeBox(l)}let o=X(this,Ue).pos,i=fc(t,n);X(this,Ue).writeBox(i);{let l=bs(!1),c=0;for(let u of n)for(let f of u.currentChunk.samples)c+=f.size;let d=X(this,Ue).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=X(this,Ue).measureBox(l)+c),l.size=d,X(this,Ue).writeBox(l)}for(let l of n){l.currentChunk.offset=X(this,Ue).pos,l.currentChunk.moofOffset=o;for(let c of l.currentChunk.samples)X(this,Ue).write(c.data),c.data=null}let r=X(this,Ue).pos;X(this,Ue).seek(X(this,Ue).offsets.get(i));let s=fc(t,n);X(this,Ue).writeBox(s),X(this,Ue).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),X(this,Ga).push(l.currentChunk),l.currentChunk=null;a&&qe(this,eo,Go).call(this)};eo=new WeakSet;Go=function(){X(this,Ue)instanceof pl&&X(this,Ue).flush()};$i=new WeakSet;Vs=function(){if(X(this,Do))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const zo=30;class to extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);J(this,"message");J(this,"code");this.code=o,this.message=t}}class Hn extends to{}class Vt extends to{}class Ji extends to{}class hc extends to{}function ug(a,n=zo){if(n<1)throw new Vt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function Ja(a,n=zo){if(n<1)throw new Vt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class Me{constructor(n=0){J(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return ug(this.millis/1e3)}set frames(n){this.millis=Ja(n)}get seconds(){return this.millis/1e3}set seconds(n){this.millis=n*1e3}addMillis(n){return this.millis=this.millis+n,this}addFrames(n){const t=Ja(n);return this.millis=this.millis+t,this}add(n){return new Me(n.millis+this.millis)}subtract(n){return new Me(this.millis-n.millis)}static fromSeconds(n){const t=new Me;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new Me;return o.millis=Ja(n,t),o}copy(){return new Me(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new Me(n)}}function vc(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function Di(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function mg(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function gc(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function pg(a){const n=a.numberOfChannels,t=a.length,o=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=a.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*n+r]=s}return o}function fg(a,n=44100,t=2){if(a.sampleRate==n&&a.numberOfChannels==t)return a;const o=Math.floor(a.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,o,n);for(let r=0;r<a.numberOfChannels;r++){const s=a.getChannelData(r),l=i.getChannelData(r),c=a.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,f=Math.floor(u),p=Math.ceil(u);if(p>=s.length)l[d]=s[f];else{const m=u-f;l[d]=s[f]*(1-m)+s[p]*m}}}return i}async function hg(a){const{fps:n,height:t,width:o,bitrate:i}=a,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const d of r)for(const u of s)l.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const c=[];if(!("VideoEncoder"in window))return c;for(const d of l){const u=await VideoEncoder.isConfigSupported(d);u.supported&&c.push(u.config??d)}return c.sort(vg)}function vg(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function gg(a,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof a=="string"&&a.startsWith("data:image/svg+xml;base64,")){const o=a.split(",")[1],i=atob(o),r=new Array(i.length);for(let c=0;c<i.length;c++)r[c]=i.charCodeAt(c);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function yc(a){return`${a.hours.toString().padStart(2,"0")}:${a.minutes.toString().padStart(2,"0")}:${a.seconds.toString().padStart(2,"0")},`+a.milliseconds.toString().padStart(3,"0")}function bc(a){const n=new Date(1970,0,1);return n.setSeconds(a),n.setMilliseconds(Math.round(a%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class gi{constructor(n){J(this,"words",[]);n&&(this.words=n)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:n})=>n).join(" ")}get start(){var n;return((n=this.words.at(0))==null?void 0:n.start)??new Me}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new Me}}var Ns=(a=>(a.en="en",a.de="de",a))(Ns||{});class wc{constructor(n,t,o,i){J(this,"id",crypto.randomUUID());J(this,"text");J(this,"start");J(this,"stop");J(this,"confidence");this.text=n,this.start=new Me(t),this.stop=new Me(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class ka{constructor(n=[],t=Ns.en){J(this,"id",crypto.randomUUID());J(this,"language",Ns.en);J(this,"groups",[]);this.groups=n,this.language=t}get text(){return this.groups.map(({text:n})=>n).join(" ")}get words(){return this.groups.flatMap(({words:n})=>n)}*iter({count:n,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(n&&r.words.length>=Di(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=Di(...t)?(yield r,r=void 0):o&&r.text.length>=Di(...o)&&(yield r,r=void 0)),r?r.words.push(l):r=new gi([l]),s==i.words.length-1&&(yield r)}}optimize(){const n=this.groups.flatMap(t=>t.words);for(let t=0;t<n.length-1;t++){const o=n[t],i=n[t+1];i.start.millis-o.stop.millis<0?i.start.millis=o.stop.millis+1:o.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,o="";for(const i of this.iter(n)){const r=bc(i.start.seconds),s=bc(i.stop.seconds);o+=`${t}
|
|
22
|
-
`+yc(r)+" --> "+yc(s)+`
|
|
23
|
-
${i.text}
|
|
24
|
-
|
|
25
|
-
`,t+=1}return{text:o,blob:new Blob([o],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(n=>n.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(n,t=!0){let o=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(o=s.start.millis),i.push(new wc(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new ka([new gi(i)]);return new ka([new gi(i)])}copy(){return ka.fromJSON(this.toJSON())}static fromJSON(n){const t=new ka;for(const o of n){const i=new gi;for(const r of o)i.words.push(new wc(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const o=await fetch(n,t);if(!o.ok)throw new Hn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return ka.fromJSON(await o.json())}}function Ri(a,n,t){return a+(n-a)*t}function yg(a,n,t){const o=Number.parseInt(a.slice(1),16),i=Number.parseInt(n.slice(1),16),r=o>>16&255,s=o>>8&255,l=o&255,c=i>>16&255,d=i>>8&255,u=i&255,f=Math.round(Ri(r,c,t)),p=Math.round(Ri(s,d,t)),m=Math.round(Ri(l,u,t));return`#${((1<<24)+(f<<16)+(p<<8)+m).toString(16).slice(1)}`}const bg={linear:a=>a,easeIn:a=>a*a,easeOut:a=>a*(2-a),easeInOut:a=>a<.5?2*a*a:-1+(4-2*a)*a};class Ae{constructor(n,t,o={}){J(this,"input");J(this,"output");J(this,"options");if(n.length!==t.length)throw new Vt({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>Ja(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(n){const{input:t}=this;if(n<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(n-t[0])/(t[1]-t[0]),segment:0};if(n>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(n-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(n,t){const o=this.output[t],i=this.output[t+1],r=bg[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return Ri(o,i,r);if(typeof o=="string"&&typeof i=="string")return yg(o,i,r);if(this.output.length==1)return this.output[0];throw new Vt({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:o}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,o)}push(n,t){return this.input.push(Ja(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ae([],[]);return Object.assign(t,n),t}}class gn{constructor(){J(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(n.hasOwnProperty(o))if(i){const r=i.fromJSON(n[o]);t[o]=r}else t[o]=n[o]}),t}}function Ce(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function Jo(a){return class extends a{constructor(){super(...arguments);J(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 bl(a,n,t=0){if(!(a instanceof ct.Container||a instanceof ct.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Ae&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&bl(i,n,t+1))}}var wg=Object.defineProperty,ir=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&wg(n,t,i),i};const Ko=class lu extends Jo(gn){constructor(t={}){super();J(this,"_name");J(this,"_start",new Me);J(this,"_stop",Me.fromSeconds(16));J(this,"type","base");J(this,"source");J(this,"view",new ct.Container);J(this,"createdAt",new Date);J(this,"disabled",!1);J(this,"state","IDLE");J(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",Me.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=Me.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Vt({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Vt({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),bl(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 lu.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};ir([Ce()],Ko.prototype,"_name");ir([Ce(Me)],Ko.prototype,"_start");ir([Ce(Me)],Ko.prototype,"_stop");ir([Ce()],Ko.prototype,"disabled");let Yo=Ko;var kg=Object.defineProperty,Ia=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&kg(n,t,i),i};class Ln extends Jo(gn){constructor(){super(...arguments);J(this,"state","IDLE");J(this,"metadata");J(this,"objectURL");J(this,"duration",Me.fromSeconds(16));J(this,"added",!1);J(this,"type","base");J(this,"name","");J(this,"mimeType");J(this,"externalURL");J(this,"external",!1);J(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 Vt({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Is(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 Hn({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=Is(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();gg(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}Ia([Ce()],Ln.prototype,"objectURL");Ia([Ce()],Ln.prototype,"duration");Ia([Ce()],Ln.prototype,"type");Ia([Ce()],Ln.prototype,"name");Ia([Ce()],Ln.prototype,"mimeType");Ia([Ce()],Ln.prototype,"externalURL");Ia([Ce()],Ln.prototype,"external");const kc="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function _g(a){const n=new TextEncoder().encode(a);let t="";const o=n.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function _c(a){if(!a||!a.body)return kc;const n=a.body.scrollWidth,t=a.body.scrollHeight,o=a.cloneNode(!0),i=o.getElementsByTagName("style").item(0),r=o.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return kc;const s=new XMLSerializer,l=i?s.serializeToString(i):"",c=s.serializeToString(r),d=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${l}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${c}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+_g(d)}class Ec extends Ln{constructor(){super();J(this,"type","html");J(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=_c(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=_c(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 Eg(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),l=a.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let f=0;f<s.length;f+=o){let p=0;const m=Math.min(f+o,s.length);for(let h=f;h<m;h++)p+=s[h]*s[h];p=Math.sqrt(p/(m-f)),p<t?(u+=o,d===null&&(d=f)):(d!==null&&u>=c&&r.push({start:Me.fromSeconds(d/l),stop:Me.fromSeconds(f/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:Me.fromSeconds(d/l),stop:Me.fromSeconds(s.length/l)}),r}const Qr=3e3;class aa extends Ln{constructor(){super(...arguments);J(this,"type","audio");J(this,"decoding",!1);J(this,"_silences");J(this,"transcript");J(this,"audioBuffer")}async decode(t=2,o=48e3,i=!1){if(this.decoding&&i&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const r=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,o).decodeAudioData(r);return this.duration.seconds=s.duration,i&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,o=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/o),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let f=0;f<l;f+=c){let p=0;for(let m=f;m<f+s;m++)p+=Math.abs(d[f]);u.push(Math.log1p(p/s*100))}return u.map(f=>Math.round(f/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,Qr,!0),l=s.getChannelData(0),c=Math.floor(Math.max(o*Qr/1e3,0)),d=i?Math.floor(Math.min(i*Qr/1e3,s.length)):s.length,u=Math.floor((d-c)/t),f=new Float32Array(t);for(let p=0;p<t;p++){const m=c+p*u,h=m+u;let g=-1/0;for(let w=m;w<h;w++){const F=l[w];F>g&&(g=F)}f[p]=r?Math.log2(1+g):g}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=Eg(r,t),i.close(),this._silences}}class Ts extends Ln{constructor(){super(...arguments);J(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 _a extends aa{constructor(){super(...arguments);J(this,"type","video");J(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Hn({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=Is(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 Vt({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 xg{static fromJSON(n){return[new Me(n[0]),new Me(n[1])]}}var Sg=Object.defineProperty,Cg=Object.getOwnPropertyDescriptor,ao=(a,n,t,o)=>{for(var i=o>1?void 0:o?Cg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Sg(n,t,i),i};const Fa=class cu extends Yo{constructor(t={}){super();J(this,"source",new aa);J(this,"_offset",new Me);J(this,"playing",!1);J(this,"duration",new Me);J(this,"range",[new Me,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=Me.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=Me.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",Me.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 hc({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=Me.fromFrames(t)),typeof o=="number"&&(o=Me.fromFrames(o)),t.millis>=o.millis)throw new Vt({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=cu.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=Me.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Vt({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new hc({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),bl(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 Vt({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=>xc(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(!xc(s,l.range))continue;const c=new Me(Math.min(s.start.millis+i,s.stop.millis));if(s.start.millis>l.range[0].millis&&s.stop.millis<l.range[1].millis){const d=l.copy();l.range[1]=c,d.range[0]=s.stop,r.push(d)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=c)}return r}};ao([Ce(Me)],Fa.prototype,"_offset",2);ao([Ce(Me)],Fa.prototype,"duration",2);ao([Ce(xg)],Fa.prototype,"range",2);ao([Ce(ka)],Fa.prototype,"transcript",1);ao([Ce()],Fa.prototype,"muted",1);ao([Ce()],Fa.prototype,"volume",1);let rr=Fa;function xc(a,n){return a.start.millis>=n[0].millis&&a.start.millis<=n[1].millis||a.stop.millis<=n[1].millis&&a.stop.millis>=n[0].millis}class yi{static fromJSON(n){return typeof n=="object"?Ae.fromJSON(n):n}}class es{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ae.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ae.fromJSON(n.y)),n}}let Vg=class{constructor(a){J(this,"target");J(this,"animation");this.target=a}init(a,n,t=0,o){if(!(a in this.target))throw new Error(`Property [${String(a)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[a]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[a])),this.target[a]=this.animation=new Ae(i,r,{easing:o})}};function Ng(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Vt({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new Me(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(o,i,r,s),n)}});return n}class Tg extends Vg{}var Mg=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,ea=(a,n,t,o)=>{for(var i=o>1?void 0:o?Bg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Mg(n,t,i),i};function sr(a){class n extends a{constructor(){super(...arguments);J(this,"filters");J(this,"_height");J(this,"_width");J(this,"_position",{x:this.view.position.x,y:this.view.position.y});J(this,"_scale");J(this,"rotation",this.view.angle);J(this,"alpha",1);J(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 Ae||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 ct.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 ct.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 Ng(new Tg(this))}}return ea([Ce(yi)],n.prototype,"_height",2),ea([Ce(yi)],n.prototype,"_width",2),ea([Ce(es)],n.prototype,"_position",2),ea([Ce(es)],n.prototype,"_scale",2),ea([Ce(yi)],n.prototype,"rotation",2),ea([Ce(yi)],n.prototype,"alpha",2),ea([Ce(es)],n.prototype,"translate",2),ea([Ce()],n.prototype,"anchor",1),n}function lr(a,n,t){const o=t.value;return t.value=function(...i){var f,p,m,h;const r=i[0].subtract(this.start),s={width:((p=(f=this.track)==null?void 0:f.composition)==null?void 0:p.width)??1920,height:((h=(m=this.track)==null?void 0:m.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 c;typeof this.translate.y=="number"?c=this.translate.y:typeof this.translate.y=="function"?c=this.translate.y.bind(this)(r):c=this.translate.y.value(r);let d;typeof this._position.x=="number"?d=this._position.x:typeof this._position.x=="string"?d=Number.parseFloat(this._position.x)*s.width/100:typeof this._position.x=="function"?d=this._position.x.bind(this)(r):d=this._position.x.value(r);let u;if(typeof this._position.y=="number"?u=this._position.y:typeof this._position.y=="string"?u=Number.parseFloat(this._position.y)*s.height/100:typeof this._position.y=="function"?u=this._position.y.bind(this)(r):u=this._position.y.value(r),this.view.position.set(d+l,u+c),typeof this._height=="string"?this.view.height=Math.round(Number.parseFloat(this._height)*s.height/100):typeof this._height=="object"?this.view.height=this._height.value(r):typeof this._height=="function"?this.view.height=this._height.bind(this)(r):this._height&&(this.view.height=this._height),this._height&&!this._width&&this.view.scale.set(this.view.scale.y),typeof this._width=="string"?this.view.width=Math.round(Number.parseFloat(this._width)*s.width/100):typeof this._width=="object"?this.view.width=this._width.value(r):typeof this._width=="function"?this.view.width=this._width.bind(this)(r):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let g;typeof this._scale.x=="number"?g=this._scale.x:typeof this._scale.x=="function"?g=this._scale.x.bind(this)(r):g=this._scale.x.value(r);let w;typeof this._scale.y=="number"?w=this._scale.y:typeof this._scale.y=="function"?w=this._scale.y.bind(this)(r):w=this._scale.y.value(r),(this._width||this._height)&&(g*=this.view.scale._x,w*=this.view.scale._y),this.view.scale.set(g,w)}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 Ig=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,$g=(a,n,t,o)=>{for(var i=Fg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ig(n,t,i),i};const du=class uu extends sr(Yo){constructor(t,o={}){super();J(this,"type","image");J(this,"element",new Image);J(this,"source",new Ts);J(this,"sprite",new ct.Sprite);this.view.addChild(this.sprite),t instanceof Ts&&(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=ct.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Hn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=uu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};$g([lr],du.prototype,"update");let Dg=du;const bi={"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 Rg=Object.defineProperty,cr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Rg(n,t,i),i};const qo=class Ms extends Jo(gn){constructor(t){super();J(this,"loaded",!1);J(this,"family");J(this,"weight");J(this,"source");J(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=Ms.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(bi).map(t=>({family:t,variants:bi[t].weights.map(o=>({family:t,source:`url(${bi[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new Ms({family:t,source:`url(${bi[t].url})`,weight:o})}};cr([Ce()],qo.prototype,"family");cr([Ce()],qo.prototype,"weight");cr([Ce()],qo.prototype,"source");cr([Ce()],qo.prototype,"style");let Zt=qo;const Dn=4,mu={center:.5,justify:.5,left:0,right:1},pu={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Ag=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,an=(a,n,t,o)=>{for(var i=Lg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ag(n,t,i),i};const Kt=class fu extends sr(Yo){constructor(t){super();J(this,"type","text");J(this,"_text","");J(this,"_textCase");J(this,"_anchor",{x:0,y:0});J(this,"_font",new Zt);J(this,"style",new ct.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 ct.Text({text:this.transformedText,style:this.style,resolution:Dn,scale:Dn});this.view.addChild(o)}this.view.children[0]instanceof ct.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*Dn}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Dn):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=mu[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=pu[t]}get fillStyle(){const{fill:t}=this.style;return new ct.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 ct.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 ct.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 ct.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=fu.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)*Dn;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};an([Ce()],Kt.prototype,"text");an([Ce(Zt)],Kt.prototype,"font");an([Ce()],Kt.prototype,"maxWidth");an([Ce()],Kt.prototype,"textAlign");an([Ce()],Kt.prototype,"padding");an([Ce()],Kt.prototype,"textBaseline");an([Ce()],Kt.prototype,"fillStyle");an([Ce()],Kt.prototype,"anchor");an([Ce()],Kt.prototype,"stroke");an([Ce()],Kt.prototype,"textCase");an([Ce()],Kt.prototype,"shadow");an([Ce()],Kt.prototype,"fontSize");an([Ce()],Kt.prototype,"leading");an([lr],Kt.prototype,"update");let oo=Kt;function ts(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Pg={get(a,n){const t=a[n];return typeof t=="number"?t*Dn:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*Dn):t}};function Og(a){return new Proxy(a,Pg)}class Ug{constructor(){J(this,"tokens",[])}get width(){return this.tokens.reduce((n,t)=>n+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(n=>n.metrics.lineHeight))}}class Sc{constructor(){J(this,"lines",[])}get width(){return Math.max(...this.lines.map(n=>n.width))}get height(){return this.lines.reduce((n,t)=>n+t.height,0)}}class zg{static fromJSON(n){return n.map(t=>(t.font&&(t.font=Zt.fromJSON(t.font)),t))}}var jg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,io=(a,n,t,o)=>{for(var i=o>1?void 0:o?Wg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&jg(n,t,i),i};const $a=class hu extends oo{constructor(t){super();J(this,"type","complex_text");J(this,"_maxWidth");J(this,"_textAlign","left");J(this,"_textBaseline","top");J(this,"model",new ct.Container);J(this,"segments",[]);J(this,"metrics",new Sc);J(this,"background");J(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=mu[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=pu[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=hu.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:ts(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:ts(o.substring(t[l].start,t[l].stop))}),!((t[l].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:ts(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 Sc;for(const c of t){const d=c.index!=null?o[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const f=Og(ct.CanvasTextMetrics.measureText(c.tokens[u],d)),p=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+f.lineWidths[0],m=this.maxWidth??Number.POSITIVE_INFINITY,h=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(p>m||h||!i.lines.length)&&i.lines.push(new Ug),this.model.addChild(new ct.Text({text:c.tokens[u],style:d,resolution:Dn,scale:Dn})),(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,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((l=this.background.padding)==null?void 0:l.x)??40,r=((c=this.background.padding)==null?void 0:c.y)??10,s=new ct.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)*Dn;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};io([Ce()],$a.prototype,"background",2);io([Ce(zg)],$a.prototype,"styles",2);io([Ce()],$a.prototype,"text",1);io([Ce()],$a.prototype,"maxWidth",1);io([Ce()],$a.prototype,"textAlign",1);io([Ce()],$a.prototype,"textBaseline",1);let dr=$a;const vu="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Zg=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),Cc=typeof self<"u"&&self.Blob&&new Blob([Zg(vu)],{type:"text/javascript;charset=utf-8"});function Hg(a){let n;try{if(n=Cc&&(self.URL||self.webkitURL).createObjectURL(Cc),!n)throw"";const t=new Worker(n,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+vu,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class Xg{constructor(){J(this,"frames",[]);J(this,"state","active");J(this,"onenqueue");J(this,"onclose")}enqueue(n){var t;this.frames.unshift(n),(t=this.onenqueue)==null||t.call(this)}async dequeue(){if(this.frames.length==0&&this.state=="active"&&await this.waitFor(2e4),!(this.frames.length==0&&this.state=="closed"))return this.frames.pop()}close(){var n;this.state="closed",(n=this.onclose)==null||n.call(this)}terminate(){for(const n of this.frames)n.close()}async waitFor(n){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function Gg(a,n,t){const o=t.value;return t.value=function(...i){var r,s,l,c;return(s=(r=this.track)==null?void 0:r.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var Jg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,Yg=(a,n,t,o)=>{for(var i=Kg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Jg(n,t,i),i};const gu=class yu extends sr(rr){constructor(t,o={}){super();J(this,"source",new _a);J(this,"type","video");J(this,"worker");J(this,"buffer");J(this,"canvas",document.createElement("canvas"));J(this,"context",this.canvas.getContext("2d"));J(this,"element",document.createElement("video"));J(this,"textrues",{html5:ct.Texture.from(this.element),canvas:ct.Texture.from(this.canvas)});J(this,"sprite",new ct.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 _a&&(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 Hn({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(Me.fromFrames(o))}enter(){var t,o,i;super.enter(),(o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var o,i,r,s,l,c;if((i=(o=this.track)==null?void 0:o.composition)!=null&&i.playing&&!this.playing)this.element.play();else if(!((s=(r=this.track)==null?void 0:r.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=yu.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 Xg,this.worker=new Hg,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)??zo}),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}};Yg([lr,Gg],gu.prototype,"update");let Bs=gu;class Ao extends rr{constructor(t,o={}){super();J(this,"type","audio");J(this,"source",new aa);J(this,"element",new Audio);t instanceof aa&&(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 Hn({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=Ao.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const qg={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 Is(a){if(!Object.keys(qg.MIXED).includes(a??""))throw new Vt({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var Qg=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,ty=(a,n,t,o)=>{for(var i=ey(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Qg(n,t,i),i};const ny=class bu extends sr(Yo){constructor(t,o={}){super();J(this,"type","html");J(this,"source",new Ec);J(this,"element",new Image);J(this,"canvas",document.createElement("canvas"));J(this,"context",this.canvas.getContext("2d"));J(this,"sprite",new ct.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof Ec&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;!i||!r||(this.canvas.width=i,this.canvas.height=r,this.context.imageSmoothingEnabled=!1,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(this.element,0,0),this.sprite.texture=ct.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Hn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new Hn({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Hn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=bu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};ty([lr],ny.prototype,"update");const wu=["DEFAULT","STACK"];class Vc{constructor(){J(this,"mode",wu[0]);J(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=Mc(n,t.clips[i]),!!o);i++)Tc(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(Nc))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Nc);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!Mc(n,t.clips[o]))break;Tc(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class ay{constructor(){J(this,"mode",wu[1])}add(n,t,o=void 0){var r;let i=-1;(o!=null&&o>0||o==null)&&(i=((r=t.clips.at((o??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new Me(i-n.start.millis+1)),o==null?t.clips.push(n):(t.clips.splice(o,0,n),t.clips.slice(o+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new Me(r))}o=i.stop.millis+1}}offset(){}}function Nc(a,n){return a.start.millis-n.start.millis}function Tc(a,n){a.start.millis>=n.start.millis&&a.start.millis<=n.stop.millis&&(a.start=n.stop.copy().addMillis(1)),a.stop.millis>=n.start.millis&&a.stop.millis<=n.stop.millis&&(a.stop=n.start.copy().addMillis(-1))}function Mc(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const l=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(c=>c.type==a.type&&!c.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return l?(l.add(a.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(a.type))==null||s.add(a.detach()),!1)}return!0}class ro extends Jo(gn){constructor(){super(...arguments);J(this,"_disabled",!1);J(this,"view",new ct.Container);J(this,"clips",[]);J(this,"pointer",0);J(this,"composition");J(this,"type","base");J(this,"strategy",new Vc)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&as(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 ay,this.strategy.update(new Yo,this)):this.strategy=new Vc,this.trigger("update",void 0),this}layer(t){var l,c;const o=((l=this.composition)==null?void 0:l.tracks)??[],i=o.findIndex(d=>d.id==this.id),r=o.length-1;if(i==-1)return this;let s=0;return t=="bottom"?s=r:t=="top"||t<0?s=0:t>r?s=r:s=t,mg(o,i,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(Me.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(as(this.clipRef)&&(!ns(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!ns(o,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(ns(o,c)&&!c.disabled)return this.pointer=l,as(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(o<c.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,o){return this.composition&&!this.composition.renderer&&await new Promise(this.composition.resolve("init")),await t.init(),await t.connect(this),await this.strategy.add(t,this,o),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const o=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),o!=null&&o>=0)return this.clips.splice(o,1),this.strategy.update(t,this),this.trigger("detach",void 0),t.off("*"),t}get stop(){var t;return((t=this.clips.at(-1))==null?void 0:t.stop)??new Me}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new Me}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 ns(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function as(a){return a?!!a.view.parent:!1}class oy{static fromType(n){switch(n.type){case"video":return new iy;case"audio":return new sy;case"html":return new ly;case"image":return new ry;case"text":return new Bc;case"complex_text":return new Bc;case"caption":return new dy;default:return new ro}}}class ku extends ro{constructor(){super(...arguments);J(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 iy extends ku{constructor(){super(...arguments);J(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class ry extends ro{constructor(){super(...arguments);J(this,"type","image")}}class sy extends ku{constructor(){super(...arguments);J(this,"type","audio")}}class Bc extends ro{constructor(){super(...arguments);J(this,"type","text")}}class ly extends ro{constructor(){super(...arguments);J(this,"type","html")}}var cy=Object.defineProperty,wl=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&cy(n,t,i),i};class Qo extends gn{constructor(t={}){super();J(this,"generatorOptions");J(this,"type","CLASSIC");J(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 Vt({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 Me,i=await Zt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new oo({text:c.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:i,stroke:{color:"#000000",width:4,join:"round"},maxWidth:t.composition.width*.85,shadow:{color:"#000000",blur:0,distance:1.1,angle:Math.PI*.4,alpha:1},position:this.position,stop:c.stop.add(o),start:c.start.add(o),scale:new Ae([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ae([0,4],[0,1],{easing:"easeOut"})}))}}wl([Ce()],Qo.prototype,"generatorOptions");wl([Ce()],Qo.prototype,"type");wl([Ce()],Qo.prototype,"position");class dy extends ro{constructor(){super(...arguments);J(this,"clip");J(this,"type","caption");J(this,"preset",new Qo)}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 uy=Object.defineProperty,ur=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&uy(n,t,i),i};class ei extends gn{constructor(t={}){super();J(this,"generatorOptions");J(this,"type","SPOTLIGHT");J(this,"color");J(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 Vt({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 Me,i=await Zt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new dr({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:i,stroke:{width:5,color:"#000000"},shadow:{color:"#000000",blur:12,alpha:.7,angle:Math.PI/4,distance:2},position:this.position,styles:[{fillStyle:this.color}],segments:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}ur([Ce()],ei.prototype,"generatorOptions");ur([Ce()],ei.prototype,"type");ur([Ce()],ei.prototype,"color");ur([Ce()],ei.prototype,"position");var my=Object.defineProperty,kl=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&my(n,t,i),i};class mr extends gn{constructor(t={}){super();J(this,"type","GUINEA");J(this,"colors");J(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l,c,d,u,f;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Vt({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 Me,i=await Zt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const p of t.clip.transcript.iter({length:[18]})){const{segments:m,words:h}=this.splitSequence(p);for(let g=0;g<p.words.length;g++){const w=(d=(c=h[g])==null?void 0:c.at(0))==null?void 0:d.start,F=(f=(u=h[g])==null?void 0:u.at(-1))==null?void 0:f.stop;!w||!F||await t.add(new dr({text:m.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:F.add(o),start:w.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:Di(0,2),start:m.slice(0,g).join(" ").length,stop:m.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(o[c].match(/ /)){r=c;break}if(o[d].match(/ /)){r=d;break}}const s=[...vc(o,r).map(c=>c.trim())],l=vc(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}kl([Ce()],mr.prototype,"type");kl([Ce()],mr.prototype,"colors");kl([Ce()],mr.prototype,"position");var py=Object.defineProperty,_l=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&py(n,t,i),i};class pr extends gn{constructor(t={}){super();J(this,"generatorOptions");J(this,"type","CASCADE");J(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 Vt({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 Me,i=await Zt.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(f=>f.text).slice(0,d+1).join(" ");await t.add(new oo({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:i,maxWidth:t.composition.width*.7,stroke:{color:"#000000",width:4,join:"round"},shadow:{color:"#000000",blur:8,alpha:.4,angle:Math.PI/4,distance:2},position:this.position,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}_l([Ce()],pr.prototype,"generatorOptions");_l([Ce()],pr.prototype,"type");_l([Ce()],pr.prototype,"position");var fy=Object.defineProperty,El=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&fy(n,t,i),i};class fr extends gn{constructor(t={}){super();J(this,"generatorOptions");J(this,"type","SOLAR");J(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,c;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new Vt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await Zt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new Me,r=new Zp.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new oo({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:o,maxWidth:t.composition.width*.85,textCase:"upper",shadow:{color:"#ab7a00",blur:0,distance:2.1,angle:Math.PI/2.5,alpha:1},position:this.position,stop:d.stop.add(i),start:d.start.add(i),scale:new Ae([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ae([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}El([Ce()],fr.prototype,"generatorOptions");El([Ce()],fr.prototype,"type");El([Ce()],fr.prototype,"position");var hy=Object.defineProperty,hr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&hy(n,t,i),i};class ti extends gn{constructor(t={}){super();J(this,"generatorOptions");J(this,"type","WHISPER");J(this,"color");J(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 Vt({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 Me,i=await Zt.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new dr({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:13,background:{alpha:.3,padding:{x:50,y:30}},maxWidth:t.composition.width*.8,font:i,position:this.position,styles:[{fillStyle:this.color}],stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}hr([Ce()],ti.prototype,"generatorOptions");hr([Ce()],ti.prototype,"type");hr([Ce()],ti.prototype,"color");hr([Ce()],ti.prototype,"position");var vy=Object.defineProperty,vr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&vy(n,t,i),i};class gr extends gn{constructor(t={}){super();J(this,"type","VERDANT");J(this,"generatorOptions");J(this,"color");J(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 Vt({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 Me,i=await Zt.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new dr({text:u.join(" "),textAlign:"center",textBaseline:"middle",fontSize:15,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:4,alpha:.7,angle:Math.PI/4,distance:2},stroke:{width:3,color:"#000000"},maxWidth:t.composition.width*.5,leading:1.1,font:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}vr([Ce()],gr.prototype,"type");vr([Ce()],gr.prototype,"generatorOptions");vr([Ce()],gr.prototype,"color");vr([Ce()],gr.prototype,"position");class gy extends Jo(gn){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();J(this,"_duration",new Me);J(this,"renderer");J(this,"stage",new ct.Container);J(this,"settings");J(this,"tracks",[]);J(this,"frame",0);J(this,"fixedDuration");J(this,"state","IDLE");J(this,"fps",zo);J(this,"canvas");J(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)),ct.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new to({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 Me?this.fixedDuration=t:this.fixedDuration=Me.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=oy.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 gc(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;gc(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(Me.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 to({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(Me.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(Me.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(rr)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*r.sampleRate),d=Math.round(l.range[0].seconds*r.sampleRate),u=Math.round(l.range[1].seconds*r.sampleRate);try{const f=await l.source.decode(t,o),p=f.numberOfChannels-1;for(let m=0;m<t;m++){const h=r.getChannelData(m),g=f.getChannelData(m>p?p:m);for(let w=0;w<h.length-1;w++)w<c+d||w>c+u||w-c<0||(h[w]+=(g[w-c]??0)*l.volume,h[w]>1&&(h[w]=1),h[w]<-1&&(h[w]=-1));r.getChannelData(m).set(h)}}catch{}}return r}time(t){const o=Ja(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/zo;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 yy(a,n){const t=new Uint8Array(19);return t[0]=79,t[1]=112,t[2]=117,t[3]=115,t[4]=72,t[5]=101,t[6]=97,t[7]=100,t[8]=1,t[9]=n,t[10]=0,t[11]=0,t[12]=a&255,t[13]=a>>8&255,t[14]=a>>16&255,t[15]=a>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Fs=[8e3,12e3,16e3,24e3,48e3],by="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",wy="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class ky{constructor(n){J(this,"output");J(this,"error");J(this,"config");J(this,"encoder");J(this,"opus");J(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(wy),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Fs.includes(i))throw new Ji({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Fs.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?by:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:yy(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new Ji({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let l=0;const c=s/i*1e6;for(;l<t;){const d=n.subarray(l*r,(l+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const f=4e3,p=this.opus._malloc(f),m=this.opus._opus_encode(this.encoder,u,s,p,f);if(m>0){const h=new Uint8Array(this.opus.HEAPU8.subarray(p,p+m));this.output({data:h,timestamp:o,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(p),l+=s,o+=c}}}function _y(a){const n=Fs;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class Ey{constructor(n,t){J(this,"canvas");J(this,"muxer");J(this,"videoEncoder");J(this,"frame",0);J(this,"sampleRate");J(this,"numberOfChannels");J(this,"videoBitrate");J(this,"gpuBatchSize");J(this,"fps");J(this,"height");J(this,"width");J(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=_y((t==null?void 0:t.sampleRate)??48e3),this.numberOfChannels=(t==null?void 0:t.numberOfChannels)??2,this.videoBitrate=(t==null?void 0:t.videoBitrate)??1e7,this.gpuBatchSize=(t==null?void 0:t.gpuBatchSize)??5,this.audio=(t==null?void 0:t.audio)??!1}async init(){const n=await hg({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new su({target:new dl,video:{...n[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(o,i)=>{i&&this.muxer.addVideoChunk(o,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var o;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(n??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(o=this.videoEncoder)==null||o.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new Ji({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=fg(n,this.sampleRate,this.numberOfChannels),o=new ky({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:pg(t),numberOfFrames:t.length})}async blob(){var t,o,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(o=this.muxer)==null||o.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new Ji({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([n],{type:"video/mp4"})}async export(){return this.blob()}}async function xy(a){var o,i;const n=(o=a.metadata)==null?void 0:o.source_url;if(n)return n;const t=(i=a.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}const Oo=class Oo{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",l=this.findTrackForClip(n),c=this.findTrackForClip(t);if(!l||!c)throw new Error("Clips must be added to composition before applying transitions");const d=n.stop.frames-r,u=n.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(n,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(n,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(n,t,o.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,o.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,o.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,o.type,d,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Ae([o,i],[1,0],{easing:r}),t.alpha=new Ae([o,i],[0,1],{easing:r}),t.start=Me.fromFrames(o)}async applyCrossFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Ae([o,i],[1,0],{easing:r}),t.alpha=new Ae([o,i],[0,1],{easing:r}),t.start=Me.fromFrames(o)}async applyWipeTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"wipe-left":l.x=new Ae([i,r],[0,-1920],{easing:s}),c.x=new Ae([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Ae([i,r],[0,1920],{easing:s}),c.x=new Ae([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Ae([i,r],[0,-1080],{easing:s}),c.y=new Ae([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Ae([i,r],[0,1080],{easing:s}),c.y=new Ae([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=Me.fromFrames(i)}async applySlideTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"slide-left":l.x=new Ae([i,r],[0,-1920],{easing:s}),c.x=new Ae([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Ae([i,r],[0,1920],{easing:s}),c.x=new Ae([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Ae([i,r],[0,-1080],{easing:s}),c.y=new Ae([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Ae([i,r],[0,1080],{easing:s}),c.y=new Ae([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=Me.fromFrames(i)}async applyZoomTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(n.scale=new Ae([i,r],[1,2],{easing:s}),n.alpha=new Ae([i,r],[1,0],{easing:s}),t.scale=new Ae([i,r],[.5,1],{easing:s}),t.alpha=new Ae([i,r],[0,1],{easing:s})):(n.scale=new Ae([i,r],[1,.5],{easing:s}),n.alpha=new Ae([i,r],[1,0],{easing:s}),t.scale=new Ae([i,r],[2,1],{easing:s}),t.alpha=new Ae([i,r],[0,1],{easing:s})),t.start=Me.fromFrames(i)}async applyDipTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((i+r)/2),c=o==="dip-to-black"?"#000000":"#ffffff",d=await Ts.fromColor(c),u=new Dg(d,{start:Me.fromFrames(i),stop:Me.fromFrames(r)});n.alpha=new Ae([i,l],[1,0],{easing:s}),u.alpha=new Ae([i,l,r],[0,1,0],{easing:s}),t.alpha=new Ae([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=Me.fromFrames(l)}findTrackForClip(n){for(const t of this.composition.tracks)if(t.clips.includes(n))return t}removeTransition(n){this.transitions.delete(n)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...Oo.TRANSITIONS]}static previewTransition(n){return Oo.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};Oo.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 jo=Oo;function kn(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function wi(a){return a>5?a/100:a}function _n(a,n,t){return Math.min(t,Math.max(n,a))}function en(){return new Ct.ColorMatrixFilter}function Sy(a,n){switch(a){case"brightness":{const t=en(),o=kn(n.value??n.brightness,1);return t.brightness(_n(wi(o),0,5),!1),t}case"contrast":{const t=en(),o=kn(n.value??n.contrast,1);return t.contrast(_n(wi(o),0,5),!1),t}case"saturation":{const t=en(),o=kn(n.value??n.saturation,1);return t.saturate(_n(wi(o),0,5),!1),t}case"hue":{const t=en(),o=kn(n.degrees??n.value,0);return t.hue(_n(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=kn(n.radius??n.blur??n.value,t);return new Ct.BlurFilter({strength:_n(o,0,32),quality:4})}case"grayscale":{const t=en(),o=_n(kn(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(_n(kn(n.amount,100),0,100)<=0)return null;const o=en();return o.sepia(!1),o}case"invert":{if(_n(kn(n.amount,100),0,100)<=0)return null;const o=en();return o.negative(!1),o}case"warmth":{const t=en(),o=_n(kn(n.value,0),-50,50);return o>0?(t.sepia(!1),t.saturate(1+o/100,!1)):o<0&&t.hue(Math.abs(o)/50*-20,!1),t}case"tint":{const t=en(),o=_n(kn(n.intensity,.3),0,1),i=typeof n.color=="string"?n.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,l=parseInt(r.slice(2,4),16)/255,c=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=en();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=en(),o=_n(wi(kn(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=en();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=en();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=en();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=Ct);class _u{constructor(n=1920,t=1080,o=30,i){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=o,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new gy({width:n,height:t,background:"#000000"}),this.initPromise=new Promise(r=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),r()};this.composition.on("init",s),queueMicrotask(()=>{var c,d,u,f;const l=this.composition;((d=(c=l==null?void 0:l.app)==null?void 0:c.renderer)!=null&&d.view||(u=l==null?void 0:l.renderer)!=null&&u.view||(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(...n){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await xy(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);n.transitions&&n.transitions.length>0&&await this.applyTransitionsToClips(n.transitions),this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async applyTransitionsToClips(n){const t=new jo(this.composition);for(const o of n){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(n){switch(n){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(n){switch(n){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}}async addTimelineClip(n,t){var o,i;try{const r=n.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((o=_a.from)==null?void 0:o.call(_a,r,{crossOrigin:"anonymous"}))??await _a.from(r),l=new Bs(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let c=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const p=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),m=n.sourceOut!==void 0?Math.max(p+1,Math.floor(n.sourceOut*this.fps)):null;c=p,d=m;try{if(l.offset=l.offset||{frames:0},l.offset.frames=p,m!==null){const h=Math.max(1,m-p);l.duration=l.duration||{frames:h},l.duration.frames=h}}catch{}}const u=await this.composition.add(l);if(d!==null&&c>=0)try{const p=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:p},u.duration.frames=p}catch{}const f=Math.floor(n.timelineStart*this.fps);f>0&&u.offsetBy(f),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(p=>requestAnimationFrame(p)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=Zt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new oo({text:n.content,font:t,fontSize:n.fontSize||34,position:n.position||"center",fillStyle:n.color||"#FFFFFF",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"});if(n.animation){const r=n.animation.duration||1,s=0,l=r*this.fps,c=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Ae([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Ae([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}n.startTime&&n.startTime>0&&o.offsetBy(n.startTime*this.fps),n.duration&&o.subclip(0,n.duration*this.fps);const i=await this.composition.add(o);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(c=>c.id));for(const[c,d]of i.entries())if(!r.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=i.get(c.id);let f=null;if(u&&u.signature===d)f=u.instance;else{if(u)try{u.instance.destroy()}catch{}f=this.createPixiFilter(c),f?i.set(c.id,{instance:f,signature:d}):i.delete(c.id)}f&&s.push(f)}this.filterCache.set(n,i);const l=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof o.enter=="function"&&o.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:n.filterId,intensity:n.intensity??1,params:o})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,o=n.params||{};if(pe.getFilter(n.filterId)&&!pe.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=rf(n.filterId,o);return r||(r=Sy(n.filterId,o)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!o.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(n={}){var s,l,c,d,u,f,p,m,h;const t=n.fps??this.fps,o=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((p=(f=this.composition)==null?void 0:f.renderer)==null?void 0:p.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(m=n.onProgress)==null||m.call(n,0);const i=new Ey(o,{fps:t});await i.init();const r=await i.export();return(h=n.onProgress)==null||h.call(n,100),r}destroy(){if(this.stopRenderLoop(),this.composition.pause(),this.clips.clear(),this.clipTimelineStart.clear(),this.filterCache.clear(),this.player&&this.composition.detachPlayer(this.player),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}this.player=null}startRenderLoop(){this.stopRenderLoop(),this.isDebug()&&this.dbg("renderLoop:start");const n=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(n)};n()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(n,t),this.composition.computeFrame())}setFitMode(n){this.fitMode=n,this.applyFitModeToClips()}applyFitModeToClips(){for(const n of this.clips.values())"scale"in n&&typeof n.scale<"u"&&this.applyFitToClip(n);this.composition.computeFrame()}applyFitToClip(n){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=n.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),c=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),f=this.fitMode==="contain"?d:u;n.scale=f}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),c=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=l+c;if(n>=l&&n<d){const u=n-l;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const Cy=["src"],Vy={class:"preview-controls"},Ny=["aria-label"],Ty={class:"time-display"},My={class:"current-time"},By={class:"total-time"},Iy={key:2,class:"loading-overlay"},Fy={key:3,class:"error-overlay"},$y=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),f=e.ref(0),p=e.ref(0);let m=null;const h=e.computed(()=>!!t.enableEngine&&!!t.recipe),g=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),w=e.computed(()=>{var _,R;return(_=t.media)!=null&&_.url?t.media.url:(((R=t.media)==null?void 0:R.file)instanceof File,"")});async function F(){var _,R,T;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const z=((_=t.recipe.source)==null?void 0:_.original_width)||1920,P=((R=t.recipe.source)==null?void 0:R.original_height)||1080,M=((T=t.recipe.output)==null?void 0:T.fps)||30;m=new _u(z,P,M,{fitMode:t.fitMode}),m.attachPlayer(r.value),c.value="Loading composition...",await m.loadFromRecipe(t.recipe),p.value=m.durationInSeconds,o("duration-change",p.value),D(),l.value=!1,o("engine-ready",m),t.autoPlay&&(m.play(),u.value=!0)}catch(z){const P=z instanceof Error?z.message:String(z);d.value=`Failed to initialize: ${P}`,l.value=!1}}function D(){if(!m)return;const _=setInterval(()=>{m&&u.value&&(f.value=m.currentTimeInSeconds,o("time-update",f.value))},100);j.value=_}function E(){h.value&&m?(u.value?m.pause():m.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 v(_){const R=Math.floor(_/60),T=Math.floor(_%60);return`${R}:${T.toString().padStart(2,"0")}`}function S(){d.value=null,h.value&&F()}function C(){!h.value&&s.value&&(p.value=s.value.duration,o("duration-change",p.value))}function V(){!h.value&&s.value&&(f.value=s.value.currentTime,o("time-update",f.value))}function x(){u.value=!1,o("play-state-change",!1)}function N(_){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{h.value&&t.recipe&&F()}),e.onUnmounted(()=>{m&&(m.destroy(),m=null),j.value&&(clearInterval(j.value),j.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async _=>{if(h.value&&_)if(_.timeline,m)try{await m.loadFromRecipe(_),p.value=m.durationInSeconds,o("duration-change",p.value)}catch{}else await F()}),e.watch(()=>t.enableEngine,async _=>{_?(await e.nextTick(),await F()):m&&(j.value&&(clearInterval(j.value),j.value=null),m.destroy(),m=null)}),e.watch(()=>t.fitMode,async _=>{if(!(!h.value||!m))try{m.setFitMode(_||"contain")}catch{}});const j=e.ref(null);return(_,R)=>(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:w.value,onLoadedmetadata:C,onTimeupdate:V,onEnded:x,onError:N,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,Cy)),e.createElementVNode("div",Vy,[e.createElementVNode("button",{class:"play-button",onClick:E,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.value?e.unref(Od):e.unref(Ud)},null,8,["icon"])],8,Ny),e.createElementVNode("div",Ty,[e.createElementVNode("span",My,e.toDisplayString(v(f.value)),1),R[0]||(R[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",By,e.toDisplayString(v(p.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Iy,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Fy,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ol)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:S},"Retry")])):e.createCommentVNode("",!0)],512))}}),$s=Ve($y,[["__scopeId","data-v-e199ac48"]]),Dy=["aria-label"],Ry=["aria-label"],Ay={class:"clip-content"},Ly={key:0,class:"clip-thumbnail"},Py=["src","alt"],Oy=["src"],Uy=["data-visual-mode"],zy={class:"clip-info"},jy={class:"clip-label"},Wy={class:"clip-duration"},Zy={key:3,class:"filter-indicators"},Hy={key:4,class:"speed-indicator"},Xy={key:0,class:"selection-overlay"},Gy=420,Jy=8,Ky=48,Yy=32,Ic=1,qy=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["select","long-press","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.ref(0),u=e.ref(0),f=e.ref(!1),p=e.ref(!1),m=e.ref(null),h=e.computed(()=>{const Z=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${Z}px`}}),g=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),w=e.computed(()=>{const B=t.clip.timelineEnd-t.clip.timelineStart;return V(B)}),F=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),D=e.computed(()=>t.clip.filters||[]),E=e.computed(()=>t.clip.waveformSamples??[]),v=e.computed(()=>t.clip.filmstripFrames??[]),S=e.computed(()=>E.value.length>0),C=e.computed(()=>v.value.length>0);function V(B){if(B<1)return`${Math.round(B*30)}f`;if(B<60)return`${B.toFixed(1)}s`;{const Z=Math.floor(B/60),ee=Math.floor(B%60);return`${Z}:${ee.toString().padStart(2,"0")}`}}function x(B){return!B||typeof B!="string"?uc:B.includes("color")||B.includes("brightness")?na:B.includes("blur")?Rf:B.includes("style")?Co:B.includes("effect")?ta:uc}function N(){r.value||o("select")}function j(B){B.button===0&&(T("move",B.clientX),B.preventDefault())}function _(B){if(B.touches.length!==1)return;const Z=B.touches[0];if(!t.isMobile){T("move",Z.clientX),B.preventDefault();return}d.value=Z.clientX,u.value=Z.clientY,f.value=!1,p.value=!1,z(),P(),m.value=window.setTimeout(()=>{p.value=!0,P(),t.selected||o("select"),o("long-press")},Gy),document.addEventListener("touchmove",M),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),B.preventDefault()}function R(B,Z){const ee="touches"in Z?Z.touches[0].clientX:Z.clientX;s.value=B==="start"?"trim-start":"trim-end",T(s.value,ee),Z.preventDefault(),Z.stopPropagation()}function T(B,Z){z(),P(),r.value=!0,s.value=B,l.value=Z,B==="move"?c.value=t.clip.timelineStart:B==="trim-start"?c.value=t.clip.sourceIn:B==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",k),document.addEventListener("mouseup",W),document.addEventListener("touchmove",O),document.addEventListener("touchend",W),t.selected||o("select")}function z(){m.value!==null&&(window.clearTimeout(m.value),m.value=null)}function P(){document.removeEventListener("touchmove",M),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L)}function M(B){if(B.touches.length!==1)return;const Z=B.touches[0],ee=Z.clientX-d.value,ne=Z.clientY-u.value;Math.hypot(ee,ne)<Jy||(f.value=!0,z(),P(),T("move",Z.clientX),k(B),B.preventDefault())}function L(){const B=!f.value&&!p.value&&!r.value;z(),P(),f.value=!1,p.value=!1,B&&o("select")}function k(B){if(!r.value||!s.value)return;const Z="touches"in B?B.touches[0].clientX:B.clientX,ne=Z-l.value;s.value==="move"?(o("drag",ne),o("drag-abs",Z)):s.value==="trim-start"?(o("trim-start",ne),o("trim-start-abs",Z)):s.value==="trim-end"&&(o("trim-end",ne),o("trim-end-abs",Z))}function O(B){k(B)}function W(){r.value=!1,s.value=null,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",W),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",W)}function G(){e.nextTick(()=>{we()})}function ie(B){var ge,Ne;const Z=Math.max(0,t.clip.timelineEnd-t.clip.timelineStart),ee=Math.max(1,Math.round(Z*t.scale)),ne=t.isMobile?Yy:Ky,de=Math.max(1,Math.round(B.clientWidth||((ge=B.parentElement)==null?void 0:ge.clientWidth)||ee)),ue=Math.max(1,Math.round(B.clientHeight||((Ne=B.parentElement)==null?void 0:Ne.clientHeight)||ne));return{width:de,height:ue}}function we(){if(C.value||!i.value)return;const B=i.value,Z=B.getContext("2d");if(!Z)return;const{width:ee,height:ne}=ie(B),de=window.devicePixelRatio||1;if(B.width=Math.max(1,Math.round(ee*de)),B.height=Math.max(1,Math.round(ne*de)),Z.setTransform(de,0,0,de,0,0),Z.clearRect(0,0,ee,ne),E.value.length>0){oe(Z,ee,ne,E.value);return}_e(Z,ee,ne)}function _e(B,Z,ee){const ne=ee/2;B.strokeStyle="rgba(255, 255, 255, 0.3)",B.lineWidth=1,B.beginPath(),B.moveTo(0,ne),B.lineTo(Z,ne);for(let de=0;de<Z;de+=4){const ue=Math.sin(de*.05)*(ee*.3);B.moveTo(de,ne-ue),B.lineTo(de,ne+ue)}B.stroke()}function oe(B,Z,ee,ne){const de=t.clip.sourceIn,ue=t.clip.sourceOut,ge=Math.max(.001,ue-de),Ne=ne.filter(Te=>Te.endTime>=de&&Te.time<=ue);if(Ne.length===0){_e(B,Z,ee);return}const fe=ee/2,me=ee*.44,Ee=ee*.32;B.fillStyle="rgba(255, 255, 255, 0.26)",Ne.forEach(Te=>{const dt=Math.max(Te.time,de),st=Math.min(Te.endTime,ue),Dt=(dt-de)/ge*Z,pt=Math.max(Ic,(st-dt)/ge*Z),ft=$(Te.rms)*Ee;B.fillRect(Dt,fe-ft,pt,ft*2)}),B.fillStyle="rgba(255, 255, 255, 0.72)",Ne.forEach(Te=>{const dt=Math.max(Te.time,de),st=Math.min(Te.endTime,ue),Dt=(dt-de)/ge*Z,pt=Math.max(Ic,(st-dt)/ge*Z),ft=$(Te.peak)*me;B.fillRect(Dt,fe-ft,pt,ft*2)})}function $(B){return Math.min(1,Math.max(0,B))}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],G,{deep:!0,flush:"post"}),e.onMounted(()=>{G(),window.addEventListener("resize",we)}),e.onUnmounted(()=>{W(),z(),P(),window.removeEventListener("resize",we)}),(B,Z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:B.selected,mobile:B.isMobile,"has-filters":F.value}]),style:e.normalizeStyle(h.value),onClick:N,onMousedown:j,onTouchstart:_},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:Z[0]||(Z[0]=e.withModifiers(ee=>R("start",ee),["stop"])),onTouchstart:Z[1]||(Z[1]=e.withModifiers(ee=>R("start",ee),["stop"])),"aria-label":`Trim start of ${B.clip.label||"clip"}`},[...Z[4]||(Z[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Dy),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:Z[2]||(Z[2]=e.withModifiers(ee=>R("end",ee),["stop"])),onTouchstart:Z[3]||(Z[3]=e.withModifiers(ee=>R("end",ee),["stop"])),"aria-label":`Trim end of ${B.clip.label||"clip"}`},[...Z[5]||(Z[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Ry),e.createElementVNode("div",Ay,[B.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Ly,[e.createElementVNode("img",{src:B.clip.thumbnail,alt:B.clip.label||"Video clip"},null,8,Py)])):e.createCommentVNode("",!0),C.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["clip-analysis-strip clip-filmstrip",{compact:B.isMobile}]),"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,ee=>(e.openBlock(),e.createElementBlock("img",{key:ee.id,class:"clip-filmstrip-frame",src:ee.uri,alt:"",draggable:"false"},null,8,Oy))),128))],2)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["clip-analysis-strip clip-waveform",{compact:B.isMobile}]),"data-visual-mode":S.value?"waveform":"placeholder","aria-hidden":"true"},[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)],10,Uy)),e.createElementVNode("div",zy,[e.createElementVNode("span",jy,e.toDisplayString(g.value),1),e.createElementVNode("span",Wy,e.toDisplayString(w.value),1)]),F.value?(e.openBlock(),e.createElementBlock("div",Zy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,ee=>(e.openBlock(),e.createBlock(e.unref(U.IonIcon),{key:ee.id||ee.filterId,icon:x(ee.filterId||ee.id),title:`Filter: ${ee.filterId||ee.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),B.clip.speed&&B.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Hy,e.toDisplayString(B.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),B.selected?(e.openBlock(),e.createElementBlock("div",Xy)):e.createCommentVNode("",!0)],38))}}),Fc=Ve(qy,[["__scopeId","data-v-b627d306"]]),Qy={class:"timeline-track-header__meta"},e1={class:"timeline-track-header__name"},t1={class:"timeline-track-header__type"},n1=["aria-label"],a1=["aria-pressed","aria-label"],o1=["aria-pressed","aria-label"],i1=["aria-pressed","aria-label"],r1=["aria-pressed","aria-label"],s1=e.defineComponent({__name:"TimelineTrackHeader",props:{track:{}},emits:["toggle-lock","toggle-hidden","toggle-muted","toggle-solo"],setup(a,{emit:n}){const t=n;return(o,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-track-header",{"is-hidden":o.track.hidden===!0}])},[e.createElementVNode("div",Qy,[e.createElementVNode("span",e1,e.toDisplayString(o.track.name),1),e.createElementVNode("span",t1,e.toDisplayString(o.track.type),1)]),e.createElementVNode("div",{class:"timeline-track-header__actions","aria-label":`Track controls for ${o.track.name}`},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.locked===!0}]),"aria-pressed":o.track.locked===!0,"aria-label":o.track.locked===!0?`Unlock ${o.track.name}`:`Lock ${o.track.name}`,title:"Lock",onClick:i[0]||(i[0]=r=>t("toggle-lock",o.track.id))}," Lock ",10,a1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.hidden===!0}]),"aria-pressed":o.track.hidden===!0,"aria-label":o.track.hidden===!0?`Show ${o.track.name}`:`Hide ${o.track.name}`,title:"Hide",onClick:i[1]||(i[1]=r=>t("toggle-hidden",o.track.id))}," Hide ",10,o1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.muted===!0}]),"aria-pressed":o.track.muted===!0,"aria-label":o.track.muted===!0?`Unmute ${o.track.name}`:`Mute ${o.track.name}`,title:"Mute",onClick:i[2]||(i[2]=r=>t("toggle-muted",o.track.id))}," Mute ",10,i1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.solo===!0}]),"aria-pressed":o.track.solo===!0,"aria-label":o.track.solo===!0?`Disable solo for ${o.track.name}`:`Solo ${o.track.name}`,title:"Solo",onClick:i[3]||(i[3]=r=>t("toggle-solo",o.track.id))}," Solo ",10,r1)],8,n1)],2))}}),l1=Ve(s1,[["__scopeId","data-v-e3a76d37"]]);class Eu{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Bs(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await _a.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=Me.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof Bs&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((l=i.source)==null?void 0:l.objectURL)||""))}),t}applyTransformations(n,t){(t.x!==void 0||t.y!==void 0)&&(n.x=t.x||0,n.y=t.y||0),t.rotation!==void 0&&(n.rotation=t.rotation),t.opacity!==void 0&&(n.alpha=t.opacity),t.scale!==void 0&&(n.scale={x:t.scale,y:t.scale})}secondsToFrames(n){return Math.round(n*this.fps)}framesToSeconds(n){return n/this.fps}framesToTime(n){const t=this.framesToSeconds(n),o=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),o=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return o}timeToFrames(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return this.secondsToFrames(o)}}const c1={class:"time-markers"},d1=["data-track-id"],u1=["data-track-id"],m1=["aria-label","title"],p1={key:0,class:"timeline-scrollbar"},$c=152,Dc=80,f1=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-move","clip-long-press","snap-state-change","toggle-frame-mode","toggle-lock","toggle-hidden","toggle-muted","toggle-solo"],setup(a,{expose:n,emit:t}){const o=a,i=e.computed(()=>o.isMobile===!0),r=t,s=e.ref(),l=e.ref(o.selectedClipId||null),c=e.ref(!1),d=e.ref(0),u=e.ref(),f=e.ref(0),p=e.computed(()=>o.selectedClipId??l.value);e.watch(()=>o.selectedClipId,Y=>{Y!==void 0&&(l.value=Y)});const m=new Eu(o.fps);e.watch(()=>o.fps,Y=>{m.setFps(Y)});const h=e.ref(!1),g=e.ref(null),w=e.ref(0),F=e.ref(0),D=e.ref(null),E=e.ref(0),v=e.ref(0),S=e.ref(0),C=e.ref(!1),V=e.ref(0),x=e.ref(o.zoomLevel),N=e.computed(()=>o.zoomLevel),j=e.computed(()=>o.tracks!==void 0&&o.tracks.length>0&&!i.value),_=e.computed(()=>j.value?$c:0),R=e.computed(()=>Math.max(0,oe.value-_.value));function T(Y){return Y.trackId??`legacy-track-${Y.track??0}`}function z(Y,re){return{id:Y,type:"video",name:`Track ${re+1}`,order:re}}const P=e.computed(()=>{const Y=new Map;for(const re of o.clips){const ae=T(re),ce=Y.get(ae);if(ce){ce.push(re);continue}Y.set(ae,[re])}return Y}),M=e.computed(()=>{if(!j.value)return[];const Y=[...o.tracks??[]].sort((ce,Be)=>ce.order-Be.order),re=new Set(Y.map(ce=>ce.id)),ae=[];for(const ce of P.value.keys())re.has(ce)||ae.push(z(ce,Y.length+ae.length));return[...Y,...ae].map(ce=>({track:ce,clips:P.value.get(ce.id)??[],height:ce.height??Dc}))}),L=e.computed(()=>new Set(M.value.filter(Y=>Y.track.locked===!0).map(Y=>Y.track.id)));function k(Y){const re=o.clips.find(ae=>ae.id===Y);return re?!L.value.has(T(re)):!1}function O(Y){const re=o.clips.find(ce=>ce.id===Y);if(!re)return null;const ae=o.clips.filter(ce=>ce.id!==Y&&ce.timelineStart>=re.timelineEnd-1e-9).map(ce=>ce.timelineStart);return ae.length?Math.min(...ae):null}function W(Y){const re=Y.sourceMaxOut??o.duration,ae=Y.timelineStart+(re-Y.sourceIn),ce=O(Y.id),Be=ce!=null?Math.max(Y.timelineStart,ce):1/0;return Math.min(ae,Be)}function G(Y,re=Dc){const ae=Y.sourceMinIn??0,Be=(Y.sourceMaxOut??o.duration)-ae,Le=Y.sourceIn-ae;return{left:`${(Y.timelineStart-Le)*N.value-d.value}px`,width:`${Be*N.value}px`,top:"0px",height:`${re}px`,opacity:p.value===Y.id?.25:.15}}const ie=e.computed(()=>o.useFrameMode?o.zoomLevel:o.zoomLevel/o.fps),we=e.computed(()=>m.secondsToFrames(o.duration)),_e=e.computed(()=>o.useFrameMode?we.value*ie.value:o.duration*N.value),oe=e.computed(()=>{var Y;return f.value||((Y=s.value)==null?void 0:Y.clientWidth)||800}),$=e.computed(()=>_e.value>R.value),B=e.computed(()=>Math.max(0,_e.value-R.value)),Z=e.computed(()=>d.value>0),ee=e.computed(()=>d.value<B.value),ne=e.computed(()=>o.useFrameMode?m.secondsToFrames(o.playhead)*ie.value-d.value:o.playhead*N.value-d.value),de=e.computed(()=>D.value===null?null:o.useFrameMode?m.secondsToFrames(D.value)*ie.value-d.value:D.value*N.value-d.value),ue=e.computed(()=>{const Y=R.value,re=Math.max(50,Y/_e.value*Y),ae=d.value/B.value*(Y-re);return{width:`${re}px`,left:`${ae}px`}}),ge=e.computed(()=>{const Y=[],re=Ne();for(let ae=0;ae<=o.duration;ae+=re){const ce=ae*N.value-d.value;ce>=-50&&ce<=R.value+50&&Y.push({position:ce+_.value,label:fe(ae),time:ae})}return Y});function Ne(){const re=80/N.value;return re<=1?1:re<=5?5:re<=10?10:re<=30?30:re<=60?60:Math.ceil(re/60)*60}function fe(Y){if(o.useFrameMode)return`F${m.secondsToFrames(Y)}`;{const re=Math.floor(Y/60),ae=Math.floor(Y%60),ce=Math.floor(Y%1*o.fps);return N.value>100?`${re}:${ae.toString().padStart(2,"0")}:${ce.toString().padStart(2,"0")}`:`${re}:${ae.toString().padStart(2,"0")}`}}function me(Y){const re=s.value.getBoundingClientRect();let ce=(Y.clientX-re.left-_.value+d.value)/N.value;const Be=o.clips.find(Le=>ce>=Le.timelineStart&&ce<=Le.timelineEnd);if(Be)ce=Math.max(Be.timelineStart,Math.min(Be.timelineEnd,ce));else if(o.selectedClipId){const Le=o.clips.find(Oe=>Oe.id===o.selectedClipId);if(Le){const Oe=Math.abs(ce-Le.timelineStart),mt=Math.abs(ce-Le.timelineEnd);ce=Oe<mt?Le.timelineStart:Le.timelineEnd}}else ce=Math.max(0,Math.min(ce,o.duration));r("update:playhead",ce)}function Ee(Y){if(!$.value)return;const re=Math.abs(Y.deltaX)>Math.abs(Y.deltaY)?Y.deltaX:Y.deltaY;re!==0&&(Y.preventDefault(),d.value=Math.max(0,Math.min(B.value,d.value+re)))}function Te(){return[...o.clips].sort((Y,re)=>Y.timelineStart-re.timelineStart)}function dt(Y){const re=Te(),ae=re.findIndex(ce=>ce.id===Y);return{previous:ae>0?re[ae-1]:null,next:ae!==-1&&ae<re.length-1?re[ae+1]:null}}function st(Y){const re=Y.timelineEnd-Y.timelineStart,{previous:ae,next:ce}=dt(Y.id),Be=ae?ae.timelineEnd:0,Le=ce?ce.timelineStart-re:Math.max(Y.timelineStart,o.duration-re);return{minStart:Be,maxStart:Math.max(Be,Le)}}function Dt(){return 12/Math.max(N.value,1)}function pt(Y){return Array.from(new Set(Y.filter(re=>typeof re=="number"&&Number.isFinite(re))))}function ft(Y,re,ae,ce){const Be=Math.max(ae,Math.min(Y,ce));if(!o.snapEnabled)return{value:Be,guideTime:null};const Le=Dt();let Oe=Be,mt=null,it=Number.POSITIVE_INFINITY;for(const rt of pt(re)){if(rt<ae||rt>ce)continue;const wt=Math.abs(rt-Be);wt<=Le&&wt<it&&(Oe=rt,mt=rt,it=wt)}return{value:Oe,guideTime:mt}}function _t(Y){if(Y.touches.length===2){C.value=!0;const re=Y.touches[0],ae=Y.touches[1];V.value=Math.hypot(ae.clientX-re.clientX,ae.clientY-re.clientY),x.value=o.zoomLevel}else Y.touches.length===1&&(E.value=Y.touches[0].clientX,v.value=Y.touches[0].clientY,S.value=E.value)}function ot(Y){if(C.value&&Y.touches.length===2){const re=Y.touches[0],ae=Y.touches[1],Be=Math.hypot(ae.clientX-re.clientX,ae.clientY-re.clientY)/V.value;Math.max(10,Math.min(200,x.value*Be)),r("update:playhead",o.playhead)}else if(Y.touches.length===1&&!C.value){const re=Y.touches[0],ae=S.value-re.clientX;Math.abs(ae)>Math.abs(re.clientY-v.value)&&(Y.preventDefault(),d.value=Math.max(0,Math.min(B.value,d.value+ae)),S.value=re.clientX)}}function bt(){C.value=!1}function gt(Y){const re=Y.target;if(re.closest(".playhead-handle"))return;const ae=Y.button===1,ce=!!re.closest(".video-track");(ae||!ce&&$.value)&&ve(Y)}function ve(Y){h.value=!0,g.value="pan",w.value=Y.clientX,F.value=d.value,document.addEventListener("mousemove",Ke),document.addEventListener("mouseup",We)}function Se(Y){Y.preventDefault(),Y.stopPropagation(),h.value=!0,g.value="playhead";const re="touches"in Y?Y.touches[0].clientX:Y.clientX;w.value=re,F.value=o.playhead,"touches"in Y?(document.addEventListener("touchmove",Ke),document.addEventListener("touchend",We)):(document.addEventListener("mousemove",Ke),document.addEventListener("mouseup",We))}function Fe(Y){Y.preventDefault(),Y.stopPropagation(),h.value=!0,g.value="scrollbar";const re="touches"in Y?Y.touches[0].clientX:Y.clientX;w.value=re,F.value=d.value,"touches"in Y?(document.addEventListener("touchmove",Ke),document.addEventListener("touchend",We)):(document.addEventListener("mousemove",Ke),document.addEventListener("mouseup",We))}function Ke(Y){if(!h.value)return;const ae=("touches"in Y?Y.touches[0].clientX:Y.clientX)-w.value;if(g.value==="playhead"){const ce=ae/N.value;let Be=F.value+ce;if(o.selectedClipId){const Le=o.clips.find(Oe=>Oe.id===o.selectedClipId);Le?Be=Math.max(Le.timelineStart,Math.min(Le.timelineEnd,Be)):Be=Math.max(0,Math.min(o.duration,Be))}else{const Le=o.clips.find(Oe=>o.playhead>=Oe.timelineStart&&o.playhead<=Oe.timelineEnd);Le?Be=Math.max(Le.timelineStart,Math.min(Le.timelineEnd,Be)):Be=Math.max(0,Math.min(o.duration,Be))}r("update:playhead",Be)}else if(g.value==="scrollbar"){const ce=ae/R.value*_e.value;d.value=Math.max(0,Math.min(B.value,F.value+ce))}else if(g.value==="pan"){const ce=F.value-ae;d.value=Math.max(0,Math.min(B.value,ce))}}function We(){h.value=!1,g.value=null,D.value=null,document.removeEventListener("mousemove",Ke),document.removeEventListener("mouseup",We),document.removeEventListener("touchmove",Ke),document.removeEventListener("touchend",We)}function ze(Y){l.value=l.value===Y?null:Y,r("clip-select",l.value)}function ut(Y){k(Y)&&(l.value=Y,r("clip-select",Y),r("clip-long-press",Y))}function Et(Y,re){if(!k(Y))return;const ae=o.clips.find(Be=>Be.id===Y);if(!ae||Math.abs(re)<2)return;const ce=re/N.value*o.sensitivity;if(o.useFrameMode){const Be=m.secondsToFrames(ae.sourceIn),Le=m.secondsToFrames(ce),Oe=Math.max(0,Be+Le),mt=m.framesToSeconds(Oe);r("trim",Y,"start",mt)}else{const Be=Math.max(0,ae.sourceIn+ce);r("trim",Y,"start",Be)}}function It(Y,re){if(!k(Y))return;const ae=o.clips.find(on=>on.id===Y);if(!ae||!s.value)return;const ce=s.value.getBoundingClientRect(),Be=re-ce.left-_.value,Le=80;Be<Le?d.value=Math.max(0,d.value-8):Be>ce.width-_.value-Le&&(d.value=Math.min(B.value,d.value+8));const Oe=Be+d.value,mt=1/o.fps;let it=Oe/N.value;const{previous:rt}=dt(ae.id),wt=ft(it,[0,rt==null?void 0:rt.timelineEnd,o.playhead],0,ae.timelineEnd-mt);it=wt.value,D.value=wt.guideTime;let At=ae.sourceIn+(it-ae.timelineStart);At=Math.round(At*o.fps)/o.fps,r("trim",Y,"start",At)}function Rt(Y,re){if(!k(Y))return;const ae=o.clips.find(Sn=>Sn.id===Y);if(!ae||!s.value)return;const ce=s.value.getBoundingClientRect(),Be=re-ce.left-_.value,Le=80;Be<Le?d.value=Math.max(0,d.value-8):Be>ce.width-_.value-Le&&(d.value=Math.min(B.value,d.value+8));const Oe=Be+d.value,mt=1/o.fps,it=W(ae);let rt=Oe/N.value;const{next:wt}=dt(ae.id),At=ft(rt,[wt==null?void 0:wt.timelineStart,o.playhead],ae.timelineStart+mt,it);rt=At.value,D.value=At.guideTime;let on=ae.sourceIn+(rt-ae.timelineStart);on=Math.round(on*o.fps)/o.fps,r("trim",Y,"end",on)}function Xt(Y,re){if(!k(Y))return;const ae=o.clips.find(At=>At.id===Y);if(!ae||!s.value)return;const ce=s.value.getBoundingClientRect(),Be=re-ce.left-_.value,Le=80;Be<Le?d.value=Math.max(0,d.value-8):Be>ce.width-_.value-Le&&(d.value=Math.min(B.value,d.value+8));const Oe=Be+d.value,mt=ae.timelineEnd-ae.timelineStart,it=st(ae);let rt=Oe/N.value;const wt=ft(rt,[it.minStart,it.maxStart,o.playhead,o.playhead-mt],it.minStart,it.maxStart);rt=wt.value,D.value=wt.guideTime,rt=Math.round(rt*o.fps)/o.fps,r("clip-move",Y,rt)}function yn(Y,re){if(!k(Y))return;const ae=o.clips.find(Le=>Le.id===Y);if(!ae||Math.abs(re)<2)return;const ce=re/N.value*o.sensitivity,Be=Le=>Math.max(0,Math.round(Le*o.fps)/o.fps);if(o.useFrameMode){const Le=m.secondsToFrames(ae.sourceOut),Oe=m.secondsToFrames(ce),mt=W(ae),it=ae.sourceIn+(mt-ae.timelineStart),rt=m.secondsToFrames(it),wt=Math.min(rt,Le+Oe),At=m.framesToSeconds(wt);r("trim",Y,"end",At)}else{const Le=W(ae),Oe=ae.sourceIn+(Le-ae.timelineStart),mt=Math.min(Oe,ae.sourceOut+ce),it=Be(mt);r("trim",Y,"end",it)}}function Pn(Y,re){if(!k(Y))return;const ae=o.clips.find(Le=>Le.id===Y);if(!ae||Math.abs(re)<2)return;const ce=re/N.value*o.sensitivity,Be=Le=>Math.max(0,Math.round(Le*o.fps)/o.fps);if(o.useFrameMode){const Le=m.secondsToFrames(ae.timelineStart),Oe=m.secondsToFrames(ce),mt=Math.max(0,Le+Oe),it=m.framesToSeconds(mt);r("clip-move",Y,it)}else{const Le=Math.max(0,ae.timelineStart+ce),Oe=Be(Le);r("clip-move",Y,Oe)}}return n({handleTrimStart:Et,handleTrimEnd:yn,handleClipDrag:Pn,handleTrimStartAbs:It,handleTrimEndAbs:Rt,handleClipDragAbs:Xt,handleClipLongPress:ut}),e.watch(()=>o.playhead,Y=>{const re=Y*N.value;re<d.value+50?d.value=Math.max(0,re-50):re>d.value+R.value-50&&(d.value=Math.min(B.value,re-R.value+50))}),e.onMounted(()=>{const Y=new ResizeObserver(re=>{re[0]&&(f.value=Math.round(re[0].contentRect.width))});s.value&&Y.observe(s.value),e.onUnmounted(()=>Y.disconnect())}),e.onUnmounted(()=>{We()}),e.watch([_e,oe],()=>{d.value>B.value&&(d.value=B.value)}),e.watch(D,(Y,re)=>{const ae=Y!==null;ae!==(re!==null)&&r("snap-state-change",ae)}),(Y,re)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:Ee},[e.createElementVNode("div",{class:"timeline-ruler",onClick:me},[e.createElementVNode("div",c1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ge.value,ae=>(e.openBlock(),e.createElementBlock("span",{key:ae.position,class:"time-marker",style:e.normalizeStyle({left:`${ae.position}px`})},e.toDisplayString(ae.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":$.value,"is-panning":h.value&&g.value==="pan","overflow-left":Z.value,"overflow-right":ee.value}]),onTouchstart:_t,onTouchmove:ot,onTouchend:bt,onMousedown:gt},[j.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-lanes",style:e.normalizeStyle({"--timeline-track-header-width":`${$c}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,ae=>(e.openBlock(),e.createElementBlock("div",{key:ae.track.id,class:e.normalizeClass(["timeline-track-lane",{"timeline-track-lane--locked":ae.track.locked,"timeline-track-lane--hidden":ae.track.hidden}]),style:e.normalizeStyle({height:`${ae.height}px`}),"data-track-id":ae.track.id},[e.createVNode(l1,{class:"timeline-track-lane__header",track:ae.track,onToggleLock:re[0]||(re[0]=ce=>r("toggle-lock",ce)),onToggleHidden:re[1]||(re[1]=ce=>r("toggle-hidden",ce)),onToggleMuted:re[2]||(re[2]=ce=>r("toggle-muted",ce)),onToggleSolo:re[3]||(re[3]=ce=>r("toggle-solo",ce))},null,8,["track"]),e.createElementVNode("div",{class:"video-track timeline-track-lane__body","data-track-id":ae.track.id},[ae.track.hidden?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ae.clips,ce=>(e.openBlock(),e.createElementBlock("div",{key:`${ce.id}-extent`,class:"clip-extent",style:e.normalizeStyle(G(ce,ae.height)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ae.clips,ce=>(e.openBlock(),e.createBlock(Fc,{key:ce.id,clip:ce,scale:N.value,"scroll-offset":d.value,selected:p.value===ce.id,"is-mobile":i.value,"data-locked":ae.track.locked===!0?"true":void 0,onSelect:Be=>ze(ce.id),onLongPress:Be=>ut(ce.id),onTrimStartAbs:Be=>It(ce.id,Be),onTrimEndAbs:Be=>Rt(ce.id,Be),onDragAbs:Be=>Xt(ce.id,Be)},null,8,["clip","scale","scroll-offset","selected","is-mobile","data-locked","onSelect","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],64))],8,u1)],14,d1))),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(Y.clips,ae=>(e.openBlock(),e.createElementBlock("div",{key:`${ae.id}-extent`,class:"clip-extent",style:e.normalizeStyle(G(ae)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Y.clips,ae=>(e.openBlock(),e.createBlock(Fc,{key:ae.id,clip:ae,scale:N.value,"scroll-offset":d.value,selected:p.value===ae.id,"is-mobile":i.value,onSelect:ce=>ze(ae.id),onLongPress:ce=>ut(ae.id),onTrimStartAbs:ce=>It(ae.id,ce),onTrimEndAbs:ce=>Rt(ae.id,ce),onDragAbs:ce=>Xt(ae.id,ce)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512)),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${_.value+ne.value}px`}),onMousedown:Se,onTouchstart:Se},[...re[5]||(re[5]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"split-indicator",style:e.normalizeStyle({left:`${_.value+ne.value}px`})},null,4)):e.createCommentVNode("",!0),de.value!==null?(e.openBlock(),e.createElementBlock("div",{key:3,class:"snap-guide",style:e.normalizeStyle({left:`${_.value+de.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:re[4]||(re[4]=ae=>Y.$emit("toggle-frame-mode")),"aria-label":Y.useFrameMode?"Switch to time mode":"Switch to frame mode",title:Y.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(Y.useFrameMode?"F":"T"),9,m1))],34),$.value?(e.openBlock(),e.createElementBlock("div",p1,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(ue.value),onMousedown:Fe,onTouchstart:Fe},null,36)])):e.createCommentVNode("",!0)],34))}}),Ds=Ve(f1,[["__scopeId","data-v-04ef5842"]]),h1={key:0,class:"control-group primary-controls"},v1=["disabled"],g1=["disabled"],y1=["disabled"],b1=["disabled"],w1=["disabled"],k1={key:1,class:"control-group mobile-action-controls"},_1=["aria-expanded"],E1={key:0,class:"mobile-action-menu",role:"menu","aria-label":"Clip actions","data-testid":"timeline-mobile-action-menu"},x1=["disabled"],S1=["disabled"],C1=["disabled"],V1=["disabled"],N1=["disabled"],T1={class:"control-group zoom-controls"},M1={class:"zoom-slider"},B1=["value"],I1={class:"control-group playback-controls"},F1=["aria-label"],$1={key:2,class:"control-group speed-control"},D1=["value"],R1=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{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","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(a,{emit:n}){const t=n,o=e.ref(!1);function i(p){switch(p){case"split":t("split");break;case"delete":t("delete");break;case"duplicate":t("duplicate");break;case"undo":t("undo");break;case"redo":t("redo");break}o.value=!1}function r(p){const m=p.target;t("zoom-change",Number(m.value))}function s(){t("fit-to-window")}function l(){t("frame-forward")}function c(){t("frame-backward")}function d(){t("skip-to-start")}function u(){t("skip-to-end")}function f(p){const m=p.target;t("speed-change",Number(m.value))}return(p,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:p.isMobile}])},[p.isMobile?(e.openBlock(),e.createElementBlock("div",k1,[e.createElementVNode("button",{class:"control-button","data-testid":"timeline-btn-mobile-actions","aria-expanded":o.value?"true":"false","aria-label":"Clip actions",onClick:m[5]||(m[5]=h=>o.value=!o.value)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ff)},null,8,["icon"]),m[17]||(m[17]=e.createElementVNode("span",{class:"control-label"},"Actions",-1))],8,_1),o.value?(e.openBlock(),e.createElementBlock("div",E1,[e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canUndo,"data-testid":"timeline-mobile-btn-undo",onClick:m[6]||(m[6]=h=>i("undo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ic)},null,8,["icon"]),m[18]||(m[18]=e.createTextVNode(" Undo ",-1))],8,x1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canRedo,"data-testid":"timeline-mobile-btn-redo",onClick:m[7]||(m[7]=h=>i("redo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(oc)},null,8,["icon"]),m[19]||(m[19]=e.createTextVNode(" Redo ",-1))],8,S1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canSplit,"data-testid":"timeline-mobile-btn-split",onClick:m[8]||(m[8]=h=>i("split"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(zi)},null,8,["icon"]),m[20]||(m[20]=e.createTextVNode(" Split ",-1))],8,C1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.selectedClip,"data-testid":"timeline-mobile-btn-duplicate",onClick:m[9]||(m[9]=h=>i("duplicate"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(vs)},null,8,["icon"]),m[21]||(m[21]=e.createTextVNode(" Duplicate ",-1))],8,V1),e.createElementVNode("button",{type:"button",role:"menuitem",class:"danger-menu-item",disabled:!p.canDelete,"data-testid":"timeline-mobile-btn-delete",onClick:m[10]||(m[10]=h=>i("delete"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(gs)},null,8,["icon"]),m[22]||(m[22]=e.createTextVNode(" Delete ",-1))],8,N1)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",h1,[e.createElementVNode("button",{class:"control-button",disabled:!p.canUndo,"data-testid":"timeline-btn-undo","aria-label":"Undo",title:"Undo",onClick:m[0]||(m[0]=h=>p.$emit("undo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ic)},null,8,["icon"])],8,v1),e.createElementVNode("button",{class:"control-button",disabled:!p.canRedo,"data-testid":"timeline-btn-redo","aria-label":"Redo",title:"Redo",onClick:m[1]||(m[1]=h=>p.$emit("redo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(oc)},null,8,["icon"])],8,g1),e.createElementVNode("button",{class:"control-button",disabled:!p.canSplit,"data-testid":"timeline-btn-split","aria-label":"Split selected clip at playhead",title:"Split",onClick:m[2]||(m[2]=h=>p.$emit("split"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(zi)},null,8,["icon"]),m[14]||(m[14]=e.createElementVNode("span",{class:"control-label"},"Split",-1))],8,y1),e.createElementVNode("button",{class:"control-button",disabled:!p.selectedClip,"data-testid":"timeline-btn-duplicate","aria-label":"Duplicate selected clip",title:"Duplicate",onClick:m[3]||(m[3]=h=>p.$emit("duplicate"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(vs)},null,8,["icon"]),m[15]||(m[15]=e.createElementVNode("span",{class:"control-label"},"Duplicate",-1))],8,b1),e.createElementVNode("button",{class:"control-button danger-button",disabled:!p.canDelete,"data-testid":"timeline-btn-delete","aria-label":"Delete selected clip",title:"Delete",onClick:m[4]||(m[4]=h=>p.$emit("delete"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(gs)},null,8,["icon"]),m[16]||(m[16]=e.createElementVNode("span",{class:"control-label"},"Delete",-1))],8,w1)])),e.createElementVNode("div",T1,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[11]||(m[11]=h=>p.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Yf)},null,8,["icon"])]),e.createElementVNode("div",M1,[e.createElementVNode("input",{type:"range",value:p.zoomLevel,onInput:r,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,B1)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[12]||(m[12]=h=>p.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ef)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Df)},null,8,["icon"]),m[23]||(m[23]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",I1,[e.createElementVNode("button",{class:"control-button",onClick:d,"aria-label":"Skip to start"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Jf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Previous frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Zf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[13]||(m[13]=h=>p.$emit("play-pause")),"aria-label":p.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:p.isPlaying?e.unref(il):e.unref(rl)},null,8,["icon"])],8,F1),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Next frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:u,"aria-label":"Skip to end"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Kf)},null,8,["icon"])])]),p.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",$1,[m[25]||(m[25]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:p.playbackSpeed,onChange:f,class:"speed-select","aria-label":"Playback speed"},[...m[24]||(m[24]=[e.createStaticVNode('<option value="0.25" data-v-6420ce13>0.25x</option><option value="0.5" data-v-6420ce13>0.5x</option><option value="1" data-v-6420ce13>1x</option><option value="1.5" data-v-6420ce13>1.5x</option><option value="2" data-v-6420ce13>2x</option>',5)])],40,D1)]))],2))}}),Rs=Ve(R1,[["__scopeId","data-v-6420ce13"]]),A1={key:0,class:"category-section"},L1={class:"category-carousel-wrapper"},P1=["disabled"],O1=["onClick","data-testid","aria-label"],U1={class:"category-name"},z1=["disabled"],j1={class:"filter-section"},W1={class:"filter-carousel-wrapper"},Z1=["disabled"],H1=["onClick","onKeydown","data-testid","aria-label"],X1=["onClick"],G1={class:"filter-preview"},J1={class:"filter-placeholder"},K1={class:"filter-name"},Y1=["disabled"],q1={class:"carousel-pagination"},Q1=["onClick"],eb={key:1,class:"filter-adjustments"},tb={class:"adjustment-header"},nb={class:"adjustment-actions"},ab={key:0},ob={key:0,class:"slider-control"},ib={class:"control-label"},rb={class:"slider-wrapper"},sb={class:"slider-value"},lb={key:1,class:"color-control"},cb={class:"control-label"},db={class:"color-wrapper"},ub=["value","onInput","disabled"],mb={class:"color-value"},pb={key:2,class:"toggle-control"},fb={class:"control-label"},hb={key:3,class:"select-control"},vb={class:"control-label"},gb=["value","onChange","disabled"],yb=["value"],bb={key:1,class:"no-params"},wb=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),f={all:ta,adjust:wo,color:na,blur:hi,light:ko,effects:Jr,stylize:Co,advanced:ta,distortion:Vo,transform:Vo};function p(k){return k.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function m(k){return k.replace(/[-_]/g," ").replace(/\b\w/g,O=>O.toUpperCase())}function h(k){return f[k.toLowerCase()]??ta}const g=e.computed(()=>{const k=Array.from(new Set(t.filters.map(O=>O.category).filter(O=>typeof O=="string"&&O.length>0))).sort((O,W)=>O.localeCompare(W));return[{id:"all",name:"All",icon:ta},...k.map(O=>({id:O,name:m(O),icon:h(O)}))]}),w=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(k=>k.category===i.value));e.watch(g,k=>{new Set(k.map(G=>G.id)).has(i.value)||(i.value="all");const W=Math.max(0,k.length-3);s.value>W&&(s.value=W)},{immediate:!0});function F(k){var O;return((O=t.activeFilters)==null?void 0:O.has(k))||!1}function D(k){if(r.value=k,!F(k.id)&&(o("apply-filter",k),k.params&&k.params.length>0)){const O=new Map;k.params.forEach(W=>{O.set(W.id,W.default)}),c.value.set(k.id,O)}o("preview-filter",k)}function E(k){var O;o("remove-filter",k),c.value.delete(k),((O=r.value)==null?void 0:O.id)===k&&(r.value=null)}function v(k){if(typeof k=="number"&&Number.isFinite(k))return k;if(typeof k=="string"){const O=Number(k);return Number.isFinite(O)?O:null}return null}function S(k,O){var $;const W=t.filters.find(B=>B.id===k),G=W==null?void 0:W.params.find(B=>B.id===O),ie=(G==null?void 0:G.default)??0,we=B=>typeof ie=="number"?v(B)??ie:typeof ie=="boolean"?typeof B=="boolean"?B:ie:typeof B=="string"?B:ie,_e=($=t.activeFilters)==null?void 0:$.get(k);if(_e&&_e.params){const B=_e.params[O];if(B!=null)return we(B)}const oe=c.value.get(k);if(oe){const B=oe.get(O);if(B!=null)return we(B)}return ie}function C(k,O,W){var G;c.value.has(k)||c.value.set(k,new Map),(G=c.value.get(k))==null||G.set(O,W),o("update-param",k,O,W)}function V(k){if(typeof k=="boolean")return k?"On":"Off";if(typeof k=="string"){const W=v(k);return W===null?"0":Number.isInteger(W)?W.toString():W.toFixed(2)}const O=v(k);return O===null?"0":Number.isInteger(O)?O.toString():O.toFixed(2)}function x(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const k=new Map;r.value.params.forEach(O=>{k.set(O.id,O.default)}),c.value.set(r.value.id,k)}}function N(k){const O=t.filters.find(W=>W.id===k);O&&O.params&&O.params.forEach(W=>{C(k,W.id,W.default)})}function j(k){return{basic:wo,color:na,blur:hi,light:ko,effects:Jr,stylize:Co,adjustment:wo,"color-matrix":na,glow:ta,distortion:Vo}[k]||ta}function _(k){return{adjustment:wo,brightness:ko,contrast:wo,saturation:na,blur:hi,"gaussian-blur":hi,"color-matrix":na,grayscale:Co,sepia:Co,vignette:Vo,glow:ta,glitch:Jr,godray:ko,lightmap:ko}[k.id]||j(k.category)}function R(){s.value>0&&(s.value--,L(d.value,s.value))}function T(){s.value<g.value.length-3&&(s.value++,L(d.value,s.value))}function z(){l.value>0&&(l.value--,L(u.value,l.value))}function P(){l.value<w.value.length-4&&(l.value++,L(u.value,l.value))}function M(k){l.value=k*4,L(u.value,l.value)}function L(k,O){var W;if(k){const G=((W=k.querySelector(".category-chip, .filter-card"))==null?void 0:W.clientWidth)||100;k.scrollTo({left:O*(G+8),behavior:"smooth"})}}return(k,O)=>{var W;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:k.compact}])},[k.showCategories?(e.openBlock(),e.createElementBlock("div",A1,[e.createElementVNode("div",L1,[e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(rc)},null,8,["icon"])],8,P1),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,G=>(e.openBlock(),e.createElementBlock("button",{key:G.id,onClick:ie=>i.value=G.id,class:e.normalizeClass(["category-chip",{active:i.value===G.id}]),"data-testid":`btn-filter-category-${p(G.id)}`,"aria-label":`Filter category ${G.name}`},[e.createVNode(e.unref(U.IonIcon),{icon:G.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",U1,e.toDisplayString(G.name),1)],10,O1))),128))],512),e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(sc)},null,8,["icon"])],8,z1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",j1,[e.createElementVNode("div",W1,[e.createElementVNode("button",{onClick:z,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(rc)},null,8,["icon"])],8,Z1),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,G=>{var ie;return e.openBlock(),e.createElementBlock("div",{key:G.id,class:e.normalizeClass(["filter-card",{active:F(G.id),selected:((ie=r.value)==null?void 0:ie.id)===G.id}]),onClick:we=>D(G),onKeydown:[e.withKeys(we=>D(G),["enter"]),e.withKeys(e.withModifiers(we=>D(G),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${p(G.id)}`,"aria-label":`Select filter ${G.name}`},[F(G.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(we=>E(G.id),["stop"])},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ld)},null,8,["icon"])],8,X1)):e.createCommentVNode("",!0),e.createElementVNode("div",G1,[e.createElementVNode("div",J1,[e.createVNode(e.unref(U.IonIcon),{icon:_(G),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",K1,e.toDisplayString(G.name),1)],42,H1)}),128))],512),e.createElementVNode("button",{onClick:P,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,w.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(sc)},null,8,["icon"])],8,Y1)]),e.createElementVNode("div",q1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(w.value.length/4),(G,ie)=>(e.openBlock(),e.createElementBlock("span",{key:ie,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===ie}]),onClick:we=>M(ie)},null,10,Q1))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",eb,[e.createElementVNode("div",tb,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",nb,[F(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),F(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:O[0]||(O[0]=G=>E(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),F(r.value.id)&&((W=r.value.params)==null?void 0:W.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:O[1]||(O[1]=G=>N(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",ab,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,G=>(e.openBlock(),e.createElementBlock("div",{key:G.id,class:"adjustment-control"},[!G.type||G.type==="slider"?(e.openBlock(),e.createElementBlock("div",ob,[e.createElementVNode("label",ib,e.toDisplayString(G.label||G.id),1),e.createElementVNode("div",rb,[e.createVNode(e.unref(U.IonRange),{value:S(r.value.id,G.id),onIonChange:ie=>C(r.value.id,G.id,ie.detail.value),min:G.min,max:G.max,step:G.step||.01,color:"primary",class:"compact-slider",disabled:!F(r.value.id),"data-testid":`range-filter-${p(r.value.id)}-${p(G.id)}`,"aria-label":`Adjust ${G.label||G.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",sb,e.toDisplayString(V(S(r.value.id,G.id))),1)])])):G.type==="color"?(e.openBlock(),e.createElementBlock("div",lb,[e.createElementVNode("label",cb,e.toDisplayString(G.label||G.id),1),e.createElementVNode("div",db,[e.createElementVNode("input",{type:"color",value:S(r.value.id,G.id),onInput:ie=>C(r.value.id,G.id,ie.target.value),disabled:!F(r.value.id),class:"color-input"},null,40,ub),e.createElementVNode("span",mb,e.toDisplayString(S(r.value.id,G.id)),1)])])):G.type==="toggle"?(e.openBlock(),e.createElementBlock("div",pb,[e.createElementVNode("label",fb,e.toDisplayString(G.label||G.id),1),e.createVNode(e.unref(U.IonToggle),{checked:!!S(r.value.id,G.id),onIonChange:ie=>C(r.value.id,G.id,ie.detail.checked),disabled:!F(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):G.type==="select"?(e.openBlock(),e.createElementBlock("div",hb,[e.createElementVNode("label",vb,e.toDisplayString(G.label||G.id),1),e.createElementVNode("select",{value:S(r.value.id,G.id),onChange:ie=>C(r.value.id,G.id,ie.target.value),disabled:!F(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.options,ie=>(e.openBlock(),e.createElementBlock("option",{key:String(ie.value),value:ie.value},e.toDisplayString(ie.label),9,yb))),128))],40,gb)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",bb," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),As=Ve(wb,[["__scopeId","data-v-9efd15d9"]]);class kb{constructor(n){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=n}setComposition(n){this.composition=n}mapMediablesToPIXI(n){switch(n.filterId){case"blur":return this.createBlurFilter(n.params);case"brightness":return this.createBrightnessFilter(n.params);case"contrast":return this.createContrastFilter(n.params);case"saturation":return this.createSaturationFilter(n.params);case"hue":return this.createHueFilter(n.params);case"vintage":return this.createVintageFilter(n.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.BlurFilter;if(!i)return null;const r=new i;return r.blur=n.intensity||5,r.quality=n.quality||4,r}catch{return null}}createBrightnessFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),n.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const o=this.mapMediablesToPIXI(t);o&&(this.pixiFilters.set(t.id,o),this.filterParams.set(t.id,t.params),this.filterTypes.set(t.id,t.filterId),this.filterIntensity.set(t.id,t.intensity),await this.applyToComposition(t.id,o))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const o=this.pixiFilters.get(n);o&&(this.filterParams.set(n,t),"blur"in o&&(o.blur=t.intensity||o.blur),"brightness"in o&&o.brightness(t.value||1,!1),"contrast"in o&&o.contrast(t.value||1,!1),"saturate"in o&&o.saturate(t.value||1,!1),"hue"in o&&o.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(n){return this.filterParams.get(n)||{}}removeFilter(n){var t;this.pixiFilters.delete(n),this.filterParams.delete(n),this.filterTypes.delete(n),this.filterIntensity.delete(n),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(n)}clearFilters(){var n;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(n=this.composition)!=null&&n.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const n=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;n.push({id:o,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const _b={class:"video-filter-preview"},Eb={class:"preview-title"},xb={class:"filter-controls"},Sb={class:"control-input"},Cb=["value","onInput","min","max","step"],Vb={class:"param-value"},Nb={class:"preview-container"},Tb={key:0,class:"filter-presets"},Mb=["onClick"],Bb={class:"preview-actions"},Ib=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const f=e.computed(()=>{var x;return((x=t.filter)==null?void 0:x.paramRanges)||{}}),p=e.computed(()=>m.value.length>0),m=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 x;if(i.value){t.useVideoEngine&&t.composition&&(u=new kb(t.composition));try{if(l=new Ct.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(x=t.currentFrame)!=null&&x.dataUrl){const N=await Ct.Assets.load(t.currentFrame.dataUrl);c=new Ct.Sprite(N);const j=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(j),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}g()}catch{}}}function g(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const x={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([x]).then(()=>{}).catch(N=>{}),d&&(d.destroy(),d=null),d=w(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=w(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}function w(x,N){switch(x){case"brightness":{const j=new Ct.ColorMatrixFilter,_=1+(N.value??0);return typeof j.brightness=="function"&&j.brightness(_,!1),j}case"contrast":{const j=new Ct.ColorMatrixFilter,_=N.value??1;return typeof j.contrast=="function"&&j.contrast(_,!1),j}case"saturation":{const j=new Ct.ColorMatrixFilter,_=N.value??1;return typeof j.saturate=="function"&&j.saturate(_,!1),j}case"hue":{const j=new Ct.ColorMatrixFilter,_=N.value??0;return typeof j.hue=="function"&&j.hue(_,!1),j}case"gaussian-blur":{const j=N.value??5;return new Ct.BlurFilter({strength:j,quality:4})}case"sepia":{const j=new Ct.ColorMatrixFilter;return typeof j.sepia=="function"&&j.sepia(!1),j}case"grayscale":{const j=new Ct.ColorMatrixFilter;return typeof j.desaturate=="function"&&j.desaturate(),j}default:return null}}function F(x,N){const j=N.target,_=Number.parseFloat(j.value),R=Number.isFinite(_)?_:0;s.value={...s.value,[x]:R},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),g()}function D(x){return x.charAt(0).toUpperCase()+x.slice(1).replace(/_/g," ")}function E(x,N){var _;const j=typeof x=="number"?x:Number(x);return Number.isFinite(j)?N==="hue"||N==="angle"?`${j}°`:N==="value"&&((_=t.filter)==null?void 0:_.id)==="brightness"?`${Math.round((1+j)*100)}%`:Number.isInteger(j)?j.toString():j.toFixed(2):"0"}function v(){var x;s.value=((x=t.filter)==null?void 0:x.defaultParams)||{},o("update-params",s.value),g()}function S(x){s.value={...x.params},o("update-params",s.value),g()}function C(x){return JSON.stringify(x.params)===JSON.stringify(s.value)}function V(){o("apply")}return e.watch(()=>t.filter,x=>{x&&(s.value={...x.defaultParams},g())}),e.watch(()=>t.currentFrame,async x=>{if(x!=null&&x.dataUrl&&c){const N=await Ct.Assets.load(x.dataUrl);c.texture=N}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),h()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(x,N)=>{var j;return e.openBlock(),e.createElementBlock("div",_b,[e.createElementVNode("h4",Eb,e.toDisplayString((j=x.filter)==null?void 0:j.name)+" Settings",1),e.createElementVNode("div",xb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(_,R)=>(e.openBlock(),e.createElementBlock("div",{key:R,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(D(R)),1),e.createElementVNode("div",Sb,[e.createElementVNode("input",{type:"range",value:s.value[R],onInput:T=>F(R,T),min:_.min,max:_.max,step:_.step,class:"param-slider"},null,40,Cb),e.createElementVNode("span",Vb,e.toDisplayString(E(s.value[R],R)),1)])]))),128))]),e.createElementVNode("div",Nb,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:N[0]||(N[0]=_=>r.value=!0),onMouseup:N[1]||(N[1]=_=>r.value=!1),onTouchstart:N[2]||(N[2]=_=>r.value=!0),onTouchend:N[3]||(N[3]=_=>r.value=!1)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Vo)},null,8,["icon"]),N[4]||(N[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),p.value?(e.openBlock(),e.createElementBlock("div",Tb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,_=>(e.openBlock(),e.createElementBlock("button",{key:_.name,class:e.normalizeClass(["preset-button",{active:C(_)}]),onClick:R=>S(_)},e.toDisplayString(_.name),11,Mb))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",Bb,[e.createElementVNode("button",{class:"action-button",onClick:v},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba)},null,8,["icon"]),N[5]||(N[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:V},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Pd)},null,8,["icon"]),N[6]||(N[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Ls=Ve(Ib,[["__scopeId","data-v-3de3dd04"]]),xu={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"}},Su={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"}},Cu={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"}},Vu={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"}},Nu=[xu,Su,Cu,Vu],xl={"mobile-share":xu,"hd-web":Su,original:Cu,"server-master":Vu},Fb=["mobile-share","hd-web"],$b=["hd-web","original","mobile-share"],Db=["server-master","hd-web","original","mobile-share"];function yr(a){return typeof a=="string"?xl[a]:a}function Rb(a){const{bitrate:n,codec:t,format:o,fps:i,quality:r}=yr(a).settings,s={format:o,codec:t,quality:r,fps:i};return typeof n=="number"&&(s.bitrate=n),s}function Ab(a){const n=yr(a);return n.settings.mobileSuitable&&n.settings.advancedVisibility==="standard"}function Lb(a=Nu){return a.filter(n=>Ab(n))}function Pb(a,n){const t=yr(a).settings.maxClientDurationSeconds;return t!==null&&Number.isFinite(n)&&n>=0&&n<=t}function Ob(a,n){const t=yr(a),o=n.endpoints.client&&Pb(t,n.durationSeconds),i=n.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 Ub(a,n){return Ob(a,n)!==null}function zb(a){const n=jb(a);for(const t of n){const o=xl[t];if(Wb(o,a.includeAdvanced===!0)&&!(a.device==="mobile"&&!o.settings.mobileSuitable)&&Ub(o,a))return o}return null}function jb(a){return a.device==="mobile"?Fb:a.includeAdvanced===!0?Db:$b}function Wb(a,n){return a.settings.advancedVisibility==="hidden"?!1:a.settings.advancedVisibility==="standard"||n}const Zb={class:"export-settings"},Hb={class:"setting-group preset-setting"},Xb={class:"setting-copy"},Gb={class:"setting-description"},Jb=["value"],Kb={key:0,class:"advanced-toggle","data-testid":"export-advanced-toggle"},Yb={class:"preset-summary","data-testid":"export-preset-summary"},qb={class:"estimated-size"},Qb={key:0,class:"export-progress"},ew={class:"progress-header"},tw={class:"progress-percentage"},nw={class:"progress-time"},aw={class:"action-buttons"},ow=["disabled"],iw=["disabled"],rw=["disabled"],sw={class:"export-options"},lw="hd-web",cw=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(a,{emit:n}){const t=a,o=n,i={client:!0,server:!0},r=Nu,s={"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35},l=e.ref(!1),c=e.ref(v()),d=e.ref(!0),u=e.ref(!1),f=e.ref(0),p=e.ref(0),m=e.ref(0);let h=null;const g=e.computed(()=>t.isMobile?Lb():r.filter(_=>_.settings.advancedVisibility==="hidden"?!1:_.settings.advancedVisibility==="standard"||l.value)),w=e.computed(()=>g.value.find(_=>_.id===c.value)??xl[v()]),F=e.computed(()=>Rb(w.value)),D=e.computed(()=>{const _=F.value,R=[_.quality,_.format.toUpperCase(),_.codec.toUpperCase(),`${_.fps} fps`],T=S(_.bitrate);return T!==null&&R.push(T),R.join(" / ")}),E=e.computed(()=>{const _=F.value,T=(typeof _.bitrate=="number"?_.bitrate/1e6:s[_.quality])*t.duration/8;return T<1e3?`~${Math.round(T)} MB`:`~${(T/1e3).toFixed(1)} GB`});function v(){var _;return((_=zb({durationSeconds:t.duration,device:t.isMobile?"mobile":"desktop",endpoints:i,includeAdvanced:l.value}))==null?void 0:_.id)??lw}function S(_){return typeof _!="number"?null:`${Number((_/1e6).toFixed(1))} Mbps`}function C(){t.isExporting?(o("cancel-export"),N()):V()}function V(){const _=F.value,R={quality:_.quality,format:_.format,optimizeForWeb:d.value,includeWatermark:u.value,presetId:w.value.id,codec:_.codec,fps:_.fps};typeof _.bitrate=="number"&&(R.bitrate=_.bitrate),o("export",R),x()}function x(){f.value=Date.now(),p.value=0,h=window.setInterval(()=>{if(p.value=Math.floor((Date.now()-f.value)/1e3),t.exportProgress>0){const _=p.value/t.exportProgress*100;m.value=Math.max(0,_-p.value)}},1e3)}function N(){h&&(clearInterval(h),h=null)}function j(_){const R=Math.floor(_/60),T=Math.floor(_%60);return`${R}:${T.toString().padStart(2,"0")}`}return e.watch([()=>t.isMobile,()=>l.value],()=>{g.value.some(R=>R.id===c.value)||(c.value=v())},{immediate:!0}),e.watch(()=>t.isExporting,_=>{_||N()}),e.onUnmounted(()=>{N()}),(_,R)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:_.isMobile}])},[e.createElementVNode("div",Zb,[R[8]||(R[8]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",Hb,[e.createElementVNode("div",Xb,[R[6]||(R[6]=e.createElementVNode("label",{for:"export-preset-select"},"Preset",-1)),e.createElementVNode("span",Gb,e.toDisplayString(w.value.description),1)]),e.withDirectives(e.createElementVNode("select",{id:"export-preset-select","onUpdate:modelValue":R[0]||(R[0]=T=>c.value=T),class:"setting-select preset-select","data-testid":"export-preset-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,T=>(e.openBlock(),e.createElementBlock("option",{key:T.id,value:T.id},e.toDisplayString(T.label),9,Jb))),128))],512),[[e.vModelSelect,c.value]])]),_.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("label",Kb,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[1]||(R[1]=T=>l.value=T),type:"checkbox","data-testid":"export-advanced-toggle-input"},null,512),[[e.vModelCheckbox,l.value]]),R[7]||(R[7]=e.createElementVNode("span",null,"Advanced presets",-1))])),e.createElementVNode("div",Yb,e.toDisplayString(D.value),1),e.createElementVNode("div",qb,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Pf)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(E.value),1)])]),_.isExporting?(e.openBlock(),e.createElementBlock("div",Qb,[e.createElementVNode("div",ew,[R[9]||(R[9]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",tw,e.toDisplayString(_.exportProgress??0)+"%",1)]),e.createVNode(e.unref(U.IonProgressBar),{value:(_.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",nw,[e.createElementVNode("span",null,e.toDisplayString(j(p.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(j(m.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",aw,[e.createElementVNode("button",{class:"control-button secondary",onClick:R[2]||(R[2]=T=>_.$emit("save-draft")),disabled:!_.canExport||_.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ar)},null,8,["icon"]),R[10]||(R[10]=e.createTextVNode(" Save Draft ",-1))],8,ow),e.createElementVNode("button",{class:"control-button secondary",onClick:R[3]||(R[3]=T=>_.$emit("reset")),disabled:_.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba)},null,8,["icon"]),R[11]||(R[11]=e.createTextVNode(" Reset ",-1))],8,iw),e.createElementVNode("button",{class:"control-button primary",onClick:C,disabled:!_.canExport&&!_.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(U.IonIcon),{icon:_.isExporting?e.unref(Ca):e.unref(qa)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(_.isExporting?"Cancel":"Export Video"),1)],8,rw)]),e.createElementVNode("div",sw,[e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:d.value,"onUpdate:modelValue":R[4]||(R[4]=T=>d.value=T)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...R[12]||(R[12]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:u.value,"onUpdate:modelValue":R[5]||(R[5]=T=>u.value=T)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...R[13]||(R[13]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Ps=Ve(cw,[["__scopeId","data-v-d26ca1bc"]]),dw={class:"thumbnail-picker"},uw={class:"thumbnail-grid"},mw=["onClick"],pw=["src","alt"],fw={key:1,class:"thumbnail-placeholder"},hw={class:"thumbnail-time"},vw={class:"custom-selector"},gw={class:"time-input-group"},yw=["max"],bw={class:"time-value"},ww=["disabled"],kw={class:"picker-actions"},_w=["disabled"],Ew=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const F=[];if(t.duration<=10)for(let E=0;E<Math.min(9,t.duration);E++)F.push(E);else{const E=t.duration/10;for(let v=1;v<=9;v++)F.push(E*v)}return F}async function d(F){try{const D=document.createElement("video");return D.crossOrigin="anonymous",D.src=await u(),new Promise(E=>{D.addEventListener("loadedmetadata",()=>{D.currentTime=F}),D.addEventListener("seeked",()=>{const v=document.createElement("canvas");v.width=D.videoWidth,v.height=D.videoHeight;const S=v.getContext("2d");S?(S.drawImage(D,0,0),E(v.toDataURL("image/jpeg",.8))):E(null),D.remove()}),D.addEventListener("error",()=>{E(null),D.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 F=c();i.value=F.map(E=>({time:E,loading:!0}));const D=3;for(let E=0;E<i.value.length;E+=D){const v=i.value.slice(E,E+D);await Promise.all(v.map(async S=>{const C=await d(S.time);C&&(S.dataUrl=C),S.loading=!1}))}}function p(F){r.value=F,s.value=i.value[F].time}function m(){r.value=-1}async function h(){l.value=!0;try{const F=await d(s.value);if(F){const D=i.value.findIndex(E=>Math.abs(E.time-s.value)<.1);D>=0?(i.value[D].dataUrl=F,r.value=D):(i.value.push({time:s.value,dataUrl:F}),r.value=i.value.length-1,i.value.sort((E,v)=>E.time-v.time),r.value=i.value.findIndex(E=>E.time===s.value))}}finally{l.value=!1}}function g(){const F=r.value>=0?i.value[r.value].time:s.value;o("select",F)}function w(F){const D=Math.floor(F/60),E=Math.floor(F%60),v=Math.floor(F%1*100);return D>0?`${D}:${E.toString().padStart(2,"0")}.${v.toString().padStart(2,"0")}`:`${E}.${v.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),(F,D)=>(e.openBlock(),e.createElementBlock("div",dw,[D[5]||(D[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",uw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(E,v)=>(e.openBlock(),e.createElementBlock("div",{key:v,class:e.normalizeClass(["thumbnail-item",{selected:r.value===v}]),onClick:S=>p(v)},[E.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:E.dataUrl,alt:`Frame at ${w(E.time)}`},null,8,pw)):(e.openBlock(),e.createElementBlock("div",fw,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",hw,e.toDisplayString(w(E.time)),1)],10,mw))),128))]),e.createElementVNode("div",vw,[D[3]||(D[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",gw,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":D[0]||(D[0]=E=>s.value=E),min:0,max:F.duration,step:.1,onInput:m,class:"time-slider"},null,40,yw),[[e.vModelText,s.value]]),e.createElementVNode("span",bw,e.toDisplayString(w(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:h,disabled:l.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Vf)},null,8,["icon"]),D[2]||(D[2]=e.createTextVNode(" Capture Frame ",-1))],8,ww)]),e.createElementVNode("div",kw,[e.createElementVNode("button",{class:"action-button",onClick:D[1]||(D[1]=E=>F.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:g,disabled:r.value===-1},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Pd)},null,8,["icon"]),D[4]||(D[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,_w)])]))}}),xw=Ve(Ew,[["__scopeId","data-v-336c322c"]]),Sw={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Cw={class:"mb-4"},Vw={class:"space-y-2 max-h-64 overflow-y-auto"},Nw={class:"flex items-center justify-between"},Tw={class:"flex-1"},Mw={class:"font-medium text-gray-900 dark:text-white"},Bw={class:"text-sm text-gray-500 dark:text-gray-400"},Iw={class:"flex items-center space-x-2"},Fw=["onClick"],$w=["onClick"],Dw={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Rw={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Aw={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Lw={class:"space-y-4"},Pw={class:"grid grid-cols-2 gap-4"},Ow={class:"grid grid-cols-2 gap-4"},Uw={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},zw={class:"grid grid-cols-2 gap-3"},jw={class:"flex justify-end space-x-3 mt-6"},Ww=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function l(p){Object.assign(s,p),i.value=p}function c(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const p={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(p.animation={type:s.animationType},s.animationDuration!==void 0&&(p.animation.duration=s.animationDuration),s.animationEasing&&(p.animation.easing=s.animationEasing),p.animation))switch(s.animationType){case"rotate":p.animation.rotation={from:0,to:360};break;case"scale":p.animation.scale={from:.5,to:1};break;case"slide":p.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,p):t("add-overlay",p),c()}function u(p){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",p)}function f(p){const m=Math.floor(p/60),h=Math.floor(p%60);return`${m}:${h.toString().padStart(2,"0")}`}return(p,m)=>(e.openBlock(),e.createElementBlock("div",Sw,[e.createElementVNode("div",Cw,[m[11]||(m[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:m[0]||(m[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"},[...m[10]||(m[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",Vw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.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",Nw,[e.createElementVNode("div",Tw,[e.createElementVNode("div",Mw,e.toDisplayString(h.text.substring(0,30))+e.toDisplayString(h.text.length>30?"...":""),1),e.createElementVNode("div",Bw,e.toDisplayString(f(h.startTime??0))+" - "+e.toDisplayString(f((h.startTime||0)+(h.duration||5))),1)]),e.createElementVNode("div",Iw,[e.createElementVNode("button",{onClick:g=>l(h),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...m[12]||(m[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,Fw),e.createElementVNode("button",{onClick:g=>u(h.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...m[13]||(m[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,$w)])])]))),128)),p.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Dw," No text overlays added yet ")):e.createCommentVNode("",!0)]),o.value||i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(c,["self"])},[e.createElementVNode("div",Rw,[e.createElementVNode("h4",Aw,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Lw,[e.createElementVNode("div",null,[m[14]||(m[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":m[1]||(m[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",Pw,[e.createElementVNode("div",null,[m[15]||(m[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":m[2]||(m[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,[m[16]||(m[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":m[3]||(m[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,[m[18]||(m[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":m[4]||(m[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"},[...m[17]||(m[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",Ow,[e.createElementVNode("div",null,[m[19]||(m[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":m[5]||(m[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,[m[20]||(m[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":m[6]||(m[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,[m[22]||(m[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":m[7]||(m[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"},[...m[21]||(m[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",Uw,[m[26]||(m[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",zw,[e.createElementVNode("div",null,[m[23]||(m[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":m[8]||(m[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,[m[25]||(m[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":m[9]||(m[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"},[...m[24]||(m[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",jw,[e.createElementVNode("button",{onClick:c,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:d,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},e.toDisplayString(i.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),Os=Ve(Ww,[["__scopeId","data-v-f86e688c"]]),Zw={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Hw={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Xw=["onClick"],Gw={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"},Jw={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Kw={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},Yw={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},qw={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"},Qw={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"},e2={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"},t2={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},n2={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},a2={class:"space-y-3"},o2={class:"flex items-center space-x-2"},i2=["disabled"],r2=["disabled"],s2={key:1,class:"mt-4"},l2={class:"space-y-2 max-h-32 overflow-y-auto"},c2={class:"text-sm text-gray-700 dark:text-gray-300"},d2=["onClick"],u2=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(jo.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),l=e.ref("linear"),c=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function d(h){r.value=h}function u(){if(!r.value||!c.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 p(h){o("remove-transition",h)}function m(h){return["fade","wipe","slide","zoom"].some(g=>h.includes(g))}return(h,g)=>(e.openBlock(),e.createElementBlock("div",Zw,[g[9]||(g[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",Hw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,w=>{var F;return e.openBlock(),e.createElementBlock("div",{key:w.type,onClick:D=>d(w),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((F=r.value)==null?void 0:F.type)===w.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",Gw,[m(w.type)?(e.openBlock(),e.createElementBlock("svg",Jw,[w.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Kw)):w.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",Yw)):w.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",qw)):w.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",Qw)):(e.openBlock(),e.createElementBlock("path",e2))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",t2,e.toDisplayString(w.name),1)],10,Xw)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",n2,[g[6]||(g[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",a2,[e.createElementVNode("div",null,[g[3]||(g[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",o2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=w=>s.value=w),type:"range",min:"0.1",max:"3",step:"0.1",class:"flex-1"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[1]||(g[1]=w=>s.value=w),type:"number",min:"0.1",max:"3",step:"0.1",class:"w-16 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[g[5]||(g[5]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[2]||(g[2]=w=>l.value=w),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...g[4]||(g[4]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("button",{onClick:u,disabled:!c.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",c.value?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])}," Apply Transition ",10,i2),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,r2)])])):e.createCommentVNode("",!0),h.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",s2,[g[8]||(g[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",l2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.appliedTransitions,(w,F)=>(e.openBlock(),e.createElementBlock("div",{key:F,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",c2,e.toDisplayString(w.name)+" ("+e.toDisplayString(w.duration)+"s) ",1),e.createElementVNode("button",{onClick:D=>p(F),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,d2)]))),128))])])):e.createCommentVNode("",!0),g[10]||(g[10]=e.createElementVNode("div",{class:"mt-4 text-xs text-gray-500 dark:text-gray-400"},[e.createElementVNode("p",null,"Select clips in the timeline, then choose a transition to apply between them.")],-1))]))}}),Us=Ve(u2,[["__scopeId","data-v-ffcc612d"]]),m2={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},p2={class:"mb-4"},f2={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},h2={class:"flex items-center justify-between mb-2"},v2={class:"text-sm text-gray-600 dark:text-gray-400"},g2={class:"flex items-center space-x-2"},y2={class:"space-y-3 max-h-64 overflow-y-auto"},b2={class:"flex items-center justify-between mb-2"},w2={class:"font-medium text-gray-900 dark:text-white"},k2={class:"flex items-center space-x-2"},_2=["onClick","title"],E2={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},x2={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},S2=["onClick"],C2=["onClick"],V2={class:"flex items-center space-x-2"},N2={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},T2=["value","onInput","disabled"],M2={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},B2={key:0,class:"ml-2"},I2={key:1,class:"ml-2"},F2={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},$2={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},D2={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},R2={class:"space-y-4"},A2={class:"space-y-2"},L2={class:"flex items-center"},P2={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},O2={class:"grid grid-cols-2 gap-4"},U2={class:"grid grid-cols-2 gap-4"},z2={class:"flex items-center"},j2={class:"flex justify-end space-x-3 mt-6"},W2=["disabled"],Z2=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(E){const v=E.target;v.files&&v.files[0]&&(c.sourceFile=v.files[0],c.name=c.name||v.files[0].name.replace(/\.[^/.]+$/,""))}function f(E){Object.assign(c,E),r.value=E}function p(){i.value=!1,r.value=null,Object.assign(c,l())}function m(){if(!d.value)return;const E={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(E.duration=c.duration),c.fadeIn>0&&(E.fadeIn=c.fadeIn),c.fadeOut>0&&(E.fadeOut=c.fadeOut),r.value?o("update-track",r.value.id,E):o("add-track",E),p()}function h(E){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",E)}function g(E,v){const S=v.target,C=parseFloat(S.value);o("update-volume",E.id,C)}function w(E){o("toggle-mute",E.id,!E.muted)}function F(){o("update-master-volume",s.value)}function D(E){const v=Math.floor(E/60),S=Math.floor(E%60);return`${v}:${S.toString().padStart(2,"0")}`}return(E,v)=>(e.openBlock(),e.createElementBlock("div",m2,[e.createElementVNode("div",p2,[v[11]||(v[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:v[0]||(v[0]=S=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...v[10]||(v[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",f2,[e.createElementVNode("div",h2,[v[12]||(v[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",v2,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",g2,[v[13]||(v[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":v[1]||(v[1]=S=>s.value=S),onInput:F,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),v[14]||(v[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",y2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.audioLayers,S=>(e.openBlock(),e.createElementBlock("div",{key:S.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",b2,[e.createElementVNode("div",w2,e.toDisplayString(S.name),1),e.createElementVNode("div",k2,[e.createElementVNode("button",{onClick:C=>w(S),class:e.normalizeClass(["p-1 rounded",S.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:S.muted?"Unmute":"Mute"},[S.muted?(e.openBlock(),e.createElementBlock("svg",x2,[...v[16]||(v[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",E2,[...v[15]||(v[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,_2),e.createElementVNode("button",{onClick:C=>f(S),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...v[17]||(v[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,S2),e.createElementVNode("button",{onClick:C=>h(S.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...v[18]||(v[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,C2)])]),e.createElementVNode("div",V2,[e.createElementVNode("span",N2,e.toDisplayString(Math.round((S.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:S.volume||1,onInput:C=>g(S,C),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:S.muted},null,40,T2)]),e.createElementVNode("div",M2,[e.createTextVNode(e.toDisplayString(D(S.startTime||0))+" - "+e.toDisplayString(D((S.startTime||0)+(S.duration||0)))+" ",1),S.fadeIn?(e.openBlock(),e.createElementBlock("span",B2,"Fade In: "+e.toDisplayString(S.fadeIn)+"s",1)):e.createCommentVNode("",!0),S.fadeOut?(e.openBlock(),e.createElementBlock("span",I2,"Fade Out: "+e.toDisplayString(S.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),E.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",F2," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.value||r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(p,["self"])},[e.createElementVNode("div",$2,[e.createElementVNode("h4",D2,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",R2,[e.createElementVNode("div",null,[v[20]||(v[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",A2,[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",L2,[v[19]||(v[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":v[2]||(v[2]=S=>c.sourceUrl=S),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[v[21]||(v[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":v[3]||(v[3]=S=>c.name=S),type:"text",placeholder:"Background Music",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",P2," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[4]||(v[4]=S=>c.volume=S),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,c.volume,void 0,{number:!0}]])]),e.createElementVNode("div",O2,[e.createElementVNode("div",null,[v[22]||(v[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":v[5]||(v[5]=S=>c.startTime=S),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[v[23]||(v[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":v[6]||(v[6]=S=>c.duration=S),type:"number",min:"0.1",step:"0.1",placeholder:"Auto",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",U2,[e.createElementVNode("div",null,[v[24]||(v[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":v[7]||(v[7]=S=>c.fadeIn=S),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[v[25]||(v[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":v[8]||(v[8]=S=>c.fadeOut=S),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",z2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[9]||(v[9]=S=>c.loop=S),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),v[26]||(v[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",j2,[e.createElementVNode("button",{onClick:p,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:m,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(r.value?"Save":"Add"),11,W2)])])])):e.createCommentVNode("",!0)]))}}),zs=Ve(Z2,[["__scopeId","data-v-593719ac"]]);function et(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function Rc(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let Ac=!1;function H2(){if(Ac)return;Ac=!0;const a=`
|
|
34
|
-
/* ── MobileVideoFilterPanel — global (not scoped) ── */
|
|
35
|
-
.mvfp {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* ── Horizontal scroll rows ── */
|
|
44
|
-
.mvfp-row {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 8px;
|
|
47
|
-
padding: 8px 12px;
|
|
48
|
-
overflow-x: auto;
|
|
49
|
-
-webkit-overflow-scrolling: touch;
|
|
50
|
-
scrollbar-width: none;
|
|
51
|
-
flex-shrink: 0;
|
|
52
|
-
}
|
|
53
|
-
.mvfp-row::-webkit-scrollbar { display: none; }
|
|
54
|
-
|
|
55
|
-
/* ── Category chips ── */
|
|
56
|
-
.mvfp-cat {
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
gap: 6px;
|
|
60
|
-
min-height: 36px;
|
|
61
|
-
padding: 8px 14px;
|
|
62
|
-
border-radius: 20px;
|
|
63
|
-
border: 1.5px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
64
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
65
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
66
|
-
font-size: 13px;
|
|
67
|
-
font-weight: 500;
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
transition: all 0.15s;
|
|
72
|
-
-webkit-tap-highlight-color: transparent;
|
|
73
|
-
}
|
|
74
|
-
.mvfp-cat.active {
|
|
75
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
76
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
77
|
-
color: #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* ── Filter cards ── */
|
|
81
|
-
.mvfp-filter {
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-direction: column;
|
|
84
|
-
align-items: center;
|
|
85
|
-
justify-content: center;
|
|
86
|
-
min-width: 72px;
|
|
87
|
-
max-width: 100px;
|
|
88
|
-
min-height: 48px;
|
|
89
|
-
padding: 10px 12px;
|
|
90
|
-
border-radius: 12px;
|
|
91
|
-
border: 2px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
92
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
93
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
text-align: center;
|
|
96
|
-
line-height: 1.3;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
flex-shrink: 0;
|
|
99
|
-
position: relative;
|
|
100
|
-
transition: all 0.15s;
|
|
101
|
-
-webkit-tap-highlight-color: transparent;
|
|
102
|
-
}
|
|
103
|
-
.mvfp-filter.active {
|
|
104
|
-
border-color: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
105
|
-
}
|
|
106
|
-
.mvfp-filter.selected {
|
|
107
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.15);
|
|
108
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
109
|
-
}
|
|
110
|
-
.mvfp-filter .mvfp-check {
|
|
111
|
-
position: absolute;
|
|
112
|
-
top: -5px;
|
|
113
|
-
right: -5px;
|
|
114
|
-
width: 18px;
|
|
115
|
-
height: 18px;
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
background: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
118
|
-
color: #fff;
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
font-size: 11px;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* ── Active filter chips ── */
|
|
127
|
-
.mvfp-active-row {
|
|
128
|
-
display: flex;
|
|
129
|
-
gap: 6px;
|
|
130
|
-
padding: 6px 12px;
|
|
131
|
-
overflow-x: auto;
|
|
132
|
-
-webkit-overflow-scrolling: touch;
|
|
133
|
-
scrollbar-width: none;
|
|
134
|
-
flex-shrink: 0;
|
|
135
|
-
}
|
|
136
|
-
.mvfp-active-row::-webkit-scrollbar { display: none; }
|
|
137
|
-
|
|
138
|
-
.mvfp-achip {
|
|
139
|
-
display: flex;
|
|
140
|
-
align-items: center;
|
|
141
|
-
gap: 6px;
|
|
142
|
-
padding: 6px 10px 6px 12px;
|
|
143
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.12);
|
|
144
|
-
border: 1px solid var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
145
|
-
border-radius: 20px;
|
|
146
|
-
white-space: nowrap;
|
|
147
|
-
flex-shrink: 0;
|
|
148
|
-
font-size: 12px;
|
|
149
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
transition: all 0.15s;
|
|
152
|
-
}
|
|
153
|
-
.mvfp-achip.selected {
|
|
154
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
155
|
-
color: #fff;
|
|
156
|
-
}
|
|
157
|
-
.mvfp-achip-x {
|
|
158
|
-
width: 20px;
|
|
159
|
-
height: 20px;
|
|
160
|
-
border-radius: 50%;
|
|
161
|
-
border: 1.5px solid currentColor;
|
|
162
|
-
background: transparent;
|
|
163
|
-
color: inherit;
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
padding: 0;
|
|
169
|
-
opacity: 0.7;
|
|
170
|
-
flex-shrink: 0;
|
|
171
|
-
}
|
|
172
|
-
.mvfp-achip-x:hover, .mvfp-achip-x:active {
|
|
173
|
-
background: var(--ion-color-danger, #ef4444);
|
|
174
|
-
border-color: var(--ion-color-danger, #ef4444);
|
|
175
|
-
color: #fff;
|
|
176
|
-
opacity: 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.mvfp-placeholder {
|
|
180
|
-
font-size: 12px;
|
|
181
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
182
|
-
padding: 6px 12px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ── Drawer ── */
|
|
186
|
-
.mvfp-drawer {
|
|
187
|
-
position: absolute;
|
|
188
|
-
bottom: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
right: 0;
|
|
191
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
192
|
-
border-top: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
193
|
-
transform: translateY(100%);
|
|
194
|
-
z-index: 20;
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
border-radius: 14px 14px 0 0;
|
|
199
|
-
}
|
|
200
|
-
.mvfp-drawer-hdr {
|
|
201
|
-
display: flex;
|
|
202
|
-
justify-content: space-between;
|
|
203
|
-
align-items: center;
|
|
204
|
-
padding: 8px 14px;
|
|
205
|
-
border-bottom: 1px solid var(--app-border, var(--ion-color-step-200, #333));
|
|
206
|
-
flex-shrink: 0;
|
|
207
|
-
}
|
|
208
|
-
.mvfp-drawer-title {
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
font-size: 14px;
|
|
211
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
212
|
-
}
|
|
213
|
-
.mvfp-drawer-actions {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
gap: 10px;
|
|
217
|
-
}
|
|
218
|
-
.mvfp-drawer-btn {
|
|
219
|
-
background: none;
|
|
220
|
-
border: none;
|
|
221
|
-
font-size: 13px;
|
|
222
|
-
font-weight: 500;
|
|
223
|
-
cursor: pointer;
|
|
224
|
-
padding: 4px 6px;
|
|
225
|
-
color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
226
|
-
}
|
|
227
|
-
.mvfp-drawer-btn.danger {
|
|
228
|
-
color: var(--ion-color-danger, #ef4444);
|
|
229
|
-
}
|
|
230
|
-
.mvfp-drawer-close {
|
|
231
|
-
width: 28px;
|
|
232
|
-
height: 28px;
|
|
233
|
-
border: none;
|
|
234
|
-
border-radius: 50%;
|
|
235
|
-
background: var(--app-surface-sunken, var(--ion-color-step-100, #2a2a2a));
|
|
236
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
justify-content: center;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
padding: 0;
|
|
242
|
-
}
|
|
243
|
-
.mvfp-drawer-body {
|
|
244
|
-
flex: 1 1 auto;
|
|
245
|
-
overflow-y: auto;
|
|
246
|
-
-webkit-overflow-scrolling: touch;
|
|
247
|
-
padding: 10px 14px 16px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* ── Drawer slider controls ── */
|
|
251
|
-
.mvfp-ctl {
|
|
252
|
-
margin-bottom: 12px;
|
|
253
|
-
}
|
|
254
|
-
.mvfp-ctl-label {
|
|
255
|
-
display: block;
|
|
256
|
-
font-size: 11px;
|
|
257
|
-
font-weight: 600;
|
|
258
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
259
|
-
text-transform: uppercase;
|
|
260
|
-
letter-spacing: 0.5px;
|
|
261
|
-
margin-bottom: 4px;
|
|
262
|
-
}
|
|
263
|
-
.mvfp-slider-row {
|
|
264
|
-
display: flex;
|
|
265
|
-
align-items: center;
|
|
266
|
-
gap: 10px;
|
|
267
|
-
}
|
|
268
|
-
.mvfp-range {
|
|
269
|
-
flex: 1;
|
|
270
|
-
height: 6px;
|
|
271
|
-
-webkit-appearance: none;
|
|
272
|
-
appearance: none;
|
|
273
|
-
background: var(--app-border, var(--ion-color-step-200, #333));
|
|
274
|
-
border-radius: 3px;
|
|
275
|
-
outline: none;
|
|
276
|
-
}
|
|
277
|
-
.mvfp-range::-webkit-slider-thumb {
|
|
278
|
-
-webkit-appearance: none;
|
|
279
|
-
width: 22px;
|
|
280
|
-
height: 22px;
|
|
281
|
-
border-radius: 50%;
|
|
282
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
border: 2px solid #fff;
|
|
285
|
-
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
|
286
|
-
}
|
|
287
|
-
.mvfp-range-val {
|
|
288
|
-
min-width: 3rem;
|
|
289
|
-
text-align: right;
|
|
290
|
-
font-size: 12px;
|
|
291
|
-
font-weight: 500;
|
|
292
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
293
|
-
}
|
|
294
|
-
.mvfp-toggle-row {
|
|
295
|
-
display: flex;
|
|
296
|
-
align-items: center;
|
|
297
|
-
justify-content: space-between;
|
|
298
|
-
gap: 10px;
|
|
299
|
-
}
|
|
300
|
-
.mvfp-color-row {
|
|
301
|
-
display: flex;
|
|
302
|
-
align-items: center;
|
|
303
|
-
justify-content: space-between;
|
|
304
|
-
gap: 10px;
|
|
305
|
-
}
|
|
306
|
-
.mvfp-color-input {
|
|
307
|
-
width: 36px;
|
|
308
|
-
height: 36px;
|
|
309
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
310
|
-
border-radius: 8px;
|
|
311
|
-
padding: 2px;
|
|
312
|
-
cursor: pointer;
|
|
313
|
-
background: transparent;
|
|
314
|
-
}
|
|
315
|
-
.mvfp-select-row {
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: space-between;
|
|
319
|
-
gap: 10px;
|
|
320
|
-
}
|
|
321
|
-
.mvfp-select {
|
|
322
|
-
padding: 6px 10px;
|
|
323
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
324
|
-
border-radius: 8px;
|
|
325
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
326
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
327
|
-
font-size: 13px;
|
|
328
|
-
}
|
|
329
|
-
.mvfp-no-params {
|
|
330
|
-
text-align: center;
|
|
331
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
332
|
-
font-style: italic;
|
|
333
|
-
font-size: 13px;
|
|
334
|
-
padding: 12px 0;
|
|
335
|
-
}
|
|
336
|
-
`,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class X2{constructor({filters:n=[],callbacks:t={}}){H2(),this._filters=n,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(n){return this._root=et("div",{className:"mvfp"}),this._catRow=et("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=et("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=et("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=et("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=et("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=et("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(et("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(et("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(c=>c.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=et("div",{className:`mvfp-achip${i?" selected":""}`}),s=et("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),l=et("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:c=>{c.stopPropagation(),this._removeFilter(t)}});l.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(s),r.appendChild(l),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=et("div",{className:"mvfp-drawer"});const n=et("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=et("span",{className:"mvfp-drawer-title"},"Filter");const t=et("div",{className:"mvfp-drawer-actions"});t.appendChild(et("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(et("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=et("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=et("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(et("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=et("div",{className:"mvfp-ctl"}),l=et("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=et("div",{className:"mvfp-slider-row"}),u=et("span",{className:"mvfp-range-val"},Rc(r)),f=et("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:p=>{var h,g;const m=parseFloat(p.target.value);u.textContent=Rc(m),(g=(h=this._cb).onUpdateParam)==null||g.call(h,n.id,i.id,m)}});d.appendChild(f),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=et("div",{className:"mvfp-toggle-row"}),u=et("input",{type:"checkbox",checked:r?"checked":void 0,onChange:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=et("div",{className:"mvfp-color-row"}),u=et("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=et("div",{className:"mvfp-select-row"}),u=et("select",{className:"mvfp-select",onChange:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.value)}});for(const f of i.options||[]){const p=et("option",{value:f.value},f.label||String(f.value));f.value===r&&(p.selected=!0),u.appendChild(p)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}const G2=[200,500,1e3];function J2(a){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[a??""]??[1920,1080]}function Lc(a){if(!a)return null;const n=a.duration;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(n&&typeof n=="object"&&"value"in n){const t=n.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null}function K2(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Pc(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-CUlCdDi7.cjs"))}function Oc(a,n=0){var r;const t=a.timeline[0],o=t?Math.max(0,t.sourceIn):0,i=(t==null?void 0:t.sourceOut)??((r=a.source)==null?void 0:r.duration)??n;return Math.max(0,i-o)}function Tu(a){let n=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await Pc();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,s)=>{var m,h,g,w;const l=i.timeline[0],c=l?Math.max(0,l.sourceIn):0,d=l?l.sourceOut:void 0,[u,f]=J2((r==null?void 0:r.quality)??((m=i.output)==null?void 0:m.quality)),p=((h=i.output)==null?void 0:h.fps)||30;a.setPlaying(!1),a.forcePixiPreview.value=!0,await e.nextTick();try{let F=!1;for(const z of G2){await K2(z);const P=a.getPreviewRef();if(!(!P||typeof P.captureFrameAt!="function")){if(typeof P.ensureReadyForCapture=="function"){if(F=await P.ensureReadyForCapture(),F)break;continue}F=!0;break}}const D=a.getPreviewRef();if(!D||typeof D.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!F)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:E,isWebCodecsSupported:v}=await Pc();if(!v())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");n=new AbortController;const S={width:u,height:f,fps:p,trimStart:c,signal:n.signal};d!==void 0&&(S.trimEnd=d),s&&(S.onProgress=s);const C=a.getSourceUrl();C!==""&&(S.sourceUrl=C);const V=Lc(D)??((g=i.source)==null?void 0:g.duration)??d??0,x=await E({captureFrameAt:z=>{var P;return((P=D.captureFrameAt)==null?void 0:P.call(D,z))??Promise.resolve(null)},duration:{value:V}},S),N=new File([x],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),j=Lc(D),_=((w=i.source)==null?void 0:w.duration)??0,T=Math.max(0,(d??j??_)-c);return{file:N,recipe:i,meta:{duration:T,width:u,height:f,format:"mp4",sizeBytes:N.size,size_bytes:N.size}}}finally{a.forcePixiPreview.value=!1,n=null}},cancelClientExport:()=>{n==null||n.abort(),n=null},resetClientExport:()=>{n=null}}}const no="default-video-track",oa="default-media-source";function Mu(a){var r,s;const n=q2(a),t=Q2(a),o=ek(a.timeline,((r=t[0])==null?void 0:r.id)??no,((s=n[0])==null?void 0:s.id)??oa),i={version:a.version,source:{...a.source},mediaSources:n,tracks:tk(t,o),clips:o,markers:a.markers?a.markers.map(l=>({...l})):[],transitions:a.transitions?a.transitions.map(Fu):[],filters:a.filters.map(l=>({...l,params:{...l.params}})),audio:{...a.audio},output:{...a.output}};return typeof a.duration=="number"&&(i.duration=a.duration),a.snapSettings&&(i.snapSettings={...a.snapSettings}),a.textOverlays&&(i.textOverlays=[...a.textOverlays]),a.captionTracks&&(i.captionTracks=a.captionTracks.map($u)),a.visualLayers&&(i.visualLayers=a.visualLayers.map(Du)),a.audioTracks&&(i.audioTracks=[...a.audioTracks]),a.posterFrame&&(i.posterFrame=a.posterFrame),a.metadata&&(i.metadata={...a.metadata}),i}function Y2(a){const n={version:"1.0",source:{...a.source},timeline:a.clips.map(t=>({...t})),mediaSources:a.mediaSources.map(Bu),tracks:a.tracks.map(Iu),markers:a.markers.map(t=>({...t})),transitions:a.transitions.map(Fu),filters:a.filters.map(t=>({...t,params:{...t.params}})),audio:{...a.audio},output:{...a.output}};return typeof a.duration=="number"&&(n.duration=a.duration),a.snapSettings&&(n.snapSettings={...a.snapSettings}),a.textOverlays&&(n.textOverlays=[...a.textOverlays]),a.captionTracks&&(n.captionTracks=a.captionTracks.map($u)),a.visualLayers&&(n.visualLayers=a.visualLayers.map(Du)),a.audioTracks&&(n.audioTracks=[...a.audioTracks]),a.posterFrame&&(n.posterFrame=a.posterFrame),a.metadata&&(n.metadata={...a.metadata}),n}function q2(a){var t,o;if(a.mediaSources&&a.mediaSources.length>0)return a.mediaSources.map(Bu);const n={id:((t=a.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??oa,type:"media",mediaUuid:a.source.media_uuid,duration:a.source.duration,width:a.source.original_width,height:a.source.original_height};return(o=a.metadata)!=null&&o.source_url&&(n.url=a.metadata.source_url),[n]}function Q2(a){var n;return a.tracks&&a.tracks.length>0?a.tracks.map(Iu):[{id:((n=a.timeline.find(t=>t.trackId))==null?void 0:n.trackId)??no,type:"video",name:"Video",order:0}]}function ek(a,n,t){return a.map(o=>{const i={...o,trackId:o.trackId??n,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 tk(a,n){return a.map(t=>{const o=n.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:o}})}function Bu(a){const n={...a};return a.metadata&&(n.metadata={...a.metadata}),n}function Iu(a){const n={...a};return a.clipIds&&(n.clipIds=[...a.clipIds]),n}function Fu(a){const n={...a};return a.params&&(n.params={...a.params}),n}function $u(a){return{...a,segments:a.segments.map(t=>{const o={...t};return t.words&&(o.words=t.words.map(i=>({...i}))),o})}}function Du(a){return{...a,transform:{...a.transform,position:{...a.transform.position},anchor:{...a.transform.anchor},scale:{...a.transform.scale}},keyframes:a.keyframes?a.keyframes.map(n=>({...n})):void 0}}const Ru="video-project-draft-snapshot:v1",js="mediables:video-project-drafts",nk=(a,n={})=>{var p,m;const t=Xn(n.now)??Date.now(),o=Xn(n.createdAt)??t,i=Xn(n.updatedAt)??t,r=fk(a),s={id:vn(n.id)??yk(i),payloadKind:r,createdAt:new Date(o).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:n.deviceKind??"unknown"},l=vn(n.projectId),c=vn(n.sourceMediaUuid)??vn(a.source.media_uuid),d=Ws(n.durationSeconds)??hk(a),u=vn(n.editorVersion)??vn((p=a.metadata)==null?void 0:p.editor_version),f=vn(n.title)??vn((m=a.metadata)==null?void 0:m.title);return l!==null&&(s.projectId=l),c!==null&&(s.sourceMediaUuid=c),d!==null&&(s.durationSeconds=d),u!==null&&(s.editorVersion=u),f!==null&&(s.title=f),n.saveReason!==void 0&&(s.saveReason=n.saveReason),{schemaVersion:Ru,metadata:s,payload:a}},Au=(a,n=js)=>{const t=vn(n)??js,o=Zc(a.metadata.projectId??"unsaved-project"),i=Zc(a.metadata.id);return`${t}:${o}:${i}`},ak=a=>JSON.stringify(a),ok=a=>{if(typeof a!="string"||a.trim().length===0)return null;try{const n=JSON.parse(a);return uk(n)?n:null}catch{return null}},ik=a=>{const n=[];for(const t of a){const o=vn(t.key),i=ok(t.value);o===null||i===null||n.push({key:o,snapshot:i})}return Lo(n)},rk=(a,n)=>{const t=gk(n.maxCount),o=Xn(n.now)??Date.now(),i=zu(n.maxAgeMs),r=[],s=[];let l=0;for(const c of Lo(a)){if(!Ou(c,n.projectId)){r.push(c);continue}if(Uu(c.snapshot,o,i)||l>=t){s.push(c);continue}r.push(c),l+=1}return{retained:Lo(r),removed:Lo(s)}},sk=(a,n={})=>{const t={key:Au(a),snapshot:a};if(!Ou(t,n.projectId))return!1;const o=Xn(n.now)??Date.now(),i=zu(n.maxAgeMs);if(Uu(a,o,i))return!1;const r=n.savedAt===null?null:Xn(n.savedAt);return r===null?!0:Ki(a)>r},lk=(a,n={})=>Lo(a).filter(t=>sk(t.snapshot,n)),ck=(a,n,t={})=>{const o=lk(a,t);if(n==="mobile"){const i=o[0]??null;return i===null?[]:[i]}return o},dk=async(a,n,t=Au(n))=>(await a.setItem(t,ak(n)),{key:t,snapshot:n}),Uc=async(a,n=js)=>{const t=await a.listKeys(n),o=[];for(const i of t)o.push({key:i,value:await a.getItem(i)});return ik(o)},zc=async(a,n)=>{for(const t of n)await a.removeItem(t.key)},uk=a=>!Gn(a)||a.schemaVersion!==Ru||!mk(a.metadata)?!1:a.metadata.payloadKind==="project"?Lu(a.payload):pk(a.payload),mk=a=>Gn(a)?Sl(a.id)&&wk(a.payloadKind)&&Wc(a.createdAt)&&Wc(a.updatedAt)&&kk(a.deviceKind)&&ki(a.projectId)&&ki(a.sourceMediaUuid)&&bk(a.durationSeconds)&&ki(a.editorVersion)&&ki(a.title)&&_k(a.saveReason):!1,pk=a=>Gn(a)?a.version==="1.0"&&Pu(a.source)&&Array.isArray(a.timeline)&&Array.isArray(a.filters)&&Gn(a.audio)&&Gn(a.output):!1,Lu=a=>Gn(a)?a.version==="1.0"&&Pu(a.source)&&Array.isArray(a.mediaSources)&&Array.isArray(a.tracks)&&Array.isArray(a.clips)&&Array.isArray(a.markers)&&Array.isArray(a.filters)&&Gn(a.audio)&&Gn(a.output):!1,Pu=a=>Gn(a)?Sl(a.media_uuid)&&Po(a.duration)&&Po(a.original_width)&&Po(a.original_height):!1,fk=a=>Lu(a)?"project":"recipe",hk=a=>Ws(a.duration)??Ws(a.source.duration),Ou=(a,n)=>{const t=vn(n);return t===null?!0:a.snapshot.metadata.projectId===t},Uu=(a,n,t)=>t===null?!1:n-Ki(a)>t,Lo=a=>[...a].sort(vk),vk=(a,n)=>{const t=Ki(n.snapshot)-Ki(a.snapshot);if(t!==0)return t;const o=jc(n.snapshot)-jc(a.snapshot);return o!==0?o:a.snapshot.metadata.id.localeCompare(n.snapshot.metadata.id)},Ki=a=>Xn(a.metadata.updatedAt)??0,jc=a=>Xn(a.metadata.createdAt)??0,gk=a=>!Number.isFinite(a)||a<0?0:Math.floor(a),zu=a=>a===void 0||!Number.isFinite(a)||a<0?null:Math.floor(a),Xn=a=>{if(a==null)return null;if(a instanceof Date)return Number.isFinite(a.getTime())?a.getTime():null;if(typeof a=="number")return Number.isFinite(a)?a:null;const n=a.trim();if(n.length===0)return null;const t=Date.parse(n);return Number.isFinite(t)?t:null},Wc=a=>typeof a=="string"&&Xn(a)!==null,yk=a=>{var t;const n=typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,12);return`draft-${a}-${n}`},Zc=a=>encodeURIComponent(a.trim()),vn=a=>{if(typeof a!="string")return null;const n=a.trim();return n.length>0?n:null},Sl=a=>vn(a)!==null,ki=a=>a===void 0||Sl(a),Ws=a=>{if(!Po(a))return null;const n=Number(a.toFixed(6));return Object.is(n,-0)?0:n},Po=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0,bk=a=>a===void 0||Po(a),wk=a=>a==="recipe"||a==="project",kk=a=>a==="desktop"||a==="mobile"||a==="tablet"||a==="unknown",_k=a=>a===void 0||a==="autosave"||a==="manual"||a==="before-export"||a==="before-close",Gn=a=>typeof a=="object"&&a!==null&&!Array.isArray(a),Ek=1,xk="master",Wo=-60,Zs=12,Cl=0,ia=-90,Yi=6,Sk=4,ju=8;function Wu(){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:ju}}}function Ck(a,n=Wu()){return Xs(n[a])}function Zu(a){return Number.isNaN(a)?Cl:a<=0||a===Number.NEGATIVE_INFINITY?Wo:Zo(20*Math.log10(a))}function Hs(a){const n=Zo(a);return n<=Wo?0:sa(Math.pow(10,n/20),6)}function Zo(a){return Number.isNaN(a)?Cl:a===Number.NEGATIVE_INFINITY?Wo:a===Number.POSITIVE_INFINITY?Zs:sa(ni(a,Wo,Zs),3)}function Hu(a){return Number.isFinite(a)?sa(ni(a,-1,1),3):0}function Vk(a,n=!1){const t=a.some(o=>o.controls.solo);return a.map(o=>{const i=o.controls.muted,r=t&&!o.controls.solo,s=n||i||r,l=s?0:o.controls.fader.linearGain;return{trackId:o.id,soloed:o.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:n,effectivelyMuted:s,audible:!s,effectiveGainLinear:l}})}function Nk(a,n={}){const t=Pk(n.effectSlotCount),o=new Set;return{schemaVersion:Ek,capabilities:n.capabilities?jk(n.capabilities):Wu(),tracks:a.map((i,r)=>Mk(i,r,t,o)),master:Bk(n.master,t)}}function Xu(a){const n=Zo(a);return{valueDb:n,minDb:Wo,maxDb:Zs,unityDb:Cl,linearGain:Hs(n)}}function Tk(a,n="constant-power"){return{value:Hu(a),mode:n}}function Gu(a=ia,n=ia,t=a){const o=os(a),i=os(n),r=os(t);return{peakDb:o,rmsDb:i,peakHoldDb:r,clipping:o>=0||r>=0}}function Ju(a){const n=qu(a);return{id:`empty-effect-slot-${n}`,index:n,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function Mk(a,n,t,o){const i=Yu(a.id),s={id:Lk(i??`legacy-audio-track-${n+1}`,o),kind:"legacy-url",name:Dk(a.name,n),order:n,source:Ik(a.source),controls:{fader:Xu(a.faderDb??Zu(a.volume??1)),pan:Tk(a.pan??0),muted:a.muted??!1,solo:a.solo??!1,meter:Gu(a.peakDb,a.rmsDb,a.peakHoldDb)},timeline:Fk(a),effectSlots:Ku(a.effectSlots,t)};return i!==void 0&&(s.legacyTrackId=i),s}function Bk(a,n){return{id:xk,name:Rk(a==null?void 0:a.name),fader:Xu((a==null?void 0:a.faderDb)??Zu((a==null?void 0:a.volume)??1)),muted:(a==null?void 0:a.muted)??!1,meter:Gu(a==null?void 0:a.peakDb,a==null?void 0:a.rmsDb,a==null?void 0:a.peakHoldDb),effectSlots:Ku(a==null?void 0:a.effectSlots,n)}}function Ik(a){const n=a.trim();return n===""?{type:"missing"}:{type:"url",url:n}}function Fk(a){const n={startTime:Uk(a.startTime??0),loop:a.loop??!1},t=Ok(a.duration);t!==void 0&&(n.duration=t);const o=Hc(a.fadeIn);o!==void 0&&(n.fadeIn=o);const i=Hc(a.fadeOut);return i!==void 0&&(n.fadeOut=i),n}function Ku(a,n){const t=new Map;for(const o of a??[]){const i=$k(o,n);t.set(i.index,i)}return Array.from({length:n},(o,i)=>t.get(i)??Ju(i))}function $k(a,n){const t=qu(a.index),o=n>0?Math.min(t,n-1):0,i=a.kind;return i==="empty"?Ju(o):{id:Yu(a.id)??`${i}-effect-slot-${o}`,index:o,kind:i,label:Ak(a.label,i),enabled:a.enabled,bypassed:a.bypassed,wetMix:zk(a.wetMix),parameters:{...a.parameters}}}function Dk(a,n){const t=a==null?void 0:a.trim();return t&&t!==""?t:`Audio ${n+1}`}function Rk(a){const n=a==null?void 0:a.trim();return n&&n!==""?n:"Master"}function Ak(a,n){const t=a.trim();return t!==""?t:n}function Lk(a,n){if(!n.has(a))return n.add(a),a;let t=2,o=`${a}-${t}`;for(;n.has(o);)t+=1,o=`${a}-${t}`;return n.add(o),o}function Yu(a){const n=a==null?void 0:a.trim();if(!(!n||n===""))return n}function Pk(a){return a===void 0||!Number.isFinite(a)?Sk:Math.trunc(ni(a,0,ju))}function qu(a){return!Number.isFinite(a)||a<0?0:Math.trunc(a)}function Ok(a){if(!(a===void 0||!Number.isFinite(a)||a<=0))return sa(a,3)}function Hc(a){if(!(a===void 0||!Number.isFinite(a)||a<0))return sa(a,3)}function Uk(a){return!Number.isFinite(a)||a<0?0:sa(a,3)}function zk(a){return Number.isFinite(a)?sa(ni(a,0,1),3):1}function os(a){return Number.isNaN(a)||a===Number.NEGATIVE_INFINITY?ia:a===Number.POSITIVE_INFINITY?Yi:sa(ni(a,ia,Yi),3)}function jk(a){return{mobile:Xs(a.mobile),desktop:Xs(a.desktop)}}function Xs(a){return{...a}}function ni(a,n,t){return Math.min(t,Math.max(n,a))}function sa(a,n){const t=10**n;return Math.round(a*t)/t}const Wk=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,Zk=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,Hk="srt-cue";class ra extends Error{constructor(n,t,o={}){super(t),this.name="CaptionSrtError",this.code=n,this.context=o}}function Xk(a,n={}){var s,l;const t=Gk(n.idPrefix),o=a.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
337
|
-
`).split(`
|
|
338
|
-
`),i=[];let r=0;for(;r<o.length;){for(;r<o.length&&Yc(o[r]);)r+=1;if(r>=o.length)break;const c=r+1,d=Jk(((s=o[r])==null?void 0:s.trim())??"",c);if(r+=1,r>=o.length)throw new ra("missing-timing",`Cue ${d} is missing its timing line.`,{cueIndex:i.length,cueNumber:d,lineNumber:c});const u=r+1,f=Kk(((l=o[r])==null?void 0:l.trim())??"",d,u);r+=1;const p=[];for(;r<o.length&&!Yc(o[r]);)p.push(o[r]??""),r+=1;i.push({cueNumber:d,id:`${t}-${i.length+1}`,startTime:f.startTime,endTime:f.endTime,text:p.join(`
|
|
339
|
-
`)})}return Qu(i),i}function Xc(a){return Qu(a),a.length===0?"":`${a.map((n,t)=>qk(n,t+1)).join(`
|
|
340
|
-
|
|
341
|
-
`)}
|
|
342
|
-
`}function Qu(a){const n=a.map((t,o)=>{const i=Kc(t,o),r=Gs(t.startTime,"startTime",i),s=Gs(t.endTime,"endTime",i);if(s<=r)throw new ra("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<n.length;t+=1){const o=n[t-1],i=n[t];if(!(o===void 0||i===void 0)&&i.startMilliseconds<o.endMilliseconds)throw new ra("overlapping-cues",`Caption cue "${i.cue.id}" overlaps cue "${o.cue.id}".`,Kc(i.cue,i.cueIndex))}}function Gc(a){const n=Gs(a,"timestamp",{}),t=Math.floor(n/36e5),o=Math.floor(n%36e5/6e4),i=Math.floor(n%6e4/1e3),r=n%1e3;return[t.toString().padStart(2,"0"),o.toString().padStart(2,"0"),i.toString().padStart(2,"0")].join(":")+`,${r.toString().padStart(3,"0")}`}function Gk(a){return a===void 0||a.trim()===""?Hk:a.trim()}function Jk(a,n){if(!/^[1-9]\d*$/.test(a))throw new ra("invalid-cue-number",`Invalid SRT cue number at line ${n}.`,{lineNumber:n});return Number.parseInt(a,10)}function Kk(a,n,t){const o=Wk.exec(a),i=o==null?void 0:o[1],r=o==null?void 0:o[2];if(i===void 0||r===void 0)throw new ra("invalid-timing",`Invalid SRT timing line for cue ${n} at line ${t}.`,{cueNumber:n,lineNumber:t});return{startTime:Jc(i,n,t),endTime:Jc(r,n,t)}}function Jc(a,n,t){const o=Zk.exec(a),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 ra("invalid-time",`Invalid SRT timestamp for cue ${n} at line ${t}.`,{cueNumber:n,lineNumber:t});const c=Number.parseInt(i,10),d=Number.parseInt(r,10),u=Number.parseInt(s,10),f=Number.parseInt(l,10);return c*60*60+d*60+u+f/1e3}function Gs(a,n,t){if(!Number.isFinite(a)||a<0)throw new ra("invalid-time",`Caption cue ${n} must be a finite, non-negative number.`,t);return Math.round(a*1e3)}function Kc(a,n){const t={cueIndex:n,segmentId:a.id},o=Yk(a);return o!==void 0&&(t.cueNumber=o),t}function Yk(a){if(!(!("cueNumber"in a)||typeof a.cueNumber!="number"))return a.cueNumber}function qk(a,n){return[n.toString(),`${Gc(a.startTime)} --> ${Gc(a.endTime)}`,Qk(a.text)].join(`
|
|
343
|
-
`)}function Qk(a){return a.replace(/\r\n?/g,`
|
|
344
|
-
`)}function Yc(a){return a===void 0||a.trim()===""}const e_=["linear","ease-in","ease-out","ease-in-out"];class qi extends Error{constructor(n,t="Invalid keyframe automation."){super(t),this.name="KeyframeAutomationError",this.issues=n}}const t_={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 n_(a){return typeof a=="string"&&e_.includes(a)}function a_(a){return a==="mobile"?{platform:a,editingMode:"preset-only",canApplyPresets:!0,canEditKeyframes:!1}:{platform:a,editingMode:"detailed",canApplyPresets:!0,canEditKeyframes:!0}}function o_(a){return[...a].sort((n,t)=>n.target!==t.target?n.target.localeCompare(t.target):n.time!==t.time?n.time-t.time:n.id.localeCompare(t.id))}function em(a,n={}){const t=[],o=new Set,i={...t_,...n.ranges};return a.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}),n.target!==void 0&&r.target!==n.target&&t.push({code:"target-mismatch",message:`Expected ${n.target} keyframe target but received ${r.target}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),!Number.isFinite(r.time)||r.time<(n.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(n.maxTime!==void 0&&r.time>n.maxTime)t.push({code:"invalid-time",message:`Keyframe time must be less than or equal to ${n.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})}n_(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 i_(a,n={}){const t=o_(a),o=em(t,n);if(!o.valid)throw new qi(o.issues);return t}function r_(a={}){return Vl({id:"fade-in",label:"Fade in",target:"opacity",startValue:a.fromOpacity??0,endValue:a.toOpacity??1,timing:Nl(a,"ease-out")})}function s_(a={}){return Vl({id:"fade-out",label:"Fade out",target:"opacity",startValue:a.fromOpacity??1,endValue:a.toOpacity??0,timing:Nl(a,"ease-in")})}function l_(a={}){return Vl({id:"zoom-in",label:"Zoom in",target:"scale",startValue:a.fromScale??1,endValue:a.toScale??1.1,timing:Nl(a,"ease-out")})}function Vl(a){const n=[{id:`${a.id}:start`,target:a.target,time:a.timing.startTime,value:a.startValue,easing:"linear"},{id:`${a.id}:end`,target:a.target,time:a.timing.endTime,value:a.endValue,easing:a.timing.easing}],t=em(n,{target:a.target});if(!t.valid)throw new qi(t.issues);return{id:a.id,label:a.label,target:a.target,editingMode:"preset-only",keyframes:n}}function Nl(a,n){const t=a.startTime??0,o=a.duration??1;if(!Number.isFinite(t)||t<0)throw new qi([{code:"invalid-time",message:"Preset start time must be a finite non-negative number.",time:t}]);if(!Number.isFinite(o)||o<=0)throw new qi([{code:"invalid-time",message:"Preset duration must be a finite number greater than zero."}]);return{startTime:t,endTime:t+o,easing:a.easing??n}}class Na extends Error{constructor(n,t){super(t),this.name="VisualLayerSchemaError",this.code=n}}function c_(a){Ml(a.id,"caption track id");const n={id:a.id,source:a.source,stylePreset:a.stylePreset??"default",animation:a.animation??"none",segments:d_(a.segments)};return a.language!==void 0&&(n.language=a.language),n}function d_(a){const n=a.map(t=>{Ml(t.id,"caption segment id");const o=Tl(t.startTime,"caption segment startTime"),i=tm(t.endTime,"caption segment endTime");if(i<=o)throw new Na("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=u_(t.id,t.words)),r}).sort((t,o)=>t.startTime-o.startTime);for(let t=1;t<n.length;t+=1){const o=n[t-1],i=n[t];if(!(o===void 0||i===void 0)&&i.startTime<o.endTime)throw new Na("invalid-caption-segment",`Caption segment "${i.id}" overlaps segment "${o.id}".`)}return n}function u_(a,n){return n.map(t=>{Ml(t.id,"caption word id");const o=Tl(t.startTime,"caption word startTime"),i=tm(t.endTime,"caption word endTime");if(i<=o)throw new Na("invalid-caption-segment",`Caption word "${t.id}" in segment "${a}" must end after it starts.`);return{id:t.id,startTime:o,endTime:i,text:t.text}}).sort((t,o)=>t.startTime-o.startTime)}function Tl(a,n){const t=m_(a,n);if(t<0)throw new Na("invalid-time",`${n} must be non-negative.`);return Math.round(t*1e3)/1e3}function tm(a,n){const t=Tl(a,n);if(t<=0)throw new Na("invalid-duration",`${n} must be greater than zero.`);return t}function m_(a,n){if(!p_(a))throw new Na("invalid-time",`${n} must be a finite number.`);return a}function Ml(a,n){if(a.trim()==="")throw new Na("empty-id",`${n} cannot be empty.`)}function p_(a){return Number.isFinite(a)}function qc(a){var f,p,m,h;f_(a);const n=g_(a),t=y_(a),o=((f=n[0])==null?void 0:f.id)??oa,i=((p=t[0])==null?void 0:p.id)??no,r=h_(a.clips,i,o),s=b_(t,r),l=[],c=E_(a),d=x_(a),u={version:"1.0",source:{media_uuid:a.mediaUuid,duration:a.originalDuration,original_width:((m=a.media)==null?void 0:m.width)||1920,original_height:((h=a.media)==null?void 0:h.height)||1080},timeline:r,mediaSources:n,tracks:s,filters:l,audio:c,output:d,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return a.textOverlays&&(u.textOverlays=a.textOverlays),a.captionTracks&&(u.captionTracks=a.captionTracks.map(g=>({...g,segments:g.segments.map(w=>{const F={...w};return w.words&&(F.words=w.words.map(D=>({...D}))),F})}))),a.visualLayers&&(u.visualLayers=a.visualLayers.map(g=>({...g}))),a.audioTracks&&(u.audioTracks=a.audioTracks.filter(g=>typeof g.source=="string")),a.transitions&&(u.transitions=a.transitions.map(__)),u}function f_(a){if(!a.mediaUuid)throw new Error("Media UUID is required");if(!a.clips||a.clips.length===0)throw new Error("At least one clip is required");const n=new Map;for(const t of a.clips){const o=v_(t),i=n.get(o)??[];i.push(t),n.set(o,i)}for(const t of n.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 h_(a,n,t){return a.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),c=o,d=c.sourceOffset??c.trimStart??0;let u=Number(r?o.sourceIn:d),f=s?Number(o.sourceOut):Number(d)+l/i;f>u||(f=u+Math.max(.033,l/Math.max(1e-6,i)));const p={id:o.id,type:"clip",trackId:o.trackId??n,sourceRefId:o.sourceRefId??t,timelineStart:o.timelineStart,timelineEnd:o.timelineEnd,sourceIn:u,sourceOut:f,speed:i,filters:o.filters?[...o.filters]:[]};return o.keyframes&&(p.keyframes=o.keyframes.map(m=>({...m}))),p})}function v_(a){return a.trackId??`legacy-track-${a.track??0}`}function g_(a){var t,o,i,r,s,l,c,d;if(a.mediaSources&&a.mediaSources.length>0)return a.mediaSources.map(w_);const n={id:((t=a.clips.find(u=>u.sourceRefId))==null?void 0:t.sourceRefId)??oa,type:"media",mediaUuid:a.mediaUuid,duration:a.originalDuration,width:((o=a.media)==null?void 0:o.width)??1920,height:((i=a.media)==null?void 0:i.height)??1080};return(r=a.media)!=null&&r.filename&&(n.filename=a.media.filename),(s=a.media)!=null&&s.mime_type&&(n.mimeType=a.media.mime_type),typeof((l=a.media)==null?void 0:l.frame_rate)=="number"&&(n.frameRate=a.media.frame_rate),typeof((c=a.media)==null?void 0:c.has_audio)=="boolean"&&(n.hasAudio=a.media.has_audio),(d=a.media)!=null&&d.thumbnail_url&&(n.thumbnailUrl=a.media.thumbnail_url),[n]}function y_(a){var n;return a.tracks&&a.tracks.length>0?a.tracks.map(k_):[{id:((n=a.clips.find(t=>t.trackId))==null?void 0:n.trackId)??no,type:"video",name:"Video",order:0}]}function b_(a,n){return a.map(t=>({...t,clipIds:n.filter(o=>o.trackId===t.id).map(o=>o.id)}))}function w_(a){const n={...a};return a.metadata&&(n.metadata={...a.metadata}),n}function k_(a){const n={...a};return a.clipIds&&(n.clipIds=[...a.clipIds]),n}function __(a){const n={...a};return a.params&&(n.params={...a.params}),n}function E_(a){const n={volume:a.audioVolume,muted:a.audioVolume===0};return a.audioFadeIn>0&&(n.fadeIn=a.audioFadeIn),a.audioFadeOut>0&&(n.fadeOut=a.audioFadeOut),n}function x_(a){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[a.exportQuality]||n["1080p"],o=(r=a.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:a.exportFormat||"mp4",codec:"h264",quality:a.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function _i(a,n=30){const t=typeof a=="number"?a:Number(a);return Number.isFinite(t)&&t>0?t:n}function nm(a,n,t){var on,Sn,la;const o=typeof a=="string"&&a.trim()!==""?a.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:o,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),l=e.ref([]),c=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),f=_i(((on=n==null?void 0:n.output)==null?void 0:on.fps)??(t==null?void 0:t.frame_rate)),p=e.shallowRef(null),m=new Eu(f),h=e.ref(f),g=e.ref(!1),w=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(j(n),(Sn=n.output)!=null&&Sn.fps&&(h.value=_i(n.output.fps,h.value),m.setFps(h.value))):(S(),n&&((la=n.output)!=null&&la.fps&&(h.value=_i(n.output.fps,h.value),m.setFps(h.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const F=e.ref(1),D=e.computed(()=>i.selectedClipId?i.clips.find(H=>H.id===i.selectedClipId)??null:null);e.watch(D,H=>{F.value=(H==null?void 0:H.speed)??1},{immediate:!0});const E=e.computed(()=>s.value.length>0),v=e.computed(()=>l.value.length>0);function S(){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 q=gt();i.mediaSources=[C(H)],i.tracks=[V([q])];const se={id:q,type:"clip",trackId:no,sourceRefId:oa,timelineStart:0,timelineEnd:H,sourceIn:0,sourceOut:H,sourceMinIn:0,sourceMaxOut:H,speed:1};i.clips=[se],i.selectedClipId=q,c.value=q,!(t||o.startsWith("temp-"))&&(async()=>{try{const xe=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!xe.ok)throw new Error(`Failed to fetch media: ${xe.status}`);const De=await xe.json(),Ge=typeof De=="object"&&De!==null&&"data"in De?De.data:De;if(!Ge||typeof Ge!="object")throw new Error("Failed to parse media payload");const Xe=Ge;i.media=Xe,n||(h.value=_i(Xe.frame_rate,h.value),m.setFps(h.value));const Ze=typeof Xe.duration=="number"&&Xe.duration>0?Xe.duration:H;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==q)return;i.originalDuration=Ze,i.totalDuration=Ze,i.mediaSources=[C(Ze,Xe)],i.tracks=[V([q])];const je=i.clips[0];je.timelineStart=0,je.timelineEnd=Ze,je.sourceIn=0,je.sourceOut=Ze,je.sourceMinIn=0,je.sourceMaxOut=Ze,me(),d=!0}catch{}})()}function C(H,q=t){const se={id:oa,type:"media",mediaUuid:o,duration:H,width:(q==null?void 0:q.width)??1920,height:(q==null?void 0:q.height)??1080};return q!=null&&q.filename&&(se.filename=q.filename),q!=null&&q.mime_type&&(se.mimeType=q.mime_type),typeof(q==null?void 0:q.frame_rate)=="number"&&(se.frameRate=q.frame_rate),typeof(q==null?void 0:q.has_audio)=="boolean"&&(se.hasAudio=q.has_audio),q!=null&&q.thumbnail_url&&(se.thumbnailUrl=q.thumbnail_url),se}function V(H){return{id:no,type:"video",name:"Video",order:0,clipIds:H}}function x(H,q){if(H.originalDuration!==1)return;H.originalDuration=q,H.totalDuration===1&&(H.totalDuration=q);const se=H.clips[0],xe=!n&&H.clips.length===1&&se!==void 0&&se.timelineStart===0&&se.timelineEnd===1&&se.sourceIn===0&&se.sourceOut===1;for(const De of H.clips)(De.sourceMaxOut===1||De.sourceMaxOut===void 0)&&(De.sourceMaxOut=q);if(H.mediaSources)for(const De of H.mediaSources)De.id===oa&&(De.duration===1||De.duration===void 0)&&(De.duration=q);xe&&se!==void 0&&(se.sourceOut=q,se.timelineEnd=q)}function N(H){if(!Number.isFinite(H)||H<=0||d)return;const q=i.hasChanges;i.originalDuration=H,i.totalDuration=Math.max(i.totalDuration,H),i.media&&(i.media.duration=H);for(const De of i.clips)De.sourceMaxOut=H;if(i.mediaSources)for(const De of i.mediaSources)(De.id===oa||De.mediaUuid===o)&&(De.duration=H);const se=i.clips[0];!n&&i.clips.length===1&&se!==void 0&&se.timelineStart===0&&se.timelineEnd===1&&se.sourceIn===0&&se.sourceOut===1&&se!==void 0&&(se.sourceOut=H,se.timelineEnd=se.timelineStart+(se.sourceOut-se.sourceIn)),me();for(const De of s.value)x(De,H);for(const De of l.value)x(De,H);d=!0,e.nextTick(()=>{q||(i.hasChanges=!1)})}function j(H){const q=Mu(H);i.mediaSources=q.mediaSources,i.tracks=q.tracks,i.transitions=q.transitions,i.clips=q.clips.map(se=>({...se,sourceMinIn:se.sourceMinIn??0,sourceMaxOut:se.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(Be):[],i.visualLayers=H.visualLayers?H.visualLayers.map(se=>({...se})):[],i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),me()}function _(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function R(){if(!E.value)return;const H=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function T(){if(!v.value)return;const H=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function z(H,q,se){_();const xe=i.clips.find(Ze=>Ze.id===H);if(!xe)return;const De=1/h.value,Ge=xe.sourceMinIn??0,Xe=xe.sourceMaxOut??i.originalDuration;if(q==="start"){const Ze=xe.sourceIn,je=Math.max(Ge,Math.min(se,xe.sourceOut-De));xe.sourceIn=je;const Tt=je-Ze;xe.timelineStart+=Tt}else{const Ze=Math.max(xe.sourceIn+De,Math.min(se,Xe));xe.sourceOut=Ze;const je=xe.sourceOut-xe.sourceIn;xe.timelineEnd=xe.timelineStart+je}me(),p.value&&p.value.trimClip(H,xe.sourceIn,xe.sourceOut)}function P(H){_();const q=i.clips.find(Xe=>H>Xe.timelineStart&&H<Xe.timelineEnd);if(!q)return;const se=H-q.timelineStart,xe=q.sourceIn+se,De={id:gt(),type:"clip",timelineStart:H,timelineEnd:q.timelineEnd,sourceIn:xe,sourceOut:q.sourceOut,speed:q.speed??1,sourceMinIn:q.sourceMinIn??0,sourceMaxOut:q.sourceMaxOut??i.originalDuration,filters:[...q.filters||[]]};q.trackId&&(De.trackId=q.trackId),q.sourceRefId&&(De.sourceRefId=q.sourceRefId),q.timelineEnd=H,q.sourceOut=xe;const Ge=i.clips.indexOf(q);i.clips.splice(Ge+1,0,De),i.selectedClipId=De.id}function M(){P(i.playheadPosition)}function L(H){var se;const q=H??i.selectedClipId??c.value??((se=i.clips[0])==null?void 0:se.id);q&&(i.selectedClipId=q,c.value=q)}function k(){if(!i.selectedClipId||i.clips.length<=1)return;const H=i.clips.findIndex(q=>q.id===i.selectedClipId);H!==-1&&(_(),i.clips.splice(H,1),O(H),me())}function O(H){if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}const q=Math.max(0,Math.min(H,i.clips.length-1)),se=i.clips[q];se&&(i.selectedClipId=se.id,c.value=se.id)}function W(H){return H.trackId??`legacy-track-${H.track??0}`}function G(){const H=i.tracks??[],q=H.find(De=>De.type==="video");if(q)return q;const se=H[0];if(se)return se;const xe=V([]);return i.tracks=[xe],xe}function ie(H){const q=1/h.value;return typeof H.duration=="number"&&Number.isFinite(H.duration)&&H.duration>q?H.duration:i.originalDuration>q?i.originalDuration:Math.max(q,i.totalDuration)}function we(H){const q=(i.mediaSources??[]).find(Ze=>Ze.id===H);if(!q)return null;_();const se=G(),xe=ie(q),De=gt(),Ge=Math.max(0,i.totalDuration),Xe={id:De,type:"clip",trackId:se.id,sourceRefId:q.id,timelineStart:Ge,timelineEnd:Ge+xe,sourceIn:0,sourceOut:xe,sourceMinIn:0,sourceMaxOut:xe,speed:1};return i.clips.push(Xe),i.selectedClipId=De,c.value=De,me(),Xe}function _e(H){const q=D.value,se=(i.mediaSources??[]).find(Ze=>Ze.id===H);if(!q||!se)return!1;_();const xe=1/h.value,De=ie(se),Ge=Math.max(xe,q.timelineEnd-q.timelineStart),Xe=Math.max(xe,Math.min(Ge,De));return q.sourceRefId=se.id,q.sourceIn=0,q.sourceOut=Xe,q.sourceMinIn=0,q.sourceMaxOut=De,q.timelineEnd=q.timelineStart+Xe,me(),!0}function oe(H){const q=i.mediaSources??[];return q.length<=1||i.clips.some(xe=>xe.sourceRefId===H)?!1:(_(),i.mediaSources=q.filter(xe=>xe.id!==H),!0)}function $(H,q){const se=(i.tracks??[]).find(xe=>xe.id===H);return se?(_(),se[q]=se[q]!==!0,!0):!1}function B(H){return $(H,"locked")}function Z(H){return $(H,"hidden")}function ee(H){return $(H,"muted")}function ne(H){return $(H,"solo")}function de(H){if(i.clips.length<=1)return!1;const q=i.clips.findIndex(Ge=>Ge.id===H),se=q===-1?void 0:i.clips[q];if(!se)return!1;const xe=Math.max(0,se.timelineEnd-se.timelineStart),De=W(se);if(_(),i.clips.splice(q,1),xe>0)for(const Ge of i.clips)W(Ge)!==De||Ge.timelineStart<se.timelineEnd||(Ge.timelineStart=Math.max(0,Ge.timelineStart-xe),Ge.timelineEnd=Math.max(Ge.timelineStart,Ge.timelineEnd-xe));return i.playheadPosition>=se.timelineEnd?i.playheadPosition=Math.max(0,i.playheadPosition-xe):i.playheadPosition>se.timelineStart&&(i.playheadPosition=se.timelineStart),O(q),me(),i.hasChanges=!0,!0}function ue(){return i.selectedClipId?de(i.selectedClipId):!1}function ge(){return[...i.clips].sort((H,q)=>H.timelineStart-q.timelineStart)}function Ne(H){const q=ge(),se=q.findIndex(Tt=>Tt.id===H);if(se===-1)return null;const xe=q[se],De=xe.timelineEnd-xe.timelineStart,Ge=se>0?q[se-1]:null,Xe=se<q.length-1?q[se+1]:null,Ze=Ge?Ge.timelineEnd:0,je=Xe?Xe.timelineStart-De:Math.max(xe.timelineStart,i.totalDuration-De);return{minStart:Ze,maxStart:Math.max(Ze,je)}}function fe(H,q){const se=i.clips.find(Xe=>Xe.id===H);if(!se)return;const xe=Ne(H),De=xe?Math.min(xe.maxStart,Math.max(xe.minStart,q)):Math.max(0,q);if(De===se.timelineStart)return;_();const Ge=De-se.timelineStart;se.timelineStart=De,se.timelineEnd+=Ge,me(),p.value&&p.value.moveClip(H,De)}function me(){if(i.clips.length===0){i.totalDuration=0;return}const H=i.clips.reduce((q,se)=>se.timelineEnd>q.timelineEnd?se:q);i.totalDuration=H.timelineEnd}function Ee(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function Te(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function dt(H){i.zoomLevel=Math.max(10,Math.min(600,Math.round(H)))}function st(){i.isPlaying=!i.isPlaying}function Dt(H){i.isPlaying=H}function pt(H){i.playheadPosition=Math.max(0,Math.min(H,i.totalDuration))}function ft(){const H=qc(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(H))}catch{}return H}function _t(){i.hasChanges=!1}function ot(){return confirm("Are you sure you want to reset all changes?")?(_(),S(),i.hasChanges=!1,!0):!1}function bt(){return qc(i)}function gt(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ve(H=1920,q=1080){if(u.value)try{p.value=new _u(H,q,h.value),await Se()}catch{p.value=null}}async function Se(){if(!(!p.value||w.value)){w.value=!0;try{const H=bt();await p.value.loadFromRecipe(H);const q=m.secondsToFrames(i.playheadPosition);p.value.seek(q)}catch{}finally{w.value=!1}}}function Fe(H){}function Ke(H){return m.secondsToFrames(H)}function We(H){return m.framesToSeconds(H)}function ze(H){const q=We(H);pt(q),p.value&&p.value.seek(H)}function ut(){g.value=!g.value}function Et(){Se()}function It(H){u.value=!1,p.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&p.value&&Se()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&p.value&&Se()},{deep:!0}),e.watch(()=>i.clips.map(H=>H.id),()=>{var q;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(se=>se.id===i.selectedClipId)){const se=c.value&&((q=i.clips.find(xe=>xe.id===c.value))==null?void 0:q.id);i.selectedClipId=se??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function Rt(H){const q=i.selectedClipId?i.clips.find(se=>se.id===i.selectedClipId):i.clips[0];q&&(q.filters=[...H],i.hasChanges=!0)}function Xt(H){i.textOverlays=[...H]}function yn(H){i.audioTracks=[...H]}function Pn(H){i.captionTracks=H.map(Be),i.hasChanges=!0}function Y(H){i.visualLayers=H.map(q=>({...q})),i.hasChanges=!0}function re(H){i.transitions=H.map(q=>{const se={...q};return q.params&&(se.params={...q.params}),se}),i.hasChanges=!0}function ae(H,q){const se=i.clips.find(xe=>xe.id===H);se&&(se.keyframes=q.map(xe=>({...xe})),i.hasChanges=!0)}function ce(H){_(),j(H),i.hasChanges=!0}function Be(H){return{...H,segments:H.segments.map(q=>{const se={...q};return q.words&&(se.words=q.words.map(xe=>({...xe}))),se})}}e.watch(u,H=>{H?ve():p.value&&(p.value.destroy(),p.value=null)}),e.watch(g,()=>{}),e.watch(h,H=>{m.setFps(H)});function Le(){if(!i.selectedClipId)return;_();const H=i.clips.find(xe=>xe.id===i.selectedClipId);if(!H)return;const q={...H,id:gt(),timelineStart:H.timelineEnd,timelineEnd:H.timelineEnd+(H.timelineEnd-H.timelineStart),filters:[...H.filters||[]]},se=i.clips.indexOf(H);i.clips.splice(se+1,0,q),i.selectedClipId=q.id,i.hasChanges=!0}function Oe(H){const q=H??800,se=i.totalDuration;if(se<=0){i.zoomLevel=50;return}const xe=q*.8/se;i.zoomLevel=Math.max(10,Math.min(600,Math.round(xe)))}function mt(){const H=1/h.value;pt(Math.min(i.playheadPosition+H,i.totalDuration))}function it(){const H=1/h.value;pt(Math.max(i.playheadPosition-H,0))}function rt(){pt(0)}function wt(){pt(i.totalDuration)}function At(H){if(!Number.isFinite(H)||H<=0)return;const q=D.value??i.clips[0];if(!q){F.value=H;return}const se=q.speed??1;if(se===H){F.value=H;return}_();const xe=Math.max(1/h.value,q.sourceOut-q.sourceIn),De=xe/se,Ge=xe/H,Xe=Ge-De;q.speed=H,q.timelineEnd=q.timelineStart+Ge;const Ze=i.clips.findIndex(je=>je.id===q.id);if(Ze!==-1&&Xe!==0)for(let je=Ze+1;je<i.clips.length;je+=1){const Tt=i.clips[je];Tt.timelineStart+=Xe,Tt.timelineEnd+=Xe}me(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,F.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:D,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:F,useVideoEngine:u,compositionAdapter:e.computed(()=>p.value),fps:h,useFrameMode:g,handleTrim:z,handleSplit:P,handleClipSelect:L,splitAtPlayhead:M,deleteSelectedClip:k,rippleDeleteClip:de,rippleDeleteSelectedClip:ue,duplicateSelectedClip:Le,appendMediaSourceToTimeline:we,replaceSelectedClipSource:_e,removeMediaSource:oe,toggleTrackLock:B,toggleTrackHidden:Z,toggleTrackMuted:ee,toggleTrackSolo:ne,setFilters:Rt,setTextOverlays:Xt,setAudioTracks:yn,setCaptionTracks:Pn,setVisualLayers:Y,setTransitions:re,setClipKeyframes:ae,loadRecipe:ce,moveClip:fe,saveDraft:ft,clearHasChanges:_t,resetChanges:ot,generateRecipe:bt,zoomIn:Ee,zoomOut:Te,setZoomLevel:dt,fitToWindow:Oe,togglePlayback:st,setPlaying:Dt,seekTo:pt,frameForward:mt,frameBackward:it,skipToStart:rt,skipToEnd:wt,setPlaybackSpeed:At,updateSourceDuration:N,undo:R,redo:T,canUndo:E,canRedo:v,initializeComposition:ve,syncCompositionWithState:Se,syncWithComposition:Fe,convertToFrames:Ke,convertToSeconds:We,seekToFrame:ze,toggleFrameMode:ut,onCompositionReady:Et,onCompositionError:It}}const S_=[{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}}}],C_={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function br(a){return typeof a=="object"&&a!==null}function V_(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function wr(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function N_(a){const n={id:a.id,type:a.type,label:a.label};a.property!==void 0&&(n.property=a.property),a.min!==void 0&&(n.min=a.min),a.max!==void 0&&(n.max=a.max),a.step!==void 0&&(n.step=a.step);const t=wr(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function am(a,n,t){const o=pe.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&br(r))for(const[s,l]of Object.entries(r))i[s]=wr(l)??null;for(const s of n){const l=s.property??s.id;i[l]===void 0&&s.default!==void 0&&(i[l]=s.default)}return i}function om(a){const n={};for(const t of a){if(t.type!=="slider")continue;const o=t.property??t.id;n[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function T_(a,n,t,o){const i=o.map(N_);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:am(a,i),paramRanges:om(i)}}function M_(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var l;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=wr((l=a.defaultParams)==null?void 0:l[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:am(a.id,t,a.defaultParams),paramRanges:om(t)}}function B_(a,n){return n.toLowerCase()==="unlisted"?!1:pe.isFilterCompatibleWithMedia(a,"video")}function is(a){return C_[a]??a}function Mo(a){const n=V_(a,1);return Math.max(0,Math.min(1,n))}function Bo(a){if(!br(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=wr(o)??null;return n}function I_(a){return!br(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:Bo(a.params),intensity:Mo(a.intensity)}}function F_(a){if(!br(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>I_(i)).filter(i=>i!==null),o=typeof a.created_at=="string"?a.created_at:new Date().toISOString();return{id:a.id,name:a.name,filters:t,created_at:o}}function im(){pe.initializeFilterRegistry();const a=e.ref([]),n=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const T=new Map,z=pe.getRegisteredFilters();for(const P of z)B_(P.id,P.category)&&T.set(P.id,T_(P.id,P.name,P.category,P.controls));for(const P of S_)T.has(P.id)||T.set(P.id,M_(P));return Array.from(T.values())}),l=e.computed(()=>{const T=new Map;for(const z of s.value)T.set(z.id,z);return T}),c=e.computed(()=>a.value.length>0),d=e.computed(()=>{const T={};for(const z of s.value)T[z.category]||(T[z.category]=[]),T[z.category].push(z);return T});function u(T){const z=l.value.get(T);if(z)return z;const P=is(T);return l.value.get(P)??null}function f(T){const z=l.value.get(T);if(z)return z.id;const P=is(T),M=l.value.get(P);return M?M.id:null}function p(T){const z=T?u(T):n.value;if(!z)return;const P=z.defaultParams||{},M={id:N(),filterId:z.id,params:{...P},intensity:1};return a.value.push(M),i.value=M.id,n.value=z,Object.keys(r).forEach(L=>delete r[L]),Object.assign(r,M.params),t.value=null,M}function m(T){const z=u(T);if(!z)return;n.value=z;const P=z.defaultParams||_(T);Object.assign(r,P),t.value={id:"preview",filterId:z.id,params:{...P},intensity:1}}function h(T){if(Object.assign(r,T),t.value&&(t.value.params={...r}),i.value){const z=a.value.find(P=>P.id===i.value);z&&(z.params={...r})}}function g(T){const z=a.value.findIndex(P=>P.id===T);z!==-1&&a.value.splice(z,1)}function w(T,z){if(T<0||T>=a.value.length||z<0||z>=a.value.length)return;const[P]=a.value.splice(T,1);a.value.splice(z,0,P)}function F(T,z){const P=a.value.find(M=>M.id===T);P&&(P.intensity=Math.max(0,Math.min(1,z)))}function D(T){const z=a.value.find(P=>P.id===T);z&&(z.intensity=z.intensity>0?0:1)}function E(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(T=>delete r[T])}function v(T){const z={id:j(),name:T,filters:a.value.map(M=>({filterId:M.filterId,params:Bo(M.params),intensity:Mo(M.intensity)})),created_at:new Date().toISOString()};o.value.push(z);const P=o.value.map(M=>({...M}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),z}function S(T){const z=o.value.find(P=>P.id===T);if(z){E();for(const P of z.filters){const M=u(P.filterId);M&&a.value.push({id:N(),filterId:M.id,params:{...P.params},intensity:Mo(P.intensity)})}}}function C(T){const z=o.value.findIndex(P=>P.id===T);z!==-1&&(o.value.splice(z,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function V(){try{const T=localStorage.getItem("video-filter-presets");if(!T)return;const z=JSON.parse(T);if(!Array.isArray(z))return;o.value=z.map(P=>F_(P)).filter(P=>P!==null)}catch{}}function x(){if(a.value.length===0)return"No filters applied";const T=a.value.map(z=>{const P=R(z.filterId);return(P==null?void 0:P.name)||z.filterId});return T.length===1?T[0]:T.length===2?`${T[0]} + ${T[1]}`:`${T[0]} + ${T.length-1} more`}function N(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function j(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function _(T){const z=u(T);return z?z.defaultParams||{}:{}}function R(T){return u(T)}return V(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:p,previewFilterEffect:m,updateFilterParams:h,removeFilter:g,reorderFilters:w,updateFilterIntensity:F,toggleFilter:D,clearAllFilters:E,saveFilterPreset:v,loadFilterPreset:S,deleteFilterPreset:C,getFilterSummary:x,setActiveFilters(T){var P;const z=[];for(const M of T){const L=f(M.filterId);if(!L){const k=is(M.filterId);z.push({...M,filterId:k,params:Bo(M.params),intensity:Mo(M.intensity)});continue}z.push({...M,filterId:L,params:Bo(M.params),intensity:Mo(M.intensity)})}a.value=z,i.value=((P=a.value[0])==null?void 0:P.id)??null,Object.keys(r).forEach(M=>delete r[M]),a.value[0]&&Object.assign(r,Bo(a.value[0].params))}}}class rm{constructor(n){this.textClips=new Map,this.overlayConfigs=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new Zt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new Zt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new Zt({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,o,i="400"){const r=new Zt({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new Zt({source:`local('${t}')`,family:t,weight:o});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,o=this.buildTextClipConfig(n),i=new oo(o);return await this.composition.add(i),this.textClips.set(t,i),this.overlayConfigs.set(t,{...n}),t}buildTextClipConfig(n){const t={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},o=n.fontFamily||"default",i=this.fonts.get(o)||this.fonts.get("default");if(i&&(t.font=i),this.applyPosition(t,n.position),n.startTime!==void 0&&(t.start=Me.fromSeconds(n.startTime)),n.duration!==void 0){const r=n.startTime||0;t.stop=Me.fromSeconds(r+n.duration)}return n.animation&&this.applyAnimation(t,n.animation,n),t}applyPosition(n,t){if(!t){n.position="center";return}if(typeof t!="string"){n.x=t.x,n.y=t.y;return}switch(t){case"center":n.position="center";break;case"top":n.x="50%",n.y="10%";break;case"bottom":n.x="50%",n.y="90%";break;case"left":n.x="10%",n.y="50%";break;case"right":n.x="90%",n.y="50%";break}}applyAnimation(n,t,o){if(!t)return;const i=o.startTime?Math.round(o.startTime*30):0,r=t.duration||1,s=Math.round(r*30),l=i+s,c=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Ae([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Ae([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Ae([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Ae([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Ae([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ae([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Ae([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ae([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Ae([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Ae([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ae([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(n,t){const o=this.textClips.get(n);if(!o)throw new Error(`Text overlay with id ${n} not found`);const i=this.overlayConfigs.get(n);if(!i)throw new Error(`Text overlay with id ${n} is missing config`);const r={...i,...t};o.set(this.buildTextClipConfig(r)),this.overlayConfigs.set(n,r)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const o=this.composition.tracks;for(const i of o){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n),this.overlayConfigs.delete(n)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const n=Array.from(this.textClips.keys());for(const t of n)await this.removeTextOverlay(t)}getOverlays(){return Array.from(this.overlayConfigs.entries()).map(([n,t])=>({id:n,config:{...t}}))}async addCaptions(n,t="classic",o){var c;const r={classic:Qo,cascade:pr,guinea:mr,solar:fr,spotlight:ei,whisper:ti}[t],s=await this.composition.createTrack("caption"),l=new rr({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),o&&s.clips.length>0){const d=s.clips[0];d==null||d.set(o)}}}class sm{constructor(n){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=n}async loadAudioSource(n,t){try{const o=await aa.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,o),o}catch(o){throw o instanceof Error?o:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`,o=await this.resolveAudioSource(n.source),i=this.createAudioClipConfig(n,o),r=new Ao(i);let s=this.findAudioTrack();s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,l),t}async resolveAudioSource(n){try{if(n instanceof aa)return n;if(typeof n=="string"&&n.trim()!=="")return await aa.from(n);if(n instanceof File)return await aa.from(URL.createObjectURL(n));throw new Error("Invalid audio source")}catch(t){throw t instanceof Error?t:new Error("Failed to create audio source")}}createAudioClipConfig(n,t){const o={source:t,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(o.start=Me.fromSeconds(n.startTime)),n.duration!==void 0){const i=n.startTime||0;o.stop=Me.fromSeconds(i+n.duration)}return(n.fadeIn||n.fadeOut)&&(o.volume=this.createVolumeKeyframes(n)),o}findAudioTrack(){return this.composition.tracks.find(n=>n.kind==="audio")}removeClipFromTrack(n,t){const o=n.clips.indexOf(t);o!==-1&&n.clips.splice(o,1)}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,o=n.startTime?Math.round(n.startTime*30):0,i=n.duration,r=[],s=[];if(n.fadeIn){const l=Math.round(n.fadeIn*30);r.push(o,o+l),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const l=o+Math.round(i*30),c=Math.round(n.fadeOut*30);n.fadeIn||(r.push(l-c),s.push(t)),r.push(l),s.push(0)}return new Ae(r,s,{easing:"linear"})}async updateVolume(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));o.config.volume=i,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async updateAudioTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i={...o.config,...t,source:t.source??o.config.source},r=await this.resolveAudioSource(i.source),s=new Ao(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(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeIn=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async applyFadeOut(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeOut=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);this.removeClipFromTrack(t.track,t.clip),this.audioLayers.delete(n)}async muteTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);t?o.clip.set({volume:0}):o.clip.set({volume:this.resolveLayerVolume(o.config)})}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));for(const t of this.audioLayers.values())t.clip.set({volume:this.resolveLayerVolume(t.config)})}resolveLayerVolume(n){return n.fadeIn||n.fadeOut?this.createVolumeKeyframes(n):(n.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(n){return this.audioLayers.get(n)}async clearAllAudioTracks(){const n=Array.from(this.audioLayers.keys());for(const t of n)await this.removeAudioTrack(t)}async syncWithVideo(n,t){for(const o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-n;if(i+r>t){o.config.duration=t-i;const s=new Ao(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(n=>({id:n.id,name:n.name,config:{...n.config,source:n.config.source&&typeof n.config.source=="object"&&"type"in n.config.source?"[AudioSource]":n.config.source}}))}async importConfiguration(n){for(const{name:t,config:o}of n)await this.addAudioTrack({...o,name:t})}}function lm(a,n){return function(){return a.apply(n,arguments)}}const{toString:$_}=Object.prototype,{getPrototypeOf:Bl}=Object,{iterator:kr,toStringTag:cm}=Symbol,_r=(a=>n=>{const t=$_.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),xn=a=>(a=a.toLowerCase(),n=>_r(n)===a),Er=a=>n=>typeof n===a,{isArray:so}=Array,Ho=Er("undefined");function ai(a){return a!==null&&!Ho(a)&&a.constructor!==null&&!Ho(a.constructor)&&tn(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const dm=xn("ArrayBuffer");function D_(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&dm(a.buffer),n}const R_=Er("string"),tn=Er("function"),um=Er("number"),oi=a=>a!==null&&typeof a=="object",A_=a=>a===!0||a===!1,Ai=a=>{if(_r(a)!=="object")return!1;const n=Bl(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(cm in a)&&!(kr in a)},L_=a=>{if(!oi(a)||ai(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},P_=xn("Date"),O_=xn("File"),U_=xn("Blob"),z_=xn("FileList"),j_=a=>oi(a)&&tn(a.pipe),W_=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||tn(a.append)&&((n=_r(a))==="formdata"||n==="object"&&tn(a.toString)&&a.toString()==="[object FormData]"))},Z_=xn("URLSearchParams"),[H_,X_,G_,J_]=["ReadableStream","Request","Response","Headers"].map(xn),K_=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ii(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),so(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(ai(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let l;for(o=0;o<s;o++)l=r[o],n.call(null,a[l],l,a)}}function mm(a,n){if(ai(a))return null;n=n.toLowerCase();const t=Object.keys(a);let o=t.length,i;for(;o-- >0;)if(i=t[o],n===i.toLowerCase())return i;return null}const Ea=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,pm=a=>!Ho(a)&&a!==Ea;function Js(){const{caseless:a}=pm(this)&&this||{},n={},t=(o,i)=>{const r=a&&mm(n,i)||i;Ai(n[r])&&Ai(o)?n[r]=Js(n[r],o):Ai(o)?n[r]=Js({},o):so(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&ii(arguments[o],t);return n}const Y_=(a,n,t,{allOwnKeys:o}={})=>(ii(n,(i,r)=>{t&&tn(i)?a[r]=lm(i,t):a[r]=i},{allOwnKeys:o}),a),q_=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),Q_=(a,n,t,o)=>{a.prototype=Object.create(n.prototype,o),a.prototype.constructor=a,Object.defineProperty(a,"super",{value:n.prototype}),t&&Object.assign(a.prototype,t)},eE=(a,n,t,o)=>{let i,r,s;const l={};if(n=n||{},a==null)return n;do{for(i=Object.getOwnPropertyNames(a),r=i.length;r-- >0;)s=i[r],(!o||o(s,a,n))&&!l[s]&&(n[s]=a[s],l[s]=!0);a=t!==!1&&Bl(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},tE=(a,n,t)=>{a=String(a),(t===void 0||t>a.length)&&(t=a.length),t-=n.length;const o=a.indexOf(n,t);return o!==-1&&o===t},nE=a=>{if(!a)return null;if(so(a))return a;let n=a.length;if(!um(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},aE=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&Bl(Uint8Array)),oE=(a,n)=>{const o=(a&&a[kr]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},iE=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},rE=xn("HTMLFormElement"),sE=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Qc=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),lE=xn("RegExp"),fm=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};ii(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},cE=a=>{fm(a,(n,t)=>{if(tn(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(tn(o)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},dE=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return so(a)?o(a):o(String(a).split(n)),t},uE=()=>{},mE=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function pE(a){return!!(a&&tn(a.append)&&a[cm]==="FormData"&&a[kr])}const fE=a=>{const n=new Array(10),t=(o,i)=>{if(oi(o)){if(n.indexOf(o)>=0)return;if(ai(o))return o;if(!("toJSON"in o)){n[i]=o;const r=so(o)?[]:{};return ii(o,(s,l)=>{const c=t(s,i+1);!Ho(c)&&(r[l]=c)}),n[i]=void 0,r}}return o};return t(a,0)},hE=xn("AsyncFunction"),vE=a=>a&&(oi(a)||tn(a))&&tn(a.then)&&tn(a.catch),hm=((a,n)=>a?setImmediate:n?((t,o)=>(Ea.addEventListener("message",({source:i,data:r})=>{i===Ea&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),Ea.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",tn(Ea.postMessage)),gE=typeof queueMicrotask<"u"?queueMicrotask.bind(Ea):typeof process<"u"&&process.nextTick||hm,yE=a=>a!=null&&tn(a[kr]),te={isArray:so,isArrayBuffer:dm,isBuffer:ai,isFormData:W_,isArrayBufferView:D_,isString:R_,isNumber:um,isBoolean:A_,isObject:oi,isPlainObject:Ai,isEmptyObject:L_,isReadableStream:H_,isRequest:X_,isResponse:G_,isHeaders:J_,isUndefined:Ho,isDate:P_,isFile:O_,isBlob:U_,isRegExp:lE,isFunction:tn,isStream:j_,isURLSearchParams:Z_,isTypedArray:aE,isFileList:z_,forEach:ii,merge:Js,extend:Y_,trim:K_,stripBOM:q_,inherits:Q_,toFlatObject:eE,kindOf:_r,kindOfTest:xn,endsWith:tE,toArray:nE,forEachEntry:oE,matchAll:iE,isHTMLForm:rE,hasOwnProperty:Qc,hasOwnProp:Qc,reduceDescriptors:fm,freezeMethods:cE,toObjectSet:dE,toCamelCase:sE,noop:uE,toFiniteNumber:mE,findKey:mm,global:Ea,isContextDefined:pm,isSpecCompliantForm:pE,toJSONObject:fE,isAsyncFn:hE,isThenable:vE,setImmediate:hm,asap:gE,isIterable:yE};function He(a,n,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=a,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}te.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:te.toJSONObject(this.config),code:this.code,status:this.status}}});const vm=He.prototype,gm={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(a=>{gm[a]={value:a}});Object.defineProperties(He,gm);Object.defineProperty(vm,"isAxiosError",{value:!0});He.from=(a,n,t,o,i,r)=>{const s=Object.create(vm);return te.toFlatObject(a,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),He.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const bE=null;function Ks(a){return te.isPlainObject(a)||te.isArray(a)}function ym(a){return te.endsWith(a,"[]")?a.slice(0,-2):a}function ed(a,n,t){return a?a.concat(n).map(function(i,r){return i=ym(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function wE(a){return te.isArray(a)&&!a.some(Ks)}const kE=te.toFlatObject(te,{},null,function(n){return/^is[A-Z]/.test(n)});function xr(a,n,t){if(!te.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=te.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,w){return!te.isUndefined(w[g])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&te.isSpecCompliantForm(n);if(!te.isFunction(i))throw new TypeError("visitor must be a function");function d(h){if(h===null)return"";if(te.isDate(h))return h.toISOString();if(te.isBoolean(h))return h.toString();if(!c&&te.isBlob(h))throw new He("Blob is not supported. Use a Buffer instead.");return te.isArrayBuffer(h)||te.isTypedArray(h)?c&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,g,w){let F=h;if(h&&!w&&typeof h=="object"){if(te.endsWith(g,"{}"))g=o?g:g.slice(0,-2),h=JSON.stringify(h);else if(te.isArray(h)&&wE(h)||(te.isFileList(h)||te.endsWith(g,"[]"))&&(F=te.toArray(h)))return g=ym(g),F.forEach(function(E,v){!(te.isUndefined(E)||E===null)&&n.append(s===!0?ed([g],v,r):s===null?g:g+"[]",d(E))}),!1}return Ks(h)?!0:(n.append(ed(w,g,r),d(h)),!1)}const f=[],p=Object.assign(kE,{defaultVisitor:u,convertValue:d,isVisitable:Ks});function m(h,g){if(!te.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(h),te.forEach(h,function(F,D){(!(te.isUndefined(F)||F===null)&&i.call(n,F,te.isString(D)?D.trim():D,g,p))===!0&&m(F,g?g.concat(D):[D])}),f.pop()}}if(!te.isObject(a))throw new TypeError("data must be an object");return m(a),n}function td(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function Il(a,n){this._pairs=[],a&&xr(a,this,n)}const bm=Il.prototype;bm.append=function(n,t){this._pairs.push([n,t])};bm.toString=function(n){const t=n?function(o){return n.call(this,o,td)}:td;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function _E(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function wm(a,n,t){if(!n)return a;const o=t&&t.encode||_E;te.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=te.isURLSearchParams(n)?n.toString():new Il(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class nd{constructor(){this.handlers=[]}use(n,t,o){return this.handlers.push({fulfilled:n,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){te.forEach(this.handlers,function(o){o!==null&&n(o)})}}const km={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},EE=typeof URLSearchParams<"u"?URLSearchParams:Il,xE=typeof FormData<"u"?FormData:null,SE=typeof Blob<"u"?Blob:null,CE={isBrowser:!0,classes:{URLSearchParams:EE,FormData:xE,Blob:SE},protocols:["http","https","file","blob","url","data"]},Fl=typeof window<"u"&&typeof document<"u",Ys=typeof navigator=="object"&&navigator||void 0,VE=Fl&&(!Ys||["ReactNative","NativeScript","NS"].indexOf(Ys.product)<0),NE=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",TE=Fl&&window.location.href||"http://localhost",ME=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fl,hasStandardBrowserEnv:VE,hasStandardBrowserWebWorkerEnv:NE,navigator:Ys,origin:TE},Symbol.toStringTag,{value:"Module"})),Ht={...ME,...CE};function BE(a,n){return xr(a,new Ht.classes.URLSearchParams,{visitor:function(t,o,i,r){return Ht.isNode&&te.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function IE(a){return te.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function FE(a){const n={},t=Object.keys(a);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],n[r]=a[r];return n}function _m(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&te.isArray(i)?i.length:s,c?(te.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!l):((!i[s]||!te.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&te.isArray(i[s])&&(i[s]=FE(i[s])),!l)}if(te.isFormData(a)&&te.isFunction(a.entries)){const t={};return te.forEachEntry(a,(o,i)=>{n(IE(o),i,t,0)}),t}return null}function $E(a,n,t){if(te.isString(a))try{return(n||JSON.parse)(a),te.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const ri={transitional:km,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=te.isObject(n);if(r&&te.isHTMLForm(n)&&(n=new FormData(n)),te.isFormData(n))return i?JSON.stringify(_m(n)):n;if(te.isArrayBuffer(n)||te.isBuffer(n)||te.isStream(n)||te.isFile(n)||te.isBlob(n)||te.isReadableStream(n))return n;if(te.isArrayBufferView(n))return n.buffer;if(te.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return BE(n,this.formSerializer).toString();if((l=te.isFileList(n))||o.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return xr(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),$E(n)):n}],transformResponse:[function(n){const t=this.transitional||ri.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(te.isResponse(n)||te.isReadableStream(n))return n;if(n&&te.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?He.from(l,He.ERR_BAD_RESPONSE,this,null,this.response):l}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ht.classes.FormData,Blob:Ht.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};te.forEach(["delete","get","head","post","put","patch"],a=>{ri.headers[a]={}});const DE=te.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"]),RE=a=>{const n={};let t,o,i;return a&&a.split(`
|
|
345
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&DE[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},ad=Symbol("internals");function Eo(a){return a&&String(a).trim().toLowerCase()}function Li(a){return a===!1||a==null?a:te.isArray(a)?a.map(Li):String(a)}function AE(a){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(a);)n[o[1]]=o[2];return n}const LE=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function rs(a,n,t,o,i){if(te.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!te.isString(n)){if(te.isString(o))return n.indexOf(o)!==-1;if(te.isRegExp(o))return o.test(n)}}function PE(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function OE(a,n){const t=te.toCamelCase(" "+n);["get","set","has"].forEach(o=>{Object.defineProperty(a,o+t,{value:function(i,r,s){return this[o].call(this,n,i,r,s)},configurable:!0})})}let nn=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(l,c,d){const u=Eo(c);if(!u)throw new Error("header name must be a non-empty string");const f=te.findKey(i,u);(!f||i[f]===void 0||d===!0||d===void 0&&i[f]!==!1)&&(i[f||c]=Li(l))}const s=(l,c)=>te.forEach(l,(d,u)=>r(d,u,c));if(te.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(te.isString(n)&&(n=n.trim())&&!LE(n))s(RE(n),t);else if(te.isObject(n)&&te.isIterable(n)){let l={},c,d;for(const u of n){if(!te.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?te.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=Eo(n),n){const o=te.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return AE(i);if(te.isFunction(t))return t.call(this,i,o);if(te.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=Eo(n),n){const o=te.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||rs(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=Eo(s),s){const l=te.findKey(o,s);l&&(!t||rs(o,o[l],l,t))&&(delete o[l],i=!0)}}return te.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!n||rs(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return te.forEach(this,(i,r)=>{const s=te.findKey(o,r);if(s){t[s]=Li(i),delete t[r];return}const l=n?PE(r):String(r).trim();l!==r&&delete t[r],t[l]=Li(i),o[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return te.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&te.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
|
|
346
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[ad]=this[ad]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=Eo(s);o[l]||(OE(i,s),o[l]=!0)}return te.isArray(n)?n.forEach(r):r(n),this}};nn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);te.reduceDescriptors(nn.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});te.freezeMethods(nn);function ss(a,n){const t=this||ri,o=n||t,i=nn.from(o.headers);let r=o.data;return te.forEach(a,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function Em(a){return!!(a&&a.__CANCEL__)}function lo(a,n,t){He.call(this,a??"canceled",He.ERR_CANCELED,n,t),this.name="CanceledError"}te.inherits(lo,He,{__CANCEL__:!0});function xm(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(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 UE(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function zE(a,n){a=a||10;const t=new Array(a),o=new Array(a);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(c){const d=Date.now(),u=o[r];s||(s=d),t[i]=c,o[i]=d;let f=r,p=0;for(;f!==i;)p+=t[f++],f=f%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const m=u&&d-u;return m?Math.round(p*1e3/m):void 0}}function jE(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),f=u-t;f>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-f)))},()=>i&&s(i)]}const Qi=(a,n,t=3)=>{let o=0;const i=zE(50,250);return jE(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-o,d=i(c),u=s<=l;o=s;const f={loaded:s,total:l,progress:l?s/l:void 0,bytes:c,rate:d||void 0,estimated:d&&l&&u?(l-s)/d:void 0,event:r,lengthComputable:l!=null,[n?"download":"upload"]:!0};a(f)},t)},od=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},id=a=>(...n)=>te.asap(()=>a(...n)),WE=Ht.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,Ht.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(Ht.origin),Ht.navigator&&/(msie|trident)/i.test(Ht.navigator.userAgent)):()=>!0,ZE=Ht.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];te.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),te.isString(o)&&s.push("path="+o),te.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(a){const n=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function HE(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function XE(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function Sm(a,n,t){let o=!HE(n);return a&&(o||t==!1)?XE(a,n):n}const rd=a=>a instanceof nn?{...a}:a;function Ta(a,n){n=n||{};const t={};function o(d,u,f,p){return te.isPlainObject(d)&&te.isPlainObject(u)?te.merge.call({caseless:p},d,u):te.isPlainObject(u)?te.merge({},u):te.isArray(u)?u.slice():u}function i(d,u,f,p){if(te.isUndefined(u)){if(!te.isUndefined(d))return o(void 0,d,f,p)}else return o(d,u,f,p)}function r(d,u){if(!te.isUndefined(u))return o(void 0,u)}function s(d,u){if(te.isUndefined(u)){if(!te.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function l(d,u,f){if(f in n)return o(d,u);if(f in a)return o(void 0,d)}const c={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(d,u,f)=>i(rd(d),rd(u),f,!0)};return te.forEach(Object.keys({...a,...n}),function(u){const f=c[u]||i,p=f(a[u],n[u],u);te.isUndefined(p)&&f!==l||(t[u]=p)}),t}const Cm=a=>{const n=Ta({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=nn.from(s),n.url=wm(Sm(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(te.isFormData(t)){if(Ht.hasStandardBrowserEnv||Ht.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(Ht.hasStandardBrowserEnv&&(o&&te.isFunction(o)&&(o=o(n)),o||o!==!1&&WE(n.url))){const d=i&&r&&ZE.read(r);d&&s.set(i,d)}return n},GE=typeof XMLHttpRequest<"u",JE=GE&&function(a){return new Promise(function(t,o){const i=Cm(a);let r=i.data;const s=nn.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,f,p,m,h;function g(){m&&m(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let w=new XMLHttpRequest;w.open(i.method.toUpperCase(),i.url,!0),w.timeout=i.timeout;function F(){if(!w)return;const E=nn.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),S={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:E,config:a,request:w};xm(function(V){t(V),g()},function(V){o(V),g()},S),w=null}"onloadend"in w?w.onloadend=F:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(F)},w.onabort=function(){w&&(o(new He("Request aborted",He.ECONNABORTED,a,w)),w=null)},w.onerror=function(){o(new He("Network Error",He.ERR_NETWORK,a,w)),w=null},w.ontimeout=function(){let v=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const S=i.transitional||km;i.timeoutErrorMessage&&(v=i.timeoutErrorMessage),o(new He(v,S.clarifyTimeoutError?He.ETIMEDOUT:He.ECONNABORTED,a,w)),w=null},r===void 0&&s.setContentType(null),"setRequestHeader"in w&&te.forEach(s.toJSON(),function(v,S){w.setRequestHeader(S,v)}),te.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),l&&l!=="json"&&(w.responseType=i.responseType),d&&([p,h]=Qi(d,!0),w.addEventListener("progress",p)),c&&w.upload&&([f,m]=Qi(c),w.upload.addEventListener("progress",f),w.upload.addEventListener("loadend",m)),(i.cancelToken||i.signal)&&(u=E=>{w&&(o(!E||E.type?new lo(null,a,w):E),w.abort(),w=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const D=UE(i.url);if(D&&Ht.protocols.indexOf(D)===-1){o(new He("Unsupported protocol "+D+":",He.ERR_BAD_REQUEST,a));return}w.send(r||null)})},KE=(a,n)=>{const{length:t}=a=a?a.filter(Boolean):[];if(n||t){let o=new AbortController,i;const r=function(d){if(!i){i=!0,l();const u=d instanceof Error?d:this.reason;o.abort(u instanceof He?u:new lo(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new He(`timeout ${n} of ms exceeded`,He.ETIMEDOUT))},n);const l=()=>{a&&(s&&clearTimeout(s),s=null,a.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),a=null)};a.forEach(d=>d.addEventListener("abort",r));const{signal:c}=o;return c.unsubscribe=()=>te.asap(l),c}},YE=function*(a,n){let t=a.byteLength;if(t<n){yield a;return}let o=0,i;for(;o<t;)i=o+n,yield a.slice(o,i),o=i},qE=async function*(a,n){for await(const t of QE(a))yield*YE(t,n)},QE=async function*(a){if(a[Symbol.asyncIterator]){yield*a;return}const n=a.getReader();try{for(;;){const{done:t,value:o}=await n.read();if(t)break;yield o}}finally{await n.cancel()}},sd=(a,n,t,o)=>{const i=qE(a,n);let r=0,s,l=c=>{s||(s=!0,o&&o(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let f=u.byteLength;if(t){let p=r+=f;t(p)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},Sr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Vm=Sr&&typeof ReadableStream=="function",ex=Sr&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),Nm=(a,...n)=>{try{return!!a(...n)}catch{return!1}},tx=Vm&&Nm(()=>{let a=!1;const n=new Request(Ht.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),ld=64*1024,qs=Vm&&Nm(()=>te.isReadableStream(new Response("").body)),er={stream:qs&&(a=>a.body)};Sr&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!er[n]&&(er[n]=te.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new He(`Response type '${n}' is not supported`,He.ERR_NOT_SUPPORT,o)})})})(new Response);const nx=async a=>{if(a==null)return 0;if(te.isBlob(a))return a.size;if(te.isSpecCompliantForm(a))return(await new Request(Ht.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(te.isArrayBufferView(a)||te.isArrayBuffer(a))return a.byteLength;if(te.isURLSearchParams(a)&&(a=a+""),te.isString(a))return(await ex(a)).byteLength},ax=async(a,n)=>{const t=te.toFiniteNumber(a.getContentLength());return t??nx(n)},ox=Sr&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:f="same-origin",fetchOptions:p}=Cm(a);d=d?(d+"").toLowerCase():"text";let m=KE([i,r&&r.toAbortSignal()],s),h;const g=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let w;try{if(c&&tx&&t!=="get"&&t!=="head"&&(w=await ax(u,o))!==0){let S=new Request(n,{method:"POST",body:o,duplex:"half"}),C;if(te.isFormData(o)&&(C=S.headers.get("content-type"))&&u.setContentType(C),S.body){const[V,x]=od(w,Qi(id(c)));o=sd(S.body,ld,V,x)}}te.isString(f)||(f=f?"include":"omit");const F="credentials"in Request.prototype;h=new Request(n,{...p,signal:m,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:F?f:void 0});let D=await fetch(h,p);const E=qs&&(d==="stream"||d==="response");if(qs&&(l||E&&g)){const S={};["status","statusText","headers"].forEach(N=>{S[N]=D[N]});const C=te.toFiniteNumber(D.headers.get("content-length")),[V,x]=l&&od(C,Qi(id(l),!0))||[];D=new Response(sd(D.body,ld,V,()=>{x&&x(),g&&g()}),S)}d=d||"text";let v=await er[te.findKey(er,d)||"text"](D,a);return!E&&g&&g(),await new Promise((S,C)=>{xm(S,C,{data:v,headers:nn.from(D.headers),status:D.status,statusText:D.statusText,config:a,request:h})})}catch(F){throw g&&g(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new He("Network Error",He.ERR_NETWORK,a,h),{cause:F.cause||F}):He.from(F,F&&F.code,a,h)}}),Qs={http:bE,xhr:JE,fetch:ox};te.forEach(Qs,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const cd=a=>`- ${a}`,ix=a=>te.isFunction(a)||a===null||a===!1,Tm={getAdapter:a=>{a=te.isArray(a)?a:[a];const{length:n}=a;let t,o;const i={};for(let r=0;r<n;r++){t=a[r];let s;if(o=t,!ix(t)&&(o=Qs[(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,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
|
|
347
|
-
`+r.map(cd).join(`
|
|
348
|
-
`):" "+cd(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:Qs};function ls(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new lo(null,a)}function dd(a){return ls(a),a.headers=nn.from(a.headers),a.data=ss.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),Tm.getAdapter(a.adapter||ri.adapter)(a).then(function(o){return ls(a),o.data=ss.call(a,a.transformResponse,o),o.headers=nn.from(o.headers),o},function(o){return Em(o)||(ls(a),o&&o.response&&(o.response.data=ss.call(a,a.transformResponse,o.response),o.response.headers=nn.from(o.response.headers))),Promise.reject(o)})}const Mm="1.11.0",Cr={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{Cr[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const ud={};Cr.transitional=function(n,t,o){function i(r,s){return"[Axios v"+Mm+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,l)=>{if(n===!1)throw new He(i(s," has been removed"+(t?" in "+t:"")),He.ERR_DEPRECATED);return t&&!ud[s]&&(ud[s]=!0),n?n(r,s,l):!0}};Cr.spelling=function(n){return(t,o)=>!0};function rx(a,n,t){if(typeof a!="object")throw new He("options must be an object",He.ERR_BAD_OPTION_VALUE);const o=Object.keys(a);let i=o.length;for(;i-- >0;){const r=o[i],s=n[r];if(s){const l=a[r],c=l===void 0||s(l,r,a);if(c!==!0)throw new He("option "+r+" must be "+c,He.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new He("Unknown option "+r,He.ERR_BAD_OPTION)}}const Pi={assertOptions:rx,validators:Cr},In=Pi.validators;let Sa=class{constructor(n){this.defaults=n||{},this.interceptors={request:new nd,response:new nd}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
|
349
|
-
`+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=Ta(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&Pi.assertOptions(o,{silentJSONParsing:In.transitional(In.boolean),forcedJSONParsing:In.transitional(In.boolean),clarifyTimeoutError:In.transitional(In.boolean)},!1),i!=null&&(te.isFunction(i)?t.paramsSerializer={serialize:i}:Pi.assertOptions(i,{encode:In.function,serialize:In.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Pi.assertOptions(t,{baseUrl:In.spelling("baseURL"),withXsrfToken:In.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&te.merge(r.common,r[t.method]);r&&te.forEach(["delete","get","head","post","put","patch","common"],h=>{delete r[h]}),t.headers=nn.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(c=c&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,f=0,p;if(!c){const h=[dd.bind(this),void 0];for(h.unshift(...l),h.push(...d),p=h.length,u=Promise.resolve(t);f<p;)u=u.then(h[f++],h[f++]);return u}p=l.length;let m=t;for(f=0;f<p;){const h=l[f++],g=l[f++];try{m=h(m)}catch(w){g.call(this,w);break}}try{u=dd.call(this,m)}catch(h){return Promise.reject(h)}for(f=0,p=d.length;f<p;)u=u.then(d[f++],d[f++]);return u}getUri(n){n=Ta(this.defaults,n);const t=Sm(n.baseURL,n.url,n.allowAbsoluteUrls);return wm(t,n.params,n.paramsSerializer)}};te.forEach(["delete","get","head","options"],function(n){Sa.prototype[n]=function(t,o){return this.request(Ta(o||{},{method:n,url:t,data:(o||{}).data}))}});te.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,l){return this.request(Ta(l||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Sa.prototype[n]=t(),Sa.prototype[n+"Form"]=t(!0)});let sx=class Bm{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{o.subscribe(l),r=l}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,l){o.reason||(o.reason=new lo(r,s,l),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=o=>{n.abort(o)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new Bm(function(i){n=i}),cancel:n}}};function lx(a){return function(t){return a.apply(null,t)}}function cx(a){return te.isObject(a)&&a.isAxiosError===!0}const el={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(el).forEach(([a,n])=>{el[n]=a});function Im(a){const n=new Sa(a),t=lm(Sa.prototype.request,n);return te.extend(t,Sa.prototype,n,{allOwnKeys:!0}),te.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return Im(Ta(a,i))},t}const St=Im(ri);St.Axios=Sa;St.CanceledError=lo;St.CancelToken=sx;St.isCancel=Em;St.VERSION=Mm;St.toFormData=xr;St.AxiosError=He;St.Cancel=St.CanceledError;St.all=function(n){return Promise.all(n)};St.spread=lx;St.isAxiosError=cx;St.mergeConfig=Ta;St.AxiosHeaders=nn;St.formToJSON=a=>_m(te.isHTMLForm(a)?new FormData(a):a);St.getAdapter=Tm.getAdapter;St.HttpStatusCode=el;St.default=St;const{Axios:TF,AxiosError:MF,CanceledError:BF,isCancel:IF,CancelToken:FF,VERSION:$F,all:DF,Cancel:RF,isAxiosError:AF,spread:LF,toFormData:PF,AxiosHeaders:OF,HttpStatusCode:UF,formToJSON:zF,getAdapter:jF,mergeConfig:WF}=St;class Vr{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=St.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const o=this.getAuthToken();return o&&(t.headers.Authorization=`Bearer ${o}`),t}),this.api.interceptors.response.use(t=>t,t=>{var o;return(o=t.response)==null||o.status,Promise.reject(t)})}async createJob(n){try{const t=await this.api.post("/video/jobs",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(n){try{const t=await this.api.post("/video/jobs/render",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(n,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.error_message??"Render job failed"))):d.status==="cancelled"?(clearInterval(c),l(new Error("Render job cancelled"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},o)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{const t=await this.api.delete(`/video/jobs/${n}`);return this.unsubscribeFromProgress(n),this.normalizeJob(t.data.data)}catch(t){throw t}}async retryJob(n){try{const t=await this.api.post(`/video/jobs/${n}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(n,t){this.progressCallbacks.set(n,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(n)}unsubscribeFromProgress(n){this.progressCallbacks.delete(n),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const n=this.getAuthToken(),t=`/api/v1/video/jobs/events${n?`?token=${n}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",o=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const o=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(o.progress),(o.status==="completed"||o.status==="failed"||o.status==="cancelled")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const o of t){const[i,r]=o.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(n){try{return(await this.api.get(`/video/jobs/${n}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(n,t=0){try{const o=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(n){const t=n,o={...t,user_id:t.user_id??t.userId??"",source_media_id:t.source_media_id??t.sourceMediaId??"",created_at:t.created_at??t.createdAt??"",updated_at:t.updated_at??t.updatedAt??""},i=t.output_media_id??t.outputMediaId;typeof i=="string"&&i!==""&&(o.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(o.error_message=r);const s=t.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 c=t.started_at??t.startedAt;typeof c=="string"&&c!==""&&(o.started_at=c);const d=t.completed_at??t.completedAt;typeof d=="string"&&d!==""&&(o.completed_at=d);const u=t.cancelled_at??t.cancelledAt;return typeof u=="string"&&u!==""&&(o.cancelled_at=u),o}}new Vr;const dx={key:0,class:"mobile-layout"},ux={class:"mobile-toolbar"},mx={class:"mobile-toolbar-left"},px=["aria-label"],fx={class:"mobile-toolbar-right"},hx=["disabled"],vx=["disabled"],gx={class:"preview-section"},yx={key:0,class:"mobile-export-overlay"},bx={class:"mobile-export-progress"},wx={class:"mobile-export-bar"},kx={class:"mobile-timeline-zoom"},_x={class:"mobile-edit-strip"},Ex={class:"mobile-selection-summary"},xx={class:"mobile-selection-title"},Sx={class:"mobile-selection-meta"},Cx={class:"mobile-readout-row"},Vx=["disabled"],Nx={class:"mobile-readout-grid"},Tx={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},Mx={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},Bx={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},Ix={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},Fx=["disabled"],$x={class:"mobile-speed-strip"},Dx={class:"mobile-speed-chips"},Rx=["data-testid","onClick"],Ax={class:"mobile-edit-actions"},Lx=["disabled"],Px=["disabled"],Ox=["disabled"],Ux=["disabled"],zx=["disabled"],jx={class:"mobile-action-sheet-header"},Wx={class:"mobile-action-sheet-title"},Zx={class:"mobile-action-sheet-subtitle"},Hx={class:"mobile-action-sheet-actions"},Xx=["disabled"],Gx=["disabled"],Jx=["disabled"],Kx=["disabled"],Yx=["disabled"],qx={key:1,class:"desktop-layout"},Qx={class:"desktop-main-row"},eS={class:"preview-panel"},tS={class:"fit-toggle"},nS={class:"editor-content"},aS={class:"editor-tabs"},oS={class:"tab-header"},iS=["onClick"],rS={class:"tab-content-area"},sS={class:"filter-controls"},lS={class:"text-controls"},cS={class:"transition-controls"},dS={class:"audio-controls"},uS={class:"adjustments-controls"},mS={key:1,class:"no-filter-selected"},pS={class:"export-controls"},fS={key:0,"data-testid":"video-export-status-completed"},hS={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},vS={class:"desktop-timeline-row"},gS={class:"timeline-zoom"},yS=["value"],bS={class:"zoom-readout"},wS={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},kS={class:"dev-editor-row"},_S={class:"dev-editor-field"},ES={class:"dev-editor-field"},xS=["disabled"],SS=["disabled"],CS=["disabled"],VS={class:"dev-editor-row"},NS={class:"dev-editor-field dev-editor-field--wide"},TS=["value"],MS=["disabled"],BS=["disabled"],IS=["disabled"],FS=["disabled"],$S=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const y=o.media.uuid??o.media.id;return typeof y=="string"&&y.trim()!==""?y.trim():void 0}),s=e.computed(()=>{const y=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return y!==""?y:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),c=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const y=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},I=o.featureFlags;return I?{filters:typeof I.filters=="boolean"?I.filters:y.filters,adjustments:typeof I.adjustments=="boolean"?I.adjustments:y.adjustments,text:typeof I.text=="boolean"?I.text:y.text,transitions:typeof I.transitions=="boolean"?I.transitions:y.transitions,audio:typeof I.audio=="boolean"?I.audio:y.audio,export:typeof I.export=="boolean"?I.export:y.export}:y}),f=e.computed(()=>l.value?c.value:d.value),p=e.computed(()=>f.value==="filters"||w.value),m=e.computed(()=>f.value!=="filters"&&!w.value),h=e.ref(null),g=e.ref(null),w=e.ref(!1),F=e.computed(()=>l.value?h.value:g.value);function D(y){return y==="contain"||y==="cover"||y==="none"}function E(y){if(!(y!=null&&y.metadata))return null;const I=y.metadata.fit_mode;return D(I)?I:null}const v=e.shallowRef(null),S=e.ref(null),C=e.ref(E(o.initialRecipe)??"contain"),V=e.ref(null),x=e.ref(null),N=e.ref(null),j=e.ref(!1),_=new Map,R=e.ref([]),T=e.ref([]),z=e.ref([]),P=e.ref([]),M=e.ref(1),L=()=>{l.value=window.innerWidth<768},k=[{id:"filters",label:"Filters",icon:na},{id:"adjustments",label:"Adjust",icon:Of},{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:qa}],O=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],W=e.computed(()=>k.filter(y=>u.value[y.id])),G=e.computed(()=>O.filter(y=>u.value[y.id])),ie=e.computed(()=>{var y,I;return((y=G.value[0])==null?void 0:y.id)??((I=W.value[0])==null?void 0:I.id)??"filters"});e.watch(u,y=>{y[c.value]||(c.value=ie.value),y[d.value]||(d.value=ie.value)},{immediate:!0,deep:!0}),e.watch(ie,y=>{u.value[c.value]||(c.value=y),u.value[d.value]||(d.value=y)},{immediate:!0}),e.watch(u,y=>{y.export||(c.value==="export"&&(c.value=ie.value),d.value==="export"&&(d.value=ie.value))},{immediate:!0,deep:!0});const we=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),_e=Wd(),{currentFrame:oe,playheadPosition:$,timelineClips:B,totalDuration:Z,hasChanges:ee,isPlaying:ne,selectedClip:de,zoomLevel:ue,playbackSpeed:ge,fps:Ne,handleTrim:fe,handleSplit:me,handleClipSelect:Ee,splitAtPlayhead:Te,deleteSelectedClip:dt,duplicateSelectedClip:st,setZoomLevel:Dt,moveClip:pt,setFilters:ft,setTextOverlays:_t,setAudioTracks:ot,saveDraft:bt,clearHasChanges:gt,resetChanges:ve,generateRecipe:Se,zoomIn:Fe,zoomOut:Ke,fitToWindow:We,togglePlayback:ze,setPlaying:ut,seekTo:Et,frameForward:It,frameBackward:Rt,skipToStart:Xt,skipToEnd:yn,setPlaybackSpeed:Pn,updateSourceDuration:Y,undo:re,redo:ae,canUndo:ce,canRedo:Be}=nm(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:Le,activeFilters:Oe,selectedFilter:mt,previewFilter:it,previewFilterEffect:rt,applyFilter:wt,updateFilterParams:At,removeFilter:on,clearAllFilters:Sn,setActiveFilters:la}=im();function H(y){var K,le;const I=((K=de.value)==null?void 0:K.id)??((le=B.value[0])==null?void 0:le.id);I&&(j.value=!0,typeof y=="object"&&y.id?wt(y.id):typeof y=="string"&&wt(y),ft(Oe.value),v.value?v.value.setClipFilters(I,Oe.value):_.set(I,[...Oe.value]),Ee(I),j.value=!1,Bn())}function q(){var I,K;const y=((I=de.value)==null?void 0:I.id)??((K=B.value[0])==null?void 0:K.id);y&&Ee(y)}function se(y){const I=Oe.value.find(K=>K.filterId===y);I&&on(I.id)}const xe=e.computed(()=>Le.value.map(I=>{var le;const K=[];if(I.controls&&I.controls.length>0)for(const ke of I.controls){const ye=ke.type;if(ye==="button"||ye==="text"||ye==="range")continue;const be={id:ke.property||ke.id,label:ke.label||ke.id,type:ye,default:ke.default??(ye==="toggle"?!1:ye==="color"?"#ffffff":0)};ye==="slider"&&(be.min=ke.min??0,be.max=ke.max??1,be.step=ke.step??.01),ye==="select"&&ke.options&&(be.options=ke.options),K.push(be)}else if(I.paramRanges){const ke=Object.entries(I.paramRanges);for(const[ye,be]of ke){const at=ye.replace(/[-_]/g," ").replace(/\b\w/g,ha=>ha.toUpperCase()),ln=(le=I.defaultParams)==null?void 0:le[ye],Wa=(be.min+be.max)/2;K.push({id:ye,label:at,min:be.min,max:be.max,step:be.step??.01,default:typeof ln=="number"?ln:Wa})}}return{id:I.id,name:I.name,category:I.category,params:K}})),De=e.ref("0.00"),Ge=e.ref("0.00"),Xe=e.ref("");e.watch(xe,y=>{if(y.length===0){Xe.value="";return}y.some(K=>K.id===Xe.value)||(Xe.value=y[0].id)},{immediate:!0});const Ze=e.ref(!1),je=e.ref(0),Tt=e.ref(!1),lt=e.ref(null),Yt=e.ref(null);let Jn=null,qt=!1;const Da=e.computed(()=>{const y=new Map;return Oe.value.forEach(I=>y.set(I.filterId,I)),y}),Br=e.computed(()=>{var y,I;return oe.value?oe.value:((y=o.media)==null?void 0:y.thumbnail_url)||((I=o.media)==null?void 0:I.url)}),rn=e.ref("");e.watch(()=>{var y,I;return{file:(y=o.media)==null?void 0:y.file,url:(I=o.media)==null?void 0:I.url}},(y,I,K)=>{var ke,ye;const le=rn.value;K(()=>{le&&le.startsWith("blob:")&&URL.revokeObjectURL(le)}),(ke=o.media)!=null&&ke.file?rn.value=URL.createObjectURL(o.media.file):(ye=o.media)!=null&&ye.url?rn.value=o.media.url:rn.value=""},{immediate:!0}),e.onUnmounted(()=>{rn.value&&rn.value.startsWith("blob:")&&URL.revokeObjectURL(rn.value)});const Ra=e.computed(()=>rn.value),Cn=Tu({forcePixiPreview:w,getPreviewRef:()=>F.value,getSourceUrl:()=>rn.value,setPlaying:ut}),Vn=e.computed(()=>{if(!o.media)return null;const{file:y,...I}=o.media;return{...I,url:rn.value}}),kt=e.computed(()=>{var I;const y=(I=o.media)==null?void 0:I.url;return!!(y&&/^https?:/i.test(y))}),sn=e.computed(()=>Oe.value),bn=e.computed(()=>$.value),Aa=e.computed(()=>!!de.value&&$.value>0),ca=e.computed(()=>!!de.value&&B.value.length>1),si=e.computed(()=>!!de.value),wn=e.ref(!0),li=[.5,1,1.5,2],La=e.computed(()=>{const y=new Set([0,Pt.value]);for(const I of B.value)y.add(I.timelineStart),y.add(I.timelineEnd);return Array.from(y).filter(I=>Number.isFinite(I)).sort((I,K)=>I-K)}),Ir=e.computed(()=>La.value.some(y=>y<$.value-.001)),Fr=e.computed(()=>La.value.some(y=>y>$.value+.001)),Kn=e.ref(!1),Pa=e.ref(null);function Nn(y){if(!Number.isFinite(y)||y<0)return"0:00";const I=Math.floor(y/60),K=Math.floor(y%60);return`${I}:${K.toString().padStart(2,"0")}`}const $r=e.computed(()=>{var K;const y=de.value??B.value[0];if(!y)return"No clip selected";const I=(K=y.label)==null?void 0:K.trim();return I&&I.length>0?I:`Clip ${y.id.slice(-4)}`}),Oa=e.computed(()=>{const y=de.value??B.value[0];if(!y)return"Tap a clip to start editing";const I=Math.max(0,y.timelineEnd-y.timelineStart);return`${Nn(y.timelineStart)} - ${Nn(y.timelineEnd)} • ${I.toFixed(1)}s`});function ci(y){return!Number.isFinite(y)||y<0?"0.0s":y<60?`${y.toFixed(1)}s`:Nn(y)}const di=e.computed(()=>Nn($.value)),Dr=e.computed(()=>{const y=de.value??B.value[0];return y?Nn(y.sourceIn):"0:00"}),Lt=e.computed(()=>{const y=de.value??B.value[0];return y?Nn(y.sourceOut):"0:00"}),da=e.computed(()=>{const y=de.value??B.value[0];return y?ci(y.timelineEnd-y.timelineStart):"0.0s"}),fn=e.computed(()=>Pa.value===null?de.value??B.value[0]??null:B.value.find(y=>y.id===Pa.value)??null),yt=e.computed(()=>{var K;const y=fn.value;if(!y)return"Clip actions";const I=(K=y.label)==null?void 0:K.trim();return I&&I.length>0?I:`Clip ${y.id.slice(-4)}`}),On=e.computed(()=>{const y=fn.value;return y?`${Nn(y.timelineStart)} - ${Nn(y.timelineEnd)} • ${ci(y.timelineEnd-y.timelineStart)}`:"Choose an action"}),ua=e.ref(0),Pt=e.computed(()=>{try{const y=Z.value??Z;return y&&typeof y=="number"&&y>0?y:ua.value}catch{return ua.value}}),Qt=e.ref(),Ua=e.ref(),co=e.ref(),za=e.ref(),Ut=e.ref(0),Un=e.ref(!1);let zt=null,Gt=null;e.watch(Pt,y=>{var K;if(Un.value||!y||y<=0)return;const I=Ut.value||((K=Qt.value)==null?void 0:K.clientWidth)||0;I>0&&(Un.value=!0,We(I))}),e.watch(Ut,y=>{if(Un.value||!y||y<=0)return;Pt.value>0&&(Un.value=!0,We(y))}),e.watch(l,y=>{y||jn()}),e.watch(()=>{var y;return(y=fn.value)==null?void 0:y.id},y=>{Kn.value&&!y&&jn()});function Tn(y){return Number.isFinite(y)?y.toFixed(2):"0.00"}function Mn(y){const I=Number(y);return Number.isFinite(I)?I:null}function Rr(y){y&&(De.value=Tn(y.sourceIn),Ge.value=Tn(y.sourceOut))}e.watch(()=>{var y,I,K;return[(y=de.value)==null?void 0:y.id,(I=de.value)==null?void 0:I.sourceIn,(K=de.value)==null?void 0:K.sourceOut]},()=>{Rr(de.value)},{immediate:!0});function uo(y){const I=de.value;if(!I)return;const K=1/30,le=I.sourceMinIn??0,ke=I.sourceMaxOut??Pt.value,ye=I.sourceIn+($.value-I.timelineStart);if(y==="start"){const at=Math.max(le,Math.min(ye,I.sourceOut-K));De.value=Tn(at);return}const be=Math.max(I.sourceIn+K,Math.min(ye,ke));Ge.value=Tn(be)}function ui(){const y=de.value;if(!y)return;const I=Mn(De.value),K=Mn(Ge.value);if(I===null||K===null)return;const le=1/30,ke=y.sourceMinIn??0,ye=y.sourceMaxOut??Pt.value,be=Math.max(ke,Math.min(I,ye-le)),at=Math.max(be+le,Math.min(K,ye));fe(y.id,"start",be),fe(y.id,"end",at),De.value=Tn(be),Ge.value=Tn(at),de.value&&Et(de.value.timelineStart)}function mo(){Xe.value.trim()!==""&&H(Xe.value)}function mi(){var y;Sn(),ft(Oe.value),(y=de.value)!=null&&y.id&&(v.value?v.value.setClipFilters(de.value.id,Oe.value):_.set(de.value.id,[...Oe.value])),Bn()}function ja(y,I,K){var ke,ye;const le=Oe.value.find(be=>be.filterId===y);le?(le.params={...le.params,[I]:K},ft(Oe.value),v.value&&((ke=de.value)!=null&&ke.id)?v.value.setClipFilters(de.value.id,Oe.value):(ye=de.value)!=null&&ye.id&&_.set(de.value.id,[...Oe.value]),Bn(),q()):it.value&&it.value.filterId===y&&(it.value.params={...it.value.params||{},[I]:K})}function po(y){Et(y)}function ma(y){!y||!Number.isFinite(y.timestamp)||Et(y.timestamp)}function pa(y){ut(y)}function zn(y){!Number.isFinite(y)||y<=0||(ua.value=y,Y(y))}function jn(){Kn.value=!1,Pa.value=null}function Ar(y){l.value&&(Pa.value=y,Kn.value=!0)}function pi(y){var le,ke,ye,be;const I=((le=de.value)==null?void 0:le.id)??((ke=B.value[0])==null?void 0:ke.id)??null;Ee(y),(((ye=de.value)==null?void 0:ye.id)??((be=B.value[0])==null?void 0:be.id)??null)!==I&&_e.selection()}function Lr(y){pi(y),Ar(y)}function fo(y){y&&_e.selection()}function ho(){wn.value=!wn.value,_e.selection()}function vo(){const y=La.value.filter(K=>K<$.value-.001),I=y.length>0?y[y.length-1]:0;Et(I)}function go(){const y=La.value.find(I=>I>$.value+.001);Et(y??Pt.value)}function b(){re()}function A(){ae()}function Q(){const y=B.value.length;Te(),B.value.length>y&&(_e.success(),jn())}function he(y){const I=B.value.length;me(y),B.value.length>I&&_e.success()}function Re(){const y=B.value.length;st(),B.value.length>y&&(_e.selection(),jn())}function $e(){const y=B.value.length;dt(),B.value.length<y&&(_e.error(),jn())}function Ye(y){const I=ge.value;Pn(y),ge.value!==I&&_e.selection()}function ht(y){return y instanceof HTMLElement?y.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Mt(y){if(l.value||ht(y.target))return;const I=y.key.toLowerCase(),K=y.metaKey||y.ctrlKey;if(y.code==="Space"){y.preventDefault(),ze();return}if(!K&&I==="s"){y.preventDefault(),Q();return}if(I==="arrowleft"){y.preventDefault(),Rt();return}if(I==="arrowright"){y.preventDefault(),It();return}if(I==="home"){y.preventDefault(),Xt();return}if(I==="end"){y.preventDefault(),yn();return}if(!K&&I==="["){y.preventDefault(),vo();return}if(!K&&I==="]"){y.preventDefault(),go();return}if(K&&I==="z"&&y.shiftKey){y.preventDefault(),A();return}K&&I==="z"&&(y.preventDefault(),b())}function Jt(){var I;const y=Ut.value||((I=Qt.value)==null?void 0:I.clientWidth)||800;We(y)}function Yn(y){Un.value=!0,Dt(y)}function sp(){Un.value=!0,Fe()}function lp(){Un.value=!0,Ke()}function cp(y){const I=y.target,K=Number(I.value);Yn(K)}function Zl(y){const I=Math.min(600,Math.max(10,ue.value+y));Yn(I)}function Pr(){Gt==null||Gt(),Gt=null;const y=co.value,I=za.value;if(!l.value||!y||!I)return;const K=()=>{Zl(-20)},le=()=>{Zl(20)};y.addEventListener("click",K),I.addEventListener("click",le),Gt=()=>{y.removeEventListener("click",K),I.removeEventListener("click",le)}}e.watch([l,co,za],()=>{Pr()},{flush:"post"});function Hl(y){var I;v.value=y,(I=v.value)!=null&&I.composition&&(V.value=new rm(v.value.composition),x.value=new jo(v.value.composition),N.value=new sm(v.value.composition));try{_.size&&(_.forEach((K,le)=>{v.value.setClipFilters(le,K)}),_.clear(),v.value.composition.computeFrame())}catch{}}function dp(y){y!=null&&y.id&&rt(y.id)}function up(y){At(y),Bn()}async function mp(y){if(!V.value)return;const I=await V.value.addTextOverlay(y);R.value.push({id:I,...y})}async function pp(y,I){if(!V.value)return;await V.value.updateTextOverlay(y,I);const K=R.value.findIndex(le=>le.id===y);K!==-1&&(R.value[K]={...R.value[K],...I})}async function fp(y){V.value&&(await V.value.removeTextOverlay(y),R.value=R.value.filter(I=>I.id!==y))}async function hp(y){if(!x.value||P.value.length<2)return;const[I,K]=P.value,le=await x.value.applyTransition(I,K,y);T.value.push({id:le,...y,name:y.type})}function vp(y){if(!x.value)return;const I=T.value[y];I&&(x.value.removeTransition(I.id),T.value.splice(y,1))}function gp(y){}async function yp(y){if(!N.value)return;const I=await N.value.addAudioTrack(y);z.value.push({id:I,...y})}async function bp(y,I){if(!N.value)return;const K=z.value.findIndex(le=>le.id===y);K!==-1&&(z.value[K]={...z.value[K],...I})}async function wp(y){N.value&&(await N.value.removeAudioTrack(y),z.value=z.value.filter(I=>I.id!==y))}async function kp(y,I){if(!N.value)return;await N.value.updateVolume(y,I);const K=z.value.find(le=>le.id===y);K&&(K.volume=I)}async function _p(y,I){if(!N.value)return;await N.value.muteTrack(y,I);const K=z.value.find(le=>le.id===y);K&&(K.muted=I)}function Ep(y){N.value&&(N.value.setMasterVolume(y),M.value=y)}function xp(y){i("thumbnail-selected",y)}function qn(){Jn!==null&&(clearInterval(Jn),Jn=null)}function Sp(y,I){return I?{...y,output:{...y.output,format:I.format,quality:I.quality}}:y}function yo(y){var I;return y.metadata||(y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),y.metadata.fit_mode=C.value,(I=o.media)!=null&&I.url&&/^https?:/i.test(o.media.url)?y.metadata.source_url=o.media.url:delete y.metadata.source_url,y}function xt(y,I,K){return Math.min(K,Math.max(I,y))}function Or(y,I){if(typeof y=="number"&&Number.isFinite(y))return y;if(typeof y=="string"){const K=Number(y);if(Number.isFinite(K))return K}return I}function jt(y,I,K){for(const le of I)if(le in y)return Or(y[le],K);return K}function Cp(y){const I=typeof y.params=="object"&&y.params!==null?y.params:{};switch(y.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:xt(jt(I,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:xt(jt(I,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:xt(jt(I,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:xt(jt(I,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:xt(jt(I,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const le=xt(jt(I,["brightness"],1)-1,-1,1),ke=xt(jt(I,["contrast"],1),.1,3),ye=xt(jt(I,["saturation"],1),0,3);return[{type:"brightness",value:le},{type:"contrast",value:ke},{type:"saturation",value:ye}]}default:return[]}}function Vp(y){const I=y.timeline[0],K=Array.isArray(I==null?void 0:I.filters)?I.filters:[],le=[];for(const ye of K)if(le.push(...Cp(ye)),le.length>=12)break;const ke={...y,filters:le.slice(0,12)};if(y.timeline.length===1&&I){const ye=Math.max(0,Or(I.sourceIn,0)),be=Or(I.sourceOut,ye);be>ye&&(ke.trim={start:ye,end:be})}return ke}async function Xl(y,I,K){return Cn.renderRecipeWithPixi(y,I,K)}async function Np(y,I){var bo;qn(),qt=!1,Cn.resetClientExport(),Yt.value=null,lt.value=null,Tt.value=!1,je.value=0;const K=yo(y??Se()),le=ec(K),ke=Array.isArray(le.filters)&&le.filters.length>0,ye=jr(le);if(!(ee.value||ke||ye))return gt(),i("video-exported",null),null;const at=le.timeline[0],ln=at?Math.max(0,at.sourceIn):0,ha=((at==null?void 0:at.sourceOut)??((bo=le.source)==null?void 0:bo.duration)??Pt.value)-ln,Hr=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&ha>o.clientExportThreshold;if(Hr){Ze.value=!0;try{return await Tp(le),null}catch(Wt){const cn=Wt instanceof Error?Wt.message:"Server render failed";throw lt.value=cn,i("server-render-failed",cn),Wt}finally{Ze.value=!1}}if(o.maxDuration>0&&ha>o.maxDuration&&!Hr){const Wt=`This video is too long for in-browser export (${Math.round(ha)}s). Server rendering is not available. Try a shorter clip.`;return lt.value=Wt,i("video-exported",null),null}Ze.value=!0;try{const Wt=await Xl(le,I,cn=>{qt||(je.value=cn)});return qt?(lt.value="Export canceled.",je.value=0,i("video-exported",null),null):(gt(),i("recipe-generated",le),i("video-exported",Wt),je.value=100,Tt.value=!0,Wt)}catch(Wt){if(qt)return lt.value="Export canceled.",je.value=0,i("video-exported",null),null;const cn=Wt instanceof Error?Wt.message:"Local WebGL export failed.";throw lt.value=cn,new Error(`Video export failed: ${cn}`)}finally{Ze.value=!1}}function fi(){return new Vr(o.serverRenderEndpoint??"/api/v1")}async function Tp(y){const I=fi();lt.value="Starting server render...",je.value=0;const K=await I.createRenderJob({source_media_uuid:s.value,recipe:y});Yt.value=K.id,i("server-render-started",K.id),i("export-started",K.id),lt.value="Rendering on server...";const le=await I.pollRenderJob(K.id,(ye,be)=>{je.value=ye,be==="processing"&&(lt.value=`Server rendering: ${ye}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);je.value=100,Tt.value=!0,lt.value="Server render complete!",gt(),i("recipe-generated",y);const ke={id:le.id};typeof le.output_media_id=="string"&&le.output_media_id!==""&&(ke.output_media_id=le.output_media_id),i("server-render-completed",ke)}async function Gl(){if(!Ze.value)return;qt=!0,w.value=!1,Cn.cancelClientExport(),qn();const y=Yt.value;if(y)try{await fi().cancelJob(y)}catch(I){const K=I instanceof Error?I.message:"Failed to cancel export";lt.value=K,Ze.value=!1,Yt.value=null;return}Ze.value=!1,je.value=0,Tt.value=!1,Yt.value=null,lt.value="Export canceled."}async function Jl(y){qn(),qt=!1,Cn.resetClientExport(),Yt.value=null,lt.value=null,Tt.value=!1,Ze.value=!0,je.value=0;try{const I=yo(Sp(Se(),y));i("recipe-generated",I);const K=s.value.startsWith("temp-"),le=I.timeline[0],ke=Array.isArray(le==null?void 0:le.filters)?le.filters:[],ye=!0,be=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(ye)try{const cn=await Xl(I,y,zp=>{qt||(je.value=zp)});if(qt){lt.value="Export canceled.",Ze.value=!1,je.value=0;return}i("video-exported",cn);const nc=URL.createObjectURL(cn.file),Xr=document.createElement("a");Xr.href=nc,Xr.download=`edited-video-${Date.now()}.mp4`,Xr.click(),setTimeout(()=>URL.revokeObjectURL(nc),100),Ze.value=!1,je.value=100,Tt.value=!0;return}catch(cn){if(qt){lt.value="Export canceled.",Ze.value=!1,je.value=0;return}if(K||!be)throw cn;je.value=0,lt.value="Local filter export failed, falling back to server render."}const at={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},ln=(y==null?void 0:y.quality)??I.output.quality,Wa=at[ln]??"high",ha={...Vp(I),export:{format:(y==null?void 0:y.format)??I.output.format,quality:Wa,resolution:ln,framerate:I.output.fps}},bo=await fi().createJob({source_media_id:s.value,recipe:ha}),Wt=typeof bo.id=="string"?bo.id:null;if(!Wt)throw new Error("Export failed: missing job id");Yt.value=Wt,i("export-started",Wt),Op(Wt)}catch(I){if(w.value=!1,Cn.resetClientExport(),qt){lt.value="Export canceled.",Ze.value=!1,je.value=0,Yt.value=null;return}try{const K=yo(Se()),le=new Blob([JSON.stringify(K,null,2)],{type:"application/json"}),ke=URL.createObjectURL(le),ye=document.createElement("a");ye.href=ke,ye.download=`video-recipe-${Date.now()}.json`,ye.click(),setTimeout(()=>URL.revokeObjectURL(ke),100)}finally{Ze.value=!1,je.value=0,Yt.value=null,lt.value=I instanceof Error?I.message:"Export failed"}}}const Ur=async y=>{await new Promise(I=>{window.setTimeout(I,y)})},zr=y=>{if(!y||y.width<=0||y.height<=0)return null;try{return y.toDataURL("image/jpeg",.85)}catch{return null}},Mp=y=>{if(!y||typeof y!="object")return null;const K=y.pixiCanvas;if(K&&typeof K=="object"&&"value"in K){const le=K.value;return le instanceof HTMLCanvasElement?le:null}return K instanceof HTMLCanvasElement?K:null},Bp=y=>{if(!y||typeof y!="object")return null;const I=y.duration;if(typeof I=="number"&&Number.isFinite(I))return I;if(I&&typeof I=="object"&&"value"in I){const K=I.value;if(typeof K=="number"&&Number.isFinite(K))return K}return null},Ip=y=>{if(!y||typeof y!="object")return null;const K=y.videoElement;if(K&&typeof K=="object"&&"value"in K){const le=K.value;return le instanceof HTMLVideoElement?le:null}return K instanceof HTMLVideoElement?K:null},Kl=y=>typeof y.params=="object"&&y.params!==null?y.params:{},Fp=y=>{const I=[];for(const K of y){const le=Kl(K),ke=K.filterId.trim().toLowerCase();if(ke==="brightness"){const be=(xt(jt(le,["value","brightness"],0),-1,1)+1)*100;I.push(`brightness(${be.toFixed(2)}%)`);continue}if(ke==="contrast"){const ye=xt(jt(le,["value","contrast"],1),.1,4);I.push(`contrast(${(ye*100).toFixed(2)}%)`);continue}if(ke==="saturation"||ke==="saturate"){const ye=xt(jt(le,["value","saturation"],1),0,4);I.push(`saturate(${(ye*100).toFixed(2)}%)`);continue}if(ke==="grayscale"){I.push("grayscale(100%)");continue}if(ke==="sepia"){I.push("sepia(100%)");continue}if(ke==="blur"||ke==="gaussian-blur"||ke==="kawase-blur"){const ye=xt(jt(le,["value","blur","radius"],0),0,30);ye>.01&&I.push(`blur(${ye.toFixed(2)}px)`);continue}if(ke==="adjustment"){const ye=jt(le,["brightness"],1),be=jt(le,["contrast"],1),at=jt(le,["saturation"],1);Math.abs(ye-1)>.01&&I.push(`brightness(${(xt(ye,0,5)*100).toFixed(2)}%)`),Math.abs(be-1)>.01&&I.push(`contrast(${(xt(be,.1,5)*100).toFixed(2)}%)`),Math.abs(at-1)>.01&&I.push(`saturate(${(xt(at,0,5)*100).toFixed(2)}%)`);continue}if(ke==="cinematic"){I.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ke==="dramatic"){I.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ke==="dreamy"){I.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return I.join(" ")},$p=y=>{const I=y.find(ke=>ke.filterId.trim().toLowerCase()==="noise");if(!I)return 0;const K=Kl(I),le=jt(K,["noise","value","amount","intensity"],.2);return le<=1?xt(le,0,1):xt(le/100,0,1)},Dp=(y,I,K,le)=>{if(le<=0)return;const ke=y.getImageData(0,0,I,K),ye=255*le;for(let be=0;be<ke.data.length;be+=4){const at=(Math.random()*2-1)*ye;ke.data[be]=xt(ke.data[be]+at,0,255),ke.data[be+1]=xt(ke.data[be+1]+at,0,255),ke.data[be+2]=xt(ke.data[be+2]+at,0,255)}y.putImageData(ke,0,0)},Yl=async y=>{y.readyState>=2&&y.videoWidth>0&&y.videoHeight>0||await new Promise(I=>{let K=!1,le=0;const ke=()=>{K||(K=!0,y.removeEventListener("loadedmetadata",ye),y.removeEventListener("loadeddata",ye),y.removeEventListener("canplay",ye),window.clearTimeout(le),I())},ye=()=>{ke()};y.addEventListener("loadedmetadata",ye),y.addEventListener("loadeddata",ye),y.addEventListener("canplay",ye),le=window.setTimeout(()=>ke(),800),y.play().catch(()=>{})})},Rp=async(y,I)=>{await new Promise(K=>{let le=!1,ke=0;const ye=()=>{le||(le=!0,y.removeEventListener("seeked",be),window.clearTimeout(ke),K())},be=()=>{ye()};if(Math.abs(y.currentTime-I)<.016){requestAnimationFrame(()=>ye());return}y.addEventListener("seeked",be),ke=window.setTimeout(()=>ye(),700),y.currentTime=I})},ql=async(y,I)=>{await Yl(y);const K=Math.floor(y.videoWidth),le=Math.floor(y.videoHeight);if(K<=0||le<=0)return null;const ke=Number.isFinite(y.duration)&&y.duration>0?y.duration:0,ye=ke>0?xt(I,0,ke):0;await Rp(y,ye);const be=document.createElement("canvas");be.width=K,be.height=le;const at=be.getContext("2d");if(!at)return null;const ln=Fp(Oe.value);ln!==""&&(at.filter=ln);try{at.drawImage(y,0,0,K,le)}catch{return null}const Wa=$p(Oe.value);return Dp(at,K,le,Wa),zr(be)},Ap=async(y,I)=>{const K=document.createElement("video");K.src=y,K.muted=!0,K.playsInline=!0,K.preload="auto",y.startsWith("blob:")||(K.crossOrigin="anonymous");try{return await Yl(K),await ql(K,I)}catch{return null}finally{K.pause(),K.removeAttribute("src"),K.load()}},Lp=async y=>{const I=F.value,K=zr(Mp(I));if(K)return K;if(I!=null&&I.captureFrameAt)for(let ye=0;ye<4;ye+=1){const be=Bp(I);if(be!==null&&be<=0&&ye<2){await Ur(80);continue}const at=await Promise.race([I.captureFrameAt(y),Ur(450).then(()=>null)]),ln=zr(at);if(ln)return ln;await Ur(80)}const le=Ip(I);if(le){const ye=await ql(le,y);if(ye)return ye}const ke=Ra.value.trim();if(ke!==""){const ye=await Ap(ke,y);if(ye)return ye}return null},Ql=y=>y.map(I=>({...I,params:I.params&&typeof I.params=="object"?{...I.params}:I.params}));function ec(y){const I=Ql(Oe.value);if(!jr(y)&&I.length>0&&Array.isArray(y.timeline)&&y.timeline.length>0){const le=y.timeline[0];le&&(y.timeline=[{...le,filters:I},...y.timeline.slice(1)])}return y}const jr=y=>Array.isArray(y.timeline)?y.timeline.some(I=>Array.isArray(I.filters)&&I.filters.length>0):!1,Pp=y=>{if(!y||typeof y!="object")return null;const I=y.posterFrame;if(typeof I!="string")return null;const K=I.trim();return K!==""?K:null};async function Wr(){const y=yo(ec(bt())),I=Ql(Oe.value),K=jr(y)||I.length>0,le=Pp(o.initialRecipe);if(K){const ke=$.value>0?$.value:.1;try{const ye=await Lp(ke);ye?y.posterFrame=ye:le&&(y.posterFrame=le)}catch{le&&(y.posterFrame=le)}}else delete y.posterFrame;return gt(),i("draft-saved",y),y}function tc(){ve()&&(Sn(),Bn())}async function Op(y){qn();const I=fi();Jn=window.setInterval(async()=>{try{if(qt){qn();return}const K=await I.getJob(y),le=Number(K.progress??0);if(je.value=Number.isFinite(le)?le:0,K.status==="completed"||K.status==="failed"||K.status==="cancelled")if(qn(),Ze.value=!1,Yt.value=null,K.status==="completed")je.value=100,Tt.value=!0,lt.value=null;else{const ke=K.status==="cancelled"||typeof K.error_message=="string"&&/cancel/i.test(K.error_message);lt.value=ke?"Export canceled.":typeof K.error_message=="string"&&K.error_message.trim()!==""?K.error_message:"Export failed"}}catch(K){qn(),Ze.value=!1,Yt.value=null,lt.value=K instanceof Error?K.message:"Failed to check export progress"}},2e3)}function Zr(){const y=yo(Se());try{const I=y.timeline??[]}catch{}S.value=y}let fa=null;function Bn(){fa&&clearTimeout(fa),fa=setTimeout(()=>{Zr(),fa=null},200)}e.watch(()=>B.value,Bn,{deep:!0}),e.watch(()=>de.value,y=>{if(j.value||!y)return;const I=(y==null?void 0:y.filters)??[];la(I)},{immediate:!0}),e.watch(()=>Oe.value,y=>{ft(y),Bn()},{deep:!0}),e.watch(()=>R.value,y=>{_t(y),Bn()},{deep:!0}),e.watch(()=>z.value,y=>{const I=y.map(K=>({...K,source:typeof K.source=="string"?K.source:void 0}));ot(I),Bn()},{deep:!0}),e.watch(()=>$.value,Bn),n({saveDraft:Wr,exportForUpload:Np}),Zr(),e.onUnmounted(()=>{qn(),qt=!0,Cn.cancelClientExport(),fa&&(clearTimeout(fa),fa=null),v.value&&(v.value.destroy(),v.value=null),V.value=null,x.value=null,N.value=null});function Up(){zt||!Ua.value||(zt=new X2({filters:xe.value,callbacks:{onApplyFilter:y=>{H(y.id)},onRemoveFilter:y=>{se(y)},onUpdateParam:(y,I,K)=>{ja(y,I,K)},onPreviewFilter:y=>{rt(y.id)}}}),zt.mount(Ua.value),zt.setActiveFilters(Da.value))}e.watch(Da,y=>{zt==null||zt.setActiveFilters(y)},{deep:!0}),e.watch(xe,y=>{zt==null||zt.setFilters(y)});let Qn=null;return e.onMounted(()=>{window.addEventListener("resize",L),window.addEventListener("keydown",Mt);const y=()=>{!Qt.value||Qn||(Qn=new ResizeObserver(I=>{I[0]&&(Ut.value=Math.round(I[0].contentRect.width))}),Qn.observe(Qt.value))};y(),Qn||e.nextTick(y),l.value&&(Pr(),Gt||e.nextTick(Pr)),o.media&&Zr(),l.value&&e.nextTick(()=>{Up()}),e.nextTick(()=>{const I=document.querySelector(".video-editor");I&&I.getBoundingClientRect();const K=document.querySelector(".mobile-layout");K&&K.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",L),window.removeEventListener("keydown",Mt),Qn==null||Qn.disconnect(),Qn=null,Gt==null||Gt(),Gt=null,zt==null||zt.destroy(),zt=null}),(y,I)=>{var K,le,ke,ye;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",dx,[e.createElementVNode("div",ux,[e.createElementVNode("div",mx,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ne)}]),onClick:I[0]||(I[0]=(...be)=>e.unref(ze)&&e.unref(ze)(...be)),"aria-label":e.unref(ne)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ne)?e.unref(il):e.unref(rl)},null,8,["icon"])],10,px),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:tc,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba)},null,8,["icon"])])]),e.createElementVNode("div",fx,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Wr,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ee)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ar)},null,8,["icon"]),I[13]||(I[13]=e.createElementVNode("span",null,"Save",-1))],8,hx),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:I[1]||(I[1]=be=>Jl()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:Ze.value||!e.unref(ee)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qa)},null,8,["icon"])],8,vx),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:I[2]||(I[2]=be=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca)},null,8,["icon"])])])]),e.createElementVNode("div",gx,[e.withDirectives(e.createVNode(ys,{ref_key:"pixiPreviewMobileRef",ref:h,"aria-hidden":!p.value,class:"preview-host-child",source:Ra.value,"fallback-duration":Pt.value,filters:sn.value,playhead:bn.value,"is-playing":e.unref(ne),"fit-mode":C.value,active:p.value,onPlayPause:e.unref(ze),onFrameUpdate:ma,onDurationChange:zn},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode($s,{"aria-hidden":!m.value,class:"preview-host-child","media-uuid":s.value,recipe:S.value,media:Vn.value,"enable-engine":m.value&&kt.value,"fit-mode":C.value,onTimeUpdate:po,onPlayStateChange:pa,onDurationChange:zn,onEngineReady:Hl},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,m.value]]),Ze.value?(e.openBlock(),e.createElementBlock("div",yx,[e.createElementVNode("div",bx,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(je.value)+"%",1),e.createElementVNode("div",wx,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:je.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Gl},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Qt,class:"timeline-section"},[e.createElementVNode("div",kx,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:co,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...I[14]||(I[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:za,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...I[15]||(I[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(Ds,{playhead:e.unref($),clips:e.unref(B),"selected-clip-id":((K=e.unref(de))==null?void 0:K.id)??((le=e.unref(B)[0])==null?void 0:le.id)??null,duration:Pt.value,fps:e.unref(Ne),"zoom-level":e.unref(ue),"snap-enabled":wn.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Et),onTrim:e.unref(fe),onSplit:he,onClipSelect:pi,onClipMove:e.unref(pt),onClipLongPress:Lr,onSnapStateChange:fo},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",_x,[e.createElementVNode("div",Ex,[e.createElementVNode("span",xx,e.toDisplayString($r.value),1),e.createElementVNode("span",Sx,e.toDisplayString(Oa.value),1)]),e.createElementVNode("div",Cx,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!Ir.value,onClick:vo}," Prev Cut ",8,Vx),e.createElementVNode("div",Nx,[e.createElementVNode("span",Tx,"Playhead "+e.toDisplayString(di.value),1),e.createElementVNode("span",Mx,"In "+e.toDisplayString(Dr.value),1),e.createElementVNode("span",Bx,"Out "+e.toDisplayString(Lt.value),1),e.createElementVNode("span",Ix,"Duration "+e.toDisplayString(da.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:!Fr.value,onClick:go}," Next Cut ",8,Fx)]),e.createElementVNode("div",$x,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:wn.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:ho},e.toDisplayString(wn.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",Dx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(li,be=>e.createElementVNode("button",{key:be,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(ge)===be}]),"data-testid":`btn-mobile-speed-${String(be).replace(".","-")}`,onClick:at=>Ye(be)},e.toDisplayString(be)+"x ",11,Rx)),64))])]),e.createElementVNode("div",Ax,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(ce),onClick:b}," Undo ",8,Lx),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(Be),onClick:A}," Redo ",8,Px),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!Aa.value,onClick:Q}," Split ",8,Ox),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!si.value,onClick:Re}," Duplicate ",8,Ux),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!ca.value,onClick:$e}," Delete ",8,zx)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Ua,class:"controls-section mobile-controls"},null,512),Kn.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:jn},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:I[3]||(I[3]=e.withModifiers(()=>{},["stop"]))},[I[16]||(I[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",jx,[e.createElementVNode("span",Wx,e.toDisplayString(yt.value),1),e.createElementVNode("span",Zx,e.toDisplayString(On.value),1)]),e.createElementVNode("div",Hx,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(ce),onClick:b},"Undo",8,Xx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(Be),onClick:A},"Redo",8,Gx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!Aa.value,onClick:Q},"Split",8,Jx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!si.value,onClick:Re},"Duplicate",8,Kx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!ca.value,onClick:$e},"Delete",8,Yx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:jn},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",qx,[e.createElementVNode("div",Qx,[e.createElementVNode("div",eS,[e.createElementVNode("div",tS,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":I[4]||(I[4]=be=>C.value=be),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...I[17]||(I[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(ys,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!p.value,class:"preview-host-child",source:Ra.value,"fallback-duration":Pt.value,filters:sn.value,playhead:bn.value,"is-playing":e.unref(ne),"fit-mode":C.value,active:p.value,onPlayPause:e.unref(ze),onFrameUpdate:ma,onDurationChange:zn},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode($s,{"aria-hidden":!m.value,class:"preview-host-child","media-uuid":s.value,recipe:S.value,media:Vn.value,"enable-engine":m.value&&kt.value,"fit-mode":C.value,onTimeUpdate:po,onPlayStateChange:pa,onDurationChange:zn,onEngineReady:Hl},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,m.value]]),y.showThumbnailPicker?(e.openBlock(),e.createBlock(xw,{key:0,"media-uuid":s.value,duration:Pt.value,onSelect:xp},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",nS,[e.createElementVNode("div",aS,[e.createElementVNode("div",oS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,be=>(e.openBlock(),e.createElementBlock("button",{key:be.id,class:e.normalizeClass(["tab-btn",{active:d.value===be.id}]),onClick:at=>d.value=be.id},e.toDisplayString(be.label),11,iS))),128))]),e.createElementVNode("div",rS,[e.withDirectives(e.createElementVNode("div",sS,[e.createVNode(As,{filters:xe.value,"active-filters":Da.value,"thumbnail-url":Br.value,onApplyFilter:H,onRemoveFilter:se,onUpdateParam:ja,onPreviewFilter:dp},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",lS,[e.createVNode(Os,{overlays:R.value,onAddOverlay:mp,onUpdateOverlay:pp,onRemoveOverlay:fp},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",cS,[e.createVNode(Us,{"selected-clips":P.value,"applied-transitions":T.value,onApplyTransition:hp,onRemoveTransition:vp,onPreviewTransition:gp},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",dS,[e.createVNode(zs,{"audio-layers":z.value,"master-volume":M.value,onAddTrack:yp,onUpdateTrack:bp,onRemoveTrack:wp,onUpdateVolume:kp,onToggleMute:_p,onUpdateMasterVolume:Ep},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",uS,[e.unref(mt)?(e.openBlock(),e.createBlock(Ls,{key:0,filter:e.unref(mt),"current-frame":e.unref(oe),onUpdateParams:up},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",mS,[...I[18]||(I[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",pS,[e.createVNode(Ps,{"can-export":e.unref(ee),"is-exporting":Ze.value,"export-progress":je.value,onExport:Jl,onCancelExport:Gl,onSaveDraft:Wr,onReset:tc},null,8,["can-export","is-exporting","export-progress"]),Tt.value?(e.openBlock(),e.createElementBlock("div",fS," Export complete ")):e.createCommentVNode("",!0),lt.value&&!Tt.value?(e.openBlock(),e.createElementBlock("div",hS,e.toDisplayString(lt.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",vS,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Qt,class:"timeline-container"},[e.createElementVNode("div",gS,[e.createElementVNode("label",null,[I[19]||(I[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ue),onInput:I[5]||(I[5]=be=>cp(be))},null,40,yS)]),e.createElementVNode("span",bS,e.toDisplayString(Math.round(e.unref(ue)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:wn.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:ho},e.toDisplayString(wn.value?"Snap On":"Snap Off"),3)]),e.createVNode(Ds,{playhead:e.unref($),clips:e.unref(B),"selected-clip-id":((ke=e.unref(de))==null?void 0:ke.id)??((ye=e.unref(B)[0])==null?void 0:ye.id)??null,duration:Pt.value,fps:e.unref(Ne),"zoom-level":e.unref(ue),"snap-enabled":wn.value,sensitivity:.25,"onUpdate:playhead":e.unref(Et),onTrim:e.unref(fe),onSplit:he,onClipSelect:pi,onClipMove:e.unref(pt),onClipLongPress:Lr,onSnapStateChange:fo},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(Rs,{"selected-clip":e.unref(de),"can-split":Aa.value,"can-delete":ca.value,"is-playing":e.unref(ne),"zoom-level":e.unref(ue),"playback-speed":e.unref(ge),onSplit:Q,onDelete:$e,onDuplicate:Re,onZoomIn:sp,onZoomOut:lp,onZoomChange:Yn,onFitToWindow:Jt,onPlayPause:e.unref(ze),onFrameForward:e.unref(It),onFrameBackward:e.unref(Rt),onSkipToStart:e.unref(Xt),onSkipToEnd:e.unref(yn),onSpeedChange:e.unref(Pn)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),we.value?(e.openBlock(),e.createElementBlock("div",wS,[e.createElementVNode("div",kS,[e.createElementVNode("label",_S,[I[20]||(I[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[6]||(I[6]=be=>De.value=be),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,De.value]])]),e.createElementVNode("label",ES,[I[21]||(I[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[7]||(I[7]=be=>Ge.value=be),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Ge.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(de),onClick:I[8]||(I[8]=be=>uo("start"))}," Start = Playhead ",8,xS),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(de),onClick:I[9]||(I[9]=be=>uo("end"))}," End = Playhead ",8,SS),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(de),onClick:ui}," Apply Trim ",8,CS)]),e.createElementVNode("div",VS,[e.createElementVNode("label",NS,[I[22]||(I[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":I[10]||(I[10]=be=>Xe.value=be),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(xe.value,be=>(e.openBlock(),e.createElementBlock("option",{key:be.id,value:be.id},e.toDisplayString(be.name),9,TS))),128))],512),[[e.vModelSelect,Xe.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(de)||Xe.value==="",onClick:mo}," Apply Filter ",8,MS),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Oe).length===0,onClick:mi}," Clear Filters ",8,BS),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(de),onClick:I[11]||(I[11]=be=>H("noise"))}," QA: Noise ",8,IS),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(de),onClick:I[12]||(I[12]=be=>H("grayscale"))}," QA: Grayscale ",8,FS)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Fm=Ve($S,[["__scopeId","data-v-1bb4247b"]]),DS={key:0,class:"video-editor-v2-toolbar"},RS={class:"video-editor-v2-body"},AS={key:0,class:"video-editor-v2-assets","data-testid":"v2-assets-panel"},LS={class:"video-editor-v2-main"},PS={class:"video-editor-v2-canvas"},OS={key:1,class:"video-editor-v2-timeline"},US=["aria-expanded"],zS=["aria-hidden","inert"],jS="(max-width: 900px)",WS=e.defineComponent({__name:"SplitPanelLayout",setup(a,{expose:n}){const t=e.ref(!1),o=e.ref(!1);let i=null,r=null;const s=d=>{t.value=d,d&&(o.value=!1)},l=()=>{o.value=!0},c=()=>{o.value=!1};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(i=window.matchMedia(jS),s(i.matches),r=d=>s(d.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)}),n({isMobile:t}),(d,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"},[d.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",DS,[e.renderSlot(d.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",RS,[!t.value&&d.$slots.assets?(e.openBlock(),e.createElementBlock("aside",AS,[e.renderSlot(d.$slots,"assets",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",LS,[e.createElementVNode("div",PS,[e.renderSlot(d.$slots,"canvas",{},void 0,!0)])])]),d.$slots.timeline?(e.openBlock(),e.createElementBlock("div",OS,[e.renderSlot(d.$slots,"timeline",{isMobile:t.value},void 0,!0)])):e.createCommentVNode("",!0),!t.value&&d.$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,US)),o.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-editor-v2-drawer-backdrop","data-testid":"v2-tools-drawer-backdrop",onClick:c})):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:c}," x ")]),e.renderSlot(d.$slots,"inspector",{},void 0,!0)],10,zS)],64)):e.createCommentVNode("",!0),t.value?e.renderSlot(d.$slots,"drawer",{key:3},void 0,!0):e.createCommentVNode("",!0)],2))}}),ZS=Ve(WS,[["__scopeId","data-v-aaf8ad3f"]]),HS=["aria-selected"],XS={class:"asset-rail-item__main"},GS={class:"asset-rail-item__type","data-testid":"asset-rail-item-type"},JS={class:"asset-rail-item__label","data-testid":"asset-rail-item-label"},KS={key:0,class:"asset-rail-item__details","data-testid":"asset-rail-item-details"},YS={class:"asset-rail-item__actions","aria-label":"Asset actions"},qS=e.defineComponent({__name:"AssetRailItem",props:{source:{},selected:{type:Boolean}},emits:["add","replaceSelected","remove"],setup(a,{emit:n}){const t=a,o=n,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 d=Math.max(0,Math.round(t.source.duration)),u=Math.floor(d/60),f=d%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(d=>d!==null)),c=d=>{if(d==="add"){o("add",t.source.id);return}if(d==="replaceSelected"){o("replaceSelected",t.source.id);return}o("remove",t.source.id)};return(d,u)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["asset-rail-item",{"is-selected":d.selected}]),"aria-selected":d.selected?"true":"false","data-testid":"asset-rail-item"},[e.createElementVNode("div",XS,[e.createElementVNode("span",GS,e.toDisplayString(d.source.type),1),e.createElementVNode("span",JS,e.toDisplayString(i.value),1),l.value.length>0?(e.openBlock(),e.createElementBlock("span",KS,e.toDisplayString(l.value.join(" / ")),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",YS,[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=>c("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=>c("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=>c("remove"))}," - ")])],10,HS))}}),QS=Ve(qS,[["__scopeId","data-v-3ba2fd25"]]),eC={class:"asset-rail","aria-label":"Assets","data-testid":"asset-rail"},tC={key:0,class:"asset-rail__list","data-testid":"asset-rail-list"},nC={key:1,class:"asset-rail__empty","data-testid":"asset-rail-empty"},aC=e.defineComponent({__name:"AssetRail",props:{sources:{},selectedSourceId:{}},emits:["add","replaceSelected","remove"],setup(a,{emit:n}){const t=n,o=(i,r)=>{if(i==="add"){t("add",r);return}if(i==="replaceSelected"){t("replaceSelected",r);return}t("remove",r)};return(i,r)=>(e.openBlock(),e.createElementBlock("section",eC,[r[3]||(r[3]=e.createElementVNode("div",{class:"asset-rail__header"},[e.createElementVNode("h2",{class:"asset-rail__title"},"Assets")],-1)),i.sources.length>0?(e.openBlock(),e.createElementBlock("div",tC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.sources,s=>(e.openBlock(),e.createBlock(QS,{key:s.id,source:s,selected:s.id===i.selectedSourceId,onAdd:r[0]||(r[0]=l=>o("add",l)),onReplaceSelected:r[1]||(r[1]=l=>o("replaceSelected",l)),onRemove:r[2]||(r[2]=l=>o("remove",l))},null,8,["source","selected"]))),128))])):(e.openBlock(),e.createElementBlock("p",nC,"No assets"))]))}}),oC=Ve(aC,[["__scopeId","data-v-db305224"]]),iC={class:"audio-mixer-panel__tracks","data-testid":"audio-mixer-tracks"},rC={key:0,class:"audio-mixer-panel__empty","data-testid":"audio-mixer-empty"},sC=["data-testid"],lC={class:"audio-mixer-strip__header"},cC={class:"audio-mixer-strip__identity"},dC={class:"audio-mixer-strip__kind"},uC=["data-testid"],mC=["data-testid"],pC=["data-testid"],fC={class:"audio-mixer-meter__rail","aria-hidden":"true"},hC={class:"audio-mixer-meter__value"},vC={class:"audio-mixer-strip__controls"},gC=["for"],yC=["id","min","max","value","data-testid","onInput"],bC={class:"audio-mixer-control__value"},wC={class:"audio-mixer-buttons"},kC=["aria-pressed","aria-label","data-testid","onClick"],_C=["aria-pressed","aria-label","data-testid","onClick"],EC=["for"],xC=["id","value","data-testid","onInput"],SC={class:"audio-mixer-control__value"},CC=["data-testid"],VC={key:0},NC={key:1},TC=["data-testid"],MC=["data-testid"],BC=["data-testid"],IC={class:"audio-mixer-routing__target"},FC={class:"audio-mixer-strip__header"},$C={class:"audio-mixer-strip__identity"},DC={class:"audio-mixer-strip__name","data-testid":"audio-mixer-master-name"},RC={class:"audio-mixer-meter__rail","aria-hidden":"true"},AC={class:"audio-mixer-meter__value"},LC={class:"audio-mixer-strip__controls"},PC={key:0,class:"audio-mixer-control audio-mixer-control--fader",for:"audio-mixer-master-fader"},OC=["min","max","value"],UC={class:"audio-mixer-control__value"},zC={class:"audio-mixer-buttons"},jC=["aria-pressed","aria-label"],WC={key:1,class:"audio-mixer-effects","data-testid":"audio-mixer-master-effects"},ZC=["data-testid"],HC=e.defineComponent({__name:"AudioMixerPanel",props:{state:{},deviceClass:{}},emits:["update"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>Ck(t.deviceClass,t.state.capabilities)),r=e.computed(()=>t.deviceClass==="desktop"),s=e.computed(()=>[...t.state.tracks].sort((M,L)=>M.order-L.order)),l=e.computed(()=>{const M=new Map(Vk(s.value,t.state.master.muted).map(L=>[L.trackId,L]));return s.value.map(L=>({track:L,effectiveState:M.get(L.id)??null}))}),c=e.computed(()=>i.value.canAdjustTrackFaders),d=e.computed(()=>i.value.canAdjustMasterFader),u=e.computed(()=>i.value.canMuteTracks),f=e.computed(()=>r.value&&i.value.canSoloTracks),p=e.computed(()=>r.value&&i.value.canAdjustPan),m=e.computed(()=>i.value.canViewMeters&&i.value.meterMode!=="off"),h=e.computed(()=>r.value&&i.value.canEditEffectSlots&&i.value.maxEffectSlots>0),g=e.computed(()=>r.value&&i.value.canEditRouting),w=M=>{if(!(M.target instanceof HTMLInputElement))return null;const L=Number(M.target.value);return Number.isFinite(L)?L:null},F=(M,L)=>{if(!c.value)return;const k=w(L);k!==null&&o("update",{type:"track-fader-db",trackId:M.id,valueDb:Zo(k)})},D=M=>{u.value&&o("update",{type:"track-mute",trackId:M.id,muted:!M.controls.muted})},E=M=>{f.value&&o("update",{type:"track-solo",trackId:M.id,solo:!M.controls.solo})},v=(M,L)=>{if(!p.value)return;const k=w(L);k!==null&&o("update",{type:"track-pan",trackId:M.id,pan:Hu(k)})},S=M=>{if(!d.value)return;const L=w(M);L!==null&&o("update",{type:"master-fader-db",valueDb:Zo(L)})},C=M=>{u.value&&o("update",{type:"master-mute",muted:!M.muted})},V=M=>{const L=Math.round(M*10)/10;return L>0?`+${L.toFixed(L%1===0?0:1)} dB`:`${L.toFixed(L%1===0?0:1)} dB`},x=M=>M===0?"C":`${M<0?"L":"R"} ${Math.round(Math.abs(M)*100)}`,N=M=>{if(M===void 0)return"";const L=Math.round(M*10)/10;return`${L.toFixed(L%1===0?0:1)}s`},j=M=>V(M),_=M=>{if(!Number.isFinite(M))return 0;const L=Math.min(Yi,Math.max(ia,M)),k=Yi-ia;return Math.round((L-ia)/k*100)},R=M=>M.slice(0,i.value.maxEffectSlots),T=M=>h.value&&R(M).length>0,z=M=>M.timeline.fadeIn!==void 0||M.timeline.fadeOut!==void 0,P=M=>M===null?"Unknown":M.mutedByMaster?"Master muted":M.mutedByTrack?"Muted":M.mutedBySolo?"Muted by solo":M.soloed?"Solo active":"Audible";return(M,L)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["audio-mixer-panel",`audio-mixer-panel--${M.deviceClass}`]),"data-testid":"audio-mixer-panel","aria-label":"Audio mixer"},[e.createElementVNode("div",iC,[l.value.length===0?(e.openBlock(),e.createElementBlock("p",rC," No audio tracks ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,({track:k,effectiveState:O})=>(e.openBlock(),e.createElementBlock("article",{key:k.id,class:e.normalizeClass(["audio-mixer-strip",{"is-muted":(O==null?void 0:O.effectivelyMuted)===!0,"is-soloed":k.controls.solo}]),"data-testid":`audio-mixer-track-${k.id}`},[e.createElementVNode("header",lC,[e.createElementVNode("div",cC,[e.createElementVNode("span",dC,e.toDisplayString(k.kind),1),e.createElementVNode("h3",{class:"audio-mixer-strip__name","data-testid":`audio-mixer-track-name-${k.id}`},e.toDisplayString(k.name),9,uC)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":(O==null?void 0:O.audible)===!0}]),"data-testid":`audio-mixer-track-status-${k.id}`},e.toDisplayString(P(O)),11,mC)]),m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":k.controls.meter.clipping}]),"data-testid":`audio-mixer-track-meter-${k.id}`,"aria-label":"Track meter"},[e.createElementVNode("span",fC,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${_(k.controls.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",hC,e.toDisplayString(j(k.controls.meter.peakDb)),1)],10,pC)):e.createCommentVNode("",!0),e.createElementVNode("div",vC,[c.value?(e.openBlock(),e.createElementBlock("label",{key:0,class:"audio-mixer-control audio-mixer-control--fader",for:`audio-mixer-track-fader-${k.id}`},[L[2]||(L[2]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:`audio-mixer-track-fader-${k.id}`,type:"range",class:"audio-mixer-control__range",min:k.controls.fader.minDb,max:k.controls.fader.maxDb,value:k.controls.fader.valueDb,step:"0.5","data-testid":`audio-mixer-track-fader-${k.id}`,onInput:W=>F(k,W)},null,40,yC),e.createElementVNode("span",bC,e.toDisplayString(V(k.controls.fader.valueDb)),1)],8,gC)):e.createCommentVNode("",!0),e.createElementVNode("div",wC,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":k.controls.muted}]),"aria-pressed":k.controls.muted?"true":"false","aria-label":k.controls.muted?`Unmute ${k.name}`:`Mute ${k.name}`,"data-testid":`audio-mixer-track-mute-${k.id}`,onClick:W=>D(k)}," M ",10,kC)):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":k.controls.solo}]),"aria-pressed":k.controls.solo?"true":"false","aria-label":k.controls.solo?`Clear solo on ${k.name}`:`Solo ${k.name}`,"data-testid":`audio-mixer-track-solo-${k.id}`,onClick:W=>E(k)}," S ",10,_C)):e.createCommentVNode("",!0)])]),p.value?(e.openBlock(),e.createElementBlock("label",{key:1,class:"audio-mixer-control audio-mixer-control--pan",for:`audio-mixer-track-pan-${k.id}`},[L[3]||(L[3]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Pan",-1)),e.createElementVNode("input",{id:`audio-mixer-track-pan-${k.id}`,type:"range",class:"audio-mixer-control__range",min:"-1",max:"1",step:"0.01",value:k.controls.pan.value,"data-testid":`audio-mixer-track-pan-${k.id}`,onInput:W=>v(k,W)},null,40,xC),e.createElementVNode("span",SC,e.toDisplayString(x(k.controls.pan.value)),1)],8,EC)):e.createCommentVNode("",!0),z(k)?(e.openBlock(),e.createElementBlock("div",{key:2,class:"audio-mixer-strip__fades","data-testid":`audio-mixer-track-fades-${k.id}`},[k.timeline.fadeIn!==void 0?(e.openBlock(),e.createElementBlock("span",VC," In "+e.toDisplayString(N(k.timeline.fadeIn)),1)):e.createCommentVNode("",!0),k.timeline.fadeOut!==void 0?(e.openBlock(),e.createElementBlock("span",NC," Out "+e.toDisplayString(N(k.timeline.fadeOut)),1)):e.createCommentVNode("",!0)],8,CC)):e.createCommentVNode("",!0),T(k.effectSlots)?(e.openBlock(),e.createElementBlock("div",{key:3,class:"audio-mixer-effects","data-testid":`audio-mixer-track-effects-${k.id}`},[L[4]||(L[4]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R(k.effectSlots),W=>(e.openBlock(),e.createElementBlock("span",{key:W.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":W.kind==="empty","is-bypassed":W.bypassed,"is-enabled":W.enabled&&!W.bypassed}]),"data-testid":`audio-mixer-track-effect-${k.id}-${W.index}`},e.toDisplayString(W.label),11,MC))),128))],8,TC)):e.createCommentVNode("",!0),g.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"audio-mixer-routing","data-testid":`audio-mixer-track-routing-${k.id}`},[L[5]||(L[5]=e.createElementVNode("span",{class:"audio-mixer-routing__label"},"Route",-1)),e.createElementVNode("span",IC,e.toDisplayString(M.state.master.name),1)],8,BC)):e.createCommentVNode("",!0)],10,sC))),128))]),e.createElementVNode("article",{class:e.normalizeClass(["audio-mixer-strip audio-mixer-strip--master",{"is-muted":M.state.master.muted}]),"data-testid":"audio-mixer-master-strip"},[e.createElementVNode("header",FC,[e.createElementVNode("div",$C,[L[6]||(L[6]=e.createElementVNode("span",{class:"audio-mixer-strip__kind"},"master",-1)),e.createElementVNode("h3",DC,e.toDisplayString(M.state.master.name),1)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":!M.state.master.muted}]),"data-testid":"audio-mixer-master-status"},e.toDisplayString(M.state.master.muted?"Muted":"Active"),3)]),m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":M.state.master.meter.clipping}]),"data-testid":"audio-mixer-master-meter","aria-label":"Master meter"},[e.createElementVNode("span",RC,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${_(M.state.master.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",AC,e.toDisplayString(j(M.state.master.meter.peakDb)),1)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",LC,[d.value?(e.openBlock(),e.createElementBlock("label",PC,[L[7]||(L[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:M.state.master.fader.minDb,max:M.state.master.fader.maxDb,value:M.state.master.fader.valueDb,step:"0.5","data-testid":"audio-mixer-master-fader",onInput:L[0]||(L[0]=k=>S(k))},null,40,OC),e.createElementVNode("span",UC,e.toDisplayString(V(M.state.master.fader.valueDb)),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",zC,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":M.state.master.muted}]),"aria-pressed":M.state.master.muted?"true":"false","aria-label":M.state.master.muted?`Unmute ${M.state.master.name}`:`Mute ${M.state.master.name}`,"data-testid":"audio-mixer-master-mute",onClick:L[1]||(L[1]=k=>C(M.state.master))}," M ",10,jC)):e.createCommentVNode("",!0)])]),T(M.state.master.effectSlots)?(e.openBlock(),e.createElementBlock("div",WC,[L[8]||(L[8]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R(M.state.master.effectSlots),k=>(e.openBlock(),e.createElementBlock("span",{key:k.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":k.kind==="empty","is-bypassed":k.bypassed,"is-enabled":k.enabled&&!k.bypassed}]),"data-testid":`audio-mixer-master-effect-${k.index}`},e.toDisplayString(k.label),11,ZC))),128))])):e.createCommentVNode("",!0)],2)],2))}}),md=Ve(HC,[["__scopeId","data-v-e5c785e8"]]),XC={class:"caption-srt-panel__header"},GC={class:"caption-srt-panel__title-group"},JC={class:"caption-srt-panel__title"},KC=["id"],YC={key:0,class:"caption-srt-panel__stats","data-testid":"caption-srt-desktop-stats"},qC={key:0,class:"caption-srt-panel__desktop-controls","data-testid":"caption-srt-desktop-controls"},QC={class:"caption-srt-panel__field"},eV={class:"caption-srt-panel__field"},tV=["for"],nV=["id","aria-describedby","aria-invalid"],aV=["id"],oV=["id"],iV={key:3,class:"caption-srt-panel__cue-summary","data-testid":"caption-srt-cue-summary","aria-label":"Current caption cue summary"},rV={key:0,class:"caption-srt-panel__cue-list"},sV={class:"caption-srt-panel__cue-time"},lV={class:"caption-srt-panel__cue-text"},cV={key:1,class:"caption-srt-panel__empty"},dV=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(a,{emit:n}){const t=a,o=n,i=e.ref(""),r=e.ref(null),s=e.ref(null),l=e.ref(""),c=e.ref(""),d=e.ref(!1),u=e.computed(()=>t.layout==="mobile"),f=e.computed(()=>`${t.panelId}-textarea`),p=e.computed(()=>`${t.panelId}-helper`),m=e.computed(()=>`${t.panelId}-error`),h=e.computed(()=>`${t.panelId}-status`),g=e.computed(()=>{const T=[p.value,h.value];return r.value!==null&&T.push(m.value),T.join(" ")}),w=e.computed(()=>t.captionTrack!==null?t.captionTrack.segments:t.segments??[]),F=e.computed(()=>{try{return{text:Xc(w.value),errorMessage:null}}catch(T){return{text:"",errorMessage:j(T)}}}),D=e.computed(()=>w.value.length),E=e.computed(()=>w.value.reduce((T,z)=>Math.max(T,z.endTime),0)),v=e.computed(()=>w.value.slice(0,5));e.watch(()=>{var T,z;return[(T=t.captionTrack)==null?void 0:T.id,(z=t.captionTrack)==null?void 0:z.language,t.trackId]},([T,z,P])=>{l.value=T??P,c.value=z??""},{immediate:!0}),e.watch(F,T=>{if(T.errorMessage!==null){r.value=T.errorMessage;return}d.value||(i.value=T.text)},{immediate:!0});const S=()=>{d.value=!0,s.value=null,r.value!==null&&(r.value=null)},C=()=>{const T=i.value;if(r.value=null,s.value=null,T.trim()===""){r.value="Paste SRT text before importing captions.";return}try{const z=Xk(T,{idPrefix:t.idPrefix}),P=c_(N(z)),M=Xc(P.segments);i.value=M,d.value=!1,s.value=`Imported ${_(P.segments.length)}.`,o("update:captionTrack",P),o("update:segments",P.segments),o("import",{track:P,segments:P.segments,sourceText:T})}catch(z){r.value=j(z)}},V=()=>{const T=F.value;if(r.value=T.errorMessage,T.errorMessage!==null){s.value=null;return}i.value=T.text,d.value=!1,s.value=T.text===""?"No captions to export.":`Exported ${_(D.value)}.`,o("export",T.text)},x=()=>{i.value="",d.value=!0,r.value=null,s.value="SRT text cleared.",o("clear")};function N(T){var M,L;const z={id:l.value.trim(),source:"srt-import",stylePreset:((M=t.captionTrack)==null?void 0:M.stylePreset)??"default",animation:((L=t.captionTrack)==null?void 0:L.animation)??"none",segments:T},P=c.value.trim();return P!==""&&(z.language=P),z}function j(T){return T instanceof ra||T instanceof Error?T.message:"Unable to process SRT captions."}function _(T){return T===1?"1 cue":`${T} cues`}function R(T){const z=Math.floor(T/60),P=Math.floor(T%60);return`${z}:${P.toString().padStart(2,"0")}`}return(T,z)=>(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",XC,[e.createElementVNode("div",GC,[e.createElementVNode("h2",JC,e.toDisplayString(T.title),1),e.createElementVNode("p",{id:p.value,class:"caption-srt-panel__helper"}," Paste SRT, import it as captions, or export the current caption track. ",8,KC)]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",YC,[e.createElementVNode("span",null,e.toDisplayString(_(D.value)),1),e.createElementVNode("span",null,e.toDisplayString(R(E.value)),1)]))]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",qC,[e.createElementVNode("label",QC,[z[3]||(z[3]=e.createElementVNode("span",null,"Track ID",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[0]||(z[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",eV,[z[4]||(z[4]=e.createElementVNode("span",null,"Language",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[1]||(z[1]=P=>c.value=P),class:"caption-srt-panel__input",type:"text",autocomplete:"off",placeholder:"en","data-testid":"caption-srt-language"},null,512),[[e.vModelText,c.value]])])])),e.createElementVNode("label",{class:"caption-srt-panel__textarea-label",for:f.value},e.toDisplayString(T.textareaLabel),9,tV),e.withDirectives(e.createElementVNode("textarea",{id:f.value,"onUpdate:modelValue":z[2]||(z[2]=P=>i.value=P),class:e.normalizeClass(["caption-srt-panel__textarea",{"has-error":r.value!==null}]),spellcheck:"false","aria-describedby":g.value,"aria-invalid":r.value!==null?"true":"false","data-testid":"caption-srt-textarea",onInput:S},null,42,nV),[[e.vModelText,i.value]]),r.value!==null?(e.openBlock(),e.createElementBlock("p",{key:1,id:m.value,class:"caption-srt-panel__error",role:"alert","data-testid":"caption-srt-error"},e.toDisplayString(r.value),9,aV)):(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,oV)),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:V}," Export "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-clear",onClick:x}," Clear ")]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",iV,[z[5]||(z[5]=e.createElementVNode("p",{class:"caption-srt-panel__cue-summary-title"},"Cue summary",-1)),v.value.length>0?(e.openBlock(),e.createElementBlock("ol",rV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,P=>(e.openBlock(),e.createElementBlock("li",{key:P.id,class:"caption-srt-panel__cue"},[e.createElementVNode("span",sV,e.toDisplayString(R(P.startTime))+"-"+e.toDisplayString(R(P.endTime)),1),e.createElementVNode("span",lV,e.toDisplayString(P.text),1)]))),128))])):(e.openBlock(),e.createElementBlock("p",cV," No captions loaded. "))]))],2))}}),pd=Ve(dV,[["__scopeId","data-v-1d5fdb3b"]]),uV=["aria-label"],mV={class:"draft-recovery-banner__header"},pV={class:"draft-recovery-banner__heading"},fV={class:"draft-recovery-banner__title"},hV={class:"draft-recovery-banner__summary","data-testid":"draft-recovery-summary"},vV={key:0,class:"draft-recovery-banner__list","data-testid":"draft-recovery-list"},gV={class:"draft-recovery-banner__record-copy"},yV={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},bV={class:"draft-recovery-banner__record-meta"},wV={"data-testid":"draft-recovery-record-updated"},kV={"data-testid":"draft-recovery-record-reason"},_V={class:"draft-recovery-banner__actions"},EV=["onClick"],xV=["onClick"],SV={key:1,class:"draft-recovery-banner__mobile-prompt","data-testid":"draft-recovery-mobile-prompt"},CV={class:"draft-recovery-banner__record-copy"},VV={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},NV={class:"draft-recovery-banner__record-meta"},TV={"data-testid":"draft-recovery-record-updated"},MV={"data-testid":"draft-recovery-record-reason"},BV={class:"draft-recovery-banner__actions draft-recovery-banner__actions--mobile"},IV={key:2,class:"draft-recovery-banner__empty","data-testid":"draft-recovery-empty"},FV=e.defineComponent({__name:"DraftRecoveryBanner",props:{records:{},surface:{},projectId:{},savedAt:{},maxAgeMs:{},now:{},maxDesktopItems:{default:3}},emits:["restore","dismiss"],setup(a,{emit:n}){const t=a,o=n,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)}),c=e.computed(()=>ck(t.records,t.surface,s.value)),d=e.computed(()=>t.surface==="mobile"?c.value:c.value.slice(0,l.value)),u=e.computed(()=>t.surface==="mobile"),f=e.computed(()=>d.value.length>0),p=e.computed(()=>u.value?d.value[0]??null:null),m=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.":`${d.value.length} recoverable draft${d.value.length===1?"":"s"} found.`:"No recoverable video drafts"),g=C=>{var V;return((V=C.snapshot.metadata.title)==null?void 0:V.trim())||"Untitled video draft"},w=C=>{const V=C.snapshot.metadata.saveReason;return V===void 0?"Saved draft":i[V]},F=C=>{const V=new Date(C.snapshot.metadata.updatedAt);return Number.isFinite(V.getTime())?r.format(V):"Updated time unavailable"},D=C=>{o("restore",C)},E=C=>{C.length!==0&&o("dismiss",C)},v=C=>{E([C])},S=()=>{E(d.value)};return(C,V)=>(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":m.value},[e.createElementVNode("header",mV,[e.createElementVNode("div",pV,[V[2]||(V[2]=e.createElementVNode("p",{class:"draft-recovery-banner__eyebrow"},"Draft recovery",-1)),e.createElementVNode("h2",fV,e.toDisplayString(m.value),1),e.createElementVNode("p",hV,e.toDisplayString(h.value),1)]),!u.value&&d.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:S}," Dismiss all ")):e.createCommentVNode("",!0)]),!u.value&&f.value?(e.openBlock(),e.createElementBlock("ul",vV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,x=>(e.openBlock(),e.createElementBlock("li",{key:x.key,class:"draft-recovery-banner__record","data-testid":"draft-recovery-record"},[e.createElementVNode("div",gV,[e.createElementVNode("h3",yV,e.toDisplayString(g(x)),1),e.createElementVNode("p",bV,[e.createElementVNode("span",wV,"Updated "+e.toDisplayString(F(x)),1),V[3]||(V[3]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",kV,e.toDisplayString(w(x)),1)])]),e.createElementVNode("div",_V,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:N=>D(x)}," Restore ",8,EV),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:N=>v(x)}," Dismiss ",8,xV)])]))),128))])):p.value?(e.openBlock(),e.createElementBlock("article",SV,[e.createElementVNode("div",CV,[e.createElementVNode("h3",VV,e.toDisplayString(g(p.value)),1),e.createElementVNode("p",NV,[e.createElementVNode("span",TV,"Updated "+e.toDisplayString(F(p.value)),1),V[4]||(V[4]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",MV,e.toDisplayString(w(p.value)),1)])]),e.createElementVNode("div",BV,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:V[0]||(V[0]=x=>D(p.value))}," Restore "),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:V[1]||(V[1]=x=>v(p.value))}," Dismiss ")])])):(e.openBlock(),e.createElementBlock("p",IV," No recoverable drafts "))],10,uV))}}),fd=Ve(FV,[["__scopeId","data-v-3ed3c273"]]),$V={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},DV=["aria-selected","data-testid","onClick"],RV=["aria-labelledby"],AV={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},LV=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(a,{emit:n}){const t=a,o=n,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",$V,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,c=>(e.openBlock(),e.createElementBlock("button",{key:c.id,type:"button",role:"tab",class:e.normalizeClass(["inspector-tab",{"is-active":s.activeTab===c.id}]),"aria-selected":s.activeTab===c.id?"true":"false","data-testid":`v2-inspector-tab-${c.id}`,onClick:d=>r(c.id)},e.toDisplayString(c.label),11,DV))),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",AV,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,RV)],2))}}),PV=Ve(LV,[["__scopeId","data-v-7f5b0e50"]]),OV={class:"keyframe-preset-panel__header"},UV={class:"keyframe-preset-panel__target","data-testid":"keyframe-preset-target"},zV={key:0,class:"keyframe-preset-panel__notice","data-testid":"keyframe-preset-invalid-duration"},jV={class:"keyframe-preset-panel__grid","data-testid":"keyframe-preset-buttons"},WV=["disabled","aria-disabled","data-testid","onClick"],ZV={class:"keyframe-preset-panel__preset-label"},HV={class:"keyframe-preset-panel__preset-summary"},XV={key:1,class:"keyframe-preset-panel__compact-summary","data-testid":"keyframe-preset-mobile-summary"},GV={key:2,class:"keyframe-preset-panel__desktop-summary","data-testid":"keyframe-preset-desktop-summary"},JV={class:"keyframe-preset-panel__summary-list"},KV=["data-testid"],YV={key:0,class:"keyframe-preset-panel__summary-empty","data-testid":"keyframe-preset-summary-empty"},qV=e.defineComponent({__name:"KeyframePresetPanel",props:{duration:{},target:{},deviceClass:{}},emits:["apply-preset"],setup(a,{emit:n}){const t=a,o=n,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 V=r_({duration:S(C)});return F("fade-in","Fade in",V,C)}},{id:"fade-out",label:"Fade out",target:"opacity",summary:"Opacity 100 -> 0%",create:C=>{const V=S(C),x=s_({startTime:C-V,duration:V});return F("fade-out","Fade out",x,C)}},{id:"push-in",label:"Push in",target:"scale",summary:"Scale 100 -> 108%",create:C=>{const V=l_({duration:C,fromScale:1,toScale:1.08,easing:"ease-out"});return F("push-in","Push in",V,C)}},{id:"push-out",label:"Push out",target:"scale",summary:"Scale 108 -> 100%",create:C=>E({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=>E({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=>E({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=>E({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=>E({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=>E({id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",duration:S(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 V=S(C);return E({id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",duration:V,startTime:C-V,startValue:1,endValue:0,easing:"ease-in"})}}],s=e.computed(()=>a_(t.deviceClass)),l=e.computed(()=>s.value.platform==="mobile"),c=e.computed(()=>Number.isFinite(t.duration)&&t.duration>0),d=e.computed(()=>t.target==="all"?r:r.filter(C=>C.target===t.target)),u=e.computed(()=>c.value?d.value.map(C=>({definition:C,automation:C.create(t.duration)})):[]),f=e.computed(()=>i[t.target]),p=e.computed(()=>{const C=d.value.length,V=C===1?"preset":"presets";return c.value?`${C} ${V} - ${h(t.duration)} clip.`:`${C} ${V} available when duration is set.`}),m=C=>{if(!c.value)return;const V=C.create(t.duration);o("apply-preset",{presetId:V.id,target:V.target,keyframes:V.keyframes,automation:V})},h=C=>{const V=Math.round(C*100)/100;return`${V.toFixed(V%1===0?0:2)}s`},g=(C,V)=>C==="opacity"||C==="audioVolume"?`${Math.round(V*100)}%`:C==="scale"?`${Math.round(V*100)}%`:C==="x"||C==="y"?`${Math.round(V*100)}%`:`${Math.round(V*100)/100}`,w=C=>{const[V,x]=C.keyframes;return`${h(V.time)} ${g(C.target,V.value)} -> ${h(x.time)} ${g(C.target,x.value)}`};function F(C,V,x,N){return D({id:C,label:V,target:x.target,duration:N,keyframes:x.keyframes})}function D(C){const V=i_(C.keyframes,{target:C.target,minTime:0,maxTime:C.duration}),x=V[0],N=V[1];if(V.length!==2||x===void 0||N===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:[x,N]}}function E(C){const V=C.startTime??0,x=[v(`${C.id}:start`,C.target,V,C.startValue,"linear"),v(`${C.id}:end`,C.target,V+C.duration,C.endValue,C.easing)];return D({id:C.id,label:C.label,target:C.target,duration:V+C.duration,keyframes:x})}function v(C,V,x,N,j){return{id:C,target:V,time:x,value:N,easing:j}}function S(C){return Math.min(C,1)}return(C,V)=>(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",OV,[V[0]||(V[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",UV,e.toDisplayString(f.value),1)]),c.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",zV," Set a valid clip duration to apply automation presets. ")),e.createElementVNode("div",jV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.id,type:"button",class:"keyframe-preset-panel__preset",disabled:!c.value,"aria-disabled":c.value?void 0:"true","data-testid":`keyframe-preset-button-${x.id}`,onClick:N=>m(x)},[e.createElementVNode("span",ZV,e.toDisplayString(x.label),1),e.createElementVNode("span",HV,e.toDisplayString(x.summary),1)],8,WV))),128))]),l.value?(e.openBlock(),e.createElementBlock("p",XV,e.toDisplayString(p.value),1)):(e.openBlock(),e.createElementBlock("div",GV,[V[1]||(V[1]=e.createElementVNode("p",{class:"keyframe-preset-panel__summary-title"},"Generated keyframes",-1)),e.createElementVNode("ul",JV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,x=>(e.openBlock(),e.createElementBlock("li",{key:x.definition.id,class:"keyframe-preset-panel__summary-row","data-testid":`keyframe-preset-summary-${x.definition.id}`},[e.createElementVNode("span",null,e.toDisplayString(x.definition.label),1),e.createElementVNode("span",null,e.toDisplayString(w(x.automation)),1)],8,KV))),128))]),u.value.length===0?(e.openBlock(),e.createElementBlock("p",YV," No generated keyframes until duration is valid. ")):e.createCommentVNode("",!0)]))],2))}}),hd=Ve(qV,[["__scopeId","data-v-79615683"]]),QV={class:"mobile-clip-summary__main"},eN={class:"mobile-clip-summary__title","data-testid":"v2-mobile-clip-label"},tN={class:"mobile-clip-summary__stats","aria-label":"Selected clip timing"},nN={class:"mobile-clip-summary__stat"},aN={"data-testid":"v2-mobile-clip-start"},oN={class:"mobile-clip-summary__stat"},iN={"data-testid":"v2-mobile-clip-end"},rN={class:"mobile-clip-summary__stat"},sN={"data-testid":"v2-mobile-clip-duration"},lN={key:1,class:"mobile-clip-summary__empty","data-testid":"v2-mobile-no-clip"},cN=e.defineComponent({__name:"MobileClipSummary",props:{selectedClip:{}},emits:["open-actions"],setup(a,{emit:n}){const t=a,o=n,i=f=>f===void 0||!Number.isFinite(f)?null:f,r=e.computed(()=>{var f,p,m;return((p=(f=t.selectedClip)==null?void 0:f.label)==null?void 0:p.trim())||((m=t.selectedClip)==null?void 0:m.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),c=e.computed(()=>{const f=s.value,p=l.value;return f!==null&&p!==null?Math.max(0,p-f):t.selectedClip?i(t.selectedClip.duration):null}),d=f=>{if(f===null)return"--";const p=Math.round(f*100)/100;return`${p.toFixed(p%1===0?0:2)}s`},u=()=>{t.selectedClip&&o("open-actions",t.selectedClip.id)};return(f,p)=>(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",QV,[p[0]||(p[0]=e.createElementVNode("p",{class:"mobile-clip-summary__eyebrow"},"Selected clip",-1)),e.createElementVNode("h2",eN,e.toDisplayString(r.value),1)]),e.createElementVNode("dl",tN,[e.createElementVNode("div",nN,[p[1]||(p[1]=e.createElementVNode("dt",null,"Start",-1)),e.createElementVNode("dd",aN,e.toDisplayString(d(s.value)),1)]),e.createElementVNode("div",oN,[p[2]||(p[2]=e.createElementVNode("dt",null,"End",-1)),e.createElementVNode("dd",iN,e.toDisplayString(d(l.value)),1)]),e.createElementVNode("div",rN,[p[3]||(p[3]=e.createElementVNode("dt",null,"Duration",-1)),e.createElementVNode("dd",sN,e.toDisplayString(d(c.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",lN," No clip selected "))],2))}}),dN=Ve(cN,[["__scopeId","data-v-433c7812"]]),uN=["aria-label"],mN=["aria-pressed","data-testid","onClick"],pN={class:"mobile-tool-picker__label"},fN=e.defineComponent({__name:"MobileToolPicker",props:{modelValue:{},ariaLabel:{default:"Mobile editor tools"}},emits:["update:modelValue"],setup(a,{emit:n}){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=a,i=n,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,c=>e.createElementVNode("button",{key:c.id,type:"button",class:e.normalizeClass(["mobile-tool-picker__button",{"is-active":s.modelValue===c.id}]),"aria-pressed":s.modelValue===c.id?"true":"false","data-testid":`v2-mobile-tool-${c.id}`,onClick:d=>r(c.id)},[e.createElementVNode("span",pN,e.toDisplayString(c.label),1)],10,mN)),64))],8,uN))}}),hN=Ve(fN,[["__scopeId","data-v-ec597c70"]]),vN=["aria-label","data-snap"],gN=["aria-expanded"],yN={class:"drawer-header"},bN={class:"drawer-body"},wN=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(a,{expose:n,emit:t}){const o=["collapsed","half","full"],i=a,r=t,s=e.ref(null),l=e.ref(null),c=e.ref(i.initialSnap);let d=!1,u=!1,f=null,p=0,m=0,h=0;const g=N=>{const j=h||(typeof window<"u"?window.innerHeight:600);switch(N){case"collapsed":return 80;case"half":return Math.round(j*.45);case"full":return Math.round(j*.85)}},w=(N,{animate:j=!0}={})=>{var T;if(!s.value)return;const _=c.value;c.value=N;const R=typeof window<"u"&&((T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=j&&!R?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${g(N)}px`,N!==_&&r("snap-change",N,_)},F=N=>{let j=o[0],_=1/0;for(const R of o){const T=Math.abs(g(R)-N);T<_&&(_=T,j=R)}return j},D=()=>{const N=o.indexOf(c.value);w(o[(N+1)%o.length])},E=N=>{if(u){u=!1,N.preventDefault();return}D()},v=N=>{var j,_,R;if(N.button===0){d=!0,u=!1,f=N.pointerId,p=N.clientY,m=((j=s.value)==null?void 0:j.offsetHeight)??0;try{(R=(_=l.value)==null?void 0:_.setPointerCapture)==null||R.call(_,N.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},S=N=>{if(!d||N.pointerId!==f)return;const j=N.clientY-p,_=m-j,R=g("collapsed"),T=g("full"),z=Math.max(R,Math.min(T,_));s.value&&(s.value.style.height=`${z}px`),Math.abs(j)>4&&(u=!0),N.preventDefault()},C=N=>{var _,R,T;if(!d)return;d=!1;try{(R=(_=l.value)==null?void 0:_.releasePointerCapture)==null||R.call(_,N.pointerId)}catch{}f=null;const j=((T=s.value)==null?void 0:T.offsetHeight)??0;w(F(j))},V=(N,j={})=>{o.includes(N)&&w(N,{animate:j.animate!==!1})},x=N=>{h=Math.max(0,Number(N)||0),w(c.value,{animate:!1})};return e.watch(()=>i.containerHeight,N=>{N>0&&x(N)}),e.onMounted(()=>{i.containerHeight>0&&(h=i.containerHeight),w(c.value,{animate:!1})}),e.onBeforeUnmount(()=>{d=!1,f=null}),n({snapTo:V,updateContainerHeight:x,snap:c}),(N,j)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":N.ariaLabel,"data-snap":c.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":c.value==="full"?"true":"false","data-testid":"v2-video-drawer-handle",onClick:E,onPointerdown:v,onPointermove:S,onPointerup:C,onPointercancel:C},[...j[0]||(j[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,gN),e.createElementVNode("div",yN,[e.renderSlot(N.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",bN,[e.renderSlot(N.$slots,"default",{},void 0,!0)])],8,vN))}}),kN=Ve(wN,[["__scopeId","data-v-4ebedbf7"]]),_N={class:"v2-toolbar-group"},EN=["aria-label"],xN=["disabled"],SN={class:"v2-toolbar-group"},CN={class:"v2-toolbar-fit"},VN=["disabled"],NN=["disabled"],TN={class:"v2-assets"},MN={key:0,class:"v2-asset-rail-status","data-testid":"v2-asset-rail-status",role:"status"},BN={class:"v2-preview-host"},IN={class:"v2-timeline-topbar"},FN={class:"v2-timeline-heading"},$N={class:"v2-timeline-meta","data-testid":"v2-timeline-meta"},DN={class:"v2-timeline-zoom"},RN=["value"],AN={class:"v2-timeline-zoom-readout"},LN=["aria-pressed"],PN={key:1,class:"v2-empty-state"},ON={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},UN={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},zN={key:1,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-look"},jN={class:"v2-mobile-panel-section"},WN={class:"v2-mobile-panel-section v2-mobile-panel-section--compact"},ZN={key:1,class:"v2-empty-state"},HN={key:2,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-trim"},XN={key:3,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-text"},GN={key:4,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-audio"},JN={key:5,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-export"},KN={key:0,class:"v2-export-status"},YN={key:1,class:"v2-export-status"},qN={key:6,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-more"},QN={class:"v2-mobile-secondary-controls"},e4={class:"v2-mobile-secondary-field"},t4=["aria-pressed"],n4=["disabled"],a4=["disabled"],o4={key:0,class:"v2-mobile-secondary-details","data-testid":"v2-mobile-transitions"},i4={class:"v2-mobile-secondary-details","data-testid":"v2-mobile-keyframes"},r4=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}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){var fo,ho,vo,go;const o=a,i=t,r=e.computed(()=>{var Q;const b=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";if(b!=="")return b;const A=(Q=o.media)==null?void 0:Q.uuid;return typeof A=="string"&&A.trim()!==""?A.trim():`temp-${Date.now()}`}),s=nm(r.value,o.initialRecipe,o.media),l=im(),c=e.ref("filters"),d=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 b=o.featureFlags??{},A=["filters","adjustments","text","transitions","audio","export"],Q={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return A.map(he=>({id:he,label:Q[he],enabled:typeof b[he]=="boolean"?b[he]:u.value[he]}))}),p=b=>f.value.some(A=>A.id===b&&A.enabled),m={look:"filters",text:"text",audio:"audio",export:"export"},h=e.computed(()=>{var b;return((b=o.featureFlags)==null?void 0:b.transitions)===!0});e.watch(d,b=>{if(b==="trim"||b==="more")return;const A=m[b];p(A)&&(c.value=A)});const g=e.ref(!1),w=e.computed(()=>c.value),F=e.computed(()=>w.value==="filters"||g.value),D=e.computed(()=>w.value!=="filters"&&!g.value),E=e.ref(null),v=e.computed(()=>E.value),S=["contain","cover","none"],C=b=>typeof b=="string"&&S.includes(b),V=b=>{var Q;const A=(Q=b==null?void 0:b.metadata)==null?void 0:Q.fit_mode;return C(A)?A:null},x=e.ref(V(o.initialRecipe)??"contain"),N=e.ref("");e.watch(()=>{var b,A;return{file:(b=o.media)==null?void 0:b.file,url:(A=o.media)==null?void 0:A.url}},(b,A,Q)=>{var Re,$e;const he=N.value;Q(()=>{he&&he.startsWith("blob:")&&URL.revokeObjectURL(he)}),(Re=o.media)!=null&&Re.file?N.value=URL.createObjectURL(o.media.file):($e=o.media)!=null&&$e.url?N.value=o.media.url:N.value=""},{immediate:!0});const j=e.computed(()=>N.value),_=e.computed(()=>l.activeFilters.value),R=e.computed(()=>s.playheadPosition.value),T=Tu({forcePixiPreview:g,getPreviewRef:()=>v.value,getSourceUrl:()=>N.value,setPlaying:s.setPlaying}),z=e.computed(()=>{if(!o.media)return null;const{file:b,...A}=o.media;return{...A,url:N.value}}),P=e.computed(()=>{var A;const b=(A=o.media)==null?void 0:A.url;return!!(b&&/^https?:/i.test(b))}),M=e.ref(0),L=e.computed(()=>{var A;if(s.totalDuration.value>0)return s.totalDuration.value;if(M.value>0)return M.value;const b=Number((A=o.media)==null?void 0:A.duration);return Number.isFinite(b)&&b>0?b:0}),k=b=>{!Number.isFinite(b)||b<=0||(M.value=b,s.updateSourceDuration(b))},O=b=>{b&&typeof b.time=="number"&&Number.isFinite(b.time)&&s.seekTo(b.time)},W=b=>{Number.isFinite(b)&&s.seekTo(b)},G=b=>{s.setPlaying(b)},ie=e.computed(()=>l.videoCompatibleFilters.value.map(A=>{var he;const Q=[];if(A.controls&&A.controls.length>0)for(const Re of A.controls){const $e=Re.type;if($e==="button"||$e==="text"||$e==="range")continue;const Ye={id:Re.property||Re.id,label:Re.label||Re.id,type:$e,default:Re.default??($e==="toggle"?!1:$e==="color"?"#ffffff":0)};$e==="slider"&&(Ye.min=Re.min??0,Ye.max=Re.max??1,Ye.step=Re.step??.01),$e==="select"&&Re.options&&(Ye.options=Re.options),Q.push(Ye)}else if(A.paramRanges){const Re=Object.entries(A.paramRanges);for(const[$e,Ye]of Re){const ht=$e.replace(/[-_]/g," ").replace(/\b\w/g,Yn=>Yn.toUpperCase()),Mt=(he=A.defaultParams)==null?void 0:he[$e],Jt=(Ye.min+Ye.max)/2;Q.push({id:$e,label:ht,min:Ye.min,max:Ye.max,step:Ye.step??.01,default:typeof Mt=="number"?Mt:Jt})}}return{id:A.id,name:A.name,category:A.category,params:Q}})),we=e.computed(()=>{const b=new Map;return l.activeFilters.value.forEach(A=>b.set(A.filterId,A)),b}),_e=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const b=o.media;return(b==null?void 0:b.thumbnail_url)??(b==null?void 0:b.url)}),oe=e.shallowRef(null),$=e.ref(null),B=e.ref(null),Z=e.ref(null),ee=e.ref(!1),ne=new Map,de=(b,A)=>{const Q={id:b.id??`text-overlay-recipe-${A}`,text:b.content};return b.fontFamily!==void 0&&(Q.fontFamily=b.fontFamily),b.fontSize!==void 0&&(Q.fontSize=b.fontSize),b.fontWeight!==void 0&&(Q.fontWeight=b.fontWeight),b.color!==void 0&&(Q.color=b.color),b.position!==void 0&&(Q.position=b.position),b.startTime!==void 0&&(Q.startTime=b.startTime),b.duration!==void 0&&(Q.duration=b.duration),b.animation!==void 0&&(Q.animation=b.animation),b.textAlign!==void 0&&(Q.textAlign=b.textAlign),b.textBaseline!==void 0&&(Q.textBaseline=b.textBaseline),Q},ue=b=>{const A={id:b.id,content:b.text};return b.fontFamily!==void 0&&(A.fontFamily=b.fontFamily),b.fontSize!==void 0&&(A.fontSize=b.fontSize),b.fontWeight!==void 0&&(A.fontWeight=b.fontWeight),b.color!==void 0&&(A.color=b.color),b.position!==void 0&&(A.position=b.position),b.startTime!==void 0&&(A.startTime=b.startTime),b.duration!==void 0&&(A.duration=b.duration),b.animation!==void 0&&(A.animation=b.animation),b.textAlign!==void 0&&(A.textAlign=b.textAlign),b.textBaseline!==void 0&&(A.textBaseline=b.textBaseline),A},ge=(b,A)=>{const Q={id:b.id??`audio-track-recipe-${A}`,source:b.source};return b.volume!==void 0&&(Q.volume=b.volume),b.startTime!==void 0&&(Q.startTime=b.startTime),b.duration!==void 0&&(Q.duration=b.duration),b.fadeIn!==void 0&&(Q.fadeIn=b.fadeIn),b.fadeOut!==void 0&&(Q.fadeOut=b.fadeOut),b.loop!==void 0&&(Q.loop=b.loop),b.name!==void 0&&(Q.name=b.name),Q},Ne=b=>{if(typeof b.source!="string")return null;const A={id:b.id,source:b.source};return b.volume!==void 0&&(A.volume=b.volume),b.startTime!==void 0&&(A.startTime=b.startTime),b.duration!==void 0&&(A.duration=b.duration),b.fadeIn!==void 0&&(A.fadeIn=b.fadeIn),b.fadeOut!==void 0&&(A.fadeOut=b.fadeOut),b.loop!==void 0&&(A.loop=b.loop),b.name!==void 0&&(A.name=b.name),A},fe=b=>{const A={id:b.id,source:typeof b.source=="string"?b.source:""};return b.volume!==void 0&&(A.volume=b.volume),b.startTime!==void 0&&(A.startTime=b.startTime),b.duration!==void 0&&(A.duration=b.duration),b.fadeIn!==void 0&&(A.fadeIn=b.fadeIn),b.fadeOut!==void 0&&(A.fadeOut=b.fadeOut),b.loop!==void 0&&(A.loop=b.loop),b.name!==void 0&&(A.name=b.name),b.muted!==void 0&&(A.muted=b.muted),b.solo!==void 0&&(A.solo=b.solo),b.pan!==void 0&&(A.pan=b.pan),b.faderDb!==void 0&&(A.faderDb=b.faderDb),A},me=b=>({...b,segments:b.segments.map(A=>{const Q={...A};return A.words&&(Q.words=A.words.map(he=>({...he}))),Q})}),Ee=e.ref((((fo=o.initialRecipe)==null?void 0:fo.textOverlays)??[]).map(de)),Te=b=>{switch(b){case"crossfade":return"cross-fade";case"zoom":return"zoom-in";case"cut":return"fade";default:return b}},dt=b=>{switch(b){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}},st=b=>{switch(b){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 b}},Dt=b=>{switch(b){case"easeIn":return"ease-in";case"easeOut":return"ease-out";case"easeInOut":return"ease-in-out";case"linear":default:return"linear"}},pt=b=>({id:b.id,type:Te(b.type),duration:b.duration,easing:dt(b.easing),name:b.type,fromClipId:b.fromClipId,toClipId:b.toClipId,cutTime:b.cutTime??0}),ft=b=>({id:b.id,type:st(b.type),fromClipId:b.fromClipId,toClipId:b.toClipId,duration:b.duration,easing:Dt(b.easing),cutTime:b.cutTime}),_t=e.ref((((ho=o.initialRecipe)==null?void 0:ho.transitions)??[]).map(pt)),ot=e.ref((((vo=o.initialRecipe)==null?void 0:vo.audioTracks)??[]).map(ge)),bt=e.ref(1),gt=e.ref(!1),ve=e.ref((((go=o.initialRecipe)==null?void 0:go.captionTracks)??[]).map(me)),Se=e.ref([]),Fe=e.ref(null),Ke=e.computed(()=>r.value),We=e.computed(()=>Se.value),ze=e.computed(()=>ve.value[0]??null),ut=e.computed(()=>{const b=s.selectedClip.value??s.timelineClips.value[0];return b?Math.max(0,b.timelineEnd-b.timelineStart):L.value}),Et=e.computed(()=>Nk(ot.value.map(fe),{master:{volume:bt.value,muted:gt.value}})),It=e.computed(()=>{const b=[...s.timelineClips.value].sort((Ye,ht)=>Ye.timelineStart-ht.timelineStart),A=s.selectedClip.value??b[0];if(!A)return[];const Q=b.findIndex(Ye=>Ye.id===A.id);if(Q===-1)return[];const he=Ye=>(Ye.trackId??null)===(A.trackId??null),Re=b.slice(Q+1).find(he);if(Re)return[A,Re];const $e=[...b.slice(0,Q)].reverse().find(he);return $e?[$e,A]:[]}),Rt=b=>{oe.value=b,b!=null&&b.composition&&(B.value=new rm(b.composition),Z.value=new sm(b.composition));try{ne.size&&oe.value&&(ne.forEach((A,Q)=>{oe.value.setClipFilters(Q,A)}),ne.clear(),oe.value.composition.computeFrame())}catch{}},Xt=b=>{oe.value?oe.value.setClipFilters(b,l.activeFilters.value):ne.set(b,[...l.activeFilters.value])},yn=b=>{var Q,he;const A=((Q=s.selectedClip.value)==null?void 0:Q.id)??((he=s.timelineClips.value[0])==null?void 0:he.id);A&&(ee.value=!0,typeof b=="object"&&b!==null&&"id"in b?l.applyFilter(b.id):typeof b=="string"&&l.applyFilter(b),s.setFilters(l.activeFilters.value),Xt(A),s.handleClipSelect(A),ee.value=!1,kt())},Pn=b=>{var he,Re;const A=l.activeFilters.value.find($e=>$e.filterId===b);A&&l.removeFilter(A.id),s.setFilters(l.activeFilters.value);const Q=((he=s.selectedClip.value)==null?void 0:he.id)??((Re=s.timelineClips.value[0])==null?void 0:Re.id);Q&&Xt(Q),kt()},Y=(b,A,Q)=>{var $e,Ye;const he=l.activeFilters.value.find(ht=>ht.filterId===b);if(he){he.params={...he.params??{},[A]:Q},s.setFilters(l.activeFilters.value);const ht=(($e=s.selectedClip.value)==null?void 0:$e.id)??((Ye=s.timelineClips.value[0])==null?void 0:Ye.id);ht&&Xt(ht),kt();return}const Re=l.previewFilter.value;Re&&Re.filterId===b&&(Re.params={...Re.params??{},[A]:Q})},re=b=>{b&&typeof b.id=="string"&&b.id!==""&&l.previewFilterEffect(b.id)},ae=b=>{l.updateFilterParams(b),s.setFilters(l.activeFilters.value),kt()},ce=async b=>{if(!B.value)return;const A=await B.value.addTextOverlay(b);Ee.value.push({id:A,...b})},Be=async(b,A)=>{if(!B.value)return;await B.value.updateTextOverlay(b,A);const Q=Ee.value.findIndex(he=>he.id===b);Q!==-1&&(Ee.value[Q]={...Ee.value[Q],...A})},Le=async b=>{B.value&&(await B.value.removeTextOverlay(b),Ee.value=Ee.value.filter(A=>A.id!==b))},Oe=async b=>{const[A,Q]=It.value;if(!A||!Q)return;const he={id:`transition-${A.id}-${Q.id}-${Date.now()}`,...b,name:b.type,fromClipId:A.id,toClipId:Q.id,cutTime:A.timelineEnd};_t.value.push(he),s.setTransitions(_t.value.map(ft)),kt()},mt=b=>{_t.value[b]&&(_t.value.splice(b,1),s.setTransitions(_t.value.map(ft)),kt())},it=b=>{},rt=async b=>{if(!Z.value)return;const A=await Z.value.addAudioTrack(b);ot.value.push({id:A,...b})},wt=async(b,A)=>{if(!Z.value)return;await Z.value.updateAudioTrack(b,A);const Q=ot.value.findIndex(he=>he.id===b);Q!==-1&&(ot.value[Q]={...ot.value[Q],...A})},At=async b=>{Z.value&&(await Z.value.removeAudioTrack(b),ot.value=ot.value.filter(A=>A.id!==b))},on=async(b,A)=>{if(!Z.value)return;await Z.value.updateVolume(b,A);const Q=ot.value.find(he=>he.id===b);Q&&(Q.volume=A)},Sn=async(b,A)=>{if(!Z.value)return;await Z.value.muteTrack(b,A);const Q=ot.value.find(he=>he.id===b);Q&&(Q.muted=A)},la=b=>{Z.value&&(Z.value.setMasterVolume(b),bt.value=b)},H=(b,A)=>{const Q=ot.value.findIndex(Re=>Re.id===b);if(Q===-1)return null;const he={...ot.value[Q],...A};return ot.value[Q]=he,he},q=b=>{switch(b.type){case"track-fader-db":{const A=Hs(b.valueDb);H(b.trackId,{faderDb:b.valueDb,volume:A}),Z.value&&Z.value.updateVolume(b.trackId,A);break}case"track-mute":H(b.trackId,{muted:b.muted}),Z.value&&Z.value.muteTrack(b.trackId,b.muted);break;case"track-solo":H(b.trackId,{solo:b.solo});break;case"track-pan":H(b.trackId,{pan:b.pan});break;case"master-fader-db":{bt.value=Hs(b.valueDb),Z.value&&Z.value.setMasterVolume(gt.value?0:bt.value);break}case"master-mute":gt.value=b.muted,Z.value&&Z.value.setMasterVolume(gt.value?0:bt.value);break}},se=b=>{ve.value=[me(b.track)],s.setCaptionTracks(ve.value),kt()},xe=b=>{ve.value=[me(b)],s.setCaptionTracks(ve.value),kt()},De=()=>{ve.value=[],s.setCaptionTracks([]),kt()},Ge=b=>{const A=s.selectedClip.value??s.timelineClips.value[0];if(!A)return;const he=[...(A.keyframes??[]).filter(Re=>Re.target!==b.target),...b.keyframes].sort((Re,$e)=>{const Ye=Re.time-$e.time;return Ye===0?Re.id.localeCompare($e.id):Ye});s.setClipKeyframes(A.id,he),kt()},Xe=b=>{var A;return b.metadata||(b.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),b.metadata.fit_mode=x.value,(A=o.media)!=null&&A.url&&/^https?:/i.test(o.media.url)?b.metadata.source_url=o.media.url:delete b.metadata.source_url,b.captionTracks=ve.value.map(me),b},Ze=(b,A)=>A?{...b,output:{...b.output,format:A.format,quality:A.quality,codec:A.codec??b.output.codec,fps:A.fps??b.output.fps,...typeof A.bitrate=="number"?{bitrate:A.bitrate}:{}}}:b,je=b=>b.map(A=>({...A,params:A.params&&typeof A.params=="object"?{...A.params}:A.params})),Tt=b=>b.timeline.some(A=>Array.isArray(A.filters)&&A.filters.length>0),lt=b=>{const A=je(l.activeFilters.value);if(!Tt(b)&&A.length>0&&b.timeline.length>0){const he=b.timeline[0];he&&(b.timeline=[{...he,filters:A},...b.timeline.slice(1)])}return b},Yt=()=>{const b=lt(Xe(s.saveDraft()));try{localStorage.setItem(`video-draft-${r.value}`,JSON.stringify(b))}catch{}return Da(b,"manual",!0),b},Jn=()=>typeof localStorage>"u"?null:{getItem:b=>localStorage.getItem(b),setItem:(b,A)=>{localStorage.setItem(b,A)},removeItem:b=>{localStorage.removeItem(b)},listKeys:b=>{const A=[];for(let Q=0;Q<localStorage.length;Q+=1){const he=localStorage.key(Q);he!=null&&he.startsWith(b)&&A.push(he)}return A}},qt=async()=>{const b=Jn();if(b===null){Se.value=[];return}Se.value=await Uc(b)},Da=async(b,A,Q)=>{var Jt,Yn;const he=Jn();if(he===null)return;const Re=new Date().toISOString(),$e={projectId:Ke.value,sourceMediaUuid:r.value,durationSeconds:L.value,editorVersion:((Jt=b.metadata)==null?void 0:Jt.editor_version)??"2.0.0",saveReason:A,now:Re};((Yn=b.metadata)==null?void 0:Yn.title)!==void 0&&($e.title=b.metadata.title);const Ye=nk(Mu(b),$e);await dk(he,Ye);const ht=await Uc(he),Mt=rk(ht,{maxCount:5,projectId:Ke.value,now:Re});await zc(he,Mt.removed),Se.value=[...Mt.retained],Q&&(Fe.value=Re)},Br=b=>b.snapshot.metadata.payloadKind==="project"?Y2(b.snapshot.payload):b.snapshot.payload,rn=b=>{const A=Br(b);s.loadRecipe(A),Ee.value=(A.textOverlays??[]).map(de),ot.value=(A.audioTracks??[]).map(ge),ve.value=(A.captionTracks??[]).map(me),_t.value=(A.transitions??[]).map(pt);const Q=V(A);Q!==null&&(x.value=Q),Cn()},Ra=b=>{const A=Jn();Se.value=Se.value.filter(Q=>!b.some(he=>he.key===Q.key)),A!==null&&zc(A,b)},Cn=()=>{$.value=Xe(s.generateRecipe())};let Vn=null;const kt=()=>{Vn&&clearTimeout(Vn),Vn=setTimeout(()=>{Cn(),Vn=null},200)};if(e.watch(()=>s.timelineClips.value,kt,{deep:!0}),e.watch(()=>s.selectedClip.value,b=>{if(ee.value||!b)return;const A=(b==null?void 0:b.filters)??[];l.setActiveFilters(A)},{immediate:!0}),e.watch(()=>l.activeFilters.value,b=>{s.setFilters(b),kt()},{deep:!0}),e.watch(()=>Ee.value,b=>{s.setTextOverlays(b.map(ue)),kt()},{deep:!0}),e.watch(()=>ot.value,b=>{const A=b.map(Ne).filter(Q=>Q!==null);s.setAudioTracks(A),kt()},{deep:!0}),e.watch(()=>ve.value,b=>{s.setCaptionTracks(b.map(me)),kt()},{deep:!0}),Ee.value.length>0&&s.setTextOverlays(Ee.value.map(ue)),ot.value.length>0){const b=ot.value.map(Ne).filter(A=>A!==null);s.setAudioTracks(b)}ve.value.length>0&&s.setCaptionTracks(ve.value.map(me)),e.watch(()=>s.playheadPosition.value,kt),Cn();const sn=e.ref(!0),bn=e.ref(null),Aa=e.computed(()=>s.tracks.value),ca=e.computed(()=>s.mediaSources.value),si=e.computed(()=>{var b,A;return((b=s.selectedClip.value)==null?void 0:b.sourceRefId)??((A=ca.value[0])==null?void 0:A.id)}),wn=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),li=e.computed(()=>!!s.selectedClip.value&&s.timelineClips.value.length>1),La=e.computed(()=>s.selectedClip.value??s.timelineClips.value[0]??null),Ir=b=>{const A=Number.isFinite(b)&&b>0?Math.round(b):0,Q=Math.floor(A/60),he=A%60;return`${Q}:${he.toString().padStart(2,"0")}`},Fr=e.computed(()=>{const b=s.timelineClips.value.length,A=Aa.value.length,Q=b===1?"1 clip":`${b} clips`,he=A===1?"1 track":`${A} tracks`;return`${Q} / ${he} / ${Ir(L.value)}`}),Kn=b=>{const A=ca.value.find(Q=>Q.id===b);return A?A.filename??A.mediaUuid??A.url??A.id:"Asset"},Pa=b=>{const A=s.appendMediaSourceToTimeline(b);if(!A){bn.value="Asset could not be added.";return}s.handleClipSelect(A.id),bn.value=`${Kn(b)} added to timeline.`,kt()},Nn=b=>{if(!s.replaceSelectedClipSource(b)){bn.value="Select a clip before replacing its source.";return}bn.value=`${Kn(b)} replaced the selected clip.`,kt()},$r=b=>{const A=Kn(b);if(!s.removeMediaSource(b)){bn.value="Remove timeline clips before deleting this asset.";return}bn.value=`${A} removed.`,kt()},Oa=(b,A)=>{A(b)&&kt()},ci=b=>{sn.value=b},di=()=>{sn.value=!sn.value},Dr=b=>{const A=b.target;if(!A)return;const Q=Number(A.value);Number.isFinite(Q)&&s.setZoomLevel(Q)},Lt=e.ref(!1),da=e.ref(0),fn=e.ref(!1),yt=e.ref(null),On=e.ref(null),ua=e.ref("preparing");let Pt=null,Qt=!1;const Ua={preparing:"Preparing export...",rendering:"Rendering frames...","encoding-video":"Encoding video...","encoding-audio":"Encoding audio...",muxing:"Muxing output...",storing:"Storing export...",complete:"Export complete"},co=b=>typeof b=="string"&&b in Ua,za=(b,A)=>{ua.value=b,yt.value=typeof A=="string"&&A.trim()!==""?A.trim():Ua[b]},Ut=(b,A,Q)=>{const he=Number.isFinite(b)?Math.max(0,Math.min(100,b)):0;da.value=he,A&&za(A,Q)},Un=b=>{if(co(b.phase))return b.phase;switch(b.status){case"pending":return"preparing";case"processing":return"rendering";case"completed":return"complete";default:return ua.value}},zt=b=>typeof b.progress_message=="string"&&b.progress_message.trim()!==""?b.progress_message.trim():void 0,Gt=(b,A,Q={allowClient:!0})=>{if(!Number.isFinite(A)||A<=0||b.timeline.length===0)return{route:"unsupported",exportDuration:A,message:"Export unavailable: the recipe has no renderable duration."};if(o.maxDuration>0&&A>o.maxDuration)return{route:"unsupported",exportDuration:A,message:`Export unavailable: duration exceeds the ${o.maxDuration}s limit.`};if(Q.allowClient&&o.clientExportThreshold>0&&A<=o.clientExportThreshold)return{route:"client",exportDuration:A};const Re=!!o.serverRenderEndpoint,$e=r.value.startsWith("temp-");return Re&&!$e?{route:"server-render",exportDuration:A}:{route:"recipe-download",exportDuration:A,message:$e?"Local media — downloaded recipe.json. Client-side PIXI export is unavailable on this device.":"No server render endpoint configured — downloaded recipe.json."}},Tn=()=>new Vr(o.serverRenderEndpoint??"/api/v1"),Mn=()=>{Pt!==null&&(clearInterval(Pt),Pt=null)},Rr=b=>{Mn();const A=Tn();Pt=setInterval(async()=>{if(Qt){Mn();return}try{const Q=await A.getJob(b),he=Number(Q.progress??0);if(Ut(he,Un(Q),zt(Q)),i("server-render-progress",da.value),Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(Mn(),Lt.value=!1,On.value=null,Q.status==="completed"){Ut(100,"complete"),fn.value=!0,yt.value=null;const Re=typeof Q.output_media_id=="string"?Q.output_media_id:void 0,$e={id:b};Re!==void 0&&($e.output_media_id=Re),i("server-render-completed",$e)}else{const Re=Q.status==="cancelled"||typeof Q.error_message=="string"&&/cancel/i.test(Q.error_message),$e=Re?"Export canceled.":typeof Q.error_message=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed";yt.value=$e,Re||i("server-render-failed",$e)}}catch(Q){Mn(),Lt.value=!1,On.value=null;const he=Q instanceof Error?Q.message:"Failed to check export progress";yt.value=he,i("server-render-failed",he)}},2e3)},uo=b=>{const A=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),Q=URL.createObjectURL(A),he=document.createElement("a");he.href=Q,he.download=`video-recipe-${Date.now()}.json`,he.click(),setTimeout(()=>URL.revokeObjectURL(Q),100)},ui=()=>{Mn(),Qt=!1,T.resetClientExport(),On.value=null,yt.value=null,fn.value=!1,da.value=0,ua.value="preparing"},mo=async b=>{Ut(0,"preparing");const Q=await Tn().createRenderJob({source_media_uuid:r.value,recipe:b}),he=typeof Q.id=="string"?Q.id:null;if(!he)throw new Error("Export failed: missing job id");On.value=he,i("export-started",he),i("server-render-started",he),Ut(1,"rendering"),Rr(he)},mi=async(b,A)=>{if(!await T.canExportClientSide())return null;const Q=await T.renderRecipeWithPixi(b,A,he=>{Qt||Ut(he,"rendering")});return Qt?(yt.value="Export canceled.",Ut(0),i("video-exported",null),null):(s.clearHasChanges(),i("recipe-generated",b),i("video-exported",Q),Ut(100,"complete"),fn.value=!0,Q)},ja=async b=>{ui(),Lt.value=!0,za("preparing");try{const A=Xe(lt(Ze(s.generateRecipe(),b)));Da(A,"before-export",!1),i("recipe-generated",A);const Q=Oc(A,L.value),he=Gt(A,Q);if(he.route==="unsupported"){Lt.value=!1,yt.value=he.message??"Export unavailable.",i("server-render-failed",yt.value);return}if(he.route==="client"){const $e=await mi(A,b);if($e!==null){const Ye=URL.createObjectURL($e.file),ht=document.createElement("a");ht.href=Ye,ht.download=`edited-video-${Date.now()}.mp4`,ht.click(),setTimeout(()=>URL.revokeObjectURL(Ye),100),Lt.value=!1;return}}const Re=he.route==="client"?Gt(A,Q,{allowClient:!1}):he;if(Re.route==="unsupported"){Lt.value=!1,yt.value=Re.message??"Export unavailable.",i("server-render-failed",yt.value);return}if(Re.route==="recipe-download"){uo(A),Lt.value=!1,Ut(100,"complete"),fn.value=!0,yt.value=Re.message??"Downloaded recipe.json.";return}await mo(A)}catch(A){const Q=Xe(s.generateRecipe());uo(Q);const he=A instanceof Error?A.message:"Export failed";Lt.value=!1,Ut(0),On.value=null,yt.value=he,i("server-render-failed",he)}},po=async()=>{Qt=!0,g.value=!1,T.cancelClientExport();const b=On.value;if(Mn(),Lt.value=!1,Ut(0),yt.value="Export canceled.",On.value=null,b&&o.serverRenderEndpoint)try{await Tn().cancelJob(b)}catch{}},ma=()=>{s.togglePlayback()},pa=()=>{s.resetChanges()},zn=()=>{const b=Yt();i("draft-saved",b)},jn=()=>{ja()},Ar=()=>{i("close")};return n({saveDraft:async()=>{const b=Yt();return i("draft-saved",b),b},exportForUpload:async b=>{ui();const A=Xe(b??s.generateRecipe()),Q=lt(A),he=Array.isArray(Q.filters)&&Q.filters.length>0,Re=Tt(Q);if(!(s.hasChanges.value||he||Re))return s.clearHasChanges(),i("video-exported",null),null;const Ye=Oc(Q,L.value),ht=Gt(Q,Ye);if(ht.route==="unsupported"){const Mt=ht.message??"Export unavailable.";throw yt.value=Mt,new Error(`Video export failed: ${Mt}`)}if(ht.route==="server-render")return Lt.value=!0,await mo(Q),null;Lt.value=!0;try{if(ht.route==="client"){const Jt=await mi(Q);if(Jt!==null)return Jt}const Mt=ht.route==="client"?Gt(Q,Ye,{allowClient:!1}):ht;if(Mt.route==="server-render")return await mo(Q),null;if(Mt.route==="unsupported"){const Jt=Mt.message??"Export unavailable.";throw yt.value=Jt,new Error(`Video export failed: ${Jt}`)}return yt.value=Mt.message??"Export unavailable for upload.",i("video-exported",null),null}catch(Mt){if(Qt)return yt.value="Export canceled.",Ut(0),i("video-exported",null),null;const Jt=Mt instanceof Error?Mt.message:"Local WebGL export failed.";throw yt.value=Jt,new Error(`Video export failed: ${Jt}`)}finally{Lt.value=!1}}}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2"),qt()}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Mn(),Qt=!0,T.cancelClientExport(),Vn&&(clearTimeout(Vn),Vn=null),oe.value&&(oe.value.destroy(),oe.value=null),B.value=null,Z.value=null}),(b,A)=>(e.openBlock(),e.createBlock(ZS,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",_N,[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:ma},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(il):e.unref(rl),"aria-hidden":"true"},null,8,["icon"])],10,EN),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:pa},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba),"aria-hidden":"true"},null,8,["icon"])],8,xN)]),A[17]||(A[17]=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",SN,[e.createElementVNode("label",CN,[A[15]||(A[15]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":A[0]||(A[0]=Q=>x.value=Q),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...A[14]||(A[14]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,x.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:zn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ar),"aria-hidden":"true"},null,8,["icon"]),A[16]||(A[16]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,VN),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":"Export",disabled:Lt.value,onClick:jn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qa),"aria-hidden":"true"},null,8,["icon"])],8,NN),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:Ar},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca),"aria-hidden":"true"},null,8,["icon"])])])]),assets:e.withCtx(()=>[e.createElementVNode("div",TN,[e.createVNode(oC,{sources:ca.value,"selected-source-id":si.value,onAdd:Pa,onReplaceSelected:Nn,onRemove:$r},null,8,["sources","selected-source-id"]),bn.value?(e.openBlock(),e.createElementBlock("p",MN,e.toDisplayString(bn.value),1)):e.createCommentVNode("",!0)])]),canvas:e.withCtx(()=>[e.createElementVNode("div",BN,[e.withDirectives(e.createVNode(ys,{ref_key:"pixiPreviewRef",ref:E,class:"v2-preview-child","aria-hidden":!F.value,source:j.value,"fallback-duration":L.value,filters:_.value,playhead:R.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":x.value,active:F.value,onPlayPause:ma,onFrameUpdate:O,onDurationChange:k},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,F.value]]),e.withDirectives(e.createVNode($s,{class:"v2-preview-child","aria-hidden":!D.value,"media-uuid":r.value,recipe:$.value,media:z.value,"enable-engine":D.value&&P.value,"fit-mode":x.value,onTimeUpdate:W,onPlayStateChange:G,onDurationChange:k,onEngineReady:Rt},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,D.value]])])]),timeline:e.withCtx(({isMobile:Q})=>{var he,Re;return[e.createElementVNode("div",{class:e.normalizeClass(["v2-timeline",{"is-mobile":!!Q}])},[e.createElementVNode("div",IN,[e.createElementVNode("div",FN,[A[18]||(A[18]=e.createElementVNode("span",{class:"v2-timeline-title","data-testid":"v2-timeline-title"},"Timeline",-1)),e.createElementVNode("span",$N,e.toDisplayString(Fr.value),1)]),e.createElementVNode("label",DN,[A[19]||(A[19]=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:Dr},null,40,RN),e.createElementVNode("span",AN,e.toDisplayString(Math.round(e.unref(s).zoomLevel.value))+" px/s",1)]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn v2-toolbar-btn--ghost",{"is-active":sn.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":sn.value?"true":"false",onClick:di},e.toDisplayString(sn.value?"Snap On":"Snap Off"),11,LN)]),e.createVNode(Ds,{playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,tracks:Aa.value,"selected-clip-id":((he=e.unref(s).selectedClip.value)==null?void 0:he.id)??((Re=e.unref(s).timelineClips.value[0])==null?void 0:Re.id)??null,duration:L.value,fps:e.unref(s).fps.value,"is-mobile":!!Q,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":sn.value,sensitivity:.25,"onUpdate:playhead":A[1]||(A[1]=$e=>e.unref(s).seekTo($e)),onTrim:A[2]||(A[2]=($e,Ye,ht)=>e.unref(s).handleTrim($e,Ye,ht)),onSplit:A[3]||(A[3]=$e=>e.unref(s).handleSplit($e)),onClipSelect:A[4]||(A[4]=$e=>e.unref(s).handleClipSelect($e)),onClipMove:A[5]||(A[5]=($e,Ye)=>e.unref(s).moveClip($e,Ye)),onSnapStateChange:ci,onToggleLock:A[6]||(A[6]=$e=>Oa($e,e.unref(s).toggleTrackLock)),onToggleHidden:A[7]||(A[7]=$e=>Oa($e,e.unref(s).toggleTrackHidden)),onToggleMuted:A[8]||(A[8]=$e=>Oa($e,e.unref(s).toggleTrackMuted)),onToggleSolo:A[9]||(A[9]=$e=>Oa($e,e.unref(s).toggleTrackSolo))},null,8,["playhead","clips","tracks","selected-clip-id","duration","fps","is-mobile","zoom-level","snap-enabled"]),e.createVNode(Rs,{"selected-clip":e.unref(s).selectedClip.value,"can-split":wn.value,"can-delete":li.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":!!Q,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,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:ma,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","onSplit","onDelete","onDuplicate","onUndo","onRedo","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])],2)]}),inspector:e.withCtx(()=>[We.value.length>0?(e.openBlock(),e.createBlock(fd,{key:0,class:"v2-draft-recovery",records:We.value,surface:"desktop","project-id":Ke.value,"saved-at":Fe.value,onRestore:rn,onDismiss:Ra},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(PV,{"active-tab":c.value,"onUpdate:activeTab":A[10]||(A[10]=Q=>c.value=Q),tabs:f.value},{filters:e.withCtx(()=>[e.createVNode(As,{filters:ie.value,"active-filters":we.value,"thumbnail-url":_e.value,onApplyFilter:yn,onRemoveFilter:Pn,onUpdateParam:Y,onPreviewFilter:re},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Ls,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:ae},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",PN,[...A[20]||(A[20]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])])),e.createVNode(hd,{class:"v2-keyframe-panel",duration:ut.value,target:"all","device-class":"desktop",onApplyPreset:Ge},null,8,["duration"])]),text:e.withCtx(()=>[e.createVNode(Os,{overlays:Ee.value,onAddOverlay:ce,onUpdateOverlay:Be,onRemoveOverlay:Le},null,8,["overlays"]),e.createVNode(pd,{class:"v2-caption-panel","caption-track":ze.value,layout:"desktop",onImport:se,"onUpdate:captionTrack":xe,onClear:De},null,8,["caption-track"])]),transitions:e.withCtx(()=>[e.createVNode(Us,{"selected-clips":It.value,"applied-transitions":_t.value,onApplyTransition:Oe,onRemoveTransition:mt,onPreviewTransition:it},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(zs,{"audio-layers":ot.value,"master-volume":bt.value,onAddTrack:rt,onUpdateTrack:wt,onRemoveTrack:At,onUpdateVolume:on,onToggleMute:Sn,onUpdateMasterVolume:la},null,8,["audio-layers","master-volume"]),e.createVNode(md,{class:"v2-audio-mixer",state:Et.value,"device-class":"desktop",onUpdate:q},null,8,["state"])]),export:e.withCtx(()=>[e.createVNode(Ps,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Lt.value,"export-progress":da.value,onExport:ja,onCancelExport:po,onSaveDraft:zn,onReset:pa},null,8,["can-export","is-exporting","export-progress"]),fn.value?(e.openBlock(),e.createElementBlock("div",ON," Export complete ")):e.createCommentVNode("",!0),yt.value&&!fn.value?(e.openBlock(),e.createElementBlock("div",UN,e.toDisplayString(yt.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(kN,{"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[We.value.length>0?(e.openBlock(),e.createBlock(fd,{key:0,class:"v2-draft-recovery",records:We.value,surface:"mobile","project-id":Ke.value,"saved-at":Fe.value,onRestore:rn,onDismiss:Ra},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(dN,{"selected-clip":La.value,onOpenActions:A[11]||(A[11]=Q=>d.value="trim")},null,8,["selected-clip"]),e.createVNode(hN,{modelValue:d.value,"onUpdate:modelValue":A[12]||(A[12]=Q=>d.value=Q)},null,8,["modelValue"]),d.value==="look"?(e.openBlock(),e.createElementBlock("section",zN,[e.createElementVNode("div",jN,[e.createVNode(As,{filters:ie.value,"active-filters":we.value,"thumbnail-url":_e.value,onApplyFilter:yn,onRemoveFilter:Pn,onUpdateParam:Y,onPreviewFilter:re},null,8,["filters","active-filters","thumbnail-url"])]),e.createElementVNode("div",WN,[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Ls,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:ae},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",ZN,[...A[21]||(A[21]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))])])):d.value==="trim"?(e.openBlock(),e.createElementBlock("section",HN,[e.createVNode(Rs,{"selected-clip":e.unref(s).selectedClip.value,"can-split":wn.value,"can-delete":li.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":"",onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,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:ma,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"])])):d.value==="text"?(e.openBlock(),e.createElementBlock("section",XN,[e.createVNode(Os,{overlays:Ee.value,onAddOverlay:ce,onUpdateOverlay:Be,onRemoveOverlay:Le},null,8,["overlays"]),e.createVNode(pd,{"caption-track":ze.value,layout:"mobile",onImport:se,"onUpdate:captionTrack":xe,onClear:De},null,8,["caption-track"])])):d.value==="audio"?(e.openBlock(),e.createElementBlock("section",GN,[e.createVNode(zs,{"audio-layers":ot.value,"master-volume":bt.value,onAddTrack:rt,onUpdateTrack:wt,onRemoveTrack:At,onUpdateVolume:on,onToggleMute:Sn,onUpdateMasterVolume:la},null,8,["audio-layers","master-volume"]),e.createVNode(md,{state:Et.value,"device-class":"mobile",onUpdate:q},null,8,["state"])])):d.value==="export"?(e.openBlock(),e.createElementBlock("section",JN,[e.createVNode(Ps,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Lt.value,"export-progress":da.value,"is-mobile":"",onExport:ja,onCancelExport:po,onSaveDraft:zn,onReset:pa},null,8,["can-export","is-exporting","export-progress"]),fn.value?(e.openBlock(),e.createElementBlock("div",KN,"Export complete")):e.createCommentVNode("",!0),yt.value&&!fn.value?(e.openBlock(),e.createElementBlock("div",YN,e.toDisplayString(yt.value),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("section",qN,[e.createElementVNode("div",QN,[e.createElementVNode("label",e4,[A[23]||(A[23]=e.createElementVNode("span",null,"Fit",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":A[13]||(A[13]=Q=>x.value=Q),"aria-label":"Mobile fit mode"},[...A[22]||(A[22]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,x.value]])]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-mobile-secondary-button",{"is-active":sn.value}]),"aria-pressed":sn.value?"true":"false","data-testid":"v2-mobile-btn-snap-toggle",onClick:di},e.toDisplayString(sn.value?"Snap On":"Snap Off"),11,t4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-reset",disabled:!e.unref(s).hasChanges.value,onClick:pa}," Reset ",8,n4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-save",disabled:!e.unref(s).hasChanges.value,onClick:zn}," Save ",8,a4)]),h.value?(e.openBlock(),e.createElementBlock("details",o4,[A[24]||(A[24]=e.createElementVNode("summary",null,"Transitions",-1)),e.createVNode(Us,{"selected-clips":It.value,"applied-transitions":_t.value,onApplyTransition:Oe,onRemoveTransition:mt,onPreviewTransition:it},null,8,["selected-clips","applied-transitions"])])):e.createCommentVNode("",!0),e.createElementVNode("details",i4,[A[25]||(A[25]=e.createElementVNode("summary",null,"Keyframe presets",-1)),e.createVNode(hd,{duration:ut.value,target:"all","device-class":"mobile",onApplyPreset:Ge},null,8,["duration"])])]))]),_:1})]),_:1}))}}),s4=Ve(r4,[["__scopeId","data-v-ec9f72e8"]]),En=a=>a===null||typeof a!="object"||Array.isArray(a)?null:a,tt=a=>{if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const n=Number(a);return Number.isFinite(n)?n:null}return null},l4=(a,n)=>{if(n===null)return;const t=En(a.source)??{},o=tt(t.duration);if(!(o!==null&&o>0&&o<=1&&n>o))return;t.duration=n,a.source=t;const r=Array.isArray(a.timeline)?a.timeline:[];if(r.length===1){const c=En(r[0]);if(c!==null){const d=tt(c.sourceIn)??0,u=tt(c.sourceOut)??tt(c.end)??tt(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const p=tt(c.end);p!==null&&p>0&&p<=1&&(c.end=n);const m=tt(c.timelineEnd);m!==null&&m>0&&m<=1&&(c.timelineEnd=n)}}}const s=tt(a.trimEnd)??tt(a.trim_end);s!==null&&s>0&&s<=1&&(a.trimEnd=n);const l=En(a.trim);if(l!==null){const c=tt(l.end);c!==null&&c>0&&c<=1&&(l.end=n,a.trim=l)}},c4=(a,n)=>{if(!a)return!1;const t=En(a);if(t===null)return!1;const o=En(t.trim),i=En(t.source),s=tt(i==null?void 0:i.duration)??n,l=Array.isArray(a.filters)&&a.filters.length>0;let c=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];m&&Array.isArray(m.filters)&&m.filters.length>0&&(c=!0)}let d=!1;const u=tt(t.trimStart)??tt(t.trim_start)??tt(o==null?void 0:o.start),f=tt(t.trimEnd)??tt(t.trim_end)??tt(o==null?void 0:o.end);if(u!==null&&u>0&&(d=!0),f!==null&&s!==void 0&&f<s&&(d=!0),!d&&Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];if(m){const h=tt(m.sourceIn),g=tt(m.sourceOut);h!==null&&h>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let p=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];if(m){const h=tt(m.speed);p=h!==null&&h!==1}}return l||c||d||p},$m=a=>{if(!a)return!1;const n=En(a);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(a.timeline)&&a.timeline.length>1)},d4=(a,n={})=>{var p,m;const t=JSON.parse(JSON.stringify(a)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?En(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=tt(i.sourceIn),g=tt(i.sourceOut);h!==null&&t.trimStart===void 0&&(t.trimStart=h),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const l=En(t.trim);if(t.trimStart===void 0){const h=tt(l==null?void 0:l.start);h!==null&&(t.trimStart=h)}if(t.trimEnd===void 0){const h=tt(l==null?void 0:l.end);h!==null&&(t.trimEnd=h)}const c=En(t.source),d=tt(t.width)??tt(c==null?void 0:c.original_width)??tt((p=n.exportMeta)==null?void 0:p.width);d!==null&&(t.width=d);const u=tt(t.height)??tt(c==null?void 0:c.original_height)??tt((m=n.exportMeta)==null?void 0:m.height);u!==null&&(t.height=u);const f=En(t.output);return t.fps=tt(t.fps)??tt(f==null?void 0:f.fps)??30,l4(t,n.mediaDuration??null),t},u4={key:0},m4=["data-testid"],p4={class:"ve-mobile-header"},f4=["data-testid"],h4={class:"ve-mobile-title"},v4=["data-testid","disabled"],g4={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},y4={class:"ve-body"},b4=["data-testid"],w4=["aria-label"],k4={class:"ve-header"},_4={class:"ve-title"},E4=["data-testid"],x4={class:"ve-body"},S4={class:"ve-footer"},C4=["data-testid"],V4=["data-testid","disabled"],N4=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),l=e.computed(()=>o.saveImmediate===!1),c=e.computed(()=>o.closeText),d=e.computed(()=>f.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),f=e.ref(!1),p=e.ref(!1),m=e.ref(null),h=`temp-${Date.now()}`,g=e.computed(()=>{var k;const L=(k=o.featureFlags)==null?void 0:k.export;return typeof L=="boolean"?L:o.workflowMode==="full"}),w=e.computed(()=>{if(o.editorVersion==="v1"||o.editorVersion==="v2")return o.editorVersion;if(typeof window>"u")return"v2";try{const L=new URLSearchParams(window.location.search),k=L.get("editor")??L.get("video-editor");if(k==="v1")return"v1";if(k==="v2")return"v2"}catch{}return"v2"}),F=e.computed(()=>w.value==="v2"?s4:Fm),D=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():h),E=e.computed(()=>{const L={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&(L.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&(L.initialRecipe=o.initialRecipe),o.media!==void 0&&(L.media=o.media),L}),v=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",v)}),e.onUnmounted(()=>{window.removeEventListener("resize",v)}),e.onErrorCaptured(()=>(p.value=!0,!1));const S=L=>{const k=Array.isArray(L.timeline)?L.timeline:[];if(k.length===0)return 0;let O=0;for(const W of k){const G=Number(W.sourceIn),ie=Number(W.sourceOut),we=Number(W.speed??1),_e=Number.isFinite(we)&&we>0?we:1;if(Number.isFinite(G)&&Number.isFinite(ie)&&ie>G){O+=(ie-G)/_e;continue}const oe=Number(W.timelineStart),$=Number(W.timelineEnd);Number.isFinite(oe)&&Number.isFinite($)&&$>oe&&(O+=$-oe)}return O},C=(L,k,O)=>{let W=null;const G=new Promise((ie,we)=>{W=setTimeout(()=>we(new Error(`${O} timed out after ${k}ms`)),k)});return Promise.race([L,G]).finally(()=>{W!==null&&clearTimeout(W)})},V=()=>{var G;const O=(G=o.media)==null?void 0:G.duration;if(typeof O!="number"||!Number.isFinite(O)||O<=0)return 12e3;const W=Math.round(O*1e3);return Math.min(45e3,Math.max(12e3,W))},x=()=>{i("close"),i("update:open",!1)},N=()=>{f.value=!1,x()},j=L=>{i("recipe-generated",L)},_=L=>{i("export-started",L),i("save-started",L)},R=L=>{i("video-exported",L)},T=L=>{i("thumbnail-selected",L)},z=(L,k,O)=>{i("save-recipe",L);const W={recipe:L,exportPayload:k};O!==void 0&&(W.toastDescription=O),i("save-complete",W),x()},P=L=>{f.value||(i("draft-saved",L),z(L,null))},M=async()=>{var L;if(!f.value){if(p.value||m.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x();return}f.value=!0;try{const k=await C(m.value.saveDraft(),V(),"saveDraft");let O=null,W=!1,G;const ie=S(k),we=ie>0?ie:((L=o.media)==null?void 0:L.duration)??0;if(g.value&&we>0&&we<=o.clientExportThreshold&&typeof m.value.exportForUpload=="function"){W=!0;const oe=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{O=await C(m.value.exportForUpload(k),oe,"exportForUpload")}catch{O=null}}if($m(k)&&O===null){i("save-error",{code:"unsupported-client-export-required",message:"These edits require in-browser export. Shorten the clip or remove text overlays, transitions, or extra clips and try again."});return}W&&O===null&&(G="Video edits saved. Final render will happen when you share."),z(k,O,G)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x()}finally{f.value=!1}}};return n({saveDraft:M}),(L,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",u4,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",p4,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:N},e.toDisplayString(c.value),9,f4),e.createElementVNode("h2",h4,e.toDisplayString(L.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:M},e.toDisplayString(d.value),9,v4)):(e.openBlock(),e.createElementBlock("span",g4))]),e.createElementVNode("section",y4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(F.value),e.mergeProps({ref_key:"videoEditorRef",ref:m,"media-uuid":D.value,"data-editor-version":w.value},E.value,{onClose:N,onDraftSaved:P,onExportStarted:_,onRecipeGenerated:j,onThumbnailSelected:T,onVideoExported:R}),null,16,["media-uuid","data-editor-version"]))])],8,m4)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(N,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":L.title,"aria-modal":"true"},[e.createElementVNode("header",k4,[e.createElementVNode("h2",_4,e.toDisplayString(L.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:N}," ✕ ",8,E4)]),e.createElementVNode("section",x4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(F.value),e.mergeProps({ref_key:"videoEditorRef",ref:m,"media-uuid":D.value,"data-editor-version":w.value},E.value,{onClose:N,onDraftSaved:P,onExportStarted:_,onRecipeGenerated:j,onThumbnailSelected:T,onVideoExported:R}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",S4,[e.renderSlot(L.$slots,"footer",{close:N,isSaving:f.value,save:M},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:N},e.toDisplayString(c.value),9,C4),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:M},e.toDisplayString(d.value),9,V4)):e.createCommentVNode("",!0)],!0)])],8,w4)],8,b4))])):e.createCommentVNode("",!0)]))}}),T4=Ve(N4,[["__scopeId","data-v-3cc6e078"]]),M4={class:"video-editor-modal"},B4={class:"video-preview-container"},I4=["src"],F4={class:"video-overlay-controls"},$4=["aria-label"],D4={class:"time-display"},R4={class:"timeline-container"},A4={class:"clip-name"},L4={class:"timeline-time-labels"},P4={class:"tool-tabs"},O4=["onClick"],U4={class:"tool-panel"},z4={key:0,class:"trim-panel"},j4={class:"trim-controls"},W4={key:1,class:"filters-panel"},Z4={class:"filter-grid"},H4=["onClick"],X4={key:2,class:"text-panel"},G4={key:3,class:"transitions-panel"},J4={class:"transition-grid"},K4=["onClick"],Y4={class:"action-buttons"},q4=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),f=e.ref(0),p=e.ref(null),m=e.ref("trim"),h=e.ref(null),g=e.ref(""),w=[{id:"trim",label:"Trim",icon:zi},{id:"filters",label:"Filters",icon:Mf},{id:"text",label:"Text",icon:zd},{id:"transitions",label:"Transitions",icon:Lf}],F=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],D=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],E=e.ref();e.onMounted(()=>{var k,O;(k=t.media)!=null&&k.url?r.value=t.media.url:(O=t.media)!=null&&O.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var k;(k=t.media)!=null&&k.file&&r.value&&URL.revokeObjectURL(r.value)});function v(){i.value&&(c.value=i.value.duration,f.value=c.value)}function S(){i.value&&(l.value=i.value.currentTime)}function C(){s.value=!1}function V(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function x(k){if(!k||isNaN(k))return"00:00";const O=Math.floor(k/60),W=Math.floor(k%60);return`${O.toString().padStart(2,"0")}:${W.toString().padStart(2,"0")}`}function N(k){if(!i.value||!E.value)return;const O=E.value.getBoundingClientRect(),ie=(k.clientX-O.left)/O.width*c.value;i.value.currentTime=Math.max(0,Math.min(ie,c.value))}function j(){u.value=l.value}function _(){f.value=l.value}function R(){u.value=0,f.value=c.value}function T(k){p.value=k;const O=G=>{if(!p.value||!E.value)return;const ie=E.value.getBoundingClientRect(),oe=(G.clientX-ie.left)/ie.width*c.value;p.value==="start"?u.value=Math.max(0,Math.min(oe,f.value-1)):f.value=Math.max(u.value+1,Math.min(oe,c.value))},W=()=>{p.value=null,document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",O),document.addEventListener("mouseup",W)}function z(k){if(h.value=k,!i.value)return;const O={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=O[k]||"none"}function P(){}function M(k){}function L(){const k={timeline:[{id:d.value,url:r.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:h.value?[{type:h.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:f.value-u.value};o("save",k)}return(k,O)=>(e.openBlock(),e.createElementBlock("div",M4,[e.createElementVNode("div",B4,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:v,onTimeupdate:S,onEnded:C,controls:""},null,40,I4),e.createElementVNode("div",F4,[e.createElementVNode("button",{class:"play-pause-btn",onClick:V,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:s.value?e.unref(zf):e.unref(Hf)},null,8,["icon"])],8,$4),e.createElementVNode("div",D4,e.toDisplayString(x(l.value))+" / "+e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",R4,[e.createElementVNode("div",{class:"timeline-track",onClick:N,ref_key:"timelineTrack",ref:E},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-f.value/c.value*100}%`})},[e.createElementVNode("span",A4,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),m.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:O[0]||(O[0]=W=>T("start"))},null,36)):e.createCommentVNode("",!0),m.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${f.value/c.value*100}%`}),onMousedown:O[1]||(O[1]=W=>T("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",L4,[e.createElementVNode("span",null,e.toDisplayString(x(0)),1),e.createElementVNode("span",null,e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",P4,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(w,W=>e.createElementVNode("button",{key:W.id,class:e.normalizeClass(["tool-tab",{active:m.value===W.id}]),onClick:G=>m.value=W.id},[e.createVNode(e.unref(U.IonIcon),{icon:W.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(W.label),1)],10,O4)),64))]),e.createElementVNode("div",U4,[m.value==="trim"?(e.openBlock(),e.createElementBlock("div",z4,[O[7]||(O[7]=e.createElementVNode("h3",null,"Trim Video",-1)),O[8]||(O[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",j4,[e.createElementVNode("button",{class:"btn-trim",onClick:j},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cc)},null,8,["icon"]),O[4]||(O[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:_},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cc)},null,8,["icon"]),O[5]||(O[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:R},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca)},null,8,["icon"]),O[6]||(O[6]=e.createTextVNode(" Clear ",-1))])])])):m.value==="filters"?(e.openBlock(),e.createElementBlock("div",W4,[O[9]||(O[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",Z4,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(F,W=>e.createElementVNode("button",{key:W.id,class:e.normalizeClass(["filter-option",{active:h.value===W.id}]),onClick:G=>z(W.id)},e.toDisplayString(W.name),11,H4)),64))])])):m.value==="text"?(e.openBlock(),e.createElementBlock("div",X4,[O[10]||(O[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[2]||(O[2]=W=>g.value=W),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:P},"Add Text")])):m.value==="transitions"?(e.openBlock(),e.createElementBlock("div",G4,[O[11]||(O[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",J4,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(D,W=>e.createElementVNode("button",{key:W.id,class:"transition-option",onClick:G=>(W.id,void 0)},e.toDisplayString(W.name),9,K4)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Y4,[e.createElementVNode("button",{class:"btn-cancel",onClick:O[3]||(O[3]=W=>k.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:L},"SAVE")])]))}}),Q4=Ve(q4,[["__scopeId","data-v-b933f33b"]]),e3={class:"time-label"},t3=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(a){const n=a,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),o=e.computed(()=>{const s=[],l=i(n.duration,n.zoom);for(let c=0;c<=n.duration;c+=l){const d=`${c/n.duration*100}%`,u=r(c),f=c%(l*5)===0;s.push({time:c,position:d,label:u,major:f})}return s});function i(s,l){const c=s/(10*l);return c<=1?1:c<=5?5:c<=10?10:c<=30?30:c<=60?60:Math.ceil(c/60)*60}function r(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",e3,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),n3=Ve(t3,[["__scopeId","data-v-0ef9c910"]]),a3=["data-track-index"],o3={class:"track-header"},i3={class:"track-label"},r3={class:"track-controls"},s3=["data-testid","aria-label"],l3=["data-testid","onMousedown","onClick"],c3={class:"clip-content"},d3={class:"clip-name"},u3={key:0,class:"clip-thumbnail"},m3=["src","alt"],p3=["onMousedown","aria-label"],f3=["onMousedown","aria-label"],h3=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(w){const F=w.timelineEnd-w.timelineStart,D=w.timelineStart/t.duration*100,E=F/t.duration*100;return{left:`${D}%`,width:`${E}%`,backgroundColor:u(w)}}function u(w){const F=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],D=parseInt(w.id.replace(/\D/g,""))%F.length;return F[D]}function f(w){return w.label?w.label:w.url?(w.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${w.id.slice(-4)}`}function p(w){i.value=w.id,o("clip-select",w.id)}function m(){r.value=!r.value}function h(w,F){if(l.value)return;s.value=!0;const D=F.clientX,E=w.timelineStart,v=C=>{if(!s.value)return;const V=C.clientX-D,x=parseFloat(c.value.width),N=V/(t.zoom*100)*(t.duration/x),j=Math.max(0,E+N);o("clip-move",w.id,j)},S=()=>{s.value=!1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",S)}function g(w,F,D){l.value=F;const E=D.clientX,v=w.sourceIn,S=w.sourceOut,C=x=>{if(!l.value)return;const N=x.clientX-E,j=parseFloat(c.value.width),_=N/(t.zoom*100)*(t.duration/j);if(l.value==="start"){const R=Math.max(0,v+_);o("clip-trim",w.id,R,S)}else{const R=Math.max(v+1,S+_);o("clip-trim",w.id,v,R)}},V=()=>{l.value=null,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",V)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",V)}return(w,F)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":w.trackIndex},[e.createElementVNode("div",o3,[e.createElementVNode("span",i3,"Track "+e.toDisplayString(w.trackIndex+1),1),e.createElementVNode("div",r3,[w.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${w.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${w.trackIndex+1}`,onClick:m},[e.createVNode(e.unref(U.IonIcon),{icon:r.value?e.unref(rh):e.unref(oh)},null,8,["icon"])],8,s3)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.clips,D=>(e.openBlock(),e.createElementBlock("div",{key:D.id,class:e.normalizeClass(["timeline-clip",{selected:D.id===i.value}]),style:e.normalizeStyle(d(D)),"data-testid":`clip-${D.id}`,onMousedown:E=>h(D,E),onClick:E=>p(D)},[e.createElementVNode("div",c3,[e.createElementVNode("span",d3,e.toDisplayString(f(D)),1),D.thumbnail?(e.openBlock(),e.createElementBlock("div",u3,[e.createElementVNode("img",{src:D.thumbnail,alt:f(D)},null,8,m3)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(E=>g(D,"start",E),["stop"]),"aria-label":`Trim start of ${f(D)}`},null,40,p3),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(E=>g(D,"end",E),["stop"]),"aria-label":`Trim end of ${f(D)}`},null,40,f3)],46,l3))),128))],4)],8,a3))}}),v3=Ve(h3,[["__scopeId","data-v-48e480d2"]]),g3={class:"video-timeline"},y3={class:"timeline-tracks"},b3=["aria-label","aria-valuenow","aria-valuemax"],w3={class:"timeline-controls"},k3={class:"zoom-level"},_3=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const E=Math.max(0,...t.clips.map(v=>v.track||0));return Array(E+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(E){return t.clips.filter(v=>(v.track||0)===E)}function f(E){const v=Math.floor(E/60),S=Math.floor(E%60);return`${v}:${S.toString().padStart(2,"0")}`}function p(E,v){o("clip-move",E,v)}function m(E,v,S){o("clip-trim",E,v,S)}function h(E){r.value=E}function g(){i.value=Math.min(i.value*1.2,5)}function w(){i.value=Math.max(i.value/1.2,.5)}function F(){s.value=!0;const E=S=>{if(!s.value||!l.value)return;const C=l.value.getBoundingClientRect(),N=Math.max(0,Math.min(S.clientX-C.left,C.width))/C.width*t.duration;o("seek",N)},v=()=>{s.value=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",v)}function D(E){let v=t.currentTime;switch(E.key){case"ArrowLeft":v=Math.max(0,t.currentTime-1);break;case"ArrowRight":v=Math.min(t.duration,t.currentTime+1);break;case"Home":v=0;break;case"End":v=t.duration;break;default:return}E.preventDefault(),o("seek",v)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(E,v)=>(e.openBlock(),e.createElementBlock("div",g3,[e.createVNode(n3,{duration:E.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",y3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(S,C)=>(e.openBlock(),e.createBlock(v3,{key:`track-${C}`,"data-testid":`track-${C}`,clips:u(C),"track-index":C,zoom:i.value,duration:E.duration,onClipMove:p,onClipTrim:m,onClipSelect:h},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:F,"data-testid":"playhead","aria-label":`Playhead at ${f(E.currentTime)}`,role:"slider","aria-valuenow":E.currentTime,"aria-valuemax":E.duration,tabindex:"0",onKeydown:D},null,44,b3),e.createElementVNode("div",w3,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(al)},null,8,["icon"])]),e.createElementVNode("span",k3,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:w},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qf)},null,8,["icon"])])])]))}}),E3=Ve(_3,[["__scopeId","data-v-001df415"]]),x3={class:"video-filters-panel"},S3={class:"filter-controls"},C3=["for"],V3={class:"filter-slider-group"},N3=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],T3={class:"filter-value"},M3={class:"filter-actions"},B3={key:0,class:"filter-presets"},I3={class:"preset-list"},F3=["data-testid","aria-label","onClick"],$3=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(a,{emit:n}){const t=n,o=[{type:"brightness",label:"Brightness",min:0,max:200,step:1,default:100},{type:"contrast",label:"Contrast",min:0,max:200,step:1,default:100},{type:"saturation",label:"Saturation",min:0,max:200,step:1,default:100},{type:"hue",label:"Hue",min:-180,max:180,step:1,default:0},{type:"blur",label:"Blur",min:0,max:10,step:.5,default:0},{type:"sharpen",label:"Sharpen",min:0,max:10,step:.5,default:0},{type:"sepia",label:"Sepia",min:0,max:100,step:1,default:0},{type:"grayscale",label:"Grayscale",min:0,max:100,step:1,default:0}],i=e.reactive(o.reduce((p,m)=>(p[m.type]=m.default,p),{})),r=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(p,m){switch(p){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${m}%`;case"hue":return`${m}°`;case"blur":case"sharpen":return m.toFixed(1);default:return m.toString()}}function l(p){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(p)}function c(p){if(!l(p))return;const m={id:`filter-${p}`,filterId:p,params:{value:i[p]},intensity:1};t("filter-change",m)}function d(){o.forEach(p=>{i[p.type]=p.default,c(p.type)})}function u(){const p=prompt("Enter preset name:");if(!p)return;const m={id:`custom-${Date.now()}`,name:p,values:{...i}};r.value.push(m)}function f(p){Object.entries(p.values).forEach(([m,h])=>{i[m]=h,c(m)})}return(p,m)=>(e.openBlock(),e.createElementBlock("div",x3,[m[3]||(m[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",S3,[(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,C3),e.createElementVNode("div",V3,[e.withDirectives(e.createElementVNode("input",{id:`filter-${h.type}`,"onUpdate:modelValue":g=>i[h.type]=g,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:g=>c(h.type)},null,40,N3),[[e.vModelText,i[h.type],void 0,{number:!0}]]),e.createElementVNode("span",T3,e.toDisplayString(s(h.type,i[h.type])),1)])])),64))]),e.createElementVNode("div",M3,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:d},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba)},null,8,["icon"]),m[0]||(m[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(U.IonIcon),{icon:e.unref(ar)},null,8,["icon"]),m[1]||(m[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",B3,[m[2]||(m[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",I3,[(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:g=>f(h)},e.toDisplayString(h.name),9,F3))),128))])])):e.createCommentVNode("",!0)]))}}),D3=Ve($3,[["__scopeId","data-v-5ad2ac63"]]),R3={class:"video-text-panel"},A3={class:"text-input-group"},L3={class:"text-options"},P3={class:"option-row"},O3={class:"option-row"},U3={class:"option-row"},z3={class:"option-row"},j3={class:"checkbox-label"},W3={class:"option-row"},Z3={class:"text-overlay-list"},H3={key:0,class:"empty-state"},X3=["data-testid"],G3={class:"overlay-preview"},J3={class:"overlay-controls"},K3=["data-testid","aria-label","onClick"],Y3=["data-testid","aria-label","onClick"],q3=["data-testid","aria-label","onClick"],Q3=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const d={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(f=>f.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function l(d){i.text=d.text,i.fontFamily=d.fontFamily||"Arial",i.fontSize=d.fontSize,i.color=d.color,i.backgroundColor=d.backgroundColor||"#000000",i.hasBackground=!!d.backgroundColor,i.animation=d.animation||"none",s(d.id)}function c(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};o.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",R3,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",A3,[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(U.IonIcon),{icon:e.unref(al)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",L3,[e.createElementVNode("div",P3,[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",O3,[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",U3,[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",z3,[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",j3,[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",W3,[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",Z3,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",H3," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(f,p)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${p}`},[e.createElementVNode("div",G3,[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",J3,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${p}`,"aria-label":`Edit overlay: ${f.text}`,onClick:m=>l(f)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(If)},null,8,["icon"])],8,K3),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${p}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:m=>c(f)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(vs)},null,8,["icon"])],8,Y3),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${p}`,"aria-label":`Remove overlay: ${f.text}`,onClick:m=>s(f.id)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(gs)},null,8,["icon"])],8,q3)])],8,X3))),128))])]))}}),eT=Ve(Q3,[["__scopeId","data-v-4d240e1e"]]),tT={class:"video-tools-panel"},nT={class:"tool-tabs"},aT=["data-testid","aria-label","aria-selected","onClick"],oT={class:"tool-content"},iT={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},rT={class:"trim-actions"},sT={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},lT={class:"transition-types"},cT=["data-testid","aria-label","onClick"],dT={class:"transition-preview"},uT=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(a){const n=[{id:"trim",name:"Trim",icon:zi},{id:"filters",name:"Filters",icon:na},{id:"text",name:"Text",icon:zd},{id:"transitions",name:"Transitions",icon:mc}],t=[{id:"fade",name:"Fade",icon:Yr},{id:"slide-left",name:"Slide Left",icon:Sf},{id:"slide-right",name:"Slide Right",icon:Cf},{id:"dissolve",name:"Dissolve",icon:Yr},{id:"wipe",name:"Wipe",icon:mc},{id:"zoom",name:"Zoom",icon:Yr}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",tT,[e.createElementVNode("div",nT,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:o.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":o.activeTool===r.id,role:"tab",onClick:s=>o.$emit("tool-change",r.id)},[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,aT)),64))]),e.createElementVNode("div",oT,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",iT,[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",rT,[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(U.IonIcon),{icon:e.unref(dc)},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(U.IonIcon),{icon:e.unref(dc)},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(U.IonIcon),{icon:e.unref(Ca)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(D3,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(eT,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",sT,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",lT,[(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",dT,[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,cT)),64))])])):e.createCommentVNode("",!0)])]))}}),mT=Ve(uT,[["__scopeId","data-v-fc135306"]]),pT={class:"video-export-panel"},fT={class:"export-presets"},hT=["value"],vT={key:0,class:"preset-details"},gT={class:"detail-row"},yT={class:"detail-row"},bT={class:"detail-row"},wT={class:"advanced-options"},kT={class:"options-content"},_T={class:"option-group"},ET={class:"option-group"},xT={class:"option-group"},ST=["disabled"],CT={key:1,class:"export-progress"},VT={class:"progress-message"},NT={class:"progress-bar"},TT=["aria-valuenow"],MT={class:"progress-percentage"},BT=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===i.value)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function c(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",pT,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",fT,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=f=>i.value=f),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,hT))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",vT,[e.createElementVNode("div",gT,[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",yT,[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",bT,[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",wT,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",kT,[e.createElementVNode("div",_T,[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",ET,[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",xT,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=f=>r.includeAudio=f),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:d.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:c},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qa)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,ST),d.isExporting?(e.openBlock(),e.createElementBlock("div",CT,[e.createElementVNode("div",VT,e.toDisplayString(l.value),1),e.createElementVNode("div",NT,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${d.exportProgress}%`}),role:"progressbar","aria-valuenow":d.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,TT)]),e.createElementVNode("div",MT,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),IT=Ve(BT,[["__scopeId","data-v-5caf8fe6"]]),FT=["data-testid"],$T={class:"progress-header"},DT={class:"file-info"},RT={class:"file-details"},AT={class:"file-name"},LT={class:"file-meta"},PT={class:"file-size"},OT={key:0,class:"separator"},UT={key:1,class:"upload-speed"},zT={key:2,class:"separator"},jT={key:3,class:"time-remaining"},WT={class:"progress-actions"},ZT={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},HT={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},XT={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},GT=["aria-valuenow","aria-label"],JT={class:"progress-bar"},KT={class:"progress-percent"},YT={key:1,class:"error-message","data-testid":"video-upload-error"},qT={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},QT=["src","alt"],eM={key:0,class:"video-duration"},tM=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(a){const n=a,t=e.computed(()=>({"is-uploading":n.upload.status==="uploading","is-processing":n.upload.status==="processing","is-completed":n.upload.status==="completed","is-error":n.upload.status==="error","is-pending":n.upload.status==="pending"})),o=e.computed(()=>jd),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const p=n.upload.timeRemaining;if(p<60)return`${Math.round(p)}s`;const m=Math.floor(p/60);return m<60?`${m}m ${Math.round(p%60)}s`:`${Math.floor(m/60)}h ${m%60}m`}),l=e.computed(()=>{var p;return n.upload.status==="completed"&&((p=n.upload.media)!=null&&p.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var p;return(p=n.upload.media)==null?void 0:p.duration});function d(p){if(p===0)return"0 B";const m=["B","KB","MB","GB","TB"],h=1024,g=Math.floor(Math.log(p)/Math.log(h));return`${(p/Math.pow(h,g)).toFixed(1)} ${m[g]}`}function u(p){if(p===0)return"0 B/s";const m=["B/s","KB/s","MB/s","GB/s"],h=1024,g=Math.floor(Math.log(p)/Math.log(h));return`${(p/Math.pow(h,g)).toFixed(1)} ${m[g]}`}function f(p){const m=Math.floor(p/3600),h=Math.floor(p%3600/60),g=Math.floor(p%60);return m>0?`${m}:${h.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${h}:${g.toString().padStart(2,"0")}`}return(p,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${p.upload.id}`},[e.createElementVNode("div",$T,[e.createElementVNode("div",DT,[e.createVNode(e.unref(U.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",RT,[e.createElementVNode("h4",AT,e.toDisplayString(p.upload.filename),1),e.createElementVNode("p",LT,[e.createElementVNode("span",PT,e.toDisplayString(d(p.upload.bytesTotal||0)),1),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",OT,"•")):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",UT,e.toDisplayString(u(p.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",zT,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",jT,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",WT,[p.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",ZT,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ld)},null,8,["icon"])])):p.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",HT,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xf),"aria-hidden":"true"},null,8,["icon"])])):p.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",XT,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:3,fill:"clear",size:"small",onClick:m[0]||(m[0]=h=>p.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:4,fill:"clear",size:"small",onClick:m[1]||(m[1]=h=>p.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:5,fill:"clear",size:"small",onClick:m[2]||(m[2]=h=>p.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":p.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",JT,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:p.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",KT,e.toDisplayString(Math.round(r.value))+"%",1)],8,GT)):e.createCommentVNode("",!0),p.upload.error?(e.openBlock(),e.createElementBlock("div",YT,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(sh)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(p.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",qT,[e.createElementVNode("img",{src:l.value,alt:p.upload.filename},null,8,QT),c.value?(e.openBlock(),e.createElementBlock("div",eM,e.toDisplayString(f(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,FT))}}),nM=Ve(tM,[["__scopeId","data-v-9eacbf91"]]),cs=4,aM=500,oM=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Nr(a){return typeof a=="object"&&a!==null}function vd(a){return Nr(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function iM(a){if(vd(a))return a;if(Nr(a)&&vd(a.data))return a.data;throw new Error("Invalid upload response from backend")}function gd(a){return Nr(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function rM(a){if(gd(a))return a;if(Nr(a)&&gd(a.data))return a.data;throw new Error("Invalid media response from backend")}function Ei(a){return a?{...a}:{}}function yd(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function sM(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function lM(a){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(a)))}catch{return btoa(a)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function cM(a,n){return[["filename",a.filename],["filetype",a.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([o,i])=>`${o} ${lM(i)}`).join(",")}function xi(a,n){const t=Math.max(a.bytesTotal,1);a.bytesUploaded=n,a.progress=Math.min(100,n/t*100);const o=Math.max((Date.now()-a.startedAt.getTime())/1e3,.001);a.uploadSpeed=n/o;const i=Math.max(t-n,0);a.timeRemaining=i/Math.max(a.uploadSpeed,1)}function dM(a,n){return a instanceof Error?a:new Error(n)}function uM(a){if(!(a instanceof Error))return!1;const n=a.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function bd(a){const n=Math.max(0,a-1),t=aM*Math.pow(2,n);return Math.min(5e3,t)}function wd(a){return new Promise(n=>{window.setTimeout(n,a)})}async function kd(a,n){for(let t=1;t<=cs;t+=1)try{const o=await n();if(o.ok||!oM.has(o.status)||t>=cs)return o;await wd(bd(t))}catch(o){if(!uM(o)||t>=cs)throw o;await wd(bd(t))}throw new Error(`${a} failed after retry attempts`)}function mM(a={}){const n=e.ref(new Map),t=e.ref(new Set),o=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>{const _=Array.from(n.value.values());return _.length===0?0:_.reduce((T,z)=>T+z.progress,0)/_.length});function d(_){o.value=_}function u(){}async function f(_){var T;const R=_.filter(z=>p(z));if(R.length!==0&&((T=a.onFilesSelected)==null||T.call(a,R),a.autoUpload!==!1))for(const z of R)await m(z)}function p(_){return!(a.maxFileSize&&_.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(_.type))}async function m(_){var z,P,M;const R=j(_);if(n.value.has(R)){const L=n.value.get(R);if((L==null?void 0:L.status)==="uploading")return}const T={id:R,file:_,filename:_.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:_.size,bytesUploaded:0};n.value.set(T.id,T),t.value.add(T.id);try{T.status="uploading",(z=a.onUploadStart)==null||z.call(a,T);const L=await h(_);a.resumable===!0||L.resumable===!0?await w(T,L):await g(T,L),T.status="processing",T.progress=100;const O=await S(L.media_uuid);T.status="completed",T.media=O,(P=a.onUploadComplete)==null||P.call(a,O)}catch(L){if(T.status!=="cancelled"){const k=dM(L,"Upload failed");T.status="error",T.error=k.message,(M=a.onUploadError)==null||M.call(a,k,T)}}finally{t.value.delete(T.id),i.delete(T.id),r.delete(T.id)}}async function h(_){if(!o.value)throw new Error("API client not configured");const R={collection:a.collection||"videos",filename:_.name,size:_.size,mime_type:_.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},T=await o.value.post("/api/v1/video/upload",R);return iM(T)}async function g(_,R){const T=new XMLHttpRequest,z=yd(R),P=Ei(R.headers);return new Promise((M,L)=>{T.upload.addEventListener("progress",k=>{var O;k.lengthComputable&&(xi(_,k.loaded),(O=a.onUploadProgress)==null||O.call(a,_))}),T.addEventListener("load",()=>{i.delete(_.id),T.status>=200&&T.status<300?M():L(new Error(`Upload failed with status ${T.status}`))}),T.addEventListener("error",()=>{i.delete(_.id),L(new Error("Upload failed"))}),T.addEventListener("abort",()=>{i.delete(_.id),L(new Error("Upload cancelled"))}),T.open(z,R.upload_url),Object.entries(P).forEach(([k,O])=>{T.setRequestHeader(k,O)}),!Object.keys(P).some(k=>k.toLowerCase()==="content-type")&&_.file.type&&T.setRequestHeader("Content-Type",_.file.type),i.set(_.id,T),T.send(_.file)})}async function w(_,R){var L;if(sM(R)){await F(_,R);return}const T=a.chunkSize||5*1024*1024,z=D(_.file,T),P=new AbortController;r.set(_.id,P);const M=await v(R.upload_id);M&&(z.forEach(k=>{k.end<=M.bytesUploaded&&(k.uploaded=!0)}),xi(_,M.bytesUploaded));for(const k of z)k.uploaded||(await E(_,R,k,P),xi(_,k.end),(L=a.onUploadProgress)==null||L.call(a,_))}async function F(_,R){var W;const T=new AbortController;r.set(_.id,T);const z={...Ei(R.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(_.file.size),"Upload-Metadata":cM(_,R)},P=await kd("Resumable upload initialization",()=>fetch(R.upload_url,{method:"POST",headers:z,signal:T.signal}));if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const M=P.headers.get("Location");if(!M)throw new Error("Resumable upload endpoint did not return upload location");const L=new URL(M,R.upload_url).toString(),k=a.chunkSize||5*1024*1024;let O=0;for(;O<_.file.size;){const G=Math.min(O+k,_.file.size),ie=_.file.slice(O,G),we={...Ei(R.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(O),"Content-Type":"application/offset+octet-stream"},_e=await kd("Resumable chunk upload",()=>fetch(L,{method:"PATCH",headers:we,body:ie,signal:T.signal}));if(_e.status===409){const $=Number(_e.headers.get("Upload-Offset")??"-1");if(Number.isFinite($)&&$>=0){O=$;continue}}if(!_e.ok)throw new Error(`Resumable chunk upload failed: ${_e.status}`);const oe=Number(_e.headers.get("Upload-Offset")??String(G));O=Number.isFinite(oe)&&oe>O?oe:G,xi(_,O),(W=a.onUploadProgress)==null||W.call(a,_)}}function D(_,R){const T=[];let z=0,P=0;for(;z<_.size;){const M=Math.min(z+R,_.size);T.push({start:z,end:M,blob:_.slice(z,M),index:P,uploaded:!1}),z=M,P++}return T}async function E(_,R,T,z){const P={...Ei(R.headers),"Content-Range":`bytes ${T.start}-${T.end-1}/${_.file.size}`,"Content-Type":_.file.type||"application/octet-stream"},M=await fetch(R.upload_url,{method:yd(R),headers:P,body:T.blob,signal:z.signal});if(!M.ok)throw new Error(`Chunk upload failed: ${M.status}`);T.uploaded=!0}async function v(_){return null}async function S(_){if(!o.value)throw new Error("API client not configured");const R=60;let T=0;for(;T<R;){const z=await o.value.get(`/api/v1/video/${_}`),P=rM(z),M=String(P.processing_status);if(M==="ready")return P;if(M==="failed"||M==="error")throw new Error("Video processing failed");await new Promise(L=>{window.setTimeout(L,5e3)}),T++}throw new Error("Video processing timeout")}function C(_){const R=n.value.get(_);if(!R)return;const T=i.get(_);T&&(T.abort(),i.delete(_));const z=r.get(_);z&&(z.abort(),r.delete(_)),R.status="cancelled",R.error="Upload cancelled",t.value.delete(_)}async function V(_){const R=n.value.get(_);R&&(R.status="pending",R.error="",R.progress=0,R.bytesUploaded=0,await m(R.file))}function x(_){n.value.delete(_),t.value.delete(_),i.delete(_),r.delete(_)}function N(){Array.from(n.value.entries()).forEach(([_,R])=>{R.status==="completed"&&n.value.delete(_)})}function j(_){return`${_.name}-${_.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:f,validateFile:p,startUpload:m,cancelUpload:C,retryUpload:V,removeUpload:x,clearCompleted:N,setApiClient:d}}const pM=["accept","multiple"],fM={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},hM=["onKeydown"],vM={key:1,class:"upload-list","data-testid":"video-upload-list"},gM={class:"drag-content"},yM=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:f,setApiClient:p}=mM({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:v=>o("upload-start",v),onUploadProgress:v=>o("upload-progress",v),onUploadComplete:v=>o("upload-complete",v),onUploadError:(v,S)=>o("upload-error",v,S),onFilesSelected:v=>o("files-selected",v)});t.apiClient&&p(t.apiClient);const m=e.computed(()=>t.allowedFormats.join(",")),h=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function w(v){const S=v.target,C=Array.from(S.files||[]);C.length>0&&(c(C),S.value="")}function F(v){var V;v.preventDefault(),r.value=!1;const C=Array.from(((V=v.dataTransfer)==null?void 0:V.files)||[]).filter(x=>x.type.startsWith("video/"));C.length>0&&c(C)}function D(v){var S;v.preventDefault(),(S=v.dataTransfer)!=null&&S.types.includes("Files")&&(r.value=!0)}function E(v){v.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",D),document.addEventListener("dragleave",E),document.addEventListener("drop",v=>v.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",D),document.removeEventListener("dragleave",E),document.removeEventListener("drop",v=>v.preventDefault())}),(v,S)=>(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:m.value,multiple:v.multiple,onChange:w,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,pM),!e.unref(l)||h.value?(e.openBlock(),e.createElementBlock("div",fM,[e.renderSlot(v.$slots,"trigger",{open:g},()=>[e.createElementVNode("div",{class:"default-upload-area","data-testid":"video-uploader-area",role:"button",tabindex:"0","aria-label":"Click to select video for upload",onClick:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(jd),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(v.label),1),e.createElementVNode("p",null,e.toDisplayString(v.description),1),e.createVNode(e.unref(U.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(al),slot:"start","aria-hidden":"true"},null,8,["icon"]),S[2]||(S[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,hM)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",vM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),C=>(e.openBlock(),e.createBlock(nM,{key:C.id,upload:C,onCancel:V=>e.unref(d)(C.id),onRetry:V=>e.unref(u)(C.id),onRemove:V=>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:F,onDragover:S[0]||(S[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:S[1]||(S[1]=C=>r.value=!1)},[e.createElementVNode("div",gM,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qa),"aria-hidden":"true"},null,8,["icon"]),S[3]||(S[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),bM=Ve(yM,[["__scopeId","data-v-ea7587f7"]]),wM=["aria-valuenow","aria-valuemax","aria-label"],kM={class:"progress-bar"},_M={class:"time-display","data-testid":"video-time-display"},EM={class:"current-time"},xM={class:"duration"},SM={class:"control-buttons"},CM={class:"controls-left"},VM=["aria-label"],NM={class:"controls-center"},TM={key:0,class:"volume-controls"},MM=["aria-label"],BM=["value"],IM={class:"controls-right"},FM={key:0,class:"quality-selector"},$M=["aria-expanded"],DM={class:"quality-label"},RM={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},AM=["data-testid","aria-label","onClick"],LM=["aria-label"],PM=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!0),r=e.ref(!1),s=e.ref(),l=U.isPlatform("mobile"),c="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),f=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let v=0;v<t.buffered.length;v++){const S=t.buffered.start(v),C=t.buffered.end(v);if(t.currentTime>=S&&t.currentTime<=C)return{width:`${C/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),p=e.computed(()=>t.muted||t.volume===0?ih:t.volume<33?nh:t.volume<66?ah:th);let m=null;function h(){i.value=!0,g()}function g(){m&&clearTimeout(m),t.playing&&!l&&(m=setTimeout(()=>{i.value=!1},3e3))}function w(v){if(!s.value||t.isLive)return;const S=s.value.getBoundingClientRect(),V=(v.clientX-S.left)/S.width*t.duration;o("seek",Math.max(0,Math.min(V,t.duration)))}function F(v){const S=v.target;o("setVolume",parseInt(S.value))}function D(v){o("selectQuality",v),r.value=!1}function E(v){if(!isFinite(v))return"0:00";const S=Math.floor(v/3600),C=Math.floor(v%3600/60),V=Math.floor(v%60);return S>0?`${S}:${C.toString().padStart(2,"0")}:${V.toString().padStart(2,"0")}`:`${C}:${V.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",h),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",h),m&&clearTimeout(m)}),(v,S)=>(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(v.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(v.duration),"aria-label":v.isLive?"Live stream":"Video progress",tabindex:"0",onClick:w},[e.createElementVNode("div",kM,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",_M,[e.createElementVNode("span",EM,e.toDisplayString(E(v.currentTime)),1),S[7]||(S[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",xM,e.toDisplayString(v.isLive?"LIVE":E(v.duration)),1)])],8,wM),e.createElementVNode("div",SM,[e.createElementVNode("div",CM,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:S[0]||(S[0]=C=>v.$emit("play-pause")),"aria-label":v.playing?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:v.playing?e.unref(Uf):e.unref(jf),"aria-hidden":"true"},null,8,["icon"])],8,VM),v.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:S[1]||(S[1]=C=>v.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Wf),"aria-hidden":"true"},null,8,["icon"]),S[8]||(S[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),v.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:S[2]||(S[2]=C=>v.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xf),"aria-hidden":"true"},null,8,["icon"]),S[9]||(S[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",NM,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",TM,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:S[3]||(S[3]=C=>v.$emit("toggleMute")),"aria-label":v.muted?"Unmute":"Mute"},[e.createVNode(e.unref(U.IonIcon),{icon:p.value,"aria-hidden":"true"},null,8,["icon"])],8,MM),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:v.muted?0:v.volume,onInput:F,"aria-label":"Volume"},null,40,BM)]))]),e.createElementVNode("div",IM,[v.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",FM,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:S[4]||(S[4]=C=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Qf),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",DM,e.toDisplayString(v.currentQuality),1)],8,$M),r.value?(e.openBlock(),e.createElementBlock("div",RM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.qualityLevels,C=>(e.openBlock(),e.createElementBlock("button",{key:C.label,class:e.normalizeClass(["quality-option",{active:C.label===v.currentQuality}]),"data-testid":`btn-video-quality-${C.label}`,"aria-label":`Set quality to ${C.label}`,role:"menuitem",onClick:V=>D(C)},e.toDisplayString(C.label),11,AM))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&c?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:S[5]||(S[5]=C=>v.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(eh),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:S[6]||(S[6]=C=>v.$emit("toggleFullscreen")),"aria-label":v.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(U.IonIcon),{icon:v.fullscreen?e.unref(Bf):e.unref($f),"aria-hidden":"true"},null,8,["icon"])],8,LM)])])],2))}}),OM=Ve(PM,[["__scopeId","data-v-2ae77c13"]]);function UM(a={}){var ie,we,_e;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(a.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),f=e.ref(!1),p=e.ref(null),m=e.ref("idle"),h=e.ref(a.playbackUrl||((ie=a.media)==null?void 0:ie.playback_url)||((we=a.media)==null?void 0:we.url)||""),g=e.ref(null),w=e.ref(a.isLive||!1),F=e.ref(null),D=e.ref(null);function E(oe){D.value=oe}if((_e=a.media)!=null&&_e.token_expires_at){const oe=new Date(a.media.token_expires_at);g.value=Number.isNaN(oe.getTime())?null:oe}async function v(){var $;const oe=w.value?t.value:n.value;if(oe)try{await oe.play(),o.value=!0,m.value=w.value?"live":"playing",($=a.onPlay)==null||$.call(a)}catch{p.value="Failed to play video",m.value="error"}}function S(){var $;const oe=w.value?t.value:n.value;oe&&(oe.pause(),o.value=!1,m.value="paused",($=a.onPause)==null||$.call(a))}function C(){o.value?S():v()}function V(oe){const $=w.value?t.value:n.value;if(!$||w.value)return;const B=Number.isFinite($.duration)?$.duration:oe;$.currentTime=Math.max(0,Math.min(oe,B)),i.value=$.currentTime}function x(oe=10){const $=n.value;!$||w.value||V($.currentTime+oe)}function N(oe=10){const $=n.value;!$||w.value||V($.currentTime-oe)}function j(){const oe=w.value?t.value:n.value;oe&&(oe.muted=!oe.muted,l.value=oe.muted)}function _(oe){const $=w.value?t.value:n.value;if(!$)return;const B=Math.max(0,Math.min(100,oe));$.volume=B/100,s.value=B,B>0&&$.muted&&($.muted=!1,l.value=!1)}function R(oe){const $=n.value;!$||w.value||($.playbackRate=oe,u.value=oe)}async function T(){const oe=document.querySelector(".video-player-container");if(oe)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await oe.requestFullscreen(),c.value=!0)}catch{}}async function z(){const oe=w.value?t.value:n.value;if(oe)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await oe.requestPictureInPicture()}catch{}}async function P(){var $;p.value=null,m.value="loading",($=a.media)!=null&&$.provider&&a.media.provider!=="local"&&await M();const oe=w.value?t.value:n.value;oe&&(oe.load(),await v())}async function M(){if(!(!D.value||!a.media))try{f.value=!0;const oe=await D.value.get(`/api/v1/video/${a.media.uuid}/playback`);h.value=oe.playback_url,g.value=new Date(oe.token_expires_at);const $=w.value?t.value:n.value;if($&&$.src!==h.value){const B=!$.paused,Z=$.currentTime;$.src=h.value,w.value||($.currentTime=Z),B&&await v()}}catch{p.value="Failed to refresh playback token",m.value="error"}finally{f.value=!1}}async function L(oe){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=oe;return}try{t.value.src=oe}catch{p.value="Live streaming not supported in this browser",m.value="error"}}}function k(){F.value&&(F.value.destroy(),F.value=null)}function O(){var $;const oe=w.value?t.value:n.value;oe&&(i.value=oe.currentTime,r.value=oe.duration,($=a.onTimeUpdate)==null||$.call(a,oe.currentTime))}const W=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let oe=0;oe<d.value.length;oe++){const $=d.value.start(oe),B=d.value.end(oe);if(i.value>=$&&i.value<=B)return B/r.value*100}return 0});function G(){if(!g.value)return!1;const oe=new Date;return g.value.getTime()-oe.getTime()<5*60*1e3}return e.watch([n,t],([oe,$])=>{const B=w.value?$:oe;B&&(B.addEventListener("timeupdate",O),B.addEventListener("loadedmetadata",()=>{r.value=B.duration,m.value="ready"}),B.addEventListener("progress",()=>{d.value=B.buffered}),B.addEventListener("ended",()=>{var Z;o.value=!1,m.value="ended",(Z=a.onEnded)==null||Z.call(a)}),B.addEventListener("error",Z=>{var ee;m.value="error",(ee=a.onError)==null||ee.call(a,"Video playback error")}),B.volume=s.value/100,B.muted=l.value)}),e.onUnmounted(()=>{k();const oe=w.value?t.value:n.value;oe&&oe.removeEventListener("timeupdate",O)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:W,playbackRate:u,isLoading:f,error:p,status:m,currentPlaybackUrl:h,tokenExpiresAt:g,play:v,pause:S,togglePlayPause:C,seek:V,skipForward:x,skipBackward:N,toggleMute:j,setVolume:_,setPlaybackRate:R,toggleFullscreen:T,togglePiP:z,retry:P,refreshToken:M,setupLiveStream:L,setApiClient:E,shouldRefreshToken:G}}const zM=["src","poster","controls","autoplay","muted","loop","preload"],jM={key:1,ref:"livePlayerEl",class:"live-player"},WM=["controls","muted"],ZM={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},HM={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},XM={key:3,class:"video-error","data-testid":"video-error",role:"alert"},GM={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},JM=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(a,{emit:n}){const t=a,o=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:f,bufferedRanges:p,isLoading:m,error:h,status:g,currentPlaybackUrl:w,tokenExpiresAt:F,play:D,pause:E,seek:v,toggleMute:S,setVolume:C,toggleFullscreen:V,togglePlayPause:x,skipForward:N,skipBackward:j,retry:_,refreshToken:R,setApiClient:T,shouldRefreshToken:z,setupLiveStream:P}=UM({...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 M(){await R()}const L=e.computed(()=>{const ee=["video-player-container"];return t.className&&ee.push(t.className),f.value&&ee.push("fullscreen"),t.isLive&&ee.push("is-live"),s.value&&ee.push("is-playing"),m.value&&ee.push("is-loading"),ee}),k=e.computed(()=>{var ee,ne;if(t.poster)return t.poster;if((ee=t.media)!=null&&ee.poster_url)return t.media.poster_url;if((ne=t.media)!=null&&ne.thumbnail_url)return t.media.thumbnail_url});function O(ee){const ne=ee.target;o("loadedmetadata",{duration:ne.duration,width:ne.videoWidth,height:ne.videoHeight})}function W(ee){const ne=ee.target;l.value=ne.currentTime,o("timeupdate",ne.currentTime)}function G(){s.value=!0,o("play")}function ie(){s.value=!1,o("pause")}function we(){s.value=!1,o("ended")}function _e(ee){const ne=ee.target;let de="Failed to load video";if(ne.error)switch(ne.error.code){case ne.error.MEDIA_ERR_ABORTED:de="Video playback aborted";break;case ne.error.MEDIA_ERR_NETWORK:de="Network error while loading video";break;case ne.error.MEDIA_ERR_DECODE:de="Video decoding error";break;case ne.error.MEDIA_ERR_SRC_NOT_SUPPORTED:de="Video format not supported";break}h.value=de,o("error",de)}function oe(ee){const ne=ee.target;p.value=ne.buffered,o("progress",ne.buffered)}function $(){m.value=!0}function B(){m.value=!1}e.watch(()=>t.apiClient,ee=>{ee&&T(ee)},{immediate:!0}),e.watch(()=>t.playbackUrl,ee=>{typeof ee=="string"&&ee.length>0&&(w.value=ee)},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.token_expires_at},ee=>{if(!ee){F.value=null;return}const ne=new Date(ee);F.value=Number.isNaN(ne.getTime())?null:ne},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.playback_url},async(ee,ne)=>{if(t.playbackUrl||!ee||ee===ne)return;const de=i.value;if(!de||t.isLive){w.value=ee;return}const ue=!de.paused,ge=de.currentTime;w.value=ee,await e.nextTick();try{de.currentTime=ge}catch{}ue&&await D()},{immediate:!0});let Z=null;return e.watch(()=>t.isLive,async ee=>{var de;if(!ee)return;const ne=t.playbackUrl||((de=t.media)==null?void 0:de.playback_url)||"";ne&&await P(ne)},{immediate:!0}),e.onMounted(()=>{var ee;(ee=t.media)!=null&&ee.provider&&t.media.provider!=="local"&&(Z=setInterval(()=>{z()&&M()},3e4)),U.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{Z&&clearInterval(Z)}),(ee,ne)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",L.value]),"data-testid":"video-player"},[ee.isLive?(e.openBlock(),e.createElementBlock("div",jM,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ee.controls&&!ee.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:G,onPause:ie,onError:_e,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,WM),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",ZM,[...ne[3]||(ne[3]=[e.createElementVNode("span",{class:"live-dot"},null,-1),e.createElementVNode("span",{class:"live-text"},"LIVE",-1)])])):e.createCommentVNode("",!0)],512)):(e.openBlock(),e.createElementBlock("video",{key:0,ref_key:"videoEl",ref:i,src:e.unref(w),poster:k.value,controls:ee.controls&&!ee.showCustomControls,autoplay:ee.autoplay,muted:e.unref(u),loop:ee.loop,preload:ee.preload,onLoadedmetadata:O,onTimeupdate:W,onPlay:G,onPause:ie,onEnded:we,onError:_e,onProgress:oe,onWaiting:$,onCanplay:B,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,zM)),e.unref(m)?(e.openBlock(),e.createElementBlock("div",HM,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",XM,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ol),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(h)),1),e.createVNode(e.unref(U.IonButton),{size:"small",onClick:e.unref(_),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ba),slot:"start","aria-hidden":"true"},null,8,["icon"]),ne[4]||(ne[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ee.showCustomControls&&!e.unref(h)?(e.openBlock(),e.createBlock(OM,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(p),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(f),isLive:ee.isLive,onPlay:e.unref(D),onPause:e.unref(E),onSeek:e.unref(v),onToggleMute:e.unref(S),onSetVolume:e.unref(C),onToggleFullscreen:e.unref(V),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ee.enableGestures&&!e.unref(h)?(e.openBlock(),e.createElementBlock("div",GM,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ne[0]||(ne[0]=(...de)=>e.unref(j)&&e.unref(j)(...de))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ne[1]||(ne[1]=(...de)=>e.unref(x)&&e.unref(x)(...de))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ne[2]||(ne[2]=(...de)=>e.unref(N)&&e.unref(N)(...de))},null,32)])):e.createCommentVNode("",!0)],2))}}),Dm=Ve(JM,[["__scopeId","data-v-b8db4951"]]),KM=nr.defineStore("video",()=>{const a=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(a.value.values())),s=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>s.value.filter(P=>P.status==="live")),c=e.computed(()=>r.value.filter(P=>P.processing_status==="processing"));function d(P){a.value.set(P.uuid,P)}function u(P,M){const L=a.value.get(P);L&&a.value.set(P,{...L,...M})}function f(P){a.value.delete(P)}function p(P){return a.value.get(P)}function m(P){n.value.set(P.id,P)}function h(P,M){const L=n.value.get(P);L&&n.value.set(P,{...L,...M})}function g(P,M){const L=n.value.get(P);L&&n.value.set(P,{...L,status:M.status,viewer_count:M.viewer_count,peak_viewers:M.peak_viewers})}function w(P){n.value.delete(P)}function F(P){return n.value.get(P)}function D(P){return s.value.find(M=>M.media_uuid===P)}function E(P){t.value.set(P.id,P)}function v(P,M){const L=t.value.get(P);L&&t.value.set(P,{...L,...M})}function S(P){t.value.delete(P)}function C(P){return t.value.get(P)}function V(P){return Array.from(t.value.values()).filter(M=>M.media_uuid===P)}function x(P){o.value=P}function N(P){o.value&&(o.value={...o.value,...P})}function j(){o.value=null}function _(P){i.value=P}function R(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function T(P){a.value.clear(),P.forEach(M=>{a.value.set(M.uuid,M)})}function z(P){n.value.clear(),P.forEach(M=>{n.value.set(M.id,M)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:f,getVideo:p,setLiveStream:m,updateLiveStream:h,updateLiveStreamStats:g,removeLiveStream:w,getLiveStream:F,getLiveStreamByMedia:D,addExportJob:E,updateExportJob:v,removeExportJob:S,getExportJob:C,getExportJobsByMedia:V,setEditorState:x,updateEditorState:N,clearEditorState:j,setProcessing:_,clearAll:R,loadVideos:T,loadLiveStreams:z}});let wa=null;function YM(a){wa=a}const Si={post:async(a,n)=>{if(!wa)throw new Error("HTTP client not configured");return await wa(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!wa)throw new Error("HTTP client not configured");return await wa(`/api/v1/video${a}`)},delete:async a=>{if(!wa)throw new Error("HTTP client not configured");return await wa(`/api/v1/video${a}`,{method:"DELETE"})}};function Ci(a,n=null){const t=typeof a.id=="string"&&a.id!==""?a.id:typeof a.stream_id=="string"&&a.stream_id!==""?a.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:a.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:a.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:a.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:a.status??(n==null?void 0:n.status)??"idle",viewer_count:a.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:a.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:a.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:a.low_latency??(n==null?void 0:n.low_latency)??!1},i=a.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(o.playback_url=i);const r=a.started_at??(n==null?void 0:n.started_at);r!==void 0&&(o.started_at=r);const s=a.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(o.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(o.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(o.vod_media_uuid=n.vod_media_uuid),o}function ds(a,n){return a instanceof Error&&a.message?a.message:n}function qM(a){const n=KM(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),f=e.ref(0);let p;const m=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),h=e.computed(()=>{var j;if(!((j=t.value)!=null&&j.playback_url))return null;const N=new URL(t.value.playback_url);return N.searchParams.set("live","true"),o.value&&N.searchParams.set("latency","low"),N.toString()}),g=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="live"}),w=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="idle"}),F=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="ended"});async function D(N={}){s.value=!0,c.value=null;try{const j=await Si.post("/live",{title:r.value||N.title||"Live Stream",low_latency:N.low_latency??o.value,auto_record:N.auto_record??i.value,...N}),_=Ci(j);return t.value=_,n.setLiveStream(_),C(),_}catch(j){throw c.value=ds(j,"Failed to create stream"),j instanceof Error?j:new Error(c.value)}finally{s.value=!1}}async function E(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const N=await Si.post(`/live/${t.value.id}/end`),j=Ci(N,t.value);return t.value=j,n.setLiveStream(j),V(),j}catch(N){throw c.value=ds(N,"Failed to end stream"),N instanceof Error?N:new Error(c.value)}finally{l.value=!1}}async function v(){if(t.value)try{const N=await Si.get(`/live/${t.value.id}`),j=Ci(N,t.value);u.value=j.viewer_count,f.value=j.peak_viewers,t.value=j;const _={status:j.status,viewer_count:j.viewer_count,peak_viewers:j.peak_viewers};j.started_at&&(_.started_at=j.started_at),j.ended_at&&(_.ended_at=j.ended_at),n.updateLiveStreamStats(j.id,_),j.status==="live"&&!d.value&&j.started_at&&(d.value=new Date(j.started_at)),j.status==="ended"&&V()}catch{}}async function S(N){try{const j=await Si.get(`/live/${N}`),_=Ci(j,t.value);return{rtmp_url:_.rtmp_url,stream_key:_.stream_key,playback_url:_.playback_url||""}}catch(j){throw c.value=ds(j,"Failed to get stream credentials"),j instanceof Error?j:new Error(c.value)}}function C(N=5e3){V(),p=window.setInterval(()=>{v()},N)}function V(){p!==void 0&&(clearInterval(p),p=void 0)}async function x(){if(!a)return;const N=n.getLiveStreamByMedia(a);N&&(t.value=N,u.value=N.viewer_count,f.value=N.peak_viewers,N.status==="live"&&(C(),N.started_at&&(d.value=new Date(N.started_at))))}return a&&x(),e.onUnmounted(()=>{V()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:m,viewerCount:u,peakViewers:f,playbackUrl:h,isLive:g,isIdle:w,hasEnded:F,createStream:D,endStream:E,refreshStreamStatus:v,getStreamCredentials:S,startStatusPolling:C,stopStatusPolling:V}}const QM={class:"stream-status"},e5={class:"flex items-center justify-between"},t5={class:"flex items-center gap-3"},n5={key:0,class:"flex items-center"},a5={key:2,class:"text-sm text-gray-600"},o5={key:0,class:"flex items-center gap-2"},i5={class:"text-sm font-medium text-gray-700"},r5={key:0,class:"text-xs text-gray-500"},s5=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(a){const n=a,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),o=e.computed(()=>{const r="px-3 py-1 rounded-full text-xs font-semibold uppercase",s={idle:"bg-gray-100 text-gray-700",live:"bg-red-100 text-red-700",ended:"bg-blue-100 text-blue-700",error:"bg-yellow-100 text-yellow-700"};return`${r} ${s[n.status]||s.idle}`}),i=e.computed(()=>{if(!n.duration)return null;const r=Math.floor(n.duration/3600),s=Math.floor(n.duration%3600/60),l=n.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",QM,[e.createElementVNode("div",e5,[e.createElementVNode("div",t5,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",n5,[...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",a5,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",o5,[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",i5,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",r5," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),l5=Ve(s5,[["__scopeId","data-v-1d09c19f"]]),c5={class:"stream-credentials"},d5={class:"space-y-3"},u5={class:"credential-field"},m5={class:"flex gap-2"},p5=["value"],f5={class:"credential-field"},h5={class:"flex gap-2"},v5=["value","type"],g5=["aria-label"],y5={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},b5={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},w5={key:0,class:"mt-2 text-sm text-green-600"},k5=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.value)return t.streamKey;if(t.streamKey.length>8){const d=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${d}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){i.value=!i.value}async function c(d,u){try{await navigator.clipboard.writeText(d),r.value=u,o("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",c5,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",d5,[e.createElementVNode("div",u5,[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",m5,[e.createElementVNode("input",{value:d.rtmpUrl,readonly:"",type:"text",class:"flex-1 px-3 py-2 bg-gray-50 border border-gray-200 rounded-md text-sm font-mono text-gray-700","aria-label":"RTMP server URL"},null,8,p5),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>c(d.rtmpUrl,"RTMP URL")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy RTMP URL"},[...u[2]||(u[2]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])]),e.createElementVNode("div",f5,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",h5,[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,v5),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",b5,[...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",y5,[...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,g5),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>c(d.streamKey,"Stream Key")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy stream key"},[...u[6]||(u[6]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])])]),u[9]||(u[9]=e.createElementVNode("details",{class:"mt-4"},[e.createElementVNode("summary",{class:"cursor-pointer text-sm text-blue-600 hover:text-blue-700"}," How to connect with OBS Studio "),e.createElementVNode("div",{class:"mt-2 p-3 bg-blue-50 rounded-md text-sm text-gray-700"},[e.createElementVNode("ol",{class:"list-decimal list-inside space-y-1"},[e.createElementVNode("li",null,"Open OBS Studio"),e.createElementVNode("li",null,"Go to Settings → Stream"),e.createElementVNode("li",null,'Set Service to "Custom"'),e.createElementVNode("li",null,'Paste the RTMP URL in "Server"'),e.createElementVNode("li",null,'Paste the Stream Key in "Stream Key"'),e.createElementVNode("li",null,'Click OK and then "Start Streaming"')])])],-1)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createElementBlock("div",w5,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),_5=Ve(k5,[["__scopeId","data-v-306d92f6"]]),E5={class:"live-stream-manager","data-testid":"live-stream-manager"},x5={key:0,class:"stream-setup"},S5={class:"space-y-4"},C5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},V5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},N5=["disabled"],T5={key:0},M5={key:1,class:"flex items-center justify-center"},B5={key:1,class:"stream-active space-y-6"},I5={key:1,class:"video-preview"},F5={key:2,class:"analytics-panel"},$5={class:"grid grid-cols-2 gap-4"},D5={class:"bg-gray-50 p-3 rounded"},R5={class:"text-2xl font-bold text-gray-900"},A5={class:"bg-gray-50 p-3 rounded"},L5={class:"text-2xl font-bold text-gray-900"},P5={class:"stream-controls flex gap-3"},O5=["disabled"],U5={key:0},z5={key:1},j5={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},W5={class:"text-red-600 text-sm"},Z5=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(a,{emit:n}){const t=a,o=n;t.httpClient&&YM(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:f,endStream:p,streamDuration:m,playbackUrl:h,refreshStreamStatus:g}=qM(t.mediaUuid),w=e.ref(!1);async function F(){var C;try{const V=await f({title:l.value,low_latency:r.value,auto_record:s.value});o("stream-created",V),(C=t.onStreamCreated)==null||C.call(t,V)}catch(V){o("error",V)}}async function D(){var C;try{const V=await p();o("stream-ended",V),(C=t.onStreamEnded)==null||C.call(t,V)}catch(V){o("error",V)}}function E(){i.value=null,l.value="",w.value=!1,u.value=null}async function v(C,V){try{await navigator.clipboard.writeText(C)}catch{}}let S;return e.onMounted(()=>{var C;((C=i.value)==null?void 0:C.status)==="live"&&(S=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{S&&clearInterval(S)}),(C,V)=>(e.openBlock(),e.createElementBlock("div",E5,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",B5,[e.createVNode(l5,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(m),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(_5,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:v},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",I5,[V[9]||(V[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Dm,{"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",F5,[V[12]||(V[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",$5,[e.createElementVNode("div",D5,[e.createElementVNode("div",R5,e.toDisplayString(e.unref(i).viewer_count),1),V[10]||(V[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",A5,[e.createElementVNode("div",L5,e.toDisplayString(e.unref(i).peak_viewers),1),V[11]||(V[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",P5,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:V[3]||(V[3]=x=>w.value=!w.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(w.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:D,disabled:e.unref(d),class:"flex-1 py-2 px-4 bg-red-600 text-white font-medium rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors","aria-label":"End live stream"},[e.unref(d)?(e.openBlock(),e.createElementBlock("span",z5,"Ending...")):(e.openBlock(),e.createElementBlock("span",U5,"End Stream"))],8,O5)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:E,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",x5,[V[8]||(V[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",S5,[e.createElementVNode("div",C5,[V[4]||(V[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":V[0]||(V[0]=x=>e.isRef(r)?r.value=x: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",V5,[V[5]||(V[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":V[1]||(V[1]=x=>e.isRef(s)?s.value=x: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,[V[6]||(V[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":V[2]||(V[2]=x=>e.isRef(l)?l.value=x: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:F,disabled:e.unref(c),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",M5,[...V[7]||(V[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",T5,"Create Stream"))],8,N5)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",j5,[e.createElementVNode("p",W5,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),H5=Ve(Z5,[["__scopeId","data-v-26291f6f"]]),X5={class:"album-tree-node"},G5=["data-album-id","draggable","aria-selected","aria-expanded"],J5={key:1,class:"album-node__chevron-placeholder"},K5={key:2,"data-testid":"media-count",class:"album-node__count"},Y5={key:0,class:"album-tree-node__children",role:"group"},q5=16,Q5=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.expandedIds.has(t.album.id)),r=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),l=e.computed(()=>t.album.children_count>0),c=e.computed(()=>`${t.depth*q5}px`),d=e.computed(()=>{var E;return((E=t.dragState)==null?void 0:E.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var E;return((E=t.dragState)==null?void 0:E.dropTargetId)===t.album.id}),f=e.computed(()=>{var E;return(E=t.dragState)!=null&&E.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),p=e.computed(()=>{const E=["album-node"];return r.value&&E.push("album-node--selected"),s.value&&E.push("album-node--focused"),t.compact&&E.push("album-node--compact"),d.value&&E.push("album-node--dragging"),u.value&&E.push("album-node--drop-target"),f.value&&E.push("album-node--invalid-drop"),E});function m(){o("select",t.album)}function h(E){E.stopPropagation(),o("toggle-expand",t.album.id)}function g(E){t.draggable&&(E.dataTransfer&&(E.dataTransfer.setData("text/plain",t.album.id),E.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function w(E){t.draggable&&(E.preventDefault(),E.dataTransfer&&(E.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function F(){o("drag-leave",t.album.id)}function D(E){t.draggable&&(E.preventDefault(),o("drop",t.album.id))}return(E,v)=>{var C;const S=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",X5,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":E.album.id,class:e.normalizeClass(p.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:E.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:g,onDragover:w,onDragleave:F,onDrop:D},[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(U.IonIcon),{icon:i.value?e.unref(Nf):e.unref(Tf)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",J5)),e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Af),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:m},e.toDisplayString(E.album.name),1),E.showMediaCount?(e.openBlock(),e.createElementBlock("span",K5,e.toDisplayString(E.album.media_count),1)):e.createCommentVNode("",!0)],46,G5),i.value&&((C=E.album.children)!=null&&C.length)?(e.openBlock(),e.createElementBlock("div",Y5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.album.children,V=>(e.openBlock(),e.createBlock(S,{key:V.id,album:V,depth:E.depth+1,"selected-id":E.selectedId,"expanded-ids":E.expandedIds,"focused-id":E.focusedId,draggable:E.draggable,"show-media-count":E.showMediaCount,compact:E.compact,onSelect:v[0]||(v[0]=x=>o("select",x)),onToggleExpand:v[1]||(v[1]=x=>o("toggle-expand",x))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),eB=Ve(Q5,[["__scopeId","data-v-76be65a6"]]),Tr=nr.defineStore("albums",()=>{const a=e.ref([]),n=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const v=new Map;return a.value.forEach(S=>v.set(S.id,S)),v}),s=e.computed(()=>a.value.filter(v=>v.parent_id===null));async function l(v){t.value=!0,o.value=null;try{const S=(v==null?void 0:v.parent_id)??null,C=S?`/api/v1/albums?parent_id=${S}`:"/api/v1/albums?parent_id=null",V=await fetch(C);if(!V.ok)throw new Error("Failed to fetch albums");((await V.json()).data||[]).forEach(j=>{const _=a.value.findIndex(R=>R.id===j.id);_>=0?a.value[_]=j:a.value.push(j)}),S!==null&&i.value.add(S)}catch(S){o.value=S instanceof Error?S.message:"Unknown error"}finally{t.value=!1}}async function c(v){t.value=!0,o.value=null;try{const S=await fetch(`/api/v1/albums/${v}`);if(!S.ok)throw new Error("Failed to fetch album");const V=(await S.json()).data,x=a.value.findIndex(N=>N.id===V.id);return x>=0?a.value[x]=V:a.value.push(V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function d(v){t.value=!0,o.value=null;try{const S=await fetch(`/api/v1/albums/${v}/media`);if(!S.ok)throw new Error("Failed to fetch album media");const V=(await S.json()).data||[];return n.value.set(v,V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function u(v,S){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${v}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:S})})).ok)throw new Error("Failed to reorder album media");const V=n.value.get(v)||[],x=S.map(N=>V.find(j=>j.uuid===N)).filter(N=>N!==void 0);n.value.set(v,x)}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function f(v){t.value=!0,o.value=null;try{const S=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(v)});if(!S.ok)throw new Error("Failed to create album");const V=(await S.json()).data;return a.value.push(V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function p(v,S){t.value=!0,o.value=null;try{const C=await fetch(`/api/v1/albums/${v}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(S)});if(!C.ok)throw new Error("Failed to update album");const x=(await C.json()).data,N=a.value.findIndex(j=>j.id===x.id);return N>=0&&(a.value[N]=x),x}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function m(v){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${v}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const C=a.value.findIndex(V=>V.id===v);C>=0&&a.value.splice(C,1),n.value.delete(v)}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}function h(v){return a.value.filter(S=>S.parent_id===v)}function g(v){return i.value.has(v)}function w(v){return n.value.get(v)||[]}async function F(v,S){const C=a.value.findIndex(x=>x.id===v);if(C<0)return;const V=a.value[C];a.value[C]={...V,parent_id:S};try{if(!(await fetch(`/api/v1/albums/${v}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:S})})).ok)throw new Error("Failed to move album")}catch(x){throw a.value[C]=V,o.value=x instanceof Error?x.message:"Unknown error",x instanceof Error?x:new Error("Failed to move album")}}function D(v){a.value=v}function E(){a.value=[],n.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:a,albumMedia:n,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:f,updateAlbum:p,deleteAlbum:m,getChildrenOf:h,childrenLoaded:g,getAlbumMedia:w,moveAlbum:F,setAlbums:D,reset:E}});function Rm(){const a=Tr(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=nr.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function l(u){return a.getChildrenOf(u)}function c(u){return a.childrenLoaded(u)}async function d(u,f){await a.moveAlbum(u,f)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function Am(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(f,p){if(f===p)return!0;const m=new Set,h=[f];for(;h.length>0;){const g=h.shift();if(!g||m.has(g))continue;m.add(g);const w=n.get(g)||[];for(const F of w){if(F===p)return!0;h.push(F)}}return!1}function r(f,p){return f===p?!1:p===null?!0:!i(f,p)}function s(f){o.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function l(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(f){o.value.dropTargetId=f}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:p}=o.value;if(!f){l();return}if(!r(f,p)){l();return}try{await t(f,p)}finally{l()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const tB={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},nB={key:1,"data-testid":"error-state",class:"album-tree__error"},aB={key:2,"data-testid":"empty-state",class:"album-tree__empty"},oB={key:3,class:"album-tree__content",role:"group"},iB=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),l=e.computed(()=>o.compact===!0),{albums:c,rootAlbums:d,loading:u,error:f,fetchAlbums:p,getChildrenOf:m,childrenLoaded:h,moveAlbum:g}=Rm(),w=e.shallowRef(new Set(o.expandedIds)),F=e.ref(o.modelValue??null),D=e.ref(null),E=new Map,v=new Map;function S($){E.clear(),v.clear();for(const B of $){E.set(B.id,B);const Z=B.parent_id??null,ee=v.get(Z)??[];ee.push(B.id),v.set(Z,ee)}}e.watch(c,$=>{S($)},{immediate:!0});const{dragState:C,canDropOn:V,startDrag:x,endDrag:N,setDropTarget:j,clearDropTarget:_,executeDrop:R}=Am({childrenByParentId:v,onMove:async($,B)=>{await g($,B),i("album-moved",{albumId:$,newParentId:B})}});e.watch(()=>o.modelValue,$=>{F.value=$??null}),e.watch(()=>o.expandedIds,$=>{w.value=new Set($)}),e.onMounted(async()=>{await p({parent_id:null})});const T=e.computed(()=>d.value.map($=>z($)));function z($){if(!w.value.has($.id))return $;const B=m($.id);return{...$,children:B.map(Z=>z(Z))}}const P=e.computed(()=>{const $=[];function B(Z){var ee;for(const ne of Z)$.push(ne),w.value.has(ne.id)&&((ee=ne.children)!=null&&ee.length)&&B(ne.children)}return B(T.value),$});function M($){var ee;if(!P.value.length)return;const B=D.value?P.value.findIndex(ne=>ne.id===D.value):-1,Z=B>=0?P.value[B]:null;switch($.key){case"ArrowDown":$.preventDefault(),B<P.value.length-1?D.value=P.value[B+1].id:B===-1&&P.value.length>0&&(D.value=P.value[0].id);break;case"ArrowUp":$.preventDefault(),B>0&&(D.value=P.value[B-1].id);break;case"ArrowRight":$.preventDefault(),Z&&(Z.children_count>0&&!w.value.has(Z.id)?L(Z.id):w.value.has(Z.id)&&((ee=Z.children)!=null&&ee.length)&&(D.value=Z.children[0].id));break;case"ArrowLeft":$.preventDefault(),Z&&(w.value.has(Z.id)&&Z.children_count>0?L(Z.id):Z.parent_id&&(D.value=Z.parent_id));break;case"Enter":case" ":$.preventDefault(),Z&&k(Z);break;case"Home":$.preventDefault(),P.value.length>0&&(D.value=P.value[0].id);break;case"End":$.preventDefault(),P.value.length>0&&(D.value=P.value[P.value.length-1].id);break}}async function L($){w.value.has($)?(w.value.delete($),i("album-collapsed",$)):(h($)||await p({parent_id:$}),w.value.add($),i("album-expanded",$))}function k($){F.value=$.id,i("update:modelValue",$.id),i("album-selected",$)}function O($){o.draggable&&x($)}function W($){var Z;if(!o.draggable)return;const B=(Z=C.value)==null?void 0:Z.draggedAlbumId;B&&(j($),V(B,$))}function G(){o.draggable&&_()}async function ie($){o.draggable&&(j($),await R())}function we($){o.draggable&&($.preventDefault(),j(null))}async function _e($){o.draggable&&($.preventDefault(),j(null),await R())}function oe(){N()}return n({focusedId:D}),($,B)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:M,onDragover:we,onDrop:_e,onDragend:oe},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",tB,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",nB,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",oB,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,Z=>(e.openBlock(),e.createBlock(eB,{key:Z.id,album:Z,depth:0,"selected-id":F.value,"expanded-ids":w.value,"focused-id":D.value,draggable:r.value,"drag-state":r.value?e.unref(C):null,"show-media-count":s.value,compact:l.value,onSelect:k,onToggleExpand:L,onDragStart:O,onDragOver:W,onDragLeave:G,onDrop:ie},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",aB,[B[0]||(B[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot($.$slots,"empty-action",{},void 0,!0)]))],32))}}),Lm=Ve(iB,[["__scopeId","data-v-ae3dea7a"]]),rB=300,sB=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,m=>{i.value=m??null});const c=e.computed(()=>r.value!==null);function d(m){const h=Date.now();if(l.value===m.id&&h-s.value<rB){o("confirm",m);return}s.value=h,l.value=m.id,i.value=m.id,r.value=m}function u(){r.value&&o("confirm",r.value)}function f(){o("close")}function p(){o("close")}return(m,h)=>(e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":m.isOpen,class:"album-browser-modal",onDidDismiss:p},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.title),1)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.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(U.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Lm,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...h[2]||(h[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Pm=Ve(sB,[["__scopeId","data-v-21676ec1"]]),lB={class:"ion-padding-start text-sm"},cB={class:"ion-padding-start text-sm"},dB={key:1},uB={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},mB={class:"flex items-center justify-between gap-3 pb-3"},pB={class:"text-base font-semibold text-gray-900"},fB={class:"ion-padding-start text-sm"},hB={class:"ion-padding-start text-sm"},vB={class:"flex justify-between pt-2"},gB={key:1},xo=255,So=1e3,yB=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(a,{emit:n}){const t=a,o=n,i=Tr(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),l=e.computed(()=>r.value?"Save":"Create"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),f=e.ref(!1),p=e.ref(null),m=e.ref(!1),h=e.ref(!1),g=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>xo?`Name must be ${xo} characters or less`:null:"Name is required":null),w=e.computed(()=>d.value.description&&c.value.description.length>So?`Description must be ${So} characters or less`:null),F=e.computed(()=>{const M=c.value.name.trim().length>0,L=c.value.name.length<=xo,k=c.value.description.length<=So;return M&&L&&k&&!m.value}),D=e.computed(()=>{var M;return((M=u.value)==null?void 0:M.name)??"None (Root)"}),E=e.computed(()=>p.value?p.value.children_count===0&&p.value.media_count===0:!1),v=e.computed(()=>p.value?p.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":p.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${p.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await S()});async function S(){if(t.albumId)try{const M=await i.fetchAlbum(t.albumId);p.value=M,c.value={name:M.name,description:M.description??"",parent_id:M.parent_id},M.parent_id&&(u.value={id:M.parent_id,name:"Parent Album"})}catch(M){o("error",M)}}function C(){d.value.name=!0}function V(){d.value.description=!0}function x(){f.value=!0}function N(M){u.value={id:M.id,name:M.name},c.value.parent_id=M.id,f.value=!1}function j(){f.value=!1}function _(){o("close")}function R(){o("close")}async function T(){if(d.value.name=!0,d.value.description=!0,!(!F.value||m.value)){m.value=!0;try{const M={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const L=await i.updateAlbum(t.albumId,M);o("updated",L)}else{const L=await i.createAlbum(M);o("created",L)}o("close")}catch(M){o("error",M)}finally{m.value=!1}}}function z(){E.value&&(h.value=!0)}async function P(M){var k;if((((k=M.detail)==null?void 0:k.role)??"")!=="confirm"){h.value=!1;return}if(t.albumId){m.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(O){o("error",O)}finally{m.value=!1,h.value=!1}}}return(M,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[M.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(U.IonModal),{key:0,"is-open":M.isOpen,class:"album-manager-modal",onDidDismiss:R},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:_},{default:e.withCtx(()=>[...L[4]||(L[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(T,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[5]||(L[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[0]||(L[0]=k=>c.value.name=k),"data-testid":"name-input",maxlength:xo,onIonBlur:C},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",lB,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[6]||(L[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[1]||(L[1]=k=>c.value.description=k),"data-testid":"description-input",maxlength:So,onIonBlur:V},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",cB,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[7]||(L[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(U.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!E.value,title:E.value?void 0:v.value,onClick:z},{default:e.withCtx(()=>[...L[8]||(L[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!F.value,onClick:T},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",dB,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",uB,[e.createElementVNode("div",mB,[e.createElementVNode("h2",pB,e.toDisplayString(s.value),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:_},{default:e.withCtx(()=>[...L[9]||(L[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(T,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[10]||(L[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[2]||(L[2]=k=>c.value.name=k),"data-testid":"name-input",maxlength:xo,onIonBlur:C},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",fB,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[11]||(L[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[3]||(L[3]=k=>c.value.description=k),"data-testid":"description-input",maxlength:So,onIonBlur:V},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",hB,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[12]||(L[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(U.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1})]),_:1}),e.createElementVNode("div",vB,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!E.value,title:E.value?void 0:v.value,onClick:z},{default:e.withCtx(()=>[...L[13]||(L[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(U.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!F.value,onClick:T},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",gB,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Pm,{"is-open":f.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:j,onConfirm:N},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(U.IonAlert),{"is-open":h.value,header:"Delete Album?",message:v.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),bB=Ve(yB,[["__scopeId","data-v-22083f3a"]]),wB={class:"album-media-grid"},kB={class:"aspect-square"},_B={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},EB={class:"text-gray-500"},xB=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],SB={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},CB={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},VB={class:"aspect-square relative"},NB=["src","alt"],TB={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},MB=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(a,{emit:n}){const t=a,o=n,i=Tr(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),c=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),f=e.computed(()=>!u.value&&r.value.length===0),p=e.computed(()=>{const R=t.columns;return["grid","gap-4",`grid-cols-${R.mobile??2}`,`sm:grid-cols-${R.sm??3}`,`md:grid-cols-${R.md??4}`,`lg:grid-cols-${R.lg??5}`,`xl:grid-cols-${R.xl??6}`]}),m=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 R=await i.fetchAlbumMedia(t.albumId);r.value=R}catch{r.value=[]}finally{s.value=!1}}function g(R){return t.selectedItems.includes(R)}function w(R){o("toggle-select",R);const T=g(R.uuid)?t.selectedItems.filter(z=>z!==R.uuid):[...t.selectedItems,R.uuid];o("selection-change",T)}function F(R){if(R.conversions&&typeof R.conversions=="object"){const T=R.conversions.thumb;if(typeof T=="string")return T}return R.original_url}function D(R){l.value=R}function E(){l.value=null}function v(R){o("preview",R)}function S(R){o("edit",R)}function C(R){o("detach",R.uuid)}function V(){o("add")}function x(R,T){t.reorderable&&(c.value=T,R.dataTransfer&&(R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",String(T))))}function N(R,T){!t.reorderable||c.value===null||(R.preventDefault(),d.value=T)}function j(R,T){if(!t.reorderable||c.value===null)return;R.preventDefault();const z=c.value;if(z!==T){const P=[...r.value],[M]=P.splice(z,1);P.splice(T,0,M),r.value=P;const L=P.map(k=>k.uuid);o("reorder",L),i.reorderAlbumMedia(t.albumId,L).catch(()=>{h()})}c.value=null,d.value=null}function _(){c.value=null,d.value=null}return(R,T)=>(e.openBlock(),e.createElementBlock("div",wB,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,z=>(e.openBlock(),e.createBlock(e.unref(U.IonCard),{key:z,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",kB,[e.createVNode(e.unref(U.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",_B,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",EB,e.toDisplayString(R.emptyText),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"add-media-btn",onClick:V},{default:e.withCtx(()=>[...T[0]||(T[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(z,P)=>(e.openBlock(),e.createElementBlock("div",{key:z.uuid,"data-media-id":z.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===P,"ring-2 ring-primary":d.value===P&&c.value!==P}]),draggable:R.reorderable,onDragstart:M=>x(M,P),onDragover:M=>N(M,P),onDrop:M=>j(M,P),onDragend:_,onMouseenter:M=>D(z.uuid),onMouseleave:E},[d.value===P&&c.value!==P&&R.reorderable?(e.openBlock(),e.createElementBlock("div",SB)):e.createCommentVNode("",!0),R.reorderable?(e.openBlock(),e.createElementBlock("div",CB,[e.createVNode(e.unref(U.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),R.selectionMode?(e.openBlock(),e.createBlock(e.unref(U.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(z.uuid),class:"absolute top-2 left-2 z-20",onIonChange:M=>w(z)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",VB,[e.createElementVNode("img",{src:F(z),alt:z.file_name,class:"w-full h-full object-cover"},null,8,NB),R.showActions&&l.value===z.uuid?(e.openBlock(),e.createElementBlock("div",TB,[e.createVNode(e.unref(U.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:M=>v(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(U.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:M=>S(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(U.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:M=>C(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,xB))),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:V},[e.createVNode(e.unref(U.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),T[1]||(T[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),BB=Ve(MB,[["__scopeId","data-v-d84b796a"]]),IB={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},FB={class:"media-album-inline-create__field"},$B={class:"media-album-inline-create__field"},DB=["value"],RB={key:1,class:"media-album-inline-create__autocomplete"},AB={class:"media-album-inline-create__autocomplete-input-wrap"},LB={key:0,class:"media-album-inline-create__autocomplete-list"},PB=["onMousedown"],OB={key:1,class:"media-album-inline-create__autocomplete-empty"},UB={class:"media-album-inline-create__actions"},zB=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(""),r=e.ref(""),s=e.ref(""),l=e.ref(!1),c=e.computed(()=>t.albums.length>5),d=e.computed(()=>{if(s.value.trim()==="")return t.albums;const w=s.value.toLowerCase();return t.albums.filter(F=>F.name.toLowerCase().includes(w))}),u=e.computed(()=>{if(r.value==="")return"";const w=t.albums.find(F=>F.id===r.value);return(w==null?void 0:w.name)??""}),f=w=>{r.value=w.id,s.value=w.name,l.value=!1},p=()=>{r.value="",s.value="",l.value=!1},m=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},h=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},g=()=>{i.value.trim()!==""&&(o("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(w,F)=>w.open?(e.openBlock(),e.createElementBlock("section",IB,[F[7]||(F[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",FB,[e.createElementVNode("span",null,e.toDisplayString(w.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":F[0]||(F[0]=D=>i.value=D),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",$B,[F[6]||(F[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),c.value?(e.openBlock(),e.createElementBlock("div",RB,[e.createElementVNode("div",AB,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":F[2]||(F[2]=D=>s.value=D),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:m,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(p,["prevent"])},[...F[5]||(F[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",LB,[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(p,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,D=>(e.openBlock(),e.createElementBlock("li",{key:D.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":D.id===r.value}]),onMousedown:e.withModifiers(E=>f(D),["prevent"])},e.toDisplayString(D.name),43,PB))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("li",OB," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":F[1]||(F[1]=D=>r.value=D),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[F[4]||(F[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.albums,D=>(e.openBlock(),e.createElementBlock("option",{key:D.id,value:D.id},e.toDisplayString(D.name),9,DB))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",UB,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:F[3]||(F[3]=D=>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:g}," Create ")])])):e.createCommentVNode("",!0)}}),Om=Ve(zB,[["__scopeId","data-v-a85162fe"]]),jB={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},WB=e.defineComponent({__name:"MediaAlbumUnavailableState",props:{title:{default:"Album unavailable"},body:{default:"You no longer have access to this album."},actionLabel:{default:"Go to library"}},emits:["goToLibrary"],setup(a,{emit:n}){const t=n;return(o,i)=>(e.openBlock(),e.createElementBlock("section",jB,[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)]))}}),Um=Ve(WB,[["__scopeId","data-v-04620e64"]]),ZB={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},HB={class:"media-preview-sheet__header"},XB=["src","alt"],GB=["src"],JB={class:"media-preview-sheet__actions"},KB=["disabled"],YB=["disabled"],qB=e.defineComponent({__name:"MediaPreviewSheet",props:{open:{type:Boolean,default:!1},media:{default:null},canGoPrevious:{type:Boolean,default:!1},canGoNext:{type:Boolean,default:!1},selected:{type:Boolean,default:!1}},emits:["close","previous","next","toggleSelect"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>{var l;return((l=t.media)==null?void 0:l.mime_type.startsWith("image/"))===!0}),r=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:""),s=()=>{t.media&&o("toggleSelect",t.media)};return(l,c)=>l.open&&l.media?(e.openBlock(),e.createElementBlock("section",ZB,[e.createElementVNode("header",HB,[e.createElementVNode("strong",null,e.toDisplayString(l.media.file_name),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__close","aria-label":"Close preview",onClick:c[0]||(c[0]=d=>o("close"))}," Close ")]),i.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:r.value,alt:l.media.file_name},null,8,XB)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,GB)),e.createElementVNode("div",JB,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>o("previous"))}," Previous ",8,KB),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select",onClick:s},e.toDisplayString(l.selected?"Deselect":"Select"),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoNext,onClick:c[2]||(c[2]=d=>o("next"))}," Next ",8,YB)])])):e.createCommentVNode("",!0)}}),zm=Ve(qB,[["__scopeId","data-v-9a05f74e"]]),QB={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},e8={class:"media-album-grid__items"},t8={class:"media-album-grid__card-name"},n8={class:"media-album-grid__card-name"},a8=["data-testid","onClick"],o8={class:"media-album-grid__card-name"},i8={key:0,class:"media-album-grid__card-meta"},r8={key:0,class:"media-album-grid__empty"},s8=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(a,{emit:n}){const t=n;return(o,i)=>o.open?(e.openBlock(),e.createElementBlock("section",QB,[e.createElementVNode("div",e8,[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",t8,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",n8,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",o8,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",i8,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,a8))),128))]),o.albums.length===0?(e.openBlock(),e.createElementBlock("p",r8," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),jm=Ve(s8,[["__scopeId","data-v-129f67b1"]]),l8={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},c8=["accept"],d8={key:0,class:"media-upload-sheet__queue"},u8={class:"media-upload-sheet__queue-info"},m8={class:"media-upload-sheet__queue-status"},p8={class:"media-upload-sheet__progress-bar"},f8=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"}},emits:["close","filesSelected"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=c=>{const d=c.target;!(d instanceof HTMLInputElement)||d.files===null||(t("filesSelected",Array.from(d.files)),d.value="")},r=c=>{c.preventDefault(),o.value=!0},s=()=>{o.value=!1},l=c=>{var d;c.preventDefault(),o.value=!1,(d=c.dataTransfer)!=null&&d.files&&c.dataTransfer.files.length>0&&t("filesSelected",Array.from(c.dataTransfer.files))};return(c,d)=>c.open?(e.openBlock(),e.createElementBlock("section",l8,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":o.value}]),onDragover:r,onDragleave:s,onDrop:l},[d[1]||(d[1]=e.createStaticVNode('<div class="media-upload-sheet__dropzone-icon" data-v-e238d615><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-e238d615><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" data-v-e238d615></path><polyline points="17 8 12 3 7 8" data-v-e238d615></polyline><line x1="12" y1="3" x2="12" y2="15" data-v-e238d615></line></svg></div><span class="media-upload-sheet__dropzone-text" data-v-e238d615> Drop files here or <strong data-v-e238d615>browse</strong></span>',2)),e.createElementVNode("input",{type:"file",accept:c.accept,multiple:"",class:"media-upload-sheet__file-input","data-testid":"input-media-upload-sheet",onChange:i},null,40,c8)],34),c.queue.length>0?(e.openBlock(),e.createElementBlock("ul",d8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.queue,u=>(e.openBlock(),e.createElementBlock("li",{key:u.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("div",u8,[e.createElementVNode("strong",null,e.toDisplayString(u.file.name),1),e.createElementVNode("span",m8,e.toDisplayString(u.status),1)]),e.createElementVNode("div",p8,[e.createElementVNode("div",{class:"media-upload-sheet__progress-fill",style:e.normalizeStyle({width:`${u.progress}%`})},null,4)])]))),128))])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close-btn","aria-label":"Close upload panel","data-testid":"btn-close-upload-sheet",onClick:d[0]||(d[0]=u=>t("close"))}," Done ")])):e.createCommentVNode("",!0)}}),Wm=Ve(f8,[["__scopeId","data-v-e238d615"]]),h8=["aria-label","aria-pressed","data-testid"],v8=["src","alt"],g8={key:1,class:"media-thumbnail-cell__video"},y8={class:"media-thumbnail-cell__video-name"},b8={key:2,class:"media-thumbnail-cell__selected-badge"},w8={key:3,class:"media-thumbnail-cell__status-badge"},k8=["aria-label"],_8=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.media.thumbnail_url??t.media.preview_url??t.media.original_url),r=e.computed(()=>t.media.mime_type.startsWith("image/")),s=e.computed(()=>{switch(t.status){case"missing":return"Unavailable";case"forbidden":return"Restricted";case"uploading":return"Uploading";case"failed":return"Failed";case"file_lost":return"Needs file";default:return null}}),l=e.computed(()=>{const u=t.media.file_name;return t.selected?`Deselect ${u}`:`Select ${u}`}),c=()=>{o("toggle",t.media)},d=()=>{o("preview",t.media)};return(u,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:c},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,v8)):(e.openBlock(),e.createElementBlock("div",g8,[f[0]||(f[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",y8,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",b8," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",w8,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,h8),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,k8)],2))}}),Zm=Ve(_8,[["__scopeId","data-v-edd4f0ad"]]),E8={class:"virtual-media-grid"},x8={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},S8={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},C8={key:2,class:"virtual-media-grid__items"},V8=["disabled"],N8=e.defineComponent({__name:"VirtualMediaGrid",props:{items:{},selectedItems:{},loading:{type:Boolean,default:!1},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},emptyMessage:{default:"No media found."},testIdPrefix:{default:"media-grid-item"}},emits:["toggle","preview","loadMore"],setup(a,{emit:n}){const t=a,o=n;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",E8,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",x8," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",S8,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",C8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(Zm,{key:l.uuid,media:l,selected:((c=i(l.uuid))==null?void 0:c.status)==="ready",status:(d=i(l.uuid))==null?void 0:d.status,"test-id":`${r.testIdPrefix}-${l.uuid}`,onToggle:s[0]||(s[0]=u=>o("toggle",u)),onPreview:s[1]||(s[1]=u=>o("preview",u))},null,8,["media","selected","status","test-id"])}),128))])),r.hasMore?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"virtual-media-grid__load-more",disabled:r.loadingMore,"data-testid":"btn-media-grid-load-more",onClick:s[2]||(s[2]=l=>o("loadMore"))},e.toDisplayString(r.loadingMore?"Loading…":"Load more"),9,V8)):e.createCommentVNode("",!0)]))}}),Hm=Ve(N8,[["__scopeId","data-v-820b9a4f"]]);function tr(a){if(a===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(a)/Math.log(n));return parseFloat((a/Math.pow(n,o)).toFixed(2))+" "+t[o]}function Xm(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function $l(a){return a.type.startsWith("image/")}async function Gm(a){return $l(a)?new Promise(n=>{const t=new Image,o=URL.createObjectURL(a);t.onload=()=>{URL.revokeObjectURL(o),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),n(null)},t.src=o}):null}async function Jm(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${tr(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${tr(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-1)):a.type===i)||t.push({field:"type",message:`File type "${a.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const o=Xm(a.name);n.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if($l(a)&&(n.maxDimensions||n.minDimensions)){const o=await Gm(a);o&&(n.maxDimensions&&(o.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(o.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const o=await n.customValidator(a);t.push(...o)}return{valid:t.length===0,errors:t}}function Dl(a={}){const n=e.ref(a.rules||{});function t(c){n.value=c}async function o(c){return Jm(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const f=await o(u);d.set(u,f)})),d}function r(c,d){return n.value.maxItems?d+c<=n.value.maxItems:!0}const s=e.computed(()=>{const c=[];return n.value.acceptedMimeTypes&&c.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&c.push(...n.value.acceptedExtensions),c.join(",")});function l(c){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:n,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function T8(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function M8(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function Rl(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d,postUpload:u}=a,f=e.ref(new Map),p=e.ref(new Set),m=o?{rules:o}:{},{validateFile:h}=Dl(m);async function g(){if(p.value.size>=t)return;const R=Array.from(f.value.entries()).find(([P,M])=>M.status==="pending"&&!p.value.has(P));if(!R){Array.from(f.value.values()).every(M=>M.status==="completed"||M.status==="error")&&f.value.size>0&&(d==null||d());return}const[T,z]=R;await w(T,z)}async function w(R,T){p.value.add(R),T.status="uploading",T.abortController=new AbortController,f.value.set(R,{...T}),r==null||r(T);try{const z={onProgress:M=>{T.progress=M,f.value.set(R,{...T}),s==null||s(T)},signal:T.abortController.signal};i&&(z.collection=i);const P=await n.upload(T.file,z);u&&(T.status="attaching",f.value.set(R,{...T}),s==null||s(T),await u(T,P.media,n)),T.status="completed",T.progress=100,T.media=P.media,f.value.set(R,{...T}),l==null||l(T,P.media)}catch(z){z.name==="AbortError"?f.value.delete(R):(T.status="error",T.error=z.message,f.value.set(R,{...T}),c==null||c(T,z))}finally{p.value.delete(R),delete T.abortController,g()}}async function F(R){var P;const T=Array.from(R),z=[];for(const M of T){const L=await h(M),k=T8(),O=M8(M),W={id:k,file:M,progress:0,status:L.valid?"pending":"error"};!L.valid&&((P=L.errors[0])!=null&&P.message)&&(W.error=L.errors[0].message),O&&(W.previewUrl=O),f.value.set(k,W);const G={media:null,clientId:k,name:M.name,order:0,upload:W,errors:L.errors};z.push(G)}for(let M=0;M<t;M++)g();return z}function D(R){const T=f.value.get(R);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),f.value.delete(R),p.value.delete(R),g())}async function E(R){const T=f.value.get(R);!T||T.status!=="error"||(T.status="pending",T.progress=0,delete T.error,f.value.set(R,{...T}),g())}function v(){for(const[R,T]of f.value.entries())(T.status==="completed"||T.status==="error")&&(T.previewUrl&&URL.revokeObjectURL(T.previewUrl),f.value.delete(R))}function S(){for(const R of f.value.values())R.abortController&&R.abortController.abort(),R.previewUrl&&URL.revokeObjectURL(R.previewUrl);f.value.clear(),p.value.clear()}function C(R){return f.value.get(R)}const V=e.computed(()=>p.value.size>0),x=e.computed(()=>p.value.size),N=e.computed(()=>Array.from(f.value.values()).filter(R=>R.status==="pending").length),j=e.computed(()=>f.value.size===0?!0:Array.from(f.value.values()).every(R=>R.status==="completed"||R.status==="error")),_=e.computed(()=>Array.from(f.value.values()));return{uploads:f,isUploading:V,activeCount:x,pendingCount:N,isComplete:j,addFiles:F,cancelUpload:D,retryUpload:E,clearCompleted:v,clearAll:S,getUpload:C,uploadsArray:_}}function Ma(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function Xo(a){return typeof a=="string"?a:null}function _d(a){return typeof a=="number"?a:null}function B8(a){return typeof a=="boolean"?a:null}function Km(a){return Ma(a)&&typeof a.uuid=="string"&&typeof a.file_name=="string"&&typeof a.mime_type=="string"&&(typeof a.original_url=="string"||a.original_url===null)&&typeof a.size=="number"&&typeof a.disk=="string"&&typeof a.created_at=="string"&&typeof a.updated_at=="string"}function I8(a){return!Ma(a)||typeof a.id!="string"||typeof a.status!="string"?null:a.status==="ready"?Km(a.media)?{id:a.id,status:"ready",media:a.media}:null:a.status==="missing"||a.status==="forbidden"?{id:a.id,status:a.status}:null}function F8(a){return Ma(a)?{next_cursor:Xo(a.next_cursor),previous_cursor:Xo(a.previous_cursor),has_more:B8(a.has_more)??!1,per_page:_d(a.per_page),count:_d(a.count)}:null}function Ed(a){const n=Ma(a)?a:{},t=Array.isArray(n.data)?n.data.filter(Km):[],o=Ma(n.meta)?n.meta:{},i=F8(o.pagination),r=(i==null?void 0:i.next_cursor)??Xo(o.next_cursor)??Xo(o.cursor),s=(i==null?void 0:i.has_more)??o.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(I8).filter(d=>d!==null):[],c={cursor:r,has_more:s};return i!==null&&(c.pagination=i),{data:t,meta:c,hydrated:l}}function xd(a,n,t,o,i){const r={view:a.scope==="album"?{scope:"album",album_id:a.albumId}:{scope:"library"},per_page:t,sort:n.sort??"newest"};return n.query&&n.query.trim()!==""&&(r.query=n.query.trim()),n.kinds&&n.kinds.length>0&&(r.kinds=n.kinds),o!==null&&(r.cursor=o),i&&i.length>0&&(r.hydrate_ids=i),r}function Sd(a){const n=new Set,t=[];for(const o of a)n.has(o.uuid)||(n.add(o.uuid),t.push(o));return t}function $8(a){var t;if(!(a instanceof Error))return null;const n=(t=a.response)==null?void 0:t.status;return typeof n=="number"?n:null}function D8(a){var n;return a instanceof Error?((n=a.response)==null?void 0:n.data)??null:null}function R8(a){if(!Ma(a))return[];const n=[];for(const t of Object.values(a)){if(typeof t=="string"&&t.trim()!==""){n.push(t.trim());continue}if(Array.isArray(t))for(const o of t){if(typeof o!="string")continue;const i=o.trim();i!==""&&n.push(i)}}return Array.from(new Set(n))}function A8(a){var r;const n=D8(a),t=Ma(n)?n:null,o=((r=Xo(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=R8(t==null?void 0:t.errors);return o!==null&&i.length>0?o==="Validation failed"?i.join(" "):i.every(l=>o.includes(l))?o:`${o} ${i.join(" ")}`:o!==null?o:i.length>0?i.join(" "):a instanceof Error?a.message:"Failed to load media."}function Cd(a,n){const t=A8(n),o=$8(n);return{code:o===403?"permission_denied":a,message:t,retriable:o!==403,cause:n}}function Al(a){const n=a.perPage??40,t=e.ref([]),o=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);let u=null,f=0;const p=async g=>{f+=1;const w=f;u==null||u.abort();const F=new AbortController;u=F,g?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const D=await a.httpClient.get("/v1/media/library",{params:xd(a.view.value,a.filters.value,n,g?i.value:null),signal:F.signal});if(w!==f)return;const E=Ed(D);t.value=g?Sd([...t.value,...E.data]):E.data,o.value=E.hydrated,i.value=E.meta.cursor,r.value=E.meta.has_more}catch(D){if(F.signal.aborted||w!==f)return;const E=Cd(g?"load_more_failed":"query_failed",D);d.value=E,c.value=E.code==="permission_denied",g||(t.value=[],i.value=null,r.value=!1)}finally{w===f&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:o,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:c,error:d,loadInitial:async()=>{i.value=null,await p(!1)},loadMore:async()=>{!r.value||l.value||await p(!0)},refresh:async()=>{i.value=null,await p(!1)},hydrateSelection:async g=>{if(g.length===0)return o.value=[],[];try{const w=await a.httpClient.get("/v1/media/library",{params:xd(a.view.value,a.filters.value,1,null,g)}),F=Ed(w);return o.value=F.hydrated,F.hydrated}catch(w){return d.value=Cd("hydration_failed",w),[]}},prepend:g=>{t.value=Sd([g,...t.value])}}}const L8="mediables.media-library.";function P8(a){return!a||a.key.trim()===""?null:`${L8}${a.key}`}function us(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function O8(a,n){const t=Date.parse(a);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function Ym(a){const n=P8(a),t=(a==null?void 0:a.ttlMinutes)??30,o=`${(a==null?void 0:a.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(n===null)return null;const l=us();if(l===null)return null;const c=l.getItem(n);if(c===null)return null;let d;try{d=JSON.parse(c)}catch{return l.removeItem(n),null}if(typeof d!="object"||d===null||Array.isArray(d))return l.removeItem(n),null;const u=d;if(u.version!==1||typeof u.savedAt!="string"||O8(u.savedAt,t))return l.removeItem(n),null;const f={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(p=>typeof p=="string"&&p.trim()!==""):[]};return((a==null?void 0:a.restoreView)??!0)&&u.view&&(f.view=u.view),u.filters&&(f.filters=u.filters),f},save:l=>{if(n===null)return;const c=us();if(c===null)return;const d={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((a==null?void 0:a.restoreView)??!0)&&l.view&&(d.view=l.view),l.filters&&(d.filters=l.filters),c.setItem(n,JSON.stringify(d))},clear:()=>{if(n===null)return;const l=us();l==null||l.removeItem(n)},sessionId:o}}function qm(a){const n=e.ref(a);return{state:n,transition:o=>{n.value=o}}}function Qm(a){return{emitMetric:(t,o)=>{const i={name:t,timestamp:new Date().toISOString()};o!==void 0&&(i.payload=o),a==null||a(i)}}}function Ka(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function U8(a){const n=Ka(a)?a:{};return(Array.isArray(n.data)?n.data:Ka(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(a)?a:[]).map(o=>{if(!Ka(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 z8(a){const n=Ka(a)?a:{},t=Ka(n.data)?n.data:Ka(a)?a:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const o={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(o.description=t.description),o}function j8(a){return a==="ready"||a==="uploading"||a==="failed"}function Vi(a,n="ready"){return{id:a.uuid,media:a,status:n,countsTowardMax:j8(n)}}function W8(a,n){return a.scope==="library"?!0:n.type==="album"&&n.albumId===a.albumId}function Z8(a,n){return a.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===a.albumId}function ms(a){return{code:"configuration_error",message:a,retriable:!1}}function ep(a){var we,_e,oe;const n=a.selectionMode??"multiple",t=a.maxSelection,o=a.uploadBehavior??"adapter",i=e.ref(a.initialView??{scope:"library"}),r=e.ref({sort:((we=a.initialFilters)==null?void 0:we.sort)??"newest",...(_e=a.initialFilters)!=null&&_e.query?{query:a.initialFilters.query}:{},...(oe=a.initialFilters)!=null&&oe.kinds?{kinds:a.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=Ym(a.sessionPolicy),{emitMetric:f}=Qm(a.telemetry),p=qm("idle"),m=Al({httpClient:a.deps.httpClient,view:i,filters:r}),h=e.computed(()=>l.value.map($=>$.id)),g=e.computed(()=>{const $=c.value;return $===null?null:m.items.value[$]??null}),w=e.computed(()=>a.uploadTarget??{type:"library"}),F=Rl({adapter:a.deps.uploadAdapter??{name:"missing-upload-adapter",upload:async()=>{throw new Error("Upload adapter is not configured.")},attach:async()=>{},attachMany:async()=>{},detach:async()=>{},reorder:async()=>{},fetchModelMedia:async()=>[],getUrl:$=>$.original_url,getThumbnailUrl:$=>$.thumbnail_url??$.preview_url??$.original_url},postUpload:async($,B,Z)=>{const ee=w.value;ee.type!=="album"||!ee.albumId||await Z.attach(B.uuid,{modelType:"album",modelId:ee.albumId})},onUploadComplete:($,B)=>{const Z=w.value;W8(i.value,Z)&&m.prepend(B),a.autoSelectUploaded&&Z8(i.value,Z)&&V(B),f("upload-complete",{mediaId:B.uuid,targetType:Z.type,targetAlbumId:Z.albumId})},onUploadError:($,B)=>{d.value={code:"upload_failed",message:B.message,retriable:!0,cause:B}}}),D=e.computed(()=>F.isUploading.value),E=()=>{u.save({selectedIds:[...h.value],view:i.value,filters:r.value})},v=async $=>{const B=await m.hydrateSelection($);l.value=B.map(Z=>Z.status==="ready"&&Z.media?Vi(Z.media):{id:Z.id,media:null,status:Z.status,countsTowardMax:!1})},S=e.computed(()=>l.value.filter($=>$.countsTowardMax).length),C=()=>n==="single"||t===void 0?!0:S.value<t,V=$=>{if(l.value.findIndex(Z=>Z.id===$.uuid)>=0){n==="multiple"?l.value=l.value.filter(Z=>Z.id!==$.uuid):l.value=[Vi($)],E();return}if(!C()){d.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}n==="single"?l.value=[Vi($)]:l.value=[...l.value,Vi($)],d.value=null,E()},x=async()=>{var B;p.transition("restoring");const $=u.restore();if($===null){p.transition("ready");return}$.view&&(i.value=$.view),$.filters&&(r.value={sort:$.filters.sort??"newest",...$.filters.query?{query:$.filters.query}:{},...$.filters.kinds?{kinds:$.filters.kinds}:{}}),await m.loadInitial(),(((B=a.sessionPolicy)==null?void 0:B.restoreSelection)??!0)&&await v($.selectedIds),p.transition("ready")};e.watch(()=>m.error.value,$=>{$!==null&&(d.value=$,p.transition("error"))});const N=async()=>{d.value=null,p.transition("idle"),await x(),m.items.value.length===0&&!m.loading.value&&!m.permissionDenied.value&&await m.loadInitial();const $=a.defaultSelectedIds??[];l.value.length===0&&$.length>0&&await v($),p.transition("ready")},j=async($,B="user")=>{const Z=i.value;i.value=$,B==="user"&&a.preserveSelectionOnViewChange===!1&&(l.value=[]),f("view-change",{from:Z.scope,to:$.scope,reason:B}),await m.loadInitial(),E()},_=async()=>{const $=await a.deps.httpClient.get("/v1/albums");s.value=U8($)},R=async($,B)=>{try{const Z={name:$,visibility:"private"};B&&B.trim()!==""&&(Z.parent_id=B);const ee=await a.deps.httpClient.post("/v1/albums",Z),ne=z8(ee);return ne===null?ms("Album creation response was invalid."):(s.value=[ne,...s.value.filter(de=>de.id!==ne.id)],await j({scope:"album",albumId:ne.id,albumName:ne.name},"inline-album-created"),ne)}catch(Z){const ee={code:"album_create_failed",message:Z instanceof Error?Z.message:"Album creation failed.",retriable:!0,cause:Z};return d.value=ee,ee}},T=async $=>{if(!a.enableUpload){d.value=ms("Uploads are not enabled for this picker.");return}if(o!=="delegate"){if(!a.deps.uploadAdapter){d.value=ms("Uploads require a configured upload adapter.");return}await F.addFiles($)}},z=()=>{var Z;const $=((Z=a.validateSelection)==null?void 0:Z.call(a,l.value))??null;if($!==null){const ee={code:"selection_invalid",message:$,retriable:!0};return d.value=ee,ee}if(l.value.filter(ee=>ee.status==="ready"&&ee.media!==null).length===0){const ee={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ee,ee}return{orderedIds:h.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},P=$=>{const B=m.items.value.findIndex(Z=>Z.uuid===$.uuid);c.value=B>=0?B:null},M=()=>{c.value=null},L=()=>{c.value===null||c.value<=0||(c.value-=1)},k=()=>{c.value===null||c.value>=m.items.value.length-1||(c.value+=1)},O=$=>{l.value=l.value.filter(B=>B.id!==$),E()},W=async()=>{await m.refresh()},G=async $=>{r.value={...r.value,...$&&$.trim()!==""?{query:$.trim()}:{}},(!$||$.trim()==="")&&delete r.value.query,await m.loadInitial(),E()},ie=async()=>{await j({scope:"library"},"permission-unavailable")};return{view:i,filters:r,albums:s,selectedItems:l,orderedIds:h,queryItems:m.items,cursor:m.cursor,hasMore:m.hasMore,loading:m.loading,loadingMore:m.loadingMore,permissionDenied:m.permissionDenied,error:d,uploadQueue:F.uploadsArray,isUploading:D,previewIndex:c,previewItem:g,initialize:N,refresh:W,loadMore:m.loadMore,setQuery:G,setView:j,toggleSelection:V,removeSelected:O,confirmSelection:z,openPreview:P,closePreview:M,showPreviousPreview:L,showNextPreview:k,loadAlbums:_,createAlbum:R,addUploadFiles:T,goToLibrary:ie,sessionId:u.sessionId}}const H8=["data-testid"],X8={class:"mlp-location-bar"},G8={class:"mlp-location-bar__left"},J8={class:"mlp-location-bar__label"},K8={class:"mlp-tabs","data-testid":"media-picker-tabs"},Y8={key:0,class:"mlp-search-row"},q8=["placeholder"],Q8={key:2,class:"mlp-overlay-panel"},eI={key:0,class:"mlp-error","data-testid":"media-picker-error"},tI={key:5,class:"mlp-bottom-bar"},nI={key:0,class:"mlp-bottom-bar__selection"},aI={class:"mlp-bottom-bar__count"},oI={class:"mlp-bottom-bar__thumbs"},iI=["src","alt"],rI={key:1,class:"mlp-bottom-bar__thumb-placeholder"},sI=["aria-label","onClick"],lI={class:"mlp-bottom-bar__actions"},cI=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{var M,L,k,O,W,G,ie,we,_e,oe,$,B,Z,ee,ne,de,ue,ge;return{title:((M=o.labels)==null?void 0:M.title)??"Media library",searchPlaceholder:((L=o.labels)==null?void 0:L.searchPlaceholder)??"Search your media",viewLibrary:((k=o.labels)==null?void 0:k.viewLibrary)??"Library",browseAlbums:((O=o.labels)==null?void 0:O.browseAlbums)??"Albums",createAlbum:((W=o.labels)==null?void 0:W.createAlbum)??"Create album",createAlbumNameLabel:((G=o.labels)==null?void 0:G.createAlbumNameLabel)??"Album name",emptyLibrary:((ie=o.labels)==null?void 0:ie.emptyLibrary)??"No media found in your library.",emptyAlbum:((we=o.labels)==null?void 0:we.emptyAlbum)??"No media found in this album.",networkError:((_e=o.labels)==null?void 0:_e.networkError)??"Unable to load media right now.",retry:((oe=o.labels)==null?void 0:oe.retry)??"Retry",selectedCount:(($=o.labels)==null?void 0:$.selectedCount)??(Ne=>`${Ne} selected`),confirmAction:((B=o.labels)==null?void 0:B.confirmAction)??"Attach selected",cancel:((Z=o.labels)==null?void 0:Z.cancel)??"Cancel",dismiss:((ee=o.labels)==null?void 0:ee.dismiss)??"Remove",uploadLabel:((ne=o.labels)==null?void 0:ne.uploadLabel)??"Upload",albumUnavailableTitle:((de=o.labels)==null?void 0:de.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((ue=o.labels)==null?void 0:ue.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((ge=o.labels)==null?void 0:ge.goToLibrary)??"Go to library"}}),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}:{},preserveSelectionOnViewChange:o.preserveSelectionOnViewChange,telemetry:M=>{var L;(L=o.telemetry)==null||L.call(o,M),i("metric",M)}},l=ep(s),c=e.ref(o.initialFilters.query??""),d=e.ref("upload"),u=e.ref(!1),f=JSON.stringify(o.modelValue.length>0?o.modelValue:o.defaultSelectedIds);let p=null;const m=e.computed(()=>JSON.stringify(l.orderedIds.value)!==f),h=e.computed(()=>l.view.value.scope==="album"?r.value.emptyAlbum:r.value.emptyLibrary),g=e.computed(()=>r.value.selectedCount(l.selectedItems.value.length)),w=e.computed(()=>l.view.value.scope==="album"?l.view.value.albumName??"Album":r.value.viewLibrary),F=e.computed(()=>l.view.value.scope==="album"),D=()=>{p!==null&&(window.clearTimeout(p),p=null)},E=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:m.value})},v=M=>{M!==null&&i("error",M)},S=M=>typeof M.code=="string",C=M=>typeof M=="object"&&M!==null&&"code"in M&&typeof M.code=="string",V=()=>{const M=l.confirmSelection();if(S(M)){v(M);return}i("confirm",{...M,dirty:m.value})},x=(M="user")=>{i("cancel",{dirty:m.value,reason:M,sessionId:l.sessionId})},N=async()=>{d.value="albums",await l.loadAlbums()},j=async()=>{await l.goToLibrary(),d.value="albums",await l.loadAlbums()},_=M=>{l.setView({scope:"album",albumId:M.id,albumName:M.name}),d.value="media"},R=async(M,L)=>{const k=l.view.value,O=await l.createAlbum(M,L);if(C(O)){v(O);return}u.value=!1,d.value="media",i("view-change",{from:k,to:{scope:"album",albumId:O.id,albumName:O.name},reason:"inline-album-created",restoredFromSession:!1})},T=async M=>{if(o.uploadBehavior==="delegate"){i("request-upload-files",{files:[...M],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(M)};function z(M){var L;return M?M.thumbnail_url??((L=M.conversion_urls)==null?void 0:L.thumb)??M.preview_url??M.original_url??M.url??null:null}function P(M){return M!=null&&M.mime_type?M.mime_type.startsWith("image/"):!1}return e.watch(()=>c.value,M=>{D(),p=window.setTimeout(()=>{l.setQuery(M)},250)}),e.watch(()=>l.selectedItems.value,()=>{E()},{deep:!0}),e.watch(()=>l.error.value,M=>{v(M)}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{D()}),n({refresh:l.refresh}),(M,L)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":M.testIdPrefix},[e.createElementVNode("header",X8,[e.createElementVNode("div",G8,[F.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:j},[...L[8]||(L[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",J8,e.toDisplayString(w.value),1)])]),e.createElementVNode("nav",K8,[M.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="upload"}]),"data-testid":"tab-media-picker-upload",onClick:L[0]||(L[0]=k=>d.value="upload")},e.toDisplayString(r.value.uploadLabel),3)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="media"}]),"data-testid":"tab-media-picker-all",onClick:L[1]||(L[1]=k=>d.value="media")}," All Media ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="albums"}]),"data-testid":"tab-media-picker-albums",onClick:N},e.toDisplayString(r.value.browseAlbums),3)]),d.value==="media"||d.value==="albums"?(e.openBlock(),e.createElementBlock("div",Y8,[L[9]||(L[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":L[2]||(L[2]=k=>c.value=k),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,q8),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),M.enableUpload&&d.value==="upload"?(e.openBlock(),e.createBlock(Wm,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:M.accept,"upload-label":r.value.uploadLabel,onClose:L[3]||(L[3]=k=>d.value="media"),onFilesSelected:T},null,8,["queue","accept","upload-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",Q8,[e.createVNode(Om,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:L[4]||(L[4]=k=>u.value=!1),onCreate:R},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(Um,{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",eI,[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:L[5]||(L[5]=(...k)=>e.unref(l).refresh&&e.unref(l).refresh(...k))},e.toDisplayString(r.value.retry),1)])):e.createCommentVNode("",!0),d.value==="media"?(e.openBlock(),e.createBlock(Hm,{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,"test-id-prefix":`${M.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","test-id-prefix","onToggle","onPreview","onLoadMore"])):d.value==="albums"?(e.openBlock(),e.createBlock(jm,{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":M.enableAlbumCreation,onSelectLibrary:j,onSelectAlbum:_,onCreateAlbum:L[6]||(L[6]=k=>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),M.showFooter?(e.openBlock(),e.createElementBlock("footer",tI,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",nI,[e.createElementVNode("span",aI,e.toDisplayString(g.value),1),e.createElementVNode("div",oI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,k=>{var O,W,G;return e.openBlock(),e.createElementBlock("div",{key:k.id,class:"mlp-bottom-bar__thumb-item"},[P(k.media)&&z(k.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z(k.media),alt:((O=k.media)==null?void 0:O.alt_text)??((W=k.media)==null?void 0:W.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,iI)):(e.openBlock(),e.createElementBlock("div",rI,[...L[10]||(L[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} ${((G=k.media)==null?void 0:G.file_name)??k.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:ie=>e.unref(l).removeSelected(k.id)},[...L[11]||(L[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,sI)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",lI,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:L[7]||(L[7]=k=>x())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:V},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),M.enablePreview?(e.openBlock(),e.createBlock(zm,{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),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","onClose","onPrevious","onNext","onToggleSelect"])):e.createCommentVNode("",!0)],8,H8))}}),tp=Ve(cI,[["__scopeId","data-v-db2ced73"]]),dI={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},uI={class:"media-library-picker-modal__panel"},mI=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(a,{emit:n}){const t=a,o=n,i=()=>{t.closeOnBackdrop&&o("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",dI,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",uI,[e.createVNode(tp,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)}}),pI=Ve(mI,[["__scopeId","data-v-a92e8703"]]),fI={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},hI={class:"media-selection-tray__header"},vI={class:"media-selection-tray__title"},gI={class:"media-selection-tray__items"},yI={class:"media-selection-tray__item-preview"},bI=["src","alt"],wI={key:1,class:"media-selection-tray__file-icon"},kI={class:"media-selection-tray__item-copy"},_I=["aria-label","onClick"],EI=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(a,{emit:n}){const t=n;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",fI,[e.createElementVNode("header",hI,[e.createElementVNode("h3",vI,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",gI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d,u,f;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",yI,[i(l.media)&&o(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:o(l.media),alt:((c=l.media)==null?void 0:c.alt_text)??((d=l.media)==null?void 0:d.file_name)??"Selected media",class:"media-selection-tray__thumb"},null,8,bI)):(e.openBlock(),e.createElementBlock("div",wI,[...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",kI,[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:p=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,_I)])}),128))])])):e.createCommentVNode("",!0)}}),xI=Ve(EI,[["__scopeId","data-v-f2a3d69d"]]);function Ll(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),l=e.ref(null),c=e.computed(()=>l.value!==null),d=F=>{if(r.value++,l.value=null,i.value=null,t.value=!1,F!=null&&typeof F=="object"&&!(F instanceof Blob)&&("image"in F||"state"in F||"sessionKey"in F)){const D=F;o.value=D.image??null,s.value=D.state??null}else o.value=F??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},f=async F=>{try{return t.value=!0,i.value=F,a.onSave&&await a.onSave(F),u(),F}catch(D){const E=D;throw l.value=E,a.onError&&a.onError(E),E}finally{t.value=!1}},p=()=>{a.onCancel&&a.onCancel(),u()},m=F=>{l.value=F,a.onError&&a.onError(F)},h=()=>{l.value=null},g=()=>i.value,w=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:w,open:d,close:u,handleSave:f,handleCancel:p,handleError:m,clearError:h,getEditedImage:g}}let ps=null;function SI(a){return ps||(ps=Ll(a)),ps}function CI(a){return n=>new Promise((t,o)=>{Ll({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function Pl(a){return a.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const o={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(o.custom_properties=n.customProperties),o})}function tl(a){return a.map((n,t)=>{const o={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(o.customProperties=n.custom_properties),o})}function Ol(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),Ya(t)}return{name:"mediables",async upload(t,o){const r=await dn().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 dn().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await dn().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await dn().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await dn().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await dn().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return dn().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 dn().deleteMedia(t)},async update(t,o){const r=await dn().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),Ya(o)}}}let Oi=null;function VI(){return Oi||(Oi=Ol()),Oi}function NI(){Oi=null}const TI={apiBaseUrl:"/media-library-pro"};function Ni(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function fs(a){const n={uuid:a.uuid,file_name:a.fileName||a.name,mime_type:`application/${a.extension}`,size:a.size,disk:"public",original_url:a.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return a.name&&(n.name=a.name),a.original_url&&(n.url=a.original_url),a.preview_url&&(n.thumbnail_url=a.preview_url,n.preview_url=a.preview_url),a.custom_properties&&(n.custom_properties=a.custom_properties),n}function Ul(a){const n={...TI,...a};return{name:"spatie",async upload(o,i){const r=new FormData;r.append("file",o),i!=null&&i.collection&&r.append("collection",i.collection),i!=null&&i.customProperties&&r.append("custom_properties",JSON.stringify(i.customProperties));const s={Accept:"application/json",...n.headers},l=n.csrfToken||Ni();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(c.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,c);if(!d.ok){const p=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(p.message||`HTTP ${d.status}`)}const u=await d.json(),f=fs(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:f,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Ni();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",o.modelType),s.append("model_id",String(o.modelId)),o.collection&&s.append("collection",o.collection);try{const l=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(fs)}catch{return[]}},getUrl(o,i){var r;if(i){const s=(r=o.conversion_urls)==null?void 0:r[i];if(s)return s}return o.original_url||o.url||""},getThumbnailUrl(o){var i,r;return o.preview_url?o.preview_url:(i=o.conversion_urls)!=null&&i.preview?o.conversion_urls.preview:o.thumbnail_url?o.thumbnail_url:(r=o.conversion_urls)!=null&&r.thumb?o.conversion_urls.thumb:o.original_url||o.url||""},async delete(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Ni();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||Ni();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const d=await l.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${l.status}`)}const c=await l.json();return fs(c)},configure(o){Object.assign(n,o)}}}let Ui=null;function MI(){return Ui||(Ui=Ul()),Ui}function BI(){Ui=null}function np(a,n){switch(a){case"mediables":return Ol(n);case"spatie":return Ul(n);default:throw new Error(`Unknown adapter: ${a}`)}}function ap(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(D,E,v){n&&("dataTransfer"in D&&D.dataTransfer&&(D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("text/plain",String(v))),d=D.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:v,dropIndex:v,draggedItem:E},c.value=!0,o==null||o(E,v))}function f(D,E){var v;if(!(!n||!l.value.isDragging)&&(D.preventDefault(),l.value.dropIndex!==E)){const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s);const C=(v=D.target)==null?void 0:v.closest("[data-index]");C==null||C.classList.add(s),l.value.dropIndex=E}}function p(){if(!l.value.isDragging)return;const{dragIndex:D,dropIndex:E,draggedItem:v}=l.value;d&&d.classList.remove(r);const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s),D!==null&&E!==null&&D!==E&&v&&(t==null||t({fromIndex:D,toIndex:E,item:v})),h(),i==null||i()}function m(){d&&d.classList.remove(r);const D=document.querySelector(`.${s}`);D==null||D.classList.remove(s),h(),i==null||i()}function h(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function g(D,E,v){const S=[...D],[C]=S.splice(E,1);return S.splice(v,0,C),S.map((V,x)=>({...V,order:x}))}function w(D,E){return{draggable:n,"data-index":E,onDragstart:v=>u(v,D,E),onDragover:v=>f(v,E),onDragend:()=>p(),onDrop:v=>{v.preventDefault(),p()}}}function F(D){D.key==="Escape"&&l.value.isDragging&&m()}return e.onMounted(()=>{document.addEventListener("keydown",F)}),e.onUnmounted(()=>{document.removeEventListener("keydown",F),m()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:f,endDrag:p,cancelDrag:m,reorderItems:g,getDragProps:w}}function Mr(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:f="mediables",adapter:p,maxConcurrentUploads:m=3,onChange:h,onUpload:g,onUploadComplete:w,onUploadError:F,onRemove:D,onReorder:E,onError:v,onReadyToSubmitChange:S}=a,C={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},V=p||np(f),x=e.ref([]),N=e.ref(!1),j=e.ref([]);function _(fe){if(fe.length===0)return[];const me=fe[0];return"media"in me&&"clientId"in me?fe:tl(fe)}x.value=_(n);const{acceptString:R,canAddFiles:T}=Dl({rules:C}),z=Rl({adapter:V,maxConcurrent:m,rules:C,collection:i,onUploadStart:fe=>{g==null||g(fe)},onUploadComplete:(fe,me)=>{const Ee=x.value.findIndex(Te=>Te.clientId===fe.id);Ee!==-1&&(x.value[Ee]={...x.value[Ee],media:me,name:me.name||me.file_name,upload:{...fe,status:"completed"}}),w==null||w(me)},onUploadError:(fe,me)=>{const Ee=x.value.findIndex(Te=>Te.clientId===fe.id);Ee!==-1&&(x.value[Ee]={...x.value[Ee],upload:{...fe,status:"error",error:me.message},errors:[{field:"upload",message:me.message,code:"UPLOAD_ERROR"}]}),F==null||F({file:fe.file,message:me.message})},onQueueComplete:()=>{h==null||h(x.value)}}),{dragState:P,getDragProps:M,reorderItems:L}=ap({enabled:c&&!d,onReorder:fe=>{x.value=L(x.value,fe.fromIndex,fe.toIndex),E==null||E(x.value),h==null||h(x.value)}}),k=e.computed(()=>z.isUploading.value),O=e.computed(()=>!z.isUploading.value&&z.pendingCount.value===0),W=e.computed(()=>r?x.value.length>=r:!1),G=e.computed(()=>Pl(x.value)),ie=e.computed(()=>x.value.length),we=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch(O,fe=>{S==null||S(fe)});function _e(fe){x.value=_(fe),h==null||h(x.value)}async function oe(fe){if(d)return;const me=Array.from(fe);if(!T(me.length,x.value.length)){const st={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};j.value=[st],v==null||v([st]);return}const Ee=await z.addFiles(me),Te=x.value.length,dt=Ee.map((st,Dt)=>({...st,order:Te+Dt}));x.value=[...x.value,...dt],h==null||h(x.value)}function $(fe){d||(fe.upload&&(fe.upload.status==="uploading"||fe.upload.status==="pending")&&z.cancelUpload(fe.clientId),x.value=x.value.filter(me=>me.clientId!==fe.clientId),x.value=x.value.map((me,Ee)=>({...me,order:Ee})),D==null||D(fe),h==null||h(x.value))}function B(fe){const me=x.value.find(Ee=>Ee.clientId===fe);me&&$(me)}function Z(){d||(z.clearAll(),x.value=[],h==null||h(x.value))}function ee(fe,me){d||!c||(x.value=L(x.value,fe,me),E==null||E(x.value),h==null||h(x.value))}function ne(fe,me){if(d)return;const Ee=x.value.findIndex(Te=>Te.clientId===fe);Ee!==-1&&(x.value[Ee]={...x.value[Ee],...me},h==null||h(x.value))}function de(fe){z.cancelUpload(fe),B(fe)}async function ue(fe){await z.retryUpload(fe)}async function ge(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const fe={modelType:t,modelId:o,collection:i},me=x.value.filter(Ee=>Ee.media&&!Ee.markedForRemoval).map(Ee=>Ee.media.uuid);N.value=!0;try{await V.attachMany(me,fe),await V.reorder(fe,me)}finally{N.value=!1}}async function Ne(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const fe={modelType:t,modelId:o,collection:i};N.value=!0;try{const me=await V.fetchModelMedia(fe);x.value=tl(me),h==null||h(x.value)}finally{N.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&Ne().catch(console.error)}),e.onUnmounted(()=>{z.clearAll()}),{items:x,setItems:_e,addFiles:oe,removeItem:$,removeItemById:B,clearAll:Z,reorderItems:ee,updateItem:ne,cancelUpload:de,retryUpload:ue,save:ge,load:Ne,isLoading:N,isUploading:k,isReadyToSubmit:O,isAtMaxItems:W,errors:j,dragState:P,getDragProps:M,adapter:V,formValues:G,acceptString:R,count:ie,remainingSlots:we}}const II=["aria-disabled"],FI=["accept","multiple","disabled"],$I={class:"media-dropzone__content"},DI={class:"media-dropzone__title"},RI={class:"media-dropzone__subtitle"},AI=["disabled"],LI={key:0,class:"media-dropzone__helper"},PI=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),l=e.computed(()=>{const g=[];return t.maxFileSize&&g.push(`Max size: ${tr(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function c(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function f(g){var F;if(g.preventDefault(),i.value=!1,t.disabled)return;const w=(F=g.dataTransfer)==null?void 0:F.files;w&&w.length>0&&o("files",w)}function p(){var g;t.disabled||(g=r.value)==null||g.click()}function m(g){const w=g.target,F=w.files;F&&F.length>0&&o("files",F),w.value=""}function h(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),p())}return(g,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":g.disabled,"aria-label":"Upload files",onClick:p,onKeydown:h,onDragenter:c,onDragleave:d,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:m},null,40,FI),e.createElementVNode("div",$I,[e.renderSlot(g.$slots,"icon",{},()=>[w[0]||(w[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",DI,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",RI,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(p,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,AI),l.value?(e.openBlock(),e.createElementBlock("p",LI,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,II))}}),zl=Ve(PI,[["__scopeId","data-v-b1366c1e"]]),OI=["data-index"],UI={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},zI={class:"media-item__thumbnail"},jI=["src","alt"],WI={key:1,class:"media-item__file-icon"},ZI={key:2,class:"media-item__progress-overlay"},HI={class:"media-item__progress-text"},XI={key:3,class:"media-item__processing-overlay"},GI={key:4,class:"media-item__error-overlay"},JI={class:"media-item__info"},KI=["title"],YI={key:0,class:"media-item__size"},qI={key:1,class:"media-item__error-message"},QI={class:"media-item__actions"},e6=["disabled"],t6=["disabled"],n6=["disabled"],a6=["disabled"],o6=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.computed(()=>{var E;return(E=t.item.upload)!=null&&E.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var E,v,S;return((E=t.item.upload)==null?void 0:E.status)==="uploading"||((v=t.item.upload)==null?void 0:v.status)==="pending"||((S=t.item.upload)==null?void 0:S.status)==="queued"}),l=e.computed(()=>{var E;return((E=t.item.upload)==null?void 0:E.status)==="processing"}),c=e.computed(()=>{var E;return((E=t.item.upload)==null?void 0:E.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var E;return(E=t.item.upload)!=null&&E.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var E;return((E=t.item.upload)==null?void 0:E.progress)||0}),f=e.computed(()=>{var E;return t.item.name||((E=t.item.media)==null?void 0:E.file_name)||"Unknown file"}),p=e.computed(()=>{var V,x;const E=((V=t.item.media)==null?void 0:V.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!E)return"";const v=1024,S=["Bytes","KB","MB","GB"],C=Math.floor(Math.log(E)/Math.log(v));return parseFloat((E/Math.pow(v,C)).toFixed(2))+" "+S[C]}),m=e.computed(()=>{var v,S;const E=((v=t.item.media)==null?void 0:v.mime_type)||((S=t.item.upload)==null?void 0:S.file.type);return E==null?void 0:E.startsWith("image/")}),h=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.value,"media-item--error":c.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function g(){t.disabled||o("remove",t.item)}function w(){t.disabled||o("edit",t.item)}function F(){t.disabled||o("retry",t.item)}function D(){t.disabled||o("cancel",t.item)}return(E,v)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),"data-index":E.index,onMouseenter:v[0]||(v[0]=S=>i.value=!0),onMouseleave:v[1]||(v[1]=S=>i.value=!1)},[E.sortable&&!E.disabled?(e.openBlock(),e.createElementBlock("div",UI,[...v[2]||(v[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",zI,[r.value&&m.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:f.value,class:"media-item__image"},null,8,jI)):(e.openBlock(),e.createElementBlock("div",WI,[...v[3]||(v[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",ZI,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",HI,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",XI,[...v[4]||(v[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",GI,[...v[5]||(v[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",JI,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,KI),p.value?(e.openBlock(),e.createElementBlock("span",YI,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",qI,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",QI,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:E.disabled,"aria-label":"Cancel upload",onClick:D},[...v[6]||(v[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,e6)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:E.disabled,"aria-label":"Retry upload",onClick:F},[...v[7]||(v[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,t6)):e.createCommentVNode("",!0),E.showEdit&&E.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:E.disabled,"aria-label":"Edit",onClick:w},[...v[8]||(v[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,n6)):e.createCommentVNode("",!0),E.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:E.disabled,"aria-label":"Remove",onClick:g},[...v[9]||(v[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,a6)):e.createCommentVNode("",!0)])],42,OI))}}),jl=Ve(o6,[["__scopeId","data-v-ff81c9ec"]]),i6=["aria-label"],r6=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],s6={key:0,class:"media-collection__footer"},l6={class:"media-collection__count"},c6={key:0},d6={key:0,class:"media-collection__uploading"},u6=["name","value"],m6=["name","value"],p6=["name","value"],f6=["name","value"],h6={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},v6=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(a,{emit:n}){const t=a,o=n,i={initialItems:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxItems:t.maxItems,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,sortable:t.sortable,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:k=>{o("update:modelValue",k),o("change",k)},onUpload:k=>{o("upload",k)},onUploadComplete:k=>{o("upload-complete",k)},onUploadError:k=>{o("upload-error",k)},onRemove:k=>{o("remove",k)},onReorder:k=>{o("reorder",k)},onError:k=>{o("validation-error",k)},onReadyToSubmitChange:k=>{o("is-ready-to-submit-change",k)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:f,isLoading:p,isUploading:m,isAtMaxItems:h,errors:g,dragState:w,getDragProps:F,adapter:D,formValues:E,acceptString:v,count:S,remainingSlots:C}=Mr(i);e.provide("mediaAdapter",D),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,k=>{k!==r.value&&s(k)},{deep:!0});const V=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),x=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":p.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":w.value.isDragging}));function N(k){l(k)}function j(k){c(k)}function _(k){f(k.clientId)}function R(k){u(k.clientId)}function T(k){}function z(k,O,W){if(!t.sortable||t.disabled)return;const G=F(O,W);G.onDragstart&&G.onDragstart(k)}function P(k,O){if(!t.sortable||t.disabled)return;k.preventDefault();const W=r.value[O],G=F(W,O);G.onDragover&&G.onDragover(k)}function M(k,O){const W=F(k,O);W.onDragend&&W.onDragend()}function L(k,O){k.preventDefault();const W=r.value[O],G=F(W,O);G.onDrop&&G.onDrop(k)}return(k,O)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(k.$slots,"dropzone",{addFiles:e.unref(l)},()=>[V.value?(e.openBlock(),e.createBlock(zl,{key:0,accept:e.unref(v),multiple:k.maxItems!==1,disabled:k.disabled,"max-file-size":k.maxFileSize,"max-items":e.unref(C),onFiles:N},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(S)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(W,G)=>e.renderSlot(k.$slots,"item",{key:W.clientId,item:W,index:G,remove:()=>j(W)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(w).dropIndex===G}]),draggable:k.sortable&&!k.disabled,"data-index":G,onDragstart:ie=>z(ie,W,G),onDragover:ie=>P(ie,G),onDragend:ie=>M(W,G),onDrop:ie=>L(ie,G)},[e.createVNode(jl,{item:W,adapter:e.unref(D),disabled:k.disabled,sortable:k.sortable,"show-remove":!k.readonly,"show-edit":!1,index:G,onRemove:j,onRetry:_,onCancel:R,onEdit:T},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,r6)],!0)),128))],8,i6)):V.value?e.createCommentVNode("",!0):e.renderSlot(k.$slots,"empty",{key:1},()=>[O[0]||(O[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(k.$slots,"footer",{count:e.unref(S),isUploading:e.unref(m)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",s6,[e.createElementVNode("span",l6,[e.createTextVNode(e.toDisplayString(e.unref(S))+" "+e.toDisplayString(e.unref(S)===1?"file":"files")+" ",1),k.maxItems?(e.openBlock(),e.createElementBlock("span",c6," / "+e.toDisplayString(k.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(m)?(e.openBlock(),e.createElementBlock("span",d6," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),k.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),(W,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${W.uuid}`,type:"hidden",name:`${k.name}[${G}][uuid]`,value:W.uuid},null,8,u6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),(W,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${W.uuid}-name`,type:"hidden",name:`${k.name}[${G}][name]`,value:W.name},null,8,m6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),(W,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${W.uuid}-order`,type:"hidden",name:`${k.name}[${G}][order]`,value:W.order},null,8,p6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),(W,G)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${k.name}-${W.uuid}-props`},[W.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[${G}][custom_properties]`,value:JSON.stringify(W.custom_properties)},null,8,f6)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",h6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),W=>(e.openBlock(),e.createElementBlock("p",{key:W.code||W.message,class:"media-collection__error"},e.toDisplayString(W.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),g6=Ve(v6,[["__scopeId","data-v-10a5bfff"]]);function Wl(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=a,p={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:V=>{t==null||t(V[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},m=Mr(p),h=e.computed(()=>m.items.value[0]||null),g=e.computed(()=>h.value!==null),w=e.computed(()=>m.formValues.value[0]||null);function F(V){V===null?m.clearAll():m.setItems([V])}async function D(V){const x=h.value;x&&m.removeItem(x),await m.addFiles([V])}function E(){h.value&&m.removeItem(h.value)}async function v(V){const x=h.value;x&&m.removeItem(x),await m.addFiles([V]);const N=m.items.value[0];N&&(o==null||o(x,N))}function S(){var V;(V=h.value)!=null&&V.upload&&m.cancelUpload(h.value.clientId)}async function C(){var V,x;((x=(V=h.value)==null?void 0:V.upload)==null?void 0:x.status)==="error"&&await m.retryUpload(h.value.clientId)}return{item:h,setItem:F,addFile:D,removeItem:E,replaceItem:v,cancelUpload:S,retryUpload:C,save:m.save,load:m.load,isLoading:m.isLoading,isUploading:m.isUploading,isReadyToSubmit:m.isReadyToSubmit,hasItem:g,errors:m.errors,adapter:m.adapter,formValue:w,acceptString:m.acceptString}}const y6=["accept","disabled"],b6={class:"media-attachment__preview"},w6=["name","value"],k6=["name","value"],_6=["name","value"],E6=["name","value"],x6={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},S6=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r={initialItem:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:_=>{o("update:modelValue",_),o("change",_)},onUpload:_=>{o("upload",_)},onUploadComplete:_=>{o("upload-complete",_)},onUploadError:_=>{o("upload-error",_)},onRemove:_=>{o("remove",_)},onReplace:(_,R)=>{o("replace",R)},onError:_=>{o("validation-error",_)},onReadyToSubmitChange:_=>{o("is-ready-to-submit-change",_)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,hasItem:h,errors:g,adapter:w,formValue:F,acceptString:D}=Wl(r);e.provide("mediaAdapter",w),e.watch(()=>t.modelValue,_=>{_!==s.value&&l(_)},{deep:!0});const E=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),v=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":m.value,"media-attachment--has-item":h.value}));function S(_){_.length>0&&c(_[0])}function C(){var _;(_=i.value)==null||_.click()}function V(_){const R=_.target,T=R.files;T&&T.length>0&&u(T[0]),R.value=""}function x(_){d()}function N(_){p()}function j(_){f()}return(_,R)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(D),disabled:_.disabled,class:"media-attachment__hidden-input",onChange:V},null,40,y6),E.value?e.renderSlot(_.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(zl,{accept:e.unref(D),multiple:!1,disabled:_.disabled,"max-file-size":_.maxFileSize,onFiles:S},null,8,["accept","disabled","max-file-size"])],!0):e.unref(h)&&e.unref(s)?e.renderSlot(_.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:C},()=>[e.createElementVNode("div",b6,[e.createVNode(jl,{item:e.unref(s),adapter:e.unref(w),disabled:_.disabled,sortable:!1,"show-remove":!_.readonly,"show-edit":!1,onRemove:x,onRetry:N,onCancel:j},null,8,["item","adapter","disabled","show-remove"]),_.showReplaceButton&&!_.readonly&&!_.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:C},[...R[0]||(R[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(_.$slots,"empty",{key:2},()=>[R[1]||(R[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),_.generateFormFields&&e.unref(F)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${_.name}[uuid]`,value:e.unref(F).uuid},null,8,w6),e.createElementVNode("input",{type:"hidden",name:`${_.name}[name]`,value:e.unref(F).name},null,8,k6),e.createElementVNode("input",{type:"hidden",name:`${_.name}[order]`,value:e.unref(F).order},null,8,_6),e.unref(F).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${_.name}[custom_properties]`,value:JSON.stringify(e.unref(F).custom_properties)},null,8,E6)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",x6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),T=>(e.openBlock(),e.createElementBlock("p",{key:T.code||T.message,class:"media-attachment__error"},e.toDisplayString(T.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),C6=Ve(S6,[["__scopeId","data-v-26911174"]]),op={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"}},V6=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:_=>{i("update:modelValue",_),i("change",_)},onUpload:_=>{i("upload",_)},onUploadComplete:_=>{i("upload-complete",_)},onUploadError:_=>{i("upload-error",_)},onRemove:_=>{i("remove",_)},onReorder:_=>{i("reorder",_)},onError:_=>{i("validation-error",_)},onReadyToSubmitChange:_=>{i("is-ready-to-submit-change",_)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:w,isAtMaxItems:F,errors:D,dragState:E,getDragProps:v,adapter:S,formValues:C,acceptString:V}=Mr(r);e.provide("mediaAdapter",S),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,_=>{_!==s.value&&l(_)},{deep:!0});const x=e.computed(()=>({...op,...o.labels})),N=e.computed(()=>({accept:V.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||F.value})),j=e.computed(()=>({items:s.value,isLoading:h.value,isUploading:g.value,isReadyToSubmit:w.value,isAtMaxItems:F.value,errors:D.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(_=>d(_))},cancelUpload:p,retryUpload:m,labels:x.value,dropzoneProps:N.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:w,isAtMaxItems:F,errors:D,dragState:E,getDragProps:v,adapter:S,formValues:C,acceptString:V}),(_,R)=>e.renderSlot(_.$slots,"default",e.normalizeProps(e.guardReactiveProps(j.value)))}}),N6=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r={initialItem:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange: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)},onReplace:(x,N)=>{i("replace",N)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,isUploading:h,isReadyToSubmit:g,hasItem:w,errors:F,adapter:D,formValue:E,acceptString:v}=Wl(r);e.provide("mediaAdapter",D),e.watch(()=>o.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const S=e.computed(()=>({...op,...o.labels})),C=e.computed(()=>({accept:v.value,multiple:!1,disabled:o.disabled||o.readonly||w.value})),V=e.computed(()=>({item:s.value,hasItem:w.value,isLoading:m.value,isUploading:h.value,isReadyToSubmit:g.value,errors:F.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,labels:S.value,dropzoneProps:C.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,isUploading:h,isReadyToSubmit:g,hasItem:w,errors:F,adapter:D,formValue:E,acceptString:v}),(x,N)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(V.value)))}}),T6=["name","value"],M6=["name","value"],B6=["name","value"],I6=["name","value"],F6=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(a){const n=a,t=e.computed(()=>n.item?[n.item]:n.items),o=e.computed(()=>Pl(t.value));function i(l,c){var u;const d=((u=o.value[l])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${c}]`}function r(l,c){return`${n.name}[${l}][${c}]`}function s(l,c){return n.format==="spatie"?i(l,c):r(l,c)}return(l,c)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(d,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:d.uuid},null,8,T6),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,M6),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,B6),d.custom_properties&&Object.keys(d.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:s(u,"custom_properties"),value:JSON.stringify(d.custom_properties)},null,8,I6)):e.createCommentVNode("",!0)],64))),128))}}),$6=["data-testid"],D6=["data-testid"],R6=["id"],A6=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],L6=e.defineComponent({__name:"MediaAttachmentMetadataFields",props:{items:{},disabled:{type:Boolean,default:!1},label:{default:"Caption"},placeholder:{default:"Add an optional caption"},maxLength:{default:500},testIdPrefix:{default:"media-attachment-metadata"},getItemLabel:{type:Function,default:(a,n)=>`${a.type==="video"?"video":"photo"} ${n+1}`}},emits:["update:items"],setup(a,{emit:n}){const t=a,o=n;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&o("update:items",t.items.map((c,d)=>d!==r?c:{...c,caption:l.value===""?null:l.value}))}return(r,s)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-attachment-metadata-fields","data-testid":r.testIdPrefix},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(l,c)=>(e.openBlock(),e.createElementBlock("div",{key:l._key??l.id??`${l.url}:${c}`,class:"media-attachment-metadata-fields__row","data-testid":`${r.testIdPrefix}-${c}`},[e.createElementVNode("p",{id:`${r.testIdPrefix}-label-${c}`,class:"media-attachment-metadata-fields__label"},e.toDisplayString(r.label)+" for "+e.toDisplayString(r.getItemLabel(l,c)),9,R6),e.createElementVNode("input",{value:l.caption??"",type:"text",class:"media-attachment-metadata-fields__input",maxlength:r.maxLength,disabled:r.disabled,"aria-labelledby":`${r.testIdPrefix}-label-${c}`,placeholder:r.placeholder,"data-testid":`input-${r.testIdPrefix}-${c}`,onInput:d=>i(c,d)},null,40,A6)],8,D6))),128))],8,$6)):e.createCommentVNode("",!0)}}),P6=Ve(L6,[["__scopeId","data-v-a153768a"]]),O6="/v1/media/deletion/check",U6="/v1/media/deletion/delete",Ti=100;function Vd(a){const n=new Set,t=[];for(const o of a){const i=o.trim().toLowerCase();i===""||n.has(i)||(n.add(i),t.push(i))}return t.sort()}function ip(a){const n=a.checkEndpoint??O6,t=a.deleteEndpoint??U6,o=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function c(f){l.value=null;const p=Vd(f);if(p.length===0)return r.value=[],[];if(p.length>Ti){const m=new Error(`Cannot check more than ${Ti} media items at once.`);throw l.value=m,m}o.value=!0;try{const m=await a.httpClient.post(n,{uuids:p}),h=((m==null?void 0:m.data)??[]).map(g=>{var w,F,D,E;return{uuid:g.uuid,canDelete:((w=g.report)==null?void 0:w.canDelete)??!1,blocks:Array.isArray((F=g.report)==null?void 0:F.blocks)?g.report.blocks:[],cascade:Array.isArray((D=g.report)==null?void 0:D.cascade)?g.report.cascade:[],variantCount:typeof((E=g.report)==null?void 0:E.variantCount)=="number"?g.report.variantCount:0}});return r.value=h,h}catch(m){throw l.value=m instanceof Error?m:new Error(String(m)),l.value}finally{o.value=!1}}async function d(f,p={}){l.value=null;const m=Vd(f);if(m.length===0){const h={results:[],summary:{}};return s.value=h,h}if(m.length>Ti){const h=new Error(`Cannot delete more than ${Ti} media items at once.`);throw l.value=h,h}i.value=!0;try{const h=await a.httpClient.post(t,{uuids:m,force:p.force===!0}),g={results:Array.isArray(h==null?void 0:h.results)?h.results:[],summary:(h==null?void 0:h.summary)??{}};return s.value=g,g}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:c,deleteMany:d,reset:u}}const z6="/v1/user/media/trash";function j6(a){return`/v1/user/media/${encodeURIComponent(a)}/restore`}function rp(a){const n=a.listEndpoint??z6,t=a.buildRestoreEndpoint??j6,o=a.perPage??50,i=e.ref([]),r=e.ref(0),s=e.ref(1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);async function u(m=1){var h,g;d.value=null,l.value=!0;try{const w=await a.httpClient.get(n,{params:{page:m,per_page:o}});i.value=Array.isArray(w==null?void 0:w.data)?w.data:[],r.value=typeof((h=w==null?void 0:w.meta)==null?void 0:h.total)=="number"?w.meta.total:0,s.value=typeof((g=w==null?void 0:w.meta)==null?void 0:g.current_page)=="number"?w.meta.current_page:m}catch(w){throw d.value=w instanceof Error?w:new Error(String(w)),d.value}finally{l.value=!1}}async function f(m){d.value=null,c.value=!0;try{const h=await a.httpClient.post(t(m)),g={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"&&(g.message=h.message),g.status==="restored"&&(i.value=i.value.filter(w=>w.uuid!==m),r.value=Math.max(0,r.value-1)),g}catch(h){const g=W6(h);if(g&&typeof g.status=="string"){const w={status:g.status,duplicate_uuid:typeof g.duplicate_uuid=="string"?g.duplicate_uuid:null};return typeof g.message=="string"&&(w.message=g.message),w}throw d.value=h instanceof Error?h:new Error(String(h)),d.value}finally{c.value=!1}}function p(){i.value=[],r.value=0,s.value=1,d.value=null}return{items:i,total:r,currentPage:s,isLoading:l,isRestoring:c,error:d,fetch:u,restore:f,reset:p}}function W6(a){var t;if(typeof a!="object"||a===null)return null;const n=a;return(t=n.response)!=null&&t.data&&typeof n.response.data=="object"?n.response.data:null}const Z6={class:"media-management-view","data-testid":"media-management-view"},H6={class:"media-management-view__header"},X6={class:"media-management-view__title"},G6={class:"media-management-view__actions"},J6={key:0,class:"media-management-view__badge"},K6={key:0,class:"media-management-view__panel","data-testid":"panel-library"},Y6={key:0,class:"media-management-view__status","data-testid":"library-loading"},q6={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},Q6={key:2,class:"media-management-view__empty","data-testid":"library-empty"},eF={key:3,class:"media-management-view__grid","data-testid":"library-grid"},tF=["data-testid"],nF=["data-testid","aria-pressed","onClick"],aF=["src","alt"],oF={key:1,class:"media-management-view__item-placeholder"},iF={class:"media-management-view__item-meta"},rF={class:"media-management-view__item-name"},sF=["data-testid"],lF={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},cF={key:4,class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},dF={"data-testid":"bulk-count"},uF=["disabled"],mF={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},pF={key:0,class:"media-management-view__status","data-testid":"trash-loading"},fF={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},hF={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},vF=["data-testid"],gF={class:"media-management-view__item-thumb"},yF=["src","alt"],bF={class:"media-management-view__item-meta"},wF={class:"media-management-view__item-name"},kF={key:0,class:"media-management-view__item-meta-line"},_F=["data-testid","disabled","onClick"],EF=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},confirmBulkDelete:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>({showTrash:!0,allowBulkDelete:!0,showOwner:!1,...o.capabilities})),s=e.computed(()=>{var M,L,k,O,W,G,ie,we,_e,oe,$,B;return{title:((M=o.labels)==null?void 0:M.title)??"My Media",libraryTab:((L=o.labels)==null?void 0:L.libraryTab)??"Library",trashTab:((k=o.labels)==null?void 0:k.trashTab)??"Trash",loading:((O=o.labels)==null?void 0:O.loading)??"Loading…",emptyLibrary:((W=o.labels)==null?void 0:W.emptyLibrary)??"No media yet — upload your first creation.",emptyTrash:((G=o.labels)==null?void 0:G.emptyTrash)??"Trash is empty.",orphanedBadge:((ie=o.labels)==null?void 0:ie.orphanedBadge)??"Not in use",selectedCount:((we=o.labels)==null?void 0:we.selectedCount)??(Z=>`${Z} selected`),deleteButton:((_e=o.labels)==null?void 0:_e.deleteButton)??"Delete",restoreButton:((oe=o.labels)==null?void 0:oe.restoreButton)??"Restore",purgeAfter:(($=o.labels)==null?void 0:$.purgeAfter)??(Z=>`Purges ${Z}`),ownerLabel:((B=o.labels)==null?void 0:B.ownerLabel)??(Z=>`User ${Z.user_id??""}`)}}),l=e.computed(()=>s.value.title),c=e.computed(()=>s.value.libraryTab),d=e.computed(()=>s.value.trashTab),u=e.computed(()=>s.value.loading),f=e.computed(()=>s.value.emptyLibrary),p=e.computed(()=>s.value.emptyTrash),m=e.computed(()=>s.value.orphanedBadge),h=e.computed(()=>s.value.deleteButton),g=e.computed(()=>s.value.restoreButton),w=e.ref("library"),F=e.ref({scope:"library"}),D=e.ref({}),E=Al({httpClient:o.httpClient,view:F,filters:D,perPage:50}),v=e.computed(()=>E.items.value),S=e.computed(()=>E.loading.value),C=e.computed(()=>{var M;return((M=E.error.value)==null?void 0:M.message)??null}),V=Zd(v),x=ip({httpClient:o.httpClient}),N=rp({httpClient:o.httpClient});function j(M){return s.value.selectedCount(M)}function _(M){return s.value.purgeAfter(M)}function R(M){return s.value.ownerLabel(M)}async function T(){const M=V.selectedItems.value;if(M.length===0)return;const L=r.value.canDelete?M.filter(k=>r.value.canDelete(k)):M;if(L.length!==0&&!(o.confirmBulkDelete&&!await o.confirmBulkDelete(L)))try{const k=L.map(G=>G.uuid),W=(await x.deleteMany(k)).results.filter(G=>G.status==="trashed"||G.status==="already_trashed").map(G=>G.uuid);if(W.length>0){for(const G of W)V.deselect(G);i("deleted",W),await E.refresh(),r.value.showTrash!==!1&&await N.fetch(N.currentPage.value).catch(()=>{})}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function z(M){var L;try{const k=await N.restore(M);if(k.status==="restored"){i("restored",M),await E.refresh().catch(()=>{});return}if(k.status==="duplicate_conflict"){i("restore-conflict",{uuid:M,duplicateUuid:k.duplicate_uuid??null}),(L=o.onRestoreCollision)==null||L.call(o,M,k.duplicate_uuid??null);return}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function P(){w.value="trash",N.items.value.length===0&&!N.isLoading.value&&await N.fetch().catch(M=>{i("error",M instanceof Error?M:new Error(String(M)))})}return e.watch(w,async M=>{M==="library"&&v.value.length===0&&!S.value&&await E.refresh().catch(()=>{})}),e.onMounted(async()=>{await E.refresh().catch(M=>{i("error",M instanceof Error?M:new Error(String(M)))}),r.value.showTrash!==!1&&N.fetch().catch(()=>{})}),n({refresh:()=>E.refresh(),refreshTrash:()=>N.fetch(),selection:V,deletion:x,trash:N}),(M,L)=>(e.openBlock(),e.createElementBlock("div",Z6,[e.createElementVNode("header",H6,[e.createElementVNode("h2",X6,e.toDisplayString(l.value),1),e.createElementVNode("div",G6,[r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":w.value==="library"}]),"data-testid":"tab-library",onClick:L[0]||(L[0]=k=>w.value="library")},e.toDisplayString(c.value),3)):e.createCommentVNode("",!0),r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":w.value==="trash"}]),"data-testid":"tab-trash",onClick:P},[e.createTextVNode(e.toDisplayString(d.value)+" ",1),e.unref(N).total.value>0?(e.openBlock(),e.createElementBlock("span",J6,e.toDisplayString(e.unref(N).total.value),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)])]),w.value==="library"?(e.openBlock(),e.createElementBlock("section",K6,[S.value?(e.openBlock(),e.createElementBlock("div",Y6,e.toDisplayString(u.value),1)):C.value?(e.openBlock(),e.createElementBlock("div",q6,e.toDisplayString(C.value),1)):v.value.length===0?(e.openBlock(),e.createElementBlock("div",Q6,e.toDisplayString(f.value),1)):(e.openBlock(),e.createElementBlock("ul",eF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,k=>(e.openBlock(),e.createElementBlock("li",{key:k.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(V).isSelected(k.uuid)}]),"data-testid":`media-item-${k.uuid}`},[e.createElementVNode("button",{type:"button",class:"media-management-view__item-thumb","data-testid":`btn-select-${k.uuid}`,"aria-pressed":e.unref(V).isSelected(k.uuid),onClick:O=>e.unref(V).toggle(k.uuid)},[k.thumbnail_url||k.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.thumbnail_url||k.original_url,alt:k.alt_text||k.file_name,loading:"lazy"},null,8,aF)):(e.openBlock(),e.createElementBlock("span",oF,e.toDisplayString(k.file_name),1))],8,nF),e.createElementVNode("div",iF,[e.createElementVNode("span",rF,e.toDisplayString(k.file_name),1),r.value.showOwner&&k.user_id?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__item-owner","data-testid":`owner-${k.uuid}`},e.toDisplayString(R(k)),9,sF)):e.createCommentVNode("",!0),k.is_orphaned?(e.openBlock(),e.createElementBlock("span",lF,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0)])],10,tF))),128))])),e.unref(V).selectedCount.value>0&&r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("footer",cF,[e.createElementVNode("span",dF,e.toDisplayString(j(e.unref(V).selectedCount.value)),1),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(x).isDeleting.value,onClick:T},e.toDisplayString(h.value),9,uF)])):e.createCommentVNode("",!0)])):w.value==="trash"?(e.openBlock(),e.createElementBlock("section",mF,[e.unref(N).isLoading.value?(e.openBlock(),e.createElementBlock("div",pF,e.toDisplayString(u.value),1)):e.unref(N).items.value.length===0?(e.openBlock(),e.createElementBlock("div",fF,e.toDisplayString(p.value),1)):(e.openBlock(),e.createElementBlock("ul",hF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(N).items.value,k=>(e.openBlock(),e.createElementBlock("li",{key:k.uuid,class:"media-management-view__item is-trashed","data-testid":`trash-item-${k.uuid}`},[e.createElementVNode("div",gF,[k.thumbnail_url||k.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.thumbnail_url||k.original_url,alt:k.alt_text||k.file_name,loading:"lazy"},null,8,yF)):e.createCommentVNode("",!0)]),e.createElementVNode("div",bF,[e.createElementVNode("span",wF,e.toDisplayString(k.file_name),1),k.purge_after?(e.openBlock(),e.createElementBlock("span",kF,e.toDisplayString(_(k.purge_after)),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-restore","data-testid":`btn-restore-${k.uuid}`,disabled:e.unref(N).isRestoring.value,onClick:O=>z(k.uuid)},e.toDisplayString(g.value),9,_F)],8,vF))),128))]))])):e.createCommentVNode("",!0)]))}}),xF=Ve(EF,[["__scopeId","data-v-ec535782"]]);exports.AlbumBrowser=Pm;exports.AlbumManager=bB;exports.AlbumMediaGrid=BB;exports.AlbumTree=Lm;exports.ArrayBufferTarget=dl;exports.ExistingMediaSelector=Hv;exports.ImageEditor=Rd;exports.ImageEditorModal=Ad;exports.LiveStreamManager=H5;exports.ManagedMediaGallery=_f;exports.MediaAlbumInlineCreate=Om;exports.MediaAlbumUnavailableState=Um;exports.MediaAttachment=C6;exports.MediaAttachmentMetadataFields=P6;exports.MediaCollection=g6;exports.MediaCollectionDropzone=zl;exports.MediaCollectionItem=jl;exports.MediaLibraryPicker=tp;exports.MediaLibraryPickerModal=pI;exports.MediaManagementView=xF;exports.MediaPreviewSheet=zm;exports.MediaSelectionTray=xI;exports.MediaSourceSheet=jm;exports.MediaThumbnailCell=Zm;exports.MediaUploadSheet=Wm;exports.MediaWorkspace=yf;exports.ModelMediaManager=fv;exports.Muxer=su;exports.VideoEditor=Fm;exports.VideoEditorDialog=T4;exports.VideoEditorSimple=Q4;exports.VideoExportPanel=IT;exports.VideoJobClient=Vr;exports.VideoPlayer=Dm;exports.VideoTimeline=E3;exports.VideoToolsPanel=mT;exports.VideoUploader=bM;exports.VirtualMediaGrid=Hm;exports._sfc_main=V6;exports._sfc_main$1=N6;exports._sfc_main$2=F6;exports.applyTemporaryMediaStoreConfig=Bd;exports.configureMediaStore=Ya;exports.createAdapter=np;exports.createEmptyEditorState=Yp;exports.createImageEditor=CI;exports.createMediablesAdapter=Ol;exports.createSpatieAdapter=Ul;exports.deserializeEditorState=Kp;exports.formatFileSize=tr;exports.fromMediaArray=tl;exports.getFileExtension=Xm;exports.getImageDimensions=Gm;exports.getMediablesAdapter=VI;exports.getSpatieAdapter=MI;exports.isImageFile=$l;exports.normalizeEditorState=nl;exports.normalizeRecipeForServerRender=d4;exports.recipeHasServerRenderableEdits=c4;exports.recipeHasUnsupportedServerEdits=$m;exports.resetMediablesAdapter=NI;exports.resetSpatieAdapter=BI;exports.restoreMediaStoreConfig=Md;exports.serializeEditorState=Nd;exports.snapshotMediaStoreConfig=Td;exports.toFormValues=Pl;exports.useAdminMediaStore=Id;exports.useAlbumDragDrop=Am;exports.useAlbumStore=Tr;exports.useAlbums=Rm;exports.useGlobalImageEditor=SI;exports.useImageEditorModal=Ll;exports.useMediaAttachment=Wl;exports.useMediaCollection=Mr;exports.useMediaDeletion=ip;exports.useMediaDragSort=ap;exports.useMediaLibraryPickerController=ep;exports.useMediaLibraryQuery=Al;exports.useMediaLibrarySession=Ym;exports.useMediaLibraryStateMachine=qm;exports.useMediaLibraryTelemetry=Qm;exports.useMediaStore=dn;exports.useMediaTrash=rp;exports.useMediaUploadQueue=Rl;exports.useMediaValidation=Dl;exports.validateFile=Jm;
|
|
350
|
-
//# sourceMappingURL=index-DeXGbdCM.cjs.map
|