@codingfactory/mediables-vue 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/PixiFrameExporter-COcgeYmj.cjs +2 -0
  2. package/dist/{PixiFrameExporter-CqKXaoCX.cjs.map → PixiFrameExporter-COcgeYmj.cjs.map} +1 -1
  3. package/dist/{PixiFrameExporter-BcywK0MP.js → PixiFrameExporter-SiG3q5-_.js} +60 -59
  4. package/dist/{PixiFrameExporter-BcywK0MP.js.map → PixiFrameExporter-SiG3q5-_.js.map} +1 -1
  5. package/dist/components/video/ui-v2/AssetRail.vue.d.ts +2 -0
  6. package/dist/components/video/ui-v2/AssetRailItem.vue.d.ts +7 -0
  7. package/dist/components/video/ui-v2/AudioMixerPanel.vue.d.ts +33 -0
  8. package/dist/components/video/ui-v2/CaptionSrtPanel.vue.d.ts +9 -0
  9. package/dist/components/video/ui-v2/DesktopInspectorSections.vue.d.ts +21 -0
  10. package/dist/components/video/ui-v2/DraftRecoveryBanner.vue.d.ts +12 -0
  11. package/dist/components/video/ui-v2/KeyframePresetPanel.vue.d.ts +26 -0
  12. package/dist/components/video/ui-v2/MobileClipSummary.vue.d.ts +4 -0
  13. package/dist/components/video/ui-v2/MobileToolPicker.vue.d.ts +3 -0
  14. package/dist/components/video/ui-v2/SplitPanelLayout.vue.d.ts +9 -5
  15. package/dist/components/video/ui-v2/TimelineTrackHeader.vue.d.ts +2 -0
  16. package/dist/composables/useClientVideoExport.d.ts +27 -0
  17. package/dist/composables/useLiveStream.d.ts +2 -2
  18. package/dist/composables/useRadialMenu.d.ts +1 -1
  19. package/dist/composables/useVideoEditor.d.ts +119 -7
  20. package/dist/composables/useVideoFilters.d.ts +4 -4
  21. package/dist/index-B6oyn6Pa.cjs +350 -0
  22. package/dist/index-B6oyn6Pa.cjs.map +1 -0
  23. package/dist/index-BGexNz7s.js +32993 -0
  24. package/dist/index-BGexNz7s.js.map +1 -0
  25. package/dist/mediables-vue.cjs +1 -1
  26. package/dist/mediables-vue.mjs +1 -1
  27. package/dist/render-page/assets/{index-y90zwXpc.js → index-jZGmiMRr.js} +991 -151
  28. package/dist/render-page/index.html +1 -1
  29. package/dist/services/VideoJobClient.d.ts +1 -1
  30. package/dist/style.css +1 -1
  31. package/dist/types/api.d.ts +14 -0
  32. package/dist/types/video.d.ts +164 -5
  33. package/dist/video/project/audioMixerSchema.d.ts +152 -0
  34. package/dist/video/project/captionSrt.d.ts +23 -0
  35. package/dist/video/project/draftRecovery.d.ts +86 -0
  36. package/dist/video/project/exportPresets.d.ts +172 -0
  37. package/dist/video/project/index.d.ts +22 -0
  38. package/dist/video/project/keyframeAutomation.d.ts +91 -0
  39. package/dist/video/project/mediaSourceAnalysis.d.ts +127 -0
  40. package/dist/video/project/mediaSourceCache.d.ts +47 -0
  41. package/dist/video/project/recipeMigration.d.ts +26 -0
  42. package/dist/video/project/timelineSelection.d.ts +23 -0
  43. package/dist/video/project/timelineTransactions.d.ts +129 -0
  44. package/dist/video/project/visualLayerSchema.d.ts +238 -0
  45. package/dist/video-engine/adapters/AudioManager.d.ts +9 -0
  46. package/dist/video-engine/adapters/MediablesCompositionAdapter.d.ts +3 -0
  47. package/dist/video-engine/adapters/TextOverlayManager.d.ts +4 -2
  48. package/package.json +1 -1
  49. package/dist/PixiFrameExporter-CqKXaoCX.cjs +0 -2
  50. package/dist/index-DNo3Kr1t.cjs +0 -342
  51. package/dist/index-DNo3Kr1t.cjs.map +0 -1
  52. package/dist/index-DpkdpuMs.js +0 -29327
  53. package/dist/index-DpkdpuMs.js.map +0 -1
@@ -1,342 +0,0 @@
1
- "use strict";var ym=Object.defineProperty;var bm=(o,n,t)=>n in o?ym(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var J=(o,n,t)=>bm(o,typeof n!="symbol"?n+"":n,t);const Ho=require("pinia"),e=require("vue"),qe=require("pixi.js"),re=require("./editor-BTwIhrcA.cjs"),U=require("@ionic/vue"),wm=require("pixi-filters");function km(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const st=km(qe),pr=1,_m=new Set(["free","square","circle"]);function Em(o){const n=typeof o;return n==="string"||n==="number"||n==="boolean"}function xm(o){if(!o||typeof o!="object")return!1;const n=o;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Zr(o){if(!o||typeof o!="object")return null;const n=o;if(n.version!==pr)return null;const t=n.crop,a=t&&xm(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&_m.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,l=[];if(Array.isArray(s))for(const c of s){if(!c||typeof c!="object")continue;const d=c;if(typeof d.id!="string")continue;const u={},m=d.values;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[h,p]of Object.entries(m))Em(p)&&(u[h]=p);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:pr,crop:{rect:a,aspectRatio:r,shape:i},filters:l}}function rc(o){const n=Zr(o);return n?JSON.stringify(n):null}function Cm(o){try{const n=JSON.parse(o);return Zr(n)}catch{return null}}function Sm(){return{version:pr,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Dt={apiBaseUrl:"/api/v1",isAdmin:!1};function na(o){Dt={...Dt,...o}}function sc(){return{...Dt}}function lc(o){Dt={...o}}function cc(o){const n=sc();return na(o),()=>{lc(n)}}const Vm=async(o,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),a={Accept:"application/json",...n.headers};t&&(a["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(a["Content-Type"]="application/json");const r={method:n.method||"GET",headers:a,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(o,r);if(!s.ok){const c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},$t=Ho.defineStore("media",()=>{const o=e.ref([]),n=e.ref([]),t=e.ref(!1),a=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),m=e.ref(new Map),h=e.ref(new Map),p=e.ref(new Set),v=e.ref(new Map),g=e.ref({}),w=5*60*1e3,M=e.computed(()=>{if(Dt.apiScope)return Dt.apiScope;if(Dt.isAdmin)return"admin"}),V=e.computed(()=>M.value==="admin");function b(){return Dt.httpClient||Vm}function f(se){const fe=Dt.apiBaseUrl||"/api/v1",xe=M.value?`/${M.value}`:"";return`${fe}${xe}${se}`}function _(se,fe){return`${M.value??"default"}-${se}-${JSON.stringify(fe)}`}function D(se){return Date.now()-se<w}function B(){v.value.clear(),g.value={}}function E(se){if(!se||!se.data)return;const fe={};se.data.forEach(xe=>{const le=`${xe.file_name}-${xe.collection_name||"default"}`,de=fe[le];(!de||Object.keys(xe.generated_conversions||{}).length>Object.keys(de.generated_conversions||{}).length)&&(fe[le]=xe)}),o.value=Object.values(fe),se.meta&&(i.value=se.meta.current_page,r.value=Math.ceil(se.meta.total/se.meta.per_page))}async function S(se=1,fe={}){const xe=_(se,fe),le=v.value.get(xe);if(le&&D(le.timestamp)){const de=le.data;return E(de),de}t.value=!0,a.value=null;try{const de=new URLSearchParams;de.append("page",se.toString()),de.append("per_page",s.value.toString()),V.value&&de.append("linked","1");for(const dt in fe)if(Object.prototype.hasOwnProperty.call(fe,dt)){const Ke=fe[dt];Ke!=null&&Ke!==""&&de.append(dt,String(Ke))}const Be=await b()(f(`/media?${de}`));return v.value.set(xe,{data:Be,timestamp:Date.now()}),E(Be),Be}catch(de){throw a.value=de instanceof Error?de.message:"Failed to fetch media",o.value=[],new Error(a.value)}finally{t.value=!1}}async function P(se,fe){t.value=!0,a.value=null;const xe=`${se.name}-${Date.now()}`,le={file:se,progress:0,status:"uploading"};m.value.set(xe,le);try{const de=new FormData;de.append("file",se),de.append("collection",fe.collection),fe.ownerUuid&&(de.append("owner_uuid",fe.ownerUuid),de.append("owner_type",fe.ownerType||"")),fe.usageUuid&&(de.append("usage_uuid",fe.usageUuid),de.append("usage_type",fe.usageType||""),de.append("usage_purpose",fe.usagePurpose||"")),fe.customProperties&&de.append("custom_properties",JSON.stringify(fe.customProperties));const Be=await b()(f("/media"),{method:"POST",body:de});return le.status="completed",le.progress=100,le.media=Be==null?void 0:Be.data,i.value===1&&(Be!=null&&Be.data)&&(o.value=[Be.data,...o.value]),B(),(Be==null?void 0:Be.data)||null}catch(de){throw le.status="error",le.error=de instanceof Error?de.message:"Upload failed",a.value=le.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(xe)},5e3)}}async function C(se){t.value=!0,a.value=null;const fe=o.value.findIndex(le=>le.uuid===se);let xe;fe!==-1&&(xe=o.value.splice(fe,1)[0]);try{return await b()(f(`/media/${se}`),{method:"DELETE"}),p.value.delete(se),B(),!0}catch(le){throw xe&&fe!==-1&&o.value.splice(fe,0,xe),a.value=le instanceof Error?le.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function A(se,fe){t.value=!0,a.value=null;try{const le=await b()(f(`/media/${se}`),{method:"PATCH",body:fe,data:fe});if(le!=null&&le.data){const de=o.value.findIndex(Ve=>Ve.uuid===se);return de!==-1&&(o.value[de]={...o.value[de],...le.data}),B(),le.data}return null}catch(xe){throw a.value=xe instanceof Error?xe.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function R(){t.value=!0,a.value=null;try{const fe=await b()(f("/media/collections"));return n.value=(fe==null?void 0:fe.data)||[],n.value}catch(se){throw a.value=se instanceof Error?se.message:"Failed to fetch collections",n.value=[],new Error(a.value)}finally{t.value=!1}}async function W(se,fe,xe="images",le){d.value=!0,u.value=null;try{const de=new URLSearchParams;de.append("collection",xe),le&&de.append("search",le);const Be=await b()(f(`/media/model/${se}/${fe}?${de}`));return Be!=null&&Be.data?(c.value=Be.data,Be.data):[]}catch(de){throw u.value=de instanceof Error?de.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function O(se,fe,xe,le="images"){d.value=!0,u.value=null;const de=[...c.value];try{const Be=await b()(f(`/media/model/${se}/${fe}/attach`),{method:"POST",body:{media_uuids:xe,collection:le}});return await W(se,fe,le),(Be==null?void 0:Be.data)||[]}catch(Ve){throw c.value=de,u.value=Ve instanceof Error?Ve.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function I(se,fe,xe,le="images"){d.value=!0,u.value=null;const de=[...c.value];c.value=c.value.filter(Ve=>Ve.uuid!==xe);try{return await b()(f(`/media/model/${se}/${fe}/detach`),{method:"POST",body:{media_uuid:xe,collection:le}}),!0}catch(Ve){throw c.value=de,u.value=Ve instanceof Error?Ve.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function F(se,fe,xe,le="images"){d.value=!0,u.value=null;const de=[...c.value],Ve=new Map(c.value.map(Be=>[Be.uuid,Be]));c.value=xe.map(Be=>Ve.get(Be)).filter(Be=>Be!==void 0);try{return await b()(f(`/media/model/${se}/${fe}/reorder`),{method:"POST",body:{media_uuids:xe,collection:le}}),!0}catch(Be){throw c.value=de,u.value=Be instanceof Error?Be.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function k(se,fe,xe={}){const le=b(),de=Dt.apiBaseUrl||"/api/v1",Ve=new FormData,Be=fe.imageData,dt=Be.match(/^data:(image\/\w+);base64,/),Ke=dt?dt[1]:"image/png",bt=Be.replace(/^data:image\/\w+;base64,/,""),et=atob(bt),at=new Uint8Array(et.length);for(let vt=0;vt<et.length;vt++)at[vt]=et.charCodeAt(vt);const wt=new Blob([at],{type:Ke});Ve.append("image_file",wt,`edited.${Ke==="image/jpeg"?"jpg":"png"}`);const Vt=rc(fe.state);Vt&&Ve.append("editor_state",Vt),fe.metadata&&(Ve.append("filters",JSON.stringify(fe.metadata.filters)),fe.metadata.cropRect&&Ve.append("crop_data",JSON.stringify(fe.metadata.cropRect))),Ve.append("save_as_new","true"),xe.asVariant&&Ve.append("as_variant","true"),xe.name!==void 0&&Ve.append("name",xe.name);const rt=await le(`${de}/editor/${se}/save`,{method:"POST",body:Ve});if("media"in rt&&rt.media)return rt.media;if("status_url"in rt&&rt.status_url)return $(le,rt.status_url,xe.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function $(se,fe,xe){const le=Date.now(),de=2e3;for(;Date.now()-le<xe;){await new Promise(Be=>setTimeout(Be,de));const Ve=await se(fe);if(Ve.status==="completed"&&Ve.media)return Ve.media;if(Ve.status==="failed")throw new Error(Ve.error??"Image processing failed")}throw new Error("Image processing timed out")}function j(se,fe,xe){l.value=xe!==void 0?{type:se,uuid:fe,collection:xe}:{type:se,uuid:fe},g.value[`${se}-${fe}`]={timestamp:Date.now()}}function Z(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function K(){if(!l.value.type||!l.value.uuid)return;const se=await W(l.value.type,l.value.uuid,l.value.collection||"images");c.value=se||[]}function ge(){o.value.forEach(se=>p.value.add(se.uuid))}function we(){p.value.clear()}function ne(se){p.value.has(se)?p.value.delete(se):p.value.add(se)}function N(se){return p.value.has(se)}function L(){return Array.from(m.value.values()).some(se=>se.status==="uploading")}function te(se){return m.value.get(se)||h.value.get(se)}function ae(){return[...Array.from(m.value.values()),...Array.from(h.value.values())]}async function ie(){const se=Array.from(p.value);let fe=0;for(const xe of se)try{await C(xe),fe++}catch{}return we(),fe}function he(se,fe){var xe;return fe&&((xe=se.conversion_urls)!=null&&xe[fe])?se.conversion_urls[fe]||"":se.original_url||se.url||""}return{items:o,collections:n,loading:t,error:a,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:V,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:h,cachedResponses:g,fetchMedia:S,uploadFile:P,deleteMedia:C,updateMedia:A,clearCache:B,fetchCollections:R,fetchModelMedia:W,attachMedia:O,detachMedia:I,reorderMedia:F,saveEditedImage:k,setModelContext:j,clearModelContext:Z,refreshModelMedia:K,selectAllItems:ge,clearSelection:we,toggleSelection:ne,isSelected:N,deleteSelectedItems:ie,getHttpClient:b,getApiUrl:f,hasActiveUploads:L,getUploadProgress:te,getAllUploadProgress:ae,getMediaUrl:he}}),dc=()=>((Dt.apiScope!=="admin"||Dt.isAdmin!==!0)&&na({...Dt,apiScope:"admin",isAdmin:!0}),$t());class uc{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=re.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),re.EDITOR_CATEGORIES.forEach(t=>{const a=re.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=re.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,a.appendChild(i)}a.appendChild(re.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,a),this.element.appendChild(a)}),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 a;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(),(a=this._onSelect)==null||a.call(this,n)}_refreshActive(){this._tabs.forEach((n,t)=>{const a=this._isSelected(t);n.classList.toggle("active",a),n.setAttribute("aria-selected",a?"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 mc{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=re.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),a=this.state.get("activeFilters"),i=this.state.get("selectedFilter");t.forEach(r=>{var c;const s=((c=a==null?void 0:a.has)==null?void 0:c.call(a,r.id))??!1,l=i===r.id;this.element.appendChild(this._renderRow(r,s,l))})}_renderRow(n,t,a){const i=re.el("button",{type:"button",className:`filter-row ${a?"selected":""}`,role:"option","aria-selected":a?"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=re.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 m,h,p,v;d.stopPropagation();const u=!((h=(m=this.state.get("activeFilters"))==null?void 0:m.has)!=null&&h.call(m,n.id));(p=this._onToggle)==null||p.call(this,n.id,u),u&&((v=this._onSelect)==null||v.call(this,n.id))}});t&&(r.innerHTML=re.checkmark),i.appendChild(r);const s=re.el("div",{className:"filter-row-body"});s.appendChild(re.el("span",{className:"filter-row-name"},n.name));const l=this._buildSummary(n,t);l&&s.appendChild(re.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const c=re.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=re.chevronRight,i.appendChild(c),i}_buildSummary(n,t){if(!t)return n.description||"";const a=this.state.getFilterValues(n.id);if(!a||Object.keys(a).length===0)return n.description||"Active";const i=[];for(const r of(n.controls||[]).slice(0,4)){const s=a[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),a=this.state.get("activeFilters");for(const r of t){const s=this.element.querySelector(`[data-filter="${r.id}"]`);if(!s)continue;const l=((i=a==null?void 0:a.has)==null?void 0:i.call(a,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(re.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 pc{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:a}={}){return this._onChange=n,this._onReset=t,this._onAction=a,this.element=re.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(re.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(n);if(!t){this.element.appendChild(re.el("div",{className:"no-filter-selected"},"Filter not found"));return}const a=re.el("div",{className:"controls-header"});a.appendChild(re.el("span",{className:"controls-title"},t.name)),a.appendChild(re.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(n)})),this.element.appendChild(a);const i=re.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,m=this._createControl(n,c,u);m&&i.appendChild(m)})}this.element.appendChild(i)}_createControl(n,t,a){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 re.createSlider({id:`v2-${n}-${t.id}`,label:i,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof a=="number"?a:t.default??0,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"toggle":return re.createToggle({id:`v2-${n}-${t.id}`,label:i,checked:!!a,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"color":return re.createColorPicker({id:`v2-${n}-${t.id}`,label:i,value:typeof a=="string"&&a.startsWith("#")?a: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 re.createSelect({id:`v2-${n}-${t.id}`,label:i,options:l,value:a??t.default,onChange:c=>{var d;return(d=this._onChange)==null?void 0:d.call(this,n,s,c)}})}case"text":return re.createTextInput({id:`v2-${n}-${t.id}`,label:i,value:typeof a=="string"?a: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=re.el("div",{className:"button-control"});return l.appendChild(re.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 Nm{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:a}={}){return this._onRemove=n,this._onSelect=t,this._onClearAll=a,this.element=re.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,a=re.el("div",{className:"panel-section-title"});if(a.appendChild(re.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&a.appendChild(re.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(a),t===0){this.element.appendChild(re.el("div",{className:"active-empty"},"No filters applied"));return}const i=re.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 a=re.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-active-${n.id}`});a.appendChild(re.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=re.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=re.close,a.appendChild(i),a}_refreshSelection(){var a;const n=this.state.get("selectedFilter"),t=(a=this.element)==null?void 0:a.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 Yn=["collapsed","half","full"];class Tm{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=re.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=re.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 a=re.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(a),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=re.el("div",{className:"drawer-header"}),n&&this._headerSlot.appendChild(n),this.element.appendChild(this._headerSlot),this._body=re.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={}){Yn.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,a,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=(a=this._handle)==null?void 0:a.setPointerCapture)==null||i.call(a,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,a=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),s=Math.max(i,Math.min(r,a));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,a=this._nearestSnap(t);this._applySnap(a,{animate:!0})}_cycleSnap(){const n=Yn.indexOf(this._snap),t=Yn[(n+1)%Yn.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=Yn[0],a=1/0;for(const i of Yn){const r=this._heightForSnap(i),s=Math.abs(r-n);s<a&&(a=s,t=i)}return t}_applySnap(n,{animate:t}){var r,s;if(!this.element)return;const a=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!==a&&((s=this._onSnapChange)==null||s.call(this,n,a))}destroy(){var n;(n=this.element)==null||n.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}class Mm{constructor(n,t,a){this.state=n,this.filterManager=t,this.editor=a,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=re.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=re.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=re.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 uc(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new mc(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 pc(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(n,t,a)=>this._callbacks.onFilterChange(n,t,a),onReset:n=>this._callbacks.onFilterReset(n),onAction:(n,t)=>this._callbacks.onFilterAction(n,t)})}navigateTo(n){var a;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),(a=this._onNavigate)==null||a.call(this,n)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const a=re.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});a.innerHTML=re.chevronLeft,this._headerEl.appendChild(a)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(re.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const a=this.state.get("selectedFilter");a&&this._headerEl.appendChild(re.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(a)}))}}_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"),a=t?this.filterManager.getFilterDef(t):null;return(a==null?void 0:a.name)||"Filter"}default:return""}}_categoryLabel(n){var t;return n&&((t=re.EDITOR_CATEGORIES.find(a=>a.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,a,i;this._unsubscribers.forEach(r=>r()),this._unsubscribers=[],(n=this._categoryTabs)==null||n.destroy(),(t=this._filterListView)==null||t.destroy(),(a=this._filterControlsView)==null||a.destroy(),(i=this.element)==null||i.remove(),this.element=null}}class Bm{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=re.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 a=re.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter");for(const r of n){const s=this.filterManager.getFilterDef(r);s&&a.appendChild(this._renderChip(s,r===i))}this.element.appendChild(a)}_renderChip(n,t){const a=re.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-mobile-chip-${n.id}`});a.appendChild(re.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=re.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=re.close,a.appendChild(i),a}_refreshSelection(){var a;const n=this.state.get("selectedFilter"),t=(a=this.element)==null?void 0:a.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 ol="(max-width: 900px)";let Fm=class{constructor(n,t,a){this.state=n,this.filterManager=t,this.editor=a,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=re.el("div",{className:"editor-v2-body"}),this.canvasSection=re.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=re.el("div",{className:"canvas-container"}),this.cropOverlay=re.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,ol).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(ol),this._mqlHandler=a=>this._handleBreakpointChange(a.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:a})=>this._applyMode(a))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(n){this._cropControlsEl=n,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=re.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new uc(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const n=re.el("div",{className:"panel-body"});this._desktopFilterListSection=re.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(re.el("div",{className:"panel-section-title"},re.el("span",{},"Filters"))),this._filterListView=new mc(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,a)=>this._callbacks.onFilterToggle(t,a),onSelect:t=>this._callbacks.onFilterSelect(t)})),n.appendChild(this._desktopFilterListSection),this._filterControlsView=new pc(this.state,this.filterManager),n.appendChild(this._filterControlsView.render({onChange:(t,a,i)=>this._callbacks.onFilterChange(t,a,i),onReset:t=>this._callbacks.onFilterReset(t),onAction:(t,a)=>this._callbacks.onFilterAction(t,a)})),this._desktopCropWrapper=re.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),n.appendChild(this._desktopCropWrapper),this._activeStack=new Nm(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,a;return(a=(t=this._callbacks).onClearAll)==null?void 0:a.call(t)}})),this._panel.appendChild(n),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new Bm(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 Tm({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new Mm(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=re.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const a=re.el("div",{className:"drawer-content"});a.appendChild(t),a.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:a});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,a,i,r,s,l;(n=this._categoryTabs)==null||n.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(a=this._filterControlsView)==null||a.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,a,i,r;(n=this._resizeObserver)==null||n.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(a=this._mobileChips)==null||a.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 a,i,r;const t=n==="crop";this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t?"none":""),(a=this._filterControlsView)!=null&&a.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 Im extends re.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 a=t.preset?re.getPreset(t.preset):null,i=a?{initialMode:a.initialMode==="crop"?"crop":"adjust",cropShape:a.cropShape,initialAspectRatio:a.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=a,this._state=re.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 re.PixiRenderer,this._filterManager=new re.FilterManager(this._state,this._renderer),this._cropManager=new re.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new re.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=re.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=re.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new Fm(this._state,this._filterManager,this);const{root:n,canvasContainer:t,cropOverlay:a}=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=a,this._editorEl.appendChild(n),this._fileInput=re.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 re.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new re.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,a;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((a=(t=this._cropManager).drawOverlay)==null||a.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,a;(t=this._editorEl)==null||t.classList.toggle("dark",n),(a=this._editorEl)==null||a.classList.toggle("light",!n)})}async _handleFileSelect(n){var a;const t=(a=n.target.files)==null?void 0:a[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 a=this._filterManager.getFilterDef(n);if(typeof(a==null?void 0:a.category)=="string"){const r=re.REGISTRY_TO_UI[a.category]||a.category;this._state.get("selectedCategory")!==r&&this._state.set("selectedCategory",r)}}_handleFilterChange(n,t,a){this._filterManager.updateValue(n,t,a)||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 a=++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!==a)){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",a=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",a)),this._state.set("crop.shape",t),this._state.set("crop.aspect",a)}if(Array.isArray(n.filters)){let t=null;for(const a of n.filters)if(a.enabled&&(t===null&&(t=a.id),this._state.toggleFilter(a.id,!0),this._filterManager.initializeValues(a.id),a.values))for(const[i,r]of Object.entries(a.values))this._state.setFilterValue(a.id,i,r);if(t!==null){this._state.set("selectedFilter",t);const a=this._filterManager.getFilterDef(t);if(typeof(a==null?void 0:a.category)=="string"){const i=re.REGISTRY_TO_UI[a.category]??a.category;this._state.set("selectedCategory",i)}}this._filterManager.applyFilters()}}}openFilePicker(){var n;(n=this._fileInput)==null||n.click()}exportImage(n="png",t=.92,a={}){return this._state.get("crop.rect")&&!this._cropManager.apply()?null:this._renderer.exportImage(n,t,a.maxEdge??0,a.dontUpscale!==!1,a.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,a={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:a,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 a=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=a||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 a=await this._removeBgManager.removeBackground(t,n);return await this.loadImage(a.dataUrl),this.emit("background-removed",{model:a.model,processMs:a.processMs}),{model:a.model,processMs:a.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 a;if(!this._loadingOverlay)this._loadingOverlay=re.el("div",{className:"editor-loading-overlay"},re.el("div",{className:"editor-loading-spinner"}),re.el("div",{className:"editor-loading-text"},n));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=n)}const t=(a=this._canvasContainer)==null?void 0:a.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var n;(n=this._loadingOverlay)==null||n.remove()}destroy(){var n,t,a,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(),(a=this._cropControls)==null||a.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 $m(o,n){try{let t=re.getFilter(o);if(t||(re.registerCorePixiFilters(),t=re.getFilter(o)),!t){try{const r=re.getAllFilters()}catch{}return null}const a={...t.defaultParams,...n};return t.createFilter(a)}catch{return null}}const Xi=78e5,Rm=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(o,{emit:n}){const t=o,a=n,i=e.ref(null);let r=null,s=null;function l(){var b;if(!r){a("error",new Error("Editor not initialized"));return}const m=r.exportImage("png",.92,{maxPixels:Xi});if(!m){a("error",new Error("Failed to export image — the image could not be processed"));return}const h=r.getSerializableState(),p=r._renderer,v=((b=p==null?void 0:p.getExportDimensions)==null?void 0:b.call(p))??{width:0,height:0},g=v.width*v.height,w=g>Xi?Math.sqrt(Xi/Math.max(1,g)):1,M={width:Math.max(1,Math.floor(v.width*w)),height:Math.max(1,Math.floor(v.height*w))};a("save",{imageData:m,dimensions:M,state:h})}function c(){a("cancel")}function d(){if(!i.value||r)return;window.PIXI=st,re.initializeFilterRegistry();const m={theme:t.theme};t.preset&&(m.preset=t.preset),t.preset?t.cropShape==="circle"&&(m.cropShape="circle",m.initialAspectRatio="1:1",m.initialMode="crop"):(m.cropShape=t.cropShape==="circle"?"circle":"free",m.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",m.initialMode=t.cropShape==="circle"?"crop":"adjust");const h=t.editorVersion==="v2"?Im:re.VanillaImageEditor;r=new h(i.value,m),r.setFilterRegistry({getAllFilters:re.getAllFilters,getFilter:re.getFilter,getFiltersByCategory:re.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",c),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(m=>{const h=m[0];h&&h.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))});const u=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})};return e.watch(()=>t.initialImage,(m,h)=>{!r||!m||m===h||u()}),e.watch(()=>t.sessionKey,(m,h)=>{m!==h&&u()}),e.watch(()=>t.initialState,(m,h)=>{m!==h&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(m,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Me=(o,n)=>{const t=o.__vccOpts||o;for(const[a,i]of n)t[a]=i;return t},fc=Me(Rm,[["__scopeId","data-v-24c46711"]]),Dm={class:"editor-modal-panel"},Am={class:"editor-fill"},Lm=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(o,{emit:n}){const t=o,a=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=g=>{a("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,a("save",g)}catch(w){c(w)}finally{s.value=!1}},m=()=>{a("cancel"),p()},h=()=>{s.value||p()},p=()=>{r.value=!1,a("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},v=g=>{if(g.key==="Escape"&&r.value&&!s.value){p();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 M=w[0],V=w[w.length-1];g.shiftKey&&document.activeElement===M?(g.preventDefault(),V.focus()):!g.shiftKey&&document.activeElement===V&&(g.preventDefault(),M.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(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(h,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:h}),e.createElementVNode("div",Dm,[e.createElementVNode("div",Am,[e.createVNode(fc,{"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:m,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)]))}}),hc=Me(Lm,[["__scopeId","data-v-adf95668"]]),Um={class:"media-workspace"},Om={class:"media-workspace-toolbar"},Pm={class:"media-workspace-label"},zm=["value"],jm={class:"media-workspace-grid"},Wm=["onClick"],Zm=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(o,{emit:n}){var m;const t=o,a=n,i=$t(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(h=>h.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=cc({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const h={};(p=l.value)!=null&&p.collection&&(h.collection=l.value.collection),await i.fetchMedia(1,h),a("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,h=>{h&&h!==r.value&&(r.value=h)}),e.watch(()=>t.subScopes,h=>{if(h.length===0){r.value="";return}h.some(p=>p.id===r.value)||(r.value=h[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,h=>{h&&(a("scope-change",h),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(h,p)=>(e.openBlock(),e.createElementBlock("div",Um,[e.createElementVNode("div",Om,[e.createElementVNode("label",Pm,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=v=>r.value=v),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,v=>(e.openBlock(),e.createElementBlock("option",{key:v.id,value:v.id},e.toDisplayString(v.label),9,zm))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=v=>a("upload"))}," Upload ")]),e.createElementVNode("div",jm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:g=>a("preview",v)},e.toDisplayString(v.file_name),9,Wm))),128))])]))}}),Hm=Me(Zm,[["__scopeId","data-v-895f26fe"]]),Xm={class:"managed-media-gallery"},Gm={class:"gallery-grid"},Jm=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(o){return(n,t)=>(e.openBlock(),e.createElementBlock("div",Xm,[e.createElementVNode("div",Gm,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Ym=Me(Jm,[["__scopeId","data-v-a60fdcd7"]]),qm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 176v160M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Hr="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>",Km="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>",Xr="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>",Qm="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>",ep="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>",xa="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>",tp="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>",vc="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>",gc="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>",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' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",np="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>",ap="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>",rl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Rn="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>",sl="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>",op="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>",yn="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>",ip="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>",ya="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>",rp="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>",sp="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>",ll="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>",yc="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>",aa="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>",lp="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>",cp="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>",dp="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>",Ca="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>",cl="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>",Gi="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>",up="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>",mp="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>",Ji="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>",pp="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>",fp="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>",hp="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>",vp="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>",bc="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>",Gr="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>",gp="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>",yp="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>",bp="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>",wp="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>",wc="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>",kp="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>",_p="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>",Jr="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>",Ep="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>",xp="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>",Un="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>",Cp="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>",Sp="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Xo="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>",Vp="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>",Yi="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>",gn="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>",ba="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>",ul="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Np="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='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>",kc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M32 415.5l120-320 120 320M230 303.5H74M326 239.5c12.19-28.69 41-48 74-48h0c46 0 80 32 80 80v144' class='ionicon-fill-none ionicon-stroke-width'/><path d='M320 358.5c0 36 26.86 58 60 58 54 0 100-27 100-106v-15c-20 0-58 1-92 5-32.77 3.86-68 19-68 58z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Tp="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M80 112h352' class='ionicon-stroke-width'/><path d='M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",_c="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>",Mp="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>",Bp="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>",Fp="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M264 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H88a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01288 119.83v272.34a24 24 0 01-24 24zM352 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C378.2 208.16 384 231.47 384 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01352 336z'/><path d='M400 384a16 16 0 01-13.87-24C405 327.05 416 299.45 416 256c0-44.12-10.94-71.52-29.83-103.95A16 16 0 01413.83 136C434.92 172.16 448 204.88 448 256c0 50.36-13.06 83.24-34.12 120a16 16 0 01-13.88 8z'/></svg>",Ip="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M157.65 192H88a8 8 0 00-8 8v112a8 8 0 008 8h69.65a16 16 0 0110.14 3.63l91.47 75a8 8 0 0012.74-6.46V119.83a8 8 0 00-12.74-6.44l-91.47 75a16 16 0 01-10.14 3.61zM352 320c9.74-19.41 16-40.81 16-64 0-23.51-6-44.4-16-64M400 368c19.48-34 32-64 32-112s-12-77.7-32-112' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",$p="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>",Rp="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='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>",Dp="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>",co="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 ml=()=>{};function Ap(o,n){function t(...a){return new Promise((i,r)=>{Promise.resolve(o(()=>n.apply(this,a),{fn:n,thisArg:this,args:a})).then(i).catch(r)})}return t}function Lp(o,n={}){let t,a,i=ml;const r=c=>{clearTimeout(c),i(),i=ml};let s;return c=>{const d=e.toValue(o),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(a&&(r(a),a=null),Promise.resolve(c())):new Promise((m,h)=>{i=n.rejectOnCancel?h:m,s=c,u&&!a&&(a=setTimeout(()=>{t&&r(t),a=null,m(s())},u)),t=setTimeout(()=>{a&&r(a),a=null,m(c())},d)})}}function Up(o,n=200,t={}){return Ap(Lp(n,t),o)}const wa=new Map;function Op(o){const n=e.getCurrentScope();function t(l){var c;const d=wa.get(o)||new Set;d.add(l),wa.set(o,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function a(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=wa.get(o);c&&(c.delete(l),c.size||r())}function r(){wa.delete(o)}function s(l,c){var d;(d=wa.get(o))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:i,emit:s,reset:r}}function Ec(){var r,s;const o=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(o)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(o)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(o)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(o)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 xc(o){const n=e.ref(new Set),t=e.ref(null),a=e.ref(-1),i=Op("media-selection"),r=Ec(),s=e.computed(()=>o.value.filter(_=>n.value.has(_.uuid))),l=e.computed(()=>n.value.size);e.watch(n,_=>{i.emit({type:"selection:changed",count:_.size,selectedIds:Array.from(_)})},{deep:!0});const c=e.computed(()=>o.value.length>0&&o.value.every(_=>n.value.has(_.uuid))),d=e.computed(()=>o.value.some(_=>n.value.has(_.uuid)));function u(_){return n.value.has(_)}function m(_){n.value.has(_)?(n.value.delete(_),t.value===_&&(t.value=null,a.value=-1)):(n.value.add(_),t.value=_,a.value=o.value.findIndex(D=>D.uuid===_),n.value.size===1&&r.selection())}function h(_){n.value.add(_),t.value=_,a.value=o.value.findIndex(D=>D.uuid===_)}function p(_){n.value.delete(_),t.value===_&&(t.value=null,a.value=-1)}function v(){o.value.forEach(_=>n.value.add(_.uuid))}function g(){n.value.clear(),t.value=null,a.value=-1}function w(){c.value?g():v()}function M(_,D){const B=o.value.findIndex(E=>E.uuid===_);if(B!==-1)if(D!=null&&D.shiftKey&&a.value!==-1){const E=Math.min(a.value,B),S=Math.max(a.value,B);for(let P=E;P<=S;P++)n.value.add(o.value[P].uuid)}else m(_)}function V(){if(o.value.length===0)return;let _=a.value+1;_>=o.value.length&&(_=0),g(),h(o.value[_].uuid)}function b(){if(o.value.length===0)return;let _=a.value-1;_<0&&(_=o.value.length-1),g(),h(o.value[_].uuid)}function f(_){switch(_.key){case"ArrowDown":_.preventDefault(),V();break;case"ArrowUp":_.preventDefault(),b();break;case"a":(_.ctrlKey||_.metaKey)&&(_.preventDefault(),v());break;case"Escape":_.preventDefault(),g();break;case" ":t.value&&(_.preventDefault(),m(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:m,select:h,deselect:p,selectAll:v,clear:g,toggleAll:w,rangeSelect:M,selectNext:V,selectPrevious:b,handleKeydown:f,selectionBus:i}}const Pp={class:"flex items-center justify-between w-full px-4"},zp={class:"p-4"},jp={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Wp={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Zp=["value"],Hp={class:"flex gap-2 mt-4"},Xp={class:"flex justify-end mb-4"},Gp={key:1,class:"flex justify-center items-center h-64"},Jp={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Yp={class:"text-sm text-theme-secondary"},qp={key:0},Kp={class:"mb-4"},Qp={class:"mb-4"},ef={class:"flex gap-2"},tf={class:"flex items-center justify-between px-4 py-2"},nf={class:"text-sm text-theme-secondary"},af={key:0},of={key:0},rf={key:1},sf={class:"flex gap-2"},lf=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(o,{emit:n}){const t=o,a=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),m=e.ref(!1),h=e.ref({}),p=e.ref(["images","documents","videos"]),v=e.ref(1),g=e.ref(!0),w=e.ref(!1),M=dc(),V=xc(c);function b(N){var fe;const L=N.conversion_urls||{},te=N.proxy_url||N.original_url||N.url||"",ae=L.thumb||L.preview||N.preview_url||N.thumbnail_url||te,ie=N.custom_properties||{},he=ie.width,se=ie.height;return{...N,uuid:N.uuid,name:N.name||N.file_name,file_name:N.file_name,filename:N.file_name,mime_type:N.mime_type,size:N.size,collection_name:N.collection_name||"images",disk:N.disk,original_url:te,url:te,thumbnail_url:ae,conversions:N.conversions||{},conversion_urls:L,generated_conversions:N.generated_conversions||{},custom_properties:ie,caption:N.caption||null,alt_text:N.alt_text||null,created_at:N.created_at,updated_at:N.updated_at,is_image:((fe=N.mime_type)==null?void 0:fe.startsWith("image/"))||!1,...typeof he=="number"?{width:he}:{},...typeof se=="number"?{height:se}:{},...N.formatted_size!==void 0?{formatted_size:N.formatted_size}:{}}}e.watch(()=>t.selectedItems,N=>{u.value=new Set(N),V.clear(),N.forEach(L=>V.select(L))});const f=e.computed(()=>{var L;let N=c.value;return(L=h.value.types)!=null&&L.length&&(N=N.filter(te=>{var ie,he;const ae=(ie=te.mime_type)==null?void 0:ie.split("/")[0];return(he=h.value.types)==null?void 0:he.includes(ae)})),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&(N=N.filter(te=>{const ae=te.size/1048576;return!(h.value.sizeMin!==void 0&&ae<h.value.sizeMin||h.value.sizeMax!==void 0&&ae>h.value.sizeMax)})),N}),_=e.computed(()=>{var L;let N=0;return h.value.search&&N++,h.value.collection&&N++,(h.value.dateFrom||h.value.dateTo)&&N++,(L=h.value.types)!=null&&L.length&&(N+=h.value.types.length),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&N++,N}),D=e.computed(()=>{const N=V.selectedCount.value;return N===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${N} ${N===1?"Item":"Items"}`:"Item"}`}),B=e.computed(()=>{const N=V.selectedCount.value;return!!(N===0||t.selectionMode==="single"&&N>1||t.maxSelection&&N>t.maxSelection)}),E=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function S(N=!0){N?(l.value=!0,c.value=[],v.value=1,g.value=!0):w.value=!0;try{const L={collection:h.value.collection||t.collection,per_page:24};switch((s.value||h.value.search)&&(L.search=s.value||h.value.search||""),h.value.dateFrom&&(L.from_date=h.value.dateFrom),h.value.dateTo&&(L.to_date=h.value.dateTo),i.value){case"recent":await M.fetchMedia(v.value,L),N?c.value=M.items.map(te=>b(te)):c.value=[...c.value,...M.items.map(te=>b(te))],g.value=M.currentPage<M.totalPages;break;case"model":if(t.modelType&&t.modelId){const te=await M.fetchModelMedia(t.modelType,t.modelId,L.collection,L.search);c.value=te?te.map(ae=>b(ae)):[],g.value=!1}break;case"library":await M.fetchMedia(v.value,L),N?c.value=M.items.map(te=>b(te)):c.value=[...c.value,...M.items.map(te=>b(te))],g.value=M.currentPage<M.totalPages;break}}catch{}finally{l.value=!1,w.value=!1}}async function P(N){if(!g.value||w.value){N!=null&&N.target&&N.target.complete();return}v.value++,await S(!1),N!=null&&N.target&&(N.target.complete(),g.value||(N.target.disabled=!0))}function C(N){return N==="recent"||N==="model"||N==="library"}function A(N){i.value=N,S()}function R(N){typeof N=="string"&&C(N)&&A(N)}async function W(N){t.selectionMode==="single"?(V.clear(),V.select(N.uuid)):(V.toggle(N.uuid),t.maxSelection&&V.selectedCount.value>t.maxSelection&&(V.deselect(N.uuid),await(await U.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function O(){a("confirm",V.selectedItems.value)}function I(){a("close")}function F(N){}const k=e.ref(null),$=e.ref(!1);function j(N){k.value=N,$.value=!0}function Z(N){const L=c.value.findIndex(ae=>ae.uuid===N.uuid);L!==-1&&(c.value[L]=N);const te={};N.alt_text!==void 0&&(te.alt_text=N.alt_text),N.caption!==void 0&&(te.caption=N.caption),N.custom_properties!==void 0&&(te.custom_properties=N.custom_properties),M.updateMedia(N.uuid,te)}function K(){S()}function ge(){h.value={},s.value="",S()}const we=Up(()=>{S(!0)},300);e.watch(s,()=>{t.isOpen&&we()});async function ne(N){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 M.deleteMedia(N),await S()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,N=>{N&&S()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(N=>V.select(N))}),(N,L)=>{const te=e.resolveComponent("AdminMediaGrid"),ae=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":N.isOpen,onDidDismiss:I,"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:I},{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(E.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Pp,[e.createVNode(e.unref(U.IonSegment),{value:i.value,onIonChange:L[0]||(L[0]=ie=>R(ie.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(()=>[...L[15]||(L[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(()=>[...L[16]||(L[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(()=>[...L[17]||(L[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(U.IonButton),{fill:"clear",size:"small",onClick:L[1]||(L[1]=ie=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[_.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(_.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",zp,[m.value?(e.openBlock(),e.createElementBlock("div",jp,[e.createElementVNode("div",Wp,[e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[18]||(L[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":L[2]||(L[2]=ie=>h.value.collection=ie),class:"w-full p-2 border rounded"},[L[19]||(L[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,ie=>(e.openBlock(),e.createElementBlock("option",{key:ie,value:ie},e.toDisplayString(ie),9,Zp))),128))],512),[[e.vModelSelect,h.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[20]||(L[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[3]||(L[3]=ie=>h.value.dateFrom=ie),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[21]||(L[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[4]||(L[4]=ie=>h.value.dateTo=ie),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateTo]])])]),e.createElementVNode("div",Hp,[e.createVNode(e.unref(U.IonButton),{size:"small",onClick:K},{default:e.withCtx(()=>[...L[22]||(L[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{size:"small",fill:"clear",onClick:ge},{default:e.withCtx(()=>[...L[23]||(L[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":L[5]||(L[5]=ie=>s.value=ie),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Xp,[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:L[6]||(L[6]=ie=>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:L[7]||(L[7]=ie=>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",Gp,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",Jp,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),L[24]||(L[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Yp,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(te,{key:3,"media-items":f.value,"selected-items":e.unref(V).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:W,onPreview:F,onEdit:j,onDelete:ne},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(f.value,(ie,he)=>(e.openBlock(),e.createBlock(ae,{key:ie.uuid,media:ie,selected:e.unref(V).isSelected(ie.uuid),"selection-mode":!0,index:he,onToggleSelect:W,onPreview:F,onEdit:j,onDelete:ne},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(U.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:L[8]||(L[8]=ie=>P(ie))},{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":$.value,onDidDismiss:L[14]||(L[14]=ie=>$.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:L[9]||(L[9]=ie=>$.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(()=>[...L[25]||(L[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",qp,[e.createElementVNode("div",Kp,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[26]||(L[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[10]||(L[10]=ie=>k.value.caption=ie),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,k.value.caption]])]),e.createElementVNode("div",Qp,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[27]||(L[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[11]||(L[11]=ie=>k.value.alt_text=ie),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",ef,[e.createVNode(e.unref(U.IonButton),{onClick:L[12]||(L[12]=ie=>Z(k.value))},{default:e.withCtx(()=>[...L[28]||(L[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:L[13]||(L[13]=ie=>$.value=!1)},{default:e.withCtx(()=>[...L[29]||(L[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",tf,[e.createElementVNode("div",nf,[e.unref(V).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",af,[e.createTextVNode(e.toDisplayString(e.unref(V).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",of," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",rf," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",sf,[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:I},{default:e.withCtx(()=>[...L[30]||(L[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{disabled:B.value,onClick:O},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),cf=Me(lf,[["__scopeId","data-v-9a8c0954"]]),df={key:1,class:"flex flex-col items-center justify-center py-16"},uf=["draggable","onDragstart","onDragover","onDrop"],mf={key:0,class:"absolute top-2 left-2 z-20"},pf=["checked","onChange"],ff={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},hf=["data-media-id"],vf={key:0,class:"w-full h-full flex items-center justify-center"},gf=["src","alt","onError","onLoad"],yf={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},bf={class:"text-center"},wf={class:"text-4xl text-gray-400 mb-2"},kf={class:"text-sm font-medium text-gray-500"},_f={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Ef=["onClick"],xf=["onClick"],Cf=["onClick"],Sf={class:"p-3"},Vf={class:"text-sm font-medium truncate mb-1"},Nf={class:"text-xs text-gray-600 dark:text-gray-400"},Tf={key:0},Mf={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Bf=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(o,{emit:n}){const t=o,a=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=B=>t.selectedItems.some(E=>E.uuid===B.uuid),d=e.computed(()=>{const B=t.columns,E=["grid","gap-4"];switch(B.mobile){case 1:E.push("grid-cols-1");break;case 2:E.push("grid-cols-2");break;case 3:E.push("grid-cols-3");break;case 4:E.push("grid-cols-4");break;default:E.push("grid-cols-2");break}switch(B.sm){case 1:E.push("sm:grid-cols-1");break;case 2:E.push("sm:grid-cols-2");break;case 3:E.push("sm:grid-cols-3");break;case 4:E.push("sm:grid-cols-4");break;case 5:E.push("sm:grid-cols-5");break;default:E.push("sm:grid-cols-3");break}switch(B.md){case 2:E.push("md:grid-cols-2");break;case 3:E.push("md:grid-cols-3");break;case 4:E.push("md:grid-cols-4");break;case 5:E.push("md:grid-cols-5");break;case 6:E.push("md:grid-cols-6");break;default:E.push("md:grid-cols-4");break}switch(B.lg){case 3:E.push("lg:grid-cols-3");break;case 4:E.push("lg:grid-cols-4");break;case 5:E.push("lg:grid-cols-5");break;case 6:E.push("lg:grid-cols-6");break;case 7:E.push("lg:grid-cols-7");break;default:E.push("lg:grid-cols-5");break}switch(B.xl){case 4:E.push("xl:grid-cols-4");break;case 5:E.push("xl:grid-cols-5");break;case 6:E.push("xl:grid-cols-6");break;case 7:E.push("xl:grid-cols-7");break;case 8:E.push("xl:grid-cols-8");break;default:E.push("xl:grid-cols-6");break}return E.join(" ")});function u(B,E,S){t.reorderable&&(i.value=E,B.dataTransfer&&(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/html","")))}function m(B,E){t.reorderable&&(B.preventDefault(),r.value=E)}function h(){r.value=null}function p(B,E){if(!t.reorderable||!i.value)return;B.preventDefault();const S=[...t.mediaItems],P=S.findIndex(C=>{var A;return C.uuid===((A=i.value)==null?void 0:A.uuid)});if(P!==-1&&P!==E&&i.value){const[C]=S.splice(P,1);S.splice(E,0,C),a("reorder",S)}i.value=null,r.value=null}function v(B){return B<1024?B+" B":B<1024*1024?(B/1024).toFixed(1)+" KB":(B/(1024*1024)).toFixed(1)+" MB"}function g(B){var S;return B.thumbnail_url||((S=B.conversion_urls)==null?void 0:S.thumb)||B.original_url||B.url||""}function w(B){var P,C,A;const E=((P=B.mime_type)==null?void 0:P.startsWith("image/"))||!1,S=!!(B.thumbnail_url||(C=B.conversion_urls)!=null&&C.thumb||(A=B.conversion_urls)!=null&&A.preview||B.original_url||B.url);return E&&S}function M(B){var E;return((E=B.split(".").pop())==null?void 0:E.toUpperCase())||""}function V(B){var S;const E=((S=B.mime_type)==null?void 0:S.toLowerCase())||"";return E.startsWith("image/")?"image":E.startsWith("video/")?"videocam":E.startsWith("audio/")?"musical-notes":E.includes("pdf")?"document-text":E.includes("zip")||E.includes("rar")?"archive":E.includes("sheet")||E.includes("excel")?"grid":E.includes("document")||E.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(B=>{B.forEach(E=>{var S;if(E.isIntersecting){const P=E.target.getAttribute("data-media-id");P&&(s.value.add(P),(S=l.value)==null||S.unobserve(E.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function b(B){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(E=>{var P;const S=E.getAttribute("data-media-id");S&&!s.value.has(S)&&((P=l.value)==null||P.observe(E))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function _(B,E){const S=B.target;delete S.dataset.fallbackIndex}function D(B,E){const S=B.target,P=S.closest("[data-media-id]"),C=[E.original_url,E.url,E.thumbnail_url,"preview_url"in E?E.preview_url:void 0].filter(A=>A&&A.trim()!==""&&A!==S.src);if(C.length>0&&S.dataset.fallbackIndex){const A=parseInt(S.dataset.fallbackIndex);if(A<C.length){S.dataset.fallbackIndex=(A+1).toString(),S.src=C[A]||"";return}}else if(C.length>0){S.dataset.fallbackIndex="1",S.src=C[0]||"";return}if(S.style.display="none",P&&!P.querySelector(".media-fallback-icon")){const R=document.createElement("div");R.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",R.innerHTML=`
2
- <div class="text-center">
3
- <div class="text-4xl text-gray-400 mb-2">${V(E)}</div>
4
- <p class="text-sm font-medium text-gray-500">${M(E.file_name)}</p>
5
- </div>
6
- `,P.appendChild(R)}}return(B,E)=>B.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,S=>e.createElementVNode("div",{key:`skeleton-${S}`,class:"relative"},[...E[1]||(E[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!B.mediaItems||!B.mediaItems.length?(e.openBlock(),e.createElementBlock("div",df,[E[2]||(E[2]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-16 h-16 text-gray-400 mb-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})],-1)),E[3]||(E[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),E[4]||(E[4]=e.createElementVNode("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-4"}," Upload some files to get started ",-1)),e.createElementVNode("button",{onClick:E[0]||(E[0]=S=>a("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(B.mediaItems,(S,P)=>(e.openBlock(),e.createElementBlock("div",{key:S.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===P}]),draggable:B.reorderable,onDragstart:C=>u(C,S),onDragover:C=>m(C,P),onDragleave:h,onDrop:C=>p(C,P)},[B.selectionMode?(e.openBlock(),e.createElementBlock("div",mf,[e.createElementVNode("input",{type:"checkbox",checked:c(S),onChange:C=>a("toggleSelect",S),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,pf)])):e.createCommentVNode("",!0),B.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",B.selectionMode?"left-10":"left-2"])},[e.renderSlot(B.$slots,"badge",{media:S,index:P},void 0,!0)],2)):e.createCommentVNode("",!0),B.reorderable?(e.openBlock(),e.createElementBlock("div",ff,[...E[5]||(E[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":c(S)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":S.uuid},[w(S)&&!b(S.uuid)?(e.openBlock(),e.createElementBlock("div",vf,[...E[6]||(E[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),w(S)&&b(S.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(S),alt:S.alt_text||S.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:C=>D(C,S),onLoad:C=>_(C)},null,40,gf)):(e.openBlock(),e.createElementBlock("div",yf,[e.createElementVNode("div",bf,[e.createElementVNode("div",wf,e.toDisplayString(V(S)),1),e.createElementVNode("p",kf,e.toDisplayString(M(S.file_name)),1)])])),e.createElementVNode("div",_f,[e.createElementVNode("button",{onClick:C=>a("preview",S),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...E[7]||(E[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,Ef),B.showEditButton&&w(S)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C=>a("edit",S),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...E[8]||(E[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})],-1)])],8,xf)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:C=>a("delete",S.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...E[9]||(E[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,Cf)])],8,hf),e.createElementVNode("div",Sf,[e.createElementVNode("h4",Vf,e.toDisplayString(S.file_name),1),e.createElementVNode("p",Nf,[e.createTextVNode(e.toDisplayString(v(S.size))+" ",1),S.width&&S.height?(e.openBlock(),e.createElementBlock("span",Tf," • "+e.toDisplayString(S.width)+"x"+e.toDisplayString(S.height),1)):e.createCommentVNode("",!0)]),S.caption?(e.openBlock(),e.createElementBlock("p",Mf,e.toDisplayString(S.caption),1)):e.createCommentVNode("",!0)])],2)],42,uf))),128))],2))}}),Ff=Me(Bf,[["__scopeId","data-v-f0c343b7"]]),If={class:"model-media-manager"},$f=["accept","multiple"],Rf={class:"flex items-center justify-between mb-4"},Df={key:0,class:"text-lg font-medium"},Af={class:"flex gap-2"},Lf={key:0,class:"flex items-center justify-center py-8"},Uf={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"},Of={class:"text-gray-600 dark:text-gray-400"},Pf={class:"flex gap-2 mt-4"},zf={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},jf=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(o,{emit:n}){const t=o,a=n,i=$t(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(0),m=e.ref(null),h=e.ref(void 0),p=e.ref(null),v=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($=>$.uuid)),M=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function V(){na({isAdmin:t.mode==="admin"})}async function b($){await(await U.toastController.create({message:$,duration:3e3,color:"danger",position:"bottom"})).present()}async function f(){if(!s.value)if(s.value=!0,V(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],a("update:media",i.modelMedia);else{r.value=!0,a("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),a("update:media",i.modelMedia)}catch($){const j=$ instanceof Error?$.message:"Failed to fetch media";a("error",{operation:"fetch",message:j,details:$})}finally{r.value=!1,a("loading",!1)}}}e.watch(()=>i.modelMedia,$=>{s.value&&a("update:media",$)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,f()}),e.watch(()=>t.mode,()=>{V()}),e.onMounted(()=>{f()}),e.onUnmounted(()=>{i.clearModelContext()});function _(){return i.modelMedia.length>0}function D(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function B($){var Z,K,ge;if(!((Z=$.mime_type)!=null&&Z.startsWith("image/")))return null;const j=$.original_url||$.url||((K=$.conversion_urls)==null?void 0:K.preview)||((ge=$.conversion_urls)==null?void 0:ge.thumb)||$.thumbnail_url;return j&&j.trim()!==""?j:null}function E(){l.value=!0}function S(){var $;($=v.value)==null||$.click()}function P(){l.value=!1}async function C($){if(!t.allowEdit)return;const j=B($);if(j){d.value=$,u.value++;try{const Z=i.getHttpClient(),K=i.getApiUrl(""),ge=await Z(`${K.replace(/\/$/,"")}/editor/${$.uuid}/edit`);h.value=ge.editable_source_url||j,m.value=ge.editor_state??null}catch{h.value=j,m.value=null}c.value=!0}}function A(){c.value=!1,d.value=null,h.value=void 0,m.value=null}async function R($){if(!d.value)throw new Error("No media selected for editing");const j=d.value,Z=t.editMode==="variant";try{p.value=null;const K=await i.saveEditedImage(j.uuid,$,{asVariant:Z,name:j.file_name});Z||await i.detachMedia(t.mediableType,t.mediableId,j.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[K.uuid],t.collection),a("edit-complete",{originalMedia:j,editedMedia:K,mode:t.editMode}),c.value=!1,d.value=null}catch(K){const ge=K instanceof Error?K.message:"Failed to save edited image";throw p.value=ge,await b(ge),K}}function W($){if(p.value===$.message){p.value=null;return}b($.message)}async function O($){const j=$.target,Z=j.files;if(!(!Z||Z.length===0)){for(let K=0;K<Z.length;K++){const ge=Z[K];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ge.type)){a("error",{operation:"upload",message:`File type ${ge.type} is not accepted`,details:{file:ge.name}});continue}if(t.maxFileSize!==void 0&&ge.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ge.name,size:ge.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:ge});try{const we=await i.uploadFile(ge,{collection:t.collection});we!=null&&we.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[we.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:ge}),a("attach",[we]))}catch(we){const ne=we instanceof Error?we.message:"Upload failed";a("error",{operation:"upload",message:ne,details:we}),a("upload-progress",{status:"error",progress:0,file:ge,error:ne})}}j.value=""}}async function I($){const j=$.map(Z=>Z.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,j,t.collection),a("reorder",i.modelMedia)}catch(Z){const K=Z instanceof Error?Z.message:"Failed to reorder media";a("error",{operation:"reorder",message:K,details:Z}),await b(K)}}async function F($){const j=i.modelMedia.find(Z=>Z.uuid===$);try{await i.detachMedia(t.mediableType,t.mediableId,$,t.collection),j&&a("detach",j)}catch(Z){const K=Z instanceof Error?Z.message:"Failed to detach media";a("error",{operation:"detach",message:K,details:Z}),await b(K)}}async function k($){l.value=!1;const j=$.map(ge=>ge.uuid),Z=new Set(w.value);let K=Array.from(new Set(j)).filter(ge=>!Z.has(ge));if(g.value!==void 0&&K.length>g.value&&(K=K.slice(0,g.value)),K.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,K,t.collection);const ge=i.modelMedia.filter(we=>K.includes(we.uuid));a("attach",ge)}catch(ge){const we=ge instanceof Error?ge.message:"Failed to attach media";a("error",{operation:"attach",message:we,details:ge})}}return($,j)=>(e.openBlock(),e.createElementBlock("div",If,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:M.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:O},null,40,$f),e.createElementVNode("div",Rf,[$.title?(e.openBlock(),e.createElementBlock("h3",Df,e.toDisplayString($.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Af,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small",disabled:D(),"data-testid":"browse-button",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(Ji)},null,8,["icon"]),j[1]||(j[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small",disabled:D(),"data-testid":"upload-button",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(sl)},null,8,["icon"]),j[2]||(j[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Lf,[e.createVNode(e.unref(U.IonSpinner),{"data-testid":"spinner"})])):_()?(e.openBlock(),e.createBlock(Ff,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!$.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!$.allowEdit,"selection-mode":!1,onReorder:I,onDelete:F,onEdit:C},e.createSlots({_:2},[$.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:Z})=>[Z===0?(e.openBlock(),e.createElementBlock("div",zf," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Uf,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ji),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Of,e.toDisplayString($.emptyText),1),e.createElementVNode("div",Pf,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(Ji)},null,8,["icon"]),j[3]||(j[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(sl)},null,8,["icon"]),j[4]||(j[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(cf,e.mergeProps({"is-open":l.value,"selected-items":w.value,collection:$.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:k,onClose:P}),null,16,["is-open","selected-items","collection"]),e.createVNode(hc,{modelValue:c.value,"onUpdate:modelValue":j[0]||(j[0]=Z=>c.value=Z),"initial-image":h.value,"initial-state":m.value,"session-key":u.value,onSave:R,onCancel:A,onError:W},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),Wf=Me(jf,[["__scopeId","data-v-f68e70ec"]]),Zf={class:"existing-media-selector","data-testid":"existing-media-selector"},Hf={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},Xf=["data-testid"],Gf={class:"existing-media-selector__section-header"},Jf={class:"existing-media-selector__section-title"},Yf=["data-testid","aria-label","onClick"],qf={class:"existing-media-selector__grid"},Kf=["data-testid","aria-label","aria-pressed","onClick"],Qf=["src","alt"],eh={key:0,class:"existing-media-selector__selected-badge"},th={key:1,class:"existing-media-selector__caption"},nh={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},ah={class:"existing-media-selector__section-header"},oh={class:"existing-media-selector__section-title"},ih={class:"existing-media-selector__albums"},rh=["data-testid","aria-label","aria-pressed","onClick"],sh={class:"existing-media-selector__album-name"},lh={key:0,class:"existing-media-selector__album-count"},ch={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},dh={class:"existing-media-selector__section-header"},uh={class:"existing-media-selector__section-subtitle"},mh={key:0,class:"existing-media-selector__section-description"},ph={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},fh={key:1,class:"existing-media-selector__grid"},hh=["data-testid","aria-label","aria-pressed","onClick"],vh=["src","alt"],gh={key:0,class:"existing-media-selector__selected-badge"},yh={key:1,class:"existing-media-selector__caption"},bh={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},wh={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},kh=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(o,{emit:n}){const t=o,a=n,i=e.reactive({}),r=e.computed(()=>t.sections.filter(f=>f.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),c=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const f=t.albums.find(_=>_.id===t.activeAlbumId);return f!=null&&f.name.trim().length?f.name.trim():t.albumSectionTitle}),d=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const f=t.albums.find(_=>_.id===t.activeAlbumId);return typeof(f==null?void 0:f.description)=="string"&&f.description.trim().length>0?f.description.trim():""});function u(f){const _=f.initialVisibleCount??6;return _>0?_:6}function m(f){return i[f]===!0}function h(f){i[f]=!m(f)}function p(f){return m(f.id)?f.items:f.items.slice(0,u(f))}function v(f){return f.items.length>u(f)}function g(f){a("select",f)}function w(f){a("update:activeAlbumId",f)}function M(f){var D;const _=(D=f.description)==null?void 0:D.trim();return _&&_.length>0?`Select ${_}`:"Select existing media"}function V(f,_){var B;const D=(B=_.description)==null?void 0:B.trim();return typeof _.alt=="string"&&_.alt.trim().length>0?_.alt.trim():D&&D.length>0?D:f.title}function b(f){const _=typeof f.mediaCount=="number"?` with ${f.mediaCount} item${f.mediaCount===1?"":"s"}`:"";return`Browse album ${f.name}${_}`}return(f,_)=>(e.openBlock(),e.createElementBlock("div",Zf,[f.isLoading?(e.openBlock(),e.createElementBlock("div",Hf," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,D=>(e.openBlock(),e.createElementBlock("section",{key:D.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${D.id}`},[e.createElementVNode("div",Gf,[e.createElementVNode("h3",Jf,e.toDisplayString(D.title),1),v(D)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${D.id}`,"aria-label":m(D.id)?`Show fewer items from ${D.title}`:`Show more items from ${D.title}`,onClick:B=>h(D.id)},e.toDisplayString(m(D.id)?"See less":"See more"),9,Yf)):e.createCommentVNode("",!0)]),e.createElementVNode("div",qf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(D),B=>(e.openBlock(),e.createElementBlock("button",{key:B.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===B.id}]),"data-testid":`existing-media-item-${D.id}-${B.id}`,"aria-label":M(B),"aria-pressed":f.selectedId===B.id?"true":"false",onClick:E=>g(B)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:B.previewUrl,alt:V(D,B)},null,8,Qf),f.selectedId===B.id?(e.openBlock(),e.createElementBlock("div",eh," Selected ")):e.createCommentVNode("",!0),B.description?(e.openBlock(),e.createElementBlock("div",th,e.toDisplayString(B.description),1)):e.createCommentVNode("",!0)],10,Kf))),128))])],8,Xf))),128)),s.value?(e.openBlock(),e.createElementBlock("section",nh,[e.createElementVNode("div",ah,[e.createElementVNode("h3",oh,e.toDisplayString(f.albumBrowseTitle),1)]),e.createElementVNode("div",ih,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.albums,D=>(e.openBlock(),e.createElementBlock("button",{key:D.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":f.activeAlbumId===D.id}]),"data-testid":`existing-media-album-${D.id}`,"aria-label":b(D),"aria-pressed":f.activeAlbumId===D.id?"true":"false",onClick:B=>w(D.id)},[e.createElementVNode("span",sh,e.toDisplayString(D.name),1),typeof D.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",lh,e.toDisplayString(D.mediaCount),1)):e.createCommentVNode("",!0)],10,rh))),128))]),e.createElementVNode("div",ch,[e.createElementVNode("div",dh,[e.createElementVNode("div",null,[e.createElementVNode("h4",uh,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",mh,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),f.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",ph," Loading album... ")):f.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",fh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.activeAlbumItems,D=>(e.openBlock(),e.createElementBlock("button",{key:D.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===D.id}]),"data-testid":`existing-media-item-album-${D.id}`,"aria-label":M(D),"aria-pressed":f.selectedId===D.id?"true":"false",onClick:B=>g(D)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:D.previewUrl,alt:D.alt||D.description||c.value},null,8,vh),f.selectedId===D.id?(e.openBlock(),e.createElementBlock("div",gh," Selected ")):e.createCommentVNode("",!0),D.description?(e.openBlock(),e.createElementBlock("div",yh,e.toDisplayString(D.description),1)):e.createCommentVNode("",!0)],10,hh))),128))])):(e.openBlock(),e.createElementBlock("div",bh,[e.renderSlot(f.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(f.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",wh,[e.renderSlot(f.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(f.emptyMessage),1)],!0)]))],64))]))}}),_h=Me(kh,[["__scopeId","data-v-904abb6b"]]);function uo(o,n,t,a){if(t<=0||a<=0)return!1;try{return n.drawImage(o,0,0,t,a),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Eh(o,n){return o?{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 xh=["src","crossorigin"],Ch={class:"preview-controls"},Sh=["aria-label"],Vh={class:"time-display"},Nh={class:"current-time"},Th={class:"total-time"},Mh={key:0,class:"fps-display"},Bh={key:0,class:"loading-overlay"},Fh={key:1,class:"error-overlay"},Ih=.1,$h=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(o,{expose:n,emit:t}){const{ColorMatrixFilter:a,BlurFilter:i}=st,r=o,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),h=e.ref(0),p=e.ref(0),v=e.ref(!1);let g,w,M=null,V=null,b=null,f=[],_="",D=null,B=0,E=0,S=0,P=0,C=!1,A=0,R=0,W,O=null,I=!1,F=!1,k=0;const $=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),j=e.computed(()=>{const ue=$.value;if(!(!ue||ue.startsWith("blob:")))return"anonymous"}),Z=e.computed(()=>Eh(v.value,r.fitMode));function K(ue){return typeof ue=="number"&&Number.isFinite(ue)&&ue>=0?ue:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function ge(ue){const Se=K(ue.duration);return Se<=0?!1:ue.currentTime>=Math.max(0,Se-Ih)}async function we(){var ue,Se;if(!F&&c.value&&!g&&!(!d.value||d.value.readyState<3)){F=!0;try{m.value=void 0;let Te=((ue=l.value)==null?void 0:ue.clientWidth)||800,je=((Se=l.value)==null?void 0:Se.clientHeight)||450;if((Te<=0||je<=0)&&(Te=d.value.videoWidth||800,je=d.value.videoHeight||450),g=new st.Application,await g.init({width:Te,height:je,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&&we()},100),g&&(g.destroy(!0),g=null);return}if(B=d.value.videoWidth,E=d.value.videoHeight,V=document.createElement("canvas"),V.width=B,V.height=E,b=V.getContext("2d"),!b)throw new Error("Unable to create 2D canvas context for video preview");const T=uo(d.value,b,B,E),z=st.Texture.from(V);M=z.source,w=new st.Sprite(z),w.visible=!0,w.alpha=1,wt(),g.stage.addChild(w),g.renderer&&!g.renderer.destroyed&&g.render()}te(),r.targetFps<60?ne():g.ticker.add(N),v.value=!0,"ResizeObserver"in window&&(D=new ResizeObserver(T=>{C||(C=!0,requestAnimationFrame(()=>{C=!1;const z=T[T.length-1],{width:G,height:ee}=z.contentRect;if(G<=0||ee<=0)return;const pe=Math.round(G),be=Math.round(ee);pe===S&&be===P||(S=pe,P=be,wt())}))}),D.observe(l.value)),r.filters&&r.filters.length>0&&te(),r.showFps&&dt(),k=0}catch{if(et(),!I&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&k<2){k+=1,window.setTimeout(()=>{I||we()},k*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{F=!1}}}function ne(){const ue=1e3/r.targetFps;let Se=performance.now();function Te(){if(I||!g)return;const je=performance.now(),T=je-Se;T>=ue&&(N(),Se=je-T%ue),O=requestAnimationFrame(Te)}O=requestAnimationFrame(Te)}function N(){if(!(!g||!w||I)&&r.active)try{b&&V&&M&&d.value&&(d.value.readyState>=2&&uo(d.value,b,V.width,V.height)&&M.update(),d.value.paused||s("frame-update",he())),r.showFps&&R++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{I=!0}}function L(){for(const ue of f)try{ue.destroy()}catch{}f=[]}function te(){if(w){if(!r.filters||r.filters.length===0){w.filters=null,L();return}L(),r.filters.forEach(ue=>{const Se=ae(ue);Se&&f.push(Se)}),w.filters=f.length>0?f:null,_=JSON.stringify(r.filters),g&&g.render()}}function ae(ue){const Se=ue.filterId,Te=ue.params||{},je=re.getFilter(Se);if(je&&!re.isFilterCompatibleWithMedia(Se,"video"))return null;if(je&&je.createFilter)try{return je.createFilter(Te)}catch{}const T=(z,G,ee)=>Math.min(ee,Math.max(G,z));switch(Se){case"brightness":{const z=new a,G=T(typeof Te.brightness=="number"?Te.brightness:typeof Te.value=="number"?Te.value:1,0,5);return z.brightness(G,!0),z}case"contrast":{const z=new a,G=T(typeof Te.contrast=="number"?Te.contrast:typeof Te.value=="number"?Te.value:1,0,5);return z.contrast(G,!0),z}case"saturation":{const z=new a,G=T(typeof Te.saturation=="number"?Te.saturation:typeof Te.value=="number"?Te.value:1,0,5);return z.saturate(G,!0),z}case"hue":{const z=new a,G=T(typeof Te.value=="number"?Te.value:0,-180,180);return z.hue(G,!0),z}case"gaussian-blur":case"blur":{const z=T(typeof Te.blur=="number"?Te.blur:typeof Te.value=="number"?Te.value:2,0,10);return new i(z)}case"grayscale":{const z=new a;return z.desaturate(),z}case"sepia":case"color-matrix":{const z=new a;return z.sepia(!0),z}case"vignette":{const z=typeof Te.value=="number"?Te.value:.3;return ie(T(z,0,1))}default:return null}}function ie(ue){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 st.Filter(void 0,Se,{strength:ue})}function he(){var Se;return!g||!w?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((Se=d.value)==null?void 0:Se.currentTime)||0,width:B||0,height:E||0}}function se(){var ue;h.value=K((ue=d.value)==null?void 0:ue.duration),s("duration-change",h.value)}function fe(){u.value=!1,m.value=void 0}function xe(){u.value&&(u.value=!1),!v.value&&r.active?we():v.value}function le(){var Se,Te,je;const ue=((Se=d.value)==null?void 0:Se.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:ue,width:((Te=d.value)==null?void 0:Te.videoWidth)||0,height:((je=d.value)==null?void 0:je.videoHeight)||0})}function de(){d.value&&(d.value.currentTime=0),s("play-pause")}function Ve(ue){var Te;const Se=ue.target;if(Se!=null&&Se.error)switch(Se.error.code){case Se.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case Se.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case Se.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case Se.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(Te=Se.src)==null?void 0:Te.substring(0,100)}`;break;default:m.value="Failed to load video"}else m.value="Failed to load video";s("error",m.value),u.value=!1}function Be(ue){d.value&&(d.value.currentTime=Math.max(0,Math.min(ue,h.value)))}function dt(){W=window.setInterval(()=>{const ue=performance.now(),Se=ue-A;p.value=Math.round(R*1e3/Se),R=0,A=ue},1e3)}function Ke(ue){if(!Number.isFinite(ue)||ue<0)return"00:00";const Se=Math.floor(ue/60),Te=Math.floor(ue%60);return`${Se.toString().padStart(2,"0")}:${Te.toString().padStart(2,"0")}`}function bt(){m.value=void 0,u.value=!0,k=0,et(),d.value&&d.value.load()}function et(){if(D&&(D.disconnect(),D=null),O&&(cancelAnimationFrame(O),O=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(N)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),L(),g=null,w=null,M=null,V=null,b=null,v.value=!1,C=!1,_=""}function at(){g&&(C||(C=!0,requestAnimationFrame(()=>{C=!1,wt()})))}function wt(){if(!g||!w||!B||!E||!l.value)return;const ue=Math.round(l.value.clientWidth),Se=Math.round(l.value.clientHeight);if(ue<=0||Se<=0)return;g.renderer.resize(ue,Se);const Te=g.screen.width/B,je=g.screen.height/E;let T=1;switch(r.fitMode){case"cover":T=Math.max(Te,je);break;case"none":T=1;break;case"contain":default:T=Math.min(Te,je);break}w.scale.set(T),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,()=>{v.value&&te()},{deep:!0}),e.watch(()=>r.active,async ue=>{if(ue&&!g&&d.value&&d.value.readyState>=2){await we();return}g&&(ue&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),w&&b&&V&&M&&(d.value&&d.value.readyState>=2&&uo(d.value,b,V.width,V.height)&&M.update(),wt(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(ue?g.ticker.start():g.ticker.stop()))}),e.watch($,ue=>{ue?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function Vt(){if(d.value){m.value=void 0,ge(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}m.value="Unable to start preview playback",s("error",m.value)}}e.watch(()=>r.isPlaying,ue=>{d.value&&(ue?Vt():d.value.pause())}),e.watch(()=>r.playhead,ue=>{d.value&&Math.abs(d.value.currentTime-ue)>.5&&Be(ue)}),e.watch(()=>r.fitMode,()=>{wt()}),e.onMounted(()=>{I=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",at),A=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value?we():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(I=!0,O&&(cancelAnimationFrame(O),O=null),window.removeEventListener("resize",at),D&&(D.disconnect(),D=null),W&&clearInterval(W),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(N)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}f.forEach(ue=>{try{ue.destroy()}catch{}}),f=[],w=null,M=null,V=null,b=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function rt(ue){if(!await vt()||!d.value||!b||!V||!M)return null;const Te=d.value,je=Number.isFinite(h.value)&&h.value>0?h.value:Number.isFinite(Te.duration)&&Te.duration>0?Te.duration:0,T=Math.max(0,Math.min(ue,je));return await new Promise(G=>{let ee=!1,pe=0;const be=()=>{ee||(ee=!0,Te.removeEventListener("seeked",$e),window.clearTimeout(pe),G())},$e=()=>{be()},Ae=Number.isFinite(Te.currentTime)?Te.currentTime:0;if(Math.abs(Ae-T)<.016){requestAnimationFrame(()=>be());return}Te.addEventListener("seeked",$e),pe=window.setTimeout(()=>be(),700),Te.currentTime=T}),uo(Te,b,V.width,V.height)?(M.update(),g.render(),g.canvas):null}async function vt(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await we()}if(!g||!w||!b||!V||!M)return!1;if(r.filters&&r.filters.length>0){const ue=w.filters,Se=Array.isArray(ue)?ue.length:0,je=JSON.stringify(r.filters)!==_;(Se===0||Se!==r.filters.length||je)&&te()}return await e.nextTick(),await new Promise(ue=>{requestAnimationFrame(()=>ue())}),!0}return n({captureFrameAt:rt,ensureReadyForCapture:vt,duration:h,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(ue,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:$.value,onLoadedmetadata:se,onLoadeddata:fe,onCanplay:xe,onTimeupdate:le,onEnded:de,onError:Ve,style:e.normalizeStyle(Z.value),crossorigin:j.value,preload:"auto",playsinline:"",controls:""},null,44,xh),e.createElementVNode("div",Ch,[e.createElementVNode("button",{class:"play-button",onClick:Se[0]||(Se[0]=Te=>ue.$emit("play-pause")),"aria-label":ue.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:ue.isPlaying?e.unref(bc):e.unref(wc)},null,8,["icon"])],8,Sh),e.createElementVNode("div",Vh,[e.createElementVNode("span",Nh,e.toDisplayString(Ke(ue.playhead)),1),Se[1]||(Se[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Th,e.toDisplayString(Ke(h.value)),1)]),ue.showFps?(e.openBlock(),e.createElementBlock("div",Mh,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",Bh,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),Se[2]||(Se[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",Fh,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:bt},"Retry")])):e.createCommentVNode("",!0)],512))}}),fr=Me($h,[["__scopeId","data-v-dd1744f4"]]);var Yr=(o,n,t)=>{if(!n.has(o))throw TypeError("Cannot "+t)},H=(o,n,t)=>(Yr(o,n,"read from private field"),t?t.call(o):n.get(o)),ze=(o,n,t)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,t)},ht=(o,n,t,a)=>(Yr(o,n,"write to private field"),n.set(o,t),t),Rh=(o,n,t,a)=>({set _(i){ht(o,n,i)},get _(){return H(o,n,a)}}),We=(o,n,t)=>(Yr(o,n,"access private method"),t),Ze=new Uint8Array(8),on=new DataView(Ze.buffer),ut=o=>[(o%256+256)%256],Ye=o=>(on.setUint16(0,o,!1),[Ze[0],Ze[1]]),Dh=o=>(on.setInt16(0,o,!1),[Ze[0],Ze[1]]),Cc=o=>(on.setUint32(0,o,!1),[Ze[1],Ze[2],Ze[3]]),Ce=o=>(on.setUint32(0,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Ah=o=>(on.setInt32(0,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Dn=o=>(on.setUint32(0,Math.floor(o/2**32),!1),on.setUint32(4,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3],Ze[4],Ze[5],Ze[6],Ze[7]]),qr=o=>(on.setInt16(0,2**8*o,!1),[Ze[0],Ze[1]]),tn=o=>(on.setInt32(0,2**16*o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),qi=o=>(on.setInt32(0,2**30*o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Ut=(o,n=!1)=>{let t=Array(o.length).fill(null).map((a,i)=>o.charCodeAt(i));return n&&t.push(0),t},Ro=o=>o&&o[o.length-1],Kr=o=>{let n;for(let t of o)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},an=(o,n,t=!0)=>{let a=o*n;return t?Math.round(a):a},Sc=o=>{let n=o*(Math.PI/180),t=Math.cos(n),a=Math.sin(n);return[t,a,0,-a,t,0,0,0,1]},Vc=Sc(0),Nc=o=>[tn(o[0]),tn(o[1]),qi(o[2]),tn(o[3]),tn(o[4]),qi(o[5]),tn(o[6]),tn(o[7]),qi(o[8])],Ma=o=>!o||typeof o!="object"?o:Array.isArray(o)?o.map(Ma):Object.fromEntries(Object.entries(o).map(([n,t])=>[n,Ma(t)])),oa=o=>o>=0&&o<2**32,ct=(o,n,t)=>({type:o,contents:n&&new Uint8Array(n.flat(10)),children:t}),Qe=(o,n,t,a,i)=>ct(o,[ut(n),Cc(t),a??[]],i),Lh=o=>{let n=512;return o.fragmented?ct("ftyp",[Ut("iso5"),Ce(n),Ut("iso5"),Ut("iso6"),Ut("mp41")]):ct("ftyp",[Ut("isom"),Ce(n),Ut("isom"),o.holdsAvc?Ut("avc1"):[],Ut("mp41")])},hr=o=>({type:"mdat",largeSize:o}),Uh=o=>({type:"free",size:o}),Eo=(o,n,t=!1)=>ct("moov",null,[Oh(n,o),...o.map(a=>Ph(a,n)),t?yv(o):null]),Oh=(o,n)=>{let t=an(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=Kr(s.samples);return l.presentationTimestamp+l.duration})),yr),a=Math.max(...n.map(s=>s.id))+1,i=!oa(o)||!oa(t),r=i?Dn:Ce;return Qe("mvhd",+i,0,[r(o),r(o),Ce(yr),r(t),tn(1),qr(1),Array(10).fill(0),Nc(Vc),Array(24).fill(0),Ce(a)])},Ph=(o,n)=>ct("trak",null,[zh(o,n),jh(o,n)]),zh=(o,n)=>{let t=Kr(o.samples),a=an(t?t.presentationTimestamp+t.duration:0,yr),i=!oa(n)||!oa(a),r=i?Dn:Ce,s;return o.info.type==="video"?s=typeof o.info.rotation=="number"?Sc(o.info.rotation):o.info.rotation:s=Vc,Qe("tkhd",+i,3,[r(n),r(n),Ce(o.id),Ce(0),r(a),Array(8).fill(0),Ye(0),Ye(0),qr(o.info.type==="audio"?1:0),Ye(0),Nc(s),tn(o.info.type==="video"?o.info.width:0),tn(o.info.type==="video"?o.info.height:0)])},jh=(o,n)=>ct("mdia",null,[Wh(o,n),Zh(o.info.type==="video"?"vide":"soun"),Hh(o)]),Wh=(o,n)=>{let t=Kr(o.samples),a=an(t?t.presentationTimestamp+t.duration:0,o.timescale),i=!oa(n)||!oa(a),r=i?Dn:Ce;return Qe("mdhd",+i,0,[r(n),r(n),Ce(o.timescale),r(a),Ye(21956),Ye(0)])},Zh=o=>Qe("hdlr",0,0,[Ut("mhlr"),Ut(o),Ce(0),Ce(0),Ce(0),Ut("mp4-muxer-hdlr",!0)]),Hh=o=>ct("minf",null,[o.info.type==="video"?Xh():Gh(),Jh(),Kh(o)]),Xh=()=>Qe("vmhd",0,1,[Ye(0),Ye(0),Ye(0),Ye(0)]),Gh=()=>Qe("smhd",0,0,[Ye(0),Ye(0)]),Jh=()=>ct("dinf",null,[Yh()]),Yh=()=>Qe("dref",0,0,[Ce(1)],[qh()]),qh=()=>Qe("url ",0,1),Kh=o=>{const n=o.compositionTimeOffsetTable.length>1||o.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return ct("stbl",null,[Qh(o),mv(o),pv(o),fv(o),hv(o),vv(o),n?gv(o):null])},Qh=o=>Qe("stsd",0,0,[Ce(1)],[o.info.type==="video"?ev(Nv[o.info.codec],o):cv(Mv[o.info.codec],o)]),ev=(o,n)=>ct(o,[Array(6).fill(0),Ye(1),Ye(0),Ye(0),Array(12).fill(0),Ye(n.info.width),Ye(n.info.height),Ce(4718592),Ce(4718592),Ce(0),Ye(1),Array(32).fill(0),Ye(24),Dh(65535)],[Tv[n.info.codec](n),n.info.decoderConfig.colorSpace?ov(n):null]),tv={bt709:1,bt470bg:5,smpte170m:6},nv={bt709:1,smpte170m:6,"iec61966-2-1":13},av={rgb:0,bt709:1,bt470bg:5,smpte170m:6},ov=o=>ct("colr",[Ut("nclx"),Ye(tv[o.info.decoderConfig.colorSpace.primaries]),Ye(nv[o.info.decoderConfig.colorSpace.transfer]),Ye(av[o.info.decoderConfig.colorSpace.matrix]),ut((o.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),iv=o=>o.info.decoderConfig&&ct("avcC",[...new Uint8Array(o.info.decoderConfig.description)]),rv=o=>o.info.decoderConfig&&ct("hvcC",[...new Uint8Array(o.info.decoderConfig.description)]),sv=o=>{if(!o.info.decoderConfig)return null;let n=o.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),a=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return Qe("vpcC",1,0,[ut(a),ut(i),ut(l),ut(2),ut(2),ut(2),Ye(0)])},lv=()=>{let t=(1<<7)+1;return ct("av1C",[t,0,0,0])},cv=(o,n)=>ct(o,[Array(6).fill(0),Ye(1),Ye(0),Ye(0),Ce(0),Ye(n.info.numberOfChannels),Ye(16),Ye(0),Ye(0),tn(n.info.sampleRate)],[Bv[n.info.codec](n)]),dv=o=>{let n=new Uint8Array(o.info.decoderConfig.description);return Qe("esds",0,0,[Ce(58753152),ut(32+n.byteLength),Ye(1),ut(0),Ce(75530368),ut(18+n.byteLength),ut(64),ut(21),Cc(0),Ce(130071),Ce(130071),Ce(92307584),ut(n.byteLength),...n,Ce(109084800),ut(1),ut(2)])},uv=o=>{var i;let n=3840,t=0;const a=(i=o.info.decoderConfig)==null?void 0:i.description;if(a){if(a.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(a)?new DataView(a.buffer,a.byteOffset,a.byteLength):new DataView(a);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return ct("dOps",[ut(0),ut(o.info.numberOfChannels),Ye(n),Ce(o.info.sampleRate),qr(t),ut(0)])},mv=o=>Qe("stts",0,0,[Ce(o.timeToSampleTable.length),o.timeToSampleTable.map(n=>[Ce(n.sampleCount),Ce(n.sampleDelta)])]),pv=o=>{if(o.samples.every(t=>t.type==="key"))return null;let n=[...o.samples.entries()].filter(([,t])=>t.type==="key");return Qe("stss",0,0,[Ce(n.length),n.map(([t])=>Ce(t+1))])},fv=o=>Qe("stsc",0,0,[Ce(o.compactlyCodedChunkTable.length),o.compactlyCodedChunkTable.map(n=>[Ce(n.firstChunk),Ce(n.samplesPerChunk),Ce(1)])]),hv=o=>Qe("stsz",0,0,[Ce(0),Ce(o.samples.length),o.samples.map(n=>Ce(n.size))]),vv=o=>o.finalizedChunks.length>0&&Ro(o.finalizedChunks).offset>=2**32?Qe("co64",0,0,[Ce(o.finalizedChunks.length),o.finalizedChunks.map(n=>Dn(n.offset))]):Qe("stco",0,0,[Ce(o.finalizedChunks.length),o.finalizedChunks.map(n=>Ce(n.offset))]),gv=o=>Qe("ctts",0,0,[Ce(o.compositionTimeOffsetTable.length),o.compositionTimeOffsetTable.map(n=>[Ce(n.sampleCount),Ce(n.sampleCompositionTimeOffset)])]),yv=o=>ct("mvex",null,o.map(bv)),bv=o=>Qe("trex",0,0,[Ce(o.id),Ce(1),Ce(0),Ce(0),Ce(0)]),pl=(o,n)=>ct("moof",null,[wv(o),...n.map(kv)]),wv=o=>Qe("mfhd",0,0,[Ce(o)]),Tc=o=>{let n=0,t=0,a=0,i=0,r=o.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|a<<8|i},kv=o=>ct("traf",null,[_v(o),Ev(o),xv(o)]),_v=o=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=o.currentChunk.samples[1]??o.currentChunk.samples[0],a={duration:t.timescaleUnitsToNextSample,size:t.size,flags:Tc(t)};return Qe("tfhd",0,n,[Ce(o.id),Ce(a.duration),Ce(a.size),Ce(a.flags)])},Ev=o=>Qe("tfdt",1,0,[Dn(an(o.currentChunk.startTimestamp,o.timescale))]),xv=o=>{let n=o.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=o.currentChunk.samples.map(g=>g.size),a=o.currentChunk.samples.map(Tc),i=o.currentChunk.samples.map(g=>an(g.presentationTimestamp-g.decodeTimestamp,o.timescale)),r=new Set(n),s=new Set(t),l=new Set(a),c=new Set(i),d=l.size===2&&a[0]!==a[1],u=r.size>1,m=s.size>1,h=!d&&l.size>1,p=c.size>1||[...c].some(g=>g!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+h,v|=2048*+p,Qe("trun",1,v,[Ce(o.currentChunk.samples.length),Ce(o.currentChunk.offset-o.currentChunk.moofOffset||0),d?Ce(a[0]):[],o.currentChunk.samples.map((g,w)=>[u?Ce(n[w]):[],m?Ce(t[w]):[],h?Ce(a[w]):[],p?Ah(i[w]):[]])])},Cv=o=>ct("mfra",null,[...o.map(Sv),Vv()]),Sv=(o,n)=>Qe("tfra",1,0,[Ce(o.id),Ce(63),Ce(o.finalizedChunks.length),o.finalizedChunks.map(a=>[Dn(an(a.startTimestamp,o.timescale)),Dn(a.moofOffset),Ce(n+1),Ce(1),Ce(1)])]),Vv=()=>Qe("mfro",0,0,[Ce(0)]),Nv={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Tv={avc:iv,hevc:rv,vp9:sv,av1:lv},Mv={aac:"mp4a",opus:"Opus"},Bv={aac:dv,opus:uv},Go=class{},Qr=class extends Go{constructor(){super(...arguments),this.buffer=null}},Mc=class extends Go{constructor(o){if(super(),this.options=o,typeof o!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(o.onData){if(typeof o.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(o.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(o.chunked!==void 0&&typeof o.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(o.chunkSize!==void 0&&(!Number.isInteger(o.chunkSize)||o.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},Fv=class extends Go{constructor(o,n){if(super(),this.stream=o,this.options=n,!(o 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")}},Cn,qn,Bc=class{constructor(){this.pos=0,ze(this,Cn,new Uint8Array(8)),ze(this,qn,new DataView(H(this,Cn).buffer)),this.offsets=new WeakMap}seek(o){this.pos=o}writeU32(o){H(this,qn).setUint32(0,o,!1),this.write(H(this,Cn).subarray(0,4))}writeU64(o){H(this,qn).setUint32(0,Math.floor(o/2**32),!1),H(this,qn).setUint32(4,o,!1),this.write(H(this,Cn).subarray(0,8))}writeAscii(o){for(let n=0;n<o.length;n++)H(this,qn).setUint8(n%8,o.charCodeAt(n)),n%8===7&&this.write(H(this,Cn));o.length%8!==0&&this.write(H(this,Cn).subarray(0,o.length%8))}writeBox(o){if(this.offsets.set(o,this.pos),o.contents&&!o.children)this.writeBoxHeader(o,o.size??o.contents.byteLength+8),this.write(o.contents);else{let n=this.pos;if(this.writeBoxHeader(o,0),o.contents&&this.write(o.contents),o.children)for(let i of o.children)i&&this.writeBox(i);let t=this.pos,a=o.size??t-n;this.seek(n),this.writeBoxHeader(o,a),this.seek(t)}}writeBoxHeader(o,n){this.writeU32(o.largeSize?1:n),this.writeAscii(o.type),o.largeSize&&this.writeU64(n)}measureBoxHeader(o){return 8+(o.largeSize?8:0)}patchBox(o){let n=this.pos;this.seek(this.offsets.get(o)),this.writeBox(o),this.seek(n)}measureBox(o){if(o.contents&&!o.children)return this.measureBoxHeader(o)+o.contents.byteLength;{let n=this.measureBoxHeader(o);if(o.contents&&(n+=o.contents.byteLength),o.children)for(let t of o.children)t&&(n+=this.measureBox(t));return n}}};Cn=new WeakMap;qn=new WeakMap;var xo,In,Da,Sa,Co,vr,Iv=class extends Bc{constructor(o){super(),ze(this,Co),ze(this,xo,void 0),ze(this,In,new ArrayBuffer(2**16)),ze(this,Da,new Uint8Array(H(this,In))),ze(this,Sa,0),ht(this,xo,o)}write(o){We(this,Co,vr).call(this,this.pos+o.byteLength),H(this,Da).set(o,this.pos),this.pos+=o.byteLength,ht(this,Sa,Math.max(H(this,Sa),this.pos))}finalize(){We(this,Co,vr).call(this,this.pos),H(this,xo).buffer=H(this,In).slice(0,Math.max(H(this,Sa),this.pos))}};xo=new WeakMap;In=new WeakMap;Da=new WeakMap;Sa=new WeakMap;Co=new WeakSet;vr=function(o){let n=H(this,In).byteLength;for(;n<o;)n*=2;if(n===H(this,In).byteLength)return;let t=new ArrayBuffer(n),a=new Uint8Array(t);a.set(H(this,Da),0),ht(this,In,t),ht(this,Da,a)};var $v=2**24,Rv=2,Ba,Sn,Va,cn,At,Do,gr,es,Fc,ts,Ic,Fa,Ao,ns=class extends Bc{constructor(o){var n,t;super(),ze(this,Do),ze(this,es),ze(this,ts),ze(this,Fa),ze(this,Ba,void 0),ze(this,Sn,[]),ze(this,Va,void 0),ze(this,cn,void 0),ze(this,At,[]),ht(this,Ba,o),ht(this,Va,((n=o.options)==null?void 0:n.chunked)??!1),ht(this,cn,((t=o.options)==null?void 0:t.chunkSize)??$v)}write(o){H(this,Sn).push({data:o.slice(),start:this.pos}),this.pos+=o.byteLength}flush(){var t,a;if(H(this,Sn).length===0)return;let o=[],n=[...H(this,Sn)].sort((i,r)=>i.start-r.start);o.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=o[o.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):o.push({start:s.start,size:s.data.byteLength})}for(let i of o){i.data=new Uint8Array(i.size);for(let r of H(this,Sn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);H(this,Va)?(We(this,Do,gr).call(this,i.data,i.start),We(this,Fa,Ao).call(this)):(a=(t=H(this,Ba).options).onData)==null||a.call(t,i.data,i.start)}H(this,Sn).length=0}finalize(){H(this,Va)&&We(this,Fa,Ao).call(this,!0)}};Ba=new WeakMap;Sn=new WeakMap;Va=new WeakMap;cn=new WeakMap;At=new WeakMap;Do=new WeakSet;gr=function(o,n){let t=H(this,At).findIndex(l=>l.start<=n&&n<l.start+H(this,cn));t===-1&&(t=We(this,ts,Ic).call(this,n));let a=H(this,At)[t],i=n-a.start,r=o.subarray(0,Math.min(H(this,cn)-i,o.byteLength));a.data.set(r,i);let s={start:i,end:i+r.byteLength};if(We(this,es,Fc).call(this,a,s),a.written[0].start===0&&a.written[0].end===H(this,cn)&&(a.shouldFlush=!0),H(this,At).length>Rv){for(let l=0;l<H(this,At).length-1;l++)H(this,At)[l].shouldFlush=!0;We(this,Fa,Ao).call(this)}r.byteLength<o.byteLength&&We(this,Do,gr).call(this,o.subarray(r.byteLength),n+r.byteLength)};es=new WeakSet;Fc=function(o,n){let t=0,a=o.written.length-1,i=-1;for(;t<=a;){let r=Math.floor(t+(a-t+1)/2);o.written[r].start<=n.start?(t=r+1,i=r):a=r-1}for(o.written.splice(i+1,0,n),(i===-1||o.written[i].end<n.start)&&i++;i<o.written.length-1&&o.written[i].end>=o.written[i+1].start;)o.written[i].end=Math.max(o.written[i].end,o.written[i+1].end),o.written.splice(i+1,1)};ts=new WeakSet;Ic=function(o){let t={start:Math.floor(o/H(this,cn))*H(this,cn),data:new Uint8Array(H(this,cn)),written:[],shouldFlush:!1};return H(this,At).push(t),H(this,At).sort((a,i)=>a.start-i.start),H(this,At).indexOf(t)};Fa=new WeakSet;Ao=function(o=!1){var n,t;for(let a=0;a<H(this,At).length;a++){let i=H(this,At)[a];if(!(!i.shouldFlush&&!o)){for(let r of i.written)(t=(n=H(this,Ba).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);H(this,At).splice(a--,1)}}};var Dv=class extends ns{constructor(o){var n;super(new Mc({onData:(t,a)=>o.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(n=o.options)==null?void 0:n.chunkSize}))}},yr=1e3,Av=["avc","hevc","vp9","av1"],Lv=["aac","opus"],Uv=2082844800,Ov=["strict","offset","cross-track-offset"],Ie,De,Lo,Rt,yt,ft,Kn,Qn,as,Vn,Nn,Ia,br,$c,wr,Rc,os,Dc,kr,Ac,is,Lc,So,_r,en,ln,rs,Uc,$a,Uo,Oo,ss,ia,Pa,Vo,Er,Oc=class{constructor(o){if(ze(this,br),ze(this,wr),ze(this,os),ze(this,kr),ze(this,is),ze(this,So),ze(this,en),ze(this,rs),ze(this,$a),ze(this,Oo),ze(this,ia),ze(this,Vo),ze(this,Ie,void 0),ze(this,De,void 0),ze(this,Lo,void 0),ze(this,Rt,void 0),ze(this,yt,null),ze(this,ft,null),ze(this,Kn,Math.floor(Date.now()/1e3)+Uv),ze(this,Qn,[]),ze(this,as,1),ze(this,Vn,[]),ze(this,Nn,[]),ze(this,Ia,!1),We(this,br,$c).call(this,o),o.video=Ma(o.video),o.audio=Ma(o.audio),o.fastStart=Ma(o.fastStart),this.target=o.target,ht(this,Ie,{firstTimestampBehavior:"strict",...o}),o.target instanceof Qr)ht(this,De,new Iv(o.target));else if(o.target instanceof Mc)ht(this,De,new ns(o.target));else if(o.target instanceof Fv)ht(this,De,new Dv(o.target));else throw new Error(`Invalid target: ${o.target}`);We(this,kr,Ac).call(this),We(this,wr,Rc).call(this)}addVideoChunk(o,n,t,a){if(!(o 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(a!==void 0&&!Number.isFinite(a))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(o.byteLength);o.copyTo(i),this.addVideoChunkRaw(i,o.type,t??o.timestamp,o.duration,n,a)}addVideoChunkRaw(o,n,t,a,i,r){if(!(o 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(a)||a<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(We(this,Vo,Er).call(this),!H(this,Ie).video)throw new Error("No video track declared.");if(typeof H(this,Ie).fastStart=="object"&&H(this,yt).samples.length===H(this,Ie).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${H(this,Ie).fastStart.expectedVideoChunks}).`);let s=We(this,So,_r).call(this,H(this,yt),o,n,t,a,i,r);if(H(this,Ie).fastStart==="fragmented"&&H(this,ft)){for(;H(this,Nn).length>0&&H(this,Nn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=H(this,Nn).shift();We(this,en,ln).call(this,H(this,ft),l)}s.decodeTimestamp<=H(this,ft).lastDecodeTimestamp?We(this,en,ln).call(this,H(this,yt),s):H(this,Vn).push(s)}else We(this,en,ln).call(this,H(this,yt),s)}addAudioChunk(o,n,t){if(!(o 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 a=new Uint8Array(o.byteLength);o.copyTo(a),this.addAudioChunkRaw(a,o.type,t??o.timestamp,o.duration,n)}addAudioChunkRaw(o,n,t,a,i){if(!(o 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(a)||a<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(We(this,Vo,Er).call(this),!H(this,Ie).audio)throw new Error("No audio track declared.");if(typeof H(this,Ie).fastStart=="object"&&H(this,ft).samples.length===H(this,Ie).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${H(this,Ie).fastStart.expectedAudioChunks}).`);let r=We(this,So,_r).call(this,H(this,ft),o,n,t,a,i);if(H(this,Ie).fastStart==="fragmented"&&H(this,yt)){for(;H(this,Vn).length>0&&H(this,Vn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=H(this,Vn).shift();We(this,en,ln).call(this,H(this,yt),s)}r.decodeTimestamp<=H(this,yt).lastDecodeTimestamp?We(this,en,ln).call(this,H(this,ft),r):H(this,Nn).push(r)}else We(this,en,ln).call(this,H(this,ft),r)}finalize(){if(H(this,Ia))throw new Error("Cannot finalize a muxer more than once.");if(H(this,Ie).fastStart==="fragmented"){for(let n of H(this,Vn))We(this,en,ln).call(this,H(this,yt),n);for(let n of H(this,Nn))We(this,en,ln).call(this,H(this,ft),n);We(this,Oo,ss).call(this,!1)}else H(this,yt)&&We(this,$a,Uo).call(this,H(this,yt)),H(this,ft)&&We(this,$a,Uo).call(this,H(this,ft));let o=[H(this,yt),H(this,ft)].filter(Boolean);if(H(this,Ie).fastStart==="in-memory"){let n;for(let a=0;a<2;a++){let i=Eo(o,H(this,Kn)),r=H(this,De).measureBox(i);n=H(this,De).measureBox(H(this,Rt));let s=H(this,De).pos+r+n;for(let l of H(this,Qn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(H(this,Rt).largeSize=!0)}let t=Eo(o,H(this,Kn));H(this,De).writeBox(t),H(this,Rt).size=n,H(this,De).writeBox(H(this,Rt));for(let a of H(this,Qn))for(let i of a.samples)H(this,De).write(i.data),i.data=null}else if(H(this,Ie).fastStart==="fragmented"){let n=H(this,De).pos,t=Cv(o);H(this,De).writeBox(t);let a=H(this,De).pos-n;H(this,De).seek(H(this,De).pos-4),H(this,De).writeU32(a)}else{let n=H(this,De).offsets.get(H(this,Rt)),t=H(this,De).pos-n;H(this,Rt).size=t,H(this,Rt).largeSize=t>=2**32,H(this,De).patchBox(H(this,Rt));let a=Eo(o,H(this,Kn));if(typeof H(this,Ie).fastStart=="object"){H(this,De).seek(H(this,Lo)),H(this,De).writeBox(a);let i=n-H(this,De).pos;H(this,De).writeBox(Uh(i))}else H(this,De).writeBox(a)}We(this,ia,Pa).call(this),H(this,De).finalize(),ht(this,Ia,!0)}};Ie=new WeakMap;De=new WeakMap;Lo=new WeakMap;Rt=new WeakMap;yt=new WeakMap;ft=new WeakMap;Kn=new WeakMap;Qn=new WeakMap;as=new WeakMap;Vn=new WeakMap;Nn=new WeakMap;Ia=new WeakMap;br=new WeakSet;$c=function(o){if(typeof o!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(o.target instanceof Go))throw new TypeError("The target must be provided and an instance of Target.");if(o.video){if(!Av.includes(o.video.codec))throw new TypeError(`Unsupported video codec: ${o.video.codec}`);if(!Number.isInteger(o.video.width)||o.video.width<=0)throw new TypeError(`Invalid video width: ${o.video.width}. Must be a positive integer.`);if(!Number.isInteger(o.video.height)||o.video.height<=0)throw new TypeError(`Invalid video height: ${o.video.height}. Must be a positive integer.`);const n=o.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(o.video.frameRate!==void 0&&(!Number.isInteger(o.video.frameRate)||o.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${o.video.frameRate}. Must be a positive integer.`)}if(o.audio){if(!Lv.includes(o.audio.codec))throw new TypeError(`Unsupported audio codec: ${o.audio.codec}`);if(!Number.isInteger(o.audio.numberOfChannels)||o.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${o.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(o.audio.sampleRate)||o.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${o.audio.sampleRate}. Must be a positive integer.`)}if(o.firstTimestampBehavior&&!Ov.includes(o.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${o.firstTimestampBehavior}`);if(typeof o.fastStart=="object"){if(o.video){if(o.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(o.fastStart.expectedVideoChunks)||o.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(o.audio){if(o.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(o.fastStart.expectedAudioChunks)||o.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(o.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(o.minFragmentDuration!==void 0&&(!Number.isFinite(o.minFragmentDuration)||o.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};wr=new WeakSet;Rc=function(){var o;if(H(this,De).writeBox(Lh({holdsAvc:((o=H(this,Ie).video)==null?void 0:o.codec)==="avc",fragmented:H(this,Ie).fastStart==="fragmented"})),ht(this,Lo,H(this,De).pos),H(this,Ie).fastStart==="in-memory")ht(this,Rt,hr(!1));else if(H(this,Ie).fastStart!=="fragmented"){if(typeof H(this,Ie).fastStart=="object"){let n=We(this,os,Dc).call(this);H(this,De).seek(H(this,De).pos+n)}ht(this,Rt,hr(!0)),H(this,De).writeBox(H(this,Rt))}We(this,ia,Pa).call(this)};os=new WeakSet;Dc=function(){if(typeof H(this,Ie).fastStart!="object")return;let o=0,n=[H(this,Ie).fastStart.expectedVideoChunks,H(this,Ie).fastStart.expectedAudioChunks];for(let t of n)t&&(o+=8*Math.ceil(2/3*t),o+=4*t,o+=12*Math.ceil(2/3*t),o+=4*t,o+=8*t);return o+=4096,o};kr=new WeakSet;Ac=function(){if(H(this,Ie).video&&ht(this,yt,{id:1,info:{type:"video",codec:H(this,Ie).video.codec,width:H(this,Ie).video.width,height:H(this,Ie).video.height,rotation:H(this,Ie).video.rotation??0,decoderConfig:null},timescale:H(this,Ie).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),H(this,Ie).audio&&(ht(this,ft,{id:H(this,Ie).video?2:1,info:{type:"audio",codec:H(this,Ie).audio.codec,numberOfChannels:H(this,Ie).audio.numberOfChannels,sampleRate:H(this,Ie).audio.sampleRate,decoderConfig:null},timescale:H(this,Ie).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),H(this,Ie).audio.codec==="aac")){let o=We(this,is,Lc).call(this,2,H(this,Ie).audio.sampleRate,H(this,Ie).audio.numberOfChannels);H(this,ft).info.decoderConfig={codec:H(this,Ie).audio.codec,description:o,numberOfChannels:H(this,Ie).audio.numberOfChannels,sampleRate:H(this,Ie).audio.sampleRate}}};is=new WeakSet;Lc=function(o,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=o.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};So=new WeakSet;_r=function(o,n,t,a,i,r,s){let l=a/1e6,c=(a-(s??0))/1e6,d=i/1e6,u=We(this,rs,Uc).call(this,l,c,o);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(o.info.decoderConfig===null?o.info.decoderConfig=r.decoderConfig:Object.assign(o.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:an(d,o.timescale)}};en=new WeakSet;ln=function(o,n){H(this,Ie).fastStart!=="fragmented"&&o.samples.push(n);const t=an(n.presentationTimestamp-n.decodeTimestamp,o.timescale);if(o.lastTimescaleUnits!==null){let i=an(n.decodeTimestamp,o.timescale,!1),r=Math.round(i-o.lastTimescaleUnits);if(o.lastTimescaleUnits+=r,o.lastSample.timescaleUnitsToNextSample=r,H(this,Ie).fastStart!=="fragmented"){let s=Ro(o.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,o.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=Ro(o.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else o.lastTimescaleUnits=0,H(this,Ie).fastStart!=="fragmented"&&(o.timeToSampleTable.push({sampleCount:1,sampleDelta:an(n.duration,o.timescale)}),o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));o.lastSample=n;let a=!1;if(!o.currentChunk)a=!0;else{let i=n.presentationTimestamp-o.currentChunk.startTimestamp;if(H(this,Ie).fastStart==="fragmented"){let r=H(this,yt)??H(this,ft);const s=H(this,Ie).minFragmentDuration??1;o===r&&n.type==="key"&&i>=s&&(a=!0,We(this,Oo,ss).call(this))}else a=i>=.5}a&&(o.currentChunk&&We(this,$a,Uo).call(this,o),o.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),o.currentChunk.samples.push(n)};rs=new WeakSet;Uc=function(o,n,t){var s,l;const a=H(this,Ie).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(a&&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(H(this,Ie).firstTimestampBehavior==="offset"||H(this,Ie).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;H(this,Ie).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=H(this,yt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=H(this,ft))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,o-=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:o,decodeTimestamp:n}};$a=new WeakSet;Uo=function(o){if(H(this,Ie).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(o.currentChunk){if(o.finalizedChunks.push(o.currentChunk),H(this,Qn).push(o.currentChunk),(o.compactlyCodedChunkTable.length===0||Ro(o.compactlyCodedChunkTable).samplesPerChunk!==o.currentChunk.samples.length)&&o.compactlyCodedChunkTable.push({firstChunk:o.finalizedChunks.length,samplesPerChunk:o.currentChunk.samples.length}),H(this,Ie).fastStart==="in-memory"){o.currentChunk.offset=0;return}o.currentChunk.offset=H(this,De).pos;for(let n of o.currentChunk.samples)H(this,De).write(n.data),n.data=null;We(this,ia,Pa).call(this)}};Oo=new WeakSet;ss=function(o=!0){if(H(this,Ie).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[H(this,yt),H(this,ft)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=Rh(this,as)._++;if(t===1){let l=Eo(n,H(this,Kn),!0);H(this,De).writeBox(l)}let a=H(this,De).pos,i=pl(t,n);H(this,De).writeBox(i);{let l=hr(!1),c=0;for(let u of n)for(let m of u.currentChunk.samples)c+=m.size;let d=H(this,De).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=H(this,De).measureBox(l)+c),l.size=d,H(this,De).writeBox(l)}for(let l of n){l.currentChunk.offset=H(this,De).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)H(this,De).write(c.data),c.data=null}let r=H(this,De).pos;H(this,De).seek(H(this,De).offsets.get(i));let s=pl(t,n);H(this,De).writeBox(s),H(this,De).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),H(this,Qn).push(l.currentChunk),l.currentChunk=null;o&&We(this,ia,Pa).call(this)};ia=new WeakSet;Pa=function(){H(this,De)instanceof ns&&H(this,De).flush()};Vo=new WeakSet;Er=function(){if(H(this,Ia))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const Aa=30;class ra extends Error{constructor({message:t="",code:a=""},...i){super(t,...i);J(this,"message");J(this,"code");this.code=a,this.message=t}}class dn extends ra{}class lt extends ra{}class Po extends ra{}class fl extends ra{}function Pv(o,n=Aa){if(n<1)throw new lt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o*n)}function ea(o,n=Aa){if(n<1)throw new lt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o/n*1e3)}class _e{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 Pv(this.millis/1e3)}set frames(n){this.millis=ea(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=ea(n);return this.millis=this.millis+t,this}add(n){return new _e(n.millis+this.millis)}subtract(n){return new _e(this.millis-n.millis)}static fromSeconds(n){const t=new _e;return t.millis=n*1e3,t}static fromFrames(n,t){const a=new _e;return a.millis=ea(n,t),a}copy(){return new _e(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new _e(n)}}function hl(o,n){return[o.slice(0,n),o.slice(n)].filter(t=>t.length>0)}function No(o,n){return n?Math.floor(Math.random()*(n-o+1)+o):o}function zv(o,n,t){t<0&&(t=0);const a=o[n];o.splice(n,1),o.splice(t,0,a)}function vl(o){return typeof o!="function"?!1:/^class\s/.test(Function.prototype.toString.call(o))}function jv(o){const n=o.numberOfChannels,t=o.length,a=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=o.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),a[i*n+r]=s}return a}function Wv(o,n=44100,t=2){if(o.sampleRate==n&&o.numberOfChannels==t)return o;const a=Math.floor(o.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,a,n);for(let r=0;r<o.numberOfChannels;r++){const s=o.getChannelData(r),l=i.getChannelData(r),c=o.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,m=Math.floor(u),h=Math.ceil(u);if(h>=s.length)l[d]=s[m];else{const p=u-m;l[d]=s[m]*(1-p)+s[h]*p}}}return i}async function Zv(o){const{fps:n,height:t,width:a,bitrate:i}=o,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:a,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(Hv)}function Hv(o,n){const t=o.hardwareAcceleration??"",a=n.hardwareAcceleration??"";return t<a?-1:t>a?1:0}async function Xv(o,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof o=="string"&&o.startsWith("data:image/svg+xml;base64,")){const a=o.split(",")[1],i=atob(a),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 o=="string"?t.href=o:t.href=URL.createObjectURL(o);t.click(),t.remove()}function gl(o){return`${o.hours.toString().padStart(2,"0")}:${o.minutes.toString().padStart(2,"0")}:${o.seconds.toString().padStart(2,"0")},`+o.milliseconds.toString().padStart(3,"0")}function yl(o){const n=new Date(1970,0,1);return n.setSeconds(o),n.setMilliseconds(Math.round(o%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class mo{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 _e}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new _e}}var xr=(o=>(o.en="en",o.de="de",o))(xr||{});class bl{constructor(n,t,a,i){J(this,"id",crypto.randomUUID());J(this,"text");J(this,"start");J(this,"stop");J(this,"confidence");this.text=n,this.start=new _e(t),this.stop=new _e(a),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class Mn{constructor(n=[],t=xr.en){J(this,"id",crypto.randomUUID());J(this,"language",xr.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:a}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(n&&r.words.length>=No(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=No(...t)?(yield r,r=void 0):a&&r.text.length>=No(...a)&&(yield r,r=void 0)),r?r.words.push(l):r=new mo([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 a=n[t],i=n[t+1];i.start.millis-a.stop.millis<0?i.start.millis=a.stop.millis+1:a.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,a="";for(const i of this.iter(n)){const r=yl(i.start.seconds),s=yl(i.stop.seconds);a+=`${t}
22
- `+gl(r)+" --> "+gl(s)+`
23
- ${i.text}
24
-
25
- `,t+=1}return{text:a,blob:new Blob([a],{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 a=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(a=s.start.millis),i.push(new bl(s.text,s.start.millis-a,s.stop.millis-a)),i.length==n)return new Mn([new mo(i)]);return new Mn([new mo(i)])}copy(){return Mn.fromJSON(this.toJSON())}static fromJSON(n){const t=new Mn;for(const a of n){const i=new mo;for(const r of a)i.words.push(new bl(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const a=await fetch(n,t);if(!a.ok)throw new dn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return Mn.fromJSON(await a.json())}}function To(o,n,t){return o+(n-o)*t}function Gv(o,n,t){const a=Number.parseInt(o.slice(1),16),i=Number.parseInt(n.slice(1),16),r=a>>16&255,s=a>>8&255,l=a&255,c=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(To(r,c,t)),h=Math.round(To(s,d,t)),p=Math.round(To(l,u,t));return`#${((1<<24)+(m<<16)+(h<<8)+p).toString(16).slice(1)}`}const Jv={linear:o=>o,easeIn:o=>o*o,easeOut:o=>o*(2-o),easeInOut:o=>o<.5?2*o*o:-1+(4-2*o)*o};class Fe{constructor(n,t,a={}){J(this,"input");J(this,"output");J(this,"options");if(n.length!==t.length)throw new lt({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>ea(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(a))}}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 a=0;a<t.length-1;a++){const i=t[a],r=t[a+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:a}}return{t:0,segment:0}}interpolate(n,t){const a=this.output[t],i=this.output[t+1],r=Jv[this.options.easing](n);if(typeof a=="number"&&typeof i=="number")return To(a,i,r);if(typeof a=="string"&&typeof i=="string")return Gv(a,i,r);if(this.output.length==1)return this.output[0];throw new lt({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:a}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,a)}push(n,t){return this.input.push(ea(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Fe([],[]);return Object.assign(t,n),t}}class Ot{constructor(){J(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:a})=>{const i=this[t];a&&i instanceof a?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:a,serializer:i})=>{if(n.hasOwnProperty(a))if(i){const r=i.fromJSON(n[a]);t[a]=r}else t[a]=n[a]}),t}}function ke(o){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:o})}}function za(o){return class extends o{constructor(){super(...arguments);J(this,"_handlers",{})}on(t,a){if(typeof a!="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]=a:this._handlers[t]={[i]:a},i}off(t,...a){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 a)this.off(i)}}trigger(t,a){var r,s;const i=new CustomEvent(t,{detail:a});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("*",a=>{t.trigger(a.type,a.detail)})}resolve(t){return(a,i)=>{this.on("error",i),this.on(t,a)}}}}function ls(o,n,t=0){if(!(o instanceof qe.Container||o instanceof qe.Filter||t==3))for(const a in o){const i=o[a];a&&(i instanceof Fe&&(o[a]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&ls(i,n,t+1))}}var Yv=Object.defineProperty,Jo=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&Yv(n,t,i),i};const ja=class Pc extends za(Ot){constructor(t={}){super();J(this,"_name");J(this,"_start",new _e);J(this,"_stop",_e.fromSeconds(16));J(this,"type","base");J(this,"source");J(this,"view",new qe.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",_e.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=_e.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new lt({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new lt({code:"trackNotAttached",message:"Track must be attached to a track"});const a=this.copy();this.stop=t.copy(),a.start=t.copy().addMillis(1),ls(a,a.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,i+1),a}copy(){return Pc.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Jo([ke()],ja.prototype,"_name");Jo([ke(_e)],ja.prototype,"_start");Jo([ke(_e)],ja.prototype,"_stop");Jo([ke()],ja.prototype,"disabled");let Wa=ja;var qv=Object.defineProperty,On=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&qv(n,t,i),i};class rn extends za(Ot){constructor(){super(...arguments);J(this,"state","IDLE");J(this,"metadata");J(this,"objectURL");J(this,"duration",_e.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 lt({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Nr(t.type),this.external=!1,this.file=t}async loadUrl(t,a){const i=await fetch(t,a);if(!(i!=null&&i.ok))throw new dn({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=Nr(r.type)}async from(t,a){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,a),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();Xv(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,i=new this){return i.from(t,a)}}On([ke()],rn.prototype,"objectURL");On([ke()],rn.prototype,"duration");On([ke()],rn.prototype,"type");On([ke()],rn.prototype,"name");On([ke()],rn.prototype,"mimeType");On([ke()],rn.prototype,"externalURL");On([ke()],rn.prototype,"external");const wl="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Kv(o){const n=new TextEncoder().encode(o);let t="";const a=n.byteLength;for(let i=0;i<a;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function kl(o){if(!o||!o.body)return wl;const n=o.body.scrollWidth,t=o.body.scrollHeight,a=o.cloneNode(!0),i=a.getElementsByTagName("style").item(0),r=a.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return wl;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,"+Kv(d)}class _l extends rn{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=kl(this.document),this.objectURL)}async loadUrl(t,a){await super.loadUrl(t,a),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((a,i)=>{this.iframe.onload=()=>a(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=kl(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 Qv(o,n={}){const{threshold:t=.02,hopSize:a=1024,minDuration:i=500}=n,r=[],s=o.getChannelData(0),l=o.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let m=0;m<s.length;m+=a){let h=0;const p=Math.min(m+a,s.length);for(let v=m;v<p;v++)h+=s[v]*s[v];h=Math.sqrt(h/(p-m)),h<t?(u+=a,d===null&&(d=m)):(d!==null&&u>=c&&r.push({start:_e.fromSeconds(d/l),stop:_e.fromSeconds(m/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:_e.fromSeconds(d/l),stop:_e.fromSeconds(s.length/l)}),r}const Ki=3e3;class bn extends rn{constructor(){super(...arguments);J(this,"type","audio");J(this,"decoding",!1);J(this,"_silences");J(this,"transcript");J(this,"audioBuffer")}async decode(t=2,a=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,a).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,a=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/a),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let m=0;m<l;m+=c){let h=0;for(let p=m;p<m+s;p++)h+=Math.abs(d[m]);u.push(Math.log1p(h/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:a=0,stop:i,logarithmic:r=!1}={}){typeof a=="object"&&(a=a.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,Ki,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*Ki/1e3,0)),d=i?Math.floor(Math.min(i*Ki/1e3,s.length)):s.length,u=Math.floor((d-c)/t),m=new Float32Array(t);for(let h=0;h<t;h++){const p=c+h*u,v=p+u;let g=-1/0;for(let w=p;w<v;w++){const M=l[w];M>g&&(g=M)}m[h]=r?Math.log2(1+g):g}return m}async thumbnail(...t){const a=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of a){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 a=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(a);return this._silences=Qv(r,t),i.close(),this._silences}}class Cr extends rn{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 Bn extends bn{constructor(){super(...arguments);J(this,"type","video");J(this,"downloadInProgress",!0)}async loadUrl(t,a){const i=await fetch(t,a);if(!(i!=null&&i.ok))throw new dn({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=Nr(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 lt({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",a=>{const i=a.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=a.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 a=await t.blob();this.file=new File([a],this.name,{type:a.type}),this.trigger("load",void 0)}catch(a){this.state=="ERROR",this.trigger("error",new Error(String(a)))}finally{this.downloadInProgress=!1}}}class e0{static fromJSON(n){return[new _e(n[0]),new _e(n[1])]}}var t0=Object.defineProperty,n0=Object.getOwnPropertyDescriptor,sa=(o,n,t,a)=>{for(var i=a>1?void 0:a?n0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&t0(n,t,i),i};const Pn=class zc extends Wa{constructor(t={}){super();J(this,"source",new bn);J(this,"_offset",new _e);J(this,"playing",!1);J(this,"duration",new _e);J(this,"range",[new _e,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=_e.fromFrames(t));const a=t.subtract(this.offset);a.millis>=0&&a.millis<this.range[1].millis?this.range[0].millis=a.millis:a.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=_e.fromFrames(t));const a=t.subtract(this.offset);a.millis>this.range[0].millis&&a.millis<=this.duration.millis?this.range[1]=a:a.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",_e.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((a,i)=>{if(!this.element)return i(new fl({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=()=>a()})}subclip(t,a){if(t||(t=this.range[0]),a||(a=this.range[1]),typeof t=="number"&&(t=_e.fromFrames(t)),typeof a=="number"&&(a=_e.fromFrames(a)),t.millis>=a.millis)throw new lt({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]),a.millis>this.duration.millis&&this.duration.millis&&(a=this.duration),this.range=[t,a],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=zc.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=_e.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new lt({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new fl({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const a=this.copy();this.range[1]=t.copy(),a.range[0]=t.copy().addMillis(1),ls(a,a.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,i+1),a}async addCaptions(t){var a;if(!((a=this.track)!=null&&a.composition))throw new lt({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 a=(await this.source.silences(t)).filter(s=>El(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(a.length==0)return[this];const i=t.padding??500,r=[this];for(const s of a){const l=r.at(-1);if(!l)break;if(!El(s,l.range))continue;const c=new _e(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}};sa([ke(_e)],Pn.prototype,"_offset",2);sa([ke(_e)],Pn.prototype,"duration",2);sa([ke(e0)],Pn.prototype,"range",2);sa([ke(Mn)],Pn.prototype,"transcript",1);sa([ke()],Pn.prototype,"muted",1);sa([ke()],Pn.prototype,"volume",1);let Yo=Pn;function El(o,n){return o.start.millis>=n[0].millis&&o.start.millis<=n[1].millis||o.stop.millis<=n[1].millis&&o.stop.millis>=n[0].millis}class po{static fromJSON(n){return typeof n=="object"?Fe.fromJSON(n):n}}class Qi{static fromJSON(n){return typeof n.x=="object"&&(n.x=Fe.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Fe.fromJSON(n.y)),n}}let a0=class{constructor(o){J(this,"target");J(this,"animation");this.target=o}init(o,n,t=0,a){if(!(o in this.target))throw new Error(`Property [${String(o)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[o]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[o])),this.target[o]=this.animation=new Fe(i,r,{easing:a})}};function o0(o){const n=new Proxy(o,{get(t,a){return a=="to"?(i,r)=>{if(!t.animation)throw new lt({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new _e(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(a,i,r,s),n)}});return n}class i0 extends a0{}var r0=Object.defineProperty,s0=Object.getOwnPropertyDescriptor,vn=(o,n,t,a)=>{for(var i=a>1?void 0:a?s0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&r0(n,t,i),i};function qo(o){class n extends o{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 Fe||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 qe.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 qe.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 o0(new i0(this))}}return vn([ke(po)],n.prototype,"_height",2),vn([ke(po)],n.prototype,"_width",2),vn([ke(Qi)],n.prototype,"_position",2),vn([ke(Qi)],n.prototype,"_scale",2),vn([ke(po)],n.prototype,"rotation",2),vn([ke(po)],n.prototype,"alpha",2),vn([ke(Qi)],n.prototype,"translate",2),vn([ke()],n.prototype,"anchor",1),n}function Ko(o,n,t){const a=t.value;return t.value=function(...i){var m,h,p,v;const r=i[0].subtract(this.start),s={width:((h=(m=this.track)==null?void 0:m.composition)==null?void 0:h.width)??1920,height:((v=(p=this.track)==null?void 0:p.composition)==null?void 0:v.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),a.apply(this,i)},t}var l0=Object.defineProperty,c0=Object.getOwnPropertyDescriptor,d0=(o,n,t,a)=>{for(var i=c0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&l0(n,t,i),i};const jc=class Wc extends qo(Wa){constructor(t,a={}){super();J(this,"type","image");J(this,"element",new Image);J(this,"source",new Cr);J(this,"sprite",new qe.Sprite);this.view.addChild(this.sprite),t instanceof Cr&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,a)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{this.sprite.texture=qe.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",a(new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Wc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};d0([Ko],jc.prototype,"update");let u0=jc;const fo={"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 m0=Object.defineProperty,Qo=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&m0(n,t,i),i};const Za=class Sr extends za(Ot){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(a=>{t.load().then(i=>{document.fonts.add(i),a(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Sr.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 a of await window.queryLocalFonts()){if(a.family in t){t[a.family].push(a);continue}t[a.family]=[a]}return Object.keys(t).map(a=>({family:a,variants:t[a].map(i=>({family:a,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(fo).map(t=>({family:t,variants:fo[t].weights.map(a=>({family:t,source:`url(${fo[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new Sr({family:t,source:`url(${fo[t].url})`,weight:a})}};Qo([ke()],Za.prototype,"family");Qo([ke()],Za.prototype,"weight");Qo([ke()],Za.prototype,"source");Qo([ke()],Za.prototype,"style");let _t=Za;const nn=4,Zc={center:.5,justify:.5,left:0,right:1},Hc={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var p0=Object.defineProperty,f0=Object.getOwnPropertyDescriptor,It=(o,n,t,a)=>{for(var i=f0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&p0(n,t,i),i};const St=class Xc extends qo(Wa){constructor(t){super();J(this,"type","text");J(this,"_text","");J(this,"_textCase");J(this,"_anchor",{x:0,y:0});J(this,"_font",new _t);J(this,"style",new qe.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 a=new qe.Text({text:this.transformedText,style:this.style,resolution:nn,scale:nn});this.view.addChild(a)}this.view.children[0]instanceof qe.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*nn}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/nn):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Zc[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=Hc[t]}get fillStyle(){const{fill:t}=this.style;return new qe.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:a=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new qe.Color(t).toHex().toUpperCase(),{color:t,alpha:a,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:a="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:a,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof qe.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:a,blur:i,color:r,distance:s}=this.style.dropShadow,l=new qe.Color(r).toHex().toUpperCase();return{alpha:t,angle:a,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=Xc.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,a=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*nn;this.view.pivot={x:(t-i)*this._anchor.x,y:(a-i)*this._anchor.y}}set(t){return super.set(t)}};It([ke()],St.prototype,"text");It([ke(_t)],St.prototype,"font");It([ke()],St.prototype,"maxWidth");It([ke()],St.prototype,"textAlign");It([ke()],St.prototype,"padding");It([ke()],St.prototype,"textBaseline");It([ke()],St.prototype,"fillStyle");It([ke()],St.prototype,"anchor");It([ke()],St.prototype,"stroke");It([ke()],St.prototype,"textCase");It([ke()],St.prototype,"shadow");It([ke()],St.prototype,"fontSize");It([ke()],St.prototype,"leading");It([Ko],St.prototype,"update");let la=St;function er(o){const n=o.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const h0={get(o,n){const t=o[n];return typeof t=="number"?t*nn:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*nn):t}};function v0(o){return new Proxy(o,h0)}class g0{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 xl{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 y0{static fromJSON(n){return n.map(t=>(t.font&&(t.font=_t.fromJSON(t.font)),t))}}var b0=Object.defineProperty,w0=Object.getOwnPropertyDescriptor,ca=(o,n,t,a)=>{for(var i=a>1?void 0:a?w0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&b0(n,t,i),i};const zn=class Gc extends la{constructor(t){super();J(this,"type","complex_text");J(this,"_maxWidth");J(this,"_textAlign","left");J(this,"_textBaseline","top");J(this,"model",new qe.Container);J(this,"segments",[]);J(this,"metrics",new xl);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=Zc[t];const a=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(a-i.width)/2),t=="right"&&(r=a-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=Hc[t];let a=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=a+l}a+=r}}copy(){const t=Gc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const a=this.transformedText??"",i=[{index:void 0,tokens:er(a.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:er(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&i.push({index:void 0,tokens:er(a.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,a){var r,s,l;const i=new xl;for(const c of t){const d=c.index!=null?a[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const m=v0(qe.CanvasTextMetrics.measureText(c.tokens[u],d)),h=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(h>p||v||!i.lines.length)&&i.lines.push(new g0),this.model.addChild(new qe.Text({text:c.tokens[u],style:d,resolution:nn,scale:nn})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(a=>{var r;const i=this.style.clone();return i.fill=a.fillStyle??this.style.fill,i.fontSize=a.fontSize??this.style.fontSize,i.stroke=a.stroke??this.style.stroke,i.fontFamily=((r=a.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,a=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 qe.Graphics;s.roundRect(0-i/2,2-r/2,t+i,a+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),a=this.createTextStyles();this.metrics=this.createTextMetrics(t,a),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)*nn;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};ca([ke()],zn.prototype,"background",2);ca([ke(y0)],zn.prototype,"styles",2);ca([ke()],zn.prototype,"text",1);ca([ke()],zn.prototype,"maxWidth",1);ca([ke()],zn.prototype,"textAlign",1);ca([ke()],zn.prototype,"textBaseline",1);let ei=zn;const Jc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",k0=o=>Uint8Array.from(atob(o),n=>n.charCodeAt(0)),Cl=typeof self<"u"&&self.Blob&&new Blob([k0(Jc)],{type:"text/javascript;charset=utf-8"});function _0(o){let n;try{if(n=Cl&&(self.URL||self.webkitURL).createObjectURL(Cl),!n)throw"";const t=new Worker(n,{name:o==null?void 0:o.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+Jc,{name:o==null?void 0:o.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class E0{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,a)=>{const i=setTimeout(()=>{a(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function x0(o,n,t){const a=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),a.apply(this,i)},t}var C0=Object.defineProperty,S0=Object.getOwnPropertyDescriptor,V0=(o,n,t,a)=>{for(var i=S0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&C0(n,t,i),i};const Yc=class qc extends qo(Yo){constructor(t,a={}){super();J(this,"source",new Bn);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:qe.Texture.from(this.element),canvas:qe.Texture.from(this.canvas)});J(this,"sprite",new qe.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 Bn&&(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,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((a,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const r=new dn({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 a=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(_e.fromFrames(a))}enter(){var t,a,i;super.enter(),(a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var a,i,r,s,l,c;if((i=(a=this.track)==null?void 0:a.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=qc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,a;return this.buffer=new E0,this.worker=new _0,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:((a=(t=this.track)==null?void 0:t.composition)==null?void 0:a.fps)??Aa}),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 a;this.start.millis<0?a=Math.abs(this.offset.seconds):a=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,[a,i]}cancelDecoding(){var t,a;(t=this.worker)==null||t.terminate(),this.worker=void 0,(a=this.buffer)==null||a.terminate(),this.buffer=void 0}};V0([Ko,x0],Yc.prototype,"update");let Vr=Yc;class zo extends Yo{constructor(t,a={}){super();J(this,"type","audio");J(this,"source",new bn);J(this,"element",new Audio);t instanceof bn&&(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,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((a,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const r=new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,a,i,r,s,l;if((a=(t=this.track)==null?void 0:t.composition)!=null&&a.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=zo.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const N0={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 Nr(o){if(!Object.keys(N0.MIXED).includes(o??""))throw new lt({message:`${o} is not an accepted mime type`,code:"invalid_mimetype"});return o}var T0=Object.defineProperty,M0=Object.getOwnPropertyDescriptor,B0=(o,n,t,a)=>{for(var i=M0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&T0(n,t,i),i};const F0=class Kc extends qo(Wa){constructor(t,a={}){super();J(this,"type","html");J(this,"source",new _l);J(this,"element",new Image);J(this,"canvas",document.createElement("canvas"));J(this,"context",this.canvas.getContext("2d"));J(this,"sprite",new qe.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof _l&&(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=qe.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new dn({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,a)=>{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 a(new dn({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{a(new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Kc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};B0([Ko],F0.prototype,"update");const Qc=["DEFAULT","STACK"];class Sl{constructor(){J(this,"mode",Qc[0]);J(this,"pauseAlignmet",!1)}add(n,t){let a=!0;for(let i=0;i<t.clips.length&&(a=Tl(n,t.clips[i]),!!a);i++)Nl(n,t.clips[i]);a&&(t.clips.push(n),t.clips.sort(Vl))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Vl);for(let a=0;a<t.clips.length;a++)if(n.id!=t.clips[a].id){if(!Tl(n,t.clips[a]))break;Nl(n,t.clips[a])}}}offset(n,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(n);this.pauseAlignmet=!1}}class I0{constructor(){J(this,"mode",Qc[1])}add(n,t,a=void 0){var r;let i=-1;(a!=null&&a>0||a==null)&&(i=((r=t.clips.at((a??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new _e(i-n.start.millis+1)),a==null?t.clips.push(n):(t.clips.splice(a,0,n),t.clips.slice(a+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let a=0;for(const i of t.clips){if(i.start.millis!=a){const r=a-i.start.millis;i.offsetBy(new _e(r))}a=i.stop.millis+1}}offset(){}}function Vl(o,n){return o.start.millis-n.start.millis}function Nl(o,n){o.start.millis>=n.start.millis&&o.start.millis<=n.stop.millis&&(o.start=n.stop.copy().addMillis(1)),o.stop.millis>=n.start.millis&&o.stop.millis<=n.stop.millis&&(o.stop=n.start.copy().addMillis(-1))}function Tl(o,n){var t,a,i,r,s;if(o.start.millis>=n.start.millis&&o.stop.millis<=n.stop.millis){const l=(a=(t=n.track)==null?void 0:t.composition)==null?void 0:a.tracks.find(c=>c.type==o.type&&!c.clips.some(d=>o.id!=d.id&&o.start.millis>=d.start.millis&&o.stop.millis<=d.stop.millis));return l?(l.add(o.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(o.type))==null||s.add(o.detach()),!1)}return!0}class da extends za(Ot){constructor(){super(...arguments);J(this,"_disabled",!1);J(this,"view",new qe.Container);J(this,"clips",[]);J(this,"pointer",0);J(this,"composition");J(this,"type","base");J(this,"strategy",new Sl)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&nr(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(a=this.clipRef)==null||a.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new I0,this.strategy.update(new Wa,this)):this.strategy=new Sl,this.trigger("update",void 0),this}layer(t){var l,c;const a=((l=this.composition)==null?void 0:l.tracks)??[],i=a.findIndex(d=>d.id==this.id),r=a.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,zv(a,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(_e.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:a}=t;if(nr(this.clipRef)&&(!tr(a,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!tr(a,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(tr(a,c)&&!c.disabled)return this.pointer=l,nr(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(a<c.start.millis&&a>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,a){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,a),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const a=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),a!=null&&a>=0)return this.clips.splice(a,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 _e}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new _e}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 tr(o,n){return n?o>=n.start.millis&&o<=n.stop.millis:!1}function nr(o){return o?!!o.view.parent:!1}class $0{static fromType(n){switch(n.type){case"video":return new R0;case"audio":return new A0;case"html":return new L0;case"image":return new D0;case"text":return new Ml;case"complex_text":return new Ml;case"caption":return new O0;default:return new da}}}class ed extends da{constructor(){super(...arguments);J(this,"clips",[])}async seek(t){for(const a of this.clips)await a.seek(t)}async removeSilences(t={}){const a=[];for(const i of this.clips.map(r=>r.detach()))a.push(...await i.removeSilences(t));for(const i of a)await this.add(i)}}class R0 extends ed{constructor(){super(...arguments);J(this,"type","video")}async seek(t){var a;(a=this.composition)!=null&&a.rendering?this.view.removeChildren():super.seek(t)}}class D0 extends da{constructor(){super(...arguments);J(this,"type","image")}}class A0 extends ed{constructor(){super(...arguments);J(this,"type","audio")}}class Ml extends da{constructor(){super(...arguments);J(this,"type","text")}}class L0 extends da{constructor(){super(...arguments);J(this,"type","html")}}var U0=Object.defineProperty,cs=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&U0(n,t,i),i};class Ha extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new la({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(a),start:c.start.add(a),scale:new Fe([0,8],[.96,1],{easing:"easeOut"}),alpha:new Fe([0,4],[0,1],{easing:"easeOut"})}))}}cs([ke()],Ha.prototype,"generatorOptions");cs([ke()],Ha.prototype,"type");cs([ke()],Ha.prototype,"position");class O0 extends da{constructor(){super(...arguments);J(this,"clip");J(this,"type","caption");J(this,"preset",new Ha)}from(t){var a;return this.clip=t,(a=this.clip)==null||a.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let a=this.preset;return typeof t=="object"?a=t:t&&(a=new t),this.clips=[],this.trigger("update",void 0),this.preset=a,await a.applyTo(this),this.trigger("update",void 0),this}}var P0=Object.defineProperty,ti=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&P0(n,t,i),i};class Xa extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new ei({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(a),start:c.words[d].start.add(a)}))}}}ti([ke()],Xa.prototype,"generatorOptions");ti([ke()],Xa.prototype,"type");ti([ke()],Xa.prototype,"color");ti([ke()],Xa.prototype,"position");var z0=Object.defineProperty,ds=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&z0(n,t,i),i};class ni extends Ot{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,m;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const h of t.clip.transcript.iter({length:[18]})){const{segments:p,words:v}=this.splitSequence(h);for(let g=0;g<h.words.length;g++){const w=(d=(c=v[g])==null?void 0:c.at(0))==null?void 0:d.start,M=(m=(u=v[g])==null?void 0:u.at(-1))==null?void 0:m.stop;!w||!M||await t.add(new ei({text:p.join(`
33
- `),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:M.add(a),start:w.add(a),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:No(0,2),start:p.slice(0,g).join(" ").length,stop:p.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const a=t.text,i=Math.ceil(a.length/2);let r=a.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(a[c].match(/ /)){r=c;break}if(a[d].match(/ /)){r=d;break}}const s=[...hl(a,r).map(c=>c.trim())],l=hl(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}ds([ke()],ni.prototype,"type");ds([ke()],ni.prototype,"colors");ds([ke()],ni.prototype,"position");var j0=Object.defineProperty,us=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&j0(n,t,i),i};class ai extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(m=>m.text).slice(0,d+1).join(" ");await t.add(new la({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(a),start:c.words[d].start.add(a)}))}}}us([ke()],ai.prototype,"generatorOptions");us([ke()],ai.prototype,"type");us([ke()],ai.prototype,"position");var W0=Object.defineProperty,ms=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&W0(n,t,i),i};class oi extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=await _t.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new _e,r=new wm.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new la({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:a,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 Fe([0,8],[.96,1],{easing:"easeOut"}),alpha:new Fe([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}ms([ke()],oi.prototype,"generatorOptions");ms([ke()],oi.prototype,"type");ms([ke()],oi.prototype,"position");var Z0=Object.defineProperty,ii=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&Z0(n,t,i),i};class Ga extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new ei({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(a),start:c.words[d].start.add(a),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}ii([ke()],Ga.prototype,"generatorOptions");ii([ke()],Ga.prototype,"type");ii([ke()],Ga.prototype,"color");ii([ke()],Ga.prototype,"position");var H0=Object.defineProperty,ri=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&H0(n,t,i),i};class si extends Ot{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 lt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await _t.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new ei({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(a),start:c.words[d].start.add(a),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}ri([ke()],si.prototype,"type");ri([ke()],si.prototype,"generatorOptions");ri([ke()],si.prototype,"color");ri([ke()],si.prototype,"position");class X0 extends za(Ot){constructor({height:t=1080,width:a=1920,background:i="#000000",backend:r="webgpu"}={}){super();J(this,"_duration",new _e);J(this,"renderer");J(this,"stage",new qe.Container);J(this,"settings");J(this,"tracks",[]);J(this,"frame",0);J(this,"fixedDuration");J(this,"state","IDLE");J(this,"fps",Aa);J(this,"canvas");J(this,"context");this.settings={height:t,width:a,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)),qe.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new ra({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 a;t?t instanceof _e?this.fixedDuration=t:this.fixedDuration=_e.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((a=this.fixedDuration)==null?void 0:a.frames)??0)}resize(t,a){var i;this.settings.width=t,this.settings.height=a,(i=this.renderer)==null||i.resize(t,a),this.canvas&&(this.canvas.height=a,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 a=typeof t=="object"?t:new t;return a.connect(this),this.stage.addChild(a.view),this.tracks.unshift(a),a.bubble(this),this.trigger("update",void 0),a}createTrack(t){const a=$0.fromType({type:t});return this.shiftTrack(a),a}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const a of this.tracks)if(a.clips.find(i=>i.id==t.id))return a.remove(t)}removeTracks(t){const a=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),a.forEach(i=>this.removeTrack(i)),a}findTracks(t){return this.tracks.filter(a=>{let i;return vl(t)?i=a instanceof t:i=t(a),i})}findClips(t){const a=[];for(const i of this.tracks)for(const r of i.clips){let s;vl(t)?s=r instanceof t:s=t(r),s&&a.push(r)}return a}computeFrame(){var t,a;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(_e.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(a=this.context)==null||a.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",a=1){if(this.computeFrame(),!this.renderer)throw new ra({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,a)}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 a of this.tracks)await a.seek(_e.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(_e.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,a=48e3){var s;const i=this.duration.seconds*a,r=new OfflineAudioContext({sampleRate:a,length:i,numberOfChannels:t}).createBuffer(t,i,a);for(const l of this.findClips(Yo)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*r.sampleRate),d=Math.round(l.range[0].seconds*r.sampleRate),u=Math.round(l.range[1].seconds*r.sampleRate);try{const m=await l.source.decode(t,a),h=m.numberOfChannels-1;for(let p=0;p<t;p++){const v=r.getChannelData(p),g=m.getChannelData(p>h?h:p);for(let w=0;w<v.length-1;w++)w<c+d||w>c+u||w-c<0||(v[w]+=(g[w-c]??0)*l.volume,v[w]>1&&(v[w]=1),v[w]<-1&&(v[w]=-1));r.getChannelData(p).set(v)}}catch{}}return r}time(t){const a=ea(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(a).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const a=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),a!=null&&a>=0)return this.tracks.splice(a,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/Aa;let a=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-a<t-i||(i=Math.min(t,i+r-a-t),a=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 a;return((a=t.stop)==null?void 0:a.frames)??0}),0),this.computeFrame()}}function G0(o,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]=o&255,t[13]=o>>8&255,t[14]=o>>16&255,t[15]=o>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Tr=[8e3,12e3,16e3,24e3,48e3],J0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",Y0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class q0{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(Y0),{numberOfChannels:a,sampleRate:i}=this.config=n;if(!Tr.includes(i))throw new Po({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Tr.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?J0:s+r}}),this.encoder=this.opus._opus_encoder_create(i,a,2048),this.meta={decoderConfig:{codec:"opus",description:G0(i,a).buffer,numberOfChannels:a,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:a=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new Po({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let l=0;const c=s/i*1e6;for(;l<t;){const d=n.subarray(l*r,(l+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const m=4e3,h=this.opus._malloc(m),p=this.opus._opus_encode(this.encoder,u,s,h,m);if(p>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(h,h+p));this.output({data:v,timestamp:a,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(h),l+=s,a+=c}}}function K0(o){const n=Tr;let t=48e3;for(const a of n)Math.abs(o-a)<Math.abs(o-t)&&(t=a);return t}class Q0{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=K0((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 Zv({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Oc({target:new Qr,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:(a,i)=>{i&&this.muxer.addVideoChunk(a,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var a;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)});(a=this.videoEncoder)==null||a.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new Po({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=Wv(n,this.sampleRate,this.numberOfChannels),a=new q0({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await a.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),a.encode({data:jv(t),numberOfFrames:t.length})}async blob(){var t,a,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(a=this.muxer)==null||a.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new Po({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 eg(o){var a,i;const n=(a=o.metadata)==null?void 0:a.source_url;if(n)return n;const t=(i=o.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}function zt(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return n}function ho(o){return o>5?o/100:o}function jt(o,n,t){return Math.min(t,Math.max(n,o))}function Mt(){return new st.ColorMatrixFilter}function tg(o,n){switch(o){case"brightness":{const t=Mt(),a=zt(n.value??n.brightness,1);return t.brightness(jt(ho(a),0,5),!1),t}case"contrast":{const t=Mt(),a=zt(n.value??n.contrast,1);return t.contrast(jt(ho(a),0,5),!1),t}case"saturation":{const t=Mt(),a=zt(n.value??n.saturation,1);return t.saturate(jt(ho(a),0,5),!1),t}case"hue":{const t=Mt(),a=zt(n.degrees??n.value,0);return t.hue(jt(a,-180,180),!1),t}case"blur":case"softFocus":{const t=o==="softFocus"?1:0,a=zt(n.radius??n.blur??n.value,t);return new st.BlurFilter({strength:jt(a,0,32),quality:4})}case"grayscale":{const t=Mt(),a=jt(zt(n.amount,100),0,100);return a<=0?null:(a>=100?t.desaturate():t.saturate(1-a/100,!1),t)}case"sepia":{if(jt(zt(n.amount,100),0,100)<=0)return null;const a=Mt();return a.sepia(!1),a}case"invert":{if(jt(zt(n.amount,100),0,100)<=0)return null;const a=Mt();return a.negative(!1),a}case"warmth":{const t=Mt(),a=jt(zt(n.value,0),-50,50);return a>0?(t.sepia(!1),t.saturate(1+a/100,!1)):a<0&&t.hue(Math.abs(a)/50*-20,!1),t}case"tint":{const t=Mt(),a=jt(zt(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-a+a*s,0,0,0,0,0,1-a+a*l,0,0,0,0,0,1-a+a*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=Mt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=Mt(),a=jt(ho(zt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(a,!1),t}case"cinematic":{const t=Mt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=Mt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=Mt();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=st);class td{constructor(n=1920,t=1080,a=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=a,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new X0({width:n,height:t,background:"#000000"}),this.initPromise=new Promise(r=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),r()};this.composition.on("init",s),queueMicrotask(()=>{var c,d,u,m;const l=this.composition;((d=(c=l==null?void 0:l.app)==null?void 0:c.renderer)!=null&&d.view||(u=l==null?void 0:l.renderer)!=null&&u.view||(m=l==null?void 0:l.renderer)!=null&&m.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...n){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var a;const n=(a=this.player)==null?void 0:a.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 a,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((a=n.source)==null?void 0:a.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 eg(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(n,t){var a,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((a=Bn.from)==null?void 0:a.call(Bn,r,{crossOrigin:"anonymous"}))??await Bn.from(r),l=new Vr(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let c=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const h=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),p=n.sourceOut!==void 0?Math.max(h+1,Math.floor(n.sourceOut*this.fps)):null;c=h,d=p;try{if(l.offset=l.offset||{frames:0},l.offset.frames=h,p!==null){const v=Math.max(1,p-h);l.duration=l.duration||{frames:v},l.duration.frames=v}}catch{}}const u=await this.composition.add(l);if(d!==null&&c>=0)try{const h=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:h},u.duration.frames=h}catch{}const m=Math.floor(n.timelineStart*this.fps);m>0&&u.offsetBy(m),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(h=>requestAnimationFrame(h)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=_t.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),a=new la({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?a.rotation=new Fe([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(a.scale=new Fe([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}n.startTime&&n.startTime>0&&a.offsetBy(n.startTime*this.fps),n.duration&&a.subclip(0,n.duration*this.fps);const i=await this.composition.add(a);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const a=this.clips.get(n);if(!a)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(c=>c.id));for(const[c,d]of i.entries())if(!r.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=i.get(c.id);let m=null;if(u&&u.signature===d)m=u.instance;else{if(u)try{u.instance.destroy()}catch{}m=this.createPixiFilter(c),m?i.set(c.id,{instance:m,signature:d}):i.delete(c.id)}m&&s.push(m)}this.filterCache.set(n,i);const l=a.view??a.sprite??a.displayObject??null;if("filters"in a)try{a.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof a.enter=="function"&&a.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},a=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:a})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,a=n.params||{};if(re.getFilter(n.filterId)&&!re.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=$m(n.filterId,a);return r||(r=tg(n.filterId,a)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!a.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(n={}){var s,l,c,d,u,m,h,p,v;const t=n.fps??this.fps,a=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((h=(m=this.composition)==null?void 0:m.renderer)==null?void 0:h.canvas);if(!a)throw new Error("Export failed: composition canvas is not initialized");(p=n.onProgress)==null||p.call(n,0);const i=new Q0(a,{fps:t});await i.init();const r=await i.export();return(v=n.onProgress)==null||v.call(n,100),r}destroy(){if(this.stopRenderLoop(),this.composition.pause(),this.clips.clear(),this.clipTimelineStart.clear(),this.filterCache.clear(),this.player&&this.composition.detachPlayer(this.player),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}this.player=null}startRenderLoop(){this.stopRenderLoop(),this.isDebug()&&this.dbg("renderLoop:start");const n=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(n)};n()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(n,t){const a=this.clips.get(n);if(!a)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(a.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,a;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)??((a=this.recipeSourceDimensions)==null?void 0:a.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,a){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(a*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,a;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:(((a=r.offset)==null?void 0:a.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const ng=["src"],ag={class:"preview-controls"},og=["aria-label"],ig={class:"time-display"},rg={class:"current-time"},sg={class:"total-time"},lg={key:2,class:"loading-overlay"},cg={key:3,class:"error-overlay"},dg=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(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),m=e.ref(0),h=e.ref(0);let p=null;const v=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 C,A;return(C=t.media)!=null&&C.url?t.media.url:(((A=t.media)==null?void 0:A.file)instanceof File,"")});async function M(){var C,A,R;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const W=((C=t.recipe.source)==null?void 0:C.original_width)||1920,O=((A=t.recipe.source)==null?void 0:A.original_height)||1080,I=((R=t.recipe.output)==null?void 0:R.fps)||30;p=new td(W,O,I,{fitMode:t.fitMode}),p.attachPlayer(r.value),c.value="Loading composition...",await p.loadFromRecipe(t.recipe),h.value=p.durationInSeconds,a("duration-change",h.value),V(),l.value=!1,a("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(W){const O=W instanceof Error?W.message:String(W);d.value=`Failed to initialize: ${O}`,l.value=!1}}function V(){if(!p)return;const C=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,a("time-update",m.value))},100);P.value=C}function b(){v.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,a("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,a("play-state-change",u.value))}function f(C){const A=Math.floor(C/60),R=Math.floor(C%60);return`${A}:${R.toString().padStart(2,"0")}`}function _(){d.value=null,v.value&&M()}function D(){!v.value&&s.value&&(h.value=s.value.duration,a("duration-change",h.value))}function B(){!v.value&&s.value&&(m.value=s.value.currentTime,a("time-update",m.value))}function E(){u.value=!1,a("play-state-change",!1)}function S(C){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&M()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),P.value&&(clearInterval(P.value),P.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async C=>{if(v.value&&C)if(p)try{await p.loadFromRecipe(C),h.value=p.durationInSeconds,a("duration-change",h.value)}catch{}else await M()}),e.watch(()=>t.enableEngine,async C=>{C?await M():p&&(P.value&&(clearInterval(P.value),P.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async C=>{if(!(!v.value||!p))try{p.setFitMode(C||"contain")}catch{}});const P=e.ref(null);return(C,A)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[v.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:r,class:"video-engine-player",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},null,512)):(e.openBlock(),e.createElementBlock("video",{key:1,ref_key:"videoRef",ref:s,src:w.value,onLoadedmetadata:D,onTimeupdate:B,onEnded:E,onError:S,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,ng)),e.createElementVNode("div",ag,[e.createElementVNode("button",{class:"play-button",onClick:b,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.value?e.unref(bc):e.unref(wc)},null,8,["icon"])],8,og),e.createElementVNode("div",ig,[e.createElementVNode("span",rg,e.toDisplayString(f(m.value)),1),A[0]||(A[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",sg,e.toDisplayString(f(h.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",lg,[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",cg,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:_},"Retry")])):e.createCommentVNode("",!0)],512))}}),Mr=Me(dg,[["__scopeId","data-v-7e604791"]]),ug=["aria-label"],mg=["aria-label"],pg={class:"clip-content"},fg={key:0,class:"clip-thumbnail"},hg=["src","alt"],vg={class:"clip-waveform"},gg={class:"clip-info"},yg={class:"clip-label"},bg={class:"clip-duration"},wg={key:1,class:"filter-indicators"},kg={key:2,class:"speed-indicator"},_g={key:0,class:"selection-overlay"},Eg=420,xg=8,Cg=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(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.ref(0),u=e.ref(0),m=e.ref(!1),h=e.ref(!1),p=e.ref(null),v=e.computed(()=>{const k=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${k}px`}}),g=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),w=e.computed(()=>{const F=t.clip.timelineEnd-t.clip.timelineStart;return b(F)}),M=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),V=e.computed(()=>t.clip.filters||[]);function b(F){if(F<1)return`${Math.round(F*30)}f`;if(F<60)return`${F.toFixed(1)}s`;{const k=Math.floor(F/60),$=Math.floor(F%60);return`${k}:${$.toString().padStart(2,"0")}`}}function f(F){return!F||typeof F!="string"?dl:F.includes("color")||F.includes("brightness")?yn:F.includes("blur")?dp:F.includes("style")?xa:F.includes("effect")?gn:dl}function _(){r.value||a("select")}function D(F){F.button===0&&(S("move",F.clientX),F.preventDefault())}function B(F){if(F.touches.length!==1)return;const k=F.touches[0];if(!t.isMobile){S("move",k.clientX),F.preventDefault();return}d.value=k.clientX,u.value=k.clientY,m.value=!1,h.value=!1,P(),C(),p.value=window.setTimeout(()=>{h.value=!0,C(),t.selected||a("select"),a("long-press")},Eg),document.addEventListener("touchmove",A),document.addEventListener("touchend",R),document.addEventListener("touchcancel",R),F.preventDefault()}function E(F,k){const $="touches"in k?k.touches[0].clientX:k.clientX;s.value=F==="start"?"trim-start":"trim-end",S(s.value,$),k.preventDefault(),k.stopPropagation()}function S(F,k){P(),C(),r.value=!0,s.value=F,l.value=k,F==="move"?c.value=t.clip.timelineStart:F==="trim-start"?c.value=t.clip.sourceIn:F==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",W),document.addEventListener("mouseup",O),document.addEventListener("touchmove",W),document.addEventListener("touchend",O),t.selected||a("select")}function P(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function C(){document.removeEventListener("touchmove",A),document.removeEventListener("touchend",R),document.removeEventListener("touchcancel",R)}function A(F){if(F.touches.length!==1)return;const k=F.touches[0],$=k.clientX-d.value,j=k.clientY-u.value;Math.hypot($,j)<xg||(m.value=!0,P(),C(),S("move",k.clientX),W(F),F.preventDefault())}function R(){const F=!m.value&&!h.value&&!r.value;P(),C(),m.value=!1,h.value=!1,F&&a("select")}function W(F){if(!r.value||!s.value)return;const k="touches"in F?F.touches[0].clientX:F.clientX,j=k-l.value;s.value==="move"?(a("drag",j),a("drag-abs",k)):s.value==="trim-start"?(a("trim-start",j),a("trim-start-abs",k)):s.value==="trim-end"&&(a("trim-end",j),a("trim-end-abs",k))}function O(){r.value=!1,s.value=null,document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",O),document.removeEventListener("touchmove",W),document.removeEventListener("touchend",O)}function I(){if(!i.value)return;const F=i.value,k=F.getContext("2d");if(!k)return;F.width=F.clientWidth*window.devicePixelRatio,F.height=F.clientHeight*window.devicePixelRatio,k.scale(window.devicePixelRatio,window.devicePixelRatio),k.strokeStyle="rgba(255, 255, 255, 0.3)",k.lineWidth=1,k.beginPath();const $=F.clientWidth,j=F.clientHeight,Z=j/2;k.moveTo(0,Z),k.lineTo($,Z);for(let K=0;K<$;K+=4){const ge=Math.sin(K*.05)*(j*.3);k.moveTo(K,Z-ge),k.lineTo(K,Z+ge)}k.stroke()}return e.onMounted(()=>{I(),window.addEventListener("resize",I)}),e.onUnmounted(()=>{O(),P(),C(),window.removeEventListener("resize",I)}),(F,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:F.selected,mobile:F.isMobile,"has-filters":M.value}]),style:e.normalizeStyle(v.value),onClick:_,onMousedown:D,onTouchstart:B},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:k[0]||(k[0]=e.withModifiers($=>E("start",$),["stop"])),onTouchstart:k[1]||(k[1]=e.withModifiers($=>E("start",$),["stop"])),"aria-label":`Trim start of ${F.clip.label||"clip"}`},[...k[4]||(k[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,ug),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:k[2]||(k[2]=e.withModifiers($=>E("end",$),["stop"])),onTouchstart:k[3]||(k[3]=e.withModifiers($=>E("end",$),["stop"])),"aria-label":`Trim end of ${F.clip.label||"clip"}`},[...k[5]||(k[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,mg),e.createElementVNode("div",pg,[F.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",fg,[e.createElementVNode("img",{src:F.clip.thumbnail,alt:F.clip.label||"Video clip"},null,8,hg)])):e.createCommentVNode("",!0),e.createElementVNode("div",vg,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",gg,[e.createElementVNode("span",yg,e.toDisplayString(g.value),1),e.createElementVNode("span",bg,e.toDisplayString(w.value),1)]),M.value?(e.openBlock(),e.createElementBlock("div",wg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,$=>(e.openBlock(),e.createBlock(e.unref(U.IonIcon),{key:$.id||$.filterId,icon:f($.filterId||$.id),title:`Filter: ${$.filterId||$.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),F.clip.speed&&F.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",kg,e.toDisplayString(F.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),F.selected?(e.openBlock(),e.createElementBlock("div",_g)):e.createCommentVNode("",!0)],38))}}),Sg=Me(Cg,[["__scopeId","data-v-be208792"]]);class nd{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const a=new Vr(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):a.duration.frames;a.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&a.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(a,n.transform),a}convertEngineClipToTimeline(n,t,a){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:a,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 a;(a=t.clear)==null||a.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await Bn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=_e.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof Vr&&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),a=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),a=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let a=0;if(t.length===2){const[i,r]=t;a=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;a=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else a=parseFloat(n);return a}timeToFrames(n){const t=n.split(":");let a=0;if(t.length===2){const[i,r]=t;a=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;a=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else a=parseFloat(n);return this.secondsToFrames(a)}}const Vg={class:"time-markers"},Ng=["aria-label","title"],Tg={key:0,class:"timeline-scrollbar"},Mg=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},duration:{},zoomLevel:{default:50},isMobile:{type:Boolean,default:!1},snapEnabled:{type:Boolean,default:!0},selectedClipId:{},fps:{default:30},useFrameMode:{type:Boolean,default:!1},sensitivity:{default:.25}},emits:["update:playhead","trim","split","clip-select","clip-move","clip-long-press","snap-state-change","toggle-frame-mode"],setup(o,{expose:n,emit:t}){const a=o,i=e.computed(()=>a.isMobile===!0),r=t,s=e.ref(),l=e.ref(a.selectedClipId||null),c=e.ref(!1),d=e.ref(0),u=e.ref(),m=e.ref(0),h=e.computed(()=>a.selectedClipId??l.value);e.watch(()=>a.selectedClipId,T=>{T!==void 0&&(l.value=T)});const p=new nd(a.fps),v=e.ref(!1),g=e.ref(null),w=e.ref(0),M=e.ref(0),V=e.ref(null),b=e.ref(0),f=e.ref(0),_=e.ref(0),D=e.ref(!1),B=e.ref(0),E=e.ref(a.zoomLevel),S=e.computed(()=>a.zoomLevel);function P(T){const z=a.clips.find(ee=>ee.id===T);if(!z)return null;const G=a.clips.filter(ee=>ee.id!==T&&ee.timelineStart>=z.timelineEnd-1e-9).map(ee=>ee.timelineStart);return G.length?Math.min(...G):null}function C(T){const z=T.sourceMaxOut??a.duration,G=T.timelineStart+(z-T.sourceIn),ee=P(T.id),pe=ee!=null?Math.max(T.timelineStart,ee):1/0;return Math.min(G,pe)}function A(T){const z=T.sourceMinIn??0,ee=(T.sourceMaxOut??a.duration)-z,pe=T.sourceIn-z;return{left:`${(T.timelineStart-pe)*S.value-d.value}px`,width:`${ee*S.value}px`,top:"0px",height:"80px",opacity:h.value===T.id?.25:.15}}const R=e.computed(()=>a.useFrameMode?a.zoomLevel:a.zoomLevel/a.fps),W=e.computed(()=>p.secondsToFrames(a.duration)),O=e.computed(()=>a.useFrameMode?W.value*R.value:a.duration*S.value),I=e.computed(()=>{var T;return m.value||((T=s.value)==null?void 0:T.clientWidth)||800}),F=e.computed(()=>O.value>I.value),k=e.computed(()=>Math.max(0,O.value-I.value)),$=e.computed(()=>d.value>0),j=e.computed(()=>d.value<k.value),Z=e.computed(()=>a.useFrameMode?p.secondsToFrames(a.playhead)*R.value-d.value:a.playhead*S.value-d.value),K=e.computed(()=>V.value===null?null:a.useFrameMode?p.secondsToFrames(V.value)*R.value-d.value:V.value*S.value-d.value),ge=e.computed(()=>{const T=Math.max(50,I.value/O.value*I.value),z=d.value/k.value*(I.value-T);return{width:`${T}px`,left:`${z}px`}}),we=e.computed(()=>{const T=[],z=ne();for(let G=0;G<=a.duration;G+=z){const ee=G*S.value-d.value;ee>=-50&&ee<=I.value+50&&T.push({position:ee,label:N(G),time:G})}return T});function ne(){const z=80/S.value;return z<=1?1:z<=5?5:z<=10?10:z<=30?30:z<=60?60:Math.ceil(z/60)*60}function N(T){if(a.useFrameMode)return`F${p.secondsToFrames(T)}`;{const z=Math.floor(T/60),G=Math.floor(T%60),ee=Math.floor(T%1*a.fps);return S.value>100?`${z}:${G.toString().padStart(2,"0")}:${ee.toString().padStart(2,"0")}`:`${z}:${G.toString().padStart(2,"0")}`}}function L(T){const z=s.value.getBoundingClientRect();let ee=(T.clientX-z.left+d.value)/S.value;const pe=a.clips.find(be=>ee>=be.timelineStart&&ee<=be.timelineEnd);if(pe)ee=Math.max(pe.timelineStart,Math.min(pe.timelineEnd,ee));else if(a.selectedClipId){const be=a.clips.find($e=>$e.id===a.selectedClipId);if(be){const $e=Math.abs(ee-be.timelineStart),Ae=Math.abs(ee-be.timelineEnd);ee=$e<Ae?be.timelineStart:be.timelineEnd}}else ee=Math.max(0,Math.min(ee,a.duration));r("update:playhead",ee)}function te(T){if(!F.value)return;const z=Math.abs(T.deltaX)>Math.abs(T.deltaY)?T.deltaX:T.deltaY;z!==0&&(T.preventDefault(),d.value=Math.max(0,Math.min(k.value,d.value+z)))}function ae(){return[...a.clips].sort((T,z)=>T.timelineStart-z.timelineStart)}function ie(T){const z=ae(),G=z.findIndex(ee=>ee.id===T);return{previous:G>0?z[G-1]:null,next:G!==-1&&G<z.length-1?z[G+1]:null}}function he(T){const z=T.timelineEnd-T.timelineStart,{previous:G,next:ee}=ie(T.id),pe=G?G.timelineEnd:0,be=ee?ee.timelineStart-z:Math.max(T.timelineStart,a.duration-z);return{minStart:pe,maxStart:Math.max(pe,be)}}function se(){return 12/Math.max(S.value,1)}function fe(T){return Array.from(new Set(T.filter(z=>typeof z=="number"&&Number.isFinite(z))))}function xe(T,z,G,ee){const pe=Math.max(G,Math.min(T,ee));if(!a.snapEnabled)return{value:pe,guideTime:null};const be=se();let $e=pe,Ae=null,Re=Number.POSITIVE_INFINITY;for(const Pe of fe(z)){if(Pe<G||Pe>ee)continue;const Je=Math.abs(Pe-pe);Je<=be&&Je<Re&&($e=Pe,Ae=Pe,Re=Je)}return{value:$e,guideTime:Ae}}function le(T){if(T.touches.length===2){D.value=!0;const z=T.touches[0],G=T.touches[1];B.value=Math.hypot(G.clientX-z.clientX,G.clientY-z.clientY),E.value=a.zoomLevel}else T.touches.length===1&&(b.value=T.touches[0].clientX,f.value=T.touches[0].clientY,_.value=b.value)}function de(T){if(D.value&&T.touches.length===2){const z=T.touches[0],G=T.touches[1],pe=Math.hypot(G.clientX-z.clientX,G.clientY-z.clientY)/B.value;Math.max(10,Math.min(200,E.value*pe)),r("update:playhead",a.playhead)}else if(T.touches.length===1&&!D.value){const z=T.touches[0],G=_.value-z.clientX;Math.abs(G)>Math.abs(z.clientY-f.value)&&(T.preventDefault(),d.value=Math.max(0,Math.min(O.value-I.value,d.value+G)),_.value=z.clientX)}}function Ve(){D.value=!1}function Be(T){const z=T.target;if(z.closest(".playhead-handle"))return;const G=T.button===1,ee=!!z.closest(".video-track");(G||!ee&&F.value)&&dt(T)}function dt(T){v.value=!0,g.value="pan",w.value=T.clientX,M.value=d.value,document.addEventListener("mousemove",et),document.addEventListener("mouseup",at)}function Ke(T){T.preventDefault(),T.stopPropagation(),v.value=!0,g.value="playhead";const z="touches"in T?T.touches[0].clientX:T.clientX;w.value=z,M.value=a.playhead,"touches"in T?(document.addEventListener("touchmove",et),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",et),document.addEventListener("mouseup",at))}function bt(T){T.preventDefault(),T.stopPropagation(),v.value=!0,g.value="scrollbar";const z="touches"in T?T.touches[0].clientX:T.clientX;w.value=z,M.value=d.value,"touches"in T?(document.addEventListener("touchmove",et),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",et),document.addEventListener("mouseup",at))}function et(T){if(!v.value)return;const G=("touches"in T?T.touches[0].clientX:T.clientX)-w.value;if(g.value==="playhead"){const ee=G/S.value;let pe=M.value+ee;if(a.selectedClipId){const be=a.clips.find($e=>$e.id===a.selectedClipId);be?pe=Math.max(be.timelineStart,Math.min(be.timelineEnd,pe)):pe=Math.max(0,Math.min(a.duration,pe))}else{const be=a.clips.find($e=>a.playhead>=$e.timelineStart&&a.playhead<=$e.timelineEnd);be?pe=Math.max(be.timelineStart,Math.min(be.timelineEnd,pe)):pe=Math.max(0,Math.min(a.duration,pe))}r("update:playhead",pe)}else if(g.value==="scrollbar"){const ee=G/I.value*O.value;d.value=Math.max(0,Math.min(k.value,M.value+ee))}else if(g.value==="pan"){const ee=M.value-G;d.value=Math.max(0,Math.min(k.value,ee))}}function at(){v.value=!1,g.value=null,V.value=null,document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",at),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",at)}function wt(T){l.value=l.value===T?null:T,r("clip-select",l.value)}function Vt(T){l.value=T,r("clip-select",T),r("clip-long-press",T)}function rt(T,z){const G=a.clips.find(pe=>pe.id===T);if(!G||Math.abs(z)<2)return;const ee=z/S.value*a.sensitivity;if(a.useFrameMode){const pe=p.secondsToFrames(G.sourceIn),be=p.secondsToFrames(ee),$e=Math.max(0,pe+be),Ae=p.framesToSeconds($e);r("trim",T,"start",Ae)}else{const pe=Math.max(0,G.sourceIn+ee);r("trim",T,"start",pe)}}function vt(T,z){const G=a.clips.find(xt=>xt.id===T);if(!G||!s.value)return;const ee=s.value.getBoundingClientRect(),pe=z-ee.left,be=80;if(pe<be)d.value=Math.max(0,d.value-8);else if(pe>ee.width-be){const xt=Math.max(0,O.value-I.value);d.value=Math.min(xt,d.value+8)}const $e=pe+d.value,Ae=1/a.fps;let Re=$e/S.value;const{previous:Pe}=ie(G.id),Je=xe(Re,[0,Pe==null?void 0:Pe.timelineEnd,a.playhead],0,G.timelineEnd-Ae);Re=Je.value,V.value=Je.guideTime;let tt=G.sourceIn+(Re-G.timelineStart);tt=Math.round(tt*a.fps)/a.fps,r("trim",T,"start",tt)}function ue(T,z){const G=a.clips.find(Ht=>Ht.id===T);if(!G||!s.value)return;const ee=s.value.getBoundingClientRect(),pe=z-ee.left,be=80;if(pe<be)d.value=Math.max(0,d.value-8);else if(pe>ee.width-be){const Ht=Math.max(0,O.value-I.value);d.value=Math.min(Ht,d.value+8)}const $e=pe+d.value,Ae=1/a.fps,Re=C(G);let Pe=$e/S.value;const{next:Je}=ie(G.id),tt=xe(Pe,[Je==null?void 0:Je.timelineStart,a.playhead],G.timelineStart+Ae,Re);Pe=tt.value,V.value=tt.guideTime;let xt=G.sourceIn+(Pe-G.timelineStart);xt=Math.round(xt*a.fps)/a.fps,r("trim",T,"end",xt)}function Se(T,z){const G=a.clips.find(tt=>tt.id===T);if(!G||!s.value)return;const ee=s.value.getBoundingClientRect(),pe=z-ee.left,be=80;if(pe<be)d.value=Math.max(0,d.value-8);else if(pe>ee.width-be){const tt=Math.max(0,O.value-I.value);d.value=Math.min(tt,d.value+8)}const $e=pe+d.value,Ae=G.timelineEnd-G.timelineStart,Re=he(G);let Pe=$e/S.value;const Je=xe(Pe,[Re.minStart,Re.maxStart,a.playhead,a.playhead-Ae],Re.minStart,Re.maxStart);Pe=Je.value,V.value=Je.guideTime,Pe=Math.round(Pe*a.fps)/a.fps,r("clip-move",T,Pe)}function Te(T,z){const G=a.clips.find(be=>be.id===T);if(!G||Math.abs(z)<2)return;const ee=z/S.value*a.sensitivity,pe=be=>Math.max(0,Math.round(be*a.fps)/a.fps);if(a.useFrameMode){const be=p.secondsToFrames(G.sourceOut),$e=p.secondsToFrames(ee),Ae=C(G),Re=G.sourceIn+(Ae-G.timelineStart),Pe=p.secondsToFrames(Re),Je=Math.min(Pe,be+$e),tt=p.framesToSeconds(Je);r("trim",T,"end",tt)}else{const be=C(G),$e=G.sourceIn+(be-G.timelineStart),Ae=Math.min($e,G.sourceOut+ee),Re=pe(Ae);r("trim",T,"end",Re)}}function je(T,z){const G=a.clips.find(be=>be.id===T);if(!G||Math.abs(z)<2)return;const ee=z/S.value*a.sensitivity,pe=be=>Math.max(0,Math.round(be*a.fps)/a.fps);if(a.useFrameMode){const be=p.secondsToFrames(G.timelineStart),$e=p.secondsToFrames(ee),Ae=Math.max(0,be+$e),Re=p.framesToSeconds(Ae);r("clip-move",T,Re)}else{const be=Math.max(0,G.timelineStart+ee),$e=pe(be);r("clip-move",T,$e)}}return n({handleTrimStart:rt,handleTrimEnd:Te,handleClipDrag:je,handleTrimStartAbs:vt,handleTrimEndAbs:ue,handleClipDragAbs:Se,handleClipLongPress:Vt}),e.watch(()=>a.playhead,T=>{const z=T*S.value;z<d.value+50?d.value=Math.max(0,z-50):z>d.value+I.value-50&&(d.value=Math.min(k.value,z-I.value+50))}),e.onMounted(()=>{const T=new ResizeObserver(z=>{z[0]&&(m.value=Math.round(z[0].contentRect.width))});s.value&&T.observe(s.value),e.onUnmounted(()=>T.disconnect())}),e.onUnmounted(()=>{at()}),e.watch([O,I],()=>{d.value>k.value&&(d.value=k.value)}),e.watch(V,(T,z)=>{const G=T!==null;G!==(z!==null)&&r("snap-state-change",G)}),(T,z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:te},[e.createElementVNode("div",{class:"timeline-ruler",onClick:L},[e.createElementVNode("div",Vg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(we.value,G=>(e.openBlock(),e.createElementBlock("span",{key:G.position,class:"time-marker",style:e.normalizeStyle({left:`${G.position}px`})},e.toDisplayString(G.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":F.value,"is-panning":v.value&&g.value==="pan","overflow-left":$.value,"overflow-right":j.value}]),onTouchstart:le,onTouchmove:de,onTouchend:Ve,onMousedown:Be},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.clips,G=>(e.openBlock(),e.createElementBlock("div",{key:`${G.id}-extent`,class:"clip-extent",style:e.normalizeStyle(A(G)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.clips,G=>(e.openBlock(),e.createBlock(Sg,{key:G.id,clip:G,scale:S.value,"scroll-offset":d.value,selected:h.value===G.id,"is-mobile":i.value,onSelect:ee=>wt(G.id),onLongPress:ee=>Vt(G.id),onTrimStartAbs:ee=>vt(G.id,ee),onTrimEndAbs:ee=>ue(G.id,ee),onDragAbs:ee=>Se(G.id,ee)},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:`${Z.value}px`}),onMousedown:Ke,onTouchstart:Ke},[...z[1]||(z[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${Z.value}px`})},null,4)):e.createCommentVNode("",!0),K.value!==null?(e.openBlock(),e.createElementBlock("div",{key:1,class:"snap-guide",style:e.normalizeStyle({left:`${K.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"frame-mode-toggle",onClick:z[0]||(z[0]=G=>T.$emit("toggle-frame-mode")),"aria-label":T.useFrameMode?"Switch to time mode":"Switch to frame mode",title:T.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(T.useFrameMode?"F":"T"),9,Ng))],34),F.value?(e.openBlock(),e.createElementBlock("div",Tg,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(ge.value),onMousedown:bt,onTouchstart:bt},null,36)])):e.createCommentVNode("",!0)],34))}}),Br=Me(Mg,[["__scopeId","data-v-d46ec03b"]]),Bg={class:"control-group zoom-controls"},Fg={class:"zoom-slider"},Ig=["value"],$g={class:"control-group playback-controls"},Rg=["aria-label"],Dg={key:0,class:"control-group speed-control"},Ag=["value"],Lg=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(o,{emit:n}){const t=n;function a(u){const m=u.target;t("zoom-change",Number(m.value))}function i(){t("fit-to-window")}function r(){t("frame-forward")}function s(){t("frame-backward")}function l(){t("skip-to-start")}function c(){t("skip-to-end")}function d(u){const m=u.target;t("speed-change",Number(m.value))}return(u,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",Bg,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=h=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Cp)},null,8,["icon"])]),e.createElementVNode("div",Fg,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,Ig)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=h=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cp)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",$g,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ep)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(bp)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=h=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.isPlaying?e.unref(Gr):e.unref(Jr)},null,8,["icon"])],8,Rg),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(_p)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xp)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Dg,[m[5]||(m[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...m[4]||(m[4]=[e.createStaticVNode('<option value="0.25" data-v-7bf65ab9>0.25x</option><option value="0.5" data-v-7bf65ab9>0.5x</option><option value="1" data-v-7bf65ab9>1x</option><option value="1.5" data-v-7bf65ab9>1.5x</option><option value="2" data-v-7bf65ab9>2x</option>',5)])],40,Ag)]))],2))}}),ad=Me(Lg,[["__scopeId","data-v-7bf65ab9"]]),Ug={key:0,class:"category-section"},Og={class:"category-carousel-wrapper"},Pg=["disabled"],zg=["onClick","data-testid","aria-label"],jg={class:"category-name"},Wg=["disabled"],Zg={class:"filter-section"},Hg={class:"filter-carousel-wrapper"},Xg=["disabled"],Gg=["onClick","onKeydown","data-testid","aria-label"],Jg=["onClick"],Yg={class:"filter-preview"},qg={class:"filter-placeholder"},Kg={class:"filter-name"},Qg=["disabled"],e1={class:"carousel-pagination"},t1=["onClick"],n1={key:1,class:"filter-adjustments"},a1={class:"adjustment-header"},o1={class:"adjustment-actions"},i1={key:0},r1={key:0,class:"slider-control"},s1={class:"control-label"},l1={class:"slider-wrapper"},c1={class:"slider-value"},d1={key:1,class:"color-control"},u1={class:"control-label"},m1={class:"color-wrapper"},p1=["value","onInput","disabled"],f1={class:"color-value"},h1={key:2,class:"toggle-control"},v1={class:"control-label"},g1={key:3,class:"select-control"},y1={class:"control-label"},b1=["value","onChange","disabled"],w1=["value"],k1={key:1,class:"no-params"},_1=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(o,{emit:n}){const t=o,a=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),m={all:gn,adjust:ya,color:yn,blur:co,light:ba,effects:Gi,stylize:xa,advanced:gn,distortion:Ca,transform:Ca};function h(k){return k.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(k){return k.replace(/[-_]/g," ").replace(/\b\w/g,$=>$.toUpperCase())}function v(k){return m[k.toLowerCase()]??gn}const g=e.computed(()=>{const k=Array.from(new Set(t.filters.map($=>$.category).filter($=>typeof $=="string"&&$.length>0))).sort(($,j)=>$.localeCompare(j));return[{id:"all",name:"All",icon:gn},...k.map($=>({id:$,name:p($),icon:v($)}))]}),w=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(k=>k.category===i.value));e.watch(g,k=>{new Set(k.map(Z=>Z.id)).has(i.value)||(i.value="all");const j=Math.max(0,k.length-3);s.value>j&&(s.value=j)},{immediate:!0});function M(k){var $;return(($=t.activeFilters)==null?void 0:$.has(k))||!1}function V(k){if(r.value=k,!M(k.id)&&(a("apply-filter",k),k.params&&k.params.length>0)){const $=new Map;k.params.forEach(j=>{$.set(j.id,j.default)}),c.value.set(k.id,$)}a("preview-filter",k)}function b(k){var $;a("remove-filter",k),c.value.delete(k),(($=r.value)==null?void 0:$.id)===k&&(r.value=null)}function f(k){if(typeof k=="number"&&Number.isFinite(k))return k;if(typeof k=="string"){const $=Number(k);return Number.isFinite($)?$:null}return null}function _(k,$){var N;const j=t.filters.find(L=>L.id===k),Z=j==null?void 0:j.params.find(L=>L.id===$),K=(Z==null?void 0:Z.default)??0,ge=L=>typeof K=="number"?f(L)??K:typeof K=="boolean"?typeof L=="boolean"?L:K:typeof L=="string"?L:K,we=(N=t.activeFilters)==null?void 0:N.get(k);if(we&&we.params){const L=we.params[$];if(L!=null)return ge(L)}const ne=c.value.get(k);if(ne){const L=ne.get($);if(L!=null)return ge(L)}return K}function D(k,$,j){var Z;c.value.has(k)||c.value.set(k,new Map),(Z=c.value.get(k))==null||Z.set($,j),a("update-param",k,$,j)}function B(k){if(typeof k=="boolean")return k?"On":"Off";if(typeof k=="string"){const j=f(k);return j===null?"0":Number.isInteger(j)?j.toString():j.toFixed(2)}const $=f(k);return $===null?"0":Number.isInteger($)?$.toString():$.toFixed(2)}function E(){if(r.value&&(a("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const k=new Map;r.value.params.forEach($=>{k.set($.id,$.default)}),c.value.set(r.value.id,k)}}function S(k){const $=t.filters.find(j=>j.id===k);$&&$.params&&$.params.forEach(j=>{D(k,j.id,j.default)})}function P(k){return{basic:ya,color:yn,blur:co,light:ba,effects:Gi,stylize:xa,adjustment:ya,"color-matrix":yn,glow:gn,distortion:Ca}[k]||gn}function C(k){return{adjustment:ya,brightness:ba,contrast:ya,saturation:yn,blur:co,"gaussian-blur":co,"color-matrix":yn,grayscale:xa,sepia:xa,vignette:Ca,glow:gn,glitch:Gi,godray:ba,lightmap:ba}[k.id]||P(k.category)}function A(){s.value>0&&(s.value--,F(d.value,s.value))}function R(){s.value<g.value.length-3&&(s.value++,F(d.value,s.value))}function W(){l.value>0&&(l.value--,F(u.value,l.value))}function O(){l.value<w.value.length-4&&(l.value++,F(u.value,l.value))}function I(k){l.value=k*4,F(u.value,l.value)}function F(k,$){var j;if(k){const Z=((j=k.querySelector(".category-chip, .filter-card"))==null?void 0:j.clientWidth)||100;k.scrollTo({left:$*(Z+8),behavior:"smooth"})}}return(k,$)=>{var j;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:k.compact}])},[k.showCategories?(e.openBlock(),e.createElementBlock("div",Ug,[e.createElementVNode("div",Og,[e.createElementVNode("button",{onClick:A,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(il)},null,8,["icon"])],8,Pg),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,Z=>(e.openBlock(),e.createElementBlock("button",{key:Z.id,onClick:K=>i.value=Z.id,class:e.normalizeClass(["category-chip",{active:i.value===Z.id}]),"data-testid":`btn-filter-category-${h(Z.id)}`,"aria-label":`Filter category ${Z.name}`},[e.createVNode(e.unref(U.IonIcon),{icon:Z.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",jg,e.toDisplayString(Z.name),1)],10,zg))),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(rl)},null,8,["icon"])],8,Wg)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Zg,[e.createElementVNode("div",Hg,[e.createElementVNode("button",{onClick:W,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(il)},null,8,["icon"])],8,Xg),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,Z=>{var K;return e.openBlock(),e.createElementBlock("div",{key:Z.id,class:e.normalizeClass(["filter-card",{active:M(Z.id),selected:((K=r.value)==null?void 0:K.id)===Z.id}]),onClick:ge=>V(Z),onKeydown:[e.withKeys(ge=>V(Z),["enter"]),e.withKeys(e.withModifiers(ge=>V(Z),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${h(Z.id)}`,"aria-label":`Select filter ${Z.name}`},[M(Z.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ge=>b(Z.id),["stop"])},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(vc)},null,8,["icon"])],8,Jg)):e.createCommentVNode("",!0),e.createElementVNode("div",Yg,[e.createElementVNode("div",qg,[e.createVNode(e.unref(U.IonIcon),{icon:C(Z),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",Kg,e.toDisplayString(Z.name),1)],42,Gg)}),128))],512),e.createElementVNode("button",{onClick:O,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(rl)},null,8,["icon"])],8,Qg)]),e.createElementVNode("div",e1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(w.value.length/4),(Z,K)=>(e.openBlock(),e.createElementBlock("span",{key:K,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===K}]),onClick:ge=>I(K)},null,10,t1))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",n1,[e.createElementVNode("div",a1,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",o1,[M(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:E,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),M(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:$[0]||($[0]=Z=>b(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),M(r.value.id)&&((j=r.value.params)==null?void 0:j.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:$[1]||($[1]=Z=>S(r.value.id)),class:"reset-btn","data-testid":"btn-reset-selected-filter"}," Reset ")):e.createCommentVNode("",!0)])]),r.value.params&&r.value.params.length>0?(e.openBlock(),e.createElementBlock("div",i1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,Z=>(e.openBlock(),e.createElementBlock("div",{key:Z.id,class:"adjustment-control"},[!Z.type||Z.type==="slider"?(e.openBlock(),e.createElementBlock("div",r1,[e.createElementVNode("label",s1,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("div",l1,[e.createVNode(e.unref(U.IonRange),{value:_(r.value.id,Z.id),onIonChange:K=>D(r.value.id,Z.id,K.detail.value),min:Z.min,max:Z.max,step:Z.step||.01,color:"primary",class:"compact-slider",disabled:!M(r.value.id),"data-testid":`range-filter-${h(r.value.id)}-${h(Z.id)}`,"aria-label":`Adjust ${Z.label||Z.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",c1,e.toDisplayString(B(_(r.value.id,Z.id))),1)])])):Z.type==="color"?(e.openBlock(),e.createElementBlock("div",d1,[e.createElementVNode("label",u1,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("div",m1,[e.createElementVNode("input",{type:"color",value:_(r.value.id,Z.id),onInput:K=>D(r.value.id,Z.id,K.target.value),disabled:!M(r.value.id),class:"color-input"},null,40,p1),e.createElementVNode("span",f1,e.toDisplayString(_(r.value.id,Z.id)),1)])])):Z.type==="toggle"?(e.openBlock(),e.createElementBlock("div",h1,[e.createElementVNode("label",v1,e.toDisplayString(Z.label||Z.id),1),e.createVNode(e.unref(U.IonToggle),{checked:!!_(r.value.id,Z.id),onIonChange:K=>D(r.value.id,Z.id,K.detail.checked),disabled:!M(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):Z.type==="select"?(e.openBlock(),e.createElementBlock("div",g1,[e.createElementVNode("label",y1,e.toDisplayString(Z.label||Z.id),1),e.createElementVNode("select",{value:_(r.value.id,Z.id),onChange:K=>D(r.value.id,Z.id,K.target.value),disabled:!M(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.options,K=>(e.openBlock(),e.createElementBlock("option",{key:String(K.value),value:K.value},e.toDisplayString(K.label),9,w1))),128))],40,b1)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",k1," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),Fr=Me(_1,[["__scopeId","data-v-9efd15d9"]]);class E1{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,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.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,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.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 a=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const i=new a;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const a=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const i=new a;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const a=this.mapMediablesToPIXI(t);a&&(this.pixiFilters.set(t.id,a),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,a))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const a=this.pixiFilters.get(n);a&&(this.filterParams.set(n,t),"blur"in a&&(a.blur=t.intensity||a.blur),"brightness"in a&&a.brightness(t.value||1,!1),"contrast"in a&&a.contrast(t.value||1,!1),"saturate"in a&&a.saturate(t.value||1,!1),"hue"in a&&a.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,a)=>{const i=this.filterParams.get(a)??{},r=this.filterTypes.get(a)??"unknown",s=this.filterIntensity.get(a)??1;n.push({id:a,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const x1={class:"video-filter-preview"},C1={class:"preview-title"},S1={class:"filter-controls"},V1={class:"control-input"},N1=["value","onInput","min","max","step"],T1={class:"param-value"},M1={class:"preview-container"},B1={key:0,class:"filter-presets"},F1=["onClick"],I1={class:"preview-actions"},$1=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const m=e.computed(()=>{var E;return((E=t.filter)==null?void 0:E.paramRanges)||{}}),h=e.computed(()=>p.value.length>0),p=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function v(){var E;if(i.value){t.useVideoEngine&&t.composition&&(u=new E1(t.composition));try{if(l=new st.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(E=t.currentFrame)!=null&&E.dataUrl){const S=await st.Assets.load(t.currentFrame.dataUrl);c=new st.Sprite(S);const P=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(P),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}g()}catch{}}}function g(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const E={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([E]).then(()=>{}).catch(S=>{}),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(E,S){switch(E){case"brightness":{const P=new st.ColorMatrixFilter,C=1+(S.value??0);return typeof P.brightness=="function"&&P.brightness(C,!1),P}case"contrast":{const P=new st.ColorMatrixFilter,C=S.value??1;return typeof P.contrast=="function"&&P.contrast(C,!1),P}case"saturation":{const P=new st.ColorMatrixFilter,C=S.value??1;return typeof P.saturate=="function"&&P.saturate(C,!1),P}case"hue":{const P=new st.ColorMatrixFilter,C=S.value??0;return typeof P.hue=="function"&&P.hue(C,!1),P}case"gaussian-blur":{const P=S.value??5;return new st.BlurFilter({strength:P,quality:4})}case"sepia":{const P=new st.ColorMatrixFilter;return typeof P.sepia=="function"&&P.sepia(!1),P}case"grayscale":{const P=new st.ColorMatrixFilter;return typeof P.desaturate=="function"&&P.desaturate(),P}default:return null}}function M(E,S){const P=S.target,C=Number.parseFloat(P.value),A=Number.isFinite(C)?C:0;s.value={...s.value,[E]:A},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),g()}function V(E){return E.charAt(0).toUpperCase()+E.slice(1).replace(/_/g," ")}function b(E,S){var C;const P=typeof E=="number"?E:Number(E);return Number.isFinite(P)?S==="hue"||S==="angle"?`${P}°`:S==="value"&&((C=t.filter)==null?void 0:C.id)==="brightness"?`${Math.round((1+P)*100)}%`:Number.isInteger(P)?P.toString():P.toFixed(2):"0"}function f(){var E;s.value=((E=t.filter)==null?void 0:E.defaultParams)||{},a("update-params",s.value),g()}function _(E){s.value={...E.params},a("update-params",s.value),g()}function D(E){return JSON.stringify(E.params)===JSON.stringify(s.value)}function B(){a("apply")}return e.watch(()=>t.filter,E=>{E&&(s.value={...E.defaultParams},g())}),e.watch(()=>t.currentFrame,async E=>{if(E!=null&&E.dataUrl&&c){const S=await st.Assets.load(E.dataUrl);c.texture=S}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),v()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(E,S)=>{var P;return e.openBlock(),e.createElementBlock("div",x1,[e.createElementVNode("h4",C1,e.toDisplayString((P=E.filter)==null?void 0:P.name)+" Settings",1),e.createElementVNode("div",S1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(C,A)=>(e.openBlock(),e.createElementBlock("div",{key:A,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(V(A)),1),e.createElementVNode("div",V1,[e.createElementVNode("input",{type:"range",value:s.value[A],onInput:R=>M(A,R),min:C.min,max:C.max,step:C.step,class:"param-slider"},null,40,N1),e.createElementVNode("span",T1,e.toDisplayString(b(s.value[A],A)),1)])]))),128))]),e.createElementVNode("div",M1,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:S[0]||(S[0]=C=>r.value=!0),onMouseup:S[1]||(S[1]=C=>r.value=!1),onTouchstart:S[2]||(S[2]=C=>r.value=!0),onTouchend:S[3]||(S[3]=C=>r.value=!1)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),h.value?(e.openBlock(),e.createElementBlock("div",B1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,C=>(e.openBlock(),e.createElementBlock("button",{key:C.name,class:e.normalizeClass(["preset-button",{active:D(C)}]),onClick:A=>_(C)},e.toDisplayString(C.name),11,F1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",I1,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),S[5]||(S[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:B},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(gc)},null,8,["icon"]),S[6]||(S[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Ir=Me($1,[["__scopeId","data-v-3de3dd04"]]),R1={class:"export-settings"},D1={class:"setting-group"},A1={class:"setting-group"},L1={class:"estimated-size"},U1={key:0,class:"export-progress"},O1={class:"progress-header"},P1={class:"progress-percentage"},z1={class:"progress-time"},j1={class:"action-buttons"},W1=["disabled"],Z1=["disabled"],H1=["disabled"],X1={class:"export-options"},G1=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(o,{emit:n}){const t=o,a=n,i=e.ref("1080p"),r=e.ref("mp4"),s=e.ref(!0),l=e.ref(!1),c=e.ref(0),d=e.ref(0),u=e.ref(0);let m=null;const h=e.computed(()=>{const f=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return f<1e3?`~${Math.round(f)} MB`:`~${(f/1e3).toFixed(1)} GB`});function p(){t.isExporting?(a("cancel-export"),w()):v()}function v(){const V={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",V),g()}function g(){c.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const V=d.value/t.exportProgress*100;u.value=Math.max(0,V-d.value)}},1e3)}function w(){m&&(clearInterval(m),m=null)}function M(V){const b=Math.floor(V/60),f=Math.floor(V%60);return`${b}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,V=>{V||w()}),e.onUnmounted(()=>{w()}),(V,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:V.isMobile}])},[e.createElementVNode("div",R1,[b[10]||(b[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",D1,[b[7]||(b[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[0]||(b[0]=f=>i.value=f),class:"setting-select"},[...b[6]||(b[6]=[e.createStaticVNode('<option value="360p" data-v-e1338d5e>360p (Low)</option><option value="480p" data-v-e1338d5e>480p (SD)</option><option value="720p" data-v-e1338d5e>720p (HD)</option><option value="1080p" data-v-e1338d5e>1080p (Full HD)</option><option value="1440p" data-v-e1338d5e>1440p (2K)</option><option value="2160p" data-v-e1338d5e>2160p (4K)</option>',6)])],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("div",A1,[b[9]||(b[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[1]||(b[1]=f=>r.value=f),class:"setting-select"},[...b[8]||(b[8]=[e.createElementVNode("option",{value:"mp4"},"MP4 (Most Compatible)",-1),e.createElementVNode("option",{value:"webm"},"WebM (Web Optimized)",-1),e.createElementVNode("option",{value:"mov"},"MOV (Apple)",-1)])],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",L1,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(pp)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(h.value),1)])]),V.isExporting?(e.openBlock(),e.createElementBlock("div",U1,[e.createElementVNode("div",O1,[b[11]||(b[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",P1,e.toDisplayString(V.exportProgress??0)+"%",1)]),e.createVNode(e.unref(U.IonProgressBar),{value:(V.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",z1,[e.createElementVNode("span",null,e.toDisplayString(M(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(M(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",j1,[e.createElementVNode("button",{class:"control-button secondary",onClick:b[2]||(b[2]=f=>V.$emit("save-draft")),disabled:!V.canExport||V.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xo)},null,8,["icon"]),b[12]||(b[12]=e.createTextVNode(" Save Draft ",-1))],8,W1),e.createElementVNode("button",{class:"control-button secondary",onClick:b[3]||(b[3]=f=>V.$emit("reset")),disabled:V.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),b[13]||(b[13]=e.createTextVNode(" Reset ",-1))],8,Z1),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!V.canExport&&!V.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(U.IonIcon),{icon:V.isExporting?e.unref(Rn):e.unref(aa)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(V.isExporting?"Cancel":"Export Video"),1)],8,H1)]),e.createElementVNode("div",X1,[e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":b[4]||(b[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...b[14]||(b[14]=[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:l.value,"onUpdate:modelValue":b[5]||(b[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...b[15]||(b[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),$r=Me(G1,[["__scopeId","data-v-e1338d5e"]]),J1={class:"thumbnail-picker"},Y1={class:"thumbnail-grid"},q1=["onClick"],K1=["src","alt"],Q1={key:1,class:"thumbnail-placeholder"},ey={class:"thumbnail-time"},ty={class:"custom-selector"},ny={class:"time-input-group"},ay=["max"],oy={class:"time-value"},iy=["disabled"],ry={class:"picker-actions"},sy=["disabled"],ly=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(o,{emit:n}){const t=o,a=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const M=[];if(t.duration<=10)for(let b=0;b<Math.min(9,t.duration);b++)M.push(b);else{const b=t.duration/10;for(let f=1;f<=9;f++)M.push(b*f)}return M}async function d(M){try{const V=document.createElement("video");return V.crossOrigin="anonymous",V.src=await u(),new Promise(b=>{V.addEventListener("loadedmetadata",()=>{V.currentTime=M}),V.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=V.videoWidth,f.height=V.videoHeight;const _=f.getContext("2d");_?(_.drawImage(V,0,0),b(f.toDataURL("image/jpeg",.8))):b(null),V.remove()}),V.addEventListener("error",()=>{b(null),V.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function m(){const M=c();i.value=M.map(b=>({time:b,loading:!0}));const V=3;for(let b=0;b<i.value.length;b+=V){const f=i.value.slice(b,b+V);await Promise.all(f.map(async _=>{const D=await d(_.time);D&&(_.dataUrl=D),_.loading=!1}))}}function h(M){r.value=M,s.value=i.value[M].time}function p(){r.value=-1}async function v(){l.value=!0;try{const M=await d(s.value);if(M){const V=i.value.findIndex(b=>Math.abs(b.time-s.value)<.1);V>=0?(i.value[V].dataUrl=M,r.value=V):(i.value.push({time:s.value,dataUrl:M}),r.value=i.value.length-1,i.value.sort((b,f)=>b.time-f.time),r.value=i.value.findIndex(b=>b.time===s.value))}}finally{l.value=!1}}function g(){const M=r.value>=0?i.value[r.value].time:s.value;a("select",M)}function w(M){const V=Math.floor(M/60),b=Math.floor(M%60),f=Math.floor(M%1*100);return V>0?`${V}:${b.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${b}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(M,V)=>(e.openBlock(),e.createElementBlock("div",J1,[V[5]||(V[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",Y1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(b,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass(["thumbnail-item",{selected:r.value===f}]),onClick:_=>h(f)},[b.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:b.dataUrl,alt:`Frame at ${w(b.time)}`},null,8,K1)):(e.openBlock(),e.createElementBlock("div",Q1,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",ey,e.toDisplayString(w(b.time)),1)],10,q1))),128))]),e.createElementVNode("div",ty,[V[3]||(V[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",ny,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":V[0]||(V[0]=b=>s.value=b),min:0,max:M.duration,step:.1,onInput:p,class:"time-slider"},null,40,ay),[[e.vModelText,s.value]]),e.createElementVNode("span",oy,e.toDisplayString(w(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(tp)},null,8,["icon"]),V[2]||(V[2]=e.createTextVNode(" Capture Frame ",-1))],8,iy)]),e.createElementVNode("div",ry,[e.createElementVNode("button",{class:"action-button",onClick:V[1]||(V[1]=b=>M.$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(gc)},null,8,["icon"]),V[4]||(V[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,sy)])]))}}),cy=Me(ly,[["__scopeId","data-v-336c322c"]]),dy={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},uy={class:"mb-4"},my={class:"space-y-2 max-h-64 overflow-y-auto"},py={class:"flex items-center justify-between"},fy={class:"flex-1"},hy={class:"font-medium text-gray-900 dark:text-white"},vy={class:"text-sm text-gray-500 dark:text-gray-400"},gy={class:"flex items-center space-x-2"},yy=["onClick"],by=["onClick"],wy={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},ky={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},_y={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Ey={class:"space-y-4"},xy={class:"grid grid-cols-2 gap-4"},Cy={class:"grid grid-cols-2 gap-4"},Sy={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Vy={class:"grid grid-cols-2 gap-3"},Ny={class:"flex justify-end space-x-3 mt-6"},Ty=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(o,{emit:n}){const t=n,a=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function l(h){Object.assign(s,h),i.value=h}function c(){a.value=!1,i.value=null,Object.assign(s,r())}function d(){const h={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(h.animation={type:s.animationType},s.animationDuration!==void 0&&(h.animation.duration=s.animationDuration),s.animationEasing&&(h.animation.easing=s.animationEasing),h.animation))switch(s.animationType){case"rotate":h.animation.rotation={from:0,to:360};break;case"scale":h.animation.scale={from:.5,to:1};break;case"slide":h.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,h):t("add-overlay",h),c()}function u(h){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",h)}function m(h){const p=Math.floor(h/60),v=Math.floor(h%60);return`${p}:${v.toString().padStart(2,"0")}`}return(h,p)=>(e.openBlock(),e.createElementBlock("div",dy,[e.createElementVNode("div",uy,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=v=>a.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...p[10]||(p[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",my,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.overlays,v=>(e.openBlock(),e.createElementBlock("div",{key:v.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"},[e.createElementVNode("div",py,[e.createElementVNode("div",fy,[e.createElementVNode("div",hy,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",vy,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",gy,[e.createElementVNode("button",{onClick:g=>l(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,yy),e.createElementVNode("button",{onClick:g=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,by)])])]))),128)),h.overlays.length===0?(e.openBlock(),e.createElementBlock("div",wy," No text overlays added yet ")):e.createCommentVNode("",!0)]),a.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",ky,[e.createElementVNode("h4",_y,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Ey,[e.createElementVNode("div",null,[p[14]||(p[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":p[1]||(p[1]=v=>s.text=v),rows:"3",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter your text..."},null,512),[[e.vModelText,s.text]])]),e.createElementVNode("div",xy,[e.createElementVNode("div",null,[p[15]||(p[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[2]||(p[2]=v=>s.fontSize=v),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[16]||(p[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[3]||(p[3]=v=>s.color=v),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[p[18]||(p[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[4]||(p[4]=v=>s.position=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[17]||(p[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",Cy,[e.createElementVNode("div",null,[p[19]||(p[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[5]||(p[5]=v=>s.startTime=v),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[20]||(p[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[6]||(p[6]=v=>s.duration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[p[22]||(p[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[7]||(p[7]=v=>s.animationType=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[21]||(p[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",Sy,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Vy,[e.createElementVNode("div",null,[p[23]||(p[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[8]||(p[8]=v=>s.animationDuration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[25]||(p[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[9]||(p[9]=v=>s.animationEasing=v),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...p[24]||(p[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ny,[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)]))}}),Rr=Me(Ty,[["__scopeId","data-v-f86e688c"]]),Ra=class Ra{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,a){const i=`transition-${this.nextId++}`,r=Math.round(a.duration*30),s=a.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(a.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,a.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,a.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,a.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,a.type,d,u,s);break}return this.transitions.set(i,a),i}async applyFadeTransition(n,t,a,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Fe([a,i],[1,0],{easing:r}),t.alpha=new Fe([a,i],[0,1],{easing:r}),t.start=_e.fromFrames(a)}async applyCrossFadeTransition(n,t,a,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Fe([a,i],[1,0],{easing:r}),t.alpha=new Fe([a,i],[0,1],{easing:r}),t.start=_e.fromFrames(a)}async applyWipeTransition(n,t,a,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(a){case"wipe-left":l.x=new Fe([i,r],[0,-1920],{easing:s}),c.x=new Fe([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Fe([i,r],[0,1920],{easing:s}),c.x=new Fe([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Fe([i,r],[0,-1080],{easing:s}),c.y=new Fe([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Fe([i,r],[0,1080],{easing:s}),c.y=new Fe([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=_e.fromFrames(i)}async applySlideTransition(n,t,a,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(a){case"slide-left":l.x=new Fe([i,r],[0,-1920],{easing:s}),c.x=new Fe([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Fe([i,r],[0,1920],{easing:s}),c.x=new Fe([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Fe([i,r],[0,-1080],{easing:s}),c.y=new Fe([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Fe([i,r],[0,1080],{easing:s}),c.y=new Fe([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=_e.fromFrames(i)}async applyZoomTransition(n,t,a,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");a==="zoom-in"?(n.scale=new Fe([i,r],[1,2],{easing:s}),n.alpha=new Fe([i,r],[1,0],{easing:s}),t.scale=new Fe([i,r],[.5,1],{easing:s}),t.alpha=new Fe([i,r],[0,1],{easing:s})):(n.scale=new Fe([i,r],[1,.5],{easing:s}),n.alpha=new Fe([i,r],[1,0],{easing:s}),t.scale=new Fe([i,r],[2,1],{easing:s}),t.alpha=new Fe([i,r],[0,1],{easing:s})),t.start=_e.fromFrames(i)}async applyDipTransition(n,t,a,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=a==="dip-to-black"?"#000000":"#ffffff",d=await Cr.fromColor(c),u=new u0(d,{start:_e.fromFrames(i),stop:_e.fromFrames(r)});n.alpha=new Fe([i,l],[1,0],{easing:s}),u.alpha=new Fe([i,l,r],[0,1,0],{easing:s}),t.alpha=new Fe([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=_e.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[...Ra.TRANSITIONS]}static previewTransition(n){return Ra.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};Ra.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 La=Ra;const My={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},By={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Fy=["onClick"],Iy={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"},$y={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ry={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},Dy={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},Ay={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"},Ly={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"},Uy={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"},Oy={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},Py={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},zy={class:"space-y-3"},jy={class:"flex items-center space-x-2"},Wy=["disabled"],Zy=["disabled"],Hy={key:1,class:"mt-4"},Xy={class:"space-y-2 max-h-32 overflow-y-auto"},Gy={class:"text-sm text-gray-700 dark:text-gray-300"},Jy=["onClick"],Yy=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(La.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(v){r.value=v}function u(){if(!r.value||!c.value)return;const v={type:r.value.type,duration:s.value,easing:l.value};a("apply-transition",v),r.value=null}function m(){if(!r.value)return;const v={type:r.value.type,duration:s.value,easing:l.value};a("preview-transition",v)}function h(v){a("remove-transition",v)}function p(v){return["fade","wipe","slide","zoom"].some(g=>v.includes(g))}return(v,g)=>(e.openBlock(),e.createElementBlock("div",My,[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",By,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,w=>{var M;return e.openBlock(),e.createElementBlock("div",{key:w.type,onClick:V=>d(w),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((M=r.value)==null?void 0:M.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",Iy,[p(w.type)?(e.openBlock(),e.createElementBlock("svg",$y,[w.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Ry)):w.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",Dy)):w.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",Ay)):w.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",Ly)):(e.openBlock(),e.createElementBlock("path",Uy))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Oy,e.toDisplayString(w.name),1)],10,Fy)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",Py,[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",zy,[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",jy,[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,Wy),e.createElementVNode("button",{onClick:m,disabled:!r.value,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"}," Preview ",8,Zy)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Hy,[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",Xy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(w,M)=>(e.openBlock(),e.createElementBlock("div",{key:M,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",Gy,e.toDisplayString(w.name)+" ("+e.toDisplayString(w.duration)+"s) ",1),e.createElementVNode("button",{onClick:V=>h(M),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Jy)]))),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))]))}}),Dr=Me(Yy,[["__scopeId","data-v-5ef1b100"]]),qy={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Ky={class:"mb-4"},Qy={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},eb={class:"flex items-center justify-between mb-2"},tb={class:"text-sm text-gray-600 dark:text-gray-400"},nb={class:"flex items-center space-x-2"},ab={class:"space-y-3 max-h-64 overflow-y-auto"},ob={class:"flex items-center justify-between mb-2"},ib={class:"font-medium text-gray-900 dark:text-white"},rb={class:"flex items-center space-x-2"},sb=["onClick","title"],lb={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},cb={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},db=["onClick"],ub=["onClick"],mb={class:"flex items-center space-x-2"},pb={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},fb=["value","onInput","disabled"],hb={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},vb={key:0,class:"ml-2"},gb={key:1,class:"ml-2"},yb={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},bb={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},wb={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},kb={class:"space-y-4"},_b={class:"space-y-2"},Eb={class:"flex items-center"},xb={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},Cb={class:"grid grid-cols-2 gap-4"},Sb={class:"grid grid-cols-2 gap-4"},Vb={class:"flex items-center"},Nb={class:"flex justify-end space-x-3 mt-6"},Tb=["disabled"],Mb=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(b){const f=b.target;f.files&&f.files[0]&&(c.sourceFile=f.files[0],c.name=c.name||f.files[0].name.replace(/\.[^/.]+$/,""))}function m(b){Object.assign(c,b),r.value=b}function h(){i.value=!1,r.value=null,Object.assign(c,l())}function p(){if(!d.value)return;const b={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(b.duration=c.duration),c.fadeIn>0&&(b.fadeIn=c.fadeIn),c.fadeOut>0&&(b.fadeOut=c.fadeOut),r.value?a("update-track",r.value.id,b):a("add-track",b),h()}function v(b){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",b)}function g(b,f){const _=f.target,D=parseFloat(_.value);a("update-volume",b.id,D)}function w(b){a("toggle-mute",b.id,!b.muted)}function M(){a("update-master-volume",s.value)}function V(b){const f=Math.floor(b/60),_=Math.floor(b%60);return`${f}:${_.toString().padStart(2,"0")}`}return(b,f)=>(e.openBlock(),e.createElementBlock("div",qy,[e.createElementVNode("div",Ky,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=_=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...f[10]||(f[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",Qy,[e.createElementVNode("div",eb,[f[12]||(f[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",tb,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",nb,[f[13]||(f[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=_=>s.value=_),onInput:M,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),f[14]||(f[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",ab,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.audioLayers,_=>(e.openBlock(),e.createElementBlock("div",{key:_.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",ob,[e.createElementVNode("div",ib,e.toDisplayString(_.name),1),e.createElementVNode("div",rb,[e.createElementVNode("button",{onClick:D=>w(_),class:e.normalizeClass(["p-1 rounded",_.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:_.muted?"Unmute":"Mute"},[_.muted?(e.openBlock(),e.createElementBlock("svg",cb,[...f[16]||(f[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",lb,[...f[15]||(f[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,sb),e.createElementVNode("button",{onClick:D=>m(_),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...f[17]||(f[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,db),e.createElementVNode("button",{onClick:D=>v(_.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[18]||(f[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,ub)])]),e.createElementVNode("div",mb,[e.createElementVNode("span",pb,e.toDisplayString(Math.round((_.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:_.volume||1,onInput:D=>g(_,D),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:_.muted},null,40,fb)]),e.createElementVNode("div",hb,[e.createTextVNode(e.toDisplayString(V(_.startTime||0))+" - "+e.toDisplayString(V((_.startTime||0)+(_.duration||0)))+" ",1),_.fadeIn?(e.openBlock(),e.createElementBlock("span",vb,"Fade In: "+e.toDisplayString(_.fadeIn)+"s",1)):e.createCommentVNode("",!0),_.fadeOut?(e.openBlock(),e.createElementBlock("span",gb,"Fade Out: "+e.toDisplayString(_.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),b.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",yb," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.value||r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(h,["self"])},[e.createElementVNode("div",bb,[e.createElementVNode("h4",wb,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",kb,[e.createElementVNode("div",null,[f[20]||(f[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",_b,[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",Eb,[f[19]||(f[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[2]||(f[2]=_=>c.sourceUrl=_),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[f[21]||(f[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[3]||(f[3]=_=>c.name=_),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",xb," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[4]||(f[4]=_=>c.volume=_),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",Cb,[e.createElementVNode("div",null,[f[22]||(f[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[5]||(f[5]=_=>c.startTime=_),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[23]||(f[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[6]||(f[6]=_=>c.duration=_),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",Sb,[e.createElementVNode("div",null,[f[24]||(f[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[7]||(f[7]=_=>c.fadeIn=_),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[25]||(f[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[8]||(f[8]=_=>c.fadeOut=_),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",Vb,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[9]||(f[9]=_=>c.loop=_),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),f[26]||(f[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",Nb,[e.createElementVNode("button",{onClick:h,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:p,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(r.value?"Save":"Add"),11,Tb)])])])):e.createCommentVNode("",!0)]))}}),Ar=Me(Mb,[["__scopeId","data-v-593719ac"]]);function Xe(o,n={},...t){const a=document.createElement(o);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?a.className=r:i==="style"&&typeof r=="object"?Object.assign(a.style,r):i.startsWith("on")&&typeof r=="function"?a.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(a.dataset,r):a.setAttribute(i,r));for(const i of t)typeof i=="string"?a.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&a.appendChild(i);return a}function Bl(o){return typeof o=="boolean"?o?"On":"Off":typeof o=="number"?Number.isInteger(o)?String(o):o.toFixed(2):String(o??"")}let Fl=!1;function Bb(){if(Fl)return;Fl=!0;const o=`
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=o,document.head.appendChild(n)}class Fb{constructor({filters:n=[],callbacks:t={}}){Bb(),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=Xe("div",{className:"mvfp"}),this._catRow=Xe("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Xe("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Xe("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,a)=>{this._activeFilters.set(a,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 a=t.category||"other";n.has(a)||n.set(a,a.charAt(0).toUpperCase()+a.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,a)=>{const i=Xe("div",{className:`mvfp-cat${this._selectedCategory===a?" active":""}`,onClick:()=>{this._selectedCategory=a,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),a=this._selectedFilterId===n.id,i=Xe("div",{className:`mvfp-filter${t?" active":""}${a?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Xe("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Xe("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,a,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(a=(t=this._cb).onApplyFilter)==null||a.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,a;(a=(t=this._cb).onRemoveFilter)==null||a.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Xe("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const a=this._filters.find(c=>c.id===t);if(!a)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Xe("div",{className:`mvfp-achip${i?" selected":""}`}),s=Xe("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(t)}},a.name),l=Xe("button",{className:"mvfp-achip-x","aria-label":`Remove ${a.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=Xe("div",{className:"mvfp-drawer"});const n=Xe("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Xe("span",{className:"mvfp-drawer-title"},"Filter");const t=Xe("div",{className:"mvfp-drawer-actions"});t.appendChild(Xe("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Xe("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const a=Xe("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});a.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(a),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Xe("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(a=>a.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const a=this._root.offsetHeight;a>0&&(this._drawer.style.height=a+"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(Xe("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),a=(t==null?void 0:t.params)||{};for(const i of n.params){const r=a[i.id]??i.default,s=Xe("div",{className:"mvfp-ctl"}),l=Xe("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Xe("div",{className:"mvfp-slider-row"}),u=Xe("span",{className:"mvfp-range-val"},Bl(r)),m=Xe("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:h=>{var v,g;const p=parseFloat(h.target.value);u.textContent=Bl(p),(g=(v=this._cb).onUpdateParam)==null||g.call(v,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Xe("div",{className:"mvfp-toggle-row"}),u=Xe("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=Xe("div",{className:"mvfp-color-row"}),u=Xe("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=Xe("div",{className:"mvfp-select-row"}),u=Xe("select",{className:"mvfp-select",onChange:m=>{var h,p;return(p=(h=this._cb).onUpdateParam)==null?void 0:p.call(h,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const h=Xe("option",{value:m.value},m.label||String(m.value));m.value===r&&(h.selected=!0),u.appendChild(h)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,a;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)(a=(t=this._cb).onUpdateParam)==null||a.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function Il(o){var s,l;Ib(o);const n=$b(o.clips),t=[],a=Rb(o),i=Db(o),r={version:"1.0",source:{media_uuid:o.mediaUuid,duration:o.originalDuration,original_width:((s=o.media)==null?void 0:s.width)||1920,original_height:((l=o.media)==null?void 0:l.height)||1080},timeline:n,filters:t,audio:a,output:i,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return o.textOverlays&&(r.textOverlays=o.textOverlays),o.audioTracks&&(r.audioTracks=o.audioTracks.filter(c=>typeof c.source=="string")),r}function Ib(o){if(!o.mediaUuid)throw new Error("Media UUID is required");if(!o.clips||o.clips.length===0)throw new Error("At least one clip is required");const n=[...o.clips].sort((t,a)=>t.timelineStart-a.timelineStart);for(let t=1;t<n.length;t++)if(n[t].timelineStart<n[t-1].timelineEnd)throw new Error(`Clips ${n[t-1].id} and ${n[t].id} overlap on timeline`)}function $b(o){return o.map(n=>{const t=n.speed||1,a=typeof n.sourceIn=="number"&&!Number.isNaN(n.sourceIn),i=typeof n.sourceOut=="number"&&!Number.isNaN(n.sourceOut),r=Math.max(0,n.timelineEnd-n.timelineStart),s=n.sourceOffset??n.trimStart??0;let l=Number(a?n.sourceIn:s),c=i?Number(n.sourceOut):Number(s)+r/t;return c>l||(c=l+Math.max(.033,r/Math.max(1e-6,t))),{id:n.id,type:"clip",timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:l,sourceOut:c,speed:t,filters:n.filters?[...n.filters]:[]}})}function Rb(o){const n={volume:o.audioVolume,muted:o.audioVolume===0};return o.audioFadeIn>0&&(n.fadeIn=o.audioFadeIn),o.audioFadeOut>0&&(n.fadeOut=o.audioFadeOut),n}function Db(o){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[o.exportQuality]||n["1080p"],a=(r=o.media)==null?void 0:r.frame_rate,i=a&&Number.isFinite(a)&&a>0?a:30;return{format:o.exportFormat||"mp4",codec:"h264",quality:o.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function od(o,n,t){var Te,je;const a=typeof o=="string"&&o.trim()!==""?o.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:a,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),l=e.ref([]),c=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),m=e.shallowRef(null),h=new nd(30),p=e.ref(30),v=e.ref(!1),g=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(B(n),(Te=n.output)!=null&&Te.fps&&(p.value=n.output.fps,h.setFps(p.value))):(f(),n&&((je=n.output)!=null&&je.fps&&(p.value=n.output.fps,h.setFps(p.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const w=e.ref(1),M=e.computed(()=>i.selectedClipId?i.clips.find(T=>T.id===i.selectedClipId)??null:null);e.watch(M,T=>{w.value=(T==null?void 0:T.speed)??1},{immediate:!0});const V=e.computed(()=>s.value.length>0),b=e.computed(()=>l.value.length>0);function f(){const T=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=T,i.totalDuration=T;const z=ie(),G={id:z,type:"clip",timelineStart:0,timelineEnd:T,sourceIn:0,sourceOut:T,sourceMinIn:0,sourceMaxOut:T,speed:1};i.clips=[G],i.selectedClipId=z,c.value=z,!(t||a.startsWith("temp-"))&&(async()=>{try{const ee=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!ee.ok)throw new Error(`Failed to fetch media: ${ee.status}`);const pe=await ee.json(),be=typeof pe=="object"&&pe!==null&&"data"in pe?pe.data:pe;if(!be||typeof be!="object")throw new Error("Failed to parse media payload");const $e=be;i.media=$e;const Ae=typeof $e.duration=="number"&&$e.duration>0?$e.duration:T;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==z)return;i.originalDuration=Ae,i.totalDuration=Ae;const Re=i.clips[0];Re.timelineStart=0,Re.timelineEnd=Ae,Re.sourceIn=0,Re.sourceOut=Ae,Re.sourceMinIn=0,Re.sourceMaxOut=Ae,$(),d=!0}catch{}})()}function _(T,z){if(T.originalDuration!==1)return;T.originalDuration=z,T.totalDuration===1&&(T.totalDuration=z);const G=T.clips[0],ee=!n&&T.clips.length===1&&G!==void 0&&G.timelineStart===0&&G.timelineEnd===1&&G.sourceIn===0&&G.sourceOut===1;for(const pe of T.clips)(pe.sourceMaxOut===1||pe.sourceMaxOut===void 0)&&(pe.sourceMaxOut=z);ee&&G!==void 0&&(G.sourceOut=z,G.timelineEnd=z)}function D(T){if(!Number.isFinite(T)||T<=0||d)return;const z=i.hasChanges;i.originalDuration=T,i.totalDuration=Math.max(i.totalDuration,T),i.media&&(i.media.duration=T);for(const pe of i.clips)pe.sourceMaxOut=T;const G=i.clips[0];!n&&i.clips.length===1&&G!==void 0&&G.timelineStart===0&&G.timelineEnd===1&&G.sourceIn===0&&G.sourceOut===1&&G!==void 0&&(G.sourceOut=T,G.timelineEnd=G.timelineStart+(G.sourceOut-G.sourceIn)),$();for(const pe of s.value)_(pe,T);for(const pe of l.value)_(pe,T);d=!0,e.nextTick(()=>{z||(i.hasChanges=!1)})}function B(T){i.clips=T.timeline.map(z=>({...z,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??T.source.duration})),i.filters=[],i.audioVolume=T.audio.volume,i.audioFadeIn=T.audio.fadeIn||0,i.audioFadeOut=T.audio.fadeOut||0,i.exportFormat=T.output.format,i.exportQuality=T.output.quality,i.originalDuration=T.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),$()}function E(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function S(){if(!V.value)return;const T=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,T)}function P(){if(!b.value)return;const T=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,T)}function C(T,z,G){E();const ee=i.clips.find(Re=>Re.id===T);if(!ee)return;const be=1/30,$e=ee.sourceMinIn??0,Ae=ee.sourceMaxOut??i.originalDuration;if(z==="start"){const Re=ee.sourceIn,Pe=Math.max($e,Math.min(G,ee.sourceOut-be));ee.sourceIn=Pe;const Je=Pe-Re;ee.timelineStart+=Je}else{const Re=Math.max(ee.sourceIn+be,Math.min(G,Ae));ee.sourceOut=Re;const Pe=ee.sourceOut-ee.sourceIn;ee.timelineEnd=ee.timelineStart+Pe}$(),m.value&&m.value.trimClip(T,ee.sourceIn,ee.sourceOut)}function A(T){E();const z=i.clips.find($e=>T>$e.timelineStart&&T<$e.timelineEnd);if(!z)return;const G=T-z.timelineStart,ee=z.sourceIn+G,pe={id:ie(),type:"clip",timelineStart:T,timelineEnd:z.timelineEnd,sourceIn:ee,sourceOut:z.sourceOut,speed:z.speed??1,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??i.originalDuration,filters:[...z.filters||[]]};z.timelineEnd=T,z.sourceOut=ee;const be=i.clips.indexOf(z);i.clips.splice(be+1,0,pe),i.selectedClipId=pe.id}function R(){A(i.playheadPosition)}function W(T){var G;const z=T??i.selectedClipId??c.value??((G=i.clips[0])==null?void 0:G.id);z&&(i.selectedClipId=z,c.value=z)}function O(){if(!i.selectedClipId||i.clips.length<=1)return;E();const T=i.clips.findIndex(z=>z.id===i.selectedClipId);if(T!==-1){i.clips.splice(T,1);const z=Math.min(T,i.clips.length-1);i.selectedClipId=i.clips[z].id,c.value=i.selectedClipId,$()}}function I(){return[...i.clips].sort((T,z)=>T.timelineStart-z.timelineStart)}function F(T){const z=I(),G=z.findIndex(Pe=>Pe.id===T);if(G===-1)return null;const ee=z[G],pe=ee.timelineEnd-ee.timelineStart,be=G>0?z[G-1]:null,$e=G<z.length-1?z[G+1]:null,Ae=be?be.timelineEnd:0,Re=$e?$e.timelineStart-pe:Math.max(ee.timelineStart,i.totalDuration-pe);return{minStart:Ae,maxStart:Math.max(Ae,Re)}}function k(T,z){const G=i.clips.find($e=>$e.id===T);if(!G)return;const ee=F(T),pe=ee?Math.min(ee.maxStart,Math.max(ee.minStart,z)):Math.max(0,z);if(pe===G.timelineStart)return;E();const be=pe-G.timelineStart;G.timelineStart=pe,G.timelineEnd+=be,$(),m.value&&m.value.moveClip(T,pe)}function $(){if(i.clips.length===0){i.totalDuration=0;return}const T=i.clips.reduce((z,G)=>G.timelineEnd>z.timelineEnd?G:z);i.totalDuration=T.timelineEnd}function j(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function Z(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function K(T){i.zoomLevel=Math.max(10,Math.min(600,Math.round(T)))}function ge(){i.isPlaying=!i.isPlaying}function we(T){i.isPlaying=T}function ne(T){i.playheadPosition=Math.max(0,Math.min(T,i.totalDuration))}function N(){const T=Il(i);try{localStorage.setItem(`video-draft-${a}`,JSON.stringify(T))}catch{}return T}function L(){i.hasChanges=!1}function te(){return confirm("Are you sure you want to reset all changes?")?(E(),f(),i.hasChanges=!1,!0):!1}function ae(){return Il(i)}function ie(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function he(T=1920,z=1080){if(u.value)try{m.value=new td(T,z,p.value),await se()}catch{m.value=null}}async function se(){if(!(!m.value||g.value)){g.value=!0;try{const T=ae();await m.value.loadFromRecipe(T);const z=h.secondsToFrames(i.playheadPosition);m.value.seek(z)}catch{}finally{g.value=!1}}}function fe(T){}function xe(T){return h.secondsToFrames(T)}function le(T){return h.framesToSeconds(T)}function de(T){const z=le(T);ne(z),m.value&&m.value.seek(T)}function Ve(){v.value=!v.value}function Be(){se()}function dt(T){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&se()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&se()},{deep:!0}),e.watch(()=>i.clips.map(T=>T.id),()=>{var z;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(G=>G.id===i.selectedClipId)){const G=c.value&&((z=i.clips.find(ee=>ee.id===c.value))==null?void 0:z.id);i.selectedClipId=G??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function Ke(T){const z=i.selectedClipId?i.clips.find(G=>G.id===i.selectedClipId):i.clips[0];z&&(z.filters=[...T],i.hasChanges=!0)}function bt(T){i.textOverlays=[...T]}function et(T){i.audioTracks=[...T]}e.watch(u,T=>{T?he():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(p,T=>{h.setFps(T)});function at(){if(!i.selectedClipId)return;E();const T=i.clips.find(ee=>ee.id===i.selectedClipId);if(!T)return;const z={...T,id:ie(),timelineStart:T.timelineEnd,timelineEnd:T.timelineEnd+(T.timelineEnd-T.timelineStart),filters:[...T.filters||[]]},G=i.clips.indexOf(T);i.clips.splice(G+1,0,z),i.selectedClipId=z.id,i.hasChanges=!0}function wt(T){const z=T??800,G=i.totalDuration;if(G<=0){i.zoomLevel=50;return}const ee=z*.8/G;i.zoomLevel=Math.max(10,Math.min(600,Math.round(ee)))}function Vt(){const T=1/p.value;ne(Math.min(i.playheadPosition+T,i.totalDuration))}function rt(){const T=1/p.value;ne(Math.max(i.playheadPosition-T,0))}function vt(){ne(0)}function ue(){ne(i.totalDuration)}function Se(T){if(!Number.isFinite(T)||T<=0)return;const z=M.value??i.clips[0];if(!z){w.value=T;return}const G=z.speed??1;if(G===T){w.value=T;return}E();const ee=Math.max(1/p.value,z.sourceOut-z.sourceIn),pe=ee/G,be=ee/T,$e=be-pe;z.speed=T,z.timelineEnd=z.timelineStart+be;const Ae=i.clips.findIndex(Re=>Re.id===z.id);if(Ae!==-1&&$e!==0)for(let Re=Ae+1;Re<i.clips.length;Re+=1){const Pe=i.clips[Re];Pe.timelineStart+=$e,Pe.timelineEnd+=$e}$(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,w.value=T}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:M,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:w,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:p,useFrameMode:v,handleTrim:C,handleSplit:A,handleClipSelect:W,splitAtPlayhead:R,deleteSelectedClip:O,duplicateSelectedClip:at,setFilters:Ke,setTextOverlays:bt,setAudioTracks:et,moveClip:k,saveDraft:N,clearHasChanges:L,resetChanges:te,generateRecipe:ae,zoomIn:j,zoomOut:Z,setZoomLevel:K,fitToWindow:wt,togglePlayback:ge,setPlaying:we,seekTo:ne,frameForward:Vt,frameBackward:rt,skipToStart:vt,skipToEnd:ue,setPlaybackSpeed:Se,updateSourceDuration:D,undo:S,redo:P,canUndo:V,canRedo:b,initializeComposition:he,syncCompositionWithState:se,syncWithComposition:fe,convertToFrames:xe,convertToSeconds:le,seekToFrame:de,toggleFrameMode:Ve,onCompositionReady:Be,onCompositionError:dt}}const Ab=[{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}}}],Lb={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function li(o){return typeof o=="object"&&o!==null}function Ub(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return n}function ci(o){if(typeof o=="number"||typeof o=="string"||typeof o=="boolean")return o}function Ob(o){const n={id:o.id,type:o.type,label:o.label};o.property!==void 0&&(n.property=o.property),o.min!==void 0&&(n.min=o.min),o.max!==void 0&&(n.max=o.max),o.step!==void 0&&(n.step=o.step);const t=ci(o.default);return t!==void 0&&(n.default=t),o.options!==void 0&&(n.options=o.options),n}function id(o,n,t){const a=re.getFilter(o),i={},r=(a==null?void 0:a.defaultParams)??t;if(r&&li(r))for(const[s,l]of Object.entries(r))i[s]=ci(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 rd(o){const n={};for(const t of o){if(t.type!=="slider")continue;const a=t.property??t.id;n[a]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function Pb(o,n,t,a){const i=a.map(Ob);return{id:o,name:n,category:t,controls:i,params:i,defaultParams:id(o,i),paramRanges:rd(i)}}function zb(o){const n=o.paramRanges??{},t=Object.entries(n).map(([a,i])=>{var l;const r={id:a,type:"slider",label:a.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:a,min:i.min,max:i.max,step:i.step},s=ci((l=o.defaultParams)==null?void 0:l[a]);return s!==void 0&&(r.default=s),r});return{id:o.id,name:o.name,category:o.category,controls:t,params:t,defaultParams:id(o.id,t,o.defaultParams),paramRanges:rd(t)}}function jb(o,n){return n.toLowerCase()==="unlisted"?!1:re.isFilterCompatibleWithMedia(o,"video")}function ar(o){return Lb[o]??o}function Na(o){const n=Ub(o,1);return Math.max(0,Math.min(1,n))}function Ta(o){if(!li(o))return{};const n={};for(const[t,a]of Object.entries(o))n[t]=ci(a)??null;return n}function Wb(o){return!li(o)||typeof o.filterId!="string"?null:{filterId:o.filterId,params:Ta(o.params),intensity:Na(o.intensity)}}function Zb(o){if(!li(o)||typeof o.id!="string"||typeof o.name!="string")return null;const t=(Array.isArray(o.filters)?o.filters:[]).map(i=>Wb(i)).filter(i=>i!==null),a=typeof o.created_at=="string"?o.created_at:new Date().toISOString();return{id:o.id,name:o.name,filters:t,created_at:a}}function sd(){re.initializeFilterRegistry();const o=e.ref([]),n=e.ref(null),t=e.ref(null),a=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const R=new Map,W=re.getRegisteredFilters();for(const O of W)jb(O.id,O.category)&&R.set(O.id,Pb(O.id,O.name,O.category,O.controls));for(const O of Ab)R.has(O.id)||R.set(O.id,zb(O));return Array.from(R.values())}),l=e.computed(()=>{const R=new Map;for(const W of s.value)R.set(W.id,W);return R}),c=e.computed(()=>o.value.length>0),d=e.computed(()=>{const R={};for(const W of s.value)R[W.category]||(R[W.category]=[]),R[W.category].push(W);return R});function u(R){const W=l.value.get(R);if(W)return W;const O=ar(R);return l.value.get(O)??null}function m(R){const W=l.value.get(R);if(W)return W.id;const O=ar(R),I=l.value.get(O);return I?I.id:null}function h(R){const W=R?u(R):n.value;if(!W)return;const O=W.defaultParams||{},I={id:S(),filterId:W.id,params:{...O},intensity:1};return o.value.push(I),i.value=I.id,n.value=W,Object.keys(r).forEach(F=>delete r[F]),Object.assign(r,I.params),t.value=null,I}function p(R){const W=u(R);if(!W)return;n.value=W;const O=W.defaultParams||C(R);Object.assign(r,O),t.value={id:"preview",filterId:W.id,params:{...O},intensity:1}}function v(R){if(Object.assign(r,R),t.value&&(t.value.params={...r}),i.value){const W=o.value.find(O=>O.id===i.value);W&&(W.params={...r})}}function g(R){const W=o.value.findIndex(O=>O.id===R);W!==-1&&o.value.splice(W,1)}function w(R,W){if(R<0||R>=o.value.length||W<0||W>=o.value.length)return;const[O]=o.value.splice(R,1);o.value.splice(W,0,O)}function M(R,W){const O=o.value.find(I=>I.id===R);O&&(O.intensity=Math.max(0,Math.min(1,W)))}function V(R){const W=o.value.find(O=>O.id===R);W&&(W.intensity=W.intensity>0?0:1)}function b(){o.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(R=>delete r[R])}function f(R){const W={id:P(),name:R,filters:o.value.map(I=>({filterId:I.filterId,params:Ta(I.params),intensity:Na(I.intensity)})),created_at:new Date().toISOString()};a.value.push(W);const O=a.value.map(I=>({...I}));return localStorage.setItem("video-filter-presets",JSON.stringify(O)),W}function _(R){const W=a.value.find(O=>O.id===R);if(W){b();for(const O of W.filters){const I=u(O.filterId);I&&o.value.push({id:S(),filterId:I.id,params:{...O.params},intensity:Na(O.intensity)})}}}function D(R){const W=a.value.findIndex(O=>O.id===R);W!==-1&&(a.value.splice(W,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function B(){try{const R=localStorage.getItem("video-filter-presets");if(!R)return;const W=JSON.parse(R);if(!Array.isArray(W))return;a.value=W.map(O=>Zb(O)).filter(O=>O!==null)}catch{}}function E(){if(o.value.length===0)return"No filters applied";const R=o.value.map(W=>{const O=A(W.filterId);return(O==null?void 0:O.name)||W.filterId});return R.length===1?R[0]:R.length===2?`${R[0]} + ${R[1]}`:`${R[0]} + ${R.length-1} more`}function S(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function P(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function C(R){const W=u(R);return W?W.defaultParams||{}:{}}function A(R){return u(R)}return B(),{videoCompatibleFilters:s,activeFilters:o,selectedFilter:n,previewFilter:t,filterPresets:a,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:h,previewFilterEffect:p,updateFilterParams:v,removeFilter:g,reorderFilters:w,updateFilterIntensity:M,toggleFilter:V,clearAllFilters:b,saveFilterPreset:f,loadFilterPreset:_,deleteFilterPreset:D,getFilterSummary:E,setActiveFilters(R){var O;const W=[];for(const I of R){const F=m(I.filterId);if(!F){const k=ar(I.filterId);W.push({...I,filterId:k,params:Ta(I.params),intensity:Na(I.intensity)});continue}W.push({...I,filterId:F,params:Ta(I.params),intensity:Na(I.intensity)})}o.value=W,i.value=((O=o.value[0])==null?void 0:O.id)??null,Object.keys(r).forEach(I=>delete r[I]),o.value[0]&&Object.assign(r,Ta(o.value[0].params))}}}class ld{constructor(n){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new _t({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new _t({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new _t({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,a,i="400"){const r=new _t({source:t,family:a,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,a="400"){const i=new _t({source:`local('${t}')`,family:t,weight:a});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,a={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},i=n.fontFamily||"default",r=this.fonts.get(i)||this.fonts.get("default");if(a.font=r,n.position)if(typeof n.position=="string")switch(n.position){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}else a.x=n.position.x,a.y=n.position.y;else a.position="center";if(n.startTime!==void 0&&(a.start=_e.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;a.stop=_e.fromSeconds(l+n.duration)}n.animation&&this.applyAnimation(a,n.animation,n);const s=new la(a);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(n,t,a){if(!t)return;const i=a.startTime?Math.round(a.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 Fe([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Fe([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Fe([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Fe([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Fe([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Fe([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Fe([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Fe([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Fe([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Fe([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Fe([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(n,t){if(!this.textClips.get(n))throw new Error(`Text overlay with id ${n} not found`);await this.removeTextOverlay(n);const i={...t};await this.addTextOverlay(i)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const a=this.composition.tracks;for(const i of a){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const n=Array.from(this.textClips.keys());for(const t of n)await this.removeTextOverlay(t)}getOverlays(){const n=[];return this.textClips.forEach((t,a)=>{const i={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};n.push({id:a,config:i})}),n}async addCaptions(n,t="classic",a){var c,d;const r={classic:Ha,cascade:ai,guinea:ni,solar:oi,spotlight:Xa,whisper:Ga}[t],s=await this.composition.createTrack("caption"),l=new Yo({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),a&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,a)}}}class cd{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 a=await bn.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,a),a}catch(a){throw a instanceof Error?a:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`;let a;try{if(typeof n.source=="object"&&n.source instanceof bn)a=n.source;else if(typeof n.source=="string")a=await bn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)a=await bn.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const i={source:a,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=_e.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;i.stop=_e.fromSeconds(c+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new zo(i);let s=this.composition.tracks.find(c=>c.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,l),t}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,a=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(a,a+l),s.push(0,t)}else r.push(a),s.push(t);if(n.fadeOut&&i){const l=a+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 Fe(r,s,{easing:"linear"})}async updateVolume(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));a.clip.volume=i*this.masterVolume,a.config.volume=i}async applyFadeIn(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);a.config.fadeIn=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async applyFadeOut(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);a.config.fadeOut=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);const a=t.track.clips.indexOf(t.clip);a!==-1&&t.track.clips.splice(a,1),this.audioLayers.delete(n)}async muteTrack(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);t?a.clip.volume=0:a.clip.volume=(a.config.volume??1)*this.masterVolume}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));for(const t of this.audioLayers.values())t.clip.volume=(t.config.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(n){return this.audioLayers.get(n)}async clearAllAudioTracks(){const n=Array.from(this.audioLayers.keys());for(const t of n)await this.removeAudioTrack(t)}async syncWithVideo(n,t){for(const a of this.audioLayers.values()){const i=a.config.startTime||0,r=a.config.duration||t-n;if(i+r>t){a.config.duration=t-i;const s=new zo({source:a.clip.source,start:_e.fromSeconds(i),stop:_e.fromSeconds(t),volume:a.clip.volume}),l=a.track.clips.indexOf(a.clip);l!==-1&&(a.track.clips[l]=s,a.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:a}of n)await this.addAudioTrack({...a,name:t})}}function dd(o,n){return function(){return o.apply(n,arguments)}}const{toString:Hb}=Object.prototype,{getPrototypeOf:ps}=Object,{iterator:di,toStringTag:ud}=Symbol,ui=(o=>n=>{const t=Hb.call(n);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Zt=o=>(o=o.toLowerCase(),n=>ui(n)===o),mi=o=>n=>typeof n===o,{isArray:ua}=Array,Ua=mi("undefined");function Ja(o){return o!==null&&!Ua(o)&&o.constructor!==null&&!Ua(o.constructor)&&Bt(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const md=Zt("ArrayBuffer");function Xb(o){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(o):n=o&&o.buffer&&md(o.buffer),n}const Gb=mi("string"),Bt=mi("function"),pd=mi("number"),Ya=o=>o!==null&&typeof o=="object",Jb=o=>o===!0||o===!1,Mo=o=>{if(ui(o)!=="object")return!1;const n=ps(o);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(ud in o)&&!(di in o)},Yb=o=>{if(!Ya(o)||Ja(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},qb=Zt("Date"),Kb=Zt("File"),Qb=Zt("Blob"),ew=Zt("FileList"),tw=o=>Ya(o)&&Bt(o.pipe),nw=o=>{let n;return o&&(typeof FormData=="function"&&o instanceof FormData||Bt(o.append)&&((n=ui(o))==="formdata"||n==="object"&&Bt(o.toString)&&o.toString()==="[object FormData]"))},aw=Zt("URLSearchParams"),[ow,iw,rw,sw]=["ReadableStream","Request","Response","Headers"].map(Zt),lw=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qa(o,n,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let a,i;if(typeof o!="object"&&(o=[o]),ua(o))for(a=0,i=o.length;a<i;a++)n.call(null,o[a],a,o);else{if(Ja(o))return;const r=t?Object.getOwnPropertyNames(o):Object.keys(o),s=r.length;let l;for(a=0;a<s;a++)l=r[a],n.call(null,o[l],l,o)}}function fd(o,n){if(Ja(o))return null;n=n.toLowerCase();const t=Object.keys(o);let a=t.length,i;for(;a-- >0;)if(i=t[a],n===i.toLowerCase())return i;return null}const Fn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,hd=o=>!Ua(o)&&o!==Fn;function Lr(){const{caseless:o}=hd(this)&&this||{},n={},t=(a,i)=>{const r=o&&fd(n,i)||i;Mo(n[r])&&Mo(a)?n[r]=Lr(n[r],a):Mo(a)?n[r]=Lr({},a):ua(a)?n[r]=a.slice():n[r]=a};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&qa(arguments[a],t);return n}const cw=(o,n,t,{allOwnKeys:a}={})=>(qa(n,(i,r)=>{t&&Bt(i)?o[r]=dd(i,t):o[r]=i},{allOwnKeys:a}),o),dw=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),uw=(o,n,t,a)=>{o.prototype=Object.create(n.prototype,a),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:n.prototype}),t&&Object.assign(o.prototype,t)},mw=(o,n,t,a)=>{let i,r,s;const l={};if(n=n||{},o==null)return n;do{for(i=Object.getOwnPropertyNames(o),r=i.length;r-- >0;)s=i[r],(!a||a(s,o,n))&&!l[s]&&(n[s]=o[s],l[s]=!0);o=t!==!1&&ps(o)}while(o&&(!t||t(o,n))&&o!==Object.prototype);return n},pw=(o,n,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=n.length;const a=o.indexOf(n,t);return a!==-1&&a===t},fw=o=>{if(!o)return null;if(ua(o))return o;let n=o.length;if(!pd(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=o[n];return t},hw=(o=>n=>o&&n instanceof o)(typeof Uint8Array<"u"&&ps(Uint8Array)),vw=(o,n)=>{const a=(o&&o[di]).call(o);let i;for(;(i=a.next())&&!i.done;){const r=i.value;n.call(o,r[0],r[1])}},gw=(o,n)=>{let t;const a=[];for(;(t=o.exec(n))!==null;)a.push(t);return a},yw=Zt("HTMLFormElement"),bw=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,i){return a.toUpperCase()+i}),$l=(({hasOwnProperty:o})=>(n,t)=>o.call(n,t))(Object.prototype),ww=Zt("RegExp"),vd=(o,n)=>{const t=Object.getOwnPropertyDescriptors(o),a={};qa(t,(i,r)=>{let s;(s=n(i,r,o))!==!1&&(a[r]=s||i)}),Object.defineProperties(o,a)},kw=o=>{vd(o,(n,t)=>{if(Bt(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=o[t];if(Bt(a)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},_w=(o,n)=>{const t={},a=i=>{i.forEach(r=>{t[r]=!0})};return ua(o)?a(o):a(String(o).split(n)),t},Ew=()=>{},xw=(o,n)=>o!=null&&Number.isFinite(o=+o)?o:n;function Cw(o){return!!(o&&Bt(o.append)&&o[ud]==="FormData"&&o[di])}const Sw=o=>{const n=new Array(10),t=(a,i)=>{if(Ya(a)){if(n.indexOf(a)>=0)return;if(Ja(a))return a;if(!("toJSON"in a)){n[i]=a;const r=ua(a)?[]:{};return qa(a,(s,l)=>{const c=t(s,i+1);!Ua(c)&&(r[l]=c)}),n[i]=void 0,r}}return a};return t(o,0)},Vw=Zt("AsyncFunction"),Nw=o=>o&&(Ya(o)||Bt(o))&&Bt(o.then)&&Bt(o.catch),gd=((o,n)=>o?setImmediate:n?((t,a)=>(Fn.addEventListener("message",({source:i,data:r})=>{i===Fn&&r===t&&a.length&&a.shift()()},!1),i=>{a.push(i),Fn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Bt(Fn.postMessage)),Tw=typeof queueMicrotask<"u"?queueMicrotask.bind(Fn):typeof process<"u"&&process.nextTick||gd,Mw=o=>o!=null&&Bt(o[di]),q={isArray:ua,isArrayBuffer:md,isBuffer:Ja,isFormData:nw,isArrayBufferView:Xb,isString:Gb,isNumber:pd,isBoolean:Jb,isObject:Ya,isPlainObject:Mo,isEmptyObject:Yb,isReadableStream:ow,isRequest:iw,isResponse:rw,isHeaders:sw,isUndefined:Ua,isDate:qb,isFile:Kb,isBlob:Qb,isRegExp:ww,isFunction:Bt,isStream:tw,isURLSearchParams:aw,isTypedArray:hw,isFileList:ew,forEach:qa,merge:Lr,extend:cw,trim:lw,stripBOM:dw,inherits:uw,toFlatObject:mw,kindOf:ui,kindOfTest:Zt,endsWith:pw,toArray:fw,forEachEntry:vw,matchAll:gw,isHTMLForm:yw,hasOwnProperty:$l,hasOwnProp:$l,reduceDescriptors:vd,freezeMethods:kw,toObjectSet:_w,toCamelCase:bw,noop:Ew,toFiniteNumber:xw,findKey:fd,global:Fn,isContextDefined:hd,isSpecCompliantForm:Cw,toJSONObject:Sw,isAsyncFn:Vw,isThenable:Nw,setImmediate:gd,asap:Tw,isIterable:Mw};function Oe(o,n,t,a,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),a&&(this.request=a),i&&(this.response=i,this.status=i.status?i.status:null)}q.inherits(Oe,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:q.toJSONObject(this.config),code:this.code,status:this.status}}});const yd=Oe.prototype,bd={};["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(o=>{bd[o]={value:o}});Object.defineProperties(Oe,bd);Object.defineProperty(yd,"isAxiosError",{value:!0});Oe.from=(o,n,t,a,i,r)=>{const s=Object.create(yd);return q.toFlatObject(o,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Oe.call(s,o.message,n,t,a,i),s.cause=o,s.name=o.name,r&&Object.assign(s,r),s};const Bw=null;function Ur(o){return q.isPlainObject(o)||q.isArray(o)}function wd(o){return q.endsWith(o,"[]")?o.slice(0,-2):o}function Rl(o,n,t){return o?o.concat(n).map(function(i,r){return i=wd(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function Fw(o){return q.isArray(o)&&!o.some(Ur)}const Iw=q.toFlatObject(q,{},null,function(n){return/^is[A-Z]/.test(n)});function pi(o,n,t){if(!q.isObject(o))throw new TypeError("target must be an object");n=n||new FormData,t=q.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,w){return!q.isUndefined(w[g])});const a=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(n);if(!q.isFunction(i))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(q.isDate(v))return v.toISOString();if(q.isBoolean(v))return v.toString();if(!c&&q.isBlob(v))throw new Oe("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(v)||q.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,g,w){let M=v;if(v&&!w&&typeof v=="object"){if(q.endsWith(g,"{}"))g=a?g:g.slice(0,-2),v=JSON.stringify(v);else if(q.isArray(v)&&Fw(v)||(q.isFileList(v)||q.endsWith(g,"[]"))&&(M=q.toArray(v)))return g=wd(g),M.forEach(function(b,f){!(q.isUndefined(b)||b===null)&&n.append(s===!0?Rl([g],f,r):s===null?g:g+"[]",d(b))}),!1}return Ur(v)?!0:(n.append(Rl(w,g,r),d(v)),!1)}const m=[],h=Object.assign(Iw,{defaultVisitor:u,convertValue:d,isVisitable:Ur});function p(v,g){if(!q.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(v),q.forEach(v,function(M,V){(!(q.isUndefined(M)||M===null)&&i.call(n,M,q.isString(V)?V.trim():V,g,h))===!0&&p(M,g?g.concat(V):[V])}),m.pop()}}if(!q.isObject(o))throw new TypeError("data must be an object");return p(o),n}function Dl(o){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(a){return n[a]})}function fs(o,n){this._pairs=[],o&&pi(o,this,n)}const kd=fs.prototype;kd.append=function(n,t){this._pairs.push([n,t])};kd.toString=function(n){const t=n?function(a){return n.call(this,a,Dl)}:Dl;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function $w(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _d(o,n,t){if(!n)return o;const a=t&&t.encode||$w;q.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=q.isURLSearchParams(n)?n.toString():new fs(n,t).toString(a),r){const s=o.indexOf("#");s!==-1&&(o=o.slice(0,s)),o+=(o.indexOf("?")===-1?"?":"&")+r}return o}class Al{constructor(){this.handlers=[]}use(n,t,a){return this.handlers.push({fulfilled:n,rejected:t,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){q.forEach(this.handlers,function(a){a!==null&&n(a)})}}const Ed={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rw=typeof URLSearchParams<"u"?URLSearchParams:fs,Dw=typeof FormData<"u"?FormData:null,Aw=typeof Blob<"u"?Blob:null,Lw={isBrowser:!0,classes:{URLSearchParams:Rw,FormData:Dw,Blob:Aw},protocols:["http","https","file","blob","url","data"]},hs=typeof window<"u"&&typeof document<"u",Or=typeof navigator=="object"&&navigator||void 0,Uw=hs&&(!Or||["ReactNative","NativeScript","NS"].indexOf(Or.product)<0),Ow=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Pw=hs&&window.location.href||"http://localhost",zw=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:hs,hasStandardBrowserEnv:Uw,hasStandardBrowserWebWorkerEnv:Ow,navigator:Or,origin:Pw},Symbol.toStringTag,{value:"Module"})),Et={...zw,...Lw};function jw(o,n){return pi(o,new Et.classes.URLSearchParams,{visitor:function(t,a,i,r){return Et.isNode&&q.isBuffer(t)?(this.append(a,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function Ww(o){return q.matchAll(/\w+|\[(\w*)]/g,o).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Zw(o){const n={},t=Object.keys(o);let a;const i=t.length;let r;for(a=0;a<i;a++)r=t[a],n[r]=o[r];return n}function xd(o){function n(t,a,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&q.isArray(i)?i.length:s,c?(q.hasOwnProp(i,s)?i[s]=[i[s],a]:i[s]=a,!l):((!i[s]||!q.isObject(i[s]))&&(i[s]=[]),n(t,a,i[s],r)&&q.isArray(i[s])&&(i[s]=Zw(i[s])),!l)}if(q.isFormData(o)&&q.isFunction(o.entries)){const t={};return q.forEachEntry(o,(a,i)=>{n(Ww(a),i,t,0)}),t}return null}function Hw(o,n,t){if(q.isString(o))try{return(n||JSON.parse)(o),q.trim(o)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(o)}const Ka={transitional:Ed,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const a=t.getContentType()||"",i=a.indexOf("application/json")>-1,r=q.isObject(n);if(r&&q.isHTMLForm(n)&&(n=new FormData(n)),q.isFormData(n))return i?JSON.stringify(xd(n)):n;if(q.isArrayBuffer(n)||q.isBuffer(n)||q.isStream(n)||q.isFile(n)||q.isBlob(n)||q.isReadableStream(n))return n;if(q.isArrayBufferView(n))return n.buffer;if(q.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(a.indexOf("application/x-www-form-urlencoded")>-1)return jw(n,this.formSerializer).toString();if((l=q.isFileList(n))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return pi(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Hw(n)):n}],transformResponse:[function(n){const t=this.transitional||Ka.transitional,a=t&&t.forcedJSONParsing,i=this.responseType==="json";if(q.isResponse(n)||q.isReadableStream(n))return n;if(n&&q.isString(n)&&(a&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?Oe.from(l,Oe.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:Et.classes.FormData,Blob:Et.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],o=>{Ka.headers[o]={}});const Xw=q.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"]),Gw=o=>{const n={};let t,a,i;return o&&o.split(`
337
- `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),a=s.substring(i+1).trim(),!(!t||n[t]&&Xw[t])&&(t==="set-cookie"?n[t]?n[t].push(a):n[t]=[a]:n[t]=n[t]?n[t]+", "+a:a)}),n},Ll=Symbol("internals");function ka(o){return o&&String(o).trim().toLowerCase()}function Bo(o){return o===!1||o==null?o:q.isArray(o)?o.map(Bo):String(o)}function Jw(o){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=t.exec(o);)n[a[1]]=a[2];return n}const Yw=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function or(o,n,t,a,i){if(q.isFunction(a))return a.call(this,n,t);if(i&&(n=t),!!q.isString(n)){if(q.isString(a))return n.indexOf(a)!==-1;if(q.isRegExp(a))return a.test(n)}}function qw(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,a)=>t.toUpperCase()+a)}function Kw(o,n){const t=q.toCamelCase(" "+n);["get","set","has"].forEach(a=>{Object.defineProperty(o,a+t,{value:function(i,r,s){return this[a].call(this,n,i,r,s)},configurable:!0})})}let Ft=class{constructor(n){n&&this.set(n)}set(n,t,a){const i=this;function r(l,c,d){const u=ka(c);if(!u)throw new Error("header name must be a non-empty string");const m=q.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||c]=Bo(l))}const s=(l,c)=>q.forEach(l,(d,u)=>r(d,u,c));if(q.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(q.isString(n)&&(n=n.trim())&&!Yw(n))s(Gw(n),t);else if(q.isObject(n)&&q.isIterable(n)){let l={},c,d;for(const u of n){if(!q.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?q.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,a);return this}get(n,t){if(n=ka(n),n){const a=q.findKey(this,n);if(a){const i=this[a];if(!t)return i;if(t===!0)return Jw(i);if(q.isFunction(t))return t.call(this,i,a);if(q.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=ka(n),n){const a=q.findKey(this,n);return!!(a&&this[a]!==void 0&&(!t||or(this,this[a],a,t)))}return!1}delete(n,t){const a=this;let i=!1;function r(s){if(s=ka(s),s){const l=q.findKey(a,s);l&&(!t||or(a,a[l],l,t))&&(delete a[l],i=!0)}}return q.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let a=t.length,i=!1;for(;a--;){const r=t[a];(!n||or(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,a={};return q.forEach(this,(i,r)=>{const s=q.findKey(a,r);if(s){t[s]=Bo(i),delete t[r];return}const l=n?qw(r):String(r).trim();l!==r&&delete t[r],t[l]=Bo(i),a[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return q.forEach(this,(a,i)=>{a!=null&&a!==!1&&(t[i]=n&&q.isArray(a)?a.join(", "):a)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
338
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const a=new this(n);return t.forEach(i=>a.set(i)),a}static accessor(n){const a=(this[Ll]=this[Ll]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=ka(s);a[l]||(Kw(i,s),a[l]=!0)}return q.isArray(n)?n.forEach(r):r(n),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);q.reduceDescriptors(Ft.prototype,({value:o},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>o,set(a){this[t]=a}}});q.freezeMethods(Ft);function ir(o,n){const t=this||Ka,a=n||t,i=Ft.from(a.headers);let r=a.data;return q.forEach(o,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function Cd(o){return!!(o&&o.__CANCEL__)}function ma(o,n,t){Oe.call(this,o??"canceled",Oe.ERR_CANCELED,n,t),this.name="CanceledError"}q.inherits(ma,Oe,{__CANCEL__:!0});function Sd(o,n,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?o(t):n(new Oe("Request failed with status code "+t.status,[Oe.ERR_BAD_REQUEST,Oe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Qw(o){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return n&&n[1]||""}function e2(o,n){o=o||10;const t=new Array(o),a=new Array(o);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(c){const d=Date.now(),u=a[r];s||(s=d),t[i]=c,a[i]=d;let m=r,h=0;for(;m!==i;)h+=t[m++],m=m%o;if(i=(i+1)%o,i===r&&(r=(r+1)%o),d-s<n)return;const p=u&&d-u;return p?Math.round(h*1e3/p):void 0}}function t2(o,n){let t=0,a=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),o(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=a?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},a-m)))},()=>i&&s(i)]}const jo=(o,n,t=3)=>{let a=0;const i=e2(50,250);return t2(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-a,d=i(c),u=s<=l;a=s;const m={loaded:s,total:l,progress:l?s/l:void 0,bytes:c,rate:d||void 0,estimated:d&&l&&u?(l-s)/d:void 0,event:r,lengthComputable:l!=null,[n?"download":"upload"]:!0};o(m)},t)},Ul=(o,n)=>{const t=o!=null;return[a=>n[0]({lengthComputable:t,total:o,loaded:a}),n[1]]},Ol=o=>(...n)=>q.asap(()=>o(...n)),n2=Et.hasStandardBrowserEnv?((o,n)=>t=>(t=new URL(t,Et.origin),o.protocol===t.protocol&&o.host===t.host&&(n||o.port===t.port)))(new URL(Et.origin),Et.navigator&&/(msie|trident)/i.test(Et.navigator.userAgent)):()=>!0,a2=Et.hasStandardBrowserEnv?{write(o,n,t,a,i,r){const s=[o+"="+encodeURIComponent(n)];q.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),q.isString(a)&&s.push("path="+a),q.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(o){const n=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(o){this.write(o,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function o2(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function i2(o,n){return n?o.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):o}function Vd(o,n,t){let a=!o2(n);return o&&(a||t==!1)?i2(o,n):n}const Pl=o=>o instanceof Ft?{...o}:o;function An(o,n){n=n||{};const t={};function a(d,u,m,h){return q.isPlainObject(d)&&q.isPlainObject(u)?q.merge.call({caseless:h},d,u):q.isPlainObject(u)?q.merge({},u):q.isArray(u)?u.slice():u}function i(d,u,m,h){if(q.isUndefined(u)){if(!q.isUndefined(d))return a(void 0,d,m,h)}else return a(d,u,m,h)}function r(d,u){if(!q.isUndefined(u))return a(void 0,u)}function s(d,u){if(q.isUndefined(u)){if(!q.isUndefined(d))return a(void 0,d)}else return a(void 0,u)}function l(d,u,m){if(m in n)return a(d,u);if(m in o)return a(void 0,d)}const c={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(d,u,m)=>i(Pl(d),Pl(u),m,!0)};return q.forEach(Object.keys({...o,...n}),function(u){const m=c[u]||i,h=m(o[u],n[u],u);q.isUndefined(h)&&m!==l||(t[u]=h)}),t}const Nd=o=>{const n=An({},o);let{data:t,withXSRFToken:a,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=Ft.from(s),n.url=_d(Vd(n.baseURL,n.url,n.allowAbsoluteUrls),o.params,o.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(q.isFormData(t)){if(Et.hasStandardBrowserEnv||Et.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(Et.hasStandardBrowserEnv&&(a&&q.isFunction(a)&&(a=a(n)),a||a!==!1&&n2(n.url))){const d=i&&r&&a2.read(r);d&&s.set(i,d)}return n},r2=typeof XMLHttpRequest<"u",s2=r2&&function(o){return new Promise(function(t,a){const i=Nd(o);let r=i.data;const s=Ft.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,m,h,p,v;function g(){p&&p(),v&&v(),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 M(){if(!w)return;const b=Ft.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:b,config:o,request:w};Sd(function(B){t(B),g()},function(B){a(B),g()},_),w=null}"onloadend"in w?w.onloadend=M:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(M)},w.onabort=function(){w&&(a(new Oe("Request aborted",Oe.ECONNABORTED,o,w)),w=null)},w.onerror=function(){a(new Oe("Network Error",Oe.ERR_NETWORK,o,w)),w=null},w.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||Ed;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),a(new Oe(f,_.clarifyTimeoutError?Oe.ETIMEDOUT:Oe.ECONNABORTED,o,w)),w=null},r===void 0&&s.setContentType(null),"setRequestHeader"in w&&q.forEach(s.toJSON(),function(f,_){w.setRequestHeader(_,f)}),q.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),l&&l!=="json"&&(w.responseType=i.responseType),d&&([h,v]=jo(d,!0),w.addEventListener("progress",h)),c&&w.upload&&([m,p]=jo(c),w.upload.addEventListener("progress",m),w.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=b=>{w&&(a(!b||b.type?new ma(null,o,w):b),w.abort(),w=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const V=Qw(i.url);if(V&&Et.protocols.indexOf(V)===-1){a(new Oe("Unsupported protocol "+V+":",Oe.ERR_BAD_REQUEST,o));return}w.send(r||null)})},l2=(o,n)=>{const{length:t}=o=o?o.filter(Boolean):[];if(n||t){let a=new AbortController,i;const r=function(d){if(!i){i=!0,l();const u=d instanceof Error?d:this.reason;a.abort(u instanceof Oe?u:new ma(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Oe(`timeout ${n} of ms exceeded`,Oe.ETIMEDOUT))},n);const l=()=>{o&&(s&&clearTimeout(s),s=null,o.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),o=null)};o.forEach(d=>d.addEventListener("abort",r));const{signal:c}=a;return c.unsubscribe=()=>q.asap(l),c}},c2=function*(o,n){let t=o.byteLength;if(t<n){yield o;return}let a=0,i;for(;a<t;)i=a+n,yield o.slice(a,i),a=i},d2=async function*(o,n){for await(const t of u2(o))yield*c2(t,n)},u2=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const n=o.getReader();try{for(;;){const{done:t,value:a}=await n.read();if(t)break;yield a}}finally{await n.cancel()}},zl=(o,n,t,a)=>{const i=d2(o,n);let r=0,s,l=c=>{s||(s=!0,a&&a(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let m=u.byteLength;if(t){let h=r+=m;t(h)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},fi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Td=fi&&typeof ReadableStream=="function",m2=fi&&(typeof TextEncoder=="function"?(o=>n=>o.encode(n))(new TextEncoder):async o=>new Uint8Array(await new Response(o).arrayBuffer())),Md=(o,...n)=>{try{return!!o(...n)}catch{return!1}},p2=Td&&Md(()=>{let o=!1;const n=new Request(Et.origin,{body:new ReadableStream,method:"POST",get duplex(){return o=!0,"half"}}).headers.has("Content-Type");return o&&!n}),jl=64*1024,Pr=Td&&Md(()=>q.isReadableStream(new Response("").body)),Wo={stream:Pr&&(o=>o.body)};fi&&(o=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Wo[n]&&(Wo[n]=q.isFunction(o[n])?t=>t[n]():(t,a)=>{throw new Oe(`Response type '${n}' is not supported`,Oe.ERR_NOT_SUPPORT,a)})})})(new Response);const f2=async o=>{if(o==null)return 0;if(q.isBlob(o))return o.size;if(q.isSpecCompliantForm(o))return(await new Request(Et.origin,{method:"POST",body:o}).arrayBuffer()).byteLength;if(q.isArrayBufferView(o)||q.isArrayBuffer(o))return o.byteLength;if(q.isURLSearchParams(o)&&(o=o+""),q.isString(o))return(await m2(o)).byteLength},h2=async(o,n)=>{const t=q.toFiniteNumber(o.getContentLength());return t??f2(n)},v2=fi&&(async o=>{let{url:n,method:t,data:a,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:h}=Nd(o);d=d?(d+"").toLowerCase():"text";let p=l2([i,r&&r.toAbortSignal()],s),v;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let w;try{if(c&&p2&&t!=="get"&&t!=="head"&&(w=await h2(u,a))!==0){let _=new Request(n,{method:"POST",body:a,duplex:"half"}),D;if(q.isFormData(a)&&(D=_.headers.get("content-type"))&&u.setContentType(D),_.body){const[B,E]=Ul(w,jo(Ol(c)));a=zl(_.body,jl,B,E)}}q.isString(m)||(m=m?"include":"omit");const M="credentials"in Request.prototype;v=new Request(n,{...h,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:M?m:void 0});let V=await fetch(v,h);const b=Pr&&(d==="stream"||d==="response");if(Pr&&(l||b&&g)){const _={};["status","statusText","headers"].forEach(S=>{_[S]=V[S]});const D=q.toFiniteNumber(V.headers.get("content-length")),[B,E]=l&&Ul(D,jo(Ol(l),!0))||[];V=new Response(zl(V.body,jl,B,()=>{E&&E(),g&&g()}),_)}d=d||"text";let f=await Wo[q.findKey(Wo,d)||"text"](V,o);return!b&&g&&g(),await new Promise((_,D)=>{Sd(_,D,{data:f,headers:Ft.from(V.headers),status:V.status,statusText:V.statusText,config:o,request:v})})}catch(M){throw g&&g(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Oe("Network Error",Oe.ERR_NETWORK,o,v),{cause:M.cause||M}):Oe.from(M,M&&M.code,o,v)}}),zr={http:Bw,xhr:s2,fetch:v2};q.forEach(zr,(o,n)=>{if(o){try{Object.defineProperty(o,"name",{value:n})}catch{}Object.defineProperty(o,"adapterName",{value:n})}});const Wl=o=>`- ${o}`,g2=o=>q.isFunction(o)||o===null||o===!1,Bd={getAdapter:o=>{o=q.isArray(o)?o:[o];const{length:n}=o;let t,a;const i={};for(let r=0;r<n;r++){t=o[r];let s;if(a=t,!g2(t)&&(a=zr[(s=String(t)).toLowerCase()],a===void 0))throw new Oe(`Unknown adapter '${s}'`);if(a)break;i[s||"#"+r]=a}if(!a){const r=Object.entries(i).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
339
- `+r.map(Wl).join(`
340
- `):" "+Wl(r[0]):"as no adapter specified";throw new Oe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:zr};function rr(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new ma(null,o)}function Zl(o){return rr(o),o.headers=Ft.from(o.headers),o.data=ir.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Bd.getAdapter(o.adapter||Ka.adapter)(o).then(function(a){return rr(o),a.data=ir.call(o,o.transformResponse,a),a.headers=Ft.from(a.headers),a},function(a){return Cd(a)||(rr(o),a&&a.response&&(a.response.data=ir.call(o,o.transformResponse,a.response),a.response.headers=Ft.from(a.response.headers))),Promise.reject(a)})}const Fd="1.11.0",hi={};["object","boolean","number","function","string","symbol"].forEach((o,n)=>{hi[o]=function(a){return typeof a===o||"a"+(n<1?"n ":" ")+o}});const Hl={};hi.transitional=function(n,t,a){function i(r,s){return"[Axios v"+Fd+"] Transitional option '"+r+"'"+s+(a?". "+a:"")}return(r,s,l)=>{if(n===!1)throw new Oe(i(s," has been removed"+(t?" in "+t:"")),Oe.ERR_DEPRECATED);return t&&!Hl[s]&&(Hl[s]=!0),n?n(r,s,l):!0}};hi.spelling=function(n){return(t,a)=>!0};function y2(o,n,t){if(typeof o!="object")throw new Oe("options must be an object",Oe.ERR_BAD_OPTION_VALUE);const a=Object.keys(o);let i=a.length;for(;i-- >0;){const r=a[i],s=n[r];if(s){const l=o[r],c=l===void 0||s(l,r,o);if(c!==!0)throw new Oe("option "+r+" must be "+c,Oe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Oe("Unknown option "+r,Oe.ERR_BAD_OPTION)}}const Fo={assertOptions:y2,validators:hi},Qt=Fo.validators;let $n=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Al,response:new Al}}async request(n,t){try{return await this._request(n,t)}catch(a){if(a instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{a.stack?r&&!String(a.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(a.stack+=`
341
- `+r):a.stack=r}catch{}}throw a}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=An(this.defaults,t);const{transitional:a,paramsSerializer:i,headers:r}=t;a!==void 0&&Fo.assertOptions(a,{silentJSONParsing:Qt.transitional(Qt.boolean),forcedJSONParsing:Qt.transitional(Qt.boolean),clarifyTimeoutError:Qt.transitional(Qt.boolean)},!1),i!=null&&(q.isFunction(i)?t.paramsSerializer={serialize:i}:Fo.assertOptions(i,{encode:Qt.function,serialize:Qt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fo.assertOptions(t,{baseUrl:Qt.spelling("baseURL"),withXsrfToken:Qt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&q.merge(r.common,r[t.method]);r&&q.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=Ft.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(c=c&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,m=0,h;if(!c){const v=[Zl.bind(this),void 0];for(v.unshift(...l),v.push(...d),h=v.length,u=Promise.resolve(t);m<h;)u=u.then(v[m++],v[m++]);return u}h=l.length;let p=t;for(m=0;m<h;){const v=l[m++],g=l[m++];try{p=v(p)}catch(w){g.call(this,w);break}}try{u=Zl.call(this,p)}catch(v){return Promise.reject(v)}for(m=0,h=d.length;m<h;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=An(this.defaults,n);const t=Vd(n.baseURL,n.url,n.allowAbsoluteUrls);return _d(t,n.params,n.paramsSerializer)}};q.forEach(["delete","get","head","options"],function(n){$n.prototype[n]=function(t,a){return this.request(An(a||{},{method:n,url:t,data:(a||{}).data}))}});q.forEach(["post","put","patch"],function(n){function t(a){return function(r,s,l){return this.request(An(l||{},{method:n,headers:a?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}$n.prototype[n]=t(),$n.prototype[n+"Form"]=t(!0)});let b2=class Id{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 a=this;this.promise.then(i=>{if(!a._listeners)return;let r=a._listeners.length;for(;r-- >0;)a._listeners[r](i);a._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{a.subscribe(l),r=l}).then(i);return s.cancel=function(){a.unsubscribe(r)},s},n(function(r,s,l){a.reason||(a.reason=new ma(r,s,l),t(a.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=a=>{n.abort(a)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new Id(function(i){n=i}),cancel:n}}};function w2(o){return function(t){return o.apply(null,t)}}function k2(o){return q.isObject(o)&&o.isAxiosError===!0}const jr={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(jr).forEach(([o,n])=>{jr[n]=o});function $d(o){const n=new $n(o),t=dd($n.prototype.request,n);return q.extend(t,$n.prototype,n,{allOwnKeys:!0}),q.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return $d(An(o,i))},t}const it=$d(Ka);it.Axios=$n;it.CanceledError=ma;it.CancelToken=b2;it.isCancel=Cd;it.VERSION=Fd;it.toFormData=pi;it.AxiosError=Oe;it.Cancel=it.CanceledError;it.all=function(n){return Promise.all(n)};it.spread=w2;it.isAxiosError=k2;it.mergeConfig=An;it.AxiosHeaders=Ft;it.formToJSON=o=>xd(q.isHTMLForm(o)?new FormData(o):o);it.getAdapter=Bd.getAdapter;it.HttpStatusCode=jr;it.default=it;const{Axios:aT,AxiosError:oT,CanceledError:iT,isCancel:rT,CancelToken:sT,VERSION:lT,all:cT,Cancel:dT,isAxiosError:uT,spread:mT,toFormData:pT,AxiosHeaders:fT,HttpStatusCode:hT,formToJSON:vT,getAdapter:gT,mergeConfig:yT}=it;class vi{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=it.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const a=this.getAuthToken();return a&&(t.headers.Authorization=`Bearer ${a}`),t}),this.api.interceptors.response.use(t=>t,t=>{var a;return(a=t.response)==null||a.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,a=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.error_message??"Render job failed"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},a)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{await this.api.delete(`/video/jobs/${n}`),this.unsubscribeFromProgress(n)}catch(t){throw t}}async retryJob(n){try{const t=await this.api.post(`/video/jobs/${n}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(n,t){this.progressCallbacks.set(n,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(n)}unsubscribeFromProgress(n){this.progressCallbacks.delete(n),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const n=this.getAuthToken(),t=`/api/v1/video/jobs/events${n?`?token=${n}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",a=>{const i=JSON.parse(a.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",a=>{const i=JSON.parse(a.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",a=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const a=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(a.progress),(a.status==="completed"||a.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const a of t){const[i,r]=a.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 a=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(a.data)}catch(a){throw a}}normalizeJob(n){const t=n,a={...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!==""&&(a.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(a.error_message=r);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(a.started_at=s);const l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(a.completed_at=l),a}}new vi;const _2={key:0,class:"mobile-layout"},E2={class:"mobile-toolbar"},x2={class:"mobile-toolbar-left"},C2=["aria-label"],S2={class:"mobile-toolbar-right"},V2=["disabled"],N2=["disabled"],T2={class:"preview-section"},M2={key:0,class:"mobile-export-overlay"},B2={class:"mobile-export-progress"},F2={class:"mobile-export-bar"},I2={class:"mobile-timeline-zoom"},$2={class:"mobile-edit-strip"},R2={class:"mobile-selection-summary"},D2={class:"mobile-selection-title"},A2={class:"mobile-selection-meta"},L2={class:"mobile-readout-row"},U2=["disabled"],O2={class:"mobile-readout-grid"},P2={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},z2={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},j2={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},W2={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},Z2=["disabled"],H2={class:"mobile-speed-strip"},X2={class:"mobile-speed-chips"},G2=["data-testid","onClick"],J2={class:"mobile-edit-actions"},Y2=["disabled"],q2=["disabled"],K2=["disabled"],Q2=["disabled"],ek=["disabled"],tk={class:"mobile-action-sheet-header"},nk={class:"mobile-action-sheet-title"},ak={class:"mobile-action-sheet-subtitle"},ok={class:"mobile-action-sheet-actions"},ik=["disabled"],rk=["disabled"],sk=["disabled"],lk=["disabled"],ck=["disabled"],dk={key:1,class:"desktop-layout"},uk={class:"desktop-main-row"},mk={class:"preview-panel"},pk={class:"fit-toggle"},fk={class:"editor-content"},hk={class:"editor-tabs"},vk={class:"tab-header"},gk=["onClick"],yk={class:"tab-content-area"},bk={class:"filter-controls"},wk={class:"text-controls"},kk={class:"transition-controls"},_k={class:"audio-controls"},Ek={class:"adjustments-controls"},xk={key:1,class:"no-filter-selected"},Ck={class:"export-controls"},Sk={key:0,"data-testid":"video-export-status-completed"},Vk={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Nk={class:"desktop-timeline-row"},Tk={class:"timeline-zoom"},Mk=["value"],Bk={class:"zoom-readout"},Fk={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Ik={class:"dev-editor-row"},$k={class:"dev-editor-field"},Rk={class:"dev-editor-field"},Dk=["disabled"],Ak=["disabled"],Lk=["disabled"],Uk={class:"dev-editor-row"},Ok={class:"dev-editor-field dev-editor-field--wide"},Pk=["value"],zk=["disabled"],jk=["disabled"],Wk=["disabled"],Zk=["disabled"],Hk=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{if(!a.media||typeof a.media!="object")return;const y=a.media.uuid??a.media.id;return typeof y=="string"&&y.trim()!==""?y.trim():void 0}),s=e.computed(()=>{const y=typeof a.mediaUuid=="string"?a.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=a.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},x=a.featureFlags;return x?{filters:typeof x.filters=="boolean"?x.filters:y.filters,adjustments:typeof x.adjustments=="boolean"?x.adjustments:y.adjustments,text:typeof x.text=="boolean"?x.text:y.text,transitions:typeof x.transitions=="boolean"?x.transitions:y.transitions,audio:typeof x.audio=="boolean"?x.audio:y.audio,export:typeof x.export=="boolean"?x.export:y.export}:y}),m=e.computed(()=>l.value?c.value:d.value),h=e.computed(()=>m.value==="filters"||w.value),p=e.computed(()=>m.value!=="filters"&&!w.value),v=e.ref(null),g=e.ref(null),w=e.ref(!1),M=e.computed(()=>l.value?v.value:g.value);function V(y){return y==="contain"||y==="cover"||y==="none"}function b(y){if(!(y!=null&&y.metadata))return null;const x=y.metadata.fit_mode;return V(x)?x:null}const f=e.shallowRef(null),_=e.ref(null),D=e.ref(b(a.initialRecipe)??"contain"),B=e.ref(null),E=e.ref(null),S=e.ref(null),P=e.ref(!1),C=new Map,A=e.ref([]),R=e.ref([]),W=e.ref([]),O=e.ref([]),I=e.ref(1),F=()=>{l.value=window.innerWidth<768},k=[{id:"filters",label:"Filters",icon:yn},{id:"adjustments",label:"Adjust",icon:fp},{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:aa}],$=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],j=e.computed(()=>k.filter(y=>u.value[y.id])),Z=e.computed(()=>$.filter(y=>u.value[y.id])),K=e.computed(()=>{var y,x;return((y=Z.value[0])==null?void 0:y.id)??((x=j.value[0])==null?void 0:x.id)??"filters"});e.watch(u,y=>{y[c.value]||(c.value=K.value),y[d.value]||(d.value=K.value)},{immediate:!0,deep:!0}),e.watch(K,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=K.value),d.value==="export"&&(d.value=K.value))},{immediate:!0,deep:!0});const ge=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),we=Ec(),{currentFrame:ne,playheadPosition:N,timelineClips:L,totalDuration:te,hasChanges:ae,isPlaying:ie,selectedClip:he,zoomLevel:se,playbackSpeed:fe,handleTrim:xe,handleSplit:le,handleClipSelect:de,splitAtPlayhead:Ve,deleteSelectedClip:Be,duplicateSelectedClip:dt,setZoomLevel:Ke,moveClip:bt,setFilters:et,setTextOverlays:at,setAudioTracks:wt,saveDraft:Vt,clearHasChanges:rt,resetChanges:vt,generateRecipe:ue,zoomIn:Se,zoomOut:Te,fitToWindow:je,togglePlayback:T,setPlaying:z,seekTo:G,frameForward:ee,frameBackward:pe,skipToStart:be,skipToEnd:$e,setPlaybackSpeed:Ae,updateSourceDuration:Re,undo:Pe,redo:Je,canUndo:tt,canRedo:xt}=od(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:Ht,activeFilters:nt,selectedFilter:Xt,previewFilter:jn,previewFilterEffect:pa,applyFilter:Wn,updateFilterParams:Qa,removeFilter:fa,clearAllFilters:Zn,setActiveFilters:ha}=sd();function wn(y){var X,oe;const x=((X=he.value)==null?void 0:X.id)??((oe=L.value[0])==null?void 0:oe.id);x&&(P.value=!0,typeof y=="object"&&y.id?Wn(y.id):typeof y=="string"&&Wn(y),et(nt.value),f.value?f.value.setClipFilters(x,nt.value):C.set(x,[...nt.value]),de(x),P.value=!1,Yt())}function wi(){var x,X;const y=((x=he.value)==null?void 0:x.id)??((X=L.value[0])==null?void 0:X.id);y&&de(y)}function ki(y){const x=nt.value.find(X=>X.filterId===y);x&&fa(x.id)}const Hn=e.computed(()=>Ht.value.map(x=>{var oe;const X=[];if(x.controls&&x.controls.length>0)for(const ve of x.controls){const ce=ve.type;if(ce==="button"||ce==="text"||ce==="range")continue;const me={id:ve.property||ve.id,label:ve.label||ve.id,type:ce,default:ve.default??(ce==="toggle"?!1:ce==="color"?"#ffffff":0)};ce==="slider"&&(me.min=ve.min??0,me.max=ve.max??1,me.step=ve.step??.01),ce==="select"&&ve.options&&(me.options=ve.options),X.push(me)}else if(x.paramRanges){const ve=Object.entries(x.paramRanges);for(const[ce,me]of ve){const He=ce.replace(/[-_]/g," ").replace(/\b\w/g,qt=>qt.toUpperCase()),Ct=(oe=x.defaultParams)==null?void 0:oe[ce],sn=(me.min+me.max)/2;X.push({id:ce,label:He,min:me.min,max:me.max,step:me.step??.01,default:typeof Ct=="number"?Ct:sn})}}return{id:x.id,name:x.name,category:x.category,params:X}})),Y=e.ref("0.00"),Q=e.ref("0.00"),ye=e.ref("");e.watch(Hn,y=>{if(y.length===0){ye.value="";return}y.some(X=>X.id===ye.value)||(ye.value=y[0].id)},{immediate:!0});const Ee=e.ref(!1),Ne=e.ref(0),Ue=e.ref(!1),Le=e.ref(null),mt=e.ref(null);let kn=null,Nt=!1,Pt=null;const _i=e.computed(()=>{const y=new Map;return nt.value.forEach(x=>y.set(x.filterId,x)),y}),cu=e.computed(()=>{var y,x;return ne.value?ne.value:((y=a.media)==null?void 0:y.thumbnail_url)||((x=a.media)==null?void 0:x.url)}),Gt=e.ref("");e.watch(()=>{var y,x;return{file:(y=a.media)==null?void 0:y.file,url:(x=a.media)==null?void 0:x.url}},(y,x,X)=>{var ve,ce;const oe=Gt.value;X(()=>{oe&&oe.startsWith("blob:")&&URL.revokeObjectURL(oe)}),(ve=a.media)!=null&&ve.file?Gt.value=URL.createObjectURL(a.media.file):(ce=a.media)!=null&&ce.url?Gt.value=a.media.url:Gt.value=""},{immediate:!0}),e.onUnmounted(()=>{Gt.value&&Gt.value.startsWith("blob:")&&URL.revokeObjectURL(Gt.value)});const Ei=e.computed(()=>Gt.value),Vs=e.computed(()=>{if(!a.media)return null;const{file:y,...x}=a.media;return{...x,url:Gt.value}}),Ns=e.computed(()=>{var x;const y=(x=a.media)==null?void 0:x.url;return!!(y&&/^https?:/i.test(y))}),Ts=e.computed(()=>nt.value),Ms=e.computed(()=>N.value),xi=e.computed(()=>!!he.value&&N.value>0),Ci=e.computed(()=>!!he.value&&L.value.length>1),Bs=e.computed(()=>!!he.value),un=e.ref(!0),du=[.5,1,1.5,2],eo=e.computed(()=>{const y=new Set([0,Lt.value]);for(const x of L.value)y.add(x.timelineStart),y.add(x.timelineEnd);return Array.from(y).filter(x=>Number.isFinite(x)).sort((x,X)=>x-X)}),uu=e.computed(()=>eo.value.some(y=>y<N.value-.001)),mu=e.computed(()=>eo.value.some(y=>y>N.value+.001)),to=e.ref(!1),no=e.ref(null);function mn(y){if(!Number.isFinite(y)||y<0)return"0:00";const x=Math.floor(y/60),X=Math.floor(y%60);return`${x}:${X.toString().padStart(2,"0")}`}const pu=e.computed(()=>{var X;const y=he.value??L.value[0];if(!y)return"No clip selected";const x=(X=y.label)==null?void 0:X.trim();return x&&x.length>0?x:`Clip ${y.id.slice(-4)}`}),fu=e.computed(()=>{const y=he.value??L.value[0];if(!y)return"Tap a clip to start editing";const x=Math.max(0,y.timelineEnd-y.timelineStart);return`${mn(y.timelineStart)} - ${mn(y.timelineEnd)} • ${x.toFixed(1)}s`});function Fs(y){return!Number.isFinite(y)||y<0?"0.0s":y<60?`${y.toFixed(1)}s`:mn(y)}const hu=e.computed(()=>mn(N.value)),vu=e.computed(()=>{const y=he.value??L.value[0];return y?mn(y.sourceIn):"0:00"}),gu=e.computed(()=>{const y=he.value??L.value[0];return y?mn(y.sourceOut):"0:00"}),yu=e.computed(()=>{const y=he.value??L.value[0];return y?Fs(y.timelineEnd-y.timelineStart):"0.0s"}),Si=e.computed(()=>no.value===null?he.value??L.value[0]??null:L.value.find(y=>y.id===no.value)??null),bu=e.computed(()=>{var X;const y=Si.value;if(!y)return"Clip actions";const x=(X=y.label)==null?void 0:X.trim();return x&&x.length>0?x:`Clip ${y.id.slice(-4)}`}),wu=e.computed(()=>{const y=Si.value;return y?`${mn(y.timelineStart)} - ${mn(y.timelineEnd)} • ${Fs(y.timelineEnd-y.timelineStart)}`:"Choose an action"}),Vi=e.ref(0),Lt=e.computed(()=>{try{const y=te.value??te;return y&&typeof y=="number"&&y>0?y:Vi.value}catch{return Vi.value}}),Xn=e.ref(),Ni=e.ref(),Ti=e.ref(),Mi=e.ref(),ao=e.ref(0),_n=e.ref(!1);let Tt=null,Jt=null;e.watch(Lt,y=>{var X;if(_n.value||!y||y<=0)return;const x=ao.value||((X=Xn.value)==null?void 0:X.clientWidth)||0;x>0&&(_n.value=!0,je(x))}),e.watch(ao,y=>{if(_n.value||!y||y<=0)return;Lt.value>0&&(_n.value=!0,je(y))}),e.watch(l,y=>{y||En()}),e.watch(()=>{var y;return(y=Si.value)==null?void 0:y.id},y=>{to.value&&!y&&En()});function Gn(y){return Number.isFinite(y)?y.toFixed(2):"0.00"}function Is(y){const x=Number(y);return Number.isFinite(x)?x:null}function ku(y){y&&(Y.value=Gn(y.sourceIn),Q.value=Gn(y.sourceOut))}e.watch(()=>{var y,x,X;return[(y=he.value)==null?void 0:y.id,(x=he.value)==null?void 0:x.sourceIn,(X=he.value)==null?void 0:X.sourceOut]},()=>{ku(he.value)},{immediate:!0});function $s(y){const x=he.value;if(!x)return;const X=1/30,oe=x.sourceMinIn??0,ve=x.sourceMaxOut??Lt.value,ce=x.sourceIn+(N.value-x.timelineStart);if(y==="start"){const He=Math.max(oe,Math.min(ce,x.sourceOut-X));Y.value=Gn(He);return}const me=Math.max(x.sourceIn+X,Math.min(ce,ve));Q.value=Gn(me)}function _u(){const y=he.value;if(!y)return;const x=Is(Y.value),X=Is(Q.value);if(x===null||X===null)return;const oe=1/30,ve=y.sourceMinIn??0,ce=y.sourceMaxOut??Lt.value,me=Math.max(ve,Math.min(x,ce-oe)),He=Math.max(me+oe,Math.min(X,ce));xe(y.id,"start",me),xe(y.id,"end",He),Y.value=Gn(me),Q.value=Gn(He),he.value&&G(he.value.timelineStart)}function Eu(){ye.value.trim()!==""&&wn(ye.value)}function xu(){var y;Zn(),et(nt.value),(y=he.value)!=null&&y.id&&(f.value?f.value.setClipFilters(he.value.id,nt.value):C.set(he.value.id,[...nt.value])),Yt()}function Rs(y,x,X){var ve,ce;const oe=nt.value.find(me=>me.filterId===y);oe?(oe.params={...oe.params,[x]:X},et(nt.value),f.value&&((ve=he.value)!=null&&ve.id)?f.value.setClipFilters(he.value.id,nt.value):(ce=he.value)!=null&&ce.id&&C.set(he.value.id,[...nt.value]),Yt(),wi()):jn.value&&jn.value.filterId===y&&(jn.value.params={...jn.value.params||{},[x]:X})}function Ds(y){G(y)}function As(y){!y||!Number.isFinite(y.timestamp)||G(y.timestamp)}function Ls(y){z(y)}function oo(y){!Number.isFinite(y)||y<=0||(Vi.value=y,Re(y))}function En(){to.value=!1,no.value=null}function Cu(y){l.value&&(no.value=y,to.value=!0)}function Bi(y){var oe,ve,ce,me;const x=((oe=he.value)==null?void 0:oe.id)??((ve=L.value[0])==null?void 0:ve.id)??null;de(y),(((ce=he.value)==null?void 0:ce.id)??((me=L.value[0])==null?void 0:me.id)??null)!==x&&we.selection()}function Us(y){Bi(y),Cu(y)}function Os(y){y&&we.selection()}function Ps(){un.value=!un.value,we.selection()}function zs(){const y=eo.value.filter(X=>X<N.value-.001),x=y.length>0?y[y.length-1]:0;G(x)}function js(){const y=eo.value.find(x=>x>N.value+.001);G(y??Lt.value)}function Fi(){Pe()}function Ii(){Je()}function io(){const y=L.value.length;Ve(),L.value.length>y&&(we.success(),En())}function Ws(y){const x=L.value.length;le(y),L.value.length>x&&we.success()}function $i(){const y=L.value.length;dt(),L.value.length>y&&(we.selection(),En())}function Ri(){const y=L.value.length;Be(),L.value.length<y&&(we.error(),En())}function Su(y){const x=fe.value;Ae(y),fe.value!==x&&we.selection()}function Vu(y){return y instanceof HTMLElement?y.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Zs(y){if(l.value||Vu(y.target))return;const x=y.key.toLowerCase(),X=y.metaKey||y.ctrlKey;if(y.code==="Space"){y.preventDefault(),T();return}if(!X&&x==="s"){y.preventDefault(),io();return}if(x==="arrowleft"){y.preventDefault(),pe();return}if(x==="arrowright"){y.preventDefault(),ee();return}if(x==="home"){y.preventDefault(),be();return}if(x==="end"){y.preventDefault(),$e();return}if(!X&&x==="["){y.preventDefault(),zs();return}if(!X&&x==="]"){y.preventDefault(),js();return}if(X&&x==="z"&&y.shiftKey){y.preventDefault(),Ii();return}X&&x==="z"&&(y.preventDefault(),Fi())}function Nu(){var x;const y=ao.value||((x=Xn.value)==null?void 0:x.clientWidth)||800;je(y)}function Di(y){_n.value=!0,Ke(y)}function Tu(){_n.value=!0,Se()}function Mu(){_n.value=!0,Te()}function Bu(y){const x=y.target,X=Number(x.value);Di(X)}function Hs(y){const x=Math.min(600,Math.max(10,se.value+y));Di(x)}function Ai(){Jt==null||Jt(),Jt=null;const y=Ti.value,x=Mi.value;if(!l.value||!y||!x)return;const X=()=>{Hs(-20)},oe=()=>{Hs(20)};y.addEventListener("click",X),x.addEventListener("click",oe),Jt=()=>{y.removeEventListener("click",X),x.removeEventListener("click",oe)}}e.watch([l,Ti,Mi],()=>{Ai()},{flush:"post"});function Xs(y){var x;f.value=y,(x=f.value)!=null&&x.composition&&(B.value=new ld(f.value.composition),E.value=new La(f.value.composition),S.value=new cd(f.value.composition));try{C.size&&(C.forEach((X,oe)=>{f.value.setClipFilters(oe,X)}),C.clear(),f.value.composition.computeFrame())}catch{}}function Fu(y){y!=null&&y.id&&pa(y.id)}function Iu(y){Qa(y),Yt()}async function $u(y){if(!B.value)return;const x=await B.value.addTextOverlay(y);A.value.push({id:x,...y})}async function Ru(y,x){if(!B.value)return;await B.value.updateTextOverlay(y,x);const X=A.value.findIndex(oe=>oe.id===y);X!==-1&&(A.value[X]={...A.value[X],...x})}async function Du(y){B.value&&(await B.value.removeTextOverlay(y),A.value=A.value.filter(x=>x.id!==y))}async function Au(y){if(!E.value||O.value.length<2)return;const[x,X]=O.value,oe=await E.value.applyTransition(x,X,y);R.value.push({id:oe,...y,name:y.type})}function Lu(y){if(!E.value)return;const x=R.value[y];x&&(E.value.removeTransition(x.id),R.value.splice(y,1))}function Uu(y){}async function Ou(y){if(!S.value)return;const x=await S.value.addAudioTrack(y);W.value.push({id:x,...y})}async function Pu(y,x){if(!S.value)return;const X=W.value.findIndex(oe=>oe.id===y);X!==-1&&(W.value[X]={...W.value[X],...x})}async function zu(y){S.value&&(await S.value.removeAudioTrack(y),W.value=W.value.filter(x=>x.id!==y))}async function ju(y,x){if(!S.value)return;await S.value.updateVolume(y,x);const X=W.value.find(oe=>oe.id===y);X&&(X.volume=x)}async function Wu(y,x){if(!S.value)return;await S.value.muteTrack(y,x);const X=W.value.find(oe=>oe.id===y);X&&(X.muted=x)}function Zu(y){S.value&&(S.value.setMasterVolume(y),I.value=y)}function Hu(y){i("thumbnail-selected",y)}function pn(){kn!==null&&(clearInterval(kn),kn=null)}function Xu(y,x){return x?{...y,output:{...y.output,format:x.format,quality:x.quality}}:y}function va(y){var x;return y.metadata||(y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),y.metadata.fit_mode=D.value,(x=a.media)!=null&&x.url&&/^https?:/i.test(a.media.url)?y.metadata.source_url=a.media.url:delete y.metadata.source_url,y}function ot(y,x,X){return Math.min(X,Math.max(x,y))}function Li(y,x){if(typeof y=="number"&&Number.isFinite(y))return y;if(typeof y=="string"){const X=Number(y);if(Number.isFinite(X))return X}return x}function kt(y,x,X){for(const oe of x)if(oe in y)return Li(y[oe],X);return X}function Gu(y){const x=typeof y.params=="object"&&y.params!==null?y.params:{};switch(y.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:ot(kt(x,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:ot(kt(x,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:ot(kt(x,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:ot(kt(x,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:ot(kt(x,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const oe=ot(kt(x,["brightness"],1)-1,-1,1),ve=ot(kt(x,["contrast"],1),.1,3),ce=ot(kt(x,["saturation"],1),0,3);return[{type:"brightness",value:oe},{type:"contrast",value:ve},{type:"saturation",value:ce}]}default:return[]}}function Ju(y){const x=y.timeline[0],X=Array.isArray(x==null?void 0:x.filters)?x.filters:[],oe=[];for(const ce of X)if(oe.push(...Gu(ce)),oe.length>=12)break;const ve={...y,filters:oe.slice(0,12)};if(y.timeline.length===1&&x){const ce=Math.max(0,Li(x.sourceIn,0)),me=Li(x.sourceOut,ce);me>ce&&(ve.trim={start:ce,end:me})}return ve}function Yu(y){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[y??""]??[1920,1080]}function qu(y){if(!y||typeof y!="object")return null;const x=y.duration;if(typeof x=="number"&&Number.isFinite(x)&&x>0)return x;if(x&&typeof x=="object"&&"value"in x){const X=x.value;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X}return null}async function Gs(y,x,X){var sn,qt,Jn,hn;const oe=y.timeline[0],ve=oe?Math.max(0,oe.sourceIn):0,ce=oe?oe.sourceOut:void 0,[me,He]=Yu((x==null?void 0:x.quality)??((sn=y.output)==null?void 0:sn.quality)),Ct=((qt=y.output)==null?void 0:qt.fps)||30;z(!1),w.value=!0,await e.nextTick();try{const pt=[200,500,1e3];let gt=!1;for(const Hi of pt){await new Promise(gm=>setTimeout(gm,Hi));const lo=M.value;if(!(!lo||typeof lo.captureFrameAt!="function")&&typeof lo.ensureReadyForCapture=="function"&&(gt=await lo.ensureReadyForCapture(),gt))break}const Kt=M.value;if(!Kt||typeof Kt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!gt)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:ga,isWebCodecsSupported:Wi}=await Promise.resolve().then(()=>require("./PixiFrameExporter-CqKXaoCX.cjs"));if(!Wi())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Pt=new AbortController;const so={width:me,height:He,fps:Ct,trimStart:ve,signal:Pt.signal};ce!==void 0&&(so.trimEnd=ce),X&&(so.onProgress=X);const al=Gt.value;al!==""&&(so.sourceUrl=al);const mm=typeof Kt.duration=="number"&&Kt.duration>0?Kt.duration:((Jn=y.source)==null?void 0:Jn.duration)??ce??0,pm=await ga({captureFrameAt:Hi=>Kt.captureFrameAt(Hi),duration:{value:mm}},so),Zi=new File([pm],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),fm=qu(Kt),hm=((hn=y.source)==null?void 0:hn.duration)??0,vm=Math.max(0,(ce??fm??hm)-ve);return{file:Zi,recipe:y,meta:{duration:vm,width:me,height:He,format:"mp4",sizeBytes:Zi.size,size_bytes:Zi.size}}}finally{w.value=!1,Pt=null}}async function Ku(y,x){var hn;pn(),Nt=!1,Pt=null,mt.value=null,Le.value=null,Ue.value=!1,Ne.value=0;const X=va(y??ue()),oe=tl(X),ve=Array.isArray(oe.filters)&&oe.filters.length>0,ce=Pi(oe);if(!(ae.value||ve||ce))return rt(),i("video-exported",null),null;const He=oe.timeline[0],Ct=He?Math.max(0,He.sourceIn):0,qt=((He==null?void 0:He.sourceOut)??((hn=oe.source)==null?void 0:hn.duration)??Lt.value)-Ct,Jn=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&qt>a.clientExportThreshold;if(Jn){Ee.value=!0;try{return await Qu(oe),null}catch(pt){const gt=pt instanceof Error?pt.message:"Server render failed";throw Le.value=gt,i("server-render-failed",gt),pt}finally{Ee.value=!1}}if(a.maxDuration>0&&qt>a.maxDuration&&!Jn){const pt=`This video is too long for in-browser export (${Math.round(qt)}s). Server rendering is not available. Try a shorter clip.`;return Le.value=pt,i("video-exported",null),null}Ee.value=!0;try{const pt=await Gs(oe,x,gt=>{Nt||(Ne.value=gt)});return Nt?(Le.value="Export canceled.",Ne.value=0,i("video-exported",null),null):(rt(),i("recipe-generated",oe),i("video-exported",pt),Ne.value=100,Ue.value=!0,pt)}catch(pt){if(Nt)return Le.value="Export canceled.",Ne.value=0,i("video-exported",null),null;const gt=pt instanceof Error?pt.message:"Local WebGL export failed.";throw Le.value=gt,new Error(`Video export failed: ${gt}`)}finally{Ee.value=!1}}function ro(){return new vi(a.serverRenderEndpoint??"/api/v1")}async function Qu(y){const x=ro();Le.value="Starting server render...",Ne.value=0;const X=await x.createRenderJob({source_media_uuid:s.value,recipe:y});mt.value=X.id,i("server-render-started",X.id),i("export-started",X.id),Le.value="Rendering on server...";const oe=await x.pollRenderJob(X.id,(ce,me)=>{Ne.value=ce,me==="processing"&&(Le.value=`Server rendering: ${ce}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);Ne.value=100,Ue.value=!0,Le.value="Server render complete!",rt(),i("recipe-generated",y);const ve={id:oe.id};typeof oe.output_media_id=="string"&&oe.output_media_id!==""&&(ve.output_media_id=oe.output_media_id),i("server-render-completed",ve)}async function Js(){if(!Ee.value)return;Nt=!0,w.value=!1,Pt&&(Pt.abort(),Pt=null),pn();const y=mt.value;if(y)try{await ro().cancelJob(y)}catch(x){const X=x instanceof Error?x.message:"Failed to cancel export";Le.value=X,Ee.value=!1,mt.value=null;return}Ee.value=!1,Ne.value=0,Ue.value=!1,mt.value=null,Le.value="Export canceled."}async function Ys(y){pn(),Nt=!1,Pt=null,mt.value=null,Le.value=null,Ue.value=!1,Ee.value=!0,Ne.value=0;try{const x=va(Xu(ue(),y));i("recipe-generated",x);const X=s.value.startsWith("temp-"),oe=x.timeline[0],ve=Array.isArray(oe==null?void 0:oe.filters)?oe.filters:[],ce=!0,me=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(ce)try{const gt=await Gs(x,y,Wi=>{Nt||(Ne.value=Wi)});if(Nt){Le.value="Export canceled.",Ee.value=!1,Ne.value=0;return}i("video-exported",gt);const Kt=URL.createObjectURL(gt.file),ga=document.createElement("a");ga.href=Kt,ga.download=`edited-video-${Date.now()}.mp4`,ga.click(),setTimeout(()=>URL.revokeObjectURL(Kt),100),Ee.value=!1,Ne.value=100,Ue.value=!0;return}catch(gt){if(Nt){Le.value="Export canceled.",Ee.value=!1,Ne.value=0;return}if(X||!me)throw gt;Ne.value=0,Le.value="Local filter export failed, falling back to server render."}const He={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},Ct=(y==null?void 0:y.quality)??x.output.quality,sn=He[Ct]??"high",qt={...Ju(x),export:{format:(y==null?void 0:y.format)??x.output.format,quality:sn,resolution:Ct,framerate:x.output.fps}},hn=await ro().createJob({source_media_id:s.value,recipe:qt}),pt=typeof hn.id=="string"?hn.id:null;if(!pt)throw new Error("Export failed: missing job id");mt.value=pt,i("export-started",pt),dm(pt)}catch(x){if(w.value=!1,Pt=null,Nt){Le.value="Export canceled.",Ee.value=!1,Ne.value=0,mt.value=null;return}try{const X=va(ue()),oe=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),ve=URL.createObjectURL(oe),ce=document.createElement("a");ce.href=ve,ce.download=`video-recipe-${Date.now()}.json`,ce.click(),setTimeout(()=>URL.revokeObjectURL(ve),100)}finally{Ee.value=!1,Ne.value=0,mt.value=null,Le.value=x instanceof Error?x.message:"Export failed"}}}const Ui=async y=>{await new Promise(x=>{window.setTimeout(x,y)})},Oi=y=>{if(!y||y.width<=0||y.height<=0)return null;try{return y.toDataURL("image/jpeg",.85)}catch{return null}},em=y=>{if(!y||typeof y!="object")return null;const X=y.pixiCanvas;if(X&&typeof X=="object"&&"value"in X){const oe=X.value;return oe instanceof HTMLCanvasElement?oe:null}return X instanceof HTMLCanvasElement?X:null},tm=y=>{if(!y||typeof y!="object")return null;const x=y.duration;if(typeof x=="number"&&Number.isFinite(x))return x;if(x&&typeof x=="object"&&"value"in x){const X=x.value;if(typeof X=="number"&&Number.isFinite(X))return X}return null},nm=y=>{if(!y||typeof y!="object")return null;const X=y.videoElement;if(X&&typeof X=="object"&&"value"in X){const oe=X.value;return oe instanceof HTMLVideoElement?oe:null}return X instanceof HTMLVideoElement?X:null},qs=y=>typeof y.params=="object"&&y.params!==null?y.params:{},am=y=>{const x=[];for(const X of y){const oe=qs(X),ve=X.filterId.trim().toLowerCase();if(ve==="brightness"){const me=(ot(kt(oe,["value","brightness"],0),-1,1)+1)*100;x.push(`brightness(${me.toFixed(2)}%)`);continue}if(ve==="contrast"){const ce=ot(kt(oe,["value","contrast"],1),.1,4);x.push(`contrast(${(ce*100).toFixed(2)}%)`);continue}if(ve==="saturation"||ve==="saturate"){const ce=ot(kt(oe,["value","saturation"],1),0,4);x.push(`saturate(${(ce*100).toFixed(2)}%)`);continue}if(ve==="grayscale"){x.push("grayscale(100%)");continue}if(ve==="sepia"){x.push("sepia(100%)");continue}if(ve==="blur"||ve==="gaussian-blur"||ve==="kawase-blur"){const ce=ot(kt(oe,["value","blur","radius"],0),0,30);ce>.01&&x.push(`blur(${ce.toFixed(2)}px)`);continue}if(ve==="adjustment"){const ce=kt(oe,["brightness"],1),me=kt(oe,["contrast"],1),He=kt(oe,["saturation"],1);Math.abs(ce-1)>.01&&x.push(`brightness(${(ot(ce,0,5)*100).toFixed(2)}%)`),Math.abs(me-1)>.01&&x.push(`contrast(${(ot(me,.1,5)*100).toFixed(2)}%)`),Math.abs(He-1)>.01&&x.push(`saturate(${(ot(He,0,5)*100).toFixed(2)}%)`);continue}if(ve==="cinematic"){x.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ve==="dramatic"){x.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ve==="dreamy"){x.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return x.join(" ")},om=y=>{const x=y.find(ve=>ve.filterId.trim().toLowerCase()==="noise");if(!x)return 0;const X=qs(x),oe=kt(X,["noise","value","amount","intensity"],.2);return oe<=1?ot(oe,0,1):ot(oe/100,0,1)},im=(y,x,X,oe)=>{if(oe<=0)return;const ve=y.getImageData(0,0,x,X),ce=255*oe;for(let me=0;me<ve.data.length;me+=4){const He=(Math.random()*2-1)*ce;ve.data[me]=ot(ve.data[me]+He,0,255),ve.data[me+1]=ot(ve.data[me+1]+He,0,255),ve.data[me+2]=ot(ve.data[me+2]+He,0,255)}y.putImageData(ve,0,0)},Ks=async y=>{y.readyState>=2&&y.videoWidth>0&&y.videoHeight>0||await new Promise(x=>{let X=!1,oe=0;const ve=()=>{X||(X=!0,y.removeEventListener("loadedmetadata",ce),y.removeEventListener("loadeddata",ce),y.removeEventListener("canplay",ce),window.clearTimeout(oe),x())},ce=()=>{ve()};y.addEventListener("loadedmetadata",ce),y.addEventListener("loadeddata",ce),y.addEventListener("canplay",ce),oe=window.setTimeout(()=>ve(),800),y.play().catch(()=>{})})},rm=async(y,x)=>{await new Promise(X=>{let oe=!1,ve=0;const ce=()=>{oe||(oe=!0,y.removeEventListener("seeked",me),window.clearTimeout(ve),X())},me=()=>{ce()};if(Math.abs(y.currentTime-x)<.016){requestAnimationFrame(()=>ce());return}y.addEventListener("seeked",me),ve=window.setTimeout(()=>ce(),700),y.currentTime=x})},Qs=async(y,x)=>{await Ks(y);const X=Math.floor(y.videoWidth),oe=Math.floor(y.videoHeight);if(X<=0||oe<=0)return null;const ve=Number.isFinite(y.duration)&&y.duration>0?y.duration:0,ce=ve>0?ot(x,0,ve):0;await rm(y,ce);const me=document.createElement("canvas");me.width=X,me.height=oe;const He=me.getContext("2d");if(!He)return null;const Ct=am(nt.value);Ct!==""&&(He.filter=Ct);try{He.drawImage(y,0,0,X,oe)}catch{return null}const sn=om(nt.value);return im(He,X,oe,sn),Oi(me)},sm=async(y,x)=>{const X=document.createElement("video");X.src=y,X.muted=!0,X.playsInline=!0,X.preload="auto",y.startsWith("blob:")||(X.crossOrigin="anonymous");try{return await Ks(X),await Qs(X,x)}catch{return null}finally{X.pause(),X.removeAttribute("src"),X.load()}},lm=async y=>{const x=M.value,X=Oi(em(x));if(X)return X;if(x!=null&&x.captureFrameAt)for(let ce=0;ce<4;ce+=1){const me=tm(x);if(me!==null&&me<=0&&ce<2){await Ui(80);continue}const He=await Promise.race([x.captureFrameAt(y),Ui(450).then(()=>null)]),Ct=Oi(He);if(Ct)return Ct;await Ui(80)}const oe=nm(x);if(oe){const ce=await Qs(oe,y);if(ce)return ce}const ve=Ei.value.trim();if(ve!==""){const ce=await sm(ve,y);if(ce)return ce}return null},el=y=>y.map(x=>({...x,params:x.params&&typeof x.params=="object"?{...x.params}:x.params}));function tl(y){const x=el(nt.value);if(!Pi(y)&&x.length>0&&Array.isArray(y.timeline)&&y.timeline.length>0){const oe=y.timeline[0];oe&&(y.timeline=[{...oe,filters:x},...y.timeline.slice(1)])}return y}const Pi=y=>Array.isArray(y.timeline)?y.timeline.some(x=>Array.isArray(x.filters)&&x.filters.length>0):!1,cm=y=>{if(!y||typeof y!="object")return null;const x=y.posterFrame;if(typeof x!="string")return null;const X=x.trim();return X!==""?X:null};async function zi(){const y=va(tl(Vt())),x=el(nt.value),X=Pi(y)||x.length>0,oe=cm(a.initialRecipe);if(X){const ve=N.value>0?N.value:.1;try{const ce=await lm(ve);ce?y.posterFrame=ce:oe&&(y.posterFrame=oe)}catch{oe&&(y.posterFrame=oe)}}else delete y.posterFrame;return rt(),i("draft-saved",y),y}function nl(){vt()&&(Zn(),Yt())}async function dm(y){pn();const x=ro();kn=window.setInterval(async()=>{try{if(Nt){pn();return}const X=await x.getJob(y),oe=Number(X.progress??0);if(Ne.value=Number.isFinite(oe)?oe:0,X.status==="completed"||X.status==="failed"||X.status==="cancelled")if(pn(),Ee.value=!1,mt.value=null,X.status==="completed")Ne.value=100,Ue.value=!0,Le.value=null;else{const ve=X.status==="cancelled"||typeof X.error_message=="string"&&/cancel/i.test(X.error_message);Le.value=ve?"Export canceled.":typeof X.error_message=="string"&&X.error_message.trim()!==""?X.error_message:"Export failed"}}catch(X){pn(),Ee.value=!1,mt.value=null,Le.value=X instanceof Error?X.message:"Failed to check export progress"}},2e3)}function ji(){const y=va(ue());try{const x=y.timeline??[]}catch{}_.value=y}let xn=null;function Yt(){xn&&clearTimeout(xn),xn=setTimeout(()=>{ji(),xn=null},200)}e.watch(()=>L.value,Yt,{deep:!0}),e.watch(()=>he.value,y=>{if(P.value||!y)return;const x=(y==null?void 0:y.filters)??[];ha(x)},{immediate:!0}),e.watch(()=>nt.value,y=>{et(y),Yt()},{deep:!0}),e.watch(()=>A.value,y=>{at(y),Yt()},{deep:!0}),e.watch(()=>W.value,y=>{const x=y.map(X=>({...X,source:typeof X.source=="string"?X.source:void 0}));wt(x),Yt()},{deep:!0}),e.watch(()=>N.value,Yt),n({saveDraft:zi,exportForUpload:Ku}),ji(),e.onUnmounted(()=>{pn(),Nt=!0,xn&&(clearTimeout(xn),xn=null),f.value&&(f.value.destroy(),f.value=null),B.value=null,E.value=null,S.value=null});function um(){Tt||!Ni.value||(Tt=new Fb({filters:Hn.value,callbacks:{onApplyFilter:y=>{wn(y.id)},onRemoveFilter:y=>{ki(y)},onUpdateParam:(y,x,X)=>{Rs(y,x,X)},onPreviewFilter:y=>{pa(y.id)}}}),Tt.mount(Ni.value),Tt.setActiveFilters(_i.value))}e.watch(_i,y=>{Tt==null||Tt.setActiveFilters(y)},{deep:!0}),e.watch(Hn,y=>{Tt==null||Tt.setFilters(y)});let fn=null;return e.onMounted(()=>{window.addEventListener("resize",F),window.addEventListener("keydown",Zs);const y=()=>{!Xn.value||fn||(fn=new ResizeObserver(x=>{x[0]&&(ao.value=Math.round(x[0].contentRect.width))}),fn.observe(Xn.value))};y(),fn||e.nextTick(y),l.value&&(Ai(),Jt||e.nextTick(Ai)),a.media&&ji(),l.value&&e.nextTick(()=>{um()}),e.nextTick(()=>{const x=document.querySelector(".video-editor");x&&x.getBoundingClientRect();const X=document.querySelector(".mobile-layout");X&&X.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",F),window.removeEventListener("keydown",Zs),fn==null||fn.disconnect(),fn=null,Jt==null||Jt(),Jt=null,Tt==null||Tt.destroy(),Tt=null}),(y,x)=>{var X,oe,ve,ce;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",_2,[e.createElementVNode("div",E2,[e.createElementVNode("div",x2,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ie)}]),onClick:x[0]||(x[0]=(...me)=>e.unref(T)&&e.unref(T)(...me)),"aria-label":e.unref(ie)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ie)?e.unref(Gr):e.unref(Jr)},null,8,["icon"])],10,C2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:nl,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"])])]),e.createElementVNode("div",S2,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:zi,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ae)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xo)},null,8,["icon"]),x[13]||(x[13]=e.createElementVNode("span",null,"Save",-1))],8,V2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:x[1]||(x[1]=me=>Ys()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:Ee.value||!e.unref(ae)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(aa)},null,8,["icon"])],8,N2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:x[2]||(x[2]=me=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"])])])]),e.createElementVNode("div",T2,[e.withDirectives(e.createVNode(fr,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!h.value,class:"preview-host-child",source:Ei.value,"fallback-duration":Lt.value,filters:Ts.value,playhead:Ms.value,"is-playing":e.unref(ie),"fit-mode":D.value,active:h.value,onPlayPause:e.unref(T),onFrameUpdate:As,onDurationChange:oo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(Mr,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:Vs.value,"enable-engine":p.value&&Ns.value,"fit-mode":D.value,onTimeUpdate:Ds,onPlayStateChange:Ls,onDurationChange:oo,onEngineReady:Xs},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),Ee.value?(e.openBlock(),e.createElementBlock("div",M2,[e.createElementVNode("div",B2,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Ne.value)+"%",1),e.createElementVNode("div",F2,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Ne.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Js},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Xn,class:"timeline-section"},[e.createElementVNode("div",I2,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:Ti,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...x[14]||(x[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:Mi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...x[15]||(x[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(Br,{playhead:e.unref(N),clips:e.unref(L),"selected-clip-id":((X=e.unref(he))==null?void 0:X.id)??((oe=e.unref(L)[0])==null?void 0:oe.id)??null,duration:Lt.value,"zoom-level":e.unref(se),"snap-enabled":un.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(G),onTrim:e.unref(xe),onSplit:Ws,onClipSelect:Bi,onClipMove:e.unref(bt),onClipLongPress:Us,onSnapStateChange:Os},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",$2,[e.createElementVNode("div",R2,[e.createElementVNode("span",D2,e.toDisplayString(pu.value),1),e.createElementVNode("span",A2,e.toDisplayString(fu.value),1)]),e.createElementVNode("div",L2,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!uu.value,onClick:zs}," Prev Cut ",8,U2),e.createElementVNode("div",O2,[e.createElementVNode("span",P2,"Playhead "+e.toDisplayString(hu.value),1),e.createElementVNode("span",z2,"In "+e.toDisplayString(vu.value),1),e.createElementVNode("span",j2,"Out "+e.toDisplayString(gu.value),1),e.createElementVNode("span",W2,"Duration "+e.toDisplayString(yu.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:!mu.value,onClick:js}," Next Cut ",8,Z2)]),e.createElementVNode("div",H2,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:un.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:Ps},e.toDisplayString(un.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",X2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(du,me=>e.createElementVNode("button",{key:me,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(fe)===me}]),"data-testid":`btn-mobile-speed-${String(me).replace(".","-")}`,onClick:He=>Su(me)},e.toDisplayString(me)+"x ",11,G2)),64))])]),e.createElementVNode("div",J2,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(tt),onClick:Fi}," Undo ",8,Y2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(xt),onClick:Ii}," Redo ",8,q2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!xi.value,onClick:io}," Split ",8,K2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!Bs.value,onClick:$i}," Duplicate ",8,Q2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!Ci.value,onClick:Ri}," Delete ",8,ek)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Ni,class:"controls-section mobile-controls"},null,512),to.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:En},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:x[3]||(x[3]=e.withModifiers(()=>{},["stop"]))},[x[16]||(x[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",tk,[e.createElementVNode("span",nk,e.toDisplayString(bu.value),1),e.createElementVNode("span",ak,e.toDisplayString(wu.value),1)]),e.createElementVNode("div",ok,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(tt),onClick:Fi},"Undo",8,ik),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(xt),onClick:Ii},"Redo",8,rk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!xi.value,onClick:io},"Split",8,sk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!Bs.value,onClick:$i},"Duplicate",8,lk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!Ci.value,onClick:Ri},"Delete",8,ck),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:En},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",dk,[e.createElementVNode("div",uk,[e.createElementVNode("div",mk,[e.createElementVNode("div",pk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":x[4]||(x[4]=me=>D.value=me),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...x[17]||(x[17]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,D.value]])])]),e.withDirectives(e.createVNode(fr,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!h.value,class:"preview-host-child",source:Ei.value,"fallback-duration":Lt.value,filters:Ts.value,playhead:Ms.value,"is-playing":e.unref(ie),"fit-mode":D.value,active:h.value,onPlayPause:e.unref(T),onFrameUpdate:As,onDurationChange:oo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(Mr,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:Vs.value,"enable-engine":p.value&&Ns.value,"fit-mode":D.value,onTimeUpdate:Ds,onPlayStateChange:Ls,onDurationChange:oo,onEngineReady:Xs},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),y.showThumbnailPicker?(e.openBlock(),e.createBlock(cy,{key:0,"media-uuid":s.value,duration:Lt.value,onSelect:Hu},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",fk,[e.createElementVNode("div",hk,[e.createElementVNode("div",vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.value,me=>(e.openBlock(),e.createElementBlock("button",{key:me.id,class:e.normalizeClass(["tab-btn",{active:d.value===me.id}]),onClick:He=>d.value=me.id},e.toDisplayString(me.label),11,gk))),128))]),e.createElementVNode("div",yk,[e.withDirectives(e.createElementVNode("div",bk,[e.createVNode(Fr,{filters:Hn.value,"active-filters":_i.value,"thumbnail-url":cu.value,onApplyFilter:wn,onRemoveFilter:ki,onUpdateParam:Rs,onPreviewFilter:Fu},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",wk,[e.createVNode(Rr,{overlays:A.value,onAddOverlay:$u,onUpdateOverlay:Ru,onRemoveOverlay:Du},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",kk,[e.createVNode(Dr,{"selected-clips":O.value,"applied-transitions":R.value,onApplyTransition:Au,onRemoveTransition:Lu,onPreviewTransition:Uu},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",_k,[e.createVNode(Ar,{"audio-layers":W.value,"master-volume":I.value,onAddTrack:Ou,onUpdateTrack:Pu,onRemoveTrack:zu,onUpdateVolume:ju,onToggleMute:Wu,onUpdateMasterVolume:Zu},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Ek,[e.unref(Xt)?(e.openBlock(),e.createBlock(Ir,{key:0,filter:e.unref(Xt),"current-frame":e.unref(ne),onUpdateParams:Iu},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",xk,[...x[18]||(x[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",Ck,[e.createVNode($r,{"can-export":e.unref(ae),"is-exporting":Ee.value,"export-progress":Ne.value,onExport:Ys,onCancelExport:Js,onSaveDraft:zi,onReset:nl},null,8,["can-export","is-exporting","export-progress"]),Ue.value?(e.openBlock(),e.createElementBlock("div",Sk," Export complete ")):e.createCommentVNode("",!0),Le.value&&!Ue.value?(e.openBlock(),e.createElementBlock("div",Vk,e.toDisplayString(Le.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Nk,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Xn,class:"timeline-container"},[e.createElementVNode("div",Tk,[e.createElementVNode("label",null,[x[19]||(x[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(se),onInput:x[5]||(x[5]=me=>Bu(me))},null,40,Mk)]),e.createElementVNode("span",Bk,e.toDisplayString(Math.round(e.unref(se)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:un.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:Ps},e.toDisplayString(un.value?"Snap On":"Snap Off"),3)]),e.createVNode(Br,{playhead:e.unref(N),clips:e.unref(L),"selected-clip-id":((ve=e.unref(he))==null?void 0:ve.id)??((ce=e.unref(L)[0])==null?void 0:ce.id)??null,duration:Lt.value,"zoom-level":e.unref(se),"snap-enabled":un.value,sensitivity:.25,"onUpdate:playhead":e.unref(G),onTrim:e.unref(xe),onSplit:Ws,onClipSelect:Bi,onClipMove:e.unref(bt),onClipLongPress:Us,onSnapStateChange:Os},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(ad,{"selected-clip":e.unref(he),"can-split":xi.value,"can-delete":Ci.value,"is-playing":e.unref(ie),"zoom-level":e.unref(se),"playback-speed":e.unref(fe),onSplit:io,onDelete:Ri,onDuplicate:$i,onZoomIn:Tu,onZoomOut:Mu,onZoomChange:Di,onFitToWindow:Nu,onPlayPause:e.unref(T),onFrameForward:e.unref(ee),onFrameBackward:e.unref(pe),onSkipToStart:e.unref(be),onSkipToEnd:e.unref($e),onSpeedChange:e.unref(Ae)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),ge.value?(e.openBlock(),e.createElementBlock("div",Fk,[e.createElementVNode("div",Ik,[e.createElementVNode("label",$k,[x[20]||(x[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":x[6]||(x[6]=me=>Y.value=me),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Y.value]])]),e.createElementVNode("label",Rk,[x[21]||(x[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":x[7]||(x[7]=me=>Q.value=me),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Q.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(he),onClick:x[8]||(x[8]=me=>$s("start"))}," Start = Playhead ",8,Dk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(he),onClick:x[9]||(x[9]=me=>$s("end"))}," End = Playhead ",8,Ak),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(he),onClick:_u}," Apply Trim ",8,Lk)]),e.createElementVNode("div",Uk,[e.createElementVNode("label",Ok,[x[22]||(x[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":x[10]||(x[10]=me=>ye.value=me),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Hn.value,me=>(e.openBlock(),e.createElementBlock("option",{key:me.id,value:me.id},e.toDisplayString(me.name),9,Pk))),128))],512),[[e.vModelSelect,ye.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(he)||ye.value==="",onClick:Eu}," Apply Filter ",8,zk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(nt).length===0,onClick:xu}," Clear Filters ",8,jk),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(he),onClick:x[11]||(x[11]=me=>wn("noise"))}," QA: Noise ",8,Wk),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(he),onClick:x[12]||(x[12]=me=>wn("grayscale"))}," QA: Grayscale ",8,Zk)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Rd=Me(Hk,[["__scopeId","data-v-f427827a"]]),Xk={key:0,class:"video-editor-v2-toolbar"},Gk={class:"video-editor-v2-body"},Jk={class:"video-editor-v2-main"},Yk={class:"video-editor-v2-canvas"},qk={key:0,class:"video-editor-v2-timeline"},Kk={class:"video-editor-v2-side","data-testid":"v2-side-panel"},Qk="(max-width: 900px)",e_=e.defineComponent({__name:"SplitPanelLayout",setup(o,{expose:n}){const t=e.ref(!1);let a=null,i=null;const r=s=>{t.value=s};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(a=window.matchMedia(Qk),r(a.matches),i=s=>r(s.matches),a.addEventListener?a.addEventListener("change",i):"addListener"in a&&a.addListener(i))}),e.onBeforeUnmount(()=>{!a||!i||(a.removeEventListener?a.removeEventListener("change",i):"removeListener"in a&&a.removeListener(i),a=null,i=null)}),n({isMobile:t}),(s,l)=>(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"},[s.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",Xk,[e.renderSlot(s.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Gk,[e.createElementVNode("div",Jk,[e.createElementVNode("div",Yk,[e.renderSlot(s.$slots,"canvas",{},void 0,!0)]),s.$slots.timeline?(e.openBlock(),e.createElementBlock("div",qk,[e.renderSlot(s.$slots,"timeline",{},void 0,!0)])):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("aside",Kk,[e.renderSlot(s.$slots,"inspector",{},void 0,!0)],512),[[e.vShow,!t.value]])]),t.value?e.renderSlot(s.$slots,"drawer",{key:1},void 0,!0):e.createCommentVNode("",!0)],2))}}),t_=Me(e_,[["__scopeId","data-v-a0d79157"]]),n_={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},a_=["aria-selected","data-testid","onClick"],o_=["aria-labelledby"],i_={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},r_=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(o,{emit:n}){const t=o,a=n,i=e.computed(()=>t.tabs.filter(s=>s.enabled)),r=s=>{s!==t.activeTab&&a("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",n_,[(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,a_))),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",i_,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,o_)],2))}}),Xl=Me(r_,[["__scopeId","data-v-7f5b0e50"]]),s_=["aria-label","data-snap"],l_=["aria-expanded"],c_={class:"drawer-header"},d_={class:"drawer-body"},u_=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(o,{expose:n,emit:t}){const a=["collapsed","half","full"],i=o,r=t,s=e.ref(null),l=e.ref(null),c=e.ref(i.initialSnap);let d=!1,u=!1,m=null,h=0,p=0,v=0;const g=S=>{const P=v||(typeof window<"u"?window.innerHeight:600);switch(S){case"collapsed":return 80;case"half":return Math.round(P*.45);case"full":return Math.round(P*.85)}},w=(S,{animate:P=!0}={})=>{var R;if(!s.value)return;const C=c.value;c.value=S;const A=typeof window<"u"&&((R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=P&&!A?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${g(S)}px`,S!==C&&r("snap-change",S,C)},M=S=>{let P=a[0],C=1/0;for(const A of a){const R=Math.abs(g(A)-S);R<C&&(C=R,P=A)}return P},V=()=>{const S=a.indexOf(c.value);w(a[(S+1)%a.length])},b=S=>{if(u){u=!1,S.preventDefault();return}V()},f=S=>{var P,C,A;if(S.button===0){d=!0,u=!1,m=S.pointerId,h=S.clientY,p=((P=s.value)==null?void 0:P.offsetHeight)??0;try{(A=(C=l.value)==null?void 0:C.setPointerCapture)==null||A.call(C,S.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},_=S=>{if(!d||S.pointerId!==m)return;const P=S.clientY-h,C=p-P,A=g("collapsed"),R=g("full"),W=Math.max(A,Math.min(R,C));s.value&&(s.value.style.height=`${W}px`),Math.abs(P)>4&&(u=!0),S.preventDefault()},D=S=>{var C,A,R;if(!d)return;d=!1;try{(A=(C=l.value)==null?void 0:C.releasePointerCapture)==null||A.call(C,S.pointerId)}catch{}m=null;const P=((R=s.value)==null?void 0:R.offsetHeight)??0;w(M(P))},B=(S,P={})=>{a.includes(S)&&w(S,{animate:P.animate!==!1})},E=S=>{v=Math.max(0,Number(S)||0),w(c.value,{animate:!1})};return e.watch(()=>i.containerHeight,S=>{S>0&&E(S)}),e.onMounted(()=>{i.containerHeight>0&&(v=i.containerHeight),w(c.value,{animate:!1})}),e.onBeforeUnmount(()=>{d=!1,m=null}),n({snapTo:B,updateContainerHeight:E,snap:c}),(S,P)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":S.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:b,onPointerdown:f,onPointermove:_,onPointerup:D,onPointercancel:D},[...P[0]||(P[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,l_),e.createElementVNode("div",c_,[e.renderSlot(S.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",d_,[e.renderSlot(S.$slots,"default",{},void 0,!0)])],8,s_))}}),m_=Me(u_,[["__scopeId","data-v-4ebedbf7"]]),p_={class:"v2-toolbar-group"},f_=["aria-label"],h_=["disabled"],v_={class:"v2-toolbar-group"},g_={class:"v2-toolbar-fit"},y_=["disabled"],b_=["disabled"],w_={class:"v2-preview-host"},k_={class:"v2-timeline"},__={class:"v2-timeline-topbar"},E_={class:"v2-timeline-zoom"},x_=["value"],C_={class:"v2-timeline-zoom-readout"},S_=["aria-pressed"],V_={key:1,class:"v2-empty-state"},N_={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},T_={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},M_={key:1,class:"v2-empty-state"},B_={key:0,class:"v2-export-status"},F_={key:1,class:"v2-export-status"},I_=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{var ye;const Y=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";if(Y!=="")return Y;const Q=(ye=a.media)==null?void 0:ye.uuid;return typeof Q=="string"&&Q.trim()!==""?Q.trim():`temp-${Date.now()}`}),s=od(r.value,a.initialRecipe,a.media),l=sd(),c=e.ref("filters"),d=e.computed(()=>a.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}),u=e.computed(()=>{const Y=a.featureFlags??{},Q=["filters","adjustments","text","transitions","audio","export"],ye={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return Q.map(Ee=>({id:Ee,label:ye[Ee],enabled:typeof Y[Ee]=="boolean"?Y[Ee]:d.value[Ee]}))}),m=e.ref(!1),h=e.computed(()=>c.value),p=e.computed(()=>h.value==="filters"||m.value),v=e.computed(()=>h.value!=="filters"&&!m.value),g=["contain","cover","none"],w=Y=>typeof Y=="string"&&g.includes(Y),M=Y=>{const Q=Y==null?void 0:Y.editor;return w(Q==null?void 0:Q.fitMode)?Q.fitMode:null},V=e.ref(M(a.initialRecipe)??"contain"),b=e.ref("");e.watch(()=>{var Y,Q;return{file:(Y=a.media)==null?void 0:Y.file,url:(Q=a.media)==null?void 0:Q.url}},(Y,Q,ye)=>{var Ne,Ue;const Ee=b.value;ye(()=>{Ee&&Ee.startsWith("blob:")&&URL.revokeObjectURL(Ee)}),(Ne=a.media)!=null&&Ne.file?b.value=URL.createObjectURL(a.media.file):(Ue=a.media)!=null&&Ue.url?b.value=a.media.url:b.value=""},{immediate:!0});const f=e.computed(()=>b.value),_=e.computed(()=>l.activeFilters.value),D=e.computed(()=>s.playheadPosition.value),B=e.computed(()=>{if(!a.media)return null;const{file:Y,...Q}=a.media;return{...Q,url:b.value}}),E=e.computed(()=>{var Q;const Y=(Q=a.media)==null?void 0:Q.url;return!!(Y&&/^https?:/i.test(Y))}),S=e.ref(0),P=e.computed(()=>{var Q;if(s.totalDuration.value>0)return s.totalDuration.value;if(S.value>0)return S.value;const Y=Number((Q=a.media)==null?void 0:Q.duration);return Number.isFinite(Y)&&Y>0?Y:0}),C=Y=>{!Number.isFinite(Y)||Y<=0||(S.value=Y,s.updateSourceDuration(Y))},A=Y=>{Y&&typeof Y.time=="number"&&Number.isFinite(Y.time)&&s.seekTo(Y.time)},R=Y=>{Number.isFinite(Y)&&s.seekTo(Y)},W=Y=>{s.setPlaying(Y)},O=e.computed(()=>l.videoCompatibleFilters.value.map(Q=>{var Ee;const ye=[];if(Q.controls&&Q.controls.length>0)for(const Ne of Q.controls){const Ue=Ne.type;if(Ue==="button"||Ue==="text"||Ue==="range")continue;const Le={id:Ne.property||Ne.id,label:Ne.label||Ne.id,type:Ue,default:Ne.default??(Ue==="toggle"?!1:Ue==="color"?"#ffffff":0)};Ue==="slider"&&(Le.min=Ne.min??0,Le.max=Ne.max??1,Le.step=Ne.step??.01),Ue==="select"&&Ne.options&&(Le.options=Ne.options),ye.push(Le)}else if(Q.paramRanges){const Ne=Object.entries(Q.paramRanges);for(const[Ue,Le]of Ne){const mt=Ue.replace(/[-_]/g," ").replace(/\b\w/g,Pt=>Pt.toUpperCase()),kn=(Ee=Q.defaultParams)==null?void 0:Ee[Ue],Nt=(Le.min+Le.max)/2;ye.push({id:Ue,label:mt,min:Le.min,max:Le.max,step:Le.step??.01,default:typeof kn=="number"?kn:Nt})}}return{id:Q.id,name:Q.name,category:Q.category,params:ye}})),I=e.computed(()=>{const Y=new Map;return l.activeFilters.value.forEach(Q=>Y.set(Q.filterId,Q)),Y}),F=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const Y=a.media;return(Y==null?void 0:Y.thumbnail_url)??(Y==null?void 0:Y.url)}),k=e.shallowRef(null),$=e.ref(null),j=e.ref(null),Z=e.ref(null),K=e.ref(null),ge=e.ref(!1),we=new Map,ne=e.ref([]),N=e.ref([]),L=e.ref([]),te=e.ref(1),ae=e.ref([]),ie=Y=>{k.value=Y,Y!=null&&Y.composition&&(j.value=new ld(Y.composition),Z.value=new La(Y.composition),K.value=new cd(Y.composition));try{we.size&&k.value&&(we.forEach((Q,ye)=>{k.value.setClipFilters(ye,Q)}),we.clear(),k.value.composition.computeFrame())}catch{}},he=Y=>{k.value?k.value.setClipFilters(Y,l.activeFilters.value):we.set(Y,[...l.activeFilters.value])},se=Y=>{var ye,Ee;const Q=((ye=s.selectedClip.value)==null?void 0:ye.id)??((Ee=s.timelineClips.value[0])==null?void 0:Ee.id);Q&&(ge.value=!0,typeof Y=="object"&&Y!==null&&"id"in Y?l.applyFilter(Y.id):typeof Y=="string"&&l.applyFilter(Y),s.setFilters(l.activeFilters.value),he(Q),s.handleClipSelect(Q),ge.value=!1,T())},fe=Y=>{var Ee,Ne;const Q=l.activeFilters.value.find(Ue=>Ue.filterId===Y);Q&&l.removeFilter(Q.id),s.setFilters(l.activeFilters.value);const ye=((Ee=s.selectedClip.value)==null?void 0:Ee.id)??((Ne=s.timelineClips.value[0])==null?void 0:Ne.id);ye&&he(ye),T()},xe=(Y,Q,ye)=>{var Ue,Le;const Ee=l.activeFilters.value.find(mt=>mt.filterId===Y);if(Ee){Ee.params={...Ee.params??{},[Q]:ye},s.setFilters(l.activeFilters.value);const mt=((Ue=s.selectedClip.value)==null?void 0:Ue.id)??((Le=s.timelineClips.value[0])==null?void 0:Le.id);mt&&he(mt),T();return}const Ne=l.previewFilter.value;Ne&&Ne.filterId===Y&&(Ne.params={...Ne.params??{},[Q]:ye})},le=Y=>{Y&&typeof Y.id=="string"&&Y.id!==""&&l.previewFilterEffect(Y.id)},de=Y=>{l.updateFilterParams(Y),s.setFilters(l.activeFilters.value),T()},Ve=async Y=>{if(!j.value)return;const Q=await j.value.addTextOverlay(Y);ne.value.push({id:Q,...Y})},Be=async(Y,Q)=>{if(!j.value)return;await j.value.updateTextOverlay(Y,Q);const ye=ne.value.findIndex(Ee=>Ee.id===Y);ye!==-1&&(ne.value[ye]={...ne.value[ye],...Q})},dt=async Y=>{j.value&&(await j.value.removeTextOverlay(Y),ne.value=ne.value.filter(Q=>Q.id!==Y))},Ke=async Y=>{if(!Z.value||ae.value.length<2)return;const[Q,ye]=ae.value,Ee=await Z.value.applyTransition(Q,ye,Y);N.value.push({id:Ee,...Y,name:Y.type})},bt=Y=>{if(!Z.value)return;const Q=N.value[Y];Q&&(Z.value.removeTransition(Q.id),N.value.splice(Y,1))},et=Y=>{},at=async Y=>{if(!K.value)return;const Q=await K.value.addAudioTrack(Y);L.value.push({id:Q,...Y})},wt=async(Y,Q)=>{if(!K.value)return;const ye=L.value.findIndex(Ee=>Ee.id===Y);ye!==-1&&(L.value[ye]={...L.value[ye],...Q})},Vt=async Y=>{K.value&&(await K.value.removeAudioTrack(Y),L.value=L.value.filter(Q=>Q.id!==Y))},rt=async(Y,Q)=>{if(!K.value)return;await K.value.updateVolume(Y,Q);const ye=L.value.find(Ee=>Ee.id===Y);ye&&(ye.volume=Q)},vt=async(Y,Q)=>{if(!K.value)return;await K.value.muteTrack(Y,Q);const ye=L.value.find(Ee=>Ee.id===Y);ye&&(ye.muted=Q)},ue=Y=>{K.value&&(K.value.setMasterVolume(Y),te.value=Y)},Se=Y=>{var Q;return Y.metadata||(Y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),Y.metadata.fit_mode=V.value,(Q=a.media)!=null&&Q.url&&/^https?:/i.test(a.media.url)?Y.metadata.source_url=a.media.url:delete Y.metadata.source_url,Y},Te=()=>{$.value=Se(s.generateRecipe())};let je=null;const T=()=>{je&&clearTimeout(je),je=setTimeout(()=>{Te(),je=null},200)};e.watch(()=>s.timelineClips.value,T,{deep:!0}),e.watch(()=>s.selectedClip.value,Y=>{if(ge.value||!Y)return;const Q=(Y==null?void 0:Y.filters)??[];l.setActiveFilters(Q)},{immediate:!0}),e.watch(()=>l.activeFilters.value,Y=>{s.setFilters(Y),T()},{deep:!0}),e.watch(()=>ne.value,Y=>{s.setTextOverlays(Y),T()},{deep:!0}),e.watch(()=>L.value,Y=>{const Q=Y.map(ye=>({...ye,source:typeof ye.source=="string"?ye.source:void 0}));s.setAudioTracks(Q),T()},{deep:!0}),e.watch(()=>s.playheadPosition.value,T),Te();const z=e.ref(!0),G=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),ee=e.computed(()=>!!s.selectedClip.value&&s.timelineClips.value.length>1),pe=Y=>{z.value=Y},be=()=>{z.value=!z.value},$e=Y=>{const Q=Y.target;if(!Q)return;const ye=Number(Q.value);Number.isFinite(ye)&&s.setZoomLevel(ye)},Ae=e.ref(!1),Re=e.ref(0),Pe=e.ref(!1),Je=e.ref(null),tt=e.ref(null);let xt=null,Ht=!1;const nt=()=>new vi(a.serverRenderEndpoint??"/api/v1"),Xt=()=>{xt!==null&&(clearInterval(xt),xt=null)},jn=Y=>{Xt();const Q=nt();xt=setInterval(async()=>{if(Ht){Xt();return}try{const ye=await Q.getJob(Y),Ee=Number(ye.progress??0);if(Re.value=Number.isFinite(Ee)?Ee:0,i("server-render-progress",Re.value),ye.status==="completed"||ye.status==="failed"||ye.status==="cancelled")if(Xt(),Ae.value=!1,tt.value=null,ye.status==="completed"){Re.value=100,Pe.value=!0,Je.value=null;const Ne=typeof ye.output_media_id=="string"?ye.output_media_id:void 0,Ue={id:Y};Ne!==void 0&&(Ue.output_media_id=Ne),i("server-render-completed",Ue)}else{const Ne=ye.status==="cancelled"||typeof ye.error_message=="string"&&/cancel/i.test(ye.error_message),Ue=Ne?"Export canceled.":typeof ye.error_message=="string"&&ye.error_message.trim()!==""?ye.error_message:"Export failed";Je.value=Ue,Ne||i("server-render-failed",Ue)}}catch(ye){Xt(),Ae.value=!1,tt.value=null;const Ee=ye instanceof Error?ye.message:"Failed to check export progress";Je.value=Ee,i("server-render-failed",Ee)}},2e3)},pa=Y=>{const Q=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),ye=URL.createObjectURL(Q),Ee=document.createElement("a");Ee.href=ye,Ee.download=`video-recipe-${Date.now()}.json`,Ee.click(),setTimeout(()=>URL.revokeObjectURL(ye),100)},Wn=async Y=>{Xt(),Ht=!1,tt.value=null,Je.value=null,Pe.value=!1,Ae.value=!0,Re.value=0;try{const Q=Se(s.generateRecipe());i("recipe-generated",Q);const ye=!!a.serverRenderEndpoint,Ee=r.value.startsWith("temp-");if(!ye||Ee){pa(Q),Ae.value=!1,Re.value=100,Pe.value=!0,Je.value=Ee?"Local media — downloaded recipe.json. Switch to V1 for PIXI-based client export.":"No server render endpoint configured — downloaded recipe.json.";return}const Ue=await nt().createJob({source_media_id:r.value,recipe:Q}),Le=typeof Ue.id=="string"?Ue.id:null;if(!Le)throw new Error("Export failed: missing job id");tt.value=Le,i("export-started",Le),i("server-render-started",Le),jn(Le)}catch(Q){const ye=Se(s.generateRecipe());pa(ye);const Ee=Q instanceof Error?Q.message:"Export failed";Ae.value=!1,Re.value=0,tt.value=null,Je.value=Ee,i("server-render-failed",Ee)}},Qa=async()=>{Ht=!0;const Y=tt.value;if(Xt(),Ae.value=!1,Re.value=0,Je.value="Export canceled.",tt.value=null,Y&&a.serverRenderEndpoint)try{await nt().cancelJob(Y)}catch{}},fa=()=>{s.togglePlayback()},Zn=()=>{s.resetChanges()},ha=()=>{const Y=s.saveDraft();i("draft-saved",Y)},wn=()=>{Wn()},wi=()=>{i("close")};return n({saveDraft:async()=>{const Y=s.saveDraft();return i("draft-saved",Y),Y},exportForUpload:async Y=>null}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2")}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Xt(),Ht=!0,je&&(clearTimeout(je),je=null),k.value&&(k.value.destroy(),k.value=null),j.value=null,Z.value=null,K.value=null}),(Y,Q)=>(e.openBlock(),e.createBlock(t_,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",p_,[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:fa},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(Gr):e.unref(Jr),"aria-hidden":"true"},null,8,["icon"])],10,f_),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:Zn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),"aria-hidden":"true"},null,8,["icon"])],8,h_)]),Q[11]||(Q[11]=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",v_,[e.createElementVNode("label",g_,[Q[9]||(Q[9]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":Q[0]||(Q[0]=ye=>V.value=ye),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...Q[8]||(Q[8]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,V.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:ha},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xo),"aria-hidden":"true"},null,8,["icon"]),Q[10]||(Q[10]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,y_),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":"Export",disabled:Ae.value,onClick:wn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(aa),"aria-hidden":"true"},null,8,["icon"])],8,b_),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:wi},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn),"aria-hidden":"true"},null,8,["icon"])])])]),canvas:e.withCtx(()=>[e.createElementVNode("div",w_,[e.withDirectives(e.createVNode(fr,{class:"v2-preview-child","aria-hidden":!p.value,source:f.value,"fallback-duration":P.value,filters:_.value,playhead:D.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":V.value,active:p.value,onPlayPause:fa,onFrameUpdate:A,onDurationChange:C},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Mr,{class:"v2-preview-child","aria-hidden":!v.value,"media-uuid":r.value,recipe:$.value,media:B.value,"enable-engine":v.value&&E.value,"fit-mode":V.value,onTimeUpdate:R,onPlayStateChange:W,onDurationChange:C,onEngineReady:ie},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,v.value]])])]),timeline:e.withCtx(()=>{var ye,Ee;return[e.createElementVNode("div",k_,[e.createElementVNode("div",__,[e.createElementVNode("label",E_,[Q[12]||(Q[12]=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:$e},null,40,x_),e.createElementVNode("span",C_,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":z.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":z.value?"true":"false",onClick:be},e.toDisplayString(z.value?"Snap On":"Snap Off"),11,S_)]),e.createVNode(Br,{playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,"selected-clip-id":((ye=e.unref(s).selectedClip.value)==null?void 0:ye.id)??((Ee=e.unref(s).timelineClips.value[0])==null?void 0:Ee.id)??null,duration:P.value,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":z.value,sensitivity:.25,"onUpdate:playhead":Q[1]||(Q[1]=Ne=>e.unref(s).seekTo(Ne)),onTrim:Q[2]||(Q[2]=(Ne,Ue,Le)=>e.unref(s).handleTrim(Ne,Ue,Le)),onSplit:Q[3]||(Q[3]=Ne=>e.unref(s).handleSplit(Ne)),onClipSelect:Q[4]||(Q[4]=Ne=>e.unref(s).handleClipSelect(Ne)),onClipMove:Q[5]||(Q[5]=(Ne,Ue)=>e.unref(s).moveClip(Ne,Ue)),onSnapStateChange:pe},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled"]),e.createVNode(ad,{"selected-clip":e.unref(s).selectedClip.value,"can-split":G.value,"can-delete":ee.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onDuplicate:e.unref(s).duplicateSelectedClip,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:fa,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","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])])]}),inspector:e.withCtx(()=>[e.createVNode(Xl,{"active-tab":c.value,"onUpdate:activeTab":Q[6]||(Q[6]=ye=>c.value=ye),tabs:u.value},{filters:e.withCtx(()=>[e.createVNode(Fr,{filters:O.value,"active-filters":I.value,"thumbnail-url":F.value,onApplyFilter:se,onRemoveFilter:fe,onUpdateParam:xe,onPreviewFilter:le},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Ir,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:de},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",V_,[...Q[13]||(Q[13]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))]),text:e.withCtx(()=>[e.createVNode(Rr,{overlays:ne.value,onAddOverlay:Ve,onUpdateOverlay:Be,onRemoveOverlay:dt},null,8,["overlays"])]),transitions:e.withCtx(()=>[e.createVNode(Dr,{"selected-clips":ae.value,"applied-transitions":N.value,onApplyTransition:Ke,onRemoveTransition:bt,onPreviewTransition:et},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Ar,{"audio-layers":L.value,"master-volume":te.value,onAddTrack:at,onUpdateTrack:wt,onRemoveTrack:Vt,onUpdateVolume:rt,onToggleMute:vt,onUpdateMasterVolume:ue},null,8,["audio-layers","master-volume"])]),export:e.withCtx(()=>[e.createVNode($r,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Ae.value,"export-progress":Re.value,onExport:Wn,onCancelExport:Qa,onSaveDraft:ha,onReset:Zn},null,8,["can-export","is-exporting","export-progress"]),Pe.value?(e.openBlock(),e.createElementBlock("div",N_," Export complete ")):e.createCommentVNode("",!0),Je.value&&!Pe.value?(e.openBlock(),e.createElementBlock("div",T_,e.toDisplayString(Je.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(m_,{"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[e.createVNode(Xl,{"active-tab":c.value,"onUpdate:activeTab":Q[7]||(Q[7]=ye=>c.value=ye),tabs:u.value,compact:""},{filters:e.withCtx(()=>[e.createVNode(Fr,{filters:O.value,"active-filters":I.value,"thumbnail-url":F.value,onApplyFilter:se,onRemoveFilter:fe,onUpdateParam:xe,onPreviewFilter:le},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Ir,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:de},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",M_,[...Q[14]||(Q[14]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))]),text:e.withCtx(()=>[e.createVNode(Rr,{overlays:ne.value,onAddOverlay:Ve,onUpdateOverlay:Be,onRemoveOverlay:dt},null,8,["overlays"])]),transitions:e.withCtx(()=>[e.createVNode(Dr,{"selected-clips":ae.value,"applied-transitions":N.value,onApplyTransition:Ke,onRemoveTransition:bt,onPreviewTransition:et},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Ar,{"audio-layers":L.value,"master-volume":te.value,onAddTrack:at,onUpdateTrack:wt,onRemoveTrack:Vt,onUpdateVolume:rt,onToggleMute:vt,onUpdateMasterVolume:ue},null,8,["audio-layers","master-volume"])]),export:e.withCtx(()=>[e.createVNode($r,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Ae.value,"export-progress":Re.value,onExport:Wn,onCancelExport:Qa,onSaveDraft:ha,onReset:Zn},null,8,["can-export","is-exporting","export-progress"]),Pe.value?(e.openBlock(),e.createElementBlock("div",B_,"Export complete")):e.createCommentVNode("",!0),Je.value&&!Pe.value?(e.openBlock(),e.createElementBlock("div",F_,e.toDisplayString(Je.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),_:1})]),_:1}))}}),$_=Me(I_,[["__scopeId","data-v-be70d186"]]),Wt=o=>o===null||typeof o!="object"||Array.isArray(o)?null:o,Ge=o=>{if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const n=Number(o);return Number.isFinite(n)?n:null}return null},R_=(o,n)=>{if(n===null)return;const t=Wt(o.source)??{},a=Ge(t.duration);if(!(a!==null&&a>0&&a<=1&&n>a))return;t.duration=n,o.source=t;const r=Array.isArray(o.timeline)?o.timeline:[];if(r.length===1){const c=Wt(r[0]);if(c!==null){const d=Ge(c.sourceIn)??0,u=Ge(c.sourceOut)??Ge(c.end)??Ge(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const h=Ge(c.end);h!==null&&h>0&&h<=1&&(c.end=n);const p=Ge(c.timelineEnd);p!==null&&p>0&&p<=1&&(c.timelineEnd=n)}}}const s=Ge(o.trimEnd)??Ge(o.trim_end);s!==null&&s>0&&s<=1&&(o.trimEnd=n);const l=Wt(o.trim);if(l!==null){const c=Ge(l.end);c!==null&&c>0&&c<=1&&(l.end=n,o.trim=l)}},D_=(o,n)=>{if(!o)return!1;const t=Wt(o);if(t===null)return!1;const a=Wt(t.trim),i=Wt(t.source),s=Ge(i==null?void 0:i.duration)??n,l=Array.isArray(o.filters)&&o.filters.length>0;let c=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(c=!0)}let d=!1;const u=Ge(t.trimStart)??Ge(t.trim_start)??Ge(a==null?void 0:a.start),m=Ge(t.trimEnd)??Ge(t.trim_end)??Ge(a==null?void 0:a.end);if(u!==null&&u>0&&(d=!0),m!==null&&s!==void 0&&m<s&&(d=!0),!d&&Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const v=Ge(p.sourceIn),g=Ge(p.sourceOut);v!==null&&v>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let h=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const v=Ge(p.speed);h=v!==null&&v!==1}}return l||c||d||h},Dd=o=>{if(!o)return!1;const n=Wt(o);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(o.timeline)&&o.timeline.length>1)},A_=(o,n={})=>{var h,p;const t=JSON.parse(JSON.stringify(o)),a=Array.isArray(t.timeline)?t.timeline:[],i=a.length>0?Wt(a[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,a.length===1&&i!==null){const v=Ge(i.sourceIn),g=Ge(i.sourceOut);v!==null&&t.trimStart===void 0&&(t.trimStart=v),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const l=Wt(t.trim);if(t.trimStart===void 0){const v=Ge(l==null?void 0:l.start);v!==null&&(t.trimStart=v)}if(t.trimEnd===void 0){const v=Ge(l==null?void 0:l.end);v!==null&&(t.trimEnd=v)}const c=Wt(t.source),d=Ge(t.width)??Ge(c==null?void 0:c.original_width)??Ge((h=n.exportMeta)==null?void 0:h.width);d!==null&&(t.width=d);const u=Ge(t.height)??Ge(c==null?void 0:c.original_height)??Ge((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Wt(t.output);return t.fps=Ge(t.fps)??Ge(m==null?void 0:m.fps)??30,R_(t,n.mediaDuration??null),t},L_={key:0},U_=["data-testid"],O_={class:"ve-mobile-header"},P_=["data-testid"],z_={class:"ve-mobile-title"},j_=["data-testid","disabled"],W_={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},Z_={class:"ve-body"},H_=["data-testid"],X_=["aria-label"],G_={class:"ve-header"},J_={class:"ve-title"},Y_=["data-testid"],q_={class:"ve-body"},K_={class:"ve-footer"},Q_=["data-testid"],eE=["data-testid","disabled"],tE=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>a.dataTestId),s=e.computed(()=>a.open),l=e.computed(()=>a.saveImmediate===!1),c=e.computed(()=>a.closeText),d=e.computed(()=>m.value?a.savingText:a.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),m=e.ref(!1),h=e.ref(!1),p=e.ref(null),v=`temp-${Date.now()}`,g=e.computed(()=>{var k;const F=(k=a.featureFlags)==null?void 0:k.export;return typeof F=="boolean"?F:a.workflowMode==="full"}),w=e.computed(()=>{if(a.editorVersion==="v1"||a.editorVersion==="v2")return a.editorVersion;if(typeof window>"u")return"v2";try{const F=new URLSearchParams(window.location.search),k=F.get("editor")??F.get("video-editor");if(k==="v1")return"v1";if(k==="v2")return"v2"}catch{}return"v2"}),M=e.computed(()=>w.value==="v2"?$_:Rd),V=e.computed(()=>typeof a.mediaUuid=="string"&&a.mediaUuid.trim()!==""?a.mediaUuid.trim():a.media&&a.media.uuid.trim()!==""?a.media.uuid.trim():v),b=e.computed(()=>{const F={showThumbnailPicker:a.showThumbnailPicker,workflowMode:a.workflowMode,clientExportThreshold:a.clientExportThreshold,maxDuration:a.maxDuration,serverRenderEndpoint:a.serverRenderEndpoint};return a.featureFlags!==void 0&&(F.featureFlags=a.featureFlags),a.initialRecipe!==void 0&&(F.initialRecipe=a.initialRecipe),a.media!==void 0&&(F.media=a.media),F}),f=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",f)}),e.onUnmounted(()=>{window.removeEventListener("resize",f)}),e.onErrorCaptured(()=>(h.value=!0,!1));const _=F=>{const k=Array.isArray(F.timeline)?F.timeline:[];if(k.length===0)return 0;let $=0;for(const j of k){const Z=Number(j.sourceIn),K=Number(j.sourceOut),ge=Number(j.speed??1),we=Number.isFinite(ge)&&ge>0?ge:1;if(Number.isFinite(Z)&&Number.isFinite(K)&&K>Z){$+=(K-Z)/we;continue}const ne=Number(j.timelineStart),N=Number(j.timelineEnd);Number.isFinite(ne)&&Number.isFinite(N)&&N>ne&&($+=N-ne)}return $},D=(F,k,$)=>{let j=null;const Z=new Promise((K,ge)=>{j=setTimeout(()=>ge(new Error(`${$} timed out after ${k}ms`)),k)});return Promise.race([F,Z]).finally(()=>{j!==null&&clearTimeout(j)})},B=()=>{var Z;const $=(Z=a.media)==null?void 0:Z.duration;if(typeof $!="number"||!Number.isFinite($)||$<=0)return 12e3;const j=Math.round($*1e3);return Math.min(45e3,Math.max(12e3,j))},E=()=>{i("close"),i("update:open",!1)},S=()=>{m.value=!1,E()},P=F=>{i("recipe-generated",F)},C=F=>{i("export-started",F),i("save-started",F)},A=F=>{i("video-exported",F)},R=F=>{i("thumbnail-selected",F)},W=(F,k,$)=>{i("save-recipe",F);const j={recipe:F,exportPayload:k};$!==void 0&&(j.toastDescription=$),i("save-complete",j),E()},O=F=>{m.value||(i("draft-saved",F),W(F,null))},I=async()=>{var F;if(!m.value){if(h.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),E();return}m.value=!0;try{const k=await D(p.value.saveDraft(),B(),"saveDraft");let $=null,j=!1,Z;const K=_(k),ge=K>0?K:((F=a.media)==null?void 0:F.duration)??0;if(g.value&&ge>0&&ge<=a.clientExportThreshold&&typeof p.value.exportForUpload=="function"){j=!0;const ne=Math.min(9e4,Math.max(15e3,a.clientExportThreshold*2e3));try{$=await D(p.value.exportForUpload(k),ne,"exportForUpload")}catch{$=null}}if(Dd(k)&&$===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}j&&$===null&&(Z="Video edits saved. Final render will happen when you share."),W(k,$,Z)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),E()}finally{m.value=!1}}};return n({saveDraft:I}),(F,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",L_,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",O_,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:S},e.toDisplayString(c.value),9,P_),e.createElementVNode("h2",z_,e.toDisplayString(F.title),1),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-mobile-action ve-mobile-action--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:I},e.toDisplayString(d.value),9,j_)):(e.openBlock(),e.createElementBlock("span",W_))]),e.createElementVNode("section",Z_,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(M.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":V.value,"data-editor-version":w.value},b.value,{onClose:S,onDraftSaved:O,onExportStarted:C,onRecipeGenerated:P,onThumbnailSelected:R,onVideoExported:A}),null,16,["media-uuid","data-editor-version"]))])],8,U_)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(S,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":F.title,"aria-modal":"true"},[e.createElementVNode("header",G_,[e.createElementVNode("h2",J_,e.toDisplayString(F.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:S}," ✕ ",8,Y_)]),e.createElementVNode("section",q_,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(M.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":V.value,"data-editor-version":w.value},b.value,{onClose:S,onDraftSaved:O,onExportStarted:C,onRecipeGenerated:P,onThumbnailSelected:R,onVideoExported:A}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",K_,[e.renderSlot(F.$slots,"footer",{close:S,isSaving:m.value,save:I},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:S},e.toDisplayString(c.value),9,Q_),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:I},e.toDisplayString(d.value),9,eE)):e.createCommentVNode("",!0)],!0)])],8,X_)],8,H_))])):e.createCommentVNode("",!0)]))}}),nE=Me(tE,[["__scopeId","data-v-7fb767d8"]]),aE={class:"video-editor-modal"},oE={class:"video-preview-container"},iE=["src"],rE={class:"video-overlay-controls"},sE=["aria-label"],lE={class:"time-display"},cE={class:"timeline-container"},dE={class:"clip-name"},uE={class:"timeline-time-labels"},mE={class:"tool-tabs"},pE=["onClick"],fE={class:"tool-panel"},hE={key:0,class:"trim-panel"},vE={class:"trim-controls"},gE={key:1,class:"filters-panel"},yE={class:"filter-grid"},bE=["onClick"],wE={key:2,class:"text-panel"},kE={key:3,class:"transitions-panel"},_E={class:"transition-grid"},EE=["onClick"],xE={class:"action-buttons"},CE=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),m=e.ref(0),h=e.ref(null),p=e.ref("trim"),v=e.ref(null),g=e.ref(""),w=[{id:"trim",label:"Trim",icon:yc},{id:"filters",label:"Filters",icon:op},{id:"text",label:"Text",icon:kc},{id:"transitions",label:"Transitions",icon:mp}],M=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],V=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],b=e.ref();e.onMounted(()=>{var k,$;(k=t.media)!=null&&k.url?r.value=t.media.url:($=t.media)!=null&&$.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 f(){i.value&&(c.value=i.value.duration,m.value=c.value)}function _(){i.value&&(l.value=i.value.currentTime)}function D(){s.value=!1}function B(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function E(k){if(!k||isNaN(k))return"00:00";const $=Math.floor(k/60),j=Math.floor(k%60);return`${$.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`}function S(k){if(!i.value||!b.value)return;const $=b.value.getBoundingClientRect(),K=(k.clientX-$.left)/$.width*c.value;i.value.currentTime=Math.max(0,Math.min(K,c.value))}function P(){u.value=l.value}function C(){m.value=l.value}function A(){u.value=0,m.value=c.value}function R(k){h.value=k;const $=Z=>{if(!h.value||!b.value)return;const K=b.value.getBoundingClientRect(),ne=(Z.clientX-K.left)/K.width*c.value;h.value==="start"?u.value=Math.max(0,Math.min(ne,m.value-1)):m.value=Math.max(u.value+1,Math.min(ne,c.value))},j=()=>{h.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",j)}function W(k){if(v.value=k,!i.value)return;const $={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=$[k]||"none"}function O(){}function I(k){}function F(){const k={timeline:[{id:d.value,url:r.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:m.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:m.value-u.value};a("save",k)}return(k,$)=>(e.openBlock(),e.createElementBlock("div",aE,[e.createElementVNode("div",oE,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:f,onTimeupdate:_,onEnded:D,controls:""},null,40,iE),e.createElementVNode("div",rE,[e.createElementVNode("button",{class:"play-pause-btn",onClick:B,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:s.value?e.unref(vp):e.unref(wp)},null,8,["icon"])],8,sE),e.createElementVNode("div",lE,e.toDisplayString(E(l.value))+" / "+e.toDisplayString(E(c.value)),1)])]),e.createElementVNode("div",cE,[e.createElementVNode("div",{class:"timeline-track",onClick:S,ref_key:"timelineTrack",ref:b},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-m.value/c.value*100}%`})},[e.createElementVNode("span",dE,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:$[0]||($[0]=j=>R("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/c.value*100}%`}),onMousedown:$[1]||($[1]=j=>R("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",uE,[e.createElementVNode("span",null,e.toDisplayString(E(0)),1),e.createElementVNode("span",null,e.toDisplayString(E(c.value)),1)])]),e.createElementVNode("div",mE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(w,j=>e.createElementVNode("button",{key:j.id,class:e.normalizeClass(["tool-tab",{active:p.value===j.id}]),onClick:Z=>p.value=j.id},[e.createVNode(e.unref(U.IonIcon),{icon:j.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(j.label),1)],10,pE)),64))]),e.createElementVNode("div",fE,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",hE,[$[7]||($[7]=e.createElementVNode("h3",null,"Trim Video",-1)),$[8]||($[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",vE,[e.createElementVNode("button",{class:"btn-trim",onClick:P},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ll)},null,8,["icon"]),$[4]||($[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:C},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ll)},null,8,["icon"]),$[5]||($[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:A},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"]),$[6]||($[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",gE,[$[9]||($[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",yE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(M,j=>e.createElementVNode("button",{key:j.id,class:e.normalizeClass(["filter-option",{active:v.value===j.id}]),onClick:Z=>W(j.id)},e.toDisplayString(j.name),11,bE)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",wE,[$[10]||($[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[2]||($[2]=j=>g.value=j),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:O},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",kE,[$[11]||($[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",_E,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(V,j=>e.createElementVNode("button",{key:j.id,class:"transition-option",onClick:Z=>(j.id,void 0)},e.toDisplayString(j.name),9,EE)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",xE,[e.createElementVNode("button",{class:"btn-cancel",onClick:$[3]||($[3]=j=>k.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:F},"SAVE")])]))}}),SE=Me(CE,[["__scopeId","data-v-b933f33b"]]),VE={class:"time-label"},NE=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(o){const n=o,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),a=e.computed(()=>{const s=[],l=i(n.duration,n.zoom);for(let c=0;c<=n.duration;c+=l){const d=`${c/n.duration*100}%`,u=r(c),m=c%(l*5)===0;s.push({time:c,position:d,label:u,major:m})}return s});function i(s,l){const c=s/(10*l);return c<=1?1:c<=5?5:c<=10?10:c<=30?30:c<=60?60:Math.ceil(c/60)*60}function r(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",VE,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),TE=Me(NE,[["__scopeId","data-v-0ef9c910"]]),ME=["data-track-index"],BE={class:"track-header"},FE={class:"track-label"},IE={class:"track-controls"},$E=["data-testid","aria-label"],RE=["data-testid","onMousedown","onClick"],DE={class:"clip-content"},AE={class:"clip-name"},LE={key:0,class:"clip-thumbnail"},UE=["src","alt"],OE=["onMousedown","aria-label"],PE=["onMousedown","aria-label"],zE=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(o,{emit:n}){const t=o,a=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 M=w.timelineEnd-w.timelineStart,V=w.timelineStart/t.duration*100,b=M/t.duration*100;return{left:`${V}%`,width:`${b}%`,backgroundColor:u(w)}}function u(w){const M=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],V=parseInt(w.id.replace(/\D/g,""))%M.length;return M[V]}function m(w){return w.label?w.label:w.url?(w.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${w.id.slice(-4)}`}function h(w){i.value=w.id,a("clip-select",w.id)}function p(){r.value=!r.value}function v(w,M){if(l.value)return;s.value=!0;const V=M.clientX,b=w.timelineStart,f=D=>{if(!s.value)return;const B=D.clientX-V,E=parseFloat(c.value.width),S=B/(t.zoom*100)*(t.duration/E),P=Math.max(0,b+S);a("clip-move",w.id,P)},_=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",_)}function g(w,M,V){l.value=M;const b=V.clientX,f=w.sourceIn,_=w.sourceOut,D=E=>{if(!l.value)return;const S=E.clientX-b,P=parseFloat(c.value.width),C=S/(t.zoom*100)*(t.duration/P);if(l.value==="start"){const A=Math.max(0,f+C);a("clip-trim",w.id,A,_)}else{const A=Math.max(f+1,_+C);a("clip-trim",w.id,f,A)}},B=()=>{l.value=null,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",B)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",B)}return(w,M)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":w.trackIndex},[e.createElementVNode("div",BE,[e.createElementVNode("span",FE,"Track "+e.toDisplayString(w.trackIndex+1),1),e.createElementVNode("div",IE,[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:p},[e.createVNode(e.unref(U.IonIcon),{icon:r.value?e.unref(Rp):e.unref(Ip)},null,8,["icon"])],8,$E)):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,V=>(e.openBlock(),e.createElementBlock("div",{key:V.id,class:e.normalizeClass(["timeline-clip",{selected:V.id===i.value}]),style:e.normalizeStyle(d(V)),"data-testid":`clip-${V.id}`,onMousedown:b=>v(V,b),onClick:b=>h(V)},[e.createElementVNode("div",DE,[e.createElementVNode("span",AE,e.toDisplayString(m(V)),1),V.thumbnail?(e.openBlock(),e.createElementBlock("div",LE,[e.createElementVNode("img",{src:V.thumbnail,alt:m(V)},null,8,UE)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(b=>g(V,"start",b),["stop"]),"aria-label":`Trim start of ${m(V)}`},null,40,OE),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(b=>g(V,"end",b),["stop"]),"aria-label":`Trim end of ${m(V)}`},null,40,PE)],46,RE))),128))],4)],8,ME))}}),jE=Me(zE,[["__scopeId","data-v-48e480d2"]]),WE={class:"video-timeline"},ZE={class:"timeline-tracks"},HE=["aria-label","aria-valuenow","aria-valuemax"],XE={class:"timeline-controls"},GE={class:"zoom-level"},JE=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const b=Math.max(0,...t.clips.map(f=>f.track||0));return Array(b+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(b){return t.clips.filter(f=>(f.track||0)===b)}function m(b){const f=Math.floor(b/60),_=Math.floor(b%60);return`${f}:${_.toString().padStart(2,"0")}`}function h(b,f){a("clip-move",b,f)}function p(b,f,_){a("clip-trim",b,f,_)}function v(b){r.value=b}function g(){i.value=Math.min(i.value*1.2,5)}function w(){i.value=Math.max(i.value/1.2,.5)}function M(){s.value=!0;const b=_=>{if(!s.value||!l.value)return;const D=l.value.getBoundingClientRect(),S=Math.max(0,Math.min(_.clientX-D.left,D.width))/D.width*t.duration;a("seek",S)},f=()=>{s.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",f)}function V(b){let f=t.currentTime;switch(b.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}b.preventDefault(),a("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(b,f)=>(e.openBlock(),e.createElementBlock("div",WE,[e.createVNode(TE,{duration:b.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",ZE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(_,D)=>(e.openBlock(),e.createBlock(jE,{key:`track-${D}`,"data-testid":`track-${D}`,clips:u(D),"track-index":D,zoom:i.value,duration:b.duration,onClipMove:h,onClipTrim:p,onClipSelect:v},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:M,"data-testid":"playhead","aria-label":`Playhead at ${m(b.currentTime)}`,role:"slider","aria-valuenow":b.currentTime,"aria-valuemax":b.duration,tabindex:"0",onKeydown:V},null,44,HE),e.createElementVNode("div",XE,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Hr)},null,8,["icon"])]),e.createElementVNode("span",GE,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(Sp)},null,8,["icon"])])])]))}}),YE=Me(JE,[["__scopeId","data-v-001df415"]]),qE={class:"video-filters-panel"},KE={class:"filter-controls"},QE=["for"],ex={class:"filter-slider-group"},tx=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],nx={class:"filter-value"},ax={class:"filter-actions"},ox={key:0,class:"filter-presets"},ix={class:"preset-list"},rx=["data-testid","aria-label","onClick"],sx=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(o,{emit:n}){const t=n,a=[{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(a.reduce((h,p)=>(h[p.type]=p.default,h),{})),r=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(h,p){switch(h){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function l(h){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(h)}function c(h){if(!l(h))return;const p={id:`filter-${h}`,filterId:h,params:{value:i[h]},intensity:1};t("filter-change",p)}function d(){a.forEach(h=>{i[h.type]=h.default,c(h.type)})}function u(){const h=prompt("Enter preset name:");if(!h)return;const p={id:`custom-${Date.now()}`,name:h,values:{...i}};r.value.push(p)}function m(h){Object.entries(h.values).forEach(([p,v])=>{i[p]=v,c(p)})}return(h,p)=>(e.openBlock(),e.createElementBlock("div",qE,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",KE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,QE),e.createElementVNode("div",ex,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":g=>i[v.type]=g,type:"range",min:v.min,max:v.max,step:v.step,class:"filter-slider","data-testid":`filter-${v.type}`,"aria-label":`${v.label} filter`,"aria-valuenow":i[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:g=>c(v.type)},null,40,tx),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",nx,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",ax,[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(Un)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xo)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",ox,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",ix,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,v=>(e.openBlock(),e.createElementBlock("button",{key:v.id,class:"preset-btn","data-testid":`preset-${v.id}`,"aria-label":`Apply ${v.name} preset`,onClick:g=>m(v)},e.toDisplayString(v.name),9,rx))),128))])])):e.createCommentVNode("",!0)]))}}),lx=Me(sx,[["__scopeId","data-v-5ad2ac63"]]),cx={class:"video-text-panel"},dx={class:"text-input-group"},ux={class:"text-options"},mx={class:"option-row"},px={class:"option-row"},fx={class:"option-row"},hx={class:"option-row"},vx={class:"checkbox-label"},gx={class:"option-row"},yx={class:"text-overlay-list"},bx={key:0,class:"empty-state"},wx=["data-testid"],kx={class:"overlay-preview"},_x={class:"overlay-controls"},Ex=["data-testid","aria-label","onClick"],xx=["data-testid","aria-label","onClick"],Cx=["data-testid","aria-label","onClick"],Sx=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(o,{emit:n}){const t=n,a=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),a.value.push(d),t("text-add",d),i.text=""}function s(d){const u=a.value.findIndex(m=>m.id===d);u!==-1&&(a.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};a.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",cx,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",dx,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=m=>i.text=m),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Hr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",ux,[e.createElementVNode("div",mx,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=m=>i.fontFamily=m),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,i.fontFamily]])]),e.createElementVNode("div",px,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=m=>i.fontSize=m),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",fx,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=m=>i.color=m),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",hx,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=m=>i.backgroundColor=m),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",vx,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=m=>i.hasBackground=m),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",gx,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=m=>i.animation=m),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,i.animation]])])]),e.createElementVNode("div",yx,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",bx," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${h}`},[e.createElementVNode("div",kx,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:m.fontFamily,fontSize:`${Math.min(m.fontSize/4,16)}px`,color:m.color})},e.toDisplayString(m.text),5)]),e.createElementVNode("div",_x,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${h}`,"aria-label":`Edit overlay: ${m.text}`,onClick:p=>l(m)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(sp)},null,8,["icon"])],8,Ex),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${h}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:p=>c(m)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(rp)},null,8,["icon"])],8,xx),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${h}`,"aria-label":`Remove overlay: ${m.text}`,onClick:p=>s(m.id)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Tp)},null,8,["icon"])],8,Cx)])],8,wx))),128))])]))}}),Vx=Me(Sx,[["__scopeId","data-v-4d240e1e"]]),Nx={class:"video-tools-panel"},Tx={class:"tool-tabs"},Mx=["data-testid","aria-label","aria-selected","onClick"],Bx={class:"tool-content"},Fx={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},Ix={class:"trim-actions"},$x={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Rx={class:"transition-types"},Dx=["data-testid","aria-label","onClick"],Ax={class:"transition-preview"},Lx=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(o){const n=[{id:"trim",name:"Trim",icon:yc},{id:"filters",name:"Filters",icon:yn},{id:"text",name:"Text",icon:kc},{id:"transitions",name:"Transitions",icon:ul}],t=[{id:"fade",name:"Fade",icon:Yi},{id:"slide-left",name:"Slide Left",icon:Qm},{id:"slide-right",name:"Slide Right",icon:ep},{id:"dissolve",name:"Dissolve",icon:Yi},{id:"wipe",name:"Wipe",icon:ul},{id:"zoom",name:"Zoom",icon:Yi}];return(a,i)=>(e.openBlock(),e.createElementBlock("div",Nx,[e.createElementVNode("div",Tx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:a.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":a.activeTool===r.id,role:"tab",onClick:s=>a.$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,Mx)),64))]),e.createElementVNode("div",Bx,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",Fx,[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",Ix,[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=>a.$emit("trim-set-start"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cl)},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=>a.$emit("trim-set-end"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cl)},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=>a.$emit("trim-clear"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(lx,{key:1,onFilterChange:i[3]||(i[3]=r=>a.$emit("filter-change",r))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(Vx,{key:2,onTextAdd:i[4]||(i[4]=r=>a.$emit("text-add",r))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",$x,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Rx,[(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=>a.$emit("transition-add",r.id)},[e.createElementVNode("div",Ax,[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,Dx)),64))])])):e.createCommentVNode("",!0)])]))}}),Ux=Me(Lx,[["__scopeId","data-v-fc135306"]]),Ox={class:"video-export-panel"},Px={class:"export-presets"},zx=["value"],jx={key:0,class:"preset-details"},Wx={class:"detail-row"},Zx={class:"detail-row"},Hx={class:"detail-row"},Xx={class:"advanced-options"},Gx={class:"options-content"},Jx={class:"option-group"},Yx={class:"option-group"},qx={class:"option-group"},Kx=["disabled"],Qx={key:1,class:"export-progress"},eC={class:"progress-message"},tC={class:"progress-bar"},nC=["aria-valuenow"],aC={class:"progress-percentage"},oC=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(o,{emit:n}){const t=o,a=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&&a("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",Ox,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",Px,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=m=>i.value=m),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,m=>(e.openBlock(),e.createElementBlock("option",{key:m.id,value:m.id},e.toDisplayString(m.name),9,zx))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",jx,[e.createElementVNode("div",Wx,[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",Zx,[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",Hx,[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",Xx,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",Gx,[e.createElementVNode("div",Jx,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=m=>r.quality=m),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,r.quality]])]),e.createElementVNode("div",Yx,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=m=>r.bitrate=m),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",qx,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=m=>r.includeAudio=m),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:d.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:c},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(aa)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,Kx),d.isExporting?(e.openBlock(),e.createElementBlock("div",Qx,[e.createElementVNode("div",eC,e.toDisplayString(l.value),1),e.createElementVNode("div",tC,[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,nC)]),e.createElementVNode("div",aC,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),iC=Me(oC,[["__scopeId","data-v-5caf8fe6"]]),rC=["data-testid"],sC={class:"progress-header"},lC={class:"file-info"},cC={class:"file-details"},dC={class:"file-name"},uC={class:"file-meta"},mC={class:"file-size"},pC={key:0,class:"separator"},fC={key:1,class:"upload-speed"},hC={key:2,class:"separator"},vC={key:3,class:"time-remaining"},gC={class:"progress-actions"},yC={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},bC={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},wC={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},kC=["aria-valuenow","aria-label"],_C={class:"progress-bar"},EC={class:"progress-percent"},xC={key:1,class:"error-message","data-testid":"video-upload-error"},CC={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},SC=["src","alt"],VC={key:0,class:"video-duration"},NC=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(o){const n=o,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"})),a=e.computed(()=>_c),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const h=n.upload.timeRemaining;if(h<60)return`${Math.round(h)}s`;const p=Math.floor(h/60);return p<60?`${p}m ${Math.round(h%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),l=e.computed(()=>{var h;return n.upload.status==="completed"&&((h=n.upload.media)!=null&&h.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var h;return(h=n.upload.media)==null?void 0:h.duration});function d(h){if(h===0)return"0 B";const p=["B","KB","MB","GB","TB"],v=1024,g=Math.floor(Math.log(h)/Math.log(v));return`${(h/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function u(h){if(h===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],v=1024,g=Math.floor(Math.log(h)/Math.log(v));return`${(h/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function m(h){const p=Math.floor(h/3600),v=Math.floor(h%3600/60),g=Math.floor(h%60);return p>0?`${p}:${v.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${v}:${g.toString().padStart(2,"0")}`}return(h,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${h.upload.id}`},[e.createElementVNode("div",sC,[e.createElementVNode("div",lC,[e.createVNode(e.unref(U.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",cC,[e.createElementVNode("h4",dC,e.toDisplayString(h.upload.filename),1),e.createElementVNode("p",uC,[e.createElementVNode("span",mC,e.toDisplayString(d(h.upload.bytesTotal||0)),1),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",pC,"•")):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",fC,e.toDisplayString(u(h.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",hC,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",vC,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",gC,[h.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",yC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(vc)},null,8,["icon"])])):h.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",bC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Km),"aria-hidden":"true"},null,8,["icon"])])):h.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",wC,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=v=>h.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=v=>h.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=v=>h.$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(Rn),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":h.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",_C,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:h.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",EC,e.toDisplayString(Math.round(r.value))+"%",1)],8,kC)):e.createCommentVNode("",!0),h.upload.error?(e.openBlock(),e.createElementBlock("div",xC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Dp)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(h.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",CC,[e.createElementVNode("img",{src:l.value,alt:h.upload.filename},null,8,SC),c.value?(e.openBlock(),e.createElementBlock("div",VC,e.toDisplayString(m(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,rC))}}),TC=Me(NC,[["__scopeId","data-v-9eacbf91"]]),sr=4,MC=500,BC=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function gi(o){return typeof o=="object"&&o!==null}function Gl(o){return gi(o)?typeof o.upload_url=="string"&&typeof o.upload_id=="string"&&typeof o.media_uuid=="string"&&typeof o.expires_at=="string":!1}function FC(o){if(Gl(o))return o;if(gi(o)&&Gl(o.data))return o.data;throw new Error("Invalid upload response from backend")}function Jl(o){return gi(o)?typeof o.uuid=="string"&&typeof o.processing_status=="string":!1}function IC(o){if(Jl(o))return o;if(gi(o)&&Jl(o.data))return o.data;throw new Error("Invalid media response from backend")}function vo(o){return o?{...o}:{}}function Yl(o,n="PUT"){return typeof o.method=="string"&&o.method.trim()!==""?o.method.trim().toUpperCase():n}function $C(o){return o.resumable===!0?!0:/tusupload/i.test(o.upload_url)}function RC(o){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(o)))}catch{return btoa(o)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function DC(o,n){return[["filename",o.filename],["filetype",o.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([a,i])=>`${a} ${RC(i)}`).join(",")}function go(o,n){const t=Math.max(o.bytesTotal,1);o.bytesUploaded=n,o.progress=Math.min(100,n/t*100);const a=Math.max((Date.now()-o.startedAt.getTime())/1e3,.001);o.uploadSpeed=n/a;const i=Math.max(t-n,0);o.timeRemaining=i/Math.max(o.uploadSpeed,1)}function AC(o,n){return o instanceof Error?o:new Error(n)}function LC(o){if(!(o instanceof Error))return!1;const n=o.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function ql(o){const n=Math.max(0,o-1),t=MC*Math.pow(2,n);return Math.min(5e3,t)}function Kl(o){return new Promise(n=>{window.setTimeout(n,o)})}async function Ql(o,n){for(let t=1;t<=sr;t+=1)try{const a=await n();if(a.ok||!BC.has(a.status)||t>=sr)return a;await Kl(ql(t))}catch(a){if(!LC(a)||t>=sr)throw a;await Kl(ql(t))}throw new Error(`${o} failed after retry attempts`)}function UC(o={}){const n=e.ref(new Map),t=e.ref(new Set),a=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 C=Array.from(n.value.values());return C.length===0?0:C.reduce((R,W)=>R+W.progress,0)/C.length});function d(C){a.value=C}function u(){}async function m(C){var R;const A=C.filter(W=>h(W));if(A.length!==0&&((R=o.onFilesSelected)==null||R.call(o,A),o.autoUpload!==!1))for(const W of A)await p(W)}function h(C){return!(o.maxFileSize&&C.size>o.maxFileSize||o.allowedFormats&&o.allowedFormats.length>0&&!o.allowedFormats.includes(C.type))}async function p(C){var W,O,I;const A=P(C);if(n.value.has(A)){const F=n.value.get(A);if((F==null?void 0:F.status)==="uploading")return}const R={id:A,file:C,filename:C.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:C.size,bytesUploaded:0};n.value.set(R.id,R),t.value.add(R.id);try{R.status="uploading",(W=o.onUploadStart)==null||W.call(o,R);const F=await v(C);o.resumable===!0||F.resumable===!0?await w(R,F):await g(R,F),R.status="processing",R.progress=100;const $=await _(F.media_uuid);R.status="completed",R.media=$,(O=o.onUploadComplete)==null||O.call(o,$)}catch(F){if(R.status!=="cancelled"){const k=AC(F,"Upload failed");R.status="error",R.error=k.message,(I=o.onUploadError)==null||I.call(o,k,R)}}finally{t.value.delete(R.id),i.delete(R.id),r.delete(R.id)}}async function v(C){if(!a.value)throw new Error("API client not configured");const A={collection:o.collection||"videos",filename:C.name,size:C.size,mime_type:C.type,...o.ownerUuid!==void 0?{ownerUuid:o.ownerUuid}:{},...o.ownerType!==void 0?{ownerType:o.ownerType}:{}},R=await a.value.post("/api/v1/video/upload",A);return FC(R)}async function g(C,A){const R=new XMLHttpRequest,W=Yl(A),O=vo(A.headers);return new Promise((I,F)=>{R.upload.addEventListener("progress",k=>{var $;k.lengthComputable&&(go(C,k.loaded),($=o.onUploadProgress)==null||$.call(o,C))}),R.addEventListener("load",()=>{i.delete(C.id),R.status>=200&&R.status<300?I():F(new Error(`Upload failed with status ${R.status}`))}),R.addEventListener("error",()=>{i.delete(C.id),F(new Error("Upload failed"))}),R.addEventListener("abort",()=>{i.delete(C.id),F(new Error("Upload cancelled"))}),R.open(W,A.upload_url),Object.entries(O).forEach(([k,$])=>{R.setRequestHeader(k,$)}),!Object.keys(O).some(k=>k.toLowerCase()==="content-type")&&C.file.type&&R.setRequestHeader("Content-Type",C.file.type),i.set(C.id,R),R.send(C.file)})}async function w(C,A){var F;if($C(A)){await M(C,A);return}const R=o.chunkSize||5*1024*1024,W=V(C.file,R),O=new AbortController;r.set(C.id,O);const I=await f(A.upload_id);I&&(W.forEach(k=>{k.end<=I.bytesUploaded&&(k.uploaded=!0)}),go(C,I.bytesUploaded));for(const k of W)k.uploaded||(await b(C,A,k,O),go(C,k.end),(F=o.onUploadProgress)==null||F.call(o,C))}async function M(C,A){var j;const R=new AbortController;r.set(C.id,R);const W={...vo(A.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(C.file.size),"Upload-Metadata":DC(C,A)},O=await Ql("Resumable upload initialization",()=>fetch(A.upload_url,{method:"POST",headers:W,signal:R.signal}));if(!O.ok)throw new Error(`Failed to initialize resumable upload: ${O.status}`);const I=O.headers.get("Location");if(!I)throw new Error("Resumable upload endpoint did not return upload location");const F=new URL(I,A.upload_url).toString(),k=o.chunkSize||5*1024*1024;let $=0;for(;$<C.file.size;){const Z=Math.min($+k,C.file.size),K=C.file.slice($,Z),ge={...vo(A.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String($),"Content-Type":"application/offset+octet-stream"},we=await Ql("Resumable chunk upload",()=>fetch(F,{method:"PATCH",headers:ge,body:K,signal:R.signal}));if(we.status===409){const N=Number(we.headers.get("Upload-Offset")??"-1");if(Number.isFinite(N)&&N>=0){$=N;continue}}if(!we.ok)throw new Error(`Resumable chunk upload failed: ${we.status}`);const ne=Number(we.headers.get("Upload-Offset")??String(Z));$=Number.isFinite(ne)&&ne>$?ne:Z,go(C,$),(j=o.onUploadProgress)==null||j.call(o,C)}}function V(C,A){const R=[];let W=0,O=0;for(;W<C.size;){const I=Math.min(W+A,C.size);R.push({start:W,end:I,blob:C.slice(W,I),index:O,uploaded:!1}),W=I,O++}return R}async function b(C,A,R,W){const O={...vo(A.headers),"Content-Range":`bytes ${R.start}-${R.end-1}/${C.file.size}`,"Content-Type":C.file.type||"application/octet-stream"},I=await fetch(A.upload_url,{method:Yl(A),headers:O,body:R.blob,signal:W.signal});if(!I.ok)throw new Error(`Chunk upload failed: ${I.status}`);R.uploaded=!0}async function f(C){return null}async function _(C){if(!a.value)throw new Error("API client not configured");const A=60;let R=0;for(;R<A;){const W=await a.value.get(`/api/v1/video/${C}`),O=IC(W),I=String(O.processing_status);if(I==="ready")return O;if(I==="failed"||I==="error")throw new Error("Video processing failed");await new Promise(F=>{window.setTimeout(F,5e3)}),R++}throw new Error("Video processing timeout")}function D(C){const A=n.value.get(C);if(!A)return;const R=i.get(C);R&&(R.abort(),i.delete(C));const W=r.get(C);W&&(W.abort(),r.delete(C)),A.status="cancelled",A.error="Upload cancelled",t.value.delete(C)}async function B(C){const A=n.value.get(C);A&&(A.status="pending",A.error="",A.progress=0,A.bytesUploaded=0,await p(A.file))}function E(C){n.value.delete(C),t.value.delete(C),i.delete(C),r.delete(C)}function S(){Array.from(n.value.entries()).forEach(([C,A])=>{A.status==="completed"&&n.value.delete(C)})}function P(C){return`${C.name}-${C.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:m,validateFile:h,startUpload:p,cancelUpload:D,retryUpload:B,removeUpload:E,clearCompleted:S,setApiClient:d}}const OC=["accept","multiple"],PC={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},zC=["onKeydown"],jC={key:1,class:"upload-list","data-testid":"video-upload-list"},WC={class:"drag-content"},ZC=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(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:h}=UC({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:f=>a("upload-start",f),onUploadProgress:f=>a("upload-progress",f),onUploadComplete:f=>a("upload-complete",f),onUploadError:(f,_)=>a("upload-error",f,_),onFilesSelected:f=>a("files-selected",f)});t.apiClient&&h(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function w(f){const _=f.target,D=Array.from(_.files||[]);D.length>0&&(c(D),_.value="")}function M(f){var B;f.preventDefault(),r.value=!1;const D=Array.from(((B=f.dataTransfer)==null?void 0:B.files)||[]).filter(E=>E.type.startsWith("video/"));D.length>0&&c(D)}function V(f){var _;f.preventDefault(),(_=f.dataTransfer)!=null&&_.types.includes("Files")&&(r.value=!0)}function b(f){f.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",V),document.addEventListener("dragleave",b),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",V),document.removeEventListener("dragleave",b),document.removeEventListener("drop",f=>f.preventDefault())}),(f,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(l)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:f.multiple,onChange:w,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,OC),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",PC,[e.renderSlot(f.$slots,"trigger",{open:g},()=>[e.createElementVNode("div",{class:"default-upload-area","data-testid":"video-uploader-area",role:"button",tabindex:"0","aria-label":"Click to select video for upload",onClick:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(_c),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(f.label),1),e.createElementVNode("p",null,e.toDisplayString(f.description),1),e.createVNode(e.unref(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(Hr),slot:"start","aria-hidden":"true"},null,8,["icon"]),_[2]||(_[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,zC)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",jC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),D=>(e.openBlock(),e.createBlock(TC,{key:D.id,upload:D,onCancel:B=>e.unref(d)(D.id),onRetry:B=>e.unref(u)(D.id),onRemove:B=>e.unref(m)(D.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:M,onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:_[1]||(_[1]=D=>r.value=!1)},[e.createElementVNode("div",WC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(aa),"aria-hidden":"true"},null,8,["icon"]),_[3]||(_[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),HC=Me(ZC,[["__scopeId","data-v-ea7587f7"]]),XC=["aria-valuenow","aria-valuemax","aria-label"],GC={class:"progress-bar"},JC={class:"time-display","data-testid":"video-time-display"},YC={class:"current-time"},qC={class:"duration"},KC={class:"control-buttons"},QC={class:"controls-left"},eS=["aria-label"],tS={class:"controls-center"},nS={key:0,class:"volume-controls"},aS=["aria-label"],oS=["value"],iS={class:"controls-right"},rS={key:0,class:"quality-selector"},sS=["aria-expanded"],lS={class:"quality-label"},cS={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},dS=["data-testid","aria-label","onClick"],uS=["aria-label"],mS=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(o,{emit:n}){const t=o,a=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}%`})),m=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let f=0;f<t.buffered.length;f++){const _=t.buffered.start(f),D=t.buffered.end(f);if(t.currentTime>=_&&t.currentTime<=D)return{width:`${D/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),h=e.computed(()=>t.muted||t.volume===0?$p:t.volume<33?Bp:t.volume<66?Fp:Mp);let p=null;function v(){i.value=!0,g()}function g(){p&&clearTimeout(p),t.playing&&!l&&(p=setTimeout(()=>{i.value=!1},3e3))}function w(f){if(!s.value||t.isLive)return;const _=s.value.getBoundingClientRect(),B=(f.clientX-_.left)/_.width*t.duration;a("seek",Math.max(0,Math.min(B,t.duration)))}function M(f){const _=f.target;a("setVolume",parseInt(_.value))}function V(f){a("selectQuality",f),r.value=!1}function b(f){if(!isFinite(f))return"0:00";const _=Math.floor(f/3600),D=Math.floor(f%3600/60),B=Math.floor(f%60);return _>0?`${_}:${D.toString().padStart(2,"0")}:${B.toString().padStart(2,"0")}`:`${D}:${B.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),p&&clearTimeout(p)}),(f,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":i.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(f.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(f.duration),"aria-label":f.isLive?"Live stream":"Video progress",tabindex:"0",onClick:w},[e.createElementVNode("div",GC,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(m.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",JC,[e.createElementVNode("span",YC,e.toDisplayString(b(f.currentTime)),1),_[7]||(_[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",qC,e.toDisplayString(f.isLive?"LIVE":b(f.duration)),1)])],8,XC),e.createElementVNode("div",KC,[e.createElementVNode("div",QC,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:_[0]||(_[0]=D=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:f.playing?e.unref(hp):e.unref(gp),"aria-hidden":"true"},null,8,["icon"])],8,eS),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:_[1]||(_[1]=D=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(yp),"aria-hidden":"true"},null,8,["icon"]),_[8]||(_[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:_[2]||(_[2]=D=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(kp),"aria-hidden":"true"},null,8,["icon"]),_[9]||(_[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",tS,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",nS,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:_[3]||(_[3]=D=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(U.IonIcon),{icon:h.value,"aria-hidden":"true"},null,8,["icon"])],8,aS),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:f.muted?0:f.volume,onInput:M,"aria-label":"Volume"},null,40,oS)]))]),e.createElementVNode("div",iS,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",rS,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:_[4]||(_[4]=D=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Vp),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",lS,e.toDisplayString(f.currentQuality),1)],8,sS),r.value?(e.openBlock(),e.createElementBlock("div",cS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,D=>(e.openBlock(),e.createElementBlock("button",{key:D.label,class:e.normalizeClass(["quality-option",{active:D.label===f.currentQuality}]),"data-testid":`btn-video-quality-${D.label}`,"aria-label":`Set quality to ${D.label}`,role:"menuitem",onClick:B=>V(D)},e.toDisplayString(D.label),11,dS))),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:_[5]||(_[5]=D=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Np),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:_[6]||(_[6]=D=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(U.IonIcon),{icon:f.fullscreen?e.unref(ip):e.unref(lp),"aria-hidden":"true"},null,8,["icon"])],8,uS)])])],2))}}),pS=Me(mS,[["__scopeId","data-v-2ae77c13"]]);function fS(o={}){var K,ge,we;const n=e.ref(),t=e.ref(),a=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(o.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),h=e.ref(null),p=e.ref("idle"),v=e.ref(o.playbackUrl||((K=o.media)==null?void 0:K.playback_url)||((ge=o.media)==null?void 0:ge.url)||""),g=e.ref(null),w=e.ref(o.isLive||!1),M=e.ref(null),V=e.ref(null);function b(ne){V.value=ne}if((we=o.media)!=null&&we.token_expires_at){const ne=new Date(o.media.token_expires_at);g.value=Number.isNaN(ne.getTime())?null:ne}async function f(){var N;const ne=w.value?t.value:n.value;if(ne)try{await ne.play(),a.value=!0,p.value=w.value?"live":"playing",(N=o.onPlay)==null||N.call(o)}catch{h.value="Failed to play video",p.value="error"}}function _(){var N;const ne=w.value?t.value:n.value;ne&&(ne.pause(),a.value=!1,p.value="paused",(N=o.onPause)==null||N.call(o))}function D(){a.value?_():f()}function B(ne){const N=w.value?t.value:n.value;if(!N||w.value)return;const L=Number.isFinite(N.duration)?N.duration:ne;N.currentTime=Math.max(0,Math.min(ne,L)),i.value=N.currentTime}function E(ne=10){const N=n.value;!N||w.value||B(N.currentTime+ne)}function S(ne=10){const N=n.value;!N||w.value||B(N.currentTime-ne)}function P(){const ne=w.value?t.value:n.value;ne&&(ne.muted=!ne.muted,l.value=ne.muted)}function C(ne){const N=w.value?t.value:n.value;if(!N)return;const L=Math.max(0,Math.min(100,ne));N.volume=L/100,s.value=L,L>0&&N.muted&&(N.muted=!1,l.value=!1)}function A(ne){const N=n.value;!N||w.value||(N.playbackRate=ne,u.value=ne)}async function R(){const ne=document.querySelector(".video-player-container");if(ne)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ne.requestFullscreen(),c.value=!0)}catch{}}async function W(){const ne=w.value?t.value:n.value;if(ne)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ne.requestPictureInPicture()}catch{}}async function O(){var N;h.value=null,p.value="loading",(N=o.media)!=null&&N.provider&&o.media.provider!=="local"&&await I();const ne=w.value?t.value:n.value;ne&&(ne.load(),await f())}async function I(){if(!(!V.value||!o.media))try{m.value=!0;const ne=await V.value.get(`/api/v1/video/${o.media.uuid}/playback`);v.value=ne.playback_url,g.value=new Date(ne.token_expires_at);const N=w.value?t.value:n.value;if(N&&N.src!==v.value){const L=!N.paused,te=N.currentTime;N.src=v.value,w.value||(N.currentTime=te),L&&await f()}}catch{h.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function F(ne){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ne;return}try{t.value.src=ne}catch{h.value="Live streaming not supported in this browser",p.value="error"}}}function k(){M.value&&(M.value.destroy(),M.value=null)}function $(){var N;const ne=w.value?t.value:n.value;ne&&(i.value=ne.currentTime,r.value=ne.duration,(N=o.onTimeUpdate)==null||N.call(o,ne.currentTime))}const j=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ne=0;ne<d.value.length;ne++){const N=d.value.start(ne),L=d.value.end(ne);if(i.value>=N&&i.value<=L)return L/r.value*100}return 0});function Z(){if(!g.value)return!1;const ne=new Date;return g.value.getTime()-ne.getTime()<5*60*1e3}return e.watch([n,t],([ne,N])=>{const L=w.value?N:ne;L&&(L.addEventListener("timeupdate",$),L.addEventListener("loadedmetadata",()=>{r.value=L.duration,p.value="ready"}),L.addEventListener("progress",()=>{d.value=L.buffered}),L.addEventListener("ended",()=>{var te;a.value=!1,p.value="ended",(te=o.onEnded)==null||te.call(o)}),L.addEventListener("error",te=>{var ae;p.value="error",(ae=o.onError)==null||ae.call(o,"Video playback error")}),L.volume=s.value/100,L.muted=l.value)}),e.onUnmounted(()=>{k();const ne=w.value?t.value:n.value;ne&&ne.removeEventListener("timeupdate",$)}),{videoEl:n,liveVideoEl:t,playing:a,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:j,playbackRate:u,isLoading:m,error:h,status:p,currentPlaybackUrl:v,tokenExpiresAt:g,play:f,pause:_,togglePlayPause:D,seek:B,skipForward:E,skipBackward:S,toggleMute:P,setVolume:C,setPlaybackRate:A,toggleFullscreen:R,togglePiP:W,retry:O,refreshToken:I,setupLiveStream:F,setApiClient:b,shouldRefreshToken:Z}}const hS=["src","poster","controls","autoplay","muted","loop","preload"],vS={key:1,ref:"livePlayerEl",class:"live-player"},gS=["controls","muted"],yS={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},bS={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},wS={key:3,class:"video-error","data-testid":"video-error",role:"alert"},kS={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},_S=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(o,{emit:n}){const t=o,a=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:m,bufferedRanges:h,isLoading:p,error:v,status:g,currentPlaybackUrl:w,tokenExpiresAt:M,play:V,pause:b,seek:f,toggleMute:_,setVolume:D,toggleFullscreen:B,togglePlayPause:E,skipForward:S,skipBackward:P,retry:C,refreshToken:A,setApiClient:R,shouldRefreshToken:W,setupLiveStream:O}=fS({...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 I(){await A()}const F=e.computed(()=>{const ae=["video-player-container"];return t.className&&ae.push(t.className),m.value&&ae.push("fullscreen"),t.isLive&&ae.push("is-live"),s.value&&ae.push("is-playing"),p.value&&ae.push("is-loading"),ae}),k=e.computed(()=>{var ae,ie;if(t.poster)return t.poster;if((ae=t.media)!=null&&ae.poster_url)return t.media.poster_url;if((ie=t.media)!=null&&ie.thumbnail_url)return t.media.thumbnail_url});function $(ae){const ie=ae.target;a("loadedmetadata",{duration:ie.duration,width:ie.videoWidth,height:ie.videoHeight})}function j(ae){const ie=ae.target;l.value=ie.currentTime,a("timeupdate",ie.currentTime)}function Z(){s.value=!0,a("play")}function K(){s.value=!1,a("pause")}function ge(){s.value=!1,a("ended")}function we(ae){const ie=ae.target;let he="Failed to load video";if(ie.error)switch(ie.error.code){case ie.error.MEDIA_ERR_ABORTED:he="Video playback aborted";break;case ie.error.MEDIA_ERR_NETWORK:he="Network error while loading video";break;case ie.error.MEDIA_ERR_DECODE:he="Video decoding error";break;case ie.error.MEDIA_ERR_SRC_NOT_SUPPORTED:he="Video format not supported";break}v.value=he,a("error",he)}function ne(ae){const ie=ae.target;h.value=ie.buffered,a("progress",ie.buffered)}function N(){p.value=!0}function L(){p.value=!1}e.watch(()=>t.apiClient,ae=>{ae&&R(ae)},{immediate:!0}),e.watch(()=>t.playbackUrl,ae=>{typeof ae=="string"&&ae.length>0&&(w.value=ae)},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.token_expires_at},ae=>{if(!ae){M.value=null;return}const ie=new Date(ae);M.value=Number.isNaN(ie.getTime())?null:ie},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.playback_url},async(ae,ie)=>{if(t.playbackUrl||!ae||ae===ie)return;const he=i.value;if(!he||t.isLive){w.value=ae;return}const se=!he.paused,fe=he.currentTime;w.value=ae,await e.nextTick();try{he.currentTime=fe}catch{}se&&await V()},{immediate:!0});let te=null;return e.watch(()=>t.isLive,async ae=>{var he;if(!ae)return;const ie=t.playbackUrl||((he=t.media)==null?void 0:he.playback_url)||"";ie&&await O(ie)},{immediate:!0}),e.onMounted(()=>{var ae;(ae=t.media)!=null&&ae.provider&&t.media.provider!=="local"&&(te=setInterval(()=>{W()&&I()},3e4)),U.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{te&&clearInterval(te)}),(ae,ie)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",F.value]),"data-testid":"video-player"},[ae.isLive?(e.openBlock(),e.createElementBlock("div",vS,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ae.controls&&!ae.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:Z,onPause:K,onError:we,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,gS),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",yS,[...ie[3]||(ie[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:ae.controls&&!ae.showCustomControls,autoplay:ae.autoplay,muted:e.unref(u),loop:ae.loop,preload:ae.preload,onLoadedmetadata:$,onTimeupdate:j,onPlay:Z,onPause:K,onEnded:ge,onError:we,onProgress:ne,onWaiting:N,onCanplay:L,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,hS)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",bS,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",wS,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xr),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(U.IonButton),{size:"small",onClick:e.unref(C),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),slot:"start","aria-hidden":"true"},null,8,["icon"]),ie[4]||(ie[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ae.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(pS,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(h),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ae.isLive,onPlay:e.unref(V),onPause:e.unref(b),onSeek:e.unref(f),onToggleMute:e.unref(_),onSetVolume:e.unref(D),onToggleFullscreen:e.unref(B),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ae.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",kS,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ie[0]||(ie[0]=(...he)=>e.unref(P)&&e.unref(P)(...he))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ie[1]||(ie[1]=(...he)=>e.unref(E)&&e.unref(E)(...he))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ie[2]||(ie[2]=(...he)=>e.unref(S)&&e.unref(S)(...he))},null,32)])):e.createCommentVNode("",!0)],2))}}),Ad=Me(_S,[["__scopeId","data-v-b8db4951"]]),ES=Ho.defineStore("video",()=>{const o=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),a=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(o.value.values())),s=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>s.value.filter(O=>O.status==="live")),c=e.computed(()=>r.value.filter(O=>O.processing_status==="processing"));function d(O){o.value.set(O.uuid,O)}function u(O,I){const F=o.value.get(O);F&&o.value.set(O,{...F,...I})}function m(O){o.value.delete(O)}function h(O){return o.value.get(O)}function p(O){n.value.set(O.id,O)}function v(O,I){const F=n.value.get(O);F&&n.value.set(O,{...F,...I})}function g(O,I){const F=n.value.get(O);F&&n.value.set(O,{...F,status:I.status,viewer_count:I.viewer_count,peak_viewers:I.peak_viewers})}function w(O){n.value.delete(O)}function M(O){return n.value.get(O)}function V(O){return s.value.find(I=>I.media_uuid===O)}function b(O){t.value.set(O.id,O)}function f(O,I){const F=t.value.get(O);F&&t.value.set(O,{...F,...I})}function _(O){t.value.delete(O)}function D(O){return t.value.get(O)}function B(O){return Array.from(t.value.values()).filter(I=>I.media_uuid===O)}function E(O){a.value=O}function S(O){a.value&&(a.value={...a.value,...O})}function P(){a.value=null}function C(O){i.value=O}function A(){o.value.clear(),n.value.clear(),t.value.clear(),a.value=null,i.value=!1}function R(O){o.value.clear(),O.forEach(I=>{o.value.set(I.uuid,I)})}function W(O){n.value.clear(),O.forEach(I=>{n.value.set(I.id,I)})}return{videos:o,liveStreams:n,exportJobs:t,currentEditorState:a,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:m,getVideo:h,setLiveStream:p,updateLiveStream:v,updateLiveStreamStats:g,removeLiveStream:w,getLiveStream:M,getLiveStreamByMedia:V,addExportJob:b,updateExportJob:f,removeExportJob:_,getExportJob:D,getExportJobsByMedia:B,setEditorState:E,updateEditorState:S,clearEditorState:P,setProcessing:C,clearAll:A,loadVideos:R,loadLiveStreams:W}});let Tn=null;function xS(o){Tn=o}const yo={post:async(o,n)=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async o=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`)},delete:async o=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`,{method:"DELETE"})}};function bo(o,n=null){const t=typeof o.id=="string"&&o.id!==""?o.id:typeof o.stream_id=="string"&&o.stream_id!==""?o.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const a={id:t,media_uuid:o.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:o.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:o.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:o.status??(n==null?void 0:n.status)??"idle",viewer_count:o.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:o.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:o.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:o.low_latency??(n==null?void 0:n.low_latency)??!1},i=o.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(a.playback_url=i);const r=o.started_at??(n==null?void 0:n.started_at);r!==void 0&&(a.started_at=r);const s=o.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(a.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(a.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(a.vod_media_uuid=n.vod_media_uuid),a}function lr(o,n){return o instanceof Error&&o.message?o.message:n}function CS(o){const n=ES(),t=e.ref(null),a=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),m=e.ref(0);let h;const p=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var P;if(!((P=t.value)!=null&&P.playback_url))return null;const S=new URL(t.value.playback_url);return S.searchParams.set("live","true"),a.value&&S.searchParams.set("latency","low"),S.toString()}),g=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="live"}),w=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="idle"}),M=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="ended"});async function V(S={}){s.value=!0,c.value=null;try{const P=await yo.post("/live",{title:r.value||S.title||"Live Stream",low_latency:S.low_latency??a.value,auto_record:S.auto_record??i.value,...S}),C=bo(P);return t.value=C,n.setLiveStream(C),D(),C}catch(P){throw c.value=lr(P,"Failed to create stream"),P instanceof Error?P:new Error(c.value)}finally{s.value=!1}}async function b(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const S=await yo.post(`/live/${t.value.id}/end`),P=bo(S,t.value);return t.value=P,n.setLiveStream(P),B(),P}catch(S){throw c.value=lr(S,"Failed to end stream"),S instanceof Error?S:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const S=await yo.get(`/live/${t.value.id}`),P=bo(S,t.value);u.value=P.viewer_count,m.value=P.peak_viewers,t.value=P;const C={status:P.status,viewer_count:P.viewer_count,peak_viewers:P.peak_viewers};P.started_at&&(C.started_at=P.started_at),P.ended_at&&(C.ended_at=P.ended_at),n.updateLiveStreamStats(P.id,C),P.status==="live"&&!d.value&&P.started_at&&(d.value=new Date(P.started_at)),P.status==="ended"&&B()}catch{}}async function _(S){try{const P=await yo.get(`/live/${S}`),C=bo(P,t.value);return{rtmp_url:C.rtmp_url,stream_key:C.stream_key,playback_url:C.playback_url||""}}catch(P){throw c.value=lr(P,"Failed to get stream credentials"),P instanceof Error?P:new Error(c.value)}}function D(S=5e3){B(),h=window.setInterval(()=>{f()},S)}function B(){h!==void 0&&(clearInterval(h),h=void 0)}async function E(){if(!o)return;const S=n.getLiveStreamByMedia(o);S&&(t.value=S,u.value=S.viewer_count,m.value=S.peak_viewers,S.status==="live"&&(D(),S.started_at&&(d.value=new Date(S.started_at))))}return o&&E(),e.onUnmounted(()=>{B()}),{stream:t,lowLatency:a,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:g,isIdle:w,hasEnded:M,createStream:V,endStream:b,refreshStreamStatus:f,getStreamCredentials:_,startStatusPolling:D,stopStatusPolling:B}}const SS={class:"stream-status"},VS={class:"flex items-center justify-between"},NS={class:"flex items-center gap-3"},TS={key:0,class:"flex items-center"},MS={key:2,class:"text-sm text-gray-600"},BS={key:0,class:"flex items-center gap-2"},FS={class:"text-sm font-medium text-gray-700"},IS={key:0,class:"text-xs text-gray-500"},$S=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(o){const n=o,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),a=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",SS,[e.createElementVNode("div",VS,[e.createElementVNode("div",NS,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",TS,[...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(a.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",MS,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",BS,[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",FS,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",IS," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),RS=Me($S,[["__scopeId","data-v-1d09c19f"]]),DS={class:"stream-credentials"},AS={class:"space-y-3"},LS={class:"credential-field"},US={class:"flex gap-2"},OS=["value"],PS={class:"credential-field"},zS={class:"flex gap-2"},jS=["value","type"],WS=["aria-label"],ZS={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},HS={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},XS={key:0,class:"mt-2 text-sm text-green-600"},GS=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(o,{emit:n}){const t=o,a=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,a("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",DS,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",AS,[e.createElementVNode("div",LS,[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",US,[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,OS),e.createElementVNode("button",{onClick:u[0]||(u[0]=m=>c(d.rtmpUrl,"RTMP URL")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy RTMP URL"},[...u[2]||(u[2]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])]),e.createElementVNode("div",PS,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",zS,[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,jS),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",HS,[...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",ZS,[...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,WS),e.createElementVNode("button",{onClick:u[1]||(u[1]=m=>c(d.streamKey,"Stream Key")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy stream key"},[...u[6]||(u[6]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])])]),u[9]||(u[9]=e.createElementVNode("details",{class:"mt-4"},[e.createElementVNode("summary",{class:"cursor-pointer text-sm text-blue-600 hover:text-blue-700"}," How to connect with OBS Studio "),e.createElementVNode("div",{class:"mt-2 p-3 bg-blue-50 rounded-md text-sm text-gray-700"},[e.createElementVNode("ol",{class:"list-decimal list-inside space-y-1"},[e.createElementVNode("li",null,"Open OBS Studio"),e.createElementVNode("li",null,"Go to Settings → Stream"),e.createElementVNode("li",null,'Set Service to "Custom"'),e.createElementVNode("li",null,'Paste the RTMP URL in "Server"'),e.createElementVNode("li",null,'Paste the Stream Key in "Stream Key"'),e.createElementVNode("li",null,'Click OK and then "Start Streaming"')])])],-1)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createElementBlock("div",XS,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),JS=Me(GS,[["__scopeId","data-v-306d92f6"]]),YS={class:"live-stream-manager","data-testid":"live-stream-manager"},qS={key:0,class:"stream-setup"},KS={class:"space-y-4"},QS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},eV={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},tV=["disabled"],nV={key:0},aV={key:1,class:"flex items-center justify-center"},oV={key:1,class:"stream-active space-y-6"},iV={key:1,class:"video-preview"},rV={key:2,class:"analytics-panel"},sV={class:"grid grid-cols-2 gap-4"},lV={class:"bg-gray-50 p-3 rounded"},cV={class:"text-2xl font-bold text-gray-900"},dV={class:"bg-gray-50 p-3 rounded"},uV={class:"text-2xl font-bold text-gray-900"},mV={class:"stream-controls flex gap-3"},pV=["disabled"],fV={key:0},hV={key:1},vV={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},gV={class:"text-red-600 text-sm"},yV=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(o,{emit:n}){const t=o,a=n;t.httpClient&&xS(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:m,endStream:h,streamDuration:p,playbackUrl:v,refreshStreamStatus:g}=CS(t.mediaUuid),w=e.ref(!1);async function M(){var D;try{const B=await m({title:l.value,low_latency:r.value,auto_record:s.value});a("stream-created",B),(D=t.onStreamCreated)==null||D.call(t,B)}catch(B){a("error",B)}}async function V(){var D;try{const B=await h();a("stream-ended",B),(D=t.onStreamEnded)==null||D.call(t,B)}catch(B){a("error",B)}}function b(){i.value=null,l.value="",w.value=!1,u.value=null}async function f(D,B){try{await navigator.clipboard.writeText(D)}catch{}}let _;return e.onMounted(()=>{var D;((D=i.value)==null?void 0:D.status)==="live"&&(_=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{_&&clearInterval(_)}),(D,B)=>(e.openBlock(),e.createElementBlock("div",YS,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",oV,[e.createVNode(RS,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(JS,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:f},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",iV,[B[9]||(B[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Ad,{"playback-url":e.unref(v),"is-live":!0,muted:!0,controls:!1,class:"w-full rounded-lg overflow-hidden"},null,8,["playback-url"])])):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("div",rV,[B[12]||(B[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",sV,[e.createElementVNode("div",lV,[e.createElementVNode("div",cV,e.toDisplayString(e.unref(i).viewer_count),1),B[10]||(B[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",dV,[e.createElementVNode("div",uV,e.toDisplayString(e.unref(i).peak_viewers),1),B[11]||(B[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",mV,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:B[3]||(B[3]=E=>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:V,disabled:e.unref(d),class:"flex-1 py-2 px-4 bg-red-600 text-white font-medium rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors","aria-label":"End live stream"},[e.unref(d)?(e.openBlock(),e.createElementBlock("span",hV,"Ending...")):(e.openBlock(),e.createElementBlock("span",fV,"End Stream"))],8,pV)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:b,class:"flex-1 py-2 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors"}," Start New Stream ")):e.createCommentVNode("",!0)])])):(e.openBlock(),e.createElementBlock("div",qS,[B[8]||(B[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",KS,[e.createElementVNode("div",QS,[B[4]||(B[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":B[0]||(B[0]=E=>e.isRef(r)?r.value=E:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable low latency mode"},null,512),[[e.vModelCheckbox,e.unref(r)]])]),e.createElementVNode("div",eV,[B[5]||(B[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":B[1]||(B[1]=E=>e.isRef(s)?s.value=E:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[B[6]||(B[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":B[2]||(B[2]=E=>e.isRef(l)?l.value=E:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:M,disabled:e.unref(c),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",aV,[...B[7]||(B[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",nV,"Create Stream"))],8,tV)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",vV,[e.createElementVNode("p",gV,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),bV=Me(yV,[["__scopeId","data-v-26291f6f"]]),wV={class:"album-tree-node"},kV=["data-album-id","draggable","aria-selected","aria-expanded"],_V={key:1,class:"album-node__chevron-placeholder"},EV={key:2,"data-testid":"media-count",class:"album-node__count"},xV={key:0,class:"album-tree-node__children",role:"group"},CV=16,SV=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(o,{emit:n}){const t=o,a=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*CV}px`),d=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.dropTargetId)===t.album.id}),m=e.computed(()=>{var b;return(b=t.dragState)!=null&&b.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),h=e.computed(()=>{const b=["album-node"];return r.value&&b.push("album-node--selected"),s.value&&b.push("album-node--focused"),t.compact&&b.push("album-node--compact"),d.value&&b.push("album-node--dragging"),u.value&&b.push("album-node--drop-target"),m.value&&b.push("album-node--invalid-drop"),b});function p(){a("select",t.album)}function v(b){b.stopPropagation(),a("toggle-expand",t.album.id)}function g(b){t.draggable&&(b.dataTransfer&&(b.dataTransfer.setData("text/plain",t.album.id),b.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function w(b){t.draggable&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function M(){a("drag-leave",t.album.id)}function V(b){t.draggable&&(b.preventDefault(),a("drop",t.album.id))}return(b,f)=>{var D;const _=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",wV,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":b.album.id,class:e.normalizeClass(h.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:b.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:g,onDragover:w,onDragleave:M,onDrop:V},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:v},[e.createVNode(e.unref(U.IonIcon),{icon:i.value?e.unref(np):e.unref(ap)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",_V)),e.createVNode(e.unref(U.IonIcon),{icon:e.unref(up),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(b.album.name),1),b.showMediaCount?(e.openBlock(),e.createElementBlock("span",EV,e.toDisplayString(b.album.media_count),1)):e.createCommentVNode("",!0)],46,kV),i.value&&((D=b.album.children)!=null&&D.length)?(e.openBlock(),e.createElementBlock("div",xV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.album.children,B=>(e.openBlock(),e.createBlock(_,{key:B.id,album:B,depth:b.depth+1,"selected-id":b.selectedId,"expanded-ids":b.expandedIds,"focused-id":b.focusedId,draggable:b.draggable,"show-media-count":b.showMediaCount,compact:b.compact,onSelect:f[0]||(f[0]=E=>a("select",E)),onToggleExpand:f[1]||(f[1]=E=>a("toggle-expand",E))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),VV=Me(SV,[["__scopeId","data-v-76be65a6"]]),yi=Ho.defineStore("albums",()=>{const o=e.ref([]),n=e.ref(new Map),t=e.ref(!1),a=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const f=new Map;return o.value.forEach(_=>f.set(_.id,_)),f}),s=e.computed(()=>o.value.filter(f=>f.parent_id===null));async function l(f){t.value=!0,a.value=null;try{const _=(f==null?void 0:f.parent_id)??null,D=_?`/api/v1/albums?parent_id=${_}`:"/api/v1/albums?parent_id=null",B=await fetch(D);if(!B.ok)throw new Error("Failed to fetch albums");((await B.json()).data||[]).forEach(P=>{const C=o.value.findIndex(A=>A.id===P.id);C>=0?o.value[C]=P:o.value.push(P)}),_!==null&&i.value.add(_)}catch(_){a.value=_ instanceof Error?_.message:"Unknown error"}finally{t.value=!1}}async function c(f){t.value=!0,a.value=null;try{const _=await fetch(`/api/v1/albums/${f}`);if(!_.ok)throw new Error("Failed to fetch album");const B=(await _.json()).data,E=o.value.findIndex(S=>S.id===B.id);return E>=0?o.value[E]=B:o.value.push(B),B}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function d(f){t.value=!0,a.value=null;try{const _=await fetch(`/api/v1/albums/${f}/media`);if(!_.ok)throw new Error("Failed to fetch album media");const B=(await _.json()).data||[];return n.value.set(f,B),B}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function u(f,_){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:_})})).ok)throw new Error("Failed to reorder album media");const B=n.value.get(f)||[],E=_.map(S=>B.find(P=>P.uuid===S)).filter(S=>S!==void 0);n.value.set(f,E)}catch(D){throw a.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function m(f){t.value=!0,a.value=null;try{const _=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(f)});if(!_.ok)throw new Error("Failed to create album");const B=(await _.json()).data;return o.value.push(B),B}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function h(f,_){t.value=!0,a.value=null;try{const D=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(_)});if(!D.ok)throw new Error("Failed to update album");const E=(await D.json()).data,S=o.value.findIndex(P=>P.id===E.id);return S>=0&&(o.value[S]=E),E}catch(D){throw a.value=D instanceof Error?D.message:"Unknown error",D}finally{t.value=!1}}async function p(f){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const D=o.value.findIndex(B=>B.id===f);D>=0&&o.value.splice(D,1),n.value.delete(f)}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}function v(f){return o.value.filter(_=>_.parent_id===f)}function g(f){return i.value.has(f)}function w(f){return n.value.get(f)||[]}async function M(f,_){const D=o.value.findIndex(E=>E.id===f);if(D<0)return;const B=o.value[D];o.value[D]={...B,parent_id:_};try{if(!(await fetch(`/api/v1/albums/${f}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:_})})).ok)throw new Error("Failed to move album")}catch(E){throw o.value[D]=B,a.value=E instanceof Error?E.message:"Unknown error",E instanceof Error?E:new Error("Failed to move album")}}function V(f){o.value=f}function b(){o.value=[],n.value.clear(),t.value=!1,a.value=null,i.value.clear()}return{albums:o,albumMedia:n,loading:t,error:a,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:h,deleteAlbum:p,getChildrenOf:v,childrenLoaded:g,getAlbumMedia:w,moveAlbum:M,setAlbums:V,reset:b}});function Ld(){const o=yi(),{albums:n,albumsById:t,rootAlbums:a,loading:i,error:r}=Ho.storeToRefs(o);async function s(u){await o.fetchAlbums(u)}function l(u){return o.getChildrenOf(u)}function c(u){return o.childrenLoaded(u)}async function d(u,m){await o.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:a,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function Ud(o){const{childrenByParentId:n,onMove:t}=o,a=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,h){if(m===h)return!0;const p=new Set,v=[m];for(;v.length>0;){const g=v.shift();if(!g||p.has(g))continue;p.add(g);const w=n.get(g)||[];for(const M of w){if(M===h)return!0;v.push(M)}}return!1}function r(m,h){return m===h?!1:h===null?!0:!i(m,h)}function s(m){a.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function l(){a.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(m){a.value.dropTargetId=m}function d(){a.value.dropTargetId=null,a.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:h}=a.value;if(!m){l();return}if(!r(m,h)){l();return}try{await t(m,h)}finally{l()}}return{dragState:a,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const NV={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},TV={key:1,"data-testid":"error-state",class:"album-tree__error"},MV={key:2,"data-testid":"empty-state",class:"album-tree__empty"},BV={key:3,class:"album-tree__content",role:"group"},FV=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>a.draggable===!0),s=e.computed(()=>a.showMediaCount===!0),l=e.computed(()=>a.compact===!0),{albums:c,rootAlbums:d,loading:u,error:m,fetchAlbums:h,getChildrenOf:p,childrenLoaded:v,moveAlbum:g}=Ld(),w=e.shallowRef(new Set(a.expandedIds)),M=e.ref(a.modelValue??null),V=e.ref(null),b=new Map,f=new Map;function _(N){b.clear(),f.clear();for(const L of N){b.set(L.id,L);const te=L.parent_id??null,ae=f.get(te)??[];ae.push(L.id),f.set(te,ae)}}e.watch(c,N=>{_(N)},{immediate:!0});const{dragState:D,canDropOn:B,startDrag:E,endDrag:S,setDropTarget:P,clearDropTarget:C,executeDrop:A}=Ud({childrenByParentId:f,onMove:async(N,L)=>{await g(N,L),i("album-moved",{albumId:N,newParentId:L})}});e.watch(()=>a.modelValue,N=>{M.value=N??null}),e.watch(()=>a.expandedIds,N=>{w.value=new Set(N)}),e.onMounted(async()=>{await h({parent_id:null})});const R=e.computed(()=>d.value.map(N=>W(N)));function W(N){if(!w.value.has(N.id))return N;const L=p(N.id);return{...N,children:L.map(te=>W(te))}}const O=e.computed(()=>{const N=[];function L(te){var ae;for(const ie of te)N.push(ie),w.value.has(ie.id)&&((ae=ie.children)!=null&&ae.length)&&L(ie.children)}return L(R.value),N});function I(N){var ae;if(!O.value.length)return;const L=V.value?O.value.findIndex(ie=>ie.id===V.value):-1,te=L>=0?O.value[L]:null;switch(N.key){case"ArrowDown":N.preventDefault(),L<O.value.length-1?V.value=O.value[L+1].id:L===-1&&O.value.length>0&&(V.value=O.value[0].id);break;case"ArrowUp":N.preventDefault(),L>0&&(V.value=O.value[L-1].id);break;case"ArrowRight":N.preventDefault(),te&&(te.children_count>0&&!w.value.has(te.id)?F(te.id):w.value.has(te.id)&&((ae=te.children)!=null&&ae.length)&&(V.value=te.children[0].id));break;case"ArrowLeft":N.preventDefault(),te&&(w.value.has(te.id)&&te.children_count>0?F(te.id):te.parent_id&&(V.value=te.parent_id));break;case"Enter":case" ":N.preventDefault(),te&&k(te);break;case"Home":N.preventDefault(),O.value.length>0&&(V.value=O.value[0].id);break;case"End":N.preventDefault(),O.value.length>0&&(V.value=O.value[O.value.length-1].id);break}}async function F(N){w.value.has(N)?(w.value.delete(N),i("album-collapsed",N)):(v(N)||await h({parent_id:N}),w.value.add(N),i("album-expanded",N))}function k(N){M.value=N.id,i("update:modelValue",N.id),i("album-selected",N)}function $(N){a.draggable&&E(N)}function j(N){var te;if(!a.draggable)return;const L=(te=D.value)==null?void 0:te.draggedAlbumId;L&&(P(N),B(L,N))}function Z(){a.draggable&&C()}async function K(N){a.draggable&&(P(N),await A())}function ge(N){a.draggable&&(N.preventDefault(),P(null))}async function we(N){a.draggable&&(N.preventDefault(),P(null),await A())}function ne(){S()}return n({focusedId:V}),(N,L)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:I,onDragover:ge,onDrop:we,onDragend:ne},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",NV,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",TV,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",BV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,te=>(e.openBlock(),e.createBlock(VV,{key:te.id,album:te,depth:0,"selected-id":M.value,"expanded-ids":w.value,"focused-id":V.value,draggable:r.value,"drag-state":r.value?e.unref(D):null,"show-media-count":s.value,compact:l.value,onSelect:k,onToggleExpand:F,onDragStart:$,onDragOver:j,onDragLeave:Z,onDrop:K},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",MV,[L[0]||(L[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(N.$slots,"empty-action",{},void 0,!0)]))],32))}}),Od=Me(FV,[["__scopeId","data-v-ae3dea7a"]]),IV=300,$V=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const c=e.computed(()=>r.value!==null);function d(p){const v=Date.now();if(l.value===p.id&&v-s.value<IV){a("confirm",p);return}s.value=v,l.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&a("confirm",r.value)}function m(){a("close")}function h(){a("close")}return(p,v)=>(e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:h},{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(p.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:m},{default:e.withCtx(()=>[...v[1]||(v[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Od,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(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:m},{default:e.withCtx(()=>[...v[2]||(v[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(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Pd=Me($V,[["__scopeId","data-v-21676ec1"]]),RV={class:"ion-padding-start text-sm"},DV={class:"ion-padding-start text-sm"},AV={key:1},LV={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},UV={class:"flex items-center justify-between gap-3 pb-3"},OV={class:"text-base font-semibold text-gray-900"},PV={class:"ion-padding-start text-sm"},zV={class:"ion-padding-start text-sm"},jV={class:"flex justify-between pt-2"},WV={key:1},_a=255,Ea=1e3,ZV=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(o,{emit:n}){const t=o,a=n,i=yi(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),l=e.computed(()=>r.value?"Save":"Create"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),m=e.ref(!1),h=e.ref(null),p=e.ref(!1),v=e.ref(!1),g=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>_a?`Name must be ${_a} characters or less`:null:"Name is required":null),w=e.computed(()=>d.value.description&&c.value.description.length>Ea?`Description must be ${Ea} characters or less`:null),M=e.computed(()=>{const I=c.value.name.trim().length>0,F=c.value.name.length<=_a,k=c.value.description.length<=Ea;return I&&F&&k&&!p.value}),V=e.computed(()=>{var I;return((I=u.value)==null?void 0:I.name)??"None (Root)"}),b=e.computed(()=>h.value?h.value.children_count===0&&h.value.media_count===0:!1),f=e.computed(()=>h.value?h.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":h.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${h.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await _()});async function _(){if(t.albumId)try{const I=await i.fetchAlbum(t.albumId);h.value=I,c.value={name:I.name,description:I.description??"",parent_id:I.parent_id},I.parent_id&&(u.value={id:I.parent_id,name:"Parent Album"})}catch(I){a("error",I)}}function D(){d.value.name=!0}function B(){d.value.description=!0}function E(){m.value=!0}function S(I){u.value={id:I.id,name:I.name},c.value.parent_id=I.id,m.value=!1}function P(){m.value=!1}function C(){a("close")}function A(){a("close")}async function R(){if(d.value.name=!0,d.value.description=!0,!(!M.value||p.value)){p.value=!0;try{const I={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const F=await i.updateAlbum(t.albumId,I);a("updated",F)}else{const F=await i.createAlbum(I);a("created",F)}a("close")}catch(I){a("error",I)}finally{p.value=!1}}}function W(){b.value&&(v.value=!0)}async function O(I){var k;if((((k=I.detail)==null?void 0:k.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch($){a("error",$)}finally{p.value=!1,v.value=!1}}}return(I,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[I.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(U.IonModal),{key:0,"is-open":I.isOpen,class:"album-manager-modal",onDidDismiss:A},{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:C},{default:e.withCtx(()=>[...F[4]||(F[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(R,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...F[5]||(F[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":F[0]||(F[0]=k=>c.value.name=k),"data-testid":"name-input",maxlength:_a,onIonBlur:D},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",RV,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(()=>[...F[6]||(F[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":F[1]||(F[1]=k=>c.value.description=k),"data-testid":"description-input",maxlength:Ea,onIonBlur:B},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",DV,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...F[7]||(F[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(V.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:!b.value,title:b.value?void 0:f.value,onClick:W},{default:e.withCtx(()=>[...F[8]||(F[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:!M.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",AV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",LV,[e.createElementVNode("div",UV,[e.createElementVNode("h2",OV,e.toDisplayString(s.value),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:C},{default:e.withCtx(()=>[...F[9]||(F[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(R,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...F[10]||(F[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":F[2]||(F[2]=k=>c.value.name=k),"data-testid":"name-input",maxlength:_a,onIonBlur:D},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",PV,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(()=>[...F[11]||(F[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":F[3]||(F[3]=k=>c.value.description=k),"data-testid":"description-input",maxlength:Ea,onIonBlur:B},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",zV,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:E},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...F[12]||(F[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(V.value),1)]),_:1})]),_:1}),e.createElementVNode("div",jV,[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:!b.value,title:b.value?void 0:f.value,onClick:W},{default:e.withCtx(()=>[...F[13]||(F[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:!M.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",WV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Pd,{"is-open":m.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:P,onConfirm:S},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(U.IonAlert),{"is-open":v.value,header:"Delete Album?",message:f.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:O},null,8,["is-open","message"])],64))}}),HV=Me(ZV,[["__scopeId","data-v-22083f3a"]]),XV={class:"album-media-grid"},GV={class:"aspect-square"},JV={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},YV={class:"text-gray-500"},qV=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],KV={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},QV={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},e4={class:"aspect-square relative"},t4=["src","alt"],n4={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},a4=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(o,{emit:n}){const t=o,a=n,i=yi(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),c=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),m=e.computed(()=>!u.value&&r.value.length===0),h=e.computed(()=>{const A=t.columns;return["grid","gap-4",`grid-cols-${A.mobile??2}`,`sm:grid-cols-${A.sm??3}`,`md:grid-cols-${A.md??4}`,`lg:grid-cols-${A.lg??5}`,`xl:grid-cols-${A.xl??6}`]}),p=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await v()}),e.watch(()=>t.albumId,async()=>{await v()});async function v(){s.value=!0;try{const A=await i.fetchAlbumMedia(t.albumId);r.value=A}catch{r.value=[]}finally{s.value=!1}}function g(A){return t.selectedItems.includes(A)}function w(A){a("toggle-select",A);const R=g(A.uuid)?t.selectedItems.filter(W=>W!==A.uuid):[...t.selectedItems,A.uuid];a("selection-change",R)}function M(A){if(A.conversions&&typeof A.conversions=="object"){const R=A.conversions.thumb;if(typeof R=="string")return R}return A.original_url}function V(A){l.value=A}function b(){l.value=null}function f(A){a("preview",A)}function _(A){a("edit",A)}function D(A){a("detach",A.uuid)}function B(){a("add")}function E(A,R){t.reorderable&&(c.value=R,A.dataTransfer&&(A.dataTransfer.effectAllowed="move",A.dataTransfer.setData("text/plain",String(R))))}function S(A,R){!t.reorderable||c.value===null||(A.preventDefault(),d.value=R)}function P(A,R){if(!t.reorderable||c.value===null)return;A.preventDefault();const W=c.value;if(W!==R){const O=[...r.value],[I]=O.splice(W,1);O.splice(R,0,I),r.value=O;const F=O.map(k=>k.uuid);a("reorder",F),i.reorderAlbumMedia(t.albumId,F).catch(()=>{v()})}c.value=null,d.value=null}function C(){c.value=null,d.value=null}return(A,R)=>(e.openBlock(),e.createElementBlock("div",XV,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(h.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,W=>(e.openBlock(),e.createBlock(e.unref(U.IonCard),{key:W,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",GV,[e.createVNode(e.unref(U.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",JV,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",YV,e.toDisplayString(A.emptyText),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"add-media-btn",onClick:B},{default:e.withCtx(()=>[...R[0]||(R[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(h.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(W,O)=>(e.openBlock(),e.createElementBlock("div",{key:W.uuid,"data-media-id":W.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===O,"ring-2 ring-primary":d.value===O&&c.value!==O}]),draggable:A.reorderable,onDragstart:I=>E(I,O),onDragover:I=>S(I,O),onDrop:I=>P(I,O),onDragend:C,onMouseenter:I=>V(W.uuid),onMouseleave:b},[d.value===O&&c.value!==O&&A.reorderable?(e.openBlock(),e.createElementBlock("div",KV)):e.createCommentVNode("",!0),A.reorderable?(e.openBlock(),e.createElementBlock("div",QV,[e.createVNode(e.unref(U.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),A.selectionMode?(e.openBlock(),e.createBlock(e.unref(U.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(W.uuid),class:"absolute top-2 left-2 z-20",onIonChange:I=>w(W)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",e4,[e.createElementVNode("img",{src:M(W),alt:W.file_name,class:"w-full h-full object-cover"},null,8,t4),A.showActions&&l.value===W.uuid?(e.openBlock(),e.createElementBlock("div",n4,[e.createVNode(e.unref(U.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:I=>f(W)},{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:I=>_(W)},{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:I=>D(W)},{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,qV))),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:B},[e.createVNode(e.unref(U.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),R[1]||(R[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),o4=Me(a4,[["__scopeId","data-v-d84b796a"]]),i4={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},r4={class:"media-album-inline-create__field"},s4={class:"media-album-inline-create__field"},l4=["value"],c4={key:1,class:"media-album-inline-create__autocomplete"},d4={class:"media-album-inline-create__autocomplete-input-wrap"},u4={key:0,class:"media-album-inline-create__autocomplete-list"},m4=["onMousedown"],p4={key:1,class:"media-album-inline-create__autocomplete-empty"},f4={class:"media-album-inline-create__actions"},h4=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(o,{emit:n}){const t=o,a=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(M=>M.name.toLowerCase().includes(w))}),u=e.computed(()=>{if(r.value==="")return"";const w=t.albums.find(M=>M.id===r.value);return(w==null?void 0:w.name)??""}),m=w=>{r.value=w.id,s.value=w.name,l.value=!1},h=()=>{r.value="",s.value="",l.value=!1},p=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},v=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},g=()=>{i.value.trim()!==""&&(a("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(w,M)=>w.open?(e.openBlock(),e.createElementBlock("section",i4,[M[7]||(M[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",r4,[e.createElementVNode("span",null,e.toDisplayString(w.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[0]||(M[0]=V=>i.value=V),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",s4,[M[6]||(M[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),c.value?(e.openBlock(),e.createElementBlock("div",c4,[e.createElementVNode("div",d4,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[2]||(M[2]=V=>s.value=V),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:p,onBlur:v},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(h,["prevent"])},[...M[5]||(M[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",u4,[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(h,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,V=>(e.openBlock(),e.createElementBlock("li",{key:V.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":V.id===r.value}]),onMousedown:e.withModifiers(b=>m(V),["prevent"])},e.toDisplayString(V.name),43,m4))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("li",p4," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":M[1]||(M[1]=V=>r.value=V),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[M[4]||(M[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.albums,V=>(e.openBlock(),e.createElementBlock("option",{key:V.id,value:V.id},e.toDisplayString(V.name),9,l4))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",f4,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:M[3]||(M[3]=V=>a("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)}}),zd=Me(h4,[["__scopeId","data-v-a85162fe"]]),v4={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},g4=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(o,{emit:n}){const t=n;return(a,i)=>(e.openBlock(),e.createElementBlock("section",v4,[e.createElementVNode("h3",null,e.toDisplayString(a.title),1),e.createElementVNode("p",null,e.toDisplayString(a.body),1),e.createElementVNode("button",{type:"button",class:"media-album-unavailable-state__button",onClick:i[0]||(i[0]=r=>t("goToLibrary"))},e.toDisplayString(a.actionLabel),1)]))}}),jd=Me(g4,[["__scopeId","data-v-04620e64"]]),y4={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},b4={class:"media-preview-sheet__header"},w4=["src","alt"],k4=["src"],_4={class:"media-preview-sheet__actions"},E4=["disabled"],x4=["disabled"],C4=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(o,{emit:n}){const t=o,a=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&&a("toggleSelect",t.media)};return(l,c)=>l.open&&l.media?(e.openBlock(),e.createElementBlock("section",y4,[e.createElementVNode("header",b4,[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=>a("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,w4)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,k4)),e.createElementVNode("div",_4,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>a("previous"))}," Previous ",8,E4),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=>a("next"))}," Next ",8,x4)])])):e.createCommentVNode("",!0)}}),Wd=Me(C4,[["__scopeId","data-v-9a05f74e"]]),S4={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},V4={class:"media-album-grid__items"},N4={class:"media-album-grid__card-name"},T4={class:"media-album-grid__card-name"},M4=["data-testid","onClick"],B4={class:"media-album-grid__card-name"},F4={key:0,class:"media-album-grid__card-meta"},I4={key:0,class:"media-album-grid__empty"},$4=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(o,{emit:n}){const t=n;return(a,i)=>a.open?(e.openBlock(),e.createElementBlock("section",S4,[e.createElementVNode("div",V4,[a.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",N4,e.toDisplayString(a.createAlbumLabel),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":a.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",T4,e.toDisplayString(a.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(a.albums,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":a.currentView.scope==="album"&&a.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",B4,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",F4,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,M4))),128))]),a.albums.length===0?(e.openBlock(),e.createElementBlock("p",I4," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),Zd=Me($4,[["__scopeId","data-v-129f67b1"]]),R4={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},D4=["accept"],A4={key:0,class:"media-upload-sheet__queue"},L4={class:"media-upload-sheet__queue-info"},U4={class:"media-upload-sheet__queue-status"},O4={class:"media-upload-sheet__progress-bar"},P4=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"}},emits:["close","filesSelected"],setup(o,{emit:n}){const t=n,a=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(),a.value=!0},s=()=>{a.value=!1},l=c=>{var d;c.preventDefault(),a.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",R4,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":a.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,D4)],34),c.queue.length>0?(e.openBlock(),e.createElementBlock("ul",A4,[(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",L4,[e.createElementVNode("strong",null,e.toDisplayString(u.file.name),1),e.createElementVNode("span",U4,e.toDisplayString(u.status),1)]),e.createElementVNode("div",O4,[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)}}),Hd=Me(P4,[["__scopeId","data-v-e238d615"]]),z4=["aria-label","aria-pressed","data-testid"],j4=["src","alt"],W4={key:1,class:"media-thumbnail-cell__video"},Z4={class:"media-thumbnail-cell__video-name"},H4={key:2,class:"media-thumbnail-cell__selected-badge"},X4={key:3,class:"media-thumbnail-cell__status-badge"},G4=["aria-label"],J4=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(o,{emit:n}){const t=o,a=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=()=>{a("toggle",t.media)},d=()=>{a("preview",t.media)};return(u,m)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["media-thumbnail-cell",{"is-selected":u.selected,"has-status":s.value!==null}])},[e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__button","aria-label":l.value,"aria-pressed":u.selected?"true":"false","data-testid":u.testId,onClick:c},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,j4)):(e.openBlock(),e.createElementBlock("div",W4,[m[0]||(m[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",Z4,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",H4," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",X4,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,z4),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,G4)],2))}}),Xd=Me(J4,[["__scopeId","data-v-edd4f0ad"]]),Y4={class:"virtual-media-grid"},q4={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},K4={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},Q4={key:2,class:"virtual-media-grid__items"},e3=["disabled"],t3=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(o,{emit:n}){const t=o,a=n;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",Y4,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",q4," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",K4,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",Q4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(Xd,{key:l.uuid,media:l,selected:((c=i(l.uuid))==null?void 0:c.status)==="ready",status:(d=i(l.uuid))==null?void 0:d.status,"test-id":`${r.testIdPrefix}-${l.uuid}`,onToggle:s[0]||(s[0]=u=>a("toggle",u)),onPreview:s[1]||(s[1]=u=>a("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=>a("loadMore"))},e.toDisplayString(r.loadingMore?"Loading…":"Load more"),9,e3)):e.createCommentVNode("",!0)]))}}),Gd=Me(t3,[["__scopeId","data-v-820b9a4f"]]);function Zo(o){if(o===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(o)/Math.log(n));return parseFloat((o/Math.pow(n,a)).toFixed(2))+" "+t[a]}function Jd(o){var t;const n=o.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function vs(o){return o.type.startsWith("image/")}async function Yd(o){return vs(o)?new Promise(n=>{const t=new Image,a=URL.createObjectURL(o);t.onload=()=>{URL.revokeObjectURL(a),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(a),n(null)},t.src=a}):null}async function qd(o,n){const t=[];if(n.maxFileSize&&o.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Zo(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&o.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Zo(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?o.type.startsWith(i.slice(0,-1)):o.type===i)||t.push({field:"type",message:`File type "${o.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const a=Jd(o.name);n.acceptedExtensions.some(r=>r.toLowerCase()===a.toLowerCase())||t.push({field:"extension",message:`File extension "${a}" is not allowed`,code:"INVALID_EXTENSION"})}if(vs(o)&&(n.maxDimensions||n.minDimensions)){const a=await Yd(o);a&&(n.maxDimensions&&(a.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),a.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(a.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),a.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const a=await n.customValidator(o);t.push(...a)}return{valid:t.length===0,errors:t}}function gs(o={}){const n=e.ref(o.rules||{});function t(c){n.value=c}async function a(c){return qd(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const m=await a(u);d.set(u,m)})),d}function r(c,d){return n.value.maxItems?d+c<=n.value.maxItems:!0}const s=e.computed(()=>{const c=[];return n.value.acceptedMimeTypes&&c.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&c.push(...n.value.acceptedExtensions),c.join(",")});function l(c){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:n,setRules:t,validateFile:a,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function n3(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function a3(o){if(o.type.startsWith("image/"))return URL.createObjectURL(o)}function ys(o){const{adapter:n,maxConcurrent:t=3,rules:a,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d,postUpload:u}=o,m=e.ref(new Map),h=e.ref(new Set),p=a?{rules:a}:{},{validateFile:v}=gs(p);async function g(){if(h.value.size>=t)return;const A=Array.from(m.value.entries()).find(([O,I])=>I.status==="pending"&&!h.value.has(O));if(!A){Array.from(m.value.values()).every(I=>I.status==="completed"||I.status==="error")&&m.value.size>0&&(d==null||d());return}const[R,W]=A;await w(R,W)}async function w(A,R){h.value.add(A),R.status="uploading",R.abortController=new AbortController,m.value.set(A,{...R}),r==null||r(R);try{const W={onProgress:I=>{R.progress=I,m.value.set(A,{...R}),s==null||s(R)},signal:R.abortController.signal};i&&(W.collection=i);const O=await n.upload(R.file,W);u&&(R.status="attaching",m.value.set(A,{...R}),s==null||s(R),await u(R,O.media,n)),R.status="completed",R.progress=100,R.media=O.media,m.value.set(A,{...R}),l==null||l(R,O.media)}catch(W){W.name==="AbortError"?m.value.delete(A):(R.status="error",R.error=W.message,m.value.set(A,{...R}),c==null||c(R,W))}finally{h.value.delete(A),delete R.abortController,g()}}async function M(A){var O;const R=Array.from(A),W=[];for(const I of R){const F=await v(I),k=n3(),$=a3(I),j={id:k,file:I,progress:0,status:F.valid?"pending":"error"};!F.valid&&((O=F.errors[0])!=null&&O.message)&&(j.error=F.errors[0].message),$&&(j.previewUrl=$),m.value.set(k,j);const Z={media:null,clientId:k,name:I.name,order:0,upload:j,errors:F.errors};W.push(Z)}for(let I=0;I<t;I++)g();return W}function V(A){const R=m.value.get(A);R&&(R.abortController&&R.abortController.abort(),R.previewUrl&&URL.revokeObjectURL(R.previewUrl),m.value.delete(A),h.value.delete(A),g())}async function b(A){const R=m.value.get(A);!R||R.status!=="error"||(R.status="pending",R.progress=0,delete R.error,m.value.set(A,{...R}),g())}function f(){for(const[A,R]of m.value.entries())(R.status==="completed"||R.status==="error")&&(R.previewUrl&&URL.revokeObjectURL(R.previewUrl),m.value.delete(A))}function _(){for(const A of m.value.values())A.abortController&&A.abortController.abort(),A.previewUrl&&URL.revokeObjectURL(A.previewUrl);m.value.clear(),h.value.clear()}function D(A){return m.value.get(A)}const B=e.computed(()=>h.value.size>0),E=e.computed(()=>h.value.size),S=e.computed(()=>Array.from(m.value.values()).filter(A=>A.status==="pending").length),P=e.computed(()=>m.value.size===0?!0:Array.from(m.value.values()).every(A=>A.status==="completed"||A.status==="error")),C=e.computed(()=>Array.from(m.value.values()));return{uploads:m,isUploading:B,activeCount:E,pendingCount:S,isComplete:P,addFiles:M,cancelUpload:V,retryUpload:b,clearCompleted:f,clearAll:_,getUpload:D,uploadsArray:C}}function Ln(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function Oa(o){return typeof o=="string"?o:null}function ec(o){return typeof o=="number"?o:null}function o3(o){return typeof o=="boolean"?o:null}function Kd(o){return Ln(o)&&typeof o.uuid=="string"&&typeof o.file_name=="string"&&typeof o.mime_type=="string"&&(typeof o.original_url=="string"||o.original_url===null)&&typeof o.size=="number"&&typeof o.disk=="string"&&typeof o.created_at=="string"&&typeof o.updated_at=="string"}function i3(o){return!Ln(o)||typeof o.id!="string"||typeof o.status!="string"?null:o.status==="ready"?Kd(o.media)?{id:o.id,status:"ready",media:o.media}:null:o.status==="missing"||o.status==="forbidden"?{id:o.id,status:o.status}:null}function r3(o){return Ln(o)?{next_cursor:Oa(o.next_cursor),previous_cursor:Oa(o.previous_cursor),has_more:o3(o.has_more)??!1,per_page:ec(o.per_page),count:ec(o.count)}:null}function tc(o){const n=Ln(o)?o:{},t=Array.isArray(n.data)?n.data.filter(Kd):[],a=Ln(n.meta)?n.meta:{},i=r3(a.pagination),r=(i==null?void 0:i.next_cursor)??Oa(a.next_cursor)??Oa(a.cursor),s=(i==null?void 0:i.has_more)??a.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(i3).filter(d=>d!==null):[],c={cursor:r,has_more:s};return i!==null&&(c.pagination=i),{data:t,meta:c,hydrated:l}}function nc(o,n,t,a,i){const r={view:o.scope==="album"?{scope:"album",album_id:o.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),a!==null&&(r.cursor=a),i&&i.length>0&&(r.hydrate_ids=i),r}function ac(o){const n=new Set,t=[];for(const a of o)n.has(a.uuid)||(n.add(a.uuid),t.push(a));return t}function s3(o){var t;if(!(o instanceof Error))return null;const n=(t=o.response)==null?void 0:t.status;return typeof n=="number"?n:null}function l3(o){var n;return o instanceof Error?((n=o.response)==null?void 0:n.data)??null:null}function c3(o){if(!Ln(o))return[];const n=[];for(const t of Object.values(o)){if(typeof t=="string"&&t.trim()!==""){n.push(t.trim());continue}if(Array.isArray(t))for(const a of t){if(typeof a!="string")continue;const i=a.trim();i!==""&&n.push(i)}}return Array.from(new Set(n))}function d3(o){var r;const n=l3(o),t=Ln(n)?n:null,a=((r=Oa(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=c3(t==null?void 0:t.errors);return a!==null&&i.length>0?a==="Validation failed"?i.join(" "):i.every(l=>a.includes(l))?a:`${a} ${i.join(" ")}`:a!==null?a:i.length>0?i.join(" "):o instanceof Error?o.message:"Failed to load media."}function oc(o,n){const t=d3(n),a=s3(n);return{code:a===403?"permission_denied":o,message:t,retriable:a!==403,cause:n}}function bs(o){const n=o.perPage??40,t=e.ref([]),a=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);let u=null,m=0;const h=async g=>{m+=1;const w=m;u==null||u.abort();const M=new AbortController;u=M,g?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const V=await o.httpClient.get("/v1/media/library",{params:nc(o.view.value,o.filters.value,n,g?i.value:null),signal:M.signal});if(w!==m)return;const b=tc(V);t.value=g?ac([...t.value,...b.data]):b.data,a.value=b.hydrated,i.value=b.meta.cursor,r.value=b.meta.has_more}catch(V){if(M.signal.aborted||w!==m)return;const b=oc(g?"load_more_failed":"query_failed",V);d.value=b,c.value=b.code==="permission_denied",g||(t.value=[],i.value=null,r.value=!1)}finally{w===m&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:a,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:c,error:d,loadInitial:async()=>{i.value=null,await h(!1)},loadMore:async()=>{!r.value||l.value||await h(!0)},refresh:async()=>{i.value=null,await h(!1)},hydrateSelection:async g=>{if(g.length===0)return a.value=[],[];try{const w=await o.httpClient.get("/v1/media/library",{params:nc(o.view.value,o.filters.value,1,null,g)}),M=tc(w);return a.value=M.hydrated,M.hydrated}catch(w){return d.value=oc("hydration_failed",w),[]}},prepend:g=>{t.value=ac([g,...t.value])}}}const u3="mediables.media-library.";function m3(o){return!o||o.key.trim()===""?null:`${u3}${o.key}`}function cr(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function p3(o,n){const t=Date.parse(o);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function Qd(o){const n=m3(o),t=(o==null?void 0:o.ttlMinutes)??30,a=`${(o==null?void 0:o.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(n===null)return null;const l=cr();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"||p3(u.savedAt,t))return l.removeItem(n),null;const m={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(h=>typeof h=="string"&&h.trim()!==""):[]};return((o==null?void 0:o.restoreView)??!0)&&u.view&&(m.view=u.view),u.filters&&(m.filters=u.filters),m},save:l=>{if(n===null)return;const c=cr();if(c===null)return;const d={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((o==null?void 0:o.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=cr();l==null||l.removeItem(n)},sessionId:a}}function eu(o){const n=e.ref(o);return{state:n,transition:a=>{n.value=a}}}function tu(o){return{emitMetric:(t,a)=>{const i={name:t,timestamp:new Date().toISOString()};a!==void 0&&(i.payload=a),o==null||o(i)}}}function ta(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function f3(o){const n=ta(o)?o:{};return(Array.isArray(n.data)?n.data:ta(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(o)?o:[]).map(a=>{if(!ta(a)||typeof a.id!="string"||typeof a.name!="string")return null;const i={id:a.id,name:a.name};return typeof a.description=="string"&&a.description.trim()!==""&&(i.description=a.description),typeof a.media_count=="number"&&(i.mediaCount=a.media_count),i}).filter(a=>a!==null)}function h3(o){const n=ta(o)?o:{},t=ta(n.data)?n.data:ta(o)?o:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const a={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(a.description=t.description),a}function v3(o){return o==="ready"||o==="uploading"||o==="failed"}function wo(o,n="ready"){return{id:o.uuid,media:o,status:n,countsTowardMax:v3(n)}}function g3(o,n){return o.scope==="library"?!0:n.type==="album"&&n.albumId===o.albumId}function y3(o,n){return o.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===o.albumId}function dr(o){return{code:"configuration_error",message:o,retriable:!1}}function nu(o){var ge,we,ne;const n=o.selectionMode??"multiple",t=o.maxSelection,a=o.uploadBehavior??"adapter",i=e.ref(o.initialView??{scope:"library"}),r=e.ref({sort:((ge=o.initialFilters)==null?void 0:ge.sort)??"newest",...(we=o.initialFilters)!=null&&we.query?{query:o.initialFilters.query}:{},...(ne=o.initialFilters)!=null&&ne.kinds?{kinds:o.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=Qd(o.sessionPolicy),{emitMetric:m}=tu(o.telemetry),h=eu("idle"),p=bs({httpClient:o.deps.httpClient,view:i,filters:r}),v=e.computed(()=>l.value.map(N=>N.id)),g=e.computed(()=>{const N=c.value;return N===null?null:p.items.value[N]??null}),w=e.computed(()=>o.uploadTarget??{type:"library"}),M=ys({adapter:o.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:N=>N.original_url,getThumbnailUrl:N=>N.thumbnail_url??N.preview_url??N.original_url},postUpload:async(N,L,te)=>{const ae=w.value;ae.type!=="album"||!ae.albumId||await te.attach(L.uuid,{modelType:"album",modelId:ae.albumId})},onUploadComplete:(N,L)=>{const te=w.value;g3(i.value,te)&&p.prepend(L),o.autoSelectUploaded&&y3(i.value,te)&&B(L),m("upload-complete",{mediaId:L.uuid,targetType:te.type,targetAlbumId:te.albumId})},onUploadError:(N,L)=>{d.value={code:"upload_failed",message:L.message,retriable:!0,cause:L}}}),V=e.computed(()=>M.isUploading.value),b=()=>{u.save({selectedIds:[...v.value],view:i.value,filters:r.value})},f=async N=>{const L=await p.hydrateSelection(N);l.value=L.map(te=>te.status==="ready"&&te.media?wo(te.media):{id:te.id,media:null,status:te.status,countsTowardMax:!1})},_=e.computed(()=>l.value.filter(N=>N.countsTowardMax).length),D=()=>n==="single"||t===void 0?!0:_.value<t,B=N=>{if(l.value.findIndex(te=>te.id===N.uuid)>=0){n==="multiple"?l.value=l.value.filter(te=>te.id!==N.uuid):l.value=[wo(N)],b();return}if(!D()){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=[wo(N)]:l.value=[...l.value,wo(N)],d.value=null,b()},E=async()=>{var L;h.transition("restoring");const N=u.restore();if(N===null){h.transition("ready");return}N.view&&(i.value=N.view),N.filters&&(r.value={sort:N.filters.sort??"newest",...N.filters.query?{query:N.filters.query}:{},...N.filters.kinds?{kinds:N.filters.kinds}:{}}),await p.loadInitial(),(((L=o.sessionPolicy)==null?void 0:L.restoreSelection)??!0)&&await f(N.selectedIds),h.transition("ready")};e.watch(()=>p.error.value,N=>{N!==null&&(d.value=N,h.transition("error"))});const S=async()=>{d.value=null,h.transition("idle"),await E(),p.items.value.length===0&&!p.loading.value&&!p.permissionDenied.value&&await p.loadInitial();const N=o.defaultSelectedIds??[];l.value.length===0&&N.length>0&&await f(N),h.transition("ready")},P=async(N,L="user")=>{const te=i.value;i.value=N,L==="user"&&o.preserveSelectionOnViewChange===!1&&(l.value=[]),m("view-change",{from:te.scope,to:N.scope,reason:L}),await p.loadInitial(),b()},C=async()=>{const N=await o.deps.httpClient.get("/v1/albums");s.value=f3(N)},A=async(N,L)=>{try{const te={name:N,visibility:"private"};L&&L.trim()!==""&&(te.parent_id=L);const ae=await o.deps.httpClient.post("/v1/albums",te),ie=h3(ae);return ie===null?dr("Album creation response was invalid."):(s.value=[ie,...s.value.filter(he=>he.id!==ie.id)],await P({scope:"album",albumId:ie.id,albumName:ie.name},"inline-album-created"),ie)}catch(te){const ae={code:"album_create_failed",message:te instanceof Error?te.message:"Album creation failed.",retriable:!0,cause:te};return d.value=ae,ae}},R=async N=>{if(!o.enableUpload){d.value=dr("Uploads are not enabled for this picker.");return}if(a!=="delegate"){if(!o.deps.uploadAdapter){d.value=dr("Uploads require a configured upload adapter.");return}await M.addFiles(N)}},W=()=>{var te;const N=((te=o.validateSelection)==null?void 0:te.call(o,l.value))??null;if(N!==null){const ae={code:"selection_invalid",message:N,retriable:!0};return d.value=ae,ae}if(l.value.filter(ae=>ae.status==="ready"&&ae.media!==null).length===0){const ae={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ae,ae}return{orderedIds:v.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},O=N=>{const L=p.items.value.findIndex(te=>te.uuid===N.uuid);c.value=L>=0?L:null},I=()=>{c.value=null},F=()=>{c.value===null||c.value<=0||(c.value-=1)},k=()=>{c.value===null||c.value>=p.items.value.length-1||(c.value+=1)},$=N=>{l.value=l.value.filter(L=>L.id!==N),b()},j=async()=>{await p.refresh()},Z=async N=>{r.value={...r.value,...N&&N.trim()!==""?{query:N.trim()}:{}},(!N||N.trim()==="")&&delete r.value.query,await p.loadInitial(),b()},K=async()=>{await P({scope:"library"},"permission-unavailable")};return{view:i,filters:r,albums:s,selectedItems:l,orderedIds:v,queryItems:p.items,cursor:p.cursor,hasMore:p.hasMore,loading:p.loading,loadingMore:p.loadingMore,permissionDenied:p.permissionDenied,error:d,uploadQueue:M.uploadsArray,isUploading:V,previewIndex:c,previewItem:g,initialize:S,refresh:j,loadMore:p.loadMore,setQuery:Z,setView:P,toggleSelection:B,removeSelected:$,confirmSelection:W,openPreview:O,closePreview:I,showPreviousPreview:F,showNextPreview:k,loadAlbums:C,createAlbum:A,addUploadFiles:R,goToLibrary:K,sessionId:u.sessionId}}const b3=["data-testid"],w3={class:"mlp-location-bar"},k3={class:"mlp-location-bar__left"},_3={class:"mlp-location-bar__label"},E3={class:"mlp-tabs","data-testid":"media-picker-tabs"},x3={key:0,class:"mlp-search-row"},C3=["placeholder"],S3={key:2,class:"mlp-overlay-panel"},V3={key:0,class:"mlp-error","data-testid":"media-picker-error"},N3={key:5,class:"mlp-bottom-bar"},T3={key:0,class:"mlp-bottom-bar__selection"},M3={class:"mlp-bottom-bar__count"},B3={class:"mlp-bottom-bar__thumbs"},F3=["src","alt"],I3={key:1,class:"mlp-bottom-bar__thumb-placeholder"},$3=["aria-label","onClick"],R3={class:"mlp-bottom-bar__actions"},D3=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{var I,F,k,$,j,Z,K,ge,we,ne,N,L,te,ae,ie,he,se,fe;return{title:((I=a.labels)==null?void 0:I.title)??"Media library",searchPlaceholder:((F=a.labels)==null?void 0:F.searchPlaceholder)??"Search your media",viewLibrary:((k=a.labels)==null?void 0:k.viewLibrary)??"Library",browseAlbums:(($=a.labels)==null?void 0:$.browseAlbums)??"Albums",createAlbum:((j=a.labels)==null?void 0:j.createAlbum)??"Create album",createAlbumNameLabel:((Z=a.labels)==null?void 0:Z.createAlbumNameLabel)??"Album name",emptyLibrary:((K=a.labels)==null?void 0:K.emptyLibrary)??"No media found in your library.",emptyAlbum:((ge=a.labels)==null?void 0:ge.emptyAlbum)??"No media found in this album.",networkError:((we=a.labels)==null?void 0:we.networkError)??"Unable to load media right now.",retry:((ne=a.labels)==null?void 0:ne.retry)??"Retry",selectedCount:((N=a.labels)==null?void 0:N.selectedCount)??(xe=>`${xe} selected`),confirmAction:((L=a.labels)==null?void 0:L.confirmAction)??"Attach selected",cancel:((te=a.labels)==null?void 0:te.cancel)??"Cancel",dismiss:((ae=a.labels)==null?void 0:ae.dismiss)??"Remove",uploadLabel:((ie=a.labels)==null?void 0:ie.uploadLabel)??"Upload",albumUnavailableTitle:((he=a.labels)==null?void 0:he.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((se=a.labels)==null?void 0:se.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((fe=a.labels)==null?void 0:fe.goToLibrary)??"Go to library"}}),s={deps:a.deps,selectionMode:a.selectionMode,initialView:a.initialView,initialFilters:a.initialFilters,...a.maxSelection!==void 0?{maxSelection:a.maxSelection}:{},...a.modelValue.length>0||a.defaultSelectedIds.length>0?{defaultSelectedIds:a.modelValue.length>0?a.modelValue:a.defaultSelectedIds}:{},...a.sessionPolicy?{sessionPolicy:a.sessionPolicy}:{},...a.enableUpload?{enableUpload:!0}:{},uploadBehavior:a.uploadBehavior,...a.uploadTarget?{uploadTarget:a.uploadTarget}:{},...a.autoSelectUploaded?{autoSelectUploaded:!0}:{},...a.validateSelection?{validateSelection:a.validateSelection}:{},preserveSelectionOnViewChange:a.preserveSelectionOnViewChange,telemetry:I=>{var F;(F=a.telemetry)==null||F.call(a,I),i("metric",I)}},l=nu(s),c=e.ref(a.initialFilters.query??""),d=e.ref("upload"),u=e.ref(!1),m=JSON.stringify(a.modelValue.length>0?a.modelValue:a.defaultSelectedIds);let h=null;const p=e.computed(()=>JSON.stringify(l.orderedIds.value)!==m),v=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),M=e.computed(()=>l.view.value.scope==="album"),V=()=>{h!==null&&(window.clearTimeout(h),h=null)},b=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:p.value})},f=I=>{I!==null&&i("error",I)},_=I=>typeof I.code=="string",D=I=>typeof I=="object"&&I!==null&&"code"in I&&typeof I.code=="string",B=()=>{const I=l.confirmSelection();if(_(I)){f(I);return}i("confirm",{...I,dirty:p.value})},E=(I="user")=>{i("cancel",{dirty:p.value,reason:I,sessionId:l.sessionId})},S=async()=>{d.value="albums",await l.loadAlbums()},P=async()=>{await l.goToLibrary(),d.value="albums",await l.loadAlbums()},C=I=>{l.setView({scope:"album",albumId:I.id,albumName:I.name}),d.value="media"},A=async(I,F)=>{const k=l.view.value,$=await l.createAlbum(I,F);if(D($)){f($);return}u.value=!1,d.value="media",i("view-change",{from:k,to:{scope:"album",albumId:$.id,albumName:$.name},reason:"inline-album-created",restoredFromSession:!1})},R=async I=>{if(a.uploadBehavior==="delegate"){i("request-upload-files",{files:[...I],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(I)};function W(I){var F;return I?I.thumbnail_url??((F=I.conversion_urls)==null?void 0:F.thumb)??I.preview_url??I.original_url??I.url??null:null}function O(I){return I!=null&&I.mime_type?I.mime_type.startsWith("image/"):!1}return e.watch(()=>c.value,I=>{V(),h=window.setTimeout(()=>{l.setQuery(I)},250)}),e.watch(()=>l.selectedItems.value,()=>{b()},{deep:!0}),e.watch(()=>l.error.value,I=>{f(I)}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{V()}),n({refresh:l.refresh}),(I,F)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":I.testIdPrefix},[e.createElementVNode("header",w3,[e.createElementVNode("div",k3,[M.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:P},[...F[8]||(F[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",_3,e.toDisplayString(w.value),1)])]),e.createElementVNode("nav",E3,[I.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:F[0]||(F[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:F[1]||(F[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:S},e.toDisplayString(r.value.browseAlbums),3)]),d.value==="media"||d.value==="albums"?(e.openBlock(),e.createElementBlock("div",x3,[F[9]||(F[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":F[2]||(F[2]=k=>c.value=k),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,C3),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),I.enableUpload&&d.value==="upload"?(e.openBlock(),e.createBlock(Hd,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:I.accept,"upload-label":r.value.uploadLabel,onClose:F[3]||(F[3]=k=>d.value="media"),onFilesSelected:R},null,8,["queue","accept","upload-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",S3,[e.createVNode(zd,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:F[4]||(F[4]=k=>u.value=!1),onCreate:A},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(jd,{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",V3,[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:F[5]||(F[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(Gd,{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":v.value,"test-id-prefix":`${I.testIdPrefix}-item`,onToggle:e.unref(l).toggleSelection,onPreview:e.unref(l).openPreview,onLoadMore:e.unref(l).loadMore},null,8,["items","selected-items","loading","loading-more","has-more","empty-message","test-id-prefix","onToggle","onPreview","onLoadMore"])):d.value==="albums"?(e.openBlock(),e.createBlock(Zd,{key:2,open:!0,"current-view":e.unref(l).view.value,albums:e.unref(l).albums.value,"view-library-label":r.value.viewLibrary,"browse-albums-label":r.value.browseAlbums,"create-album-label":r.value.createAlbum,"enable-album-creation":I.enableAlbumCreation,onSelectLibrary:P,onSelectAlbum:C,onCreateAlbum:F[6]||(F[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),I.showFooter?(e.openBlock(),e.createElementBlock("footer",N3,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",T3,[e.createElementVNode("span",M3,e.toDisplayString(g.value),1),e.createElementVNode("div",B3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,k=>{var $,j,Z;return e.openBlock(),e.createElementBlock("div",{key:k.id,class:"mlp-bottom-bar__thumb-item"},[O(k.media)&&W(k.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:W(k.media),alt:(($=k.media)==null?void 0:$.alt_text)??((j=k.media)==null?void 0:j.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,F3)):(e.openBlock(),e.createElementBlock("div",I3,[...F[10]||(F[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} ${((Z=k.media)==null?void 0:Z.file_name)??k.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:K=>e.unref(l).removeSelected(k.id)},[...F[11]||(F[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,$3)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",R3,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:F[7]||(F[7]=k=>E())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:B},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),I.enablePreview?(e.openBlock(),e.createBlock(Wd,{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,b3))}}),au=Me(D3,[["__scopeId","data-v-db2ced73"]]),A3={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},L3={class:"media-library-picker-modal__panel"},U3=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(o,{emit:n}){const t=o,a=n,i=()=>{t.closeOnBackdrop&&a("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",A3,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",L3,[e.createVNode(au,e.mergeProps(t,{"onUpdate:modelValue":s[0]||(s[0]=l=>a("update:modelValue",l)),onConfirm:s[1]||(s[1]=l=>a("confirm",l)),onCancel:s[2]||(s[2]=l=>a("cancel",l))}),null,16)])])):e.createCommentVNode("",!0)}}),O3=Me(U3,[["__scopeId","data-v-a92e8703"]]),P3={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},z3={class:"media-selection-tray__header"},j3={class:"media-selection-tray__title"},W3={class:"media-selection-tray__items"},Z3={class:"media-selection-tray__item-preview"},H3=["src","alt"],X3={key:1,class:"media-selection-tray__file-icon"},G3={class:"media-selection-tray__item-copy"},J3=["aria-label","onClick"],Y3=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(o,{emit:n}){const t=n;function a(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",P3,[e.createElementVNode("header",z3,[e.createElementVNode("h3",j3,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",W3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d,u,m;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",Z3,[i(l.media)&&a(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:a(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,H3)):(e.openBlock(),e.createElementBlock("div",X3,[...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",G3,[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} ${((m=l.media)==null?void 0:m.file_name)??l.id}`,onClick:h=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,J3)])}),128))])])):e.createCommentVNode("",!0)}}),q3=Me(Y3,[["__scopeId","data-v-f2a3d69d"]]);function ws(o={}){const n=e.ref(!1),t=e.ref(!1),a=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),l=e.ref(null),c=e.computed(()=>l.value!==null),d=M=>{if(r.value++,l.value=null,i.value=null,t.value=!1,M!=null&&typeof M=="object"&&!(M instanceof Blob)&&("image"in M||"state"in M||"sessionKey"in M)){const V=M;a.value=V.image??null,s.value=V.state??null}else a.value=M??null,s.value=null;n.value=!0},u=()=>{n.value=!1,a.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},m=async M=>{try{return t.value=!0,i.value=M,o.onSave&&await o.onSave(M),u(),M}catch(V){const b=V;throw l.value=b,o.onError&&o.onError(b),b}finally{t.value=!1}},h=()=>{o.onCancel&&o.onCancel(),u()},p=M=>{l.value=M,o.onError&&o.onError(M)},v=()=>{l.value=null},g=()=>i.value,w=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:a,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:w,open:d,close:u,handleSave:m,handleCancel:h,handleError:p,clearError:v,getEditedImage:g}}let ur=null;function K3(o){return ur||(ur=ws(o)),ur}function Q3(o){return n=>new Promise((t,a)=>{ws({...o,onSave:async r=>{o!=null&&o.onSave&&await o.onSave(r),t(r)},onError:r=>{o!=null&&o.onError&&o.onError(r),a(r)},onCancel:()=>{o!=null&&o.onCancel&&o.onCancel(),a(new Error("User cancelled"))}}).open(n)})}function ks(o){return o.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const a={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(a.custom_properties=n.customProperties),a})}function Wr(o){return o.map((n,t)=>{const a={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(a.customProperties=n.custom_properties),a})}function _s(o){if(o){const t={};o.apiBaseUrl!==void 0&&(t.apiBaseUrl=o.apiBaseUrl),o.isAdmin!==void 0&&(t.isAdmin=o.isAdmin),na(t)}return{name:"mediables",async upload(t,a){const r=await $t().uploadFile(t,{collection:(a==null?void 0:a.collection)||"default",customProperties:a==null?void 0:a.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,a){await $t().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await $t().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await $t().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await $t().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await $t().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return $t().getMediaUrl(t,a)},getThumbnailUrl(t){var a,i;return(a=t.conversion_urls)!=null&&a.thumb?t.conversion_urls.thumb:(i=t.conversion_urls)!=null&&i.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await $t().deleteMedia(t)},async update(t,a){const r=await $t().updateMedia(t,a);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const a={};t.apiBaseUrl!==void 0&&(a.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(a.isAdmin=t.isAdmin),na(a)}}}let Io=null;function eN(){return Io||(Io=_s()),Io}function tN(){Io=null}const nN={apiBaseUrl:"/media-library-pro"};function ko(){var o;return typeof document>"u"?null:((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||null}function mr(o){const n={uuid:o.uuid,file_name:o.fileName||o.name,mime_type:`application/${o.extension}`,size:o.size,disk:"public",original_url:o.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return o.name&&(n.name=o.name),o.original_url&&(n.url=o.original_url),o.preview_url&&(n.thumbnail_url=o.preview_url,n.preview_url=o.preview_url),o.custom_properties&&(n.custom_properties=o.custom_properties),n}function Es(o){const n={...nN,...o};return{name:"spatie",async upload(a,i){const r=new FormData;r.append("file",a),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||ko();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(c.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,c);if(!d.ok){const h=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(h.message||`HTTP ${d.status}`)}const u=await d.json(),m=mr(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(a,i){},async attachMany(a,i){},async detach(a,i){},async reorder(a,i){},async fetchModelMedia(a){const i={Accept:"application/json",...n.headers},r=n.csrfToken||ko();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",a.modelType),s.append("model_id",String(a.modelId)),a.collection&&s.append("collection",a.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(mr)}catch{return[]}},getUrl(a,i){var r;if(i){const s=(r=a.conversion_urls)==null?void 0:r[i];if(s)return s}return a.original_url||a.url||""},getThumbnailUrl(a){var i,r;return a.preview_url?a.preview_url:(i=a.conversion_urls)!=null&&i.preview?a.conversion_urls.preview:a.thumbnail_url?a.thumbnail_url:(r=a.conversion_urls)!=null&&r.thumb?a.conversion_urls.thumb:a.original_url||a.url||""},async delete(a){const i={Accept:"application/json",...n.headers},r=n.csrfToken||ko();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${a}`,{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(a,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||ko();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${a}`,{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 mr(c)},configure(a){Object.assign(n,a)}}}let $o=null;function aN(){return $o||($o=Es()),$o}function oN(){$o=null}function ou(o,n){switch(o){case"mediables":return _s(n);case"spatie":return Es(n);default:throw new Error(`Unknown adapter: ${o}`)}}function iu(o={}){const{enabled:n=!0,onReorder:t,onDragStart:a,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=o,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(V,b,f){n&&("dataTransfer"in V&&V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",String(f))),d=V.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:b},c.value=!0,a==null||a(b,f))}function m(V,b){var f;if(!(!n||!l.value.isDragging)&&(V.preventDefault(),l.value.dropIndex!==b)){const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s);const D=(f=V.target)==null?void 0:f.closest("[data-index]");D==null||D.classList.add(s),l.value.dropIndex=b}}function h(){if(!l.value.isDragging)return;const{dragIndex:V,dropIndex:b,draggedItem:f}=l.value;d&&d.classList.remove(r);const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s),V!==null&&b!==null&&V!==b&&f&&(t==null||t({fromIndex:V,toIndex:b,item:f})),v(),i==null||i()}function p(){d&&d.classList.remove(r);const V=document.querySelector(`.${s}`);V==null||V.classList.remove(s),v(),i==null||i()}function v(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function g(V,b,f){const _=[...V],[D]=_.splice(b,1);return _.splice(f,0,D),_.map((B,E)=>({...B,order:E}))}function w(V,b){return{draggable:n,"data-index":b,onDragstart:f=>u(f,V,b),onDragover:f=>m(f,b),onDragend:()=>h(),onDrop:f=>{f.preventDefault(),h()}}}function M(V){V.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onUnmounted(()=>{document.removeEventListener("keydown",M),p()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:m,endDrag:h,cancelDrag:p,reorderItems:g,getDragProps:w}}function bi(o={}){const{initialItems:n=[],modelType:t,modelId:a,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:h,maxConcurrentUploads:p=3,onChange:v,onUpload:g,onUploadComplete:w,onUploadError:M,onRemove:V,onReorder:b,onError:f,onReadyToSubmitChange:_}=o,D={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},B=h||ou(m),E=e.ref([]),S=e.ref(!1),P=e.ref([]);function C(le){if(le.length===0)return[];const de=le[0];return"media"in de&&"clientId"in de?le:Wr(le)}E.value=C(n);const{acceptString:A,canAddFiles:R}=gs({rules:D}),W=ys({adapter:B,maxConcurrent:p,rules:D,collection:i,onUploadStart:le=>{g==null||g(le)},onUploadComplete:(le,de)=>{const Ve=E.value.findIndex(Be=>Be.clientId===le.id);Ve!==-1&&(E.value[Ve]={...E.value[Ve],media:de,name:de.name||de.file_name,upload:{...le,status:"completed"}}),w==null||w(de)},onUploadError:(le,de)=>{const Ve=E.value.findIndex(Be=>Be.clientId===le.id);Ve!==-1&&(E.value[Ve]={...E.value[Ve],upload:{...le,status:"error",error:de.message},errors:[{field:"upload",message:de.message,code:"UPLOAD_ERROR"}]}),M==null||M({file:le.file,message:de.message})},onQueueComplete:()=>{v==null||v(E.value)}}),{dragState:O,getDragProps:I,reorderItems:F}=iu({enabled:c&&!d,onReorder:le=>{E.value=F(E.value,le.fromIndex,le.toIndex),b==null||b(E.value),v==null||v(E.value)}}),k=e.computed(()=>W.isUploading.value),$=e.computed(()=>!W.isUploading.value&&W.pendingCount.value===0),j=e.computed(()=>r?E.value.length>=r:!1),Z=e.computed(()=>ks(E.value)),K=e.computed(()=>E.value.length),ge=e.computed(()=>r?Math.max(0,r-E.value.length):1/0);e.watch($,le=>{_==null||_(le)});function we(le){E.value=C(le),v==null||v(E.value)}async function ne(le){if(d)return;const de=Array.from(le);if(!R(de.length,E.value.length)){const Ke={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};P.value=[Ke],f==null||f([Ke]);return}const Ve=await W.addFiles(de),Be=E.value.length,dt=Ve.map((Ke,bt)=>({...Ke,order:Be+bt}));E.value=[...E.value,...dt],v==null||v(E.value)}function N(le){d||(le.upload&&(le.upload.status==="uploading"||le.upload.status==="pending")&&W.cancelUpload(le.clientId),E.value=E.value.filter(de=>de.clientId!==le.clientId),E.value=E.value.map((de,Ve)=>({...de,order:Ve})),V==null||V(le),v==null||v(E.value))}function L(le){const de=E.value.find(Ve=>Ve.clientId===le);de&&N(de)}function te(){d||(W.clearAll(),E.value=[],v==null||v(E.value))}function ae(le,de){d||!c||(E.value=F(E.value,le,de),b==null||b(E.value),v==null||v(E.value))}function ie(le,de){if(d)return;const Ve=E.value.findIndex(Be=>Be.clientId===le);Ve!==-1&&(E.value[Ve]={...E.value[Ve],...de},v==null||v(E.value))}function he(le){W.cancelUpload(le),L(le)}async function se(le){await W.retryUpload(le)}async function fe(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const le={modelType:t,modelId:a,collection:i},de=E.value.filter(Ve=>Ve.media&&!Ve.markedForRemoval).map(Ve=>Ve.media.uuid);S.value=!0;try{await B.attachMany(de,le),await B.reorder(le,de)}finally{S.value=!1}}async function xe(){if(!t||!a)throw new Error("modelType and modelId are required for load()");const le={modelType:t,modelId:a,collection:i};S.value=!0;try{const de=await B.fetchModelMedia(le);E.value=Wr(de),v==null||v(E.value)}finally{S.value=!1}}return e.onMounted(()=>{t&&a&&n.length===0&&xe().catch(console.error)}),e.onUnmounted(()=>{W.clearAll()}),{items:E,setItems:we,addFiles:ne,removeItem:N,removeItemById:L,clearAll:te,reorderItems:ae,updateItem:ie,cancelUpload:he,retryUpload:se,save:fe,load:xe,isLoading:S,isUploading:k,isReadyToSubmit:$,isAtMaxItems:j,errors:P,dragState:O,getDragProps:I,adapter:B,formValues:Z,acceptString:A,count:K,remainingSlots:ge}}const iN=["aria-disabled"],rN=["accept","multiple","disabled"],sN={class:"media-dropzone__content"},lN={class:"media-dropzone__title"},cN={class:"media-dropzone__subtitle"},dN=["disabled"],uN={key:0,class:"media-dropzone__helper"},mN=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(o,{emit:n}){const t=o,a=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: ${Zo(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function c(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function m(g){var M;if(g.preventDefault(),i.value=!1,t.disabled)return;const w=(M=g.dataTransfer)==null?void 0:M.files;w&&w.length>0&&a("files",w)}function h(){var g;t.disabled||(g=r.value)==null||g.click()}function p(g){const w=g.target,M=w.files;M&&M.length>0&&a("files",M),w.value=""}function v(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),h())}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:h,onKeydown:v,onDragenter:c,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:p},null,40,rN),e.createElementVNode("div",sN,[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",lN,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",cN,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(h,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,dN),l.value?(e.openBlock(),e.createElementBlock("p",uN,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,iN))}}),xs=Me(mN,[["__scopeId","data-v-b1366c1e"]]),pN=["data-index"],fN={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},hN={class:"media-item__thumbnail"},vN=["src","alt"],gN={key:1,class:"media-item__file-icon"},yN={key:2,class:"media-item__progress-overlay"},bN={class:"media-item__progress-text"},wN={key:3,class:"media-item__processing-overlay"},kN={key:4,class:"media-item__error-overlay"},_N={class:"media-item__info"},EN=["title"],xN={key:0,class:"media-item__size"},CN={key:1,class:"media-item__error-message"},SN={class:"media-item__actions"},VN=["disabled"],NN=["disabled"],TN=["disabled"],MN=["disabled"],BN=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(o,{emit:n}){const t=o,a=n,i=e.ref(!1),r=e.computed(()=>{var b;return(b=t.item.upload)!=null&&b.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var b,f,_;return((b=t.item.upload)==null?void 0:b.status)==="uploading"||((f=t.item.upload)==null?void 0:f.status)==="pending"||((_=t.item.upload)==null?void 0:_.status)==="queued"}),l=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="processing"}),c=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var b;return(b=t.item.upload)!=null&&b.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.progress)||0}),m=e.computed(()=>{var b;return t.item.name||((b=t.item.media)==null?void 0:b.file_name)||"Unknown file"}),h=e.computed(()=>{var B,E;const b=((B=t.item.media)==null?void 0:B.size)||((E=t.item.upload)==null?void 0:E.file.size);if(!b)return"";const f=1024,_=["Bytes","KB","MB","GB"],D=Math.floor(Math.log(b)/Math.log(f));return parseFloat((b/Math.pow(f,D)).toFixed(2))+" "+_[D]}),p=e.computed(()=>{var f,_;const b=((f=t.item.media)==null?void 0:f.mime_type)||((_=t.item.upload)==null?void 0:_.file.type);return b==null?void 0:b.startsWith("image/")}),v=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||a("remove",t.item)}function w(){t.disabled||a("edit",t.item)}function M(){t.disabled||a("retry",t.item)}function V(){t.disabled||a("cancel",t.item)}return(b,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":b.index,onMouseenter:f[0]||(f[0]=_=>i.value=!0),onMouseleave:f[1]||(f[1]=_=>i.value=!1)},[b.sortable&&!b.disabled?(e.openBlock(),e.createElementBlock("div",fN,[...f[2]||(f[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",hN,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,vN)):(e.openBlock(),e.createElementBlock("div",gN,[...f[3]||(f[3]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),s.value?(e.openBlock(),e.createElementBlock("div",yN,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",bN,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",wN,[...f[4]||(f[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",kN,[...f[5]||(f[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",_N,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,EN),h.value?(e.openBlock(),e.createElementBlock("span",xN,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",CN,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",SN,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:b.disabled,"aria-label":"Cancel upload",onClick:V},[...f[6]||(f[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,VN)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:b.disabled,"aria-label":"Retry upload",onClick:M},[...f[7]||(f[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,NN)):e.createCommentVNode("",!0),b.showEdit&&b.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:b.disabled,"aria-label":"Edit",onClick:w},[...f[8]||(f[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,TN)):e.createCommentVNode("",!0),b.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:b.disabled,"aria-label":"Remove",onClick:g},[...f[9]||(f[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,MN)):e.createCommentVNode("",!0)])],42,pN))}}),Cs=Me(BN,[["__scopeId","data-v-ff81c9ec"]]),FN=["aria-label"],IN=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],$N={key:0,class:"media-collection__footer"},RN={class:"media-collection__count"},DN={key:0},AN={key:0,class:"media-collection__uploading"},LN=["name","value"],UN=["name","value"],ON=["name","value"],PN=["name","value"],zN={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},jN=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(o,{emit:n}){const t=o,a=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=>{a("update:modelValue",k),a("change",k)},onUpload:k=>{a("upload",k)},onUploadComplete:k=>{a("upload-complete",k)},onUploadError:k=>{a("upload-error",k)},onRemove:k=>{a("remove",k)},onReorder:k=>{a("reorder",k)},onError:k=>{a("validation-error",k)},onReadyToSubmitChange:k=>{a("is-ready-to-submit-change",k)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:h,isUploading:p,isAtMaxItems:v,errors:g,dragState:w,getDragProps:M,adapter:V,formValues:b,acceptString:f,count:_,remainingSlots:D}=bi(i);e.provide("mediaAdapter",V),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,k=>{k!==r.value&&s(k)},{deep:!0});const B=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),E=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":h.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":w.value.isDragging}));function S(k){l(k)}function P(k){c(k)}function C(k){m(k.clientId)}function A(k){u(k.clientId)}function R(k){}function W(k,$,j){if(!t.sortable||t.disabled)return;const Z=M($,j);Z.onDragstart&&Z.onDragstart(k)}function O(k,$){if(!t.sortable||t.disabled)return;k.preventDefault();const j=r.value[$],Z=M(j,$);Z.onDragover&&Z.onDragover(k)}function I(k,$){const j=M(k,$);j.onDragend&&j.onDragend()}function F(k,$){k.preventDefault();const j=r.value[$],Z=M(j,$);Z.onDrop&&Z.onDrop(k)}return(k,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(E.value)},[e.renderSlot(k.$slots,"dropzone",{addFiles:e.unref(l)},()=>[B.value?(e.openBlock(),e.createBlock(xs,{key:0,accept:e.unref(f),multiple:k.maxItems!==1,disabled:k.disabled,"max-file-size":k.maxFileSize,"max-items":e.unref(D),onFiles:S},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(_)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(j,Z)=>e.renderSlot(k.$slots,"item",{key:j.clientId,item:j,index:Z,remove:()=>P(j)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(w).dropIndex===Z}]),draggable:k.sortable&&!k.disabled,"data-index":Z,onDragstart:K=>W(K,j,Z),onDragover:K=>O(K,Z),onDragend:K=>I(j,Z),onDrop:K=>F(K,Z)},[e.createVNode(Cs,{item:j,adapter:e.unref(V),disabled:k.disabled,sortable:k.sortable,"show-remove":!k.readonly,"show-edit":!1,index:Z,onRemove:P,onRetry:C,onCancel:A,onEdit:R},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,IN)],!0)),128))],8,FN)):B.value?e.createCommentVNode("",!0):e.renderSlot(k.$slots,"empty",{key:1},()=>[$[0]||($[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(_),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",$N,[e.createElementVNode("span",RN,[e.createTextVNode(e.toDisplayString(e.unref(_))+" "+e.toDisplayString(e.unref(_)===1?"file":"files")+" ",1),k.maxItems?(e.openBlock(),e.createElementBlock("span",DN," / "+e.toDisplayString(k.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",AN," 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(b),(j,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${j.uuid}`,type:"hidden",name:`${k.name}[${Z}][uuid]`,value:j.uuid},null,8,LN))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(j,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${j.uuid}-name`,type:"hidden",name:`${k.name}[${Z}][name]`,value:j.name},null,8,UN))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(j,Z)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${j.uuid}-order`,type:"hidden",name:`${k.name}[${Z}][order]`,value:j.order},null,8,ON))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(j,Z)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${k.name}-${j.uuid}-props`},[j.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[${Z}][custom_properties]`,value:JSON.stringify(j.custom_properties)},null,8,PN)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",zN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),j=>(e.openBlock(),e.createElementBlock("p",{key:j.code||j.message,class:"media-collection__error"},e.toDisplayString(j.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),WN=Me(jN,[["__scopeId","data-v-10a5bfff"]]);function Ss(o={}){const{initialItem:n,onChange:t,onReplace:a,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=o,h={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:B=>{t==null||t(B[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},p=bi(h),v=e.computed(()=>p.items.value[0]||null),g=e.computed(()=>v.value!==null),w=e.computed(()=>p.formValues.value[0]||null);function M(B){B===null?p.clearAll():p.setItems([B])}async function V(B){const E=v.value;E&&p.removeItem(E),await p.addFiles([B])}function b(){v.value&&p.removeItem(v.value)}async function f(B){const E=v.value;E&&p.removeItem(E),await p.addFiles([B]);const S=p.items.value[0];S&&(a==null||a(E,S))}function _(){var B;(B=v.value)!=null&&B.upload&&p.cancelUpload(v.value.clientId)}async function D(){var B,E;((E=(B=v.value)==null?void 0:B.upload)==null?void 0:E.status)==="error"&&await p.retryUpload(v.value.clientId)}return{item:v,setItem:M,addFile:V,removeItem:b,replaceItem:f,cancelUpload:_,retryUpload:D,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:g,errors:p.errors,adapter:p.adapter,formValue:w,acceptString:p.acceptString}}const ZN=["accept","disabled"],HN={class:"media-attachment__preview"},XN=["name","value"],GN=["name","value"],JN=["name","value"],YN=["name","value"],qN={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},KN=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(o,{emit:n}){const t=o,a=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:C=>{a("update:modelValue",C),a("change",C)},onUpload:C=>{a("upload",C)},onUploadComplete:C=>{a("upload-complete",C)},onUploadError:C=>{a("upload-error",C)},onRemove:C=>{a("remove",C)},onReplace:(C,A)=>{a("replace",A)},onError:C=>{a("validation-error",C)},onReadyToSubmitChange:C=>{a("is-ready-to-submit-change",C)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,hasItem:v,errors:g,adapter:w,formValue:M,acceptString:V}=Ss(r);e.provide("mediaAdapter",w),e.watch(()=>t.modelValue,C=>{C!==s.value&&l(C)},{deep:!0});const b=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),f=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":v.value}));function _(C){C.length>0&&c(C[0])}function D(){var C;(C=i.value)==null||C.click()}function B(C){const A=C.target,R=A.files;R&&R.length>0&&u(R[0]),A.value=""}function E(C){d()}function S(C){h()}function P(C){m()}return(C,A)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(V),disabled:C.disabled,class:"media-attachment__hidden-input",onChange:B},null,40,ZN),b.value?e.renderSlot(C.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(xs,{accept:e.unref(V),multiple:!1,disabled:C.disabled,"max-file-size":C.maxFileSize,onFiles:_},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(C.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:D},()=>[e.createElementVNode("div",HN,[e.createVNode(Cs,{item:e.unref(s),adapter:e.unref(w),disabled:C.disabled,sortable:!1,"show-remove":!C.readonly,"show-edit":!1,onRemove:E,onRetry:S,onCancel:P},null,8,["item","adapter","disabled","show-remove"]),C.showReplaceButton&&!C.readonly&&!C.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:D},[...A[0]||(A[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(C.$slots,"empty",{key:2},()=>[A[1]||(A[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),C.generateFormFields&&e.unref(M)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${C.name}[uuid]`,value:e.unref(M).uuid},null,8,XN),e.createElementVNode("input",{type:"hidden",name:`${C.name}[name]`,value:e.unref(M).name},null,8,GN),e.createElementVNode("input",{type:"hidden",name:`${C.name}[order]`,value:e.unref(M).order},null,8,JN),e.unref(M).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${C.name}[custom_properties]`,value:JSON.stringify(e.unref(M).custom_properties)},null,8,YN)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",qN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),R=>(e.openBlock(),e.createElementBlock("p",{key:R.code||R.message,class:"media-attachment__error"},e.toDisplayString(R.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),QN=Me(KN,[["__scopeId","data-v-26911174"]]),ru={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"}},e5=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(o,{expose:n,emit:t}){const a=o,i=t,r={initialItems:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxItems:a.maxItems,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,sortable:a.sortable,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:C=>{i("update:modelValue",C),i("change",C)},onUpload:C=>{i("upload",C)},onUploadComplete:C=>{i("upload-complete",C)},onUploadError:C=>{i("upload-error",C)},onRemove:C=>{i("remove",C)},onReorder:C=>{i("reorder",C)},onError:C=>{i("validation-error",C)},onReadyToSubmitChange:C=>{i("is-ready-to-submit-change",C)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:w,isAtMaxItems:M,errors:V,dragState:b,getDragProps:f,adapter:_,formValues:D,acceptString:B}=bi(r);e.provide("mediaAdapter",_),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,C=>{C!==s.value&&l(C)},{deep:!0});const E=e.computed(()=>({...ru,...a.labels})),S=e.computed(()=>({accept:B.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||M.value})),P=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:g.value,isReadyToSubmit:w.value,isAtMaxItems:M.value,errors:V.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(C=>d(C))},cancelUpload:h,retryUpload:p,labels:E.value,dropzoneProps:S.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:w,isAtMaxItems:M,errors:V,dragState:b,getDragProps:f,adapter:_,formValues:D,acceptString:B}),(C,A)=>e.renderSlot(C.$slots,"default",e.normalizeProps(e.guardReactiveProps(P.value)))}}),t5=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(o,{expose:n,emit:t}){const a=o,i=t,r={initialItem:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:E=>{i("update:modelValue",E),i("change",E)},onUpload:E=>{i("upload",E)},onUploadComplete:E=>{i("upload-complete",E)},onUploadError:E=>{i("upload-error",E)},onRemove:E=>{i("remove",E)},onReplace:(E,S)=>{i("replace",S)},onError:E=>{i("validation-error",E)},onReadyToSubmitChange:E=>{i("is-ready-to-submit-change",E)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:w,errors:M,adapter:V,formValue:b,acceptString:f}=Ss(r);e.provide("mediaAdapter",V),e.watch(()=>a.modelValue,E=>{E!==s.value&&l(E)},{deep:!0});const _=e.computed(()=>({...ru,...a.labels})),D=e.computed(()=>({accept:f.value,multiple:!1,disabled:a.disabled||a.readonly||w.value})),B=e.computed(()=>({item:s.value,hasItem:w.value,isLoading:p.value,isUploading:v.value,isReadyToSubmit:g.value,errors:M.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,labels:_.value,dropzoneProps:D.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:w,errors:M,adapter:V,formValue:b,acceptString:f}),(E,S)=>e.renderSlot(E.$slots,"default",e.normalizeProps(e.guardReactiveProps(B.value)))}}),n5=["name","value"],a5=["name","value"],o5=["name","value"],i5=["name","value"],r5=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(o){const n=o,t=e.computed(()=>n.item?[n.item]:n.items),a=e.computed(()=>ks(t.value));function i(l,c){var u;const d=((u=a.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(a.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,n5),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,a5),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,o5),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,i5)):e.createCommentVNode("",!0)],64))),128))}}),s5=["data-testid"],l5=["data-testid"],c5=["id"],d5=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],u5=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:(o,n)=>`${o.type==="video"?"video":"photo"} ${n+1}`}},emits:["update:items"],setup(o,{emit:n}){const t=o,a=n;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&a("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,c5),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,d5)],8,l5))),128))],8,s5)):e.createCommentVNode("",!0)}}),m5=Me(u5,[["__scopeId","data-v-a153768a"]]),p5="/v1/media/deletion/check",f5="/v1/media/deletion/delete",_o=100;function ic(o){const n=new Set,t=[];for(const a of o){const i=a.trim().toLowerCase();i===""||n.has(i)||(n.add(i),t.push(i))}return t.sort()}function su(o){const n=o.checkEndpoint??p5,t=o.deleteEndpoint??f5,a=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function c(m){l.value=null;const h=ic(m);if(h.length===0)return r.value=[],[];if(h.length>_o){const p=new Error(`Cannot check more than ${_o} media items at once.`);throw l.value=p,p}a.value=!0;try{const p=await o.httpClient.post(n,{uuids:h}),v=((p==null?void 0:p.data)??[]).map(g=>{var w,M,V,b;return{uuid:g.uuid,canDelete:((w=g.report)==null?void 0:w.canDelete)??!1,blocks:Array.isArray((M=g.report)==null?void 0:M.blocks)?g.report.blocks:[],cascade:Array.isArray((V=g.report)==null?void 0:V.cascade)?g.report.cascade:[],variantCount:typeof((b=g.report)==null?void 0:b.variantCount)=="number"?g.report.variantCount:0}});return r.value=v,v}catch(p){throw l.value=p instanceof Error?p:new Error(String(p)),l.value}finally{a.value=!1}}async function d(m,h={}){l.value=null;const p=ic(m);if(p.length===0){const v={results:[],summary:{}};return s.value=v,v}if(p.length>_o){const v=new Error(`Cannot delete more than ${_o} media items at once.`);throw l.value=v,v}i.value=!0;try{const v=await o.httpClient.post(t,{uuids:p,force:h.force===!0}),g={results:Array.isArray(v==null?void 0:v.results)?v.results:[],summary:(v==null?void 0:v.summary)??{}};return s.value=g,g}catch(v){throw l.value=v instanceof Error?v:new Error(String(v)),l.value}finally{i.value=!1}}function u(){r.value=null,s.value=null,l.value=null}return{isChecking:a,isDeleting:i,lastReport:r,lastResponse:s,error:l,checkDependencies:c,deleteMany:d,reset:u}}const h5="/v1/user/media/trash";function v5(o){return`/v1/user/media/${encodeURIComponent(o)}/restore`}function lu(o){const n=o.listEndpoint??h5,t=o.buildRestoreEndpoint??v5,a=o.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(p=1){var v,g;d.value=null,l.value=!0;try{const w=await o.httpClient.get(n,{params:{page:p,per_page:a}});i.value=Array.isArray(w==null?void 0:w.data)?w.data:[],r.value=typeof((v=w==null?void 0:w.meta)==null?void 0:v.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:p}catch(w){throw d.value=w instanceof Error?w:new Error(String(w)),d.value}finally{l.value=!1}}async function m(p){d.value=null,c.value=!0;try{const v=await o.httpClient.post(t(p)),g={status:(v==null?void 0:v.status)??"failed",data:(v==null?void 0:v.data)??null,duplicate_uuid:(v==null?void 0:v.duplicate_uuid)??null};return typeof(v==null?void 0:v.message)=="string"&&(g.message=v.message),g.status==="restored"&&(i.value=i.value.filter(w=>w.uuid!==p),r.value=Math.max(0,r.value-1)),g}catch(v){const g=g5(v);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=v instanceof Error?v:new Error(String(v)),d.value}finally{c.value=!1}}function h(){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:m,reset:h}}function g5(o){var t;if(typeof o!="object"||o===null)return null;const n=o;return(t=n.response)!=null&&t.data&&typeof n.response.data=="object"?n.response.data:null}const y5={class:"media-management-view","data-testid":"media-management-view"},b5={class:"media-management-view__header"},w5={class:"media-management-view__title"},k5={class:"media-management-view__actions"},_5={key:0,class:"media-management-view__badge"},E5={key:0,class:"media-management-view__panel","data-testid":"panel-library"},x5={key:0,class:"media-management-view__status","data-testid":"library-loading"},C5={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},S5={key:2,class:"media-management-view__empty","data-testid":"library-empty"},V5={key:3,class:"media-management-view__grid","data-testid":"library-grid"},N5=["data-testid"],T5=["data-testid","aria-pressed","onClick"],M5=["src","alt"],B5={key:1,class:"media-management-view__item-placeholder"},F5={class:"media-management-view__item-meta"},I5={class:"media-management-view__item-name"},$5=["data-testid"],R5={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},D5={key:4,class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},A5={"data-testid":"bulk-count"},L5=["disabled"],U5={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},O5={key:0,class:"media-management-view__status","data-testid":"trash-loading"},P5={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},z5={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},j5=["data-testid"],W5={class:"media-management-view__item-thumb"},Z5=["src","alt"],H5={class:"media-management-view__item-meta"},X5={class:"media-management-view__item-name"},G5={key:0,class:"media-management-view__item-meta-line"},J5=["data-testid","disabled","onClick"],Y5=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},confirmBulkDelete:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","error"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>({showTrash:!0,allowBulkDelete:!0,showOwner:!1,...a.capabilities})),s=e.computed(()=>{var I,F,k,$,j,Z,K,ge,we,ne,N,L;return{title:((I=a.labels)==null?void 0:I.title)??"My Media",libraryTab:((F=a.labels)==null?void 0:F.libraryTab)??"Library",trashTab:((k=a.labels)==null?void 0:k.trashTab)??"Trash",loading:(($=a.labels)==null?void 0:$.loading)??"Loading…",emptyLibrary:((j=a.labels)==null?void 0:j.emptyLibrary)??"No media yet — upload your first creation.",emptyTrash:((Z=a.labels)==null?void 0:Z.emptyTrash)??"Trash is empty.",orphanedBadge:((K=a.labels)==null?void 0:K.orphanedBadge)??"Not in use",selectedCount:((ge=a.labels)==null?void 0:ge.selectedCount)??(te=>`${te} selected`),deleteButton:((we=a.labels)==null?void 0:we.deleteButton)??"Delete",restoreButton:((ne=a.labels)==null?void 0:ne.restoreButton)??"Restore",purgeAfter:((N=a.labels)==null?void 0:N.purgeAfter)??(te=>`Purges ${te}`),ownerLabel:((L=a.labels)==null?void 0:L.ownerLabel)??(te=>`User ${te.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),m=e.computed(()=>s.value.emptyLibrary),h=e.computed(()=>s.value.emptyTrash),p=e.computed(()=>s.value.orphanedBadge),v=e.computed(()=>s.value.deleteButton),g=e.computed(()=>s.value.restoreButton),w=e.ref("library"),M=e.ref({scope:"library"}),V=e.ref({}),b=bs({httpClient:a.httpClient,view:M,filters:V,perPage:50}),f=e.computed(()=>b.items.value),_=e.computed(()=>b.loading.value),D=e.computed(()=>{var I;return((I=b.error.value)==null?void 0:I.message)??null}),B=xc(f),E=su({httpClient:a.httpClient}),S=lu({httpClient:a.httpClient});function P(I){return s.value.selectedCount(I)}function C(I){return s.value.purgeAfter(I)}function A(I){return s.value.ownerLabel(I)}async function R(){const I=B.selectedItems.value;if(I.length===0)return;const F=r.value.canDelete?I.filter(k=>r.value.canDelete(k)):I;if(F.length!==0&&!(a.confirmBulkDelete&&!await a.confirmBulkDelete(F)))try{const k=F.map(Z=>Z.uuid),j=(await E.deleteMany(k)).results.filter(Z=>Z.status==="trashed"||Z.status==="already_trashed").map(Z=>Z.uuid);if(j.length>0){for(const Z of j)B.deselect(Z);i("deleted",j),await b.refresh(),r.value.showTrash!==!1&&await S.fetch(S.currentPage.value).catch(()=>{})}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function W(I){var F;try{const k=await S.restore(I);if(k.status==="restored"){i("restored",I),await b.refresh().catch(()=>{});return}if(k.status==="duplicate_conflict"){i("restore-conflict",{uuid:I,duplicateUuid:k.duplicate_uuid??null}),(F=a.onRestoreCollision)==null||F.call(a,I,k.duplicate_uuid??null);return}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function O(){w.value="trash",S.items.value.length===0&&!S.isLoading.value&&await S.fetch().catch(I=>{i("error",I instanceof Error?I:new Error(String(I)))})}return e.watch(w,async I=>{I==="library"&&f.value.length===0&&!_.value&&await b.refresh().catch(()=>{})}),e.onMounted(async()=>{await b.refresh().catch(I=>{i("error",I instanceof Error?I:new Error(String(I)))}),r.value.showTrash!==!1&&S.fetch().catch(()=>{})}),n({refresh:()=>b.refresh(),refreshTrash:()=>S.fetch(),selection:B,deletion:E,trash:S}),(I,F)=>(e.openBlock(),e.createElementBlock("div",y5,[e.createElementVNode("header",b5,[e.createElementVNode("h2",w5,e.toDisplayString(l.value),1),e.createElementVNode("div",k5,[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:F[0]||(F[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:O},[e.createTextVNode(e.toDisplayString(d.value)+" ",1),e.unref(S).total.value>0?(e.openBlock(),e.createElementBlock("span",_5,e.toDisplayString(e.unref(S).total.value),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)])]),w.value==="library"?(e.openBlock(),e.createElementBlock("section",E5,[_.value?(e.openBlock(),e.createElementBlock("div",x5,e.toDisplayString(u.value),1)):D.value?(e.openBlock(),e.createElementBlock("div",C5,e.toDisplayString(D.value),1)):f.value.length===0?(e.openBlock(),e.createElementBlock("div",S5,e.toDisplayString(m.value),1)):(e.openBlock(),e.createElementBlock("ul",V5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,k=>(e.openBlock(),e.createElementBlock("li",{key:k.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(B).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(B).isSelected(k.uuid),onClick:$=>e.unref(B).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,M5)):(e.openBlock(),e.createElementBlock("span",B5,e.toDisplayString(k.file_name),1))],8,T5),e.createElementVNode("div",F5,[e.createElementVNode("span",I5,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(A(k)),9,$5)):e.createCommentVNode("",!0),k.is_orphaned?(e.openBlock(),e.createElementBlock("span",R5,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0)])],10,N5))),128))])),e.unref(B).selectedCount.value>0&&r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("footer",D5,[e.createElementVNode("span",A5,e.toDisplayString(P(e.unref(B).selectedCount.value)),1),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(E).isDeleting.value,onClick:R},e.toDisplayString(v.value),9,L5)])):e.createCommentVNode("",!0)])):w.value==="trash"?(e.openBlock(),e.createElementBlock("section",U5,[e.unref(S).isLoading.value?(e.openBlock(),e.createElementBlock("div",O5,e.toDisplayString(u.value),1)):e.unref(S).items.value.length===0?(e.openBlock(),e.createElementBlock("div",P5,e.toDisplayString(h.value),1)):(e.openBlock(),e.createElementBlock("ul",z5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(S).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",W5,[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,Z5)):e.createCommentVNode("",!0)]),e.createElementVNode("div",H5,[e.createElementVNode("span",X5,e.toDisplayString(k.file_name),1),k.purge_after?(e.openBlock(),e.createElementBlock("span",G5,e.toDisplayString(C(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(S).isRestoring.value,onClick:$=>W(k.uuid)},e.toDisplayString(g.value),9,J5)],8,j5))),128))]))])):e.createCommentVNode("",!0)]))}}),q5=Me(Y5,[["__scopeId","data-v-ec535782"]]);exports.AlbumBrowser=Pd;exports.AlbumManager=HV;exports.AlbumMediaGrid=o4;exports.AlbumTree=Od;exports.ArrayBufferTarget=Qr;exports.ExistingMediaSelector=_h;exports.ImageEditor=fc;exports.ImageEditorModal=hc;exports.LiveStreamManager=bV;exports.ManagedMediaGallery=Ym;exports.MediaAlbumInlineCreate=zd;exports.MediaAlbumUnavailableState=jd;exports.MediaAttachment=QN;exports.MediaAttachmentMetadataFields=m5;exports.MediaCollection=WN;exports.MediaCollectionDropzone=xs;exports.MediaCollectionItem=Cs;exports.MediaLibraryPicker=au;exports.MediaLibraryPickerModal=O3;exports.MediaManagementView=q5;exports.MediaPreviewSheet=Wd;exports.MediaSelectionTray=q3;exports.MediaSourceSheet=Zd;exports.MediaThumbnailCell=Xd;exports.MediaUploadSheet=Hd;exports.MediaWorkspace=Hm;exports.ModelMediaManager=Wf;exports.Muxer=Oc;exports.VideoEditor=Rd;exports.VideoEditorDialog=nE;exports.VideoEditorSimple=SE;exports.VideoExportPanel=iC;exports.VideoJobClient=vi;exports.VideoPlayer=Ad;exports.VideoTimeline=YE;exports.VideoToolsPanel=Ux;exports.VideoUploader=HC;exports.VirtualMediaGrid=Gd;exports._sfc_main=e5;exports._sfc_main$1=t5;exports._sfc_main$2=r5;exports.applyTemporaryMediaStoreConfig=cc;exports.configureMediaStore=na;exports.createAdapter=ou;exports.createEmptyEditorState=Sm;exports.createImageEditor=Q3;exports.createMediablesAdapter=_s;exports.createSpatieAdapter=Es;exports.deserializeEditorState=Cm;exports.formatFileSize=Zo;exports.fromMediaArray=Wr;exports.getFileExtension=Jd;exports.getImageDimensions=Yd;exports.getMediablesAdapter=eN;exports.getSpatieAdapter=aN;exports.isImageFile=vs;exports.normalizeEditorState=Zr;exports.normalizeRecipeForServerRender=A_;exports.recipeHasServerRenderableEdits=D_;exports.recipeHasUnsupportedServerEdits=Dd;exports.resetMediablesAdapter=tN;exports.resetSpatieAdapter=oN;exports.restoreMediaStoreConfig=lc;exports.serializeEditorState=rc;exports.snapshotMediaStoreConfig=sc;exports.toFormValues=ks;exports.useAdminMediaStore=dc;exports.useAlbumDragDrop=Ud;exports.useAlbumStore=yi;exports.useAlbums=Ld;exports.useGlobalImageEditor=K3;exports.useImageEditorModal=ws;exports.useMediaAttachment=Ss;exports.useMediaCollection=bi;exports.useMediaDeletion=su;exports.useMediaDragSort=iu;exports.useMediaLibraryPickerController=nu;exports.useMediaLibraryQuery=bs;exports.useMediaLibrarySession=Qd;exports.useMediaLibraryStateMachine=eu;exports.useMediaLibraryTelemetry=tu;exports.useMediaStore=$t;exports.useMediaTrash=lu;exports.useMediaUploadQueue=ys;exports.useMediaValidation=gs;exports.validateFile=qd;
342
- //# sourceMappingURL=index-DNo3Kr1t.cjs.map