@codingfactory/mediables-vue 2.6.2 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-DJsxS-v6.js → PixiFrameExporter-BcywK0MP.js} +2 -2
- package/dist/{PixiFrameExporter-DJsxS-v6.js.map → PixiFrameExporter-BcywK0MP.js.map} +1 -1
- package/dist/{PixiFrameExporter-CUqM394V.cjs → PixiFrameExporter-CqKXaoCX.cjs} +2 -2
- package/dist/{PixiFrameExporter-CUqM394V.cjs.map → PixiFrameExporter-CqKXaoCX.cjs.map} +1 -1
- package/dist/components/video/VideoEditorDialog.vue.d.ts +10 -2
- package/dist/components/video/VideoEditorV2.vue.d.ts +2 -0
- package/dist/components/video/ui-v2/InspectorPanel.vue.d.ts +13 -0
- package/dist/components/video/ui-v2/SplitPanelLayout.vue.d.ts +20 -0
- package/dist/components/video/ui-v2/VideoBottomDrawer.vue.d.ts +14 -0
- package/dist/index-DNo3Kr1t.cjs +342 -0
- package/dist/index-DNo3Kr1t.cjs.map +1 -0
- package/dist/{index-CtHJav8G.js → index-DpkdpuMs.js} +10583 -9657
- package/dist/index-DpkdpuMs.js.map +1 -0
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index-BUrSZVu3.cjs +0 -342
- package/dist/index-BUrSZVu3.cjs.map +0 -1
- package/dist/index-CtHJav8G.js.map +0 -1
package/dist/index-BUrSZVu3.cjs
DELETED
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";var rm=Object.defineProperty;var sm=(o,n,t)=>n in o?rm(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var G=(o,n,t)=>sm(o,typeof n!="symbol"?n+"":n,t);const Uo=require("pinia"),e=require("vue"),We=require("pixi.js"),oe=require("./editor-BTwIhrcA.cjs"),O=require("@ionic/vue"),lm=require("pixi-filters");function cm(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 qe=cm(We),nr=1,dm=new Set(["free","square","circle"]);function um(o){const n=typeof o;return n==="string"||n==="number"||n==="boolean"}function mm(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 Sr(o){if(!o||typeof o!="object")return null;const n=o;if(n.version!==nr)return null;const t=n.crop,a=t&&mm(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&dm.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))um(p)&&(u[h]=p);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:nr,crop:{rect:a,aspectRatio:r,shape:i},filters:l}}function Gl(o){const n=Sr(o);return n?JSON.stringify(n):null}function pm(o){try{const n=JSON.parse(o);return Sr(n)}catch{return null}}function fm(){return{version:nr,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Nt={apiBaseUrl:"/api/v1",isAdmin:!1};function Hn(o){Nt={...Nt,...o}}function Jl(){return{...Nt}}function Yl(o){Nt={...o}}function ql(o){const n=Jl();return Hn(o),()=>{Yl(n)}}const hm=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()},St=Uo.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),y=e.ref({}),w=5*60*1e3,N=e.computed(()=>{if(Nt.apiScope)return Nt.apiScope;if(Nt.isAdmin)return"admin"}),C=e.computed(()=>N.value==="admin");function b(){return Nt.httpClient||hm}function f(ie){const pe=Nt.apiBaseUrl||"/api/v1",ke=N.value?`/${N.value}`:"";return`${pe}${ke}${ie}`}function _(ie,pe){return`${N.value??"default"}-${ie}-${JSON.stringify(pe)}`}function $(ie){return Date.now()-ie<w}function T(){v.value.clear(),y.value={}}function x(ie){if(!ie||!ie.data)return;const pe={};ie.data.forEach(ke=>{const re=`${ke.file_name}-${ke.collection_name||"default"}`,ce=pe[re];(!ce||Object.keys(ke.generated_conversions||{}).length>Object.keys(ce.generated_conversions||{}).length)&&(pe[re]=ke)}),o.value=Object.values(pe),ie.meta&&(i.value=ie.meta.current_page,r.value=Math.ceil(ie.meta.total/ie.meta.per_page))}async function I(ie=1,pe={}){const ke=_(ie,pe),re=v.value.get(ke);if(re&&$(re.timestamp)){const ce=re.data;return x(ce),ce}t.value=!0,a.value=null;try{const ce=new URLSearchParams;ce.append("page",ie.toString()),ce.append("per_page",s.value.toString()),C.value&&ce.append("linked","1");for(const ut in pe)if(Object.prototype.hasOwnProperty.call(pe,ut)){const He=pe[ut];He!=null&&He!==""&&ce.append(ut,String(He))}const Ve=await b()(f(`/media?${ce}`));return v.value.set(ke,{data:Ve,timestamp:Date.now()}),x(Ve),Ve}catch(ce){throw a.value=ce instanceof Error?ce.message:"Failed to fetch media",o.value=[],new Error(a.value)}finally{t.value=!1}}async function Z(ie,pe){t.value=!0,a.value=null;const ke=`${ie.name}-${Date.now()}`,re={file:ie,progress:0,status:"uploading"};m.value.set(ke,re);try{const ce=new FormData;ce.append("file",ie),ce.append("collection",pe.collection),pe.ownerUuid&&(ce.append("owner_uuid",pe.ownerUuid),ce.append("owner_type",pe.ownerType||"")),pe.usageUuid&&(ce.append("usage_uuid",pe.usageUuid),ce.append("usage_type",pe.usageType||""),ce.append("usage_purpose",pe.usagePurpose||"")),pe.customProperties&&ce.append("custom_properties",JSON.stringify(pe.customProperties));const Ve=await b()(f("/media"),{method:"POST",body:ce});return re.status="completed",re.progress=100,re.media=Ve==null?void 0:Ve.data,i.value===1&&(Ve!=null&&Ve.data)&&(o.value=[Ve.data,...o.value]),T(),(Ve==null?void 0:Ve.data)||null}catch(ce){throw re.status="error",re.error=ce instanceof Error?ce.message:"Upload failed",a.value=re.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(ke)},5e3)}}async function S(ie){t.value=!0,a.value=null;const pe=o.value.findIndex(re=>re.uuid===ie);let ke;pe!==-1&&(ke=o.value.splice(pe,1)[0]);try{return await b()(f(`/media/${ie}`),{method:"DELETE"}),p.value.delete(ie),T(),!0}catch(re){throw ke&&pe!==-1&&o.value.splice(pe,0,ke),a.value=re instanceof Error?re.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function L(ie,pe){t.value=!0,a.value=null;try{const re=await b()(f(`/media/${ie}`),{method:"PATCH",body:pe,data:pe});if(re!=null&&re.data){const ce=o.value.findIndex(_e=>_e.uuid===ie);return ce!==-1&&(o.value[ce]={...o.value[ce],...re.data}),T(),re.data}return null}catch(ke){throw a.value=ke instanceof Error?ke.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function R(){t.value=!0,a.value=null;try{const pe=await b()(f("/media/collections"));return n.value=(pe==null?void 0:pe.data)||[],n.value}catch(ie){throw a.value=ie instanceof Error?ie.message:"Failed to fetch collections",n.value=[],new Error(a.value)}finally{t.value=!1}}async function P(ie,pe,ke="images",re){d.value=!0,u.value=null;try{const ce=new URLSearchParams;ce.append("collection",ke),re&&ce.append("search",re);const Ve=await b()(f(`/media/model/${ie}/${pe}?${ce}`));return Ve!=null&&Ve.data?(c.value=Ve.data,Ve.data):[]}catch(ce){throw u.value=ce instanceof Error?ce.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function A(ie,pe,ke,re="images"){d.value=!0,u.value=null;const ce=[...c.value];try{const Ve=await b()(f(`/media/model/${ie}/${pe}/attach`),{method:"POST",body:{media_uuids:ke,collection:re}});return await P(ie,pe,re),(Ve==null?void 0:Ve.data)||[]}catch(_e){throw c.value=ce,u.value=_e instanceof Error?_e.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function B(ie,pe,ke,re="images"){d.value=!0,u.value=null;const ce=[...c.value];c.value=c.value.filter(_e=>_e.uuid!==ke);try{return await b()(f(`/media/model/${ie}/${pe}/detach`),{method:"POST",body:{media_uuid:ke,collection:re}}),!0}catch(_e){throw c.value=ce,u.value=_e instanceof Error?_e.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function D(ie,pe,ke,re="images"){d.value=!0,u.value=null;const ce=[...c.value],_e=new Map(c.value.map(Ve=>[Ve.uuid,Ve]));c.value=ke.map(Ve=>_e.get(Ve)).filter(Ve=>Ve!==void 0);try{return await b()(f(`/media/model/${ie}/${pe}/reorder`),{method:"POST",body:{media_uuids:ke,collection:re}}),!0}catch(Ve){throw c.value=ce,u.value=Ve instanceof Error?Ve.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function k(ie,pe,ke={}){const re=b(),ce=Nt.apiBaseUrl||"/api/v1",_e=new FormData,Ve=pe.imageData,ut=Ve.match(/^data:(image\/\w+);base64,/),He=ut?ut[1]:"image/png",xt=Ve.replace(/^data:image\/\w+;base64,/,""),Ge=atob(xt),at=new Uint8Array(Ge.length);for(let yt=0;yt<Ge.length;yt++)at[yt]=Ge.charCodeAt(yt);const Ct=new Blob([at],{type:He});_e.append("image_file",Ct,`edited.${He==="image/jpeg"?"jpg":"png"}`);const $t=Gl(pe.state);$t&&_e.append("editor_state",$t),pe.metadata&&(_e.append("filters",JSON.stringify(pe.metadata.filters)),pe.metadata.cropRect&&_e.append("crop_data",JSON.stringify(pe.metadata.cropRect))),_e.append("save_as_new","true"),ke.asVariant&&_e.append("as_variant","true"),ke.name!==void 0&&_e.append("name",ke.name);const lt=await re(`${ce}/editor/${ie}/save`,{method:"POST",body:_e});if("media"in lt&<.media)return lt.media;if("status_url"in lt&<.status_url)return F(re,lt.status_url,ke.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function F(ie,pe,ke){const re=Date.now(),ce=2e3;for(;Date.now()-re<ke;){await new Promise(Ve=>setTimeout(Ve,ce));const _e=await ie(pe);if(_e.status==="completed"&&_e.media)return _e.media;if(_e.status==="failed")throw new Error(_e.error??"Image processing failed")}throw new Error("Image processing timed out")}function H(ie,pe,ke){l.value=ke!==void 0?{type:ie,uuid:pe,collection:ke}:{type:ie,uuid:pe},y.value[`${ie}-${pe}`]={timestamp:Date.now()}}function j(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function te(){if(!l.value.type||!l.value.uuid)return;const ie=await P(l.value.type,l.value.uuid,l.value.collection||"images");c.value=ie||[]}function he(){o.value.forEach(ie=>p.value.add(ie.uuid))}function ge(){p.value.clear()}function ae(ie){p.value.has(ie)?p.value.delete(ie):p.value.add(ie)}function V(ie){return p.value.has(ie)}function U(){return Array.from(m.value.values()).some(ie=>ie.status==="uploading")}function K(ie){return m.value.get(ie)||h.value.get(ie)}function ee(){return[...Array.from(m.value.values()),...Array.from(h.value.values())]}async function ne(){const ie=Array.from(p.value);let pe=0;for(const ke of ie)try{await S(ke),pe++}catch{}return ge(),pe}function fe(ie,pe){var ke;return pe&&((ke=ie.conversion_urls)!=null&&ke[pe])?ie.conversion_urls[pe]||"":ie.original_url||ie.url||""}return{items:o,collections:n,loading:t,error:a,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:C,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:h,cachedResponses:y,fetchMedia:I,uploadFile:Z,deleteMedia:S,updateMedia:L,clearCache:T,fetchCollections:R,fetchModelMedia:P,attachMedia:A,detachMedia:B,reorderMedia:D,saveEditedImage:k,setModelContext:H,clearModelContext:j,refreshModelMedia:te,selectAllItems:he,clearSelection:ge,toggleSelection:ae,isSelected:V,deleteSelectedItems:ne,getHttpClient:b,getApiUrl:f,hasActiveUploads:U,getUploadProgress:K,getAllUploadProgress:ee,getMediaUrl:fe}}),Kl=()=>((Nt.apiScope!=="admin"||Nt.isAdmin!==!0)&&Hn({...Nt,apiScope:"admin",isAdmin:!0}),St());class Ql{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=oe.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),oe.EDITOR_CATEGORIES.forEach(t=>{const a=oe.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=oe.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,a.appendChild(i)}a.appendChild(oe.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 ec{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=oe.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=oe.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=oe.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=oe.checkmark),i.appendChild(r);const s=oe.el("div",{className:"filter-row-body"});s.appendChild(oe.el("span",{className:"filter-row-name"},n.name));const l=this._buildSummary(n,t);l&&s.appendChild(oe.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const c=oe.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=oe.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(oe.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 tc{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=oe.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(oe.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(n);if(!t){this.element.appendChild(oe.el("div",{className:"no-filter-selected"},"Filter not found"));return}const a=oe.el("div",{className:"controls-header"});a.appendChild(oe.el("span",{className:"controls-title"},t.name)),a.appendChild(oe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(n)})),this.element.appendChild(a);const i=oe.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 oe.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 oe.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 oe.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 oe.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 oe.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=oe.el("div",{className:"button-control"});return l.appendChild(oe.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 vm{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=oe.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=oe.el("div",{className:"panel-section-title"});if(a.appendChild(oe.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&a.appendChild(oe.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(oe.el("div",{className:"active-empty"},"No filters applied"));return}const i=oe.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=oe.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-active-${n.id}`});a.appendChild(oe.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=oe.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=oe.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 On=["collapsed","half","full"];class gm{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=oe.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=oe.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=oe.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=oe.el("div",{className:"drawer-header"}),n&&this._headerSlot.appendChild(n),this.element.appendChild(this._headerSlot),this._body=oe.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={}){On.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=On.indexOf(this._snap),t=On[(n+1)%On.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=On[0],a=1/0;for(const i of On){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 ym{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=oe.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=oe.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=oe.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 Ql(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new ec(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 tc(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=oe.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});a.innerHTML=oe.chevronLeft,this._headerEl.appendChild(a)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(oe.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const a=this.state.get("selectedFilter");a&&this._headerEl.appendChild(oe.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=oe.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=oe.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=oe.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=oe.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-mobile-chip-${n.id}`});a.appendChild(oe.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=oe.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=oe.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 js="(max-width: 900px)";class wm{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=oe.el("div",{className:"editor-v2-body"}),this.canvasSection=oe.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=oe.el("div",{className:"canvas-container"}),this.cropOverlay=oe.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,js).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(js),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=oe.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new Ql(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const n=oe.el("div",{className:"panel-body"});this._desktopFilterListSection=oe.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(oe.el("div",{className:"panel-section-title"},oe.el("span",{},"Filters"))),this._filterListView=new ec(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 tc(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=oe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),n.appendChild(this._desktopCropWrapper),this._activeStack=new vm(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 gm({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new ym(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=oe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const a=oe.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 km extends oe.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?oe.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=oe.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 oe.PixiRenderer,this._filterManager=new oe.FilterManager(this._state,this._renderer),this._cropManager=new oe.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new oe.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=oe.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=oe.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new wm(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=oe.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 oe.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new oe.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=oe.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=oe.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=oe.el("div",{className:"editor-loading-overlay"},oe.el("div",{className:"editor-loading-spinner"}),oe.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=oe.getFilter(o);if(t||(oe.registerCorePixiFilters(),t=oe.getFilter(o)),!t){try{const r=oe.getAllFilters()}catch{}return null}const a={...t.defaultParams,...n};return t.createFilter(a)}catch{return null}}const Di=78e5,Em=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:Di});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},y=v.width*v.height,w=y>Di?Math.sqrt(Di/Math.max(1,y)):1,N={width:Math.max(1,Math.floor(v.width*w)),height:Math.max(1,Math.floor(v.height*w))};a("save",{imageData:m,dimensions:N,state:h})}function c(){a("cancel")}function d(){if(!i.value||r)return;window.PIXI=qe,oe.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"?km:oe.VanillaImageEditor;r=new h(i.value,m),r.setFilterRegistry({getAllFilters:oe.getAllFilters,getFilter:oe.getFilter,getFiltersByCategory:oe.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))}}),Ce=(o,n)=>{const t=o.__vccOpts||o;for(const[a,i]of n)t[a]=i;return t},nc=Ce(Em,[["__scopeId","data-v-24c46711"]]),xm={class:"editor-modal-panel"},Cm={class:"editor-fill"},Sm=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=y=>{a("error",y)},d=()=>{e.nextTick(()=>{if(i.value){const y=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");y&&y.focus()}})};e.watch(()=>t.modelValue,y=>{r.value=y,y&&(l.value=document.activeElement,d())},{immediate:!0});const u=y=>{try{s.value=!0,a("save",y)}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=y=>{if(y.key==="Escape"&&r.value&&!s.value){p();return}if(y.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 N=w[0],C=w[w.length-1];y.shiftKey&&document.activeElement===N?(y.preventDefault(),C.focus()):!y.shiftKey&&document.activeElement===C&&(y.preventDefault(),N.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(y,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",xm,[e.createElementVNode("div",Cm,[e.createVNode(nc,{"initial-image":y.initialImage,"initial-state":y.initialState,"session-key":y.sessionKey,theme:y.theme,"crop-shape":y.cropShape,preset:y.preset,"editor-version":y.editorVersion,"primary-color":y.primaryColor,"secondary-color":y.secondaryColor,"save-button-color":y.saveButtonColor,"download-button-color":y.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)]))}}),ac=Ce(Sm,[["__scopeId","data-v-adf95668"]]),Vm={class:"media-workspace"},Nm={class:"media-workspace-toolbar"},Tm={class:"media-workspace-label"},Mm=["value"],Bm={class:"media-workspace-grid"},Im=["onClick"],Fm=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=St(),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=ql({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",Vm,[e.createElementVNode("div",Nm,[e.createElementVNode("label",Tm,[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,Mm))),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",Bm,[(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:y=>a("preview",v)},e.toDisplayString(v.file_name),9,Im))),128))])]))}}),$m=Ce(Fm,[["__scopeId","data-v-895f26fe"]]),Rm={class:"managed-media-gallery"},Dm={class:"gallery-grid"},Am=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",Rm,[e.createElementVNode("div",Dm,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Lm=Ce(Am,[["__scopeId","data-v-a60fdcd7"]]),Um="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>",Vr="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>",Om="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>",Nr="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>",zm="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>",Pm="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>",ha="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>",Wm="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>",oc="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>",ic="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>",Zs="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",jm="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>",Zm="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>",Hs="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Xn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 368L144 144M368 144L144 368' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Xs="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>",Hm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='184' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='344' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='168' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='144' cy='208' r='32'/><circle cx='152' cy='311' r='32'/><circle cx='224' cy='144' r='32'/><circle cx='256' cy='367' r='48'/><circle cx='328' cy='144' r='32'/></svg>",Xm="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>",ca="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>",Gm="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>",Jm="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>",Gs="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>",rc="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>",Va="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>",Ym="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>",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' 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>",Km="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>",va="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>",Js="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>",Ai="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>",Qm="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>",ep="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>",Li="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>",tp="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>",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' 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>",ap="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>",op="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>",sc="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>",lc="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>",ip="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>",rp="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>",sp="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>",lp="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>",cc="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>",cp="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>",dp="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>",dc="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>",up="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>",mp="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>",qn="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>",pp="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>",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='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ys="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>",Tr="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>",hp="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>",Ui="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",pn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",da="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>",qs="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>",vp="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>",uc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",gp="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>",mc="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>",yp="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>",wp="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>",kp="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>",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-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>",xp="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>",to="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 Ks=()=>{};function Cp(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 Sp(o,n={}){let t,a,i=Ks;const r=c=>{clearTimeout(c),i(),i=Ks};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 Vp(o,n=200,t={}){return Cp(Sp(n,t),o)}const ua=new Map;function Np(o){const n=e.getCurrentScope();function t(l){var c;const d=ua.get(o)||new Set;d.add(l),ua.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=ua.get(o);c&&(c.delete(l),c.size||r())}function r(){ua.delete(o)}function s(l,c){var d;(d=ua.get(o))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:i,emit:s,reset:r}}function pc(){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 fc(o){const n=e.ref(new Set),t=e.ref(null),a=e.ref(-1),i=Np("media-selection"),r=pc(),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($=>$.uuid===_),n.value.size===1&&r.selection())}function h(_){n.value.add(_),t.value=_,a.value=o.value.findIndex($=>$.uuid===_)}function p(_){n.value.delete(_),t.value===_&&(t.value=null,a.value=-1)}function v(){o.value.forEach(_=>n.value.add(_.uuid))}function y(){n.value.clear(),t.value=null,a.value=-1}function w(){c.value?y():v()}function N(_,$){const T=o.value.findIndex(x=>x.uuid===_);if(T!==-1)if($!=null&&$.shiftKey&&a.value!==-1){const x=Math.min(a.value,T),I=Math.max(a.value,T);for(let Z=x;Z<=I;Z++)n.value.add(o.value[Z].uuid)}else m(_)}function C(){if(o.value.length===0)return;let _=a.value+1;_>=o.value.length&&(_=0),y(),h(o.value[_].uuid)}function b(){if(o.value.length===0)return;let _=a.value-1;_<0&&(_=o.value.length-1),y(),h(o.value[_].uuid)}function f(_){switch(_.key){case"ArrowDown":_.preventDefault(),C();break;case"ArrowUp":_.preventDefault(),b();break;case"a":(_.ctrlKey||_.metaKey)&&(_.preventDefault(),v());break;case"Escape":_.preventDefault(),y();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:y,toggleAll:w,rangeSelect:N,selectNext:C,selectPrevious:b,handleKeydown:f,selectionBus:i}}const Tp={class:"flex items-center justify-between w-full px-4"},Mp={class:"p-4"},Bp={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Ip={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Fp=["value"],$p={class:"flex gap-2 mt-4"},Rp={class:"flex justify-end mb-4"},Dp={key:1,class:"flex justify-center items-center h-64"},Ap={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Lp={class:"text-sm text-theme-secondary"},Up={key:0},Op={class:"mb-4"},zp={class:"mb-4"},Pp={class:"flex gap-2"},Wp={class:"flex items-center justify-between px-4 py-2"},jp={class:"text-sm text-theme-secondary"},Zp={key:0},Hp={key:0},Xp={key:1},Gp={class:"flex gap-2"},Jp=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),y=e.ref(!0),w=e.ref(!1),N=Kl(),C=fc(c);function b(V){var pe;const U=V.conversion_urls||{},K=V.proxy_url||V.original_url||V.url||"",ee=U.thumb||U.preview||V.preview_url||V.thumbnail_url||K,ne=V.custom_properties||{},fe=ne.width,ie=ne.height;return{...V,uuid:V.uuid,name:V.name||V.file_name,file_name:V.file_name,filename:V.file_name,mime_type:V.mime_type,size:V.size,collection_name:V.collection_name||"images",disk:V.disk,original_url:K,url:K,thumbnail_url:ee,conversions:V.conversions||{},conversion_urls:U,generated_conversions:V.generated_conversions||{},custom_properties:ne,caption:V.caption||null,alt_text:V.alt_text||null,created_at:V.created_at,updated_at:V.updated_at,is_image:((pe=V.mime_type)==null?void 0:pe.startsWith("image/"))||!1,...typeof fe=="number"?{width:fe}:{},...typeof ie=="number"?{height:ie}:{},...V.formatted_size!==void 0?{formatted_size:V.formatted_size}:{}}}e.watch(()=>t.selectedItems,V=>{u.value=new Set(V),C.clear(),V.forEach(U=>C.select(U))});const f=e.computed(()=>{var U;let V=c.value;return(U=h.value.types)!=null&&U.length&&(V=V.filter(K=>{var ne,fe;const ee=(ne=K.mime_type)==null?void 0:ne.split("/")[0];return(fe=h.value.types)==null?void 0:fe.includes(ee)})),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&(V=V.filter(K=>{const ee=K.size/1048576;return!(h.value.sizeMin!==void 0&&ee<h.value.sizeMin||h.value.sizeMax!==void 0&&ee>h.value.sizeMax)})),V}),_=e.computed(()=>{var U;let V=0;return h.value.search&&V++,h.value.collection&&V++,(h.value.dateFrom||h.value.dateTo)&&V++,(U=h.value.types)!=null&&U.length&&(V+=h.value.types.length),(h.value.sizeMin!==void 0||h.value.sizeMax!==void 0)&&V++,V}),$=e.computed(()=>{const V=C.selectedCount.value;return V===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${V} ${V===1?"Item":"Items"}`:"Item"}`}),T=e.computed(()=>{const V=C.selectedCount.value;return!!(V===0||t.selectionMode==="single"&&V>1||t.maxSelection&&V>t.maxSelection)}),x=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function I(V=!0){V?(l.value=!0,c.value=[],v.value=1,y.value=!0):w.value=!0;try{const U={collection:h.value.collection||t.collection,per_page:24};switch((s.value||h.value.search)&&(U.search=s.value||h.value.search||""),h.value.dateFrom&&(U.from_date=h.value.dateFrom),h.value.dateTo&&(U.to_date=h.value.dateTo),i.value){case"recent":await N.fetchMedia(v.value,U),V?c.value=N.items.map(K=>b(K)):c.value=[...c.value,...N.items.map(K=>b(K))],y.value=N.currentPage<N.totalPages;break;case"model":if(t.modelType&&t.modelId){const K=await N.fetchModelMedia(t.modelType,t.modelId,U.collection,U.search);c.value=K?K.map(ee=>b(ee)):[],y.value=!1}break;case"library":await N.fetchMedia(v.value,U),V?c.value=N.items.map(K=>b(K)):c.value=[...c.value,...N.items.map(K=>b(K))],y.value=N.currentPage<N.totalPages;break}}catch{}finally{l.value=!1,w.value=!1}}async function Z(V){if(!y.value||w.value){V!=null&&V.target&&V.target.complete();return}v.value++,await I(!1),V!=null&&V.target&&(V.target.complete(),y.value||(V.target.disabled=!0))}function S(V){return V==="recent"||V==="model"||V==="library"}function L(V){i.value=V,I()}function R(V){typeof V=="string"&&S(V)&&L(V)}async function P(V){t.selectionMode==="single"?(C.clear(),C.select(V.uuid)):(C.toggle(V.uuid),t.maxSelection&&C.selectedCount.value>t.maxSelection&&(C.deselect(V.uuid),await(await O.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function A(){a("confirm",C.selectedItems.value)}function B(){a("close")}function D(V){}const k=e.ref(null),F=e.ref(!1);function H(V){k.value=V,F.value=!0}function j(V){const U=c.value.findIndex(ee=>ee.uuid===V.uuid);U!==-1&&(c.value[U]=V);const K={};V.alt_text!==void 0&&(K.alt_text=V.alt_text),V.caption!==void 0&&(K.caption=V.caption),V.custom_properties!==void 0&&(K.custom_properties=V.custom_properties),N.updateMedia(V.uuid,K)}function te(){I()}function he(){h.value={},s.value="",I()}const ge=Vp(()=>{I(!0)},300);e.watch(s,()=>{t.isOpen&&ge()});async function ae(V){try{await(await O.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 N.deleteMedia(V),await I()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,V=>{V&&I()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(V=>C.select(V))}),(V,U)=>{const K=e.resolveComponent("AdminMediaGrid"),ee=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(O.IonModal),{"is-open":V.isOpen,onDidDismiss:B,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(O.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{onClick:B},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(O.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Tp,[e.createVNode(e.unref(O.IonSegment),{value:i.value,onIonChange:U[0]||(U[0]=ne=>R(ne.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[15]||(U[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(O.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[16]||(U[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[17]||(U[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(O.IonButton),{fill:"clear",size:"small",onClick:U[1]||(U[1]=ne=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[_.value>0?(e.openBlock(),e.createBlock(e.unref(O.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(O.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Mp,[m.value?(e.openBlock(),e.createElementBlock("div",Bp,[e.createElementVNode("div",Ip,[e.createElementVNode("div",null,[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[18]||(U[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":U[2]||(U[2]=ne=>h.value.collection=ne),class:"w-full p-2 border rounded"},[U[19]||(U[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,ne=>(e.openBlock(),e.createElementBlock("option",{key:ne,value:ne},e.toDisplayString(ne),9,Fp))),128))],512),[[e.vModelSelect,h.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[20]||(U[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":U[3]||(U[3]=ne=>h.value.dateFrom=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[21]||(U[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":U[4]||(U[4]=ne=>h.value.dateTo=ne),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,h.value.dateTo]])])]),e.createElementVNode("div",$p,[e.createVNode(e.unref(O.IonButton),{size:"small",onClick:te},{default:e.withCtx(()=>[...U[22]||(U[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(O.IonButton),{size:"small",fill:"clear",onClick:he},{default:e.withCtx(()=>[...U[23]||(U[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":U[5]||(U[5]=ne=>s.value=ne),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Rp,[e.createVNode(e.unref(O.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:U[6]||(U[6]=ne=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(O.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:U[7]||(U[7]=ne=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",Dp,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",Ap,[e.createVNode(e.unref(O.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),U[24]||(U[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Lp,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(K,{key:3,"media-items":f.value,"selected-items":e.unref(C).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:P,onPreview:D,onEdit:H,onDelete:ae},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(O.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(ne,fe)=>(e.openBlock(),e.createBlock(ee,{key:ne.uuid,media:ne,selected:e.unref(C).isSelected(ne.uuid),"selection-mode":!0,index:fe,onToggleSelect:P,onPreview:D,onEdit:H,onDelete:ae},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(O.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:U[8]||(U[8]=ne=>Z(ne))},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(O.IonModal),{"is-open":F.value,onDidDismiss:U[14]||(U[14]=ne=>F.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(O.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{onClick:U[9]||(U[9]=ne=>F.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(O.IonTitle),null,{default:e.withCtx(()=>[...U[25]||(U[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(O.IonContent),{class:"p-4"},{default:e.withCtx(()=>[k.value?(e.openBlock(),e.createElementBlock("div",Up,[e.createElementVNode("div",Op,[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[26]||(U[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":U[10]||(U[10]=ne=>k.value.caption=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,k.value.caption]])]),e.createElementVNode("div",zp,[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...U[27]||(U[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":U[11]||(U[11]=ne=>k.value.alt_text=ne),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,k.value.alt_text]])]),e.createElementVNode("div",Pp,[e.createVNode(e.unref(O.IonButton),{onClick:U[12]||(U[12]=ne=>j(k.value))},{default:e.withCtx(()=>[...U[28]||(U[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(O.IonButton),{fill:"clear",onClick:U[13]||(U[13]=ne=>F.value=!1)},{default:e.withCtx(()=>[...U[29]||(U[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(O.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Wp,[e.createElementVNode("div",jp,[e.unref(C).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Zp,[e.createTextVNode(e.toDisplayString(e.unref(C).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Hp," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Xp," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Gp,[e.createVNode(e.unref(O.IonButton),{fill:"clear",onClick:B},{default:e.withCtx(()=>[...U[30]||(U[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(O.IonButton),{disabled:T.value,onClick:A},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Yp=Ce(Jp,[["__scopeId","data-v-9a8c0954"]]),qp={key:1,class:"flex flex-col items-center justify-center py-16"},Kp=["draggable","onDragstart","onDragover","onDrop"],Qp={key:0,class:"absolute top-2 left-2 z-20"},ef=["checked","onChange"],tf={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},nf=["data-media-id"],af={key:0,class:"w-full h-full flex items-center justify-center"},of=["src","alt","onError","onLoad"],rf={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},sf={class:"text-center"},lf={class:"text-4xl text-gray-400 mb-2"},cf={class:"text-sm font-medium text-gray-500"},df={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},uf=["onClick"],mf=["onClick"],pf=["onClick"],ff={class:"p-3"},hf={class:"text-sm font-medium truncate mb-1"},vf={class:"text-xs text-gray-600 dark:text-gray-400"},gf={key:0},yf={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=T=>t.selectedItems.some(x=>x.uuid===T.uuid),d=e.computed(()=>{const T=t.columns,x=["grid","gap-4"];switch(T.mobile){case 1:x.push("grid-cols-1");break;case 2:x.push("grid-cols-2");break;case 3:x.push("grid-cols-3");break;case 4:x.push("grid-cols-4");break;default:x.push("grid-cols-2");break}switch(T.sm){case 1:x.push("sm:grid-cols-1");break;case 2:x.push("sm:grid-cols-2");break;case 3:x.push("sm:grid-cols-3");break;case 4:x.push("sm:grid-cols-4");break;case 5:x.push("sm:grid-cols-5");break;default:x.push("sm:grid-cols-3");break}switch(T.md){case 2:x.push("md:grid-cols-2");break;case 3:x.push("md:grid-cols-3");break;case 4:x.push("md:grid-cols-4");break;case 5:x.push("md:grid-cols-5");break;case 6:x.push("md:grid-cols-6");break;default:x.push("md:grid-cols-4");break}switch(T.lg){case 3:x.push("lg:grid-cols-3");break;case 4:x.push("lg:grid-cols-4");break;case 5:x.push("lg:grid-cols-5");break;case 6:x.push("lg:grid-cols-6");break;case 7:x.push("lg:grid-cols-7");break;default:x.push("lg:grid-cols-5");break}switch(T.xl){case 4:x.push("xl:grid-cols-4");break;case 5:x.push("xl:grid-cols-5");break;case 6:x.push("xl:grid-cols-6");break;case 7:x.push("xl:grid-cols-7");break;case 8:x.push("xl:grid-cols-8");break;default:x.push("xl:grid-cols-6");break}return x.join(" ")});function u(T,x,I){t.reorderable&&(i.value=x,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/html","")))}function m(T,x){t.reorderable&&(T.preventDefault(),r.value=x)}function h(){r.value=null}function p(T,x){if(!t.reorderable||!i.value)return;T.preventDefault();const I=[...t.mediaItems],Z=I.findIndex(S=>{var L;return S.uuid===((L=i.value)==null?void 0:L.uuid)});if(Z!==-1&&Z!==x&&i.value){const[S]=I.splice(Z,1);I.splice(x,0,S),a("reorder",I)}i.value=null,r.value=null}function v(T){return T<1024?T+" B":T<1024*1024?(T/1024).toFixed(1)+" KB":(T/(1024*1024)).toFixed(1)+" MB"}function y(T){var I;return T.thumbnail_url||((I=T.conversion_urls)==null?void 0:I.thumb)||T.original_url||T.url||""}function w(T){var Z,S,L;const x=((Z=T.mime_type)==null?void 0:Z.startsWith("image/"))||!1,I=!!(T.thumbnail_url||(S=T.conversion_urls)!=null&&S.thumb||(L=T.conversion_urls)!=null&&L.preview||T.original_url||T.url);return x&&I}function N(T){var x;return((x=T.split(".").pop())==null?void 0:x.toUpperCase())||""}function C(T){var I;const x=((I=T.mime_type)==null?void 0:I.toLowerCase())||"";return x.startsWith("image/")?"image":x.startsWith("video/")?"videocam":x.startsWith("audio/")?"musical-notes":x.includes("pdf")?"document-text":x.includes("zip")||x.includes("rar")?"archive":x.includes("sheet")||x.includes("excel")?"grid":x.includes("document")||x.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(T=>{T.forEach(x=>{var I;if(x.isIntersecting){const Z=x.target.getAttribute("data-media-id");Z&&(s.value.add(Z),(I=l.value)==null||I.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function b(T){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var Z;const I=x.getAttribute("data-media-id");I&&!s.value.has(I)&&((Z=l.value)==null||Z.observe(x))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function _(T,x){const I=T.target;delete I.dataset.fallbackIndex}function $(T,x){const I=T.target,Z=I.closest("[data-media-id]"),S=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(L=>L&&L.trim()!==""&&L!==I.src);if(S.length>0&&I.dataset.fallbackIndex){const L=parseInt(I.dataset.fallbackIndex);if(L<S.length){I.dataset.fallbackIndex=(L+1).toString(),I.src=S[L]||"";return}}else if(S.length>0){I.dataset.fallbackIndex="1",I.src=S[0]||"";return}if(I.style.display="none",Z&&!Z.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">${C(x)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${N(x.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,Z.appendChild(R)}}return(T,x)=>T.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,I=>e.createElementVNode("div",{key:`skeleton-${I}`,class:"relative"},[...x[1]||(x[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!T.mediaItems||!T.mediaItems.length?(e.openBlock(),e.createElementBlock("div",qp,[x[2]||(x[2]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-16 h-16 text-gray-400 mb-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})],-1)),x[3]||(x[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),x[4]||(x[4]=e.createElementVNode("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-4"}," Upload some files to get started ",-1)),e.createElementVNode("button",{onClick:x[0]||(x[0]=I=>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(T.mediaItems,(I,Z)=>(e.openBlock(),e.createElementBlock("div",{key:I.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===Z}]),draggable:T.reorderable,onDragstart:S=>u(S,I),onDragover:S=>m(S,Z),onDragleave:h,onDrop:S=>p(S,Z)},[T.selectionMode?(e.openBlock(),e.createElementBlock("div",Qp,[e.createElementVNode("input",{type:"checkbox",checked:c(I),onChange:S=>a("toggleSelect",I),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,ef)])):e.createCommentVNode("",!0),T.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",T.selectionMode?"left-10":"left-2"])},[e.renderSlot(T.$slots,"badge",{media:I,index:Z},void 0,!0)],2)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",tf,[...x[5]||(x[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":c(I)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":I.uuid},[w(I)&&!b(I.uuid)?(e.openBlock(),e.createElementBlock("div",af,[...x[6]||(x[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),w(I)&&b(I.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:y(I),alt:I.alt_text||I.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:S=>$(S,I),onLoad:S=>_(S)},null,40,of)):(e.openBlock(),e.createElementBlock("div",rf,[e.createElementVNode("div",sf,[e.createElementVNode("div",lf,e.toDisplayString(C(I)),1),e.createElementVNode("p",cf,e.toDisplayString(N(I.file_name)),1)])])),e.createElementVNode("div",df,[e.createElementVNode("button",{onClick:S=>a("preview",I),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...x[7]||(x[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,uf),T.showEditButton&&w(I)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:S=>a("edit",I),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...x[8]||(x[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})],-1)])],8,mf)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:S=>a("delete",I.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...x[9]||(x[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,pf)])],8,nf),e.createElementVNode("div",ff,[e.createElementVNode("h4",hf,e.toDisplayString(I.file_name),1),e.createElementVNode("p",vf,[e.createTextVNode(e.toDisplayString(v(I.size))+" ",1),I.width&&I.height?(e.openBlock(),e.createElementBlock("span",gf," • "+e.toDisplayString(I.width)+"x"+e.toDisplayString(I.height),1)):e.createCommentVNode("",!0)]),I.caption?(e.openBlock(),e.createElementBlock("p",yf,e.toDisplayString(I.caption),1)):e.createCommentVNode("",!0)])],2)],42,Kp))),128))],2))}}),wf=Ce(bf,[["__scopeId","data-v-f0c343b7"]]),kf={class:"model-media-manager"},_f=["accept","multiple"],Ef={class:"flex items-center justify-between mb-4"},xf={key:0,class:"text-lg font-medium"},Cf={class:"flex gap-2"},Sf={key:0,class:"flex items-center justify-center py-8"},Vf={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"},Nf={class:"text-gray-600 dark:text-gray-400"},Tf={class:"flex gap-2 mt-4"},Mf={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Bf=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=St(),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),y=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),w=e.computed(()=>i.modelMedia.map(F=>F.uuid)),N=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function C(){Hn({isAdmin:t.mode==="admin"})}async function b(F){await(await O.toastController.create({message:F,duration:3e3,color:"danger",position:"bottom"})).present()}async function f(){if(!s.value)if(s.value=!0,C(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],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(F){const H=F instanceof Error?F.message:"Failed to fetch media";a("error",{operation:"fetch",message:H,details:F})}finally{r.value=!1,a("loading",!1)}}}e.watch(()=>i.modelMedia,F=>{s.value&&a("update:media",F)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,f()}),e.watch(()=>t.mode,()=>{C()}),e.onMounted(()=>{f()}),e.onUnmounted(()=>{i.clearModelContext()});function _(){return i.modelMedia.length>0}function $(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function T(F){var j,te,he;if(!((j=F.mime_type)!=null&&j.startsWith("image/")))return null;const H=F.original_url||F.url||((te=F.conversion_urls)==null?void 0:te.preview)||((he=F.conversion_urls)==null?void 0:he.thumb)||F.thumbnail_url;return H&&H.trim()!==""?H:null}function x(){l.value=!0}function I(){var F;(F=v.value)==null||F.click()}function Z(){l.value=!1}async function S(F){if(!t.allowEdit)return;const H=T(F);if(H){d.value=F,u.value++;try{const j=i.getHttpClient(),te=i.getApiUrl(""),he=await j(`${te.replace(/\/$/,"")}/editor/${F.uuid}/edit`);h.value=he.editable_source_url||H,m.value=he.editor_state??null}catch{h.value=H,m.value=null}c.value=!0}}function L(){c.value=!1,d.value=null,h.value=void 0,m.value=null}async function R(F){if(!d.value)throw new Error("No media selected for editing");const H=d.value,j=t.editMode==="variant";try{p.value=null;const te=await i.saveEditedImage(H.uuid,F,{asVariant:j,name:H.file_name});j||await i.detachMedia(t.mediableType,t.mediableId,H.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[te.uuid],t.collection),a("edit-complete",{originalMedia:H,editedMedia:te,mode:t.editMode}),c.value=!1,d.value=null}catch(te){const he=te instanceof Error?te.message:"Failed to save edited image";throw p.value=he,await b(he),te}}function P(F){if(p.value===F.message){p.value=null;return}b(F.message)}async function A(F){const H=F.target,j=H.files;if(!(!j||j.length===0)){for(let te=0;te<j.length;te++){const he=j[te];if(y.value!==void 0&&y.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(he.type)){a("error",{operation:"upload",message:`File type ${he.type} is not accepted`,details:{file:he.name}});continue}if(t.maxFileSize!==void 0&&he.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:he.name,size:he.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:he});try{const ge=await i.uploadFile(he,{collection:t.collection});ge!=null&&ge.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[ge.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:he}),a("attach",[ge]))}catch(ge){const ae=ge instanceof Error?ge.message:"Upload failed";a("error",{operation:"upload",message:ae,details:ge}),a("upload-progress",{status:"error",progress:0,file:he,error:ae})}}H.value=""}}async function B(F){const H=F.map(j=>j.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,H,t.collection),a("reorder",i.modelMedia)}catch(j){const te=j instanceof Error?j.message:"Failed to reorder media";a("error",{operation:"reorder",message:te,details:j}),await b(te)}}async function D(F){const H=i.modelMedia.find(j=>j.uuid===F);try{await i.detachMedia(t.mediableType,t.mediableId,F,t.collection),H&&a("detach",H)}catch(j){const te=j instanceof Error?j.message:"Failed to detach media";a("error",{operation:"detach",message:te,details:j}),await b(te)}}async function k(F){l.value=!1;const H=F.map(he=>he.uuid),j=new Set(w.value);let te=Array.from(new Set(H)).filter(he=>!j.has(he));if(y.value!==void 0&&te.length>y.value&&(te=te.slice(0,y.value)),te.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,te,t.collection);const he=i.modelMedia.filter(ge=>te.includes(ge.uuid));a("attach",he)}catch(he){const ge=he instanceof Error?he.message:"Failed to attach media";a("error",{operation:"attach",message:ge,details:he})}}return(F,H)=>(e.openBlock(),e.createElementBlock("div",kf,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:N.value,multiple:y.value===void 0||y.value>1,class:"hidden","data-testid":"upload-input",onChange:A},null,40,_f),e.createElementVNode("div",Ef,[F.title?(e.openBlock(),e.createElementBlock("h3",xf,e.toDisplayString(F.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Cf,[F.allowBrowse?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:0,fill:"outline",size:"small",disabled:$(),"data-testid":"browse-button",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"start",icon:e.unref(Li)},null,8,["icon"]),H[1]||(H[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),F.allowUpload?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:1,fill:"solid",size:"small",disabled:$(),"data-testid":"upload-button",onClick:I},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"start",icon:e.unref(Xs)},null,8,["icon"]),H[2]||(H[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Sf,[e.createVNode(e.unref(O.IonSpinner),{"data-testid":"spinner"})])):_()?(e.openBlock(),e.createBlock(wf,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!F.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!F.allowEdit,"selection-mode":!1,onReorder:B,onDelete:D,onEdit:S},e.createSlots({_:2},[F.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:j})=>[j===0?(e.openBlock(),e.createElementBlock("div",Mf," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Vf,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Li),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Nf,e.toDisplayString(F.emptyText),1),e.createElementVNode("div",Tf,[F.allowBrowse?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"start",icon:e.unref(Li)},null,8,["icon"]),H[3]||(H[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),F.allowUpload?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:I},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"start",icon:e.unref(Xs)},null,8,["icon"]),H[4]||(H[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Yp,e.mergeProps({"is-open":l.value,"selected-items":w.value,collection:F.collection},y.value!==null&&y.value!==void 0?{maxSelection:y.value}:{},{onConfirm:k,onClose:Z}),null,16,["is-open","selected-items","collection"]),e.createVNode(ac,{modelValue:c.value,"onUpdate:modelValue":H[0]||(H[0]=j=>c.value=j),"initial-image":h.value,"initial-state":m.value,"session-key":u.value,onSave:R,onCancel:L,onError:P},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),If=Ce(Bf,[["__scopeId","data-v-f68e70ec"]]),Ff={class:"existing-media-selector","data-testid":"existing-media-selector"},$f={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},Rf=["data-testid"],Df={class:"existing-media-selector__section-header"},Af={class:"existing-media-selector__section-title"},Lf=["data-testid","aria-label","onClick"],Uf={class:"existing-media-selector__grid"},Of=["data-testid","aria-label","aria-pressed","onClick"],zf=["src","alt"],Pf={key:0,class:"existing-media-selector__selected-badge"},Wf={key:1,class:"existing-media-selector__caption"},jf={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},Zf={class:"existing-media-selector__section-header"},Hf={class:"existing-media-selector__section-title"},Xf={class:"existing-media-selector__albums"},Gf=["data-testid","aria-label","aria-pressed","onClick"],Jf={class:"existing-media-selector__album-name"},Yf={key:0,class:"existing-media-selector__album-count"},qf={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},Kf={class:"existing-media-selector__section-header"},Qf={class:"existing-media-selector__section-subtitle"},eh={key:0,class:"existing-media-selector__section-description"},th={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},nh={key:1,class:"existing-media-selector__grid"},ah=["data-testid","aria-label","aria-pressed","onClick"],oh=["src","alt"],ih={key:0,class:"existing-media-selector__selected-badge"},rh={key:1,class:"existing-media-selector__caption"},sh={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},lh={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},ch=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 y(f){a("select",f)}function w(f){a("update:activeAlbumId",f)}function N(f){var $;const _=($=f.description)==null?void 0:$.trim();return _&&_.length>0?`Select ${_}`:"Select existing media"}function C(f,_){var T;const $=(T=_.description)==null?void 0:T.trim();return typeof _.alt=="string"&&_.alt.trim().length>0?_.alt.trim():$&&$.length>0?$: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",Ff,[f.isLoading?(e.openBlock(),e.createElementBlock("div",$f," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,$=>(e.openBlock(),e.createElementBlock("section",{key:$.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${$.id}`},[e.createElementVNode("div",Df,[e.createElementVNode("h3",Af,e.toDisplayString($.title),1),v($)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${$.id}`,"aria-label":m($.id)?`Show fewer items from ${$.title}`:`Show more items from ${$.title}`,onClick:T=>h($.id)},e.toDisplayString(m($.id)?"See less":"See more"),9,Lf)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Uf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p($),T=>(e.openBlock(),e.createElementBlock("button",{key:T.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===T.id}]),"data-testid":`existing-media-item-${$.id}-${T.id}`,"aria-label":N(T),"aria-pressed":f.selectedId===T.id?"true":"false",onClick:x=>y(T)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:T.previewUrl,alt:C($,T)},null,8,zf),f.selectedId===T.id?(e.openBlock(),e.createElementBlock("div",Pf," Selected ")):e.createCommentVNode("",!0),T.description?(e.openBlock(),e.createElementBlock("div",Wf,e.toDisplayString(T.description),1)):e.createCommentVNode("",!0)],10,Of))),128))])],8,Rf))),128)),s.value?(e.openBlock(),e.createElementBlock("section",jf,[e.createElementVNode("div",Zf,[e.createElementVNode("h3",Hf,e.toDisplayString(f.albumBrowseTitle),1)]),e.createElementVNode("div",Xf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.albums,$=>(e.openBlock(),e.createElementBlock("button",{key:$.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":f.activeAlbumId===$.id}]),"data-testid":`existing-media-album-${$.id}`,"aria-label":b($),"aria-pressed":f.activeAlbumId===$.id?"true":"false",onClick:T=>w($.id)},[e.createElementVNode("span",Jf,e.toDisplayString($.name),1),typeof $.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",Yf,e.toDisplayString($.mediaCount),1)):e.createCommentVNode("",!0)],10,Gf))),128))]),e.createElementVNode("div",qf,[e.createElementVNode("div",Kf,[e.createElementVNode("div",null,[e.createElementVNode("h4",Qf,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",eh,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),f.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",th," Loading album... ")):f.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",nh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.activeAlbumItems,$=>(e.openBlock(),e.createElementBlock("button",{key:$.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":f.selectedId===$.id}]),"data-testid":`existing-media-item-album-${$.id}`,"aria-label":N($),"aria-pressed":f.selectedId===$.id?"true":"false",onClick:T=>y($)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:$.previewUrl,alt:$.alt||$.description||c.value},null,8,oh),f.selectedId===$.id?(e.openBlock(),e.createElementBlock("div",ih," Selected ")):e.createCommentVNode("",!0),$.description?(e.openBlock(),e.createElementBlock("div",rh,e.toDisplayString($.description),1)):e.createCommentVNode("",!0)],10,ah))),128))])):(e.openBlock(),e.createElementBlock("div",sh,[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",lh,[e.renderSlot(f.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(f.emptyMessage),1)],!0)]))],64))]))}}),dh=Ce(ch,[["__scopeId","data-v-904abb6b"]]);function no(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 uh(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 mh=["src","crossorigin"],ph={class:"preview-controls"},fh=["aria-label"],hh={class:"time-display"},vh={class:"current-time"},gh={class:"total-time"},yh={key:0,class:"fps-display"},bh={key:0,class:"loading-overlay"},wh={key:1,class:"error-overlay"},kh=.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}=qe,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 y,w,N=null,C=null,b=null,f=[],_="",$=null,T=0,x=0,I=0,Z=0,S=!1,L=0,R=0,P,A=null,B=!1,D=!1,k=0;const F=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),H=e.computed(()=>{const de=F.value;if(!(!de||de.startsWith("blob:")))return"anonymous"}),j=e.computed(()=>uh(v.value,r.fitMode));function te(de){return typeof de=="number"&&Number.isFinite(de)&&de>=0?de:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function he(de){const Ee=te(de.duration);return Ee<=0?!1:de.currentTime>=Math.max(0,Ee-kh)}async function ge(){var de,Ee;if(!D&&c.value&&!y&&!(!d.value||d.value.readyState<3)){D=!0;try{m.value=void 0;let xe=((de=l.value)==null?void 0:de.clientWidth)||800,ze=((Ee=l.value)==null?void 0:Ee.clientHeight)||450;if((xe<=0||ze<=0)&&(xe=d.value.videoWidth||800,ze=d.value.videoHeight||450),y=new qe.Application,await y.init({width:xe,height:ze,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(y.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!y&&ge()},100),y&&(y.destroy(!0),y=null);return}if(T=d.value.videoWidth,x=d.value.videoHeight,C=document.createElement("canvas"),C.width=T,C.height=x,b=C.getContext("2d"),!b)throw new Error("Unable to create 2D canvas context for video preview");const M=no(d.value,b,T,x),z=qe.Texture.from(C);N=z.source,w=new qe.Sprite(z),w.visible=!0,w.alpha=1,Ct(),y.stage.addChild(w),y.renderer&&!y.renderer.destroyed&&y.render()}K(),r.targetFps<60?ae():y.ticker.add(V),v.value=!0,"ResizeObserver"in window&&($=new ResizeObserver(M=>{S||(S=!0,requestAnimationFrame(()=>{S=!1;const z=M[M.length-1],{width:J,height:q}=z.contentRect;if(J<=0||q<=0)return;const ue=Math.round(J),ve=Math.round(q);ue===I&&ve===Z||(I=ue,Z=ve,Ct())}))}),$.observe(l.value)),r.filters&&r.filters.length>0&&K(),r.showFps&&ut(),k=0}catch{if(Ge(),!B&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&k<2){k+=1,window.setTimeout(()=>{B||ge()},k*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{D=!1}}}function ae(){const de=1e3/r.targetFps;let Ee=performance.now();function xe(){if(B||!y)return;const ze=performance.now(),M=ze-Ee;M>=de&&(V(),Ee=ze-M%de),A=requestAnimationFrame(xe)}A=requestAnimationFrame(xe)}function V(){if(!(!y||!w||B)&&r.active)try{b&&C&&N&&d.value&&(d.value.readyState>=2&&no(d.value,b,C.width,C.height)&&N.update(),d.value.paused||s("frame-update",fe())),r.showFps&&R++,y.renderer&&!y.renderer.destroyed&&y.render()}catch{B=!0}}function U(){for(const de of f)try{de.destroy()}catch{}f=[]}function K(){if(w){if(!r.filters||r.filters.length===0){w.filters=null,U();return}U(),r.filters.forEach(de=>{const Ee=ee(de);Ee&&f.push(Ee)}),w.filters=f.length>0?f:null,_=JSON.stringify(r.filters),y&&y.render()}}function ee(de){const Ee=de.filterId,xe=de.params||{},ze=oe.getFilter(Ee);if(ze&&!oe.isFilterCompatibleWithMedia(Ee,"video"))return null;if(ze&&ze.createFilter)try{return ze.createFilter(xe)}catch{}const M=(z,J,q)=>Math.min(q,Math.max(J,z));switch(Ee){case"brightness":{const z=new a,J=M(typeof xe.brightness=="number"?xe.brightness:typeof xe.value=="number"?xe.value:1,0,5);return z.brightness(J,!0),z}case"contrast":{const z=new a,J=M(typeof xe.contrast=="number"?xe.contrast:typeof xe.value=="number"?xe.value:1,0,5);return z.contrast(J,!0),z}case"saturation":{const z=new a,J=M(typeof xe.saturation=="number"?xe.saturation:typeof xe.value=="number"?xe.value:1,0,5);return z.saturate(J,!0),z}case"hue":{const z=new a,J=M(typeof xe.value=="number"?xe.value:0,-180,180);return z.hue(J,!0),z}case"gaussian-blur":case"blur":{const z=M(typeof xe.blur=="number"?xe.blur:typeof xe.value=="number"?xe.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 xe.value=="number"?xe.value:.3;return ne(M(z,0,1))}default:return null}}function ne(de){const Ee=`
|
|
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 qe.Filter(void 0,Ee,{strength:de})}function fe(){var Ee;return!y||!w?null:{dataUrl:y.canvas.toDataURL("image/jpeg",.8),timestamp:((Ee=d.value)==null?void 0:Ee.currentTime)||0,width:T||0,height:x||0}}function ie(){var de;h.value=te((de=d.value)==null?void 0:de.duration),s("duration-change",h.value)}function pe(){u.value=!1,m.value=void 0}function ke(){u.value&&(u.value=!1),!v.value&&r.active?ge():v.value}function re(){var Ee,xe,ze;const de=((Ee=d.value)==null?void 0:Ee.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:de,width:((xe=d.value)==null?void 0:xe.videoWidth)||0,height:((ze=d.value)==null?void 0:ze.videoHeight)||0})}function ce(){d.value&&(d.value.currentTime=0),s("play-pause")}function _e(de){var xe;const Ee=de.target;if(Ee!=null&&Ee.error)switch(Ee.error.code){case Ee.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case Ee.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case Ee.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case Ee.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(xe=Ee.src)==null?void 0:xe.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 Ve(de){d.value&&(d.value.currentTime=Math.max(0,Math.min(de,h.value)))}function ut(){P=window.setInterval(()=>{const de=performance.now(),Ee=de-L;p.value=Math.round(R*1e3/Ee),R=0,L=de},1e3)}function He(de){if(!Number.isFinite(de)||de<0)return"00:00";const Ee=Math.floor(de/60),xe=Math.floor(de%60);return`${Ee.toString().padStart(2,"0")}:${xe.toString().padStart(2,"0")}`}function xt(){m.value=void 0,u.value=!0,k=0,Ge(),d.value&&d.value.load()}function Ge(){if($&&($.disconnect(),$=null),A&&(cancelAnimationFrame(A),A=null),y!=null&&y.ticker&&(y.ticker.stop(),y.ticker.remove(V)),y)try{y.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),U(),y=null,w=null,N=null,C=null,b=null,v.value=!1,S=!1,_=""}function at(){y&&(S||(S=!0,requestAnimationFrame(()=>{S=!1,Ct()})))}function Ct(){if(!y||!w||!T||!x||!l.value)return;const de=Math.round(l.value.clientWidth),Ee=Math.round(l.value.clientHeight);if(de<=0||Ee<=0)return;y.renderer.resize(de,Ee);const xe=y.screen.width/T,ze=y.screen.height/x;let M=1;switch(r.fitMode){case"cover":M=Math.max(xe,ze);break;case"none":M=1;break;case"contain":default:M=Math.min(xe,ze);break}w.scale.set(M),w.anchor.set(.5),w.position.set(y.screen.width/2,y.screen.height/2),w.visible=!0,w.alpha=1,y.renderer&&!y.renderer.destroyed&&y.render()}e.watch(()=>r.filters,()=>{v.value&&K()},{deep:!0}),e.watch(()=>r.active,async de=>{if(de&&!y&&d.value&&d.value.readyState>=2){await ge();return}y&&(de&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),w&&b&&C&&N&&(d.value&&d.value.readyState>=2&&no(d.value,b,C.width,C.height)&&N.update(),Ct(),y.renderer&&!y.renderer.destroyed&&y.render())),r.targetFps>=60&&y.ticker&&(de?y.ticker.start():y.ticker.stop()))}),e.watch(F,de=>{de?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function $t(){if(d.value){m.value=void 0,he(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,de=>{d.value&&(de?$t():d.value.pause())}),e.watch(()=>r.playhead,de=>{d.value&&Math.abs(d.value.currentTime-de)>.5&&Ve(de)}),e.watch(()=>r.fitMode,()=>{Ct()}),e.onMounted(()=>{B=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",at),L=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value?ge():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(B=!0,A&&(cancelAnimationFrame(A),A=null),window.removeEventListener("resize",at),$&&($.disconnect(),$=null),P&&clearInterval(P),y&&y.ticker&&(y.ticker.stop(),y.ticker.remove(V)),y){try{y.destroy(!0,{children:!0,texture:!0})}catch{}y=null}f.forEach(de=>{try{de.destroy()}catch{}}),f=[],w=null,N=null,C=null,b=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function lt(de){if(!await yt()||!d.value||!b||!C||!N)return null;const xe=d.value,ze=Number.isFinite(h.value)&&h.value>0?h.value:Number.isFinite(xe.duration)&&xe.duration>0?xe.duration:0,M=Math.max(0,Math.min(de,ze));return await new Promise(J=>{let q=!1,ue=0;const ve=()=>{q||(q=!0,xe.removeEventListener("seeked",Te),window.clearTimeout(ue),J())},Te=()=>{ve()},$e=Number.isFinite(xe.currentTime)?xe.currentTime:0;if(Math.abs($e-M)<.016){requestAnimationFrame(()=>ve());return}xe.addEventListener("seeked",Te),ue=window.setTimeout(()=>ve(),700),xe.currentTime=M}),no(xe,b,C.width,C.height)?(N.update(),y.render(),y.canvas):null}async function yt(){if(!d.value)return!1;if(!y){if(!(d.value.readyState>=2))return!1;await ge()}if(!y||!w||!b||!C||!N)return!1;if(r.filters&&r.filters.length>0){const de=w.filters,Ee=Array.isArray(de)?de.length:0,ze=JSON.stringify(r.filters)!==_;(Ee===0||Ee!==r.filters.length||ze)&&K()}return await e.nextTick(),await new Promise(de=>{requestAnimationFrame(()=>de())}),!0}return n({captureFrameAt:lt,ensureReadyForCapture:yt,duration:h,pixiCanvas:e.computed(()=>y?y.canvas:null),videoElement:e.computed(()=>d.value??null)}),(de,Ee)=>(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:F.value,onLoadedmetadata:ie,onLoadeddata:pe,onCanplay:ke,onTimeupdate:re,onEnded:ce,onError:_e,style:e.normalizeStyle(j.value),crossorigin:H.value,preload:"auto",playsinline:"",controls:""},null,44,mh),e.createElementVNode("div",ph,[e.createElementVNode("button",{class:"play-button",onClick:Ee[0]||(Ee[0]=xe=>de.$emit("play-pause")),"aria-label":de.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(O.IonIcon),{icon:de.isPlaying?e.unref(sc):e.unref(cc)},null,8,["icon"])],8,fh),e.createElementVNode("div",hh,[e.createElementVNode("span",vh,e.toDisplayString(He(de.playhead)),1),Ee[1]||(Ee[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",gh,e.toDisplayString(He(h.value)),1)]),de.showFps?(e.openBlock(),e.createElementBlock("div",yh,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",bh,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"}),Ee[2]||(Ee[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",wh,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Nr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:xt},"Retry")])):e.createCommentVNode("",!0)],512))}}),Qs=Ce(_h,[["__scopeId","data-v-dd1744f4"]]);var Mr=(o,n,t)=>{if(!n.has(o))throw TypeError("Cannot "+t)},W=(o,n,t)=>(Mr(o,n,"read from private field"),t?t.call(o):n.get(o)),Fe=(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)},st=(o,n,t,a)=>(Mr(o,n,"write to private field"),n.set(o,t),t),Eh=(o,n,t,a)=>({set _(i){st(o,n,i)},get _(){return W(o,n,a)}}),Re=(o,n,t)=>(Mr(o,n,"access private method"),t),De=new Uint8Array(8),qt=new DataView(De.buffer),nt=o=>[(o%256+256)%256],Pe=o=>(qt.setUint16(0,o,!1),[De[0],De[1]]),xh=o=>(qt.setInt16(0,o,!1),[De[0],De[1]]),hc=o=>(qt.setUint32(0,o,!1),[De[1],De[2],De[3]]),we=o=>(qt.setUint32(0,o,!1),[De[0],De[1],De[2],De[3]]),Ch=o=>(qt.setInt32(0,o,!1),[De[0],De[1],De[2],De[3]]),Tn=o=>(qt.setUint32(0,Math.floor(o/2**32),!1),qt.setUint32(4,o,!1),[De[0],De[1],De[2],De[3],De[4],De[5],De[6],De[7]]),Br=o=>(qt.setInt16(0,2**8*o,!1),[De[0],De[1]]),Gt=o=>(qt.setInt32(0,2**16*o,!1),[De[0],De[1],De[2],De[3]]),Oi=o=>(qt.setInt32(0,2**30*o,!1),[De[0],De[1],De[2],De[3]]),It=(o,n=!1)=>{let t=Array(o.length).fill(null).map((a,i)=>o.charCodeAt(i));return n&&t.push(0),t},Vo=o=>o&&o[o.length-1],Ir=o=>{let n;for(let t of o)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Yt=(o,n,t=!0)=>{let a=o*n;return t?Math.round(a):a},vc=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]},gc=vc(0),yc=o=>[Gt(o[0]),Gt(o[1]),Oi(o[2]),Gt(o[3]),Gt(o[4]),Oi(o[5]),Gt(o[6]),Gt(o[7]),Oi(o[8])],ka=o=>!o||typeof o!="object"?o:Array.isArray(o)?o.map(ka):Object.fromEntries(Object.entries(o).map(([n,t])=>[n,ka(t)])),Gn=o=>o>=0&&o<2**32,Qe=(o,n,t)=>({type:o,contents:n&&new Uint8Array(n.flat(10)),children:t}),je=(o,n,t,a,i)=>Qe(o,[nt(n),hc(t),a??[]],i),Sh=o=>{let n=512;return o.fragmented?Qe("ftyp",[It("iso5"),we(n),It("iso5"),It("iso6"),It("mp41")]):Qe("ftyp",[It("isom"),we(n),It("isom"),o.holdsAvc?It("avc1"):[],It("mp41")])},ar=o=>({type:"mdat",largeSize:o}),Vh=o=>({type:"free",size:o}),ho=(o,n,t=!1)=>Qe("moov",null,[Nh(n,o),...o.map(a=>Th(a,n)),t?rv(o):null]),Nh=(o,n)=>{let t=Yt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=Ir(s.samples);return l.presentationTimestamp+l.duration})),rr),a=Math.max(...n.map(s=>s.id))+1,i=!Gn(o)||!Gn(t),r=i?Tn:we;return je("mvhd",+i,0,[r(o),r(o),we(rr),r(t),Gt(1),Br(1),Array(10).fill(0),yc(gc),Array(24).fill(0),we(a)])},Th=(o,n)=>Qe("trak",null,[Mh(o,n),Bh(o,n)]),Mh=(o,n)=>{let t=Ir(o.samples),a=Yt(t?t.presentationTimestamp+t.duration:0,rr),i=!Gn(n)||!Gn(a),r=i?Tn:we,s;return o.info.type==="video"?s=typeof o.info.rotation=="number"?vc(o.info.rotation):o.info.rotation:s=gc,je("tkhd",+i,3,[r(n),r(n),we(o.id),we(0),r(a),Array(8).fill(0),Pe(0),Pe(0),Br(o.info.type==="audio"?1:0),Pe(0),yc(s),Gt(o.info.type==="video"?o.info.width:0),Gt(o.info.type==="video"?o.info.height:0)])},Bh=(o,n)=>Qe("mdia",null,[Ih(o,n),Fh(o.info.type==="video"?"vide":"soun"),$h(o)]),Ih=(o,n)=>{let t=Ir(o.samples),a=Yt(t?t.presentationTimestamp+t.duration:0,o.timescale),i=!Gn(n)||!Gn(a),r=i?Tn:we;return je("mdhd",+i,0,[r(n),r(n),we(o.timescale),r(a),Pe(21956),Pe(0)])},Fh=o=>je("hdlr",0,0,[It("mhlr"),It(o),we(0),we(0),we(0),It("mp4-muxer-hdlr",!0)]),$h=o=>Qe("minf",null,[o.info.type==="video"?Rh():Dh(),Ah(),Oh(o)]),Rh=()=>je("vmhd",0,1,[Pe(0),Pe(0),Pe(0),Pe(0)]),Dh=()=>je("smhd",0,0,[Pe(0),Pe(0)]),Ah=()=>Qe("dinf",null,[Lh()]),Lh=()=>je("dref",0,0,[we(1)],[Uh()]),Uh=()=>je("url ",0,1),Oh=o=>{const n=o.compositionTimeOffsetTable.length>1||o.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Qe("stbl",null,[zh(o),ev(o),tv(o),nv(o),av(o),ov(o),n?iv(o):null])},zh=o=>je("stsd",0,0,[we(1)],[o.info.type==="video"?Ph(vv[o.info.codec],o):qh(yv[o.info.codec],o)]),Ph=(o,n)=>Qe(o,[Array(6).fill(0),Pe(1),Pe(0),Pe(0),Array(12).fill(0),Pe(n.info.width),Pe(n.info.height),we(4718592),we(4718592),we(0),Pe(1),Array(32).fill(0),Pe(24),xh(65535)],[gv[n.info.codec](n),n.info.decoderConfig.colorSpace?Hh(n):null]),Wh={bt709:1,bt470bg:5,smpte170m:6},jh={bt709:1,smpte170m:6,"iec61966-2-1":13},Zh={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Hh=o=>Qe("colr",[It("nclx"),Pe(Wh[o.info.decoderConfig.colorSpace.primaries]),Pe(jh[o.info.decoderConfig.colorSpace.transfer]),Pe(Zh[o.info.decoderConfig.colorSpace.matrix]),nt((o.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Xh=o=>o.info.decoderConfig&&Qe("avcC",[...new Uint8Array(o.info.decoderConfig.description)]),Gh=o=>o.info.decoderConfig&&Qe("hvcC",[...new Uint8Array(o.info.decoderConfig.description)]),Jh=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 je("vpcC",1,0,[nt(a),nt(i),nt(l),nt(2),nt(2),nt(2),Pe(0)])},Yh=()=>{let t=(1<<7)+1;return Qe("av1C",[t,0,0,0])},qh=(o,n)=>Qe(o,[Array(6).fill(0),Pe(1),Pe(0),Pe(0),we(0),Pe(n.info.numberOfChannels),Pe(16),Pe(0),Pe(0),Gt(n.info.sampleRate)],[bv[n.info.codec](n)]),Kh=o=>{let n=new Uint8Array(o.info.decoderConfig.description);return je("esds",0,0,[we(58753152),nt(32+n.byteLength),Pe(1),nt(0),we(75530368),nt(18+n.byteLength),nt(64),nt(21),hc(0),we(130071),we(130071),we(92307584),nt(n.byteLength),...n,we(109084800),nt(1),nt(2)])},Qh=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 Qe("dOps",[nt(0),nt(o.info.numberOfChannels),Pe(n),we(o.info.sampleRate),Br(t),nt(0)])},ev=o=>je("stts",0,0,[we(o.timeToSampleTable.length),o.timeToSampleTable.map(n=>[we(n.sampleCount),we(n.sampleDelta)])]),tv=o=>{if(o.samples.every(t=>t.type==="key"))return null;let n=[...o.samples.entries()].filter(([,t])=>t.type==="key");return je("stss",0,0,[we(n.length),n.map(([t])=>we(t+1))])},nv=o=>je("stsc",0,0,[we(o.compactlyCodedChunkTable.length),o.compactlyCodedChunkTable.map(n=>[we(n.firstChunk),we(n.samplesPerChunk),we(1)])]),av=o=>je("stsz",0,0,[we(0),we(o.samples.length),o.samples.map(n=>we(n.size))]),ov=o=>o.finalizedChunks.length>0&&Vo(o.finalizedChunks).offset>=2**32?je("co64",0,0,[we(o.finalizedChunks.length),o.finalizedChunks.map(n=>Tn(n.offset))]):je("stco",0,0,[we(o.finalizedChunks.length),o.finalizedChunks.map(n=>we(n.offset))]),iv=o=>je("ctts",0,0,[we(o.compositionTimeOffsetTable.length),o.compositionTimeOffsetTable.map(n=>[we(n.sampleCount),we(n.sampleCompositionTimeOffset)])]),rv=o=>Qe("mvex",null,o.map(sv)),sv=o=>je("trex",0,0,[we(o.id),we(1),we(0),we(0),we(0)]),el=(o,n)=>Qe("moof",null,[lv(o),...n.map(cv)]),lv=o=>je("mfhd",0,0,[we(o)]),bc=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},cv=o=>Qe("traf",null,[dv(o),uv(o),mv(o)]),dv=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:bc(t)};return je("tfhd",0,n,[we(o.id),we(a.duration),we(a.size),we(a.flags)])},uv=o=>je("tfdt",1,0,[Tn(Yt(o.currentChunk.startTimestamp,o.timescale))]),mv=o=>{let n=o.currentChunk.samples.map(y=>y.timescaleUnitsToNextSample),t=o.currentChunk.samples.map(y=>y.size),a=o.currentChunk.samples.map(bc),i=o.currentChunk.samples.map(y=>Yt(y.presentationTimestamp-y.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(y=>y!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+h,v|=2048*+p,je("trun",1,v,[we(o.currentChunk.samples.length),we(o.currentChunk.offset-o.currentChunk.moofOffset||0),d?we(a[0]):[],o.currentChunk.samples.map((y,w)=>[u?we(n[w]):[],m?we(t[w]):[],h?we(a[w]):[],p?Ch(i[w]):[]])])},pv=o=>Qe("mfra",null,[...o.map(fv),hv()]),fv=(o,n)=>je("tfra",1,0,[we(o.id),we(63),we(o.finalizedChunks.length),o.finalizedChunks.map(a=>[Tn(Yt(a.startTimestamp,o.timescale)),Tn(a.moofOffset),we(n+1),we(1),we(1)])]),hv=()=>je("mfro",0,0,[we(0)]),vv={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},gv={avc:Xh,hevc:Gh,vp9:Jh,av1:Yh},yv={aac:"mp4a",opus:"Opus"},bv={aac:Kh,opus:Qh},Oo=class{},Fr=class extends Oo{constructor(){super(...arguments),this.buffer=null}},wc=class extends Oo{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.")}},wv=class extends Oo{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")}},bn,zn,kc=class{constructor(){this.pos=0,Fe(this,bn,new Uint8Array(8)),Fe(this,zn,new DataView(W(this,bn).buffer)),this.offsets=new WeakMap}seek(o){this.pos=o}writeU32(o){W(this,zn).setUint32(0,o,!1),this.write(W(this,bn).subarray(0,4))}writeU64(o){W(this,zn).setUint32(0,Math.floor(o/2**32),!1),W(this,zn).setUint32(4,o,!1),this.write(W(this,bn).subarray(0,8))}writeAscii(o){for(let n=0;n<o.length;n++)W(this,zn).setUint8(n%8,o.charCodeAt(n)),n%8===7&&this.write(W(this,bn));o.length%8!==0&&this.write(W(this,bn).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}}};bn=new WeakMap;zn=new WeakMap;var vo,Vn,Na,ga,go,or,kv=class extends kc{constructor(o){super(),Fe(this,go),Fe(this,vo,void 0),Fe(this,Vn,new ArrayBuffer(2**16)),Fe(this,Na,new Uint8Array(W(this,Vn))),Fe(this,ga,0),st(this,vo,o)}write(o){Re(this,go,or).call(this,this.pos+o.byteLength),W(this,Na).set(o,this.pos),this.pos+=o.byteLength,st(this,ga,Math.max(W(this,ga),this.pos))}finalize(){Re(this,go,or).call(this,this.pos),W(this,vo).buffer=W(this,Vn).slice(0,Math.max(W(this,ga),this.pos))}};vo=new WeakMap;Vn=new WeakMap;Na=new WeakMap;ga=new WeakMap;go=new WeakSet;or=function(o){let n=W(this,Vn).byteLength;for(;n<o;)n*=2;if(n===W(this,Vn).byteLength)return;let t=new ArrayBuffer(n),a=new Uint8Array(t);a.set(W(this,Na),0),st(this,Vn,t),st(this,Na,a)};var _v=2**24,Ev=2,_a,wn,ya,an,Tt,No,ir,$r,_c,Rr,Ec,Ea,To,Dr=class extends kc{constructor(o){var n,t;super(),Fe(this,No),Fe(this,$r),Fe(this,Rr),Fe(this,Ea),Fe(this,_a,void 0),Fe(this,wn,[]),Fe(this,ya,void 0),Fe(this,an,void 0),Fe(this,Tt,[]),st(this,_a,o),st(this,ya,((n=o.options)==null?void 0:n.chunked)??!1),st(this,an,((t=o.options)==null?void 0:t.chunkSize)??_v)}write(o){W(this,wn).push({data:o.slice(),start:this.pos}),this.pos+=o.byteLength}flush(){var t,a;if(W(this,wn).length===0)return;let o=[],n=[...W(this,wn)].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 W(this,wn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);W(this,ya)?(Re(this,No,ir).call(this,i.data,i.start),Re(this,Ea,To).call(this)):(a=(t=W(this,_a).options).onData)==null||a.call(t,i.data,i.start)}W(this,wn).length=0}finalize(){W(this,ya)&&Re(this,Ea,To).call(this,!0)}};_a=new WeakMap;wn=new WeakMap;ya=new WeakMap;an=new WeakMap;Tt=new WeakMap;No=new WeakSet;ir=function(o,n){let t=W(this,Tt).findIndex(l=>l.start<=n&&n<l.start+W(this,an));t===-1&&(t=Re(this,Rr,Ec).call(this,n));let a=W(this,Tt)[t],i=n-a.start,r=o.subarray(0,Math.min(W(this,an)-i,o.byteLength));a.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Re(this,$r,_c).call(this,a,s),a.written[0].start===0&&a.written[0].end===W(this,an)&&(a.shouldFlush=!0),W(this,Tt).length>Ev){for(let l=0;l<W(this,Tt).length-1;l++)W(this,Tt)[l].shouldFlush=!0;Re(this,Ea,To).call(this)}r.byteLength<o.byteLength&&Re(this,No,ir).call(this,o.subarray(r.byteLength),n+r.byteLength)};$r=new WeakSet;_c=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)};Rr=new WeakSet;Ec=function(o){let t={start:Math.floor(o/W(this,an))*W(this,an),data:new Uint8Array(W(this,an)),written:[],shouldFlush:!1};return W(this,Tt).push(t),W(this,Tt).sort((a,i)=>a.start-i.start),W(this,Tt).indexOf(t)};Ea=new WeakSet;To=function(o=!1){var n,t;for(let a=0;a<W(this,Tt).length;a++){let i=W(this,Tt)[a];if(!(!i.shouldFlush&&!o)){for(let r of i.written)(t=(n=W(this,_a).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);W(this,Tt).splice(a--,1)}}};var xv=class extends Dr{constructor(o){var n;super(new wc({onData:(t,a)=>o.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(n=o.options)==null?void 0:n.chunkSize}))}},rr=1e3,Cv=["avc","hevc","vp9","av1"],Sv=["aac","opus"],Vv=2082844800,Nv=["strict","offset","cross-track-offset"],Ne,Me,Mo,Vt,dt,rt,Pn,Wn,Ar,kn,_n,xa,sr,xc,lr,Cc,Lr,Sc,cr,Vc,Ur,Nc,yo,dr,Xt,nn,Or,Tc,Ca,Bo,Io,zr,Jn,Ia,bo,ur,Mc=class{constructor(o){if(Fe(this,sr),Fe(this,lr),Fe(this,Lr),Fe(this,cr),Fe(this,Ur),Fe(this,yo),Fe(this,Xt),Fe(this,Or),Fe(this,Ca),Fe(this,Io),Fe(this,Jn),Fe(this,bo),Fe(this,Ne,void 0),Fe(this,Me,void 0),Fe(this,Mo,void 0),Fe(this,Vt,void 0),Fe(this,dt,null),Fe(this,rt,null),Fe(this,Pn,Math.floor(Date.now()/1e3)+Vv),Fe(this,Wn,[]),Fe(this,Ar,1),Fe(this,kn,[]),Fe(this,_n,[]),Fe(this,xa,!1),Re(this,sr,xc).call(this,o),o.video=ka(o.video),o.audio=ka(o.audio),o.fastStart=ka(o.fastStart),this.target=o.target,st(this,Ne,{firstTimestampBehavior:"strict",...o}),o.target instanceof Fr)st(this,Me,new kv(o.target));else if(o.target instanceof wc)st(this,Me,new Dr(o.target));else if(o.target instanceof wv)st(this,Me,new xv(o.target));else throw new Error(`Invalid target: ${o.target}`);Re(this,cr,Vc).call(this),Re(this,lr,Cc).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(Re(this,bo,ur).call(this),!W(this,Ne).video)throw new Error("No video track declared.");if(typeof W(this,Ne).fastStart=="object"&&W(this,dt).samples.length===W(this,Ne).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${W(this,Ne).fastStart.expectedVideoChunks}).`);let s=Re(this,yo,dr).call(this,W(this,dt),o,n,t,a,i,r);if(W(this,Ne).fastStart==="fragmented"&&W(this,rt)){for(;W(this,_n).length>0&&W(this,_n)[0].decodeTimestamp<=s.decodeTimestamp;){let l=W(this,_n).shift();Re(this,Xt,nn).call(this,W(this,rt),l)}s.decodeTimestamp<=W(this,rt).lastDecodeTimestamp?Re(this,Xt,nn).call(this,W(this,dt),s):W(this,kn).push(s)}else Re(this,Xt,nn).call(this,W(this,dt),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(Re(this,bo,ur).call(this),!W(this,Ne).audio)throw new Error("No audio track declared.");if(typeof W(this,Ne).fastStart=="object"&&W(this,rt).samples.length===W(this,Ne).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${W(this,Ne).fastStart.expectedAudioChunks}).`);let r=Re(this,yo,dr).call(this,W(this,rt),o,n,t,a,i);if(W(this,Ne).fastStart==="fragmented"&&W(this,dt)){for(;W(this,kn).length>0&&W(this,kn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=W(this,kn).shift();Re(this,Xt,nn).call(this,W(this,dt),s)}r.decodeTimestamp<=W(this,dt).lastDecodeTimestamp?Re(this,Xt,nn).call(this,W(this,rt),r):W(this,_n).push(r)}else Re(this,Xt,nn).call(this,W(this,rt),r)}finalize(){if(W(this,xa))throw new Error("Cannot finalize a muxer more than once.");if(W(this,Ne).fastStart==="fragmented"){for(let n of W(this,kn))Re(this,Xt,nn).call(this,W(this,dt),n);for(let n of W(this,_n))Re(this,Xt,nn).call(this,W(this,rt),n);Re(this,Io,zr).call(this,!1)}else W(this,dt)&&Re(this,Ca,Bo).call(this,W(this,dt)),W(this,rt)&&Re(this,Ca,Bo).call(this,W(this,rt));let o=[W(this,dt),W(this,rt)].filter(Boolean);if(W(this,Ne).fastStart==="in-memory"){let n;for(let a=0;a<2;a++){let i=ho(o,W(this,Pn)),r=W(this,Me).measureBox(i);n=W(this,Me).measureBox(W(this,Vt));let s=W(this,Me).pos+r+n;for(let l of W(this,Wn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(W(this,Vt).largeSize=!0)}let t=ho(o,W(this,Pn));W(this,Me).writeBox(t),W(this,Vt).size=n,W(this,Me).writeBox(W(this,Vt));for(let a of W(this,Wn))for(let i of a.samples)W(this,Me).write(i.data),i.data=null}else if(W(this,Ne).fastStart==="fragmented"){let n=W(this,Me).pos,t=pv(o);W(this,Me).writeBox(t);let a=W(this,Me).pos-n;W(this,Me).seek(W(this,Me).pos-4),W(this,Me).writeU32(a)}else{let n=W(this,Me).offsets.get(W(this,Vt)),t=W(this,Me).pos-n;W(this,Vt).size=t,W(this,Vt).largeSize=t>=2**32,W(this,Me).patchBox(W(this,Vt));let a=ho(o,W(this,Pn));if(typeof W(this,Ne).fastStart=="object"){W(this,Me).seek(W(this,Mo)),W(this,Me).writeBox(a);let i=n-W(this,Me).pos;W(this,Me).writeBox(Vh(i))}else W(this,Me).writeBox(a)}Re(this,Jn,Ia).call(this),W(this,Me).finalize(),st(this,xa,!0)}};Ne=new WeakMap;Me=new WeakMap;Mo=new WeakMap;Vt=new WeakMap;dt=new WeakMap;rt=new WeakMap;Pn=new WeakMap;Wn=new WeakMap;Ar=new WeakMap;kn=new WeakMap;_n=new WeakMap;xa=new WeakMap;sr=new WeakSet;xc=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 Oo))throw new TypeError("The target must be provided and an instance of Target.");if(o.video){if(!Cv.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(!Sv.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&&!Nv.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.")};lr=new WeakSet;Cc=function(){var o;if(W(this,Me).writeBox(Sh({holdsAvc:((o=W(this,Ne).video)==null?void 0:o.codec)==="avc",fragmented:W(this,Ne).fastStart==="fragmented"})),st(this,Mo,W(this,Me).pos),W(this,Ne).fastStart==="in-memory")st(this,Vt,ar(!1));else if(W(this,Ne).fastStart!=="fragmented"){if(typeof W(this,Ne).fastStart=="object"){let n=Re(this,Lr,Sc).call(this);W(this,Me).seek(W(this,Me).pos+n)}st(this,Vt,ar(!0)),W(this,Me).writeBox(W(this,Vt))}Re(this,Jn,Ia).call(this)};Lr=new WeakSet;Sc=function(){if(typeof W(this,Ne).fastStart!="object")return;let o=0,n=[W(this,Ne).fastStart.expectedVideoChunks,W(this,Ne).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};cr=new WeakSet;Vc=function(){if(W(this,Ne).video&&st(this,dt,{id:1,info:{type:"video",codec:W(this,Ne).video.codec,width:W(this,Ne).video.width,height:W(this,Ne).video.height,rotation:W(this,Ne).video.rotation??0,decoderConfig:null},timescale:W(this,Ne).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),W(this,Ne).audio&&(st(this,rt,{id:W(this,Ne).video?2:1,info:{type:"audio",codec:W(this,Ne).audio.codec,numberOfChannels:W(this,Ne).audio.numberOfChannels,sampleRate:W(this,Ne).audio.sampleRate,decoderConfig:null},timescale:W(this,Ne).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),W(this,Ne).audio.codec==="aac")){let o=Re(this,Ur,Nc).call(this,2,W(this,Ne).audio.sampleRate,W(this,Ne).audio.numberOfChannels);W(this,rt).info.decoderConfig={codec:W(this,Ne).audio.codec,description:o,numberOfChannels:W(this,Ne).audio.numberOfChannels,sampleRate:W(this,Ne).audio.sampleRate}}};Ur=new WeakSet;Nc=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};yo=new WeakSet;dr=function(o,n,t,a,i,r,s){let l=a/1e6,c=(a-(s??0))/1e6,d=i/1e6,u=Re(this,Or,Tc).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:Yt(d,o.timescale)}};Xt=new WeakSet;nn=function(o,n){W(this,Ne).fastStart!=="fragmented"&&o.samples.push(n);const t=Yt(n.presentationTimestamp-n.decodeTimestamp,o.timescale);if(o.lastTimescaleUnits!==null){let i=Yt(n.decodeTimestamp,o.timescale,!1),r=Math.round(i-o.lastTimescaleUnits);if(o.lastTimescaleUnits+=r,o.lastSample.timescaleUnitsToNextSample=r,W(this,Ne).fastStart!=="fragmented"){let s=Vo(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=Vo(o.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else o.lastTimescaleUnits=0,W(this,Ne).fastStart!=="fragmented"&&(o.timeToSampleTable.push({sampleCount:1,sampleDelta:Yt(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(W(this,Ne).fastStart==="fragmented"){let r=W(this,dt)??W(this,rt);const s=W(this,Ne).minFragmentDuration??1;o===r&&n.type==="key"&&i>=s&&(a=!0,Re(this,Io,zr).call(this))}else a=i>=.5}a&&(o.currentChunk&&Re(this,Ca,Bo).call(this,o),o.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),o.currentChunk.samples.push(n)};Or=new WeakSet;Tc=function(o,n,t){var s,l;const a=W(this,Ne).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(W(this,Ne).firstTimestampBehavior==="offset"||W(this,Ne).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;W(this,Ne).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=W(this,dt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=W(this,rt))==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}};Ca=new WeakSet;Bo=function(o){if(W(this,Ne).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),W(this,Wn).push(o.currentChunk),(o.compactlyCodedChunkTable.length===0||Vo(o.compactlyCodedChunkTable).samplesPerChunk!==o.currentChunk.samples.length)&&o.compactlyCodedChunkTable.push({firstChunk:o.finalizedChunks.length,samplesPerChunk:o.currentChunk.samples.length}),W(this,Ne).fastStart==="in-memory"){o.currentChunk.offset=0;return}o.currentChunk.offset=W(this,Me).pos;for(let n of o.currentChunk.samples)W(this,Me).write(n.data),n.data=null;Re(this,Jn,Ia).call(this)}};Io=new WeakSet;zr=function(o=!0){if(W(this,Ne).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[W(this,dt),W(this,rt)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=Eh(this,Ar)._++;if(t===1){let l=ho(n,W(this,Pn),!0);W(this,Me).writeBox(l)}let a=W(this,Me).pos,i=el(t,n);W(this,Me).writeBox(i);{let l=ar(!1),c=0;for(let u of n)for(let m of u.currentChunk.samples)c+=m.size;let d=W(this,Me).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=W(this,Me).measureBox(l)+c),l.size=d,W(this,Me).writeBox(l)}for(let l of n){l.currentChunk.offset=W(this,Me).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)W(this,Me).write(c.data),c.data=null}let r=W(this,Me).pos;W(this,Me).seek(W(this,Me).offsets.get(i));let s=el(t,n);W(this,Me).writeBox(s),W(this,Me).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),W(this,Wn).push(l.currentChunk),l.currentChunk=null;o&&Re(this,Jn,Ia).call(this)};Jn=new WeakSet;Ia=function(){W(this,Me)instanceof Dr&&W(this,Me).flush()};bo=new WeakSet;ur=function(){if(W(this,xa))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const Ta=30;class Yn extends Error{constructor({message:t="",code:a=""},...i){super(t,...i);G(this,"message");G(this,"code");this.code=a,this.message=t}}class on extends Yn{}class Ke extends Yn{}class Fo extends Yn{}class tl extends Yn{}function Tv(o,n=Ta){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o*n)}function jn(o,n=Ta){if(n<1)throw new Ke({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o/n*1e3)}class be{constructor(n=0){G(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return Tv(this.millis/1e3)}set frames(n){this.millis=jn(n)}get seconds(){return this.millis/1e3}set seconds(n){this.millis=n*1e3}addMillis(n){return this.millis=this.millis+n,this}addFrames(n){const t=jn(n);return this.millis=this.millis+t,this}add(n){return new be(n.millis+this.millis)}subtract(n){return new be(this.millis-n.millis)}static fromSeconds(n){const t=new be;return t.millis=n*1e3,t}static fromFrames(n,t){const a=new be;return a.millis=jn(n,t),a}copy(){return new be(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new be(n)}}function nl(o,n){return[o.slice(0,n),o.slice(n)].filter(t=>t.length>0)}function wo(o,n){return n?Math.floor(Math.random()*(n-o+1)+o):o}function Mv(o,n,t){t<0&&(t=0);const a=o[n];o.splice(n,1),o.splice(t,0,a)}function al(o){return typeof o!="function"?!1:/^class\s/.test(Function.prototype.toString.call(o))}function Bv(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 Iv(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 Fv(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($v)}function $v(o,n){const t=o.hardwareAcceleration??"",a=n.hardwareAcceleration??"";return t<a?-1:t>a?1:0}async function Rv(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 ol(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 il(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 ao{constructor(n){G(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 be}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new be}}var mr=(o=>(o.en="en",o.de="de",o))(mr||{});class rl{constructor(n,t,a,i){G(this,"id",crypto.randomUUID());G(this,"text");G(this,"start");G(this,"stop");G(this,"confidence");this.text=n,this.start=new be(t),this.stop=new be(a),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class xn{constructor(n=[],t=mr.en){G(this,"id",crypto.randomUUID());G(this,"language",mr.en);G(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>=wo(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=wo(...t)?(yield r,r=void 0):a&&r.text.length>=wo(...a)&&(yield r,r=void 0)),r?r.words.push(l):r=new ao([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=il(i.start.seconds),s=il(i.stop.seconds);a+=`${t}
|
|
22
|
-
`+ol(r)+" --> "+ol(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 rl(s.text,s.start.millis-a,s.stop.millis-a)),i.length==n)return new xn([new ao(i)]);return new xn([new ao(i)])}copy(){return xn.fromJSON(this.toJSON())}static fromJSON(n){const t=new xn;for(const a of n){const i=new ao;for(const r of a)i.words.push(new rl(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 on({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return xn.fromJSON(await a.json())}}function ko(o,n,t){return o+(n-o)*t}function Dv(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(ko(r,c,t)),h=Math.round(ko(s,d,t)),p=Math.round(ko(l,u,t));return`#${((1<<24)+(m<<16)+(h<<8)+p).toString(16).slice(1)}`}const Av={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 Se{constructor(n,t,a={}){G(this,"input");G(this,"output");G(this,"options");if(n.length!==t.length)throw new Ke({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>jn(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(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=Av[this.options.easing](n);if(typeof a=="number"&&typeof i=="number")return ko(a,i,r);if(typeof a=="string"&&typeof i=="string")return Dv(a,i,r);if(this.output.length==1)return this.output[0];throw new Ke({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(jn(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Se([],[]);return Object.assign(t,n),t}}class Ft{constructor(){G(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 ye(o){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:o})}}function Fa(o){return class extends o{constructor(){super(...arguments);G(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 Pr(o,n,t=0){if(!(o instanceof We.Container||o instanceof We.Filter||t==3))for(const a in o){const i=o[a];a&&(i instanceof Se&&(o[a]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&Pr(i,n,t+1))}}var Lv=Object.defineProperty,zo=(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&&Lv(n,t,i),i};const $a=class Bc extends Fa(Ft){constructor(t={}){super();G(this,"_name");G(this,"_start",new be);G(this,"_stop",be.fromSeconds(16));G(this,"type","base");G(this,"source");G(this,"view",new We.Container);G(this,"createdAt",new Date);G(this,"disabled",!1);G(this,"state","IDLE");G(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",be.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=be.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ke({code:"trackNotAttached",message:"Track must be attached to a track"});const a=this.copy();this.stop=t.copy(),a.start=t.copy().addMillis(1),Pr(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 Bc.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};zo([ye()],$a.prototype,"_name");zo([ye(be)],$a.prototype,"_start");zo([ye(be)],$a.prototype,"_stop");zo([ye()],$a.prototype,"disabled");let Ra=$a;var Uv=Object.defineProperty,In=(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&&Uv(n,t,i),i};class Kt extends Fa(Ft){constructor(){super(...arguments);G(this,"state","IDLE");G(this,"metadata");G(this,"objectURL");G(this,"duration",be.fromSeconds(16));G(this,"added",!1);G(this,"type","base");G(this,"name","");G(this,"mimeType");G(this,"externalURL");G(this,"external",!1);G(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 Ke({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=vr(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 on({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=vr(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();Rv(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,i=new this){return i.from(t,a)}}In([ye()],Kt.prototype,"objectURL");In([ye()],Kt.prototype,"duration");In([ye()],Kt.prototype,"type");In([ye()],Kt.prototype,"name");In([ye()],Kt.prototype,"mimeType");In([ye()],Kt.prototype,"externalURL");In([ye()],Kt.prototype,"external");const sl="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Ov(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 ll(o){if(!o||!o.body)return sl;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 sl;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,"+Ov(d)}class cl extends Kt{constructor(){super();G(this,"type","html");G(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=ll(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=ll(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 zv(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:be.fromSeconds(d/l),stop:be.fromSeconds(m/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:be.fromSeconds(d/l),stop:be.fromSeconds(s.length/l)}),r}const zi=3e3;class hn extends Kt{constructor(){super(...arguments);G(this,"type","audio");G(this,"decoding",!1);G(this,"_silences");G(this,"transcript");G(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,zi,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*zi/1e3,0)),d=i?Math.floor(Math.min(i*zi/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 y=-1/0;for(let w=p;w<v;w++){const N=l[w];N>y&&(y=N)}m[h]=r?Math.log2(1+y):y}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=zv(r,t),i.close(),this._silences}}class pr extends Kt{constructor(){super(...arguments);G(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 Cn extends hn{constructor(){super(...arguments);G(this,"type","video");G(this,"downloadInProgress",!0)}async loadUrl(t,a){const i=await fetch(t,a);if(!(i!=null&&i.ok))throw new on({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=vr(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 Ke({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 Pv{static fromJSON(n){return[new be(n[0]),new be(n[1])]}}var Wv=Object.defineProperty,jv=Object.getOwnPropertyDescriptor,Kn=(o,n,t,a)=>{for(var i=a>1?void 0:a?jv(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&&Wv(n,t,i),i};const Fn=class Ic extends Ra{constructor(t={}){super();G(this,"source",new hn);G(this,"_offset",new be);G(this,"playing",!1);G(this,"duration",new be);G(this,"range",[new be,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=be.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=be.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",be.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 tl({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=be.fromFrames(t)),typeof a=="number"&&(a=be.fromFrames(a)),t.millis>=a.millis)throw new Ke({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=Ic.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=be.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ke({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new tl({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),Pr(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 Ke({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=>dl(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(!dl(s,l.range))continue;const c=new be(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}};Kn([ye(be)],Fn.prototype,"_offset",2);Kn([ye(be)],Fn.prototype,"duration",2);Kn([ye(Pv)],Fn.prototype,"range",2);Kn([ye(xn)],Fn.prototype,"transcript",1);Kn([ye()],Fn.prototype,"muted",1);Kn([ye()],Fn.prototype,"volume",1);let Po=Fn;function dl(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 oo{static fromJSON(n){return typeof n=="object"?Se.fromJSON(n):n}}class Pi{static fromJSON(n){return typeof n.x=="object"&&(n.x=Se.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Se.fromJSON(n.y)),n}}let Zv=class{constructor(o){G(this,"target");G(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 Se(i,r,{easing:a})}};function Hv(o){const n=new Proxy(o,{get(t,a){return a=="to"?(i,r)=>{if(!t.animation)throw new Ke({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new be(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 Xv extends Zv{}var Gv=Object.defineProperty,Jv=Object.getOwnPropertyDescriptor,mn=(o,n,t,a)=>{for(var i=a>1?void 0:a?Jv(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&&Gv(n,t,i),i};function Wo(o){class n extends o{constructor(){super(...arguments);G(this,"filters");G(this,"_height");G(this,"_width");G(this,"_position",{x:this.view.position.x,y:this.view.position.y});G(this,"_scale");G(this,"rotation",this.view.angle);G(this,"alpha",1);G(this,"translate",{x:0,y:0})}get position(){return this._position}set position(i){typeof i=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=i}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(i){typeof i=="number"||i instanceof Se||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof We.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 We.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 Hv(new Xv(this))}}return mn([ye(oo)],n.prototype,"_height",2),mn([ye(oo)],n.prototype,"_width",2),mn([ye(Pi)],n.prototype,"_position",2),mn([ye(Pi)],n.prototype,"_scale",2),mn([ye(oo)],n.prototype,"rotation",2),mn([ye(oo)],n.prototype,"alpha",2),mn([ye(Pi)],n.prototype,"translate",2),mn([ye()],n.prototype,"anchor",1),n}function jo(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 y;typeof this._scale.x=="number"?y=this._scale.x:typeof this._scale.x=="function"?y=this._scale.x.bind(this)(r):y=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)&&(y*=this.view.scale._x,w*=this.view.scale._y),this.view.scale.set(y,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 Yv=Object.defineProperty,qv=Object.getOwnPropertyDescriptor,Kv=(o,n,t,a)=>{for(var i=qv(n,t),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 Fc=class $c extends Wo(Ra){constructor(t,a={}){super();G(this,"type","image");G(this,"element",new Image);G(this,"source",new pr);G(this,"sprite",new We.Sprite);this.view.addChild(this.sprite),t instanceof pr&&(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=We.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",a(new on({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=$c.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Kv([jo],Fc.prototype,"update");let Qv=Fc;const io={"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 e0=Object.defineProperty,Zo=(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&&e0(n,t,i),i};const Da=class fr extends Fa(Ft){constructor(t){super();G(this,"loaded",!1);G(this,"family");G(this,"weight");G(this,"source");G(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=fr.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(io).map(t=>({family:t,variants:io[t].weights.map(a=>({family:t,source:`url(${io[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new fr({family:t,source:`url(${io[t].url})`,weight:a})}};Zo([ye()],Da.prototype,"family");Zo([ye()],Da.prototype,"weight");Zo([ye()],Da.prototype,"source");Zo([ye()],Da.prototype,"style");let pt=Da;const Jt=4,Rc={center:.5,justify:.5,left:0,right:1},Dc={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var t0=Object.defineProperty,n0=Object.getOwnPropertyDescriptor,Et=(o,n,t,a)=>{for(var i=n0(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 gt=class Ac extends Wo(Ra){constructor(t){super();G(this,"type","text");G(this,"_text","");G(this,"_textCase");G(this,"_anchor",{x:0,y:0});G(this,"_font",new pt);G(this,"style",new We.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 We.Text({text:this.transformedText,style:this.style,resolution:Jt,scale:Jt});this.view.addChild(a)}this.view.children[0]instanceof We.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*Jt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Jt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Rc[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=Dc[t]}get fillStyle(){const{fill:t}=this.style;return new We.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 We.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 We.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 We.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=Ac.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)*Jt;this.view.pivot={x:(t-i)*this._anchor.x,y:(a-i)*this._anchor.y}}set(t){return super.set(t)}};Et([ye()],gt.prototype,"text");Et([ye(pt)],gt.prototype,"font");Et([ye()],gt.prototype,"maxWidth");Et([ye()],gt.prototype,"textAlign");Et([ye()],gt.prototype,"padding");Et([ye()],gt.prototype,"textBaseline");Et([ye()],gt.prototype,"fillStyle");Et([ye()],gt.prototype,"anchor");Et([ye()],gt.prototype,"stroke");Et([ye()],gt.prototype,"textCase");Et([ye()],gt.prototype,"shadow");Et([ye()],gt.prototype,"fontSize");Et([ye()],gt.prototype,"leading");Et([jo],gt.prototype,"update");let Qn=gt;function Wi(o){const n=o.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const a0={get(o,n){const t=o[n];return typeof t=="number"?t*Jt:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*Jt):t}};function o0(o){return new Proxy(o,a0)}class i0{constructor(){G(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 ul{constructor(){G(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 r0{static fromJSON(n){return n.map(t=>(t.font&&(t.font=pt.fromJSON(t.font)),t))}}var s0=Object.defineProperty,l0=Object.getOwnPropertyDescriptor,ea=(o,n,t,a)=>{for(var i=a>1?void 0:a?l0(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&&s0(n,t,i),i};const $n=class Lc extends Qn{constructor(t){super();G(this,"type","complex_text");G(this,"_maxWidth");G(this,"_textAlign","left");G(this,"_textBaseline","top");G(this,"model",new We.Container);G(this,"segments",[]);G(this,"metrics",new ul);G(this,"background");G(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=Rc[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=Dc[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=Lc.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:Wi(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:Wi(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&i.push({index:void 0,tokens:Wi(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 ul;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=o0(We.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 i0),this.model.addChild(new We.Text({text:c.tokens[u],style:d,resolution:Jt,scale:Jt})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(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 We.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)*Jt;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};ea([ye()],$n.prototype,"background",2);ea([ye(r0)],$n.prototype,"styles",2);ea([ye()],$n.prototype,"text",1);ea([ye()],$n.prototype,"maxWidth",1);ea([ye()],$n.prototype,"textAlign",1);ea([ye()],$n.prototype,"textBaseline",1);let Ho=$n;const Uc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",c0=o=>Uint8Array.from(atob(o),n=>n.charCodeAt(0)),ml=typeof self<"u"&&self.Blob&&new Blob([c0(Uc)],{type:"text/javascript;charset=utf-8"});function d0(o){let n;try{if(n=ml&&(self.URL||self.webkitURL).createObjectURL(ml),!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,"+Uc,{name:o==null?void 0:o.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class u0{constructor(){G(this,"frames",[]);G(this,"state","active");G(this,"onenqueue");G(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 m0(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 p0=Object.defineProperty,f0=Object.getOwnPropertyDescriptor,h0=(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 Oc=class zc extends Wo(Po){constructor(t,a={}){super();G(this,"source",new Cn);G(this,"type","video");G(this,"worker");G(this,"buffer");G(this,"canvas",document.createElement("canvas"));G(this,"context",this.canvas.getContext("2d"));G(this,"element",document.createElement("video"));G(this,"textrues",{html5:We.Texture.from(this.element),canvas:We.Texture.from(this.canvas)});G(this,"sprite",new We.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 Cn&&(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 on({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(be.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=zc.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 u0,this.worker=new d0,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)??Ta}),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}};h0([jo,m0],Oc.prototype,"update");let hr=Oc;class $o extends Po{constructor(t,a={}){super();G(this,"type","audio");G(this,"source",new hn);G(this,"element",new Audio);t instanceof hn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,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 on({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=$o.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const v0={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 vr(o){if(!Object.keys(v0.MIXED).includes(o??""))throw new Ke({message:`${o} is not an accepted mime type`,code:"invalid_mimetype"});return o}var g0=Object.defineProperty,y0=Object.getOwnPropertyDescriptor,b0=(o,n,t,a)=>{for(var i=y0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&g0(n,t,i),i};const w0=class Pc extends Wo(Ra){constructor(t,a={}){super();G(this,"type","html");G(this,"source",new cl);G(this,"element",new Image);G(this,"canvas",document.createElement("canvas"));G(this,"context",this.canvas.getContext("2d"));G(this,"sprite",new We.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof cl&&(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=We.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new on({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 on({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{a(new on({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Pc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};b0([jo],w0.prototype,"update");const Wc=["DEFAULT","STACK"];class pl{constructor(){G(this,"mode",Wc[0]);G(this,"pauseAlignmet",!1)}add(n,t){let a=!0;for(let i=0;i<t.clips.length&&(a=vl(n,t.clips[i]),!!a);i++)hl(n,t.clips[i]);a&&(t.clips.push(n),t.clips.sort(fl))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(fl);for(let a=0;a<t.clips.length;a++)if(n.id!=t.clips[a].id){if(!vl(n,t.clips[a]))break;hl(n,t.clips[a])}}}offset(n,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(n);this.pauseAlignmet=!1}}class k0{constructor(){G(this,"mode",Wc[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 be(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 be(r))}a=i.stop.millis+1}}offset(){}}function fl(o,n){return o.start.millis-n.start.millis}function hl(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 vl(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 ta extends Fa(Ft){constructor(){super(...arguments);G(this,"_disabled",!1);G(this,"view",new We.Container);G(this,"clips",[]);G(this,"pointer",0);G(this,"composition");G(this,"type","base");G(this,"strategy",new pl)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&Zi(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 k0,this.strategy.update(new Ra,this)):this.strategy=new pl,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,Mv(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(be.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(Zi(this.clipRef)&&(!ji(a,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!ji(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(ji(a,c)&&!c.disabled)return this.pointer=l,Zi(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 be}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new be}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 ji(o,n){return n?o>=n.start.millis&&o<=n.stop.millis:!1}function Zi(o){return o?!!o.view.parent:!1}class _0{static fromType(n){switch(n.type){case"video":return new E0;case"audio":return new C0;case"html":return new S0;case"image":return new x0;case"text":return new gl;case"complex_text":return new gl;case"caption":return new N0;default:return new ta}}}class jc extends ta{constructor(){super(...arguments);G(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 E0 extends jc{constructor(){super(...arguments);G(this,"type","video")}async seek(t){var a;(a=this.composition)!=null&&a.rendering?this.view.removeChildren():super.seek(t)}}class x0 extends ta{constructor(){super(...arguments);G(this,"type","image")}}class C0 extends jc{constructor(){super(...arguments);G(this,"type","audio")}}class gl extends ta{constructor(){super(...arguments);G(this,"type","text")}}class S0 extends ta{constructor(){super(...arguments);G(this,"type","html")}}var V0=Object.defineProperty,Wr=(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&&V0(n,t,i),i};class Aa extends Ft{constructor(t={}){super();G(this,"generatorOptions");G(this,"type","CLASSIC");G(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 Ke({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 be,i=await pt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new Qn({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 Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"})}))}}Wr([ye()],Aa.prototype,"generatorOptions");Wr([ye()],Aa.prototype,"type");Wr([ye()],Aa.prototype,"position");class N0 extends ta{constructor(){super(...arguments);G(this,"clip");G(this,"type","caption");G(this,"preset",new Aa)}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 T0=Object.defineProperty,Xo=(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&&T0(n,t,i),i};class La extends Ft{constructor(t={}){super();G(this,"generatorOptions");G(this,"type","SPOTLIGHT");G(this,"color");G(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 Ke({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 be,i=await pt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Ho({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)}))}}}Xo([ye()],La.prototype,"generatorOptions");Xo([ye()],La.prototype,"type");Xo([ye()],La.prototype,"color");Xo([ye()],La.prototype,"position");var M0=Object.defineProperty,jr=(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};class Go extends Ft{constructor(t={}){super();G(this,"type","GUINEA");G(this,"colors");G(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 Ke({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 be,i=await pt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const h of t.clip.transcript.iter({length:[18]})){const{segments:p,words:v}=this.splitSequence(h);for(let y=0;y<h.words.length;y++){const w=(d=(c=v[y])==null?void 0:c.at(0))==null?void 0:d.start,N=(m=(u=v[y])==null?void 0:u.at(-1))==null?void 0:m.stop;!w||!N||await t.add(new Ho({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:N.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:wo(0,2),start:p.slice(0,y).join(" ").length,stop:p.slice(0,y+1).join(" ").length+y*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=[...nl(a,r).map(c=>c.trim())],l=nl(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}jr([ye()],Go.prototype,"type");jr([ye()],Go.prototype,"colors");jr([ye()],Go.prototype,"position");var B0=Object.defineProperty,Zr=(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&&B0(n,t,i),i};class Jo extends Ft{constructor(t={}){super();G(this,"generatorOptions");G(this,"type","CASCADE");G(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 Ke({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 be,i=await pt.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(m=>m.text).slice(0,d+1).join(" ");await t.add(new Qn({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)}))}}}Zr([ye()],Jo.prototype,"generatorOptions");Zr([ye()],Jo.prototype,"type");Zr([ye()],Jo.prototype,"position");var I0=Object.defineProperty,Hr=(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&&I0(n,t,i),i};class Yo extends Ft{constructor(t={}){super();G(this,"generatorOptions");G(this,"type","SOLAR");G(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 Ke({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=await pt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new be,r=new lm.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Qn({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 Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}Hr([ye()],Yo.prototype,"generatorOptions");Hr([ye()],Yo.prototype,"type");Hr([ye()],Yo.prototype,"position");var F0=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&&F0(n,t,i),i};class Ua extends Ft{constructor(t={}){super();G(this,"generatorOptions");G(this,"type","WHISPER");G(this,"color");G(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 Ke({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 be,i=await pt.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Ho({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}))}}}qo([ye()],Ua.prototype,"generatorOptions");qo([ye()],Ua.prototype,"type");qo([ye()],Ua.prototype,"color");qo([ye()],Ua.prototype,"position");var $0=Object.defineProperty,Ko=(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&&$0(n,t,i),i};class Qo extends Ft{constructor(t={}){super();G(this,"type","VERDANT");G(this,"generatorOptions");G(this,"color");G(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 Ke({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 be,i=await pt.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(m=>m.text);await t.add(new Ho({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}]}))}}}Ko([ye()],Qo.prototype,"type");Ko([ye()],Qo.prototype,"generatorOptions");Ko([ye()],Qo.prototype,"color");Ko([ye()],Qo.prototype,"position");class R0 extends Fa(Ft){constructor({height:t=1080,width:a=1920,background:i="#000000",backend:r="webgpu"}={}){super();G(this,"_duration",new be);G(this,"renderer");G(this,"stage",new We.Container);G(this,"settings");G(this,"tracks",[]);G(this,"frame",0);G(this,"fixedDuration");G(this,"state","IDLE");G(this,"fps",Ta);G(this,"canvas");G(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)),We.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Yn({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 be?this.fixedDuration=t:this.fixedDuration=be.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 al(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;al(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(be.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 Yn({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(be.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(be.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(Po)){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),y=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]+=(y[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=jn(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/Ta;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 D0(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 gr=[8e3,12e3,16e3,24e3,48e3],A0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",L0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class U0{constructor(n){G(this,"output");G(this,"error");G(this,"config");G(this,"encoder");G(this,"opus");G(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(L0),{numberOfChannels:a,sampleRate:i}=this.config=n;if(!gr.includes(i))throw new Fo({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${gr.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?A0:s+r}}),this.encoder=this.opus._opus_encoder_create(i,a,2048),this.meta={decoderConfig:{codec:"opus",description:D0(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 Fo({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 O0(o){const n=gr;let t=48e3;for(const a of n)Math.abs(o-a)<Math.abs(o-t)&&(t=a);return t}class z0{constructor(n,t){G(this,"canvas");G(this,"muxer");G(this,"videoEncoder");G(this,"frame",0);G(this,"sampleRate");G(this,"numberOfChannels");G(this,"videoBitrate");G(this,"gpuBatchSize");G(this,"fps");G(this,"height");G(this,"width");G(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=O0((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 Fv({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Mc({target:new Fr,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 Fo({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=Iv(n,this.sampleRate,this.numberOfChannels),a=new U0({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:Bv(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 Fo({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 P0(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 Dt(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 ro(o){return o>5?o/100:o}function At(o,n,t){return Math.min(t,Math.max(n,o))}function wt(){return new qe.ColorMatrixFilter}function W0(o,n){switch(o){case"brightness":{const t=wt(),a=Dt(n.value??n.brightness,1);return t.brightness(At(ro(a),0,5),!1),t}case"contrast":{const t=wt(),a=Dt(n.value??n.contrast,1);return t.contrast(At(ro(a),0,5),!1),t}case"saturation":{const t=wt(),a=Dt(n.value??n.saturation,1);return t.saturate(At(ro(a),0,5),!1),t}case"hue":{const t=wt(),a=Dt(n.degrees??n.value,0);return t.hue(At(a,-180,180),!1),t}case"blur":case"softFocus":{const t=o==="softFocus"?1:0,a=Dt(n.radius??n.blur??n.value,t);return new qe.BlurFilter({strength:At(a,0,32),quality:4})}case"grayscale":{const t=wt(),a=At(Dt(n.amount,100),0,100);return a<=0?null:(a>=100?t.desaturate():t.saturate(1-a/100,!1),t)}case"sepia":{if(At(Dt(n.amount,100),0,100)<=0)return null;const a=wt();return a.sepia(!1),a}case"invert":{if(At(Dt(n.amount,100),0,100)<=0)return null;const a=wt();return a.negative(!1),a}case"warmth":{const t=wt(),a=At(Dt(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=wt(),a=At(Dt(n.intensity,.3),0,1),i=typeof n.color=="string"?n.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,l=parseInt(r.slice(2,4),16)/255,c=parseInt(r.slice(4,6),16)/255;t.matrix=[1-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=wt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=wt(),a=At(ro(Dt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(a,!1),t}case"cinematic":{const t=wt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=wt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=wt();return t.brightness(1.05,!1),t.saturate(.9,!1),t.contrast(.95,!1),t}default:return null}}typeof window<"u"&&!window.PIXI&&(window.PIXI=qe);class Zc{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 R0({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 P0(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=Cn.from)==null?void 0:a.call(Cn,r,{crossOrigin:"anonymous"}))??await Cn.from(r),l=new hr(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=pt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),a=new Qn({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 Se([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(a.scale=new Se([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(oe.getFilter(n.filterId)&&!oe.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=_m(n.filterId,a);return r||(r=W0(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 z0(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 j0=["src"],Z0={class:"preview-controls"},H0=["aria-label"],X0={class:"time-display"},G0={class:"current-time"},J0={class:"total-time"},Y0={key:2,class:"loading-overlay"},q0={key:3,class:"error-overlay"},K0=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),y=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),w=e.computed(()=>{var S,L;return(S=t.media)!=null&&S.url?t.media.url:(((L=t.media)==null?void 0:L.file)instanceof File,"")});async function N(){var S,L,R;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const P=((S=t.recipe.source)==null?void 0:S.original_width)||1920,A=((L=t.recipe.source)==null?void 0:L.original_height)||1080,B=((R=t.recipe.output)==null?void 0:R.fps)||30;p=new Zc(P,A,B,{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),C(),l.value=!1,a("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(P){const A=P instanceof Error?P.message:String(P);d.value=`Failed to initialize: ${A}`,l.value=!1}}function C(){if(!p)return;const S=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,a("time-update",m.value))},100);Z.value=S}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(S){const L=Math.floor(S/60),R=Math.floor(S%60);return`${L}:${R.toString().padStart(2,"0")}`}function _(){d.value=null,v.value&&N()}function $(){!v.value&&s.value&&(h.value=s.value.duration,a("duration-change",h.value))}function T(){!v.value&&s.value&&(m.value=s.value.currentTime,a("time-update",m.value))}function x(){u.value=!1,a("play-state-change",!1)}function I(S){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&N()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),Z.value&&(clearInterval(Z.value),Z.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async S=>{if(v.value&&S)if(p)try{await p.loadFromRecipe(S),h.value=p.durationInSeconds,a("duration-change",h.value)}catch{}else await N()}),e.watch(()=>t.enableEngine,async S=>{S?await N():p&&(Z.value&&(clearInterval(Z.value),Z.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async S=>{if(!(!v.value||!p))try{p.setFitMode(S||"contain")}catch{}});const Z=e.ref(null);return(S,L)=>(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:$,onTimeupdate:T,onEnded:x,onError:I,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:y.value}),playsinline:"",controls:""},null,44,j0)),e.createElementVNode("div",Z0,[e.createElementVNode("button",{class:"play-button",onClick:b,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(O.IonIcon),{icon:u.value?e.unref(sc):e.unref(cc)},null,8,["icon"])],8,H0),e.createElementVNode("div",X0,[e.createElementVNode("span",G0,e.toDisplayString(f(m.value)),1),L[0]||(L[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",J0,e.toDisplayString(f(h.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Y0,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",q0,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Nr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:_},"Retry")])):e.createCommentVNode("",!0)],512))}}),yl=Ce(K0,[["__scopeId","data-v-7e604791"]]),Q0=["aria-label"],eg=["aria-label"],tg={class:"clip-content"},ng={key:0,class:"clip-thumbnail"},ag=["src","alt"],og={class:"clip-waveform"},ig={class:"clip-info"},rg={class:"clip-label"},sg={class:"clip-duration"},lg={key:1,class:"filter-indicators"},cg={key:2,class:"speed-indicator"},dg={key:0,class:"selection-overlay"},ug=420,mg=8,pg=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`}}),y=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),w=e.computed(()=>{const D=t.clip.timelineEnd-t.clip.timelineStart;return b(D)}),N=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),C=e.computed(()=>t.clip.filters||[]);function b(D){if(D<1)return`${Math.round(D*30)}f`;if(D<60)return`${D.toFixed(1)}s`;{const k=Math.floor(D/60),F=Math.floor(D%60);return`${k}:${F.toString().padStart(2,"0")}`}}function f(D){return!D||typeof D!="string"?Ys:D.includes("color")||D.includes("brightness")?fn:D.includes("blur")?Km:D.includes("style")?ha:D.includes("effect")?pn:Ys}function _(){r.value||a("select")}function $(D){D.button===0&&(I("move",D.clientX),D.preventDefault())}function T(D){if(D.touches.length!==1)return;const k=D.touches[0];if(!t.isMobile){I("move",k.clientX),D.preventDefault();return}d.value=k.clientX,u.value=k.clientY,m.value=!1,h.value=!1,Z(),S(),p.value=window.setTimeout(()=>{h.value=!0,S(),t.selected||a("select"),a("long-press")},ug),document.addEventListener("touchmove",L),document.addEventListener("touchend",R),document.addEventListener("touchcancel",R),D.preventDefault()}function x(D,k){const F="touches"in k?k.touches[0].clientX:k.clientX;s.value=D==="start"?"trim-start":"trim-end",I(s.value,F),k.preventDefault(),k.stopPropagation()}function I(D,k){Z(),S(),r.value=!0,s.value=D,l.value=k,D==="move"?c.value=t.clip.timelineStart:D==="trim-start"?c.value=t.clip.sourceIn:D==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",P),document.addEventListener("mouseup",A),document.addEventListener("touchmove",P),document.addEventListener("touchend",A),t.selected||a("select")}function Z(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function S(){document.removeEventListener("touchmove",L),document.removeEventListener("touchend",R),document.removeEventListener("touchcancel",R)}function L(D){if(D.touches.length!==1)return;const k=D.touches[0],F=k.clientX-d.value,H=k.clientY-u.value;Math.hypot(F,H)<mg||(m.value=!0,Z(),S(),I("move",k.clientX),P(D),D.preventDefault())}function R(){const D=!m.value&&!h.value&&!r.value;Z(),S(),m.value=!1,h.value=!1,D&&a("select")}function P(D){if(!r.value||!s.value)return;const k="touches"in D?D.touches[0].clientX:D.clientX,H=k-l.value;s.value==="move"?(a("drag",H),a("drag-abs",k)):s.value==="trim-start"?(a("trim-start",H),a("trim-start-abs",k)):s.value==="trim-end"&&(a("trim-end",H),a("trim-end-abs",k))}function A(){r.value=!1,s.value=null,document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",A),document.removeEventListener("touchmove",P),document.removeEventListener("touchend",A)}function B(){if(!i.value)return;const D=i.value,k=D.getContext("2d");if(!k)return;D.width=D.clientWidth*window.devicePixelRatio,D.height=D.clientHeight*window.devicePixelRatio,k.scale(window.devicePixelRatio,window.devicePixelRatio),k.strokeStyle="rgba(255, 255, 255, 0.3)",k.lineWidth=1,k.beginPath();const F=D.clientWidth,H=D.clientHeight,j=H/2;k.moveTo(0,j),k.lineTo(F,j);for(let te=0;te<F;te+=4){const he=Math.sin(te*.05)*(H*.3);k.moveTo(te,j-he),k.lineTo(te,j+he)}k.stroke()}return e.onMounted(()=>{B(),window.addEventListener("resize",B)}),e.onUnmounted(()=>{A(),Z(),S(),window.removeEventListener("resize",B)}),(D,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:D.selected,mobile:D.isMobile,"has-filters":N.value}]),style:e.normalizeStyle(v.value),onClick:_,onMousedown:$,onTouchstart:T},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:k[0]||(k[0]=e.withModifiers(F=>x("start",F),["stop"])),onTouchstart:k[1]||(k[1]=e.withModifiers(F=>x("start",F),["stop"])),"aria-label":`Trim start of ${D.clip.label||"clip"}`},[...k[4]||(k[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Q0),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:k[2]||(k[2]=e.withModifiers(F=>x("end",F),["stop"])),onTouchstart:k[3]||(k[3]=e.withModifiers(F=>x("end",F),["stop"])),"aria-label":`Trim end of ${D.clip.label||"clip"}`},[...k[5]||(k[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,eg),e.createElementVNode("div",tg,[D.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",ng,[e.createElementVNode("img",{src:D.clip.thumbnail,alt:D.clip.label||"Video clip"},null,8,ag)])):e.createCommentVNode("",!0),e.createElementVNode("div",og,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",ig,[e.createElementVNode("span",rg,e.toDisplayString(y.value),1),e.createElementVNode("span",sg,e.toDisplayString(w.value),1)]),N.value?(e.openBlock(),e.createElementBlock("div",lg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,F=>(e.openBlock(),e.createBlock(e.unref(O.IonIcon),{key:F.id||F.filterId,icon:f(F.filterId||F.id),title:`Filter: ${F.filterId||F.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),D.clip.speed&&D.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",cg,e.toDisplayString(D.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),D.selected?(e.openBlock(),e.createElementBlock("div",dg)):e.createCommentVNode("",!0)],38))}}),fg=Ce(pg,[["__scopeId","data-v-be208792"]]);class Hc{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const a=new hr(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 Cn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=be.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof hr&&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 hg={class:"time-markers"},vg=["aria-label","title"],gg={key:0,class:"timeline-scrollbar"},yg=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,M=>{M!==void 0&&(l.value=M)});const p=new Hc(a.fps),v=e.ref(!1),y=e.ref(null),w=e.ref(0),N=e.ref(0),C=e.ref(null),b=e.ref(0),f=e.ref(0),_=e.ref(0),$=e.ref(!1),T=e.ref(0),x=e.ref(a.zoomLevel),I=e.computed(()=>a.zoomLevel);function Z(M){const z=a.clips.find(q=>q.id===M);if(!z)return null;const J=a.clips.filter(q=>q.id!==M&&q.timelineStart>=z.timelineEnd-1e-9).map(q=>q.timelineStart);return J.length?Math.min(...J):null}function S(M){const z=M.sourceMaxOut??a.duration,J=M.timelineStart+(z-M.sourceIn),q=Z(M.id),ue=q!=null?Math.max(M.timelineStart,q):1/0;return Math.min(J,ue)}function L(M){const z=M.sourceMinIn??0,q=(M.sourceMaxOut??a.duration)-z,ue=M.sourceIn-z;return{left:`${(M.timelineStart-ue)*I.value-d.value}px`,width:`${q*I.value}px`,top:"0px",height:"80px",opacity:h.value===M.id?.25:.15}}const R=e.computed(()=>a.useFrameMode?a.zoomLevel:a.zoomLevel/a.fps),P=e.computed(()=>p.secondsToFrames(a.duration)),A=e.computed(()=>a.useFrameMode?P.value*R.value:a.duration*I.value),B=e.computed(()=>{var M;return m.value||((M=s.value)==null?void 0:M.clientWidth)||800}),D=e.computed(()=>A.value>B.value),k=e.computed(()=>Math.max(0,A.value-B.value)),F=e.computed(()=>d.value>0),H=e.computed(()=>d.value<k.value),j=e.computed(()=>a.useFrameMode?p.secondsToFrames(a.playhead)*R.value-d.value:a.playhead*I.value-d.value),te=e.computed(()=>C.value===null?null:a.useFrameMode?p.secondsToFrames(C.value)*R.value-d.value:C.value*I.value-d.value),he=e.computed(()=>{const M=Math.max(50,B.value/A.value*B.value),z=d.value/k.value*(B.value-M);return{width:`${M}px`,left:`${z}px`}}),ge=e.computed(()=>{const M=[],z=ae();for(let J=0;J<=a.duration;J+=z){const q=J*I.value-d.value;q>=-50&&q<=B.value+50&&M.push({position:q,label:V(J),time:J})}return M});function ae(){const z=80/I.value;return z<=1?1:z<=5?5:z<=10?10:z<=30?30:z<=60?60:Math.ceil(z/60)*60}function V(M){if(a.useFrameMode)return`F${p.secondsToFrames(M)}`;{const z=Math.floor(M/60),J=Math.floor(M%60),q=Math.floor(M%1*a.fps);return I.value>100?`${z}:${J.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`:`${z}:${J.toString().padStart(2,"0")}`}}function U(M){const z=s.value.getBoundingClientRect();let q=(M.clientX-z.left+d.value)/I.value;const ue=a.clips.find(ve=>q>=ve.timelineStart&&q<=ve.timelineEnd);if(ue)q=Math.max(ue.timelineStart,Math.min(ue.timelineEnd,q));else if(a.selectedClipId){const ve=a.clips.find(Te=>Te.id===a.selectedClipId);if(ve){const Te=Math.abs(q-ve.timelineStart),$e=Math.abs(q-ve.timelineEnd);q=Te<$e?ve.timelineStart:ve.timelineEnd}}else q=Math.max(0,Math.min(q,a.duration));r("update:playhead",q)}function K(M){if(!D.value)return;const z=Math.abs(M.deltaX)>Math.abs(M.deltaY)?M.deltaX:M.deltaY;z!==0&&(M.preventDefault(),d.value=Math.max(0,Math.min(k.value,d.value+z)))}function ee(){return[...a.clips].sort((M,z)=>M.timelineStart-z.timelineStart)}function ne(M){const z=ee(),J=z.findIndex(q=>q.id===M);return{previous:J>0?z[J-1]:null,next:J!==-1&&J<z.length-1?z[J+1]:null}}function fe(M){const z=M.timelineEnd-M.timelineStart,{previous:J,next:q}=ne(M.id),ue=J?J.timelineEnd:0,ve=q?q.timelineStart-z:Math.max(M.timelineStart,a.duration-z);return{minStart:ue,maxStart:Math.max(ue,ve)}}function ie(){return 12/Math.max(I.value,1)}function pe(M){return Array.from(new Set(M.filter(z=>typeof z=="number"&&Number.isFinite(z))))}function ke(M,z,J,q){const ue=Math.max(J,Math.min(M,q));if(!a.snapEnabled)return{value:ue,guideTime:null};const ve=ie();let Te=ue,$e=null,Be=Number.POSITIVE_INFINITY;for(const Ae of pe(z)){if(Ae<J||Ae>q)continue;const et=Math.abs(Ae-ue);et<=ve&&et<Be&&(Te=Ae,$e=Ae,Be=et)}return{value:Te,guideTime:$e}}function re(M){if(M.touches.length===2){$.value=!0;const z=M.touches[0],J=M.touches[1];T.value=Math.hypot(J.clientX-z.clientX,J.clientY-z.clientY),x.value=a.zoomLevel}else M.touches.length===1&&(b.value=M.touches[0].clientX,f.value=M.touches[0].clientY,_.value=b.value)}function ce(M){if($.value&&M.touches.length===2){const z=M.touches[0],J=M.touches[1],ue=Math.hypot(J.clientX-z.clientX,J.clientY-z.clientY)/T.value;Math.max(10,Math.min(200,x.value*ue)),r("update:playhead",a.playhead)}else if(M.touches.length===1&&!$.value){const z=M.touches[0],J=_.value-z.clientX;Math.abs(J)>Math.abs(z.clientY-f.value)&&(M.preventDefault(),d.value=Math.max(0,Math.min(A.value-B.value,d.value+J)),_.value=z.clientX)}}function _e(){$.value=!1}function Ve(M){const z=M.target;if(z.closest(".playhead-handle"))return;const J=M.button===1,q=!!z.closest(".video-track");(J||!q&&D.value)&&ut(M)}function ut(M){v.value=!0,y.value="pan",w.value=M.clientX,N.value=d.value,document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",at)}function He(M){M.preventDefault(),M.stopPropagation(),v.value=!0,y.value="playhead";const z="touches"in M?M.touches[0].clientX:M.clientX;w.value=z,N.value=a.playhead,"touches"in M?(document.addEventListener("touchmove",Ge),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",at))}function xt(M){M.preventDefault(),M.stopPropagation(),v.value=!0,y.value="scrollbar";const z="touches"in M?M.touches[0].clientX:M.clientX;w.value=z,N.value=d.value,"touches"in M?(document.addEventListener("touchmove",Ge),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",at))}function Ge(M){if(!v.value)return;const J=("touches"in M?M.touches[0].clientX:M.clientX)-w.value;if(y.value==="playhead"){const q=J/I.value;let ue=N.value+q;if(a.selectedClipId){const ve=a.clips.find(Te=>Te.id===a.selectedClipId);ve?ue=Math.max(ve.timelineStart,Math.min(ve.timelineEnd,ue)):ue=Math.max(0,Math.min(a.duration,ue))}else{const ve=a.clips.find(Te=>a.playhead>=Te.timelineStart&&a.playhead<=Te.timelineEnd);ve?ue=Math.max(ve.timelineStart,Math.min(ve.timelineEnd,ue)):ue=Math.max(0,Math.min(a.duration,ue))}r("update:playhead",ue)}else if(y.value==="scrollbar"){const q=J/B.value*A.value;d.value=Math.max(0,Math.min(k.value,N.value+q))}else if(y.value==="pan"){const q=N.value-J;d.value=Math.max(0,Math.min(k.value,q))}}function at(){v.value=!1,y.value=null,C.value=null,document.removeEventListener("mousemove",Ge),document.removeEventListener("mouseup",at),document.removeEventListener("touchmove",Ge),document.removeEventListener("touchend",at)}function Ct(M){l.value=l.value===M?null:M,r("clip-select",l.value)}function $t(M){l.value=M,r("clip-select",M),r("clip-long-press",M)}function lt(M,z){const J=a.clips.find(ue=>ue.id===M);if(!J||Math.abs(z)<2)return;const q=z/I.value*a.sensitivity;if(a.useFrameMode){const ue=p.secondsToFrames(J.sourceIn),ve=p.secondsToFrames(q),Te=Math.max(0,ue+ve),$e=p.framesToSeconds(Te);r("trim",M,"start",$e)}else{const ue=Math.max(0,J.sourceIn+q);r("trim",M,"start",ue)}}function yt(M,z){const J=a.clips.find(Ot=>Ot.id===M);if(!J||!s.value)return;const q=s.value.getBoundingClientRect(),ue=z-q.left,ve=80;if(ue<ve)d.value=Math.max(0,d.value-8);else if(ue>q.width-ve){const Ot=Math.max(0,A.value-B.value);d.value=Math.min(Ot,d.value+8)}const Te=ue+d.value,$e=1/a.fps;let Be=Te/I.value;const{previous:Ae}=ne(J.id),et=ke(Be,[0,Ae==null?void 0:Ae.timelineEnd,a.playhead],0,J.timelineEnd-$e);Be=et.value,C.value=et.guideTime;let ht=J.sourceIn+(Be-J.timelineStart);ht=Math.round(ht*a.fps)/a.fps,r("trim",M,"start",ht)}function de(M,z){const J=a.clips.find(oa=>oa.id===M);if(!J||!s.value)return;const q=s.value.getBoundingClientRect(),ue=z-q.left,ve=80;if(ue<ve)d.value=Math.max(0,d.value-8);else if(ue>q.width-ve){const oa=Math.max(0,A.value-B.value);d.value=Math.min(oa,d.value+8)}const Te=ue+d.value,$e=1/a.fps,Be=S(J);let Ae=Te/I.value;const{next:et}=ne(J.id),ht=ke(Ae,[et==null?void 0:et.timelineStart,a.playhead],J.timelineStart+$e,Be);Ae=ht.value,C.value=ht.guideTime;let Ot=J.sourceIn+(Ae-J.timelineStart);Ot=Math.round(Ot*a.fps)/a.fps,r("trim",M,"end",Ot)}function Ee(M,z){const J=a.clips.find(ht=>ht.id===M);if(!J||!s.value)return;const q=s.value.getBoundingClientRect(),ue=z-q.left,ve=80;if(ue<ve)d.value=Math.max(0,d.value-8);else if(ue>q.width-ve){const ht=Math.max(0,A.value-B.value);d.value=Math.min(ht,d.value+8)}const Te=ue+d.value,$e=J.timelineEnd-J.timelineStart,Be=fe(J);let Ae=Te/I.value;const et=ke(Ae,[Be.minStart,Be.maxStart,a.playhead,a.playhead-$e],Be.minStart,Be.maxStart);Ae=et.value,C.value=et.guideTime,Ae=Math.round(Ae*a.fps)/a.fps,r("clip-move",M,Ae)}function xe(M,z){const J=a.clips.find(ve=>ve.id===M);if(!J||Math.abs(z)<2)return;const q=z/I.value*a.sensitivity,ue=ve=>Math.max(0,Math.round(ve*a.fps)/a.fps);if(a.useFrameMode){const ve=p.secondsToFrames(J.sourceOut),Te=p.secondsToFrames(q),$e=S(J),Be=J.sourceIn+($e-J.timelineStart),Ae=p.secondsToFrames(Be),et=Math.min(Ae,ve+Te),ht=p.framesToSeconds(et);r("trim",M,"end",ht)}else{const ve=S(J),Te=J.sourceIn+(ve-J.timelineStart),$e=Math.min(Te,J.sourceOut+q),Be=ue($e);r("trim",M,"end",Be)}}function ze(M,z){const J=a.clips.find(ve=>ve.id===M);if(!J||Math.abs(z)<2)return;const q=z/I.value*a.sensitivity,ue=ve=>Math.max(0,Math.round(ve*a.fps)/a.fps);if(a.useFrameMode){const ve=p.secondsToFrames(J.timelineStart),Te=p.secondsToFrames(q),$e=Math.max(0,ve+Te),Be=p.framesToSeconds($e);r("clip-move",M,Be)}else{const ve=Math.max(0,J.timelineStart+q),Te=ue(ve);r("clip-move",M,Te)}}return n({handleTrimStart:lt,handleTrimEnd:xe,handleClipDrag:ze,handleTrimStartAbs:yt,handleTrimEndAbs:de,handleClipDragAbs:Ee,handleClipLongPress:$t}),e.watch(()=>a.playhead,M=>{const z=M*I.value;z<d.value+50?d.value=Math.max(0,z-50):z>d.value+B.value-50&&(d.value=Math.min(k.value,z-B.value+50))}),e.onMounted(()=>{const M=new ResizeObserver(z=>{z[0]&&(m.value=Math.round(z[0].contentRect.width))});s.value&&M.observe(s.value),e.onUnmounted(()=>M.disconnect())}),e.onUnmounted(()=>{at()}),e.watch([A,B],()=>{d.value>k.value&&(d.value=k.value)}),e.watch(C,(M,z)=>{const J=M!==null;J!==(z!==null)&&r("snap-state-change",J)}),(M,z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:K},[e.createElementVNode("div",{class:"timeline-ruler",onClick:U},[e.createElementVNode("div",hg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ge.value,J=>(e.openBlock(),e.createElementBlock("span",{key:J.position,class:"time-marker",style:e.normalizeStyle({left:`${J.position}px`})},e.toDisplayString(J.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":D.value,"is-panning":v.value&&y.value==="pan","overflow-left":F.value,"overflow-right":H.value}]),onTouchstart:re,onTouchmove:ce,onTouchend:_e,onMousedown:Ve},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.clips,J=>(e.openBlock(),e.createElementBlock("div",{key:`${J.id}-extent`,class:"clip-extent",style:e.normalizeStyle(L(J)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.clips,J=>(e.openBlock(),e.createBlock(fg,{key:J.id,clip:J,scale:I.value,"scroll-offset":d.value,selected:h.value===J.id,"is-mobile":i.value,onSelect:q=>Ct(J.id),onLongPress:q=>$t(J.id),onTrimStartAbs:q=>yt(J.id,q),onTrimEndAbs:q=>de(J.id,q),onDragAbs:q=>Ee(J.id,q)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${j.value}px`}),onMousedown:He,onTouchstart:He},[...z[1]||(z[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${j.value}px`})},null,4)):e.createCommentVNode("",!0),te.value!==null?(e.openBlock(),e.createElementBlock("div",{key:1,class:"snap-guide",style:e.normalizeStyle({left:`${te.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"frame-mode-toggle",onClick:z[0]||(z[0]=J=>M.$emit("toggle-frame-mode")),"aria-label":M.useFrameMode?"Switch to time mode":"Switch to frame mode",title:M.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(M.useFrameMode?"F":"T"),9,vg))],34),D.value?(e.openBlock(),e.createElementBlock("div",gg,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(he.value),onMousedown:xt,onTouchstart:xt},null,36)])):e.createCommentVNode("",!0)],34))}}),bl=Ce(yg,[["__scopeId","data-v-d46ec03b"]]),bg={class:"control-group zoom-controls"},wg={class:"zoom-slider"},kg=["value"],_g={class:"control-group playback-controls"},Eg=["aria-label"],xg={key:0,class:"control-group speed-control"},Cg=["value"],Sg=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(O.IonIcon),{icon:e.unref(pp)},null,8,["icon"])]),e.createElementVNode("div",wg,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,kg)]),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(O.IonIcon),{icon:e.unref(Um)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(qm)},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(O.IonIcon),{icon:e.unref(up)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(sp)},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(O.IonIcon),{icon:u.isPlaying?e.unref(lc):e.unref(dc)},null,8,["icon"])],8,Eg),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(dp)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(mp)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",xg,[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,Cg)]))],2))}}),Vg=Ce(Sg,[["__scopeId","data-v-7bf65ab9"]]),Ng={key:0,class:"category-section"},Tg={class:"category-carousel-wrapper"},Mg=["disabled"],Bg=["onClick","data-testid","aria-label"],Ig={class:"category-name"},Fg=["disabled"],$g={class:"filter-section"},Rg={class:"filter-carousel-wrapper"},Dg=["disabled"],Ag=["onClick","onKeydown","data-testid","aria-label"],Lg=["onClick"],Ug={class:"filter-preview"},Og={class:"filter-placeholder"},zg={class:"filter-name"},Pg=["disabled"],Wg={class:"carousel-pagination"},jg=["onClick"],Zg={key:1,class:"filter-adjustments"},Hg={class:"adjustment-header"},Xg={class:"adjustment-actions"},Gg={key:0},Jg={key:0,class:"slider-control"},Yg={class:"control-label"},qg={class:"slider-wrapper"},Kg={class:"slider-value"},Qg={key:1,class:"color-control"},e1={class:"control-label"},t1={class:"color-wrapper"},n1=["value","onInput","disabled"],a1={class:"color-value"},o1={key:2,class:"toggle-control"},i1={class:"control-label"},r1={key:3,class:"select-control"},s1={class:"control-label"},l1=["value","onChange","disabled"],c1=["value"],d1={key:1,class:"no-params"},u1=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:pn,adjust:ca,color:fn,blur:to,light:da,effects:Ai,stylize:ha,advanced:pn,distortion:va,transform:va};function h(k){return k.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(k){return k.replace(/[-_]/g," ").replace(/\b\w/g,F=>F.toUpperCase())}function v(k){return m[k.toLowerCase()]??pn}const y=e.computed(()=>{const k=Array.from(new Set(t.filters.map(F=>F.category).filter(F=>typeof F=="string"&&F.length>0))).sort((F,H)=>F.localeCompare(H));return[{id:"all",name:"All",icon:pn},...k.map(F=>({id:F,name:p(F),icon:v(F)}))]}),w=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(k=>k.category===i.value));e.watch(y,k=>{new Set(k.map(j=>j.id)).has(i.value)||(i.value="all");const H=Math.max(0,k.length-3);s.value>H&&(s.value=H)},{immediate:!0});function N(k){var F;return((F=t.activeFilters)==null?void 0:F.has(k))||!1}function C(k){if(r.value=k,!N(k.id)&&(a("apply-filter",k),k.params&&k.params.length>0)){const F=new Map;k.params.forEach(H=>{F.set(H.id,H.default)}),c.value.set(k.id,F)}a("preview-filter",k)}function b(k){var F;a("remove-filter",k),c.value.delete(k),((F=r.value)==null?void 0:F.id)===k&&(r.value=null)}function f(k){if(typeof k=="number"&&Number.isFinite(k))return k;if(typeof k=="string"){const F=Number(k);return Number.isFinite(F)?F:null}return null}function _(k,F){var V;const H=t.filters.find(U=>U.id===k),j=H==null?void 0:H.params.find(U=>U.id===F),te=(j==null?void 0:j.default)??0,he=U=>typeof te=="number"?f(U)??te:typeof te=="boolean"?typeof U=="boolean"?U:te:typeof U=="string"?U:te,ge=(V=t.activeFilters)==null?void 0:V.get(k);if(ge&&ge.params){const U=ge.params[F];if(U!=null)return he(U)}const ae=c.value.get(k);if(ae){const U=ae.get(F);if(U!=null)return he(U)}return te}function $(k,F,H){var j;c.value.has(k)||c.value.set(k,new Map),(j=c.value.get(k))==null||j.set(F,H),a("update-param",k,F,H)}function T(k){if(typeof k=="boolean")return k?"On":"Off";if(typeof k=="string"){const H=f(k);return H===null?"0":Number.isInteger(H)?H.toString():H.toFixed(2)}const F=f(k);return F===null?"0":Number.isInteger(F)?F.toString():F.toFixed(2)}function x(){if(r.value&&(a("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const k=new Map;r.value.params.forEach(F=>{k.set(F.id,F.default)}),c.value.set(r.value.id,k)}}function I(k){const F=t.filters.find(H=>H.id===k);F&&F.params&&F.params.forEach(H=>{$(k,H.id,H.default)})}function Z(k){return{basic:ca,color:fn,blur:to,light:da,effects:Ai,stylize:ha,adjustment:ca,"color-matrix":fn,glow:pn,distortion:va}[k]||pn}function S(k){return{adjustment:ca,brightness:da,contrast:ca,saturation:fn,blur:to,"gaussian-blur":to,"color-matrix":fn,grayscale:ha,sepia:ha,vignette:va,glow:pn,glitch:Ai,godray:da,lightmap:da}[k.id]||Z(k.category)}function L(){s.value>0&&(s.value--,D(d.value,s.value))}function R(){s.value<y.value.length-3&&(s.value++,D(d.value,s.value))}function P(){l.value>0&&(l.value--,D(u.value,l.value))}function A(){l.value<w.value.length-4&&(l.value++,D(u.value,l.value))}function B(k){l.value=k*4,D(u.value,l.value)}function D(k,F){var H;if(k){const j=((H=k.querySelector(".category-chip, .filter-card"))==null?void 0:H.clientWidth)||100;k.scrollTo({left:F*(j+8),behavior:"smooth"})}}return(k,F)=>{var H;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:k.compact}])},[k.showCategories?(e.openBlock(),e.createElementBlock("div",Ng,[e.createElementVNode("div",Tg,[e.createElementVNode("button",{onClick:L,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Zs)},null,8,["icon"])],8,Mg),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,j=>(e.openBlock(),e.createElementBlock("button",{key:j.id,onClick:te=>i.value=j.id,class:e.normalizeClass(["category-chip",{active:i.value===j.id}]),"data-testid":`btn-filter-category-${h(j.id)}`,"aria-label":`Filter category ${j.name}`},[e.createVNode(e.unref(O.IonIcon),{icon:j.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",Ig,e.toDisplayString(j.name),1)],10,Bg))),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:s.value>=y.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Hs)},null,8,["icon"])],8,Fg)])])):e.createCommentVNode("",!0),e.createElementVNode("div",$g,[e.createElementVNode("div",Rg,[e.createElementVNode("button",{onClick:P,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Zs)},null,8,["icon"])],8,Dg),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,j=>{var te;return e.openBlock(),e.createElementBlock("div",{key:j.id,class:e.normalizeClass(["filter-card",{active:N(j.id),selected:((te=r.value)==null?void 0:te.id)===j.id}]),onClick:he=>C(j),onKeydown:[e.withKeys(he=>C(j),["enter"]),e.withKeys(e.withModifiers(he=>C(j),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${h(j.id)}`,"aria-label":`Select filter ${j.name}`},[N(j.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(he=>b(j.id),["stop"])},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(oc)},null,8,["icon"])],8,Lg)):e.createCommentVNode("",!0),e.createElementVNode("div",Ug,[e.createElementVNode("div",Og,[e.createVNode(e.unref(O.IonIcon),{icon:S(j),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",zg,e.toDisplayString(j.name),1)],42,Ag)}),128))],512),e.createElementVNode("button",{onClick:A,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(O.IonIcon),{icon:e.unref(Hs)},null,8,["icon"])],8,Pg)]),e.createElementVNode("div",Wg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(w.value.length/4),(j,te)=>(e.openBlock(),e.createElementBlock("span",{key:te,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===te}]),onClick:he=>B(te)},null,10,jg))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",Zg,[e.createElementVNode("div",Hg,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",Xg,[N(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),N(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:F[0]||(F[0]=j=>b(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),N(r.value.id)&&((H=r.value.params)==null?void 0:H.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:F[1]||(F[1]=j=>I(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",Gg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,j=>(e.openBlock(),e.createElementBlock("div",{key:j.id,class:"adjustment-control"},[!j.type||j.type==="slider"?(e.openBlock(),e.createElementBlock("div",Jg,[e.createElementVNode("label",Yg,e.toDisplayString(j.label||j.id),1),e.createElementVNode("div",qg,[e.createVNode(e.unref(O.IonRange),{value:_(r.value.id,j.id),onIonChange:te=>$(r.value.id,j.id,te.detail.value),min:j.min,max:j.max,step:j.step||.01,color:"primary",class:"compact-slider",disabled:!N(r.value.id),"data-testid":`range-filter-${h(r.value.id)}-${h(j.id)}`,"aria-label":`Adjust ${j.label||j.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Kg,e.toDisplayString(T(_(r.value.id,j.id))),1)])])):j.type==="color"?(e.openBlock(),e.createElementBlock("div",Qg,[e.createElementVNode("label",e1,e.toDisplayString(j.label||j.id),1),e.createElementVNode("div",t1,[e.createElementVNode("input",{type:"color",value:_(r.value.id,j.id),onInput:te=>$(r.value.id,j.id,te.target.value),disabled:!N(r.value.id),class:"color-input"},null,40,n1),e.createElementVNode("span",a1,e.toDisplayString(_(r.value.id,j.id)),1)])])):j.type==="toggle"?(e.openBlock(),e.createElementBlock("div",o1,[e.createElementVNode("label",i1,e.toDisplayString(j.label||j.id),1),e.createVNode(e.unref(O.IonToggle),{checked:!!_(r.value.id,j.id),onIonChange:te=>$(r.value.id,j.id,te.detail.checked),disabled:!N(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):j.type==="select"?(e.openBlock(),e.createElementBlock("div",r1,[e.createElementVNode("label",s1,e.toDisplayString(j.label||j.id),1),e.createElementVNode("select",{value:_(r.value.id,j.id),onChange:te=>$(r.value.id,j.id,te.target.value),disabled:!N(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.options,te=>(e.openBlock(),e.createElementBlock("option",{key:String(te.value),value:te.value},e.toDisplayString(te.label),9,c1))),128))],40,l1)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",d1," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),m1=Ce(u1,[["__scopeId","data-v-9efd15d9"]]);class p1{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 f1={class:"video-filter-preview"},h1={class:"preview-title"},v1={class:"filter-controls"},g1={class:"control-input"},y1=["value","onInput","min","max","step"],b1={class:"param-value"},w1={class:"preview-container"},k1={key:0,class:"filter-presets"},_1=["onClick"],E1={class:"preview-actions"},x1=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 x;return((x=t.filter)==null?void 0:x.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 x;if(i.value){t.useVideoEngine&&t.composition&&(u=new p1(t.composition));try{if(l=new qe.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(x=t.currentFrame)!=null&&x.dataUrl){const I=await qe.Assets.load(t.currentFrame.dataUrl);c=new qe.Sprite(I);const Z=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(Z),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}y()}catch{}}}function y(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const x={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([x]).then(()=>{}).catch(I=>{}),d&&(d.destroy(),d=null),d=w(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=w(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}function w(x,I){switch(x){case"brightness":{const Z=new qe.ColorMatrixFilter,S=1+(I.value??0);return typeof Z.brightness=="function"&&Z.brightness(S,!1),Z}case"contrast":{const Z=new qe.ColorMatrixFilter,S=I.value??1;return typeof Z.contrast=="function"&&Z.contrast(S,!1),Z}case"saturation":{const Z=new qe.ColorMatrixFilter,S=I.value??1;return typeof Z.saturate=="function"&&Z.saturate(S,!1),Z}case"hue":{const Z=new qe.ColorMatrixFilter,S=I.value??0;return typeof Z.hue=="function"&&Z.hue(S,!1),Z}case"gaussian-blur":{const Z=I.value??5;return new qe.BlurFilter({strength:Z,quality:4})}case"sepia":{const Z=new qe.ColorMatrixFilter;return typeof Z.sepia=="function"&&Z.sepia(!1),Z}case"grayscale":{const Z=new qe.ColorMatrixFilter;return typeof Z.desaturate=="function"&&Z.desaturate(),Z}default:return null}}function N(x,I){const Z=I.target,S=Number.parseFloat(Z.value),L=Number.isFinite(S)?S:0;s.value={...s.value,[x]:L},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),y()}function C(x){return x.charAt(0).toUpperCase()+x.slice(1).replace(/_/g," ")}function b(x,I){var S;const Z=typeof x=="number"?x:Number(x);return Number.isFinite(Z)?I==="hue"||I==="angle"?`${Z}°`:I==="value"&&((S=t.filter)==null?void 0:S.id)==="brightness"?`${Math.round((1+Z)*100)}%`:Number.isInteger(Z)?Z.toString():Z.toFixed(2):"0"}function f(){var x;s.value=((x=t.filter)==null?void 0:x.defaultParams)||{},a("update-params",s.value),y()}function _(x){s.value={...x.params},a("update-params",s.value),y()}function $(x){return JSON.stringify(x.params)===JSON.stringify(s.value)}function T(){a("apply")}return e.watch(()=>t.filter,x=>{x&&(s.value={...x.defaultParams},y())}),e.watch(()=>t.currentFrame,async x=>{if(x!=null&&x.dataUrl&&c){const I=await qe.Assets.load(x.dataUrl);c.texture=I}}),e.watch(r,y),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()}),(x,I)=>{var Z;return e.openBlock(),e.createElementBlock("div",f1,[e.createElementVNode("h4",h1,e.toDisplayString((Z=x.filter)==null?void 0:Z.name)+" Settings",1),e.createElementVNode("div",v1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(S,L)=>(e.openBlock(),e.createElementBlock("div",{key:L,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(C(L)),1),e.createElementVNode("div",g1,[e.createElementVNode("input",{type:"range",value:s.value[L],onInput:R=>N(L,R),min:S.min,max:S.max,step:S.step,class:"param-slider"},null,40,y1),e.createElementVNode("span",b1,e.toDisplayString(b(s.value[L],L)),1)])]))),128))]),e.createElementVNode("div",w1,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:I[0]||(I[0]=S=>r.value=!0),onMouseup:I[1]||(I[1]=S=>r.value=!1),onTouchstart:I[2]||(I[2]=S=>r.value=!0),onTouchend:I[3]||(I[3]=S=>r.value=!1)},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(va)},null,8,["icon"]),I[4]||(I[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),h.value?(e.openBlock(),e.createElementBlock("div",k1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,S=>(e.openBlock(),e.createElementBlock("button",{key:S.name,class:e.normalizeClass(["preset-button",{active:$(S)}]),onClick:L=>_(S)},e.toDisplayString(S.name),11,_1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",E1,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(qn)},null,8,["icon"]),I[5]||(I[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:T},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(ic)},null,8,["icon"]),I[6]||(I[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),C1=Ce(x1,[["__scopeId","data-v-3de3dd04"]]),S1={class:"export-settings"},V1={class:"setting-group"},N1={class:"setting-group"},T1={class:"estimated-size"},M1={key:0,class:"export-progress"},B1={class:"progress-header"},I1={class:"progress-percentage"},F1={class:"progress-time"},$1={class:"action-buttons"},R1=["disabled"],D1=["disabled"],A1=["disabled"],L1={class:"export-options"},U1=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 C={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",C),y()}function y(){c.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const C=d.value/t.exportProgress*100;u.value=Math.max(0,C-d.value)}},1e3)}function w(){m&&(clearInterval(m),m=null)}function N(C){const b=Math.floor(C/60),f=Math.floor(C%60);return`${b}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,C=>{C||w()}),e.onUnmounted(()=>{w()}),(C,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:C.isMobile}])},[e.createElementVNode("div",S1,[b[10]||(b[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",V1,[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",N1,[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",T1,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(tp)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(h.value),1)])]),C.isExporting?(e.openBlock(),e.createElementBlock("div",M1,[e.createElementVNode("div",B1,[b[11]||(b[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",I1,e.toDisplayString(C.exportProgress??0)+"%",1)]),e.createVNode(e.unref(O.IonProgressBar),{value:(C.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",F1,[e.createElementVNode("span",null,e.toDisplayString(N(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(N(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",$1,[e.createElementVNode("button",{class:"control-button secondary",onClick:b[2]||(b[2]=f=>C.$emit("save-draft")),disabled:!C.canExport||C.isExporting},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Tr)},null,8,["icon"]),b[12]||(b[12]=e.createTextVNode(" Save Draft ",-1))],8,R1),e.createElementVNode("button",{class:"control-button secondary",onClick:b[3]||(b[3]=f=>C.$emit("reset")),disabled:C.isExporting},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(qn)},null,8,["icon"]),b[13]||(b[13]=e.createTextVNode(" Reset ",-1))],8,D1),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!C.canExport&&!C.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(O.IonIcon),{icon:C.isExporting?e.unref(Xn):e.unref(Va)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(C.isExporting?"Cancel":"Export Video"),1)],8,A1)]),e.createElementVNode("div",L1,[e.createVNode(e.unref(O.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":b[4]||(b[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...b[14]||(b[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(O.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":b[5]||(b[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...b[15]||(b[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),O1=Ce(U1,[["__scopeId","data-v-e1338d5e"]]),z1={class:"thumbnail-picker"},P1={class:"thumbnail-grid"},W1=["onClick"],j1=["src","alt"],Z1={key:1,class:"thumbnail-placeholder"},H1={class:"thumbnail-time"},X1={class:"custom-selector"},G1={class:"time-input-group"},J1=["max"],Y1={class:"time-value"},q1=["disabled"],K1={class:"picker-actions"},Q1=["disabled"],ey=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 N=[];if(t.duration<=10)for(let b=0;b<Math.min(9,t.duration);b++)N.push(b);else{const b=t.duration/10;for(let f=1;f<=9;f++)N.push(b*f)}return N}async function d(N){try{const C=document.createElement("video");return C.crossOrigin="anonymous",C.src=await u(),new Promise(b=>{C.addEventListener("loadedmetadata",()=>{C.currentTime=N}),C.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=C.videoWidth,f.height=C.videoHeight;const _=f.getContext("2d");_?(_.drawImage(C,0,0),b(f.toDataURL("image/jpeg",.8))):b(null),C.remove()}),C.addEventListener("error",()=>{b(null),C.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function m(){const N=c();i.value=N.map(b=>({time:b,loading:!0}));const C=3;for(let b=0;b<i.value.length;b+=C){const f=i.value.slice(b,b+C);await Promise.all(f.map(async _=>{const $=await d(_.time);$&&(_.dataUrl=$),_.loading=!1}))}}function h(N){r.value=N,s.value=i.value[N].time}function p(){r.value=-1}async function v(){l.value=!0;try{const N=await d(s.value);if(N){const C=i.value.findIndex(b=>Math.abs(b.time-s.value)<.1);C>=0?(i.value[C].dataUrl=N,r.value=C):(i.value.push({time:s.value,dataUrl:N}),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 y(){const N=r.value>=0?i.value[r.value].time:s.value;a("select",N)}function w(N){const C=Math.floor(N/60),b=Math.floor(N%60),f=Math.floor(N%1*100);return C>0?`${C}:${b.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${b}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(N,C)=>(e.openBlock(),e.createElementBlock("div",z1,[C[5]||(C[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",P1,[(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,j1)):(e.openBlock(),e.createElementBlock("div",Z1,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",H1,e.toDisplayString(w(b.time)),1)],10,W1))),128))]),e.createElementVNode("div",X1,[C[3]||(C[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",G1,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":C[0]||(C[0]=b=>s.value=b),min:0,max:N.duration,step:.1,onInput:p,class:"time-slider"},null,40,J1),[[e.vModelText,s.value]]),e.createElementVNode("span",Y1,e.toDisplayString(w(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Wm)},null,8,["icon"]),C[2]||(C[2]=e.createTextVNode(" Capture Frame ",-1))],8,q1)]),e.createElementVNode("div",K1,[e.createElementVNode("button",{class:"action-button",onClick:C[1]||(C[1]=b=>N.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:y,disabled:r.value===-1},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(ic)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Q1)])]))}}),ty=Ce(ey,[["__scopeId","data-v-336c322c"]]),ny={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},ay={class:"mb-4"},oy={class:"space-y-2 max-h-64 overflow-y-auto"},iy={class:"flex items-center justify-between"},ry={class:"flex-1"},sy={class:"font-medium text-gray-900 dark:text-white"},ly={class:"text-sm text-gray-500 dark:text-gray-400"},cy={class:"flex items-center space-x-2"},dy=["onClick"],uy=["onClick"],my={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},py={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},fy={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},hy={class:"space-y-4"},vy={class:"grid grid-cols-2 gap-4"},gy={class:"grid grid-cols-2 gap-4"},yy={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},by={class:"grid grid-cols-2 gap-3"},wy={class:"flex justify-end space-x-3 mt-6"},ky=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",ny,[e.createElementVNode("div",ay,[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",oy,[(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",iy,[e.createElementVNode("div",ry,[e.createElementVNode("div",sy,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",ly,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",cy,[e.createElementVNode("button",{onClick:y=>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,dy),e.createElementVNode("button",{onClick:y=>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,uy)])])]))),128)),h.overlays.length===0?(e.openBlock(),e.createElementBlock("div",my," 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",py,[e.createElementVNode("h4",fy,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",hy,[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",vy,[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",gy,[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",yy,[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",by,[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",wy,[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)]))}}),_y=Ce(ky,[["__scopeId","data-v-f86e688c"]]),Sa=class Sa{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 Se([a,i],[1,0],{easing:r}),t.alpha=new Se([a,i],[0,1],{easing:r}),t.start=be.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 Se([a,i],[1,0],{easing:r}),t.alpha=new Se([a,i],[0,1],{easing:r}),t.start=be.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 Se([i,r],[0,-1920],{easing:s}),c.x=new Se([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Se([i,r],[0,1920],{easing:s}),c.x=new Se([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Se([i,r],[0,-1080],{easing:s}),c.y=new Se([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Se([i,r],[0,1080],{easing:s}),c.y=new Se([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=be.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 Se([i,r],[0,-1920],{easing:s}),c.x=new Se([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Se([i,r],[0,1920],{easing:s}),c.x=new Se([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Se([i,r],[0,-1080],{easing:s}),c.y=new Se([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Se([i,r],[0,1080],{easing:s}),c.y=new Se([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=be.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 Se([i,r],[1,2],{easing:s}),n.alpha=new Se([i,r],[1,0],{easing:s}),t.scale=new Se([i,r],[.5,1],{easing:s}),t.alpha=new Se([i,r],[0,1],{easing:s})):(n.scale=new Se([i,r],[1,.5],{easing:s}),n.alpha=new Se([i,r],[1,0],{easing:s}),t.scale=new Se([i,r],[2,1],{easing:s}),t.alpha=new Se([i,r],[0,1],{easing:s})),t.start=be.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 pr.fromColor(c),u=new Qv(d,{start:be.fromFrames(i),stop:be.fromFrames(r)});n.alpha=new Se([i,l],[1,0],{easing:s}),u.alpha=new Se([i,l,r],[0,1,0],{easing:s}),t.alpha=new Se([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=be.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[...Sa.TRANSITIONS]}static previewTransition(n){return Sa.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};Sa.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 Ro=Sa;const Ey={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},xy={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Cy=["onClick"],Sy={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"},Vy={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ny={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},Ty={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},My={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"},By={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"},Iy={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"},Fy={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},$y={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Ry={class:"space-y-3"},Dy={class:"flex items-center space-x-2"},Ay=["disabled"],Ly=["disabled"],Uy={key:1,class:"mt-4"},Oy={class:"space-y-2 max-h-32 overflow-y-auto"},zy={class:"text-sm text-gray-700 dark:text-gray-300"},Py=["onClick"],Wy=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(Ro.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(y=>v.includes(y))}return(v,y)=>(e.openBlock(),e.createElementBlock("div",Ey,[y[9]||(y[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",xy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,w=>{var N;return e.openBlock(),e.createElementBlock("div",{key:w.type,onClick:C=>d(w),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((N=r.value)==null?void 0:N.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",Sy,[p(w.type)?(e.openBlock(),e.createElementBlock("svg",Vy,[w.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Ny)):w.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",Ty)):w.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",My)):w.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",By)):(e.openBlock(),e.createElementBlock("path",Iy))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Fy,e.toDisplayString(w.name),1)],10,Cy)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",$y,[y[6]||(y[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",Ry,[e.createElementVNode("div",null,[y[3]||(y[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",Dy,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":y[0]||(y[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":y[1]||(y[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,[y[5]||(y[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":y[2]||(y[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"},[...y[4]||(y[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,Ay),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,Ly)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Uy,[y[8]||(y[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",Oy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(w,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",zy,e.toDisplayString(w.name)+" ("+e.toDisplayString(w.duration)+"s) ",1),e.createElementVNode("button",{onClick:C=>h(N),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...y[7]||(y[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,Py)]))),128))])])):e.createCommentVNode("",!0),y[10]||(y[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))]))}}),jy=Ce(Wy,[["__scopeId","data-v-5ef1b100"]]),Zy={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Hy={class:"mb-4"},Xy={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Gy={class:"flex items-center justify-between mb-2"},Jy={class:"text-sm text-gray-600 dark:text-gray-400"},Yy={class:"flex items-center space-x-2"},qy={class:"space-y-3 max-h-64 overflow-y-auto"},Ky={class:"flex items-center justify-between mb-2"},Qy={class:"font-medium text-gray-900 dark:text-white"},eb={class:"flex items-center space-x-2"},tb=["onClick","title"],nb={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},ab={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},ob=["onClick"],ib=["onClick"],rb={class:"flex items-center space-x-2"},sb={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},lb=["value","onInput","disabled"],cb={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},db={key:0,class:"ml-2"},ub={key:1,class:"ml-2"},mb={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},pb={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},fb={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},hb={class:"space-y-4"},vb={class:"space-y-2"},gb={class:"flex items-center"},yb={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},bb={class:"grid grid-cols-2 gap-4"},wb={class:"grid grid-cols-2 gap-4"},kb={class:"flex items-center"},_b={class:"flex justify-end space-x-3 mt-6"},Eb=["disabled"],xb=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 y(b,f){const _=f.target,$=parseFloat(_.value);a("update-volume",b.id,$)}function w(b){a("toggle-mute",b.id,!b.muted)}function N(){a("update-master-volume",s.value)}function C(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",Zy,[e.createElementVNode("div",Hy,[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",Xy,[e.createElementVNode("div",Gy,[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",Jy,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",Yy,[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:N,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",qy,[(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",Ky,[e.createElementVNode("div",Qy,e.toDisplayString(_.name),1),e.createElementVNode("div",eb,[e.createElementVNode("button",{onClick:$=>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",ab,[...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",nb,[...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,tb),e.createElementVNode("button",{onClick:$=>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,ob),e.createElementVNode("button",{onClick:$=>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,ib)])]),e.createElementVNode("div",rb,[e.createElementVNode("span",sb,e.toDisplayString(Math.round((_.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:_.volume||1,onInput:$=>y(_,$),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:_.muted},null,40,lb)]),e.createElementVNode("div",cb,[e.createTextVNode(e.toDisplayString(C(_.startTime||0))+" - "+e.toDisplayString(C((_.startTime||0)+(_.duration||0)))+" ",1),_.fadeIn?(e.openBlock(),e.createElementBlock("span",db,"Fade In: "+e.toDisplayString(_.fadeIn)+"s",1)):e.createCommentVNode("",!0),_.fadeOut?(e.openBlock(),e.createElementBlock("span",ub,"Fade Out: "+e.toDisplayString(_.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),b.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",mb," 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",pb,[e.createElementVNode("h4",fb,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",hb,[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",vb,[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",gb,[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",yb," 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",bb,[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",wb,[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",kb,[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",_b,[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,Eb)])])])):e.createCommentVNode("",!0)]))}}),Cb=Ce(xb,[["__scopeId","data-v-593719ac"]]);function Ue(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 wl(o){return typeof o=="boolean"?o?"On":"Off":typeof o=="number"?Number.isInteger(o)?String(o):o.toFixed(2):String(o??"")}let kl=!1;function Sb(){if(kl)return;kl=!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 Vb{constructor({filters:n=[],callbacks:t={}}){Sb(),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=Ue("div",{className:"mvfp"}),this._catRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Ue("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=Ue("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=Ue("div",{className:`mvfp-filter${t?" active":""}${a?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Ue("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Ue("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(Ue("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=Ue("div",{className:`mvfp-achip${i?" selected":""}`}),s=Ue("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(t)}},a.name),l=Ue("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=Ue("div",{className:"mvfp-drawer"});const n=Ue("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Ue("span",{className:"mvfp-drawer-title"},"Filter");const t=Ue("div",{className:"mvfp-drawer-actions"});t.appendChild(Ue("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Ue("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const a=Ue("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=Ue("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(Ue("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=Ue("div",{className:"mvfp-ctl"}),l=Ue("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Ue("div",{className:"mvfp-slider-row"}),u=Ue("span",{className:"mvfp-range-val"},wl(r)),m=Ue("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,y;const p=parseFloat(h.target.value);u.textContent=wl(p),(y=(v=this._cb).onUpdateParam)==null||y.call(v,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Ue("div",{className:"mvfp-toggle-row"}),u=Ue("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=Ue("div",{className:"mvfp-color-row"}),u=Ue("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=Ue("div",{className:"mvfp-select-row"}),u=Ue("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=Ue("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 _l(o){var s,l;Nb(o);const n=Tb(o.clips),t=[],a=Mb(o),i=Bb(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 Nb(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 Tb(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 Mb(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 Bb(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 Ib(o,n,t){var xe,ze;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 Hc(30),p=e.ref(30),v=e.ref(!1),y=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(T(n),(xe=n.output)!=null&&xe.fps&&(p.value=n.output.fps,h.setFps(p.value))):(f(),n&&((ze=n.output)!=null&&ze.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),N=e.computed(()=>i.selectedClipId?i.clips.find(M=>M.id===i.selectedClipId)??null:null);e.watch(N,M=>{w.value=(M==null?void 0:M.speed)??1},{immediate:!0});const C=e.computed(()=>s.value.length>0),b=e.computed(()=>l.value.length>0);function f(){const M=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=M,i.totalDuration=M;const z=ne(),J={id:z,type:"clip",timelineStart:0,timelineEnd:M,sourceIn:0,sourceOut:M,sourceMinIn:0,sourceMaxOut:M,speed:1};i.clips=[J],i.selectedClipId=z,c.value=z,!(t||a.startsWith("temp-"))&&(async()=>{try{const q=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!q.ok)throw new Error(`Failed to fetch media: ${q.status}`);const ue=await q.json(),ve=typeof ue=="object"&&ue!==null&&"data"in ue?ue.data:ue;if(!ve||typeof ve!="object")throw new Error("Failed to parse media payload");const Te=ve;i.media=Te;const $e=typeof Te.duration=="number"&&Te.duration>0?Te.duration:M;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==z)return;i.originalDuration=$e,i.totalDuration=$e;const Be=i.clips[0];Be.timelineStart=0,Be.timelineEnd=$e,Be.sourceIn=0,Be.sourceOut=$e,Be.sourceMinIn=0,Be.sourceMaxOut=$e,F(),d=!0}catch{}})()}function _(M,z){if(M.originalDuration!==1)return;M.originalDuration=z,M.totalDuration===1&&(M.totalDuration=z);const J=M.clips[0],q=!n&&M.clips.length===1&&J!==void 0&&J.timelineStart===0&&J.timelineEnd===1&&J.sourceIn===0&&J.sourceOut===1;for(const ue of M.clips)(ue.sourceMaxOut===1||ue.sourceMaxOut===void 0)&&(ue.sourceMaxOut=z);q&&J!==void 0&&(J.sourceOut=z,J.timelineEnd=z)}function $(M){if(!Number.isFinite(M)||M<=0||d)return;const z=i.hasChanges;i.originalDuration=M,i.totalDuration=Math.max(i.totalDuration,M),i.media&&(i.media.duration=M);for(const ue of i.clips)ue.sourceMaxOut=M;const J=i.clips[0];!n&&i.clips.length===1&&J!==void 0&&J.timelineStart===0&&J.timelineEnd===1&&J.sourceIn===0&&J.sourceOut===1&&J!==void 0&&(J.sourceOut=M,J.timelineEnd=J.timelineStart+(J.sourceOut-J.sourceIn)),F();for(const ue of s.value)_(ue,M);for(const ue of l.value)_(ue,M);d=!0,e.nextTick(()=>{z||(i.hasChanges=!1)})}function T(M){i.clips=M.timeline.map(z=>({...z,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??M.source.duration})),i.filters=[],i.audioVolume=M.audio.volume,i.audioFadeIn=M.audio.fadeIn||0,i.audioFadeOut=M.audio.fadeOut||0,i.exportFormat=M.output.format,i.exportQuality=M.output.quality,i.originalDuration=M.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),F()}function x(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function I(){if(!C.value)return;const M=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,M)}function Z(){if(!b.value)return;const M=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,M)}function S(M,z,J){x();const q=i.clips.find(Be=>Be.id===M);if(!q)return;const ve=1/30,Te=q.sourceMinIn??0,$e=q.sourceMaxOut??i.originalDuration;if(z==="start"){const Be=q.sourceIn,Ae=Math.max(Te,Math.min(J,q.sourceOut-ve));q.sourceIn=Ae;const et=Ae-Be;q.timelineStart+=et}else{const Be=Math.max(q.sourceIn+ve,Math.min(J,$e));q.sourceOut=Be;const Ae=q.sourceOut-q.sourceIn;q.timelineEnd=q.timelineStart+Ae}F(),m.value&&m.value.trimClip(M,q.sourceIn,q.sourceOut)}function L(M){x();const z=i.clips.find(Te=>M>Te.timelineStart&&M<Te.timelineEnd);if(!z)return;const J=M-z.timelineStart,q=z.sourceIn+J,ue={id:ne(),type:"clip",timelineStart:M,timelineEnd:z.timelineEnd,sourceIn:q,sourceOut:z.sourceOut,speed:z.speed??1,sourceMinIn:z.sourceMinIn??0,sourceMaxOut:z.sourceMaxOut??i.originalDuration,filters:[...z.filters||[]]};z.timelineEnd=M,z.sourceOut=q;const ve=i.clips.indexOf(z);i.clips.splice(ve+1,0,ue),i.selectedClipId=ue.id}function R(){L(i.playheadPosition)}function P(M){var J;const z=M??i.selectedClipId??c.value??((J=i.clips[0])==null?void 0:J.id);z&&(i.selectedClipId=z,c.value=z)}function A(){if(!i.selectedClipId||i.clips.length<=1)return;x();const M=i.clips.findIndex(z=>z.id===i.selectedClipId);if(M!==-1){i.clips.splice(M,1);const z=Math.min(M,i.clips.length-1);i.selectedClipId=i.clips[z].id,c.value=i.selectedClipId,F()}}function B(){return[...i.clips].sort((M,z)=>M.timelineStart-z.timelineStart)}function D(M){const z=B(),J=z.findIndex(Ae=>Ae.id===M);if(J===-1)return null;const q=z[J],ue=q.timelineEnd-q.timelineStart,ve=J>0?z[J-1]:null,Te=J<z.length-1?z[J+1]:null,$e=ve?ve.timelineEnd:0,Be=Te?Te.timelineStart-ue:Math.max(q.timelineStart,i.totalDuration-ue);return{minStart:$e,maxStart:Math.max($e,Be)}}function k(M,z){const J=i.clips.find(Te=>Te.id===M);if(!J)return;const q=D(M),ue=q?Math.min(q.maxStart,Math.max(q.minStart,z)):Math.max(0,z);if(ue===J.timelineStart)return;x();const ve=ue-J.timelineStart;J.timelineStart=ue,J.timelineEnd+=ve,F(),m.value&&m.value.moveClip(M,ue)}function F(){if(i.clips.length===0){i.totalDuration=0;return}const M=i.clips.reduce((z,J)=>J.timelineEnd>z.timelineEnd?J:z);i.totalDuration=M.timelineEnd}function H(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function j(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function te(M){i.zoomLevel=Math.max(10,Math.min(600,Math.round(M)))}function he(){i.isPlaying=!i.isPlaying}function ge(M){i.isPlaying=M}function ae(M){i.playheadPosition=Math.max(0,Math.min(M,i.totalDuration))}function V(){const M=_l(i);try{localStorage.setItem(`video-draft-${a}`,JSON.stringify(M))}catch{}return M}function U(){i.hasChanges=!1}function K(){return confirm("Are you sure you want to reset all changes?")?(x(),f(),i.hasChanges=!1,!0):!1}function ee(){return _l(i)}function ne(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function fe(M=1920,z=1080){if(u.value)try{m.value=new Zc(M,z,p.value),await ie()}catch{m.value=null}}async function ie(){if(!(!m.value||y.value)){y.value=!0;try{const M=ee();await m.value.loadFromRecipe(M);const z=h.secondsToFrames(i.playheadPosition);m.value.seek(z)}catch{}finally{y.value=!1}}}function pe(M){}function ke(M){return h.secondsToFrames(M)}function re(M){return h.framesToSeconds(M)}function ce(M){const z=re(M);ae(z),m.value&&m.value.seek(M)}function _e(){v.value=!v.value}function Ve(){ie()}function ut(M){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&ie()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&ie()},{deep:!0}),e.watch(()=>i.clips.map(M=>M.id),()=>{var z;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(J=>J.id===i.selectedClipId)){const J=c.value&&((z=i.clips.find(q=>q.id===c.value))==null?void 0:z.id);i.selectedClipId=J??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function He(M){const z=i.selectedClipId?i.clips.find(J=>J.id===i.selectedClipId):i.clips[0];z&&(z.filters=[...M],i.hasChanges=!0)}function xt(M){i.textOverlays=[...M]}function Ge(M){i.audioTracks=[...M]}e.watch(u,M=>{M?fe():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(p,M=>{h.setFps(M)});function at(){if(!i.selectedClipId)return;x();const M=i.clips.find(q=>q.id===i.selectedClipId);if(!M)return;const z={...M,id:ne(),timelineStart:M.timelineEnd,timelineEnd:M.timelineEnd+(M.timelineEnd-M.timelineStart),filters:[...M.filters||[]]},J=i.clips.indexOf(M);i.clips.splice(J+1,0,z),i.selectedClipId=z.id,i.hasChanges=!0}function Ct(M){const z=M??800,J=i.totalDuration;if(J<=0){i.zoomLevel=50;return}const q=z*.8/J;i.zoomLevel=Math.max(10,Math.min(600,Math.round(q)))}function $t(){const M=1/p.value;ae(Math.min(i.playheadPosition+M,i.totalDuration))}function lt(){const M=1/p.value;ae(Math.max(i.playheadPosition-M,0))}function yt(){ae(0)}function de(){ae(i.totalDuration)}function Ee(M){if(!Number.isFinite(M)||M<=0)return;const z=N.value??i.clips[0];if(!z){w.value=M;return}const J=z.speed??1;if(J===M){w.value=M;return}x();const q=Math.max(1/p.value,z.sourceOut-z.sourceIn),ue=q/J,ve=q/M,Te=ve-ue;z.speed=M,z.timelineEnd=z.timelineStart+ve;const $e=i.clips.findIndex(Be=>Be.id===z.id);if($e!==-1&&Te!==0)for(let Be=$e+1;Be<i.clips.length;Be+=1){const Ae=i.clips[Be];Ae.timelineStart+=Te,Ae.timelineEnd+=Te}F(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,w.value=M}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:N,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:w,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:p,useFrameMode:v,handleTrim:S,handleSplit:L,handleClipSelect:P,splitAtPlayhead:R,deleteSelectedClip:A,duplicateSelectedClip:at,setFilters:He,setTextOverlays:xt,setAudioTracks:Ge,moveClip:k,saveDraft:V,clearHasChanges:U,resetChanges:K,generateRecipe:ee,zoomIn:H,zoomOut:j,setZoomLevel:te,fitToWindow:Ct,togglePlayback:he,setPlaying:ge,seekTo:ae,frameForward:$t,frameBackward:lt,skipToStart:yt,skipToEnd:de,setPlaybackSpeed:Ee,updateSourceDuration:$,undo:I,redo:Z,canUndo:C,canRedo:b,initializeComposition:fe,syncCompositionWithState:ie,syncWithComposition:pe,convertToFrames:ke,convertToSeconds:re,seekToFrame:ce,toggleFrameMode:_e,onCompositionReady:Ve,onCompositionError:ut}}const Fb=[{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}}}],$b={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function ei(o){return typeof o=="object"&&o!==null}function Rb(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 ti(o){if(typeof o=="number"||typeof o=="string"||typeof o=="boolean")return o}function Db(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=ti(o.default);return t!==void 0&&(n.default=t),o.options!==void 0&&(n.options=o.options),n}function Xc(o,n,t){const a=oe.getFilter(o),i={},r=(a==null?void 0:a.defaultParams)??t;if(r&&ei(r))for(const[s,l]of Object.entries(r))i[s]=ti(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 Gc(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 Ab(o,n,t,a){const i=a.map(Db);return{id:o,name:n,category:t,controls:i,params:i,defaultParams:Xc(o,i),paramRanges:Gc(i)}}function Lb(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=ti((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:Xc(o.id,t,o.defaultParams),paramRanges:Gc(t)}}function Ub(o,n){return n.toLowerCase()==="unlisted"?!1:oe.isFilterCompatibleWithMedia(o,"video")}function Hi(o){return $b[o]??o}function ba(o){const n=Rb(o,1);return Math.max(0,Math.min(1,n))}function wa(o){if(!ei(o))return{};const n={};for(const[t,a]of Object.entries(o))n[t]=ti(a)??null;return n}function Ob(o){return!ei(o)||typeof o.filterId!="string"?null:{filterId:o.filterId,params:wa(o.params),intensity:ba(o.intensity)}}function zb(o){if(!ei(o)||typeof o.id!="string"||typeof o.name!="string")return null;const t=(Array.isArray(o.filters)?o.filters:[]).map(i=>Ob(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 Pb(){oe.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,P=oe.getRegisteredFilters();for(const A of P)Ub(A.id,A.category)&&R.set(A.id,Ab(A.id,A.name,A.category,A.controls));for(const A of Fb)R.has(A.id)||R.set(A.id,Lb(A));return Array.from(R.values())}),l=e.computed(()=>{const R=new Map;for(const P of s.value)R.set(P.id,P);return R}),c=e.computed(()=>o.value.length>0),d=e.computed(()=>{const R={};for(const P of s.value)R[P.category]||(R[P.category]=[]),R[P.category].push(P);return R});function u(R){const P=l.value.get(R);if(P)return P;const A=Hi(R);return l.value.get(A)??null}function m(R){const P=l.value.get(R);if(P)return P.id;const A=Hi(R),B=l.value.get(A);return B?B.id:null}function h(R){const P=R?u(R):n.value;if(!P)return;const A=P.defaultParams||{},B={id:I(),filterId:P.id,params:{...A},intensity:1};return o.value.push(B),i.value=B.id,n.value=P,Object.keys(r).forEach(D=>delete r[D]),Object.assign(r,B.params),t.value=null,B}function p(R){const P=u(R);if(!P)return;n.value=P;const A=P.defaultParams||S(R);Object.assign(r,A),t.value={id:"preview",filterId:P.id,params:{...A},intensity:1}}function v(R){if(Object.assign(r,R),t.value&&(t.value.params={...r}),i.value){const P=o.value.find(A=>A.id===i.value);P&&(P.params={...r})}}function y(R){const P=o.value.findIndex(A=>A.id===R);P!==-1&&o.value.splice(P,1)}function w(R,P){if(R<0||R>=o.value.length||P<0||P>=o.value.length)return;const[A]=o.value.splice(R,1);o.value.splice(P,0,A)}function N(R,P){const A=o.value.find(B=>B.id===R);A&&(A.intensity=Math.max(0,Math.min(1,P)))}function C(R){const P=o.value.find(A=>A.id===R);P&&(P.intensity=P.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 P={id:Z(),name:R,filters:o.value.map(B=>({filterId:B.filterId,params:wa(B.params),intensity:ba(B.intensity)})),created_at:new Date().toISOString()};a.value.push(P);const A=a.value.map(B=>({...B}));return localStorage.setItem("video-filter-presets",JSON.stringify(A)),P}function _(R){const P=a.value.find(A=>A.id===R);if(P){b();for(const A of P.filters){const B=u(A.filterId);B&&o.value.push({id:I(),filterId:B.id,params:{...A.params},intensity:ba(A.intensity)})}}}function $(R){const P=a.value.findIndex(A=>A.id===R);P!==-1&&(a.value.splice(P,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function T(){try{const R=localStorage.getItem("video-filter-presets");if(!R)return;const P=JSON.parse(R);if(!Array.isArray(P))return;a.value=P.map(A=>zb(A)).filter(A=>A!==null)}catch{}}function x(){if(o.value.length===0)return"No filters applied";const R=o.value.map(P=>{const A=L(P.filterId);return(A==null?void 0:A.name)||P.filterId});return R.length===1?R[0]:R.length===2?`${R[0]} + ${R[1]}`:`${R[0]} + ${R.length-1} more`}function I(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function Z(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function S(R){const P=u(R);return P?P.defaultParams||{}:{}}function L(R){return u(R)}return T(),{videoCompatibleFilters:s,activeFilters:o,selectedFilter:n,previewFilter:t,filterPresets:a,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:h,previewFilterEffect:p,updateFilterParams:v,removeFilter:y,reorderFilters:w,updateFilterIntensity:N,toggleFilter:C,clearAllFilters:b,saveFilterPreset:f,loadFilterPreset:_,deleteFilterPreset:$,getFilterSummary:x,setActiveFilters(R){var A;const P=[];for(const B of R){const D=m(B.filterId);if(!D){const k=Hi(B.filterId);P.push({...B,filterId:k,params:wa(B.params),intensity:ba(B.intensity)});continue}P.push({...B,filterId:D,params:wa(B.params),intensity:ba(B.intensity)})}o.value=P,i.value=((A=o.value[0])==null?void 0:A.id)??null,Object.keys(r).forEach(B=>delete r[B]),o.value[0]&&Object.assign(r,wa(o.value[0].params))}}}class Wb{constructor(n){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new pt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new pt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new pt({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,a,i="400"){const r=new pt({source:t,family:a,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,a="400"){const i=new pt({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=be.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;a.stop=be.fromSeconds(l+n.duration)}n.animation&&this.applyAnimation(a,n.animation,n);const s=new Qn(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 Se([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Se([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Se([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Se([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Se([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Se([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Se([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Se([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Se([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(n,t){if(!this.textClips.get(n))throw new Error(`Text overlay with id ${n} not found`);await this.removeTextOverlay(n);const i={...t};await this.addTextOverlay(i)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const 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:Aa,cascade:Jo,guinea:Go,solar:Yo,spotlight:La,whisper:Ua}[t],s=await this.composition.createTrack("caption"),l=new Po({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 jb{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 hn.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 hn)a=n.source;else if(typeof n.source=="string")a=await hn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)a=await hn.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const i={source:a,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=be.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;i.stop=be.fromSeconds(c+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new $o(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 Se(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 $o({source:a.clip.source,start:be.fromSeconds(i),stop:be.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 Jc(o,n){return function(){return o.apply(n,arguments)}}const{toString:Zb}=Object.prototype,{getPrototypeOf:Xr}=Object,{iterator:ni,toStringTag:Yc}=Symbol,ai=(o=>n=>{const t=Zb.call(n);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=o=>(o=o.toLowerCase(),n=>ai(n)===o),oi=o=>n=>typeof n===o,{isArray:na}=Array,Ma=oi("undefined");function Oa(o){return o!==null&&!Ma(o)&&o.constructor!==null&&!Ma(o.constructor)&&kt(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const qc=Ut("ArrayBuffer");function Hb(o){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(o):n=o&&o.buffer&&qc(o.buffer),n}const Xb=oi("string"),kt=oi("function"),Kc=oi("number"),za=o=>o!==null&&typeof o=="object",Gb=o=>o===!0||o===!1,_o=o=>{if(ai(o)!=="object")return!1;const n=Xr(o);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Yc in o)&&!(ni in o)},Jb=o=>{if(!za(o)||Oa(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Yb=Ut("Date"),qb=Ut("File"),Kb=Ut("Blob"),Qb=Ut("FileList"),ew=o=>za(o)&&kt(o.pipe),tw=o=>{let n;return o&&(typeof FormData=="function"&&o instanceof FormData||kt(o.append)&&((n=ai(o))==="formdata"||n==="object"&&kt(o.toString)&&o.toString()==="[object FormData]"))},nw=Ut("URLSearchParams"),[aw,ow,iw,rw]=["ReadableStream","Request","Response","Headers"].map(Ut),sw=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Pa(o,n,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let a,i;if(typeof o!="object"&&(o=[o]),na(o))for(a=0,i=o.length;a<i;a++)n.call(null,o[a],a,o);else{if(Oa(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 Qc(o,n){if(Oa(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 Sn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ed=o=>!Ma(o)&&o!==Sn;function yr(){const{caseless:o}=ed(this)&&this||{},n={},t=(a,i)=>{const r=o&&Qc(n,i)||i;_o(n[r])&&_o(a)?n[r]=yr(n[r],a):_o(a)?n[r]=yr({},a):na(a)?n[r]=a.slice():n[r]=a};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Pa(arguments[a],t);return n}const lw=(o,n,t,{allOwnKeys:a}={})=>(Pa(n,(i,r)=>{t&&kt(i)?o[r]=Jc(i,t):o[r]=i},{allOwnKeys:a}),o),cw=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),dw=(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)},uw=(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&&Xr(o)}while(o&&(!t||t(o,n))&&o!==Object.prototype);return n},mw=(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},pw=o=>{if(!o)return null;if(na(o))return o;let n=o.length;if(!Kc(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=o[n];return t},fw=(o=>n=>o&&n instanceof o)(typeof Uint8Array<"u"&&Xr(Uint8Array)),hw=(o,n)=>{const a=(o&&o[ni]).call(o);let i;for(;(i=a.next())&&!i.done;){const r=i.value;n.call(o,r[0],r[1])}},vw=(o,n)=>{let t;const a=[];for(;(t=o.exec(n))!==null;)a.push(t);return a},gw=Ut("HTMLFormElement"),yw=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,i){return a.toUpperCase()+i}),El=(({hasOwnProperty:o})=>(n,t)=>o.call(n,t))(Object.prototype),bw=Ut("RegExp"),td=(o,n)=>{const t=Object.getOwnPropertyDescriptors(o),a={};Pa(t,(i,r)=>{let s;(s=n(i,r,o))!==!1&&(a[r]=s||i)}),Object.defineProperties(o,a)},ww=o=>{td(o,(n,t)=>{if(kt(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=o[t];if(kt(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+"'")})}})},kw=(o,n)=>{const t={},a=i=>{i.forEach(r=>{t[r]=!0})};return na(o)?a(o):a(String(o).split(n)),t},_w=()=>{},Ew=(o,n)=>o!=null&&Number.isFinite(o=+o)?o:n;function xw(o){return!!(o&&kt(o.append)&&o[Yc]==="FormData"&&o[ni])}const Cw=o=>{const n=new Array(10),t=(a,i)=>{if(za(a)){if(n.indexOf(a)>=0)return;if(Oa(a))return a;if(!("toJSON"in a)){n[i]=a;const r=na(a)?[]:{};return Pa(a,(s,l)=>{const c=t(s,i+1);!Ma(c)&&(r[l]=c)}),n[i]=void 0,r}}return a};return t(o,0)},Sw=Ut("AsyncFunction"),Vw=o=>o&&(za(o)||kt(o))&&kt(o.then)&&kt(o.catch),nd=((o,n)=>o?setImmediate:n?((t,a)=>(Sn.addEventListener("message",({source:i,data:r})=>{i===Sn&&r===t&&a.length&&a.shift()()},!1),i=>{a.push(i),Sn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",kt(Sn.postMessage)),Nw=typeof queueMicrotask<"u"?queueMicrotask.bind(Sn):typeof process<"u"&&process.nextTick||nd,Tw=o=>o!=null&&kt(o[ni]),Y={isArray:na,isArrayBuffer:qc,isBuffer:Oa,isFormData:tw,isArrayBufferView:Hb,isString:Xb,isNumber:Kc,isBoolean:Gb,isObject:za,isPlainObject:_o,isEmptyObject:Jb,isReadableStream:aw,isRequest:ow,isResponse:iw,isHeaders:rw,isUndefined:Ma,isDate:Yb,isFile:qb,isBlob:Kb,isRegExp:bw,isFunction:kt,isStream:ew,isURLSearchParams:nw,isTypedArray:fw,isFileList:Qb,forEach:Pa,merge:yr,extend:lw,trim:sw,stripBOM:cw,inherits:dw,toFlatObject:uw,kindOf:ai,kindOfTest:Ut,endsWith:mw,toArray:pw,forEachEntry:hw,matchAll:vw,isHTMLForm:gw,hasOwnProperty:El,hasOwnProp:El,reduceDescriptors:td,freezeMethods:ww,toObjectSet:kw,toCamelCase:yw,noop:_w,toFiniteNumber:Ew,findKey:Qc,global:Sn,isContextDefined:ed,isSpecCompliantForm:xw,toJSONObject:Cw,isAsyncFn:Sw,isThenable:Vw,setImmediate:nd,asap:Nw,isIterable:Tw};function Ie(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)}Y.inherits(Ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}});const ad=Ie.prototype,od={};["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=>{od[o]={value:o}});Object.defineProperties(Ie,od);Object.defineProperty(ad,"isAxiosError",{value:!0});Ie.from=(o,n,t,a,i,r)=>{const s=Object.create(ad);return Y.toFlatObject(o,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Ie.call(s,o.message,n,t,a,i),s.cause=o,s.name=o.name,r&&Object.assign(s,r),s};const Mw=null;function br(o){return Y.isPlainObject(o)||Y.isArray(o)}function id(o){return Y.endsWith(o,"[]")?o.slice(0,-2):o}function xl(o,n,t){return o?o.concat(n).map(function(i,r){return i=id(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function Bw(o){return Y.isArray(o)&&!o.some(br)}const Iw=Y.toFlatObject(Y,{},null,function(n){return/^is[A-Z]/.test(n)});function ii(o,n,t){if(!Y.isObject(o))throw new TypeError("target must be an object");n=n||new FormData,t=Y.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,w){return!Y.isUndefined(w[y])});const a=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(n);if(!Y.isFunction(i))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(Y.isDate(v))return v.toISOString();if(Y.isBoolean(v))return v.toString();if(!c&&Y.isBlob(v))throw new Ie("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(v)||Y.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,y,w){let N=v;if(v&&!w&&typeof v=="object"){if(Y.endsWith(y,"{}"))y=a?y:y.slice(0,-2),v=JSON.stringify(v);else if(Y.isArray(v)&&Bw(v)||(Y.isFileList(v)||Y.endsWith(y,"[]"))&&(N=Y.toArray(v)))return y=id(y),N.forEach(function(b,f){!(Y.isUndefined(b)||b===null)&&n.append(s===!0?xl([y],f,r):s===null?y:y+"[]",d(b))}),!1}return br(v)?!0:(n.append(xl(w,y,r),d(v)),!1)}const m=[],h=Object.assign(Iw,{defaultVisitor:u,convertValue:d,isVisitable:br});function p(v,y){if(!Y.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+y.join("."));m.push(v),Y.forEach(v,function(N,C){(!(Y.isUndefined(N)||N===null)&&i.call(n,N,Y.isString(C)?C.trim():C,y,h))===!0&&p(N,y?y.concat(C):[C])}),m.pop()}}if(!Y.isObject(o))throw new TypeError("data must be an object");return p(o),n}function Cl(o){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(a){return n[a]})}function Gr(o,n){this._pairs=[],o&&ii(o,this,n)}const rd=Gr.prototype;rd.append=function(n,t){this._pairs.push([n,t])};rd.toString=function(n){const t=n?function(a){return n.call(this,a,Cl)}:Cl;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Fw(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function sd(o,n,t){if(!n)return o;const a=t&&t.encode||Fw;Y.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=Y.isURLSearchParams(n)?n.toString():new Gr(n,t).toString(a),r){const s=o.indexOf("#");s!==-1&&(o=o.slice(0,s)),o+=(o.indexOf("?")===-1?"?":"&")+r}return o}class Sl{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){Y.forEach(this.handlers,function(a){a!==null&&n(a)})}}const ld={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$w=typeof URLSearchParams<"u"?URLSearchParams:Gr,Rw=typeof FormData<"u"?FormData:null,Dw=typeof Blob<"u"?Blob:null,Aw={isBrowser:!0,classes:{URLSearchParams:$w,FormData:Rw,Blob:Dw},protocols:["http","https","file","blob","url","data"]},Jr=typeof window<"u"&&typeof document<"u",wr=typeof navigator=="object"&&navigator||void 0,Lw=Jr&&(!wr||["ReactNative","NativeScript","NS"].indexOf(wr.product)<0),Uw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ow=Jr&&window.location.href||"http://localhost",zw=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Jr,hasStandardBrowserEnv:Lw,hasStandardBrowserWebWorkerEnv:Uw,navigator:wr,origin:Ow},Symbol.toStringTag,{value:"Module"})),ft={...zw,...Aw};function Pw(o,n){return ii(o,new ft.classes.URLSearchParams,{visitor:function(t,a,i,r){return ft.isNode&&Y.isBuffer(t)?(this.append(a,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function Ww(o){return Y.matchAll(/\w+|\[(\w*)]/g,o).map(n=>n[0]==="[]"?"":n[1]||n[0])}function jw(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 cd(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&&Y.isArray(i)?i.length:s,c?(Y.hasOwnProp(i,s)?i[s]=[i[s],a]:i[s]=a,!l):((!i[s]||!Y.isObject(i[s]))&&(i[s]=[]),n(t,a,i[s],r)&&Y.isArray(i[s])&&(i[s]=jw(i[s])),!l)}if(Y.isFormData(o)&&Y.isFunction(o.entries)){const t={};return Y.forEachEntry(o,(a,i)=>{n(Ww(a),i,t,0)}),t}return null}function Zw(o,n,t){if(Y.isString(o))try{return(n||JSON.parse)(o),Y.trim(o)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(o)}const Wa={transitional:ld,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const a=t.getContentType()||"",i=a.indexOf("application/json")>-1,r=Y.isObject(n);if(r&&Y.isHTMLForm(n)&&(n=new FormData(n)),Y.isFormData(n))return i?JSON.stringify(cd(n)):n;if(Y.isArrayBuffer(n)||Y.isBuffer(n)||Y.isStream(n)||Y.isFile(n)||Y.isBlob(n)||Y.isReadableStream(n))return n;if(Y.isArrayBufferView(n))return n.buffer;if(Y.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(a.indexOf("application/x-www-form-urlencoded")>-1)return Pw(n,this.formSerializer).toString();if((l=Y.isFileList(n))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return ii(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Zw(n)):n}],transformResponse:[function(n){const t=this.transitional||Wa.transitional,a=t&&t.forcedJSONParsing,i=this.responseType==="json";if(Y.isResponse(n)||Y.isReadableStream(n))return n;if(n&&Y.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"?Ie.from(l,Ie.ERR_BAD_RESPONSE,this,null,this.response):l}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ft.classes.FormData,Blob:ft.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],o=>{Wa.headers[o]={}});const Hw=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Xw=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]&&Hw[t])&&(t==="set-cookie"?n[t]?n[t].push(a):n[t]=[a]:n[t]=n[t]?n[t]+", "+a:a)}),n},Vl=Symbol("internals");function ma(o){return o&&String(o).trim().toLowerCase()}function Eo(o){return o===!1||o==null?o:Y.isArray(o)?o.map(Eo):String(o)}function Gw(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 Jw=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function Xi(o,n,t,a,i){if(Y.isFunction(a))return a.call(this,n,t);if(i&&(n=t),!!Y.isString(n)){if(Y.isString(a))return n.indexOf(a)!==-1;if(Y.isRegExp(a))return a.test(n)}}function Yw(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,a)=>t.toUpperCase()+a)}function qw(o,n){const t=Y.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 _t=class{constructor(n){n&&this.set(n)}set(n,t,a){const i=this;function r(l,c,d){const u=ma(c);if(!u)throw new Error("header name must be a non-empty string");const m=Y.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||c]=Eo(l))}const s=(l,c)=>Y.forEach(l,(d,u)=>r(d,u,c));if(Y.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(Y.isString(n)&&(n=n.trim())&&!Jw(n))s(Xw(n),t);else if(Y.isObject(n)&&Y.isIterable(n)){let l={},c,d;for(const u of n){if(!Y.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?Y.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,a);return this}get(n,t){if(n=ma(n),n){const a=Y.findKey(this,n);if(a){const i=this[a];if(!t)return i;if(t===!0)return Gw(i);if(Y.isFunction(t))return t.call(this,i,a);if(Y.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=ma(n),n){const a=Y.findKey(this,n);return!!(a&&this[a]!==void 0&&(!t||Xi(this,this[a],a,t)))}return!1}delete(n,t){const a=this;let i=!1;function r(s){if(s=ma(s),s){const l=Y.findKey(a,s);l&&(!t||Xi(a,a[l],l,t))&&(delete a[l],i=!0)}}return Y.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||Xi(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,a={};return Y.forEach(this,(i,r)=>{const s=Y.findKey(a,r);if(s){t[s]=Eo(i),delete t[r];return}const l=n?Yw(r):String(r).trim();l!==r&&delete t[r],t[l]=Eo(i),a[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return Y.forEach(this,(a,i)=>{a!=null&&a!==!1&&(t[i]=n&&Y.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[Vl]=this[Vl]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=ma(s);a[l]||(qw(i,s),a[l]=!0)}return Y.isArray(n)?n.forEach(r):r(n),this}};_t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Y.reduceDescriptors(_t.prototype,({value:o},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>o,set(a){this[t]=a}}});Y.freezeMethods(_t);function Gi(o,n){const t=this||Wa,a=n||t,i=_t.from(a.headers);let r=a.data;return Y.forEach(o,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function dd(o){return!!(o&&o.__CANCEL__)}function aa(o,n,t){Ie.call(this,o??"canceled",Ie.ERR_CANCELED,n,t),this.name="CanceledError"}Y.inherits(aa,Ie,{__CANCEL__:!0});function ud(o,n,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?o(t):n(new Ie("Request failed with status code "+t.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Kw(o){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return n&&n[1]||""}function Qw(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 e2(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 Do=(o,n,t=3)=>{let a=0;const i=Qw(50,250);return e2(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)},Nl=(o,n)=>{const t=o!=null;return[a=>n[0]({lengthComputable:t,total:o,loaded:a}),n[1]]},Tl=o=>(...n)=>Y.asap(()=>o(...n)),t2=ft.hasStandardBrowserEnv?((o,n)=>t=>(t=new URL(t,ft.origin),o.protocol===t.protocol&&o.host===t.host&&(n||o.port===t.port)))(new URL(ft.origin),ft.navigator&&/(msie|trident)/i.test(ft.navigator.userAgent)):()=>!0,n2=ft.hasStandardBrowserEnv?{write(o,n,t,a,i,r){const s=[o+"="+encodeURIComponent(n)];Y.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),Y.isString(a)&&s.push("path="+a),Y.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 a2(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function o2(o,n){return n?o.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):o}function md(o,n,t){let a=!a2(n);return o&&(a||t==!1)?o2(o,n):n}const Ml=o=>o instanceof _t?{...o}:o;function Mn(o,n){n=n||{};const t={};function a(d,u,m,h){return Y.isPlainObject(d)&&Y.isPlainObject(u)?Y.merge.call({caseless:h},d,u):Y.isPlainObject(u)?Y.merge({},u):Y.isArray(u)?u.slice():u}function i(d,u,m,h){if(Y.isUndefined(u)){if(!Y.isUndefined(d))return a(void 0,d,m,h)}else return a(d,u,m,h)}function r(d,u){if(!Y.isUndefined(u))return a(void 0,u)}function s(d,u){if(Y.isUndefined(u)){if(!Y.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(Ml(d),Ml(u),m,!0)};return Y.forEach(Object.keys({...o,...n}),function(u){const m=c[u]||i,h=m(o[u],n[u],u);Y.isUndefined(h)&&m!==l||(t[u]=h)}),t}const pd=o=>{const n=Mn({},o);let{data:t,withXSRFToken:a,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=_t.from(s),n.url=sd(md(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(Y.isFormData(t)){if(ft.hasStandardBrowserEnv||ft.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(ft.hasStandardBrowserEnv&&(a&&Y.isFunction(a)&&(a=a(n)),a||a!==!1&&t2(n.url))){const d=i&&r&&n2.read(r);d&&s.set(i,d)}return n},i2=typeof XMLHttpRequest<"u",r2=i2&&function(o){return new Promise(function(t,a){const i=pd(o);let r=i.data;const s=_t.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,m,h,p,v;function y(){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 N(){if(!w)return;const b=_t.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};ud(function(T){t(T),y()},function(T){a(T),y()},_),w=null}"onloadend"in w?w.onloadend=N:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(N)},w.onabort=function(){w&&(a(new Ie("Request aborted",Ie.ECONNABORTED,o,w)),w=null)},w.onerror=function(){a(new Ie("Network Error",Ie.ERR_NETWORK,o,w)),w=null},w.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||ld;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),a(new Ie(f,_.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,o,w)),w=null},r===void 0&&s.setContentType(null),"setRequestHeader"in w&&Y.forEach(s.toJSON(),function(f,_){w.setRequestHeader(_,f)}),Y.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),l&&l!=="json"&&(w.responseType=i.responseType),d&&([h,v]=Do(d,!0),w.addEventListener("progress",h)),c&&w.upload&&([m,p]=Do(c),w.upload.addEventListener("progress",m),w.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=b=>{w&&(a(!b||b.type?new aa(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 C=Kw(i.url);if(C&&ft.protocols.indexOf(C)===-1){a(new Ie("Unsupported protocol "+C+":",Ie.ERR_BAD_REQUEST,o));return}w.send(r||null)})},s2=(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 Ie?u:new aa(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Ie(`timeout ${n} of ms exceeded`,Ie.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=()=>Y.asap(l),c}},l2=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},c2=async function*(o,n){for await(const t of d2(o))yield*l2(t,n)},d2=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()}},Bl=(o,n,t,a)=>{const i=c2(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})},ri=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",fd=ri&&typeof ReadableStream=="function",u2=ri&&(typeof TextEncoder=="function"?(o=>n=>o.encode(n))(new TextEncoder):async o=>new Uint8Array(await new Response(o).arrayBuffer())),hd=(o,...n)=>{try{return!!o(...n)}catch{return!1}},m2=fd&&hd(()=>{let o=!1;const n=new Request(ft.origin,{body:new ReadableStream,method:"POST",get duplex(){return o=!0,"half"}}).headers.has("Content-Type");return o&&!n}),Il=64*1024,kr=fd&&hd(()=>Y.isReadableStream(new Response("").body)),Ao={stream:kr&&(o=>o.body)};ri&&(o=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Ao[n]&&(Ao[n]=Y.isFunction(o[n])?t=>t[n]():(t,a)=>{throw new Ie(`Response type '${n}' is not supported`,Ie.ERR_NOT_SUPPORT,a)})})})(new Response);const p2=async o=>{if(o==null)return 0;if(Y.isBlob(o))return o.size;if(Y.isSpecCompliantForm(o))return(await new Request(ft.origin,{method:"POST",body:o}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(o)||Y.isArrayBuffer(o))return o.byteLength;if(Y.isURLSearchParams(o)&&(o=o+""),Y.isString(o))return(await u2(o)).byteLength},f2=async(o,n)=>{const t=Y.toFiniteNumber(o.getContentLength());return t??p2(n)},h2=ri&&(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}=pd(o);d=d?(d+"").toLowerCase():"text";let p=s2([i,r&&r.toAbortSignal()],s),v;const y=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let w;try{if(c&&m2&&t!=="get"&&t!=="head"&&(w=await f2(u,a))!==0){let _=new Request(n,{method:"POST",body:a,duplex:"half"}),$;if(Y.isFormData(a)&&($=_.headers.get("content-type"))&&u.setContentType($),_.body){const[T,x]=Nl(w,Do(Tl(c)));a=Bl(_.body,Il,T,x)}}Y.isString(m)||(m=m?"include":"omit");const N="credentials"in Request.prototype;v=new Request(n,{...h,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:N?m:void 0});let C=await fetch(v,h);const b=kr&&(d==="stream"||d==="response");if(kr&&(l||b&&y)){const _={};["status","statusText","headers"].forEach(I=>{_[I]=C[I]});const $=Y.toFiniteNumber(C.headers.get("content-length")),[T,x]=l&&Nl($,Do(Tl(l),!0))||[];C=new Response(Bl(C.body,Il,T,()=>{x&&x(),y&&y()}),_)}d=d||"text";let f=await Ao[Y.findKey(Ao,d)||"text"](C,o);return!b&&y&&y(),await new Promise((_,$)=>{ud(_,$,{data:f,headers:_t.from(C.headers),status:C.status,statusText:C.statusText,config:o,request:v})})}catch(N){throw y&&y(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,o,v),{cause:N.cause||N}):Ie.from(N,N&&N.code,o,v)}}),_r={http:Mw,xhr:r2,fetch:h2};Y.forEach(_r,(o,n)=>{if(o){try{Object.defineProperty(o,"name",{value:n})}catch{}Object.defineProperty(o,"adapterName",{value:n})}});const Fl=o=>`- ${o}`,v2=o=>Y.isFunction(o)||o===null||o===!1,vd={getAdapter:o=>{o=Y.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,!v2(t)&&(a=_r[(s=String(t)).toLowerCase()],a===void 0))throw new Ie(`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(Fl).join(`
|
|
340
|
-
`):" "+Fl(r[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:_r};function Ji(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new aa(null,o)}function $l(o){return Ji(o),o.headers=_t.from(o.headers),o.data=Gi.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),vd.getAdapter(o.adapter||Wa.adapter)(o).then(function(a){return Ji(o),a.data=Gi.call(o,o.transformResponse,a),a.headers=_t.from(a.headers),a},function(a){return dd(a)||(Ji(o),a&&a.response&&(a.response.data=Gi.call(o,o.transformResponse,a.response),a.response.headers=_t.from(a.response.headers))),Promise.reject(a)})}const gd="1.11.0",si={};["object","boolean","number","function","string","symbol"].forEach((o,n)=>{si[o]=function(a){return typeof a===o||"a"+(n<1?"n ":" ")+o}});const Rl={};si.transitional=function(n,t,a){function i(r,s){return"[Axios v"+gd+"] Transitional option '"+r+"'"+s+(a?". "+a:"")}return(r,s,l)=>{if(n===!1)throw new Ie(i(s," has been removed"+(t?" in "+t:"")),Ie.ERR_DEPRECATED);return t&&!Rl[s]&&(Rl[s]=!0),n?n(r,s,l):!0}};si.spelling=function(n){return(t,a)=>!0};function g2(o,n,t){if(typeof o!="object")throw new Ie("options must be an object",Ie.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 Ie("option "+r+" must be "+c,Ie.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Ie("Unknown option "+r,Ie.ERR_BAD_OPTION)}}const xo={assertOptions:g2,validators:si},Ht=xo.validators;let Nn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Sl,response:new Sl}}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=Mn(this.defaults,t);const{transitional:a,paramsSerializer:i,headers:r}=t;a!==void 0&&xo.assertOptions(a,{silentJSONParsing:Ht.transitional(Ht.boolean),forcedJSONParsing:Ht.transitional(Ht.boolean),clarifyTimeoutError:Ht.transitional(Ht.boolean)},!1),i!=null&&(Y.isFunction(i)?t.paramsSerializer={serialize:i}:xo.assertOptions(i,{encode:Ht.function,serialize:Ht.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),xo.assertOptions(t,{baseUrl:Ht.spelling("baseURL"),withXsrfToken:Ht.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&Y.merge(r.common,r[t.method]);r&&Y.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=_t.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(t)===!1||(c=c&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const d=[];this.interceptors.response.forEach(function(y){d.push(y.fulfilled,y.rejected)});let u,m=0,h;if(!c){const v=[$l.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++],y=l[m++];try{p=v(p)}catch(w){y.call(this,w);break}}try{u=$l.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=Mn(this.defaults,n);const t=md(n.baseURL,n.url,n.allowAbsoluteUrls);return sd(t,n.params,n.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(n){Nn.prototype[n]=function(t,a){return this.request(Mn(a||{},{method:n,url:t,data:(a||{}).data}))}});Y.forEach(["post","put","patch"],function(n){function t(a){return function(r,s,l){return this.request(Mn(l||{},{method:n,headers:a?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Nn.prototype[n]=t(),Nn.prototype[n+"Form"]=t(!0)});let y2=class yd{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 aa(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 yd(function(i){n=i}),cancel:n}}};function b2(o){return function(t){return o.apply(null,t)}}function w2(o){return Y.isObject(o)&&o.isAxiosError===!0}const Er={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(Er).forEach(([o,n])=>{Er[n]=o});function bd(o){const n=new Nn(o),t=Jc(Nn.prototype.request,n);return Y.extend(t,Nn.prototype,n,{allOwnKeys:!0}),Y.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return bd(Mn(o,i))},t}const Ye=bd(Wa);Ye.Axios=Nn;Ye.CanceledError=aa;Ye.CancelToken=y2;Ye.isCancel=dd;Ye.VERSION=gd;Ye.toFormData=ii;Ye.AxiosError=Ie;Ye.Cancel=Ye.CanceledError;Ye.all=function(n){return Promise.all(n)};Ye.spread=b2;Ye.isAxiosError=w2;Ye.mergeConfig=Mn;Ye.AxiosHeaders=_t;Ye.formToJSON=o=>cd(Y.isHTMLForm(o)?new FormData(o):o);Ye.getAdapter=vd.getAdapter;Ye.HttpStatusCode=Er;Ye.default=Ye;const{Axios:p5,AxiosError:f5,CanceledError:h5,isCancel:v5,CancelToken:g5,VERSION:y5,all:b5,Cancel:w5,isAxiosError:k5,spread:_5,toFormData:E5,AxiosHeaders:x5,HttpStatusCode:C5,formToJSON:S5,getAdapter:V5,mergeConfig:N5}=Ye;class Yr{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Ye.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 Yr;const k2={key:0,class:"mobile-layout"},_2={class:"mobile-toolbar"},E2={class:"mobile-toolbar-left"},x2=["aria-label"],C2={class:"mobile-toolbar-right"},S2=["disabled"],V2=["disabled"],N2={class:"preview-section"},T2={key:0,class:"mobile-export-overlay"},M2={class:"mobile-export-progress"},B2={class:"mobile-export-bar"},I2={class:"mobile-timeline-zoom"},F2={class:"mobile-edit-strip"},$2={class:"mobile-selection-summary"},R2={class:"mobile-selection-title"},D2={class:"mobile-selection-meta"},A2={class:"mobile-readout-row"},L2=["disabled"],U2={class:"mobile-readout-grid"},O2={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},z2={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},P2={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},W2={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},j2=["disabled"],Z2={class:"mobile-speed-strip"},H2={class:"mobile-speed-chips"},X2=["data-testid","onClick"],G2={class:"mobile-edit-actions"},J2=["disabled"],Y2=["disabled"],q2=["disabled"],K2=["disabled"],Q2=["disabled"],ek={class:"mobile-action-sheet-header"},tk={class:"mobile-action-sheet-title"},nk={class:"mobile-action-sheet-subtitle"},ak={class:"mobile-action-sheet-actions"},ok=["disabled"],ik=["disabled"],rk=["disabled"],sk=["disabled"],lk=["disabled"],ck={key:1,class:"desktop-layout"},dk={class:"desktop-main-row"},uk={class:"preview-panel"},mk={class:"fit-toggle"},pk={class:"editor-content"},fk={class:"editor-tabs"},hk={class:"tab-header"},vk=["onClick"],gk={class:"tab-content-area"},yk={class:"filter-controls"},bk={class:"text-controls"},wk={class:"transition-controls"},kk={class:"audio-controls"},_k={class:"adjustments-controls"},Ek={key:1,class:"no-filter-selected"},xk={class:"export-controls"},Ck={key:0,"data-testid":"video-export-status-completed"},Sk={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Vk={class:"desktop-timeline-row"},Nk={class:"timeline-zoom"},Tk=["value"],Mk={class:"zoom-readout"},Bk={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Ik={class:"dev-editor-row"},Fk={class:"dev-editor-field"},$k={class:"dev-editor-field"},Rk=["disabled"],Dk=["disabled"],Ak=["disabled"],Lk={class:"dev-editor-row"},Uk={class:"dev-editor-field dev-editor-field--wide"},Ok=["value"],zk=["disabled"],Pk=["disabled"],Wk=["disabled"],jk=["disabled"],Zk=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 g=a.media.uuid??a.media.id;return typeof g=="string"&&g.trim()!==""?g.trim():void 0}),s=e.computed(()=>{const g=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return g!==""?g: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 g=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},E=a.featureFlags;return E?{filters:typeof E.filters=="boolean"?E.filters:g.filters,adjustments:typeof E.adjustments=="boolean"?E.adjustments:g.adjustments,text:typeof E.text=="boolean"?E.text:g.text,transitions:typeof E.transitions=="boolean"?E.transitions:g.transitions,audio:typeof E.audio=="boolean"?E.audio:g.audio,export:typeof E.export=="boolean"?E.export:g.export}:g}),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),y=e.ref(null),w=e.ref(!1),N=e.computed(()=>l.value?v.value:y.value);function C(g){return g==="contain"||g==="cover"||g==="none"}function b(g){if(!(g!=null&&g.metadata))return null;const E=g.metadata.fit_mode;return C(E)?E:null}const f=e.shallowRef(null),_=e.ref(null),$=e.ref(b(a.initialRecipe)??"contain"),T=e.ref(null),x=e.ref(null),I=e.ref(null),Z=e.ref(!1),S=new Map,L=e.ref([]),R=e.ref([]),P=e.ref([]),A=e.ref([]),B=e.ref(1),D=()=>{l.value=window.innerWidth<768},k=[{id:"filters",label:"Filters",icon:fn},{id:"adjustments",label:"Adjust",icon:np},{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:Va}],F=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],H=e.computed(()=>k.filter(g=>u.value[g.id])),j=e.computed(()=>F.filter(g=>u.value[g.id])),te=e.computed(()=>{var g,E;return((g=j.value[0])==null?void 0:g.id)??((E=H.value[0])==null?void 0:E.id)??"filters"});e.watch(u,g=>{g[c.value]||(c.value=te.value),g[d.value]||(d.value=te.value)},{immediate:!0,deep:!0}),e.watch(te,g=>{u.value[c.value]||(c.value=g),u.value[d.value]||(d.value=g)},{immediate:!0}),e.watch(u,g=>{g.export||(c.value==="export"&&(c.value=te.value),d.value==="export"&&(d.value=te.value))},{immediate:!0,deep:!0});const he=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),ge=pc(),{currentFrame:ae,playheadPosition:V,timelineClips:U,totalDuration:K,hasChanges:ee,isPlaying:ne,selectedClip:fe,zoomLevel:ie,playbackSpeed:pe,handleTrim:ke,handleSplit:re,handleClipSelect:ce,splitAtPlayhead:_e,deleteSelectedClip:Ve,duplicateSelectedClip:ut,setZoomLevel:He,moveClip:xt,setFilters:Ge,setTextOverlays:at,setAudioTracks:Ct,saveDraft:$t,clearHasChanges:lt,resetChanges:yt,generateRecipe:de,zoomIn:Ee,zoomOut:xe,fitToWindow:ze,togglePlayback:M,setPlaying:z,seekTo:J,frameForward:q,frameBackward:ue,skipToStart:ve,skipToEnd:Te,setPlaybackSpeed:$e,updateSourceDuration:Be,undo:Ae,redo:et,canUndo:ht,canRedo:Ot}=Ib(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:oa,activeFilters:tt,selectedFilter:ls,previewFilter:ja,previewFilterEffect:cs,applyFilter:ds,updateFilterParams:Xd,removeFilter:Gd,clearAllFilters:us,setActiveFilters:Jd}=Pb();function ia(g){var X,Q;const E=((X=fe.value)==null?void 0:X.id)??((Q=U.value[0])==null?void 0:Q.id);E&&(Z.value=!0,typeof g=="object"&&g.id?ds(g.id):typeof g=="string"&&ds(g),Ge(tt.value),f.value?f.value.setClipFilters(E,tt.value):S.set(E,[...tt.value]),ce(E),Z.value=!1,Wt())}function Yd(){var E,X;const g=((E=fe.value)==null?void 0:E.id)??((X=U.value[0])==null?void 0:X.id);g&&ce(g)}function ms(g){const E=tt.value.find(X=>X.filterId===g);E&&Gd(E.id)}const ra=e.computed(()=>oa.value.map(E=>{var Q;const X=[];if(E.controls&&E.controls.length>0)for(const me of E.controls){const se=me.type;if(se==="button"||se==="text"||se==="range")continue;const le={id:me.property||me.id,label:me.label||me.id,type:se,default:me.default??(se==="toggle"?!1:se==="color"?"#ffffff":0)};se==="slider"&&(le.min=me.min??0,le.max=me.max??1,le.step=me.step??.01),se==="select"&&me.options&&(le.options=me.options),X.push(le)}else if(E.paramRanges){const me=Object.entries(E.paramRanges);for(const[se,le]of me){const Le=se.replace(/[-_]/g," ").replace(/\b\w/g,jt=>jt.toUpperCase()),vt=(Q=E.defaultParams)==null?void 0:Q[se],tn=(le.min+le.max)/2;X.push({id:se,label:Le,min:le.min,max:le.max,step:le.step??.01,default:typeof vt=="number"?vt:tn})}}return{id:E.id,name:E.name,category:E.category,params:X}})),Rn=e.ref("0.00"),Dn=e.ref("0.00"),rn=e.ref("");e.watch(ra,g=>{if(g.length===0){rn.value="";return}g.some(X=>X.id===rn.value)||(rn.value=g[0].id)},{immediate:!0});const ot=e.ref(!1),Xe=e.ref(0),Qt=e.ref(!1),Ze=e.ref(null),Rt=e.ref(null);let Za=null,Mt=!1,en=null;const ui=e.computed(()=>{const g=new Map;return tt.value.forEach(E=>g.set(E.filterId,E)),g}),qd=e.computed(()=>{var g,E;return ae.value?ae.value:((g=a.media)==null?void 0:g.thumbnail_url)||((E=a.media)==null?void 0:E.url)}),zt=e.ref("");e.watch(()=>{var g,E;return{file:(g=a.media)==null?void 0:g.file,url:(E=a.media)==null?void 0:E.url}},(g,E,X)=>{var me,se;const Q=zt.value;X(()=>{Q&&Q.startsWith("blob:")&&URL.revokeObjectURL(Q)}),(me=a.media)!=null&&me.file?zt.value=URL.createObjectURL(a.media.file):(se=a.media)!=null&&se.url?zt.value=a.media.url:zt.value=""},{immediate:!0}),e.onUnmounted(()=>{zt.value&&zt.value.startsWith("blob:")&&URL.revokeObjectURL(zt.value)});const mi=e.computed(()=>zt.value),ps=e.computed(()=>{if(!a.media)return null;const{file:g,...E}=a.media;return{...E,url:zt.value}}),fs=e.computed(()=>{var E;const g=(E=a.media)==null?void 0:E.url;return!!(g&&/^https?:/i.test(g))}),hs=e.computed(()=>tt.value),vs=e.computed(()=>V.value),pi=e.computed(()=>!!fe.value&&V.value>0),fi=e.computed(()=>!!fe.value&&U.value.length>1),gs=e.computed(()=>!!fe.value),sn=e.ref(!0),Kd=[.5,1,1.5,2],Ha=e.computed(()=>{const g=new Set([0,Bt.value]);for(const E of U.value)g.add(E.timelineStart),g.add(E.timelineEnd);return Array.from(g).filter(E=>Number.isFinite(E)).sort((E,X)=>E-X)}),Qd=e.computed(()=>Ha.value.some(g=>g<V.value-.001)),eu=e.computed(()=>Ha.value.some(g=>g>V.value+.001)),Xa=e.ref(!1),Ga=e.ref(null);function ln(g){if(!Number.isFinite(g)||g<0)return"0:00";const E=Math.floor(g/60),X=Math.floor(g%60);return`${E}:${X.toString().padStart(2,"0")}`}const tu=e.computed(()=>{var X;const g=fe.value??U.value[0];if(!g)return"No clip selected";const E=(X=g.label)==null?void 0:X.trim();return E&&E.length>0?E:`Clip ${g.id.slice(-4)}`}),nu=e.computed(()=>{const g=fe.value??U.value[0];if(!g)return"Tap a clip to start editing";const E=Math.max(0,g.timelineEnd-g.timelineStart);return`${ln(g.timelineStart)} - ${ln(g.timelineEnd)} • ${E.toFixed(1)}s`});function ys(g){return!Number.isFinite(g)||g<0?"0.0s":g<60?`${g.toFixed(1)}s`:ln(g)}const au=e.computed(()=>ln(V.value)),ou=e.computed(()=>{const g=fe.value??U.value[0];return g?ln(g.sourceIn):"0:00"}),iu=e.computed(()=>{const g=fe.value??U.value[0];return g?ln(g.sourceOut):"0:00"}),ru=e.computed(()=>{const g=fe.value??U.value[0];return g?ys(g.timelineEnd-g.timelineStart):"0.0s"}),hi=e.computed(()=>Ga.value===null?fe.value??U.value[0]??null:U.value.find(g=>g.id===Ga.value)??null),su=e.computed(()=>{var X;const g=hi.value;if(!g)return"Clip actions";const E=(X=g.label)==null?void 0:X.trim();return E&&E.length>0?E:`Clip ${g.id.slice(-4)}`}),lu=e.computed(()=>{const g=hi.value;return g?`${ln(g.timelineStart)} - ${ln(g.timelineEnd)} • ${ys(g.timelineEnd-g.timelineStart)}`:"Choose an action"}),vi=e.ref(0),Bt=e.computed(()=>{try{const g=K.value??K;return g&&typeof g=="number"&&g>0?g:vi.value}catch{return vi.value}}),An=e.ref(),gi=e.ref(),yi=e.ref(),bi=e.ref(),Ja=e.ref(0),vn=e.ref(!1);let bt=null,Pt=null;e.watch(Bt,g=>{var X;if(vn.value||!g||g<=0)return;const E=Ja.value||((X=An.value)==null?void 0:X.clientWidth)||0;E>0&&(vn.value=!0,ze(E))}),e.watch(Ja,g=>{if(vn.value||!g||g<=0)return;Bt.value>0&&(vn.value=!0,ze(g))}),e.watch(l,g=>{g||gn()}),e.watch(()=>{var g;return(g=hi.value)==null?void 0:g.id},g=>{Xa.value&&!g&&gn()});function Ln(g){return Number.isFinite(g)?g.toFixed(2):"0.00"}function bs(g){const E=Number(g);return Number.isFinite(E)?E:null}function cu(g){g&&(Rn.value=Ln(g.sourceIn),Dn.value=Ln(g.sourceOut))}e.watch(()=>{var g,E,X;return[(g=fe.value)==null?void 0:g.id,(E=fe.value)==null?void 0:E.sourceIn,(X=fe.value)==null?void 0:X.sourceOut]},()=>{cu(fe.value)},{immediate:!0});function ws(g){const E=fe.value;if(!E)return;const X=1/30,Q=E.sourceMinIn??0,me=E.sourceMaxOut??Bt.value,se=E.sourceIn+(V.value-E.timelineStart);if(g==="start"){const Le=Math.max(Q,Math.min(se,E.sourceOut-X));Rn.value=Ln(Le);return}const le=Math.max(E.sourceIn+X,Math.min(se,me));Dn.value=Ln(le)}function du(){const g=fe.value;if(!g)return;const E=bs(Rn.value),X=bs(Dn.value);if(E===null||X===null)return;const Q=1/30,me=g.sourceMinIn??0,se=g.sourceMaxOut??Bt.value,le=Math.max(me,Math.min(E,se-Q)),Le=Math.max(le+Q,Math.min(X,se));ke(g.id,"start",le),ke(g.id,"end",Le),Rn.value=Ln(le),Dn.value=Ln(Le),fe.value&&J(fe.value.timelineStart)}function uu(){rn.value.trim()!==""&&ia(rn.value)}function mu(){var g;us(),Ge(tt.value),(g=fe.value)!=null&&g.id&&(f.value?f.value.setClipFilters(fe.value.id,tt.value):S.set(fe.value.id,[...tt.value])),Wt()}function ks(g,E,X){var me,se;const Q=tt.value.find(le=>le.filterId===g);Q?(Q.params={...Q.params,[E]:X},Ge(tt.value),f.value&&((me=fe.value)!=null&&me.id)?f.value.setClipFilters(fe.value.id,tt.value):(se=fe.value)!=null&&se.id&&S.set(fe.value.id,[...tt.value]),Wt(),Yd()):ja.value&&ja.value.filterId===g&&(ja.value.params={...ja.value.params||{},[E]:X})}function _s(g){J(g)}function Es(g){!g||!Number.isFinite(g.timestamp)||J(g.timestamp)}function xs(g){z(g)}function Ya(g){!Number.isFinite(g)||g<=0||(vi.value=g,Be(g))}function gn(){Xa.value=!1,Ga.value=null}function pu(g){l.value&&(Ga.value=g,Xa.value=!0)}function wi(g){var Q,me,se,le;const E=((Q=fe.value)==null?void 0:Q.id)??((me=U.value[0])==null?void 0:me.id)??null;ce(g),(((se=fe.value)==null?void 0:se.id)??((le=U.value[0])==null?void 0:le.id)??null)!==E&&ge.selection()}function Cs(g){wi(g),pu(g)}function Ss(g){g&&ge.selection()}function Vs(){sn.value=!sn.value,ge.selection()}function Ns(){const g=Ha.value.filter(X=>X<V.value-.001),E=g.length>0?g[g.length-1]:0;J(E)}function Ts(){const g=Ha.value.find(E=>E>V.value+.001);J(g??Bt.value)}function ki(){Ae()}function _i(){et()}function qa(){const g=U.value.length;_e(),U.value.length>g&&(ge.success(),gn())}function Ms(g){const E=U.value.length;re(g),U.value.length>E&&ge.success()}function Ei(){const g=U.value.length;ut(),U.value.length>g&&(ge.selection(),gn())}function xi(){const g=U.value.length;Ve(),U.value.length<g&&(ge.error(),gn())}function fu(g){const E=pe.value;$e(g),pe.value!==E&&ge.selection()}function hu(g){return g instanceof HTMLElement?g.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Bs(g){if(l.value||hu(g.target))return;const E=g.key.toLowerCase(),X=g.metaKey||g.ctrlKey;if(g.code==="Space"){g.preventDefault(),M();return}if(!X&&E==="s"){g.preventDefault(),qa();return}if(E==="arrowleft"){g.preventDefault(),ue();return}if(E==="arrowright"){g.preventDefault(),q();return}if(E==="home"){g.preventDefault(),ve();return}if(E==="end"){g.preventDefault(),Te();return}if(!X&&E==="["){g.preventDefault(),Ns();return}if(!X&&E==="]"){g.preventDefault(),Ts();return}if(X&&E==="z"&&g.shiftKey){g.preventDefault(),_i();return}X&&E==="z"&&(g.preventDefault(),ki())}function vu(){var E;const g=Ja.value||((E=An.value)==null?void 0:E.clientWidth)||800;ze(g)}function Ci(g){vn.value=!0,He(g)}function gu(){vn.value=!0,Ee()}function yu(){vn.value=!0,xe()}function bu(g){const E=g.target,X=Number(E.value);Ci(X)}function Is(g){const E=Math.min(600,Math.max(10,ie.value+g));Ci(E)}function Si(){Pt==null||Pt(),Pt=null;const g=yi.value,E=bi.value;if(!l.value||!g||!E)return;const X=()=>{Is(-20)},Q=()=>{Is(20)};g.addEventListener("click",X),E.addEventListener("click",Q),Pt=()=>{g.removeEventListener("click",X),E.removeEventListener("click",Q)}}e.watch([l,yi,bi],()=>{Si()},{flush:"post"});function Fs(g){var E;f.value=g,(E=f.value)!=null&&E.composition&&(T.value=new Wb(f.value.composition),x.value=new Ro(f.value.composition),I.value=new jb(f.value.composition));try{S.size&&(S.forEach((X,Q)=>{f.value.setClipFilters(Q,X)}),S.clear(),f.value.composition.computeFrame())}catch{}}function wu(g){g!=null&&g.id&&cs(g.id)}function ku(g){Xd(g),Wt()}async function _u(g){if(!T.value)return;const E=await T.value.addTextOverlay(g);L.value.push({id:E,...g})}async function Eu(g,E){if(!T.value)return;await T.value.updateTextOverlay(g,E);const X=L.value.findIndex(Q=>Q.id===g);X!==-1&&(L.value[X]={...L.value[X],...E})}async function xu(g){T.value&&(await T.value.removeTextOverlay(g),L.value=L.value.filter(E=>E.id!==g))}async function Cu(g){if(!x.value||A.value.length<2)return;const[E,X]=A.value,Q=await x.value.applyTransition(E,X,g);R.value.push({id:Q,...g,name:g.type})}function Su(g){if(!x.value)return;const E=R.value[g];E&&(x.value.removeTransition(E.id),R.value.splice(g,1))}function Vu(g){}async function Nu(g){if(!I.value)return;const E=await I.value.addAudioTrack(g);P.value.push({id:E,...g})}async function Tu(g,E){if(!I.value)return;const X=P.value.findIndex(Q=>Q.id===g);X!==-1&&(P.value[X]={...P.value[X],...E})}async function Mu(g){I.value&&(await I.value.removeAudioTrack(g),P.value=P.value.filter(E=>E.id!==g))}async function Bu(g,E){if(!I.value)return;await I.value.updateVolume(g,E);const X=P.value.find(Q=>Q.id===g);X&&(X.volume=E)}async function Iu(g,E){if(!I.value)return;await I.value.muteTrack(g,E);const X=P.value.find(Q=>Q.id===g);X&&(X.muted=E)}function Fu(g){I.value&&(I.value.setMasterVolume(g),B.value=g)}function $u(g){i("thumbnail-selected",g)}function cn(){Za!==null&&(clearInterval(Za),Za=null)}function Ru(g,E){return E?{...g,output:{...g.output,format:E.format,quality:E.quality}}:g}function sa(g){var E;return g.metadata||(g.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),g.metadata.fit_mode=$.value,(E=a.media)!=null&&E.url&&/^https?:/i.test(a.media.url)?g.metadata.source_url=a.media.url:delete g.metadata.source_url,g}function Je(g,E,X){return Math.min(X,Math.max(E,g))}function Vi(g,E){if(typeof g=="number"&&Number.isFinite(g))return g;if(typeof g=="string"){const X=Number(g);if(Number.isFinite(X))return X}return E}function mt(g,E,X){for(const Q of E)if(Q in g)return Vi(g[Q],X);return X}function Du(g){const E=typeof g.params=="object"&&g.params!==null?g.params:{};switch(g.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Je(mt(E,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Je(mt(E,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Je(mt(E,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Je(mt(E,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Je(mt(E,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const Q=Je(mt(E,["brightness"],1)-1,-1,1),me=Je(mt(E,["contrast"],1),.1,3),se=Je(mt(E,["saturation"],1),0,3);return[{type:"brightness",value:Q},{type:"contrast",value:me},{type:"saturation",value:se}]}default:return[]}}function Au(g){const E=g.timeline[0],X=Array.isArray(E==null?void 0:E.filters)?E.filters:[],Q=[];for(const se of X)if(Q.push(...Du(se)),Q.length>=12)break;const me={...g,filters:Q.slice(0,12)};if(g.timeline.length===1&&E){const se=Math.max(0,Vi(E.sourceIn,0)),le=Vi(E.sourceOut,se);le>se&&(me.trim={start:se,end:le})}return me}function Lu(g){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[g??""]??[1920,1080]}function Uu(g){if(!g||typeof g!="object")return null;const E=g.duration;if(typeof E=="number"&&Number.isFinite(E)&&E>0)return E;if(E&&typeof E=="object"&&"value"in E){const X=E.value;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X}return null}async function $s(g,E,X){var tn,jt,Un,un;const Q=g.timeline[0],me=Q?Math.max(0,Q.sourceIn):0,se=Q?Q.sourceOut:void 0,[le,Le]=Lu((E==null?void 0:E.quality)??((tn=g.output)==null?void 0:tn.quality)),vt=((jt=g.output)==null?void 0:jt.fps)||30;z(!1),w.value=!0,await e.nextTick();try{const it=[200,500,1e3];let ct=!1;for(const Ri of it){await new Promise(im=>setTimeout(im,Ri));const eo=N.value;if(!(!eo||typeof eo.captureFrameAt!="function")&&typeof eo.ensureReadyForCapture=="function"&&(ct=await eo.ensureReadyForCapture(),ct))break}const Zt=N.value;if(!Zt||typeof Zt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!ct)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:la,isWebCodecsSupported:Fi}=await Promise.resolve().then(()=>require("./PixiFrameExporter-CUqM394V.cjs"));if(!Fi())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");en=new AbortController;const Qa={width:le,height:Le,fps:vt,trimStart:me,signal:en.signal};se!==void 0&&(Qa.trimEnd=se),X&&(Qa.onProgress=X);const Ws=zt.value;Ws!==""&&(Qa.sourceUrl=Ws);const em=typeof Zt.duration=="number"&&Zt.duration>0?Zt.duration:((Un=g.source)==null?void 0:Un.duration)??se??0,tm=await la({captureFrameAt:Ri=>Zt.captureFrameAt(Ri),duration:{value:em}},Qa),$i=new File([tm],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),nm=Uu(Zt),am=((un=g.source)==null?void 0:un.duration)??0,om=Math.max(0,(se??nm??am)-me);return{file:$i,recipe:g,meta:{duration:om,width:le,height:Le,format:"mp4",sizeBytes:$i.size,size_bytes:$i.size}}}finally{w.value=!1,en=null}}async function Ou(g,E){var un;cn(),Mt=!1,en=null,Rt.value=null,Ze.value=null,Qt.value=!1,Xe.value=0;const X=sa(g??de()),Q=zs(X),me=Array.isArray(Q.filters)&&Q.filters.length>0,se=Mi(Q);if(!(ee.value||me||se))return lt(),i("video-exported",null),null;const Le=Q.timeline[0],vt=Le?Math.max(0,Le.sourceIn):0,jt=((Le==null?void 0:Le.sourceOut)??((un=Q.source)==null?void 0:un.duration)??Bt.value)-vt,Un=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&jt>a.clientExportThreshold;if(Un){ot.value=!0;try{return await zu(Q),null}catch(it){const ct=it instanceof Error?it.message:"Server render failed";throw Ze.value=ct,i("server-render-failed",ct),it}finally{ot.value=!1}}if(a.maxDuration>0&&jt>a.maxDuration&&!Un){const it=`This video is too long for in-browser export (${Math.round(jt)}s). Server rendering is not available. Try a shorter clip.`;return Ze.value=it,i("video-exported",null),null}ot.value=!0;try{const it=await $s(Q,E,ct=>{Mt||(Xe.value=ct)});return Mt?(Ze.value="Export canceled.",Xe.value=0,i("video-exported",null),null):(lt(),i("recipe-generated",Q),i("video-exported",it),Xe.value=100,Qt.value=!0,it)}catch(it){if(Mt)return Ze.value="Export canceled.",Xe.value=0,i("video-exported",null),null;const ct=it instanceof Error?it.message:"Local WebGL export failed.";throw Ze.value=ct,new Error(`Video export failed: ${ct}`)}finally{ot.value=!1}}function Ka(){return new Yr(a.serverRenderEndpoint??"/api/v1")}async function zu(g){const E=Ka();Ze.value="Starting server render...",Xe.value=0;const X=await E.createRenderJob({source_media_uuid:s.value,recipe:g});Rt.value=X.id,i("server-render-started",X.id),i("export-started",X.id),Ze.value="Rendering on server...";const Q=await E.pollRenderJob(X.id,(se,le)=>{Xe.value=se,le==="processing"&&(Ze.value=`Server rendering: ${se}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);Xe.value=100,Qt.value=!0,Ze.value="Server render complete!",lt(),i("recipe-generated",g);const me={id:Q.id};typeof Q.output_media_id=="string"&&Q.output_media_id!==""&&(me.output_media_id=Q.output_media_id),i("server-render-completed",me)}async function Rs(){if(!ot.value)return;Mt=!0,w.value=!1,en&&(en.abort(),en=null),cn();const g=Rt.value;if(g)try{await Ka().cancelJob(g)}catch(E){const X=E instanceof Error?E.message:"Failed to cancel export";Ze.value=X,ot.value=!1,Rt.value=null;return}ot.value=!1,Xe.value=0,Qt.value=!1,Rt.value=null,Ze.value="Export canceled."}async function Ds(g){cn(),Mt=!1,en=null,Rt.value=null,Ze.value=null,Qt.value=!1,ot.value=!0,Xe.value=0;try{const E=sa(Ru(de(),g));i("recipe-generated",E);const X=s.value.startsWith("temp-"),Q=E.timeline[0],me=Array.isArray(Q==null?void 0:Q.filters)?Q.filters:[],se=!0,le=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(se)try{const ct=await $s(E,g,Fi=>{Mt||(Xe.value=Fi)});if(Mt){Ze.value="Export canceled.",ot.value=!1,Xe.value=0;return}i("video-exported",ct);const Zt=URL.createObjectURL(ct.file),la=document.createElement("a");la.href=Zt,la.download=`edited-video-${Date.now()}.mp4`,la.click(),setTimeout(()=>URL.revokeObjectURL(Zt),100),ot.value=!1,Xe.value=100,Qt.value=!0;return}catch(ct){if(Mt){Ze.value="Export canceled.",ot.value=!1,Xe.value=0;return}if(X||!le)throw ct;Xe.value=0,Ze.value="Local filter export failed, falling back to server render."}const Le={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},vt=(g==null?void 0:g.quality)??E.output.quality,tn=Le[vt]??"high",jt={...Au(E),export:{format:(g==null?void 0:g.format)??E.output.format,quality:tn,resolution:vt,framerate:E.output.fps}},un=await Ka().createJob({source_media_id:s.value,recipe:jt}),it=typeof un.id=="string"?un.id:null;if(!it)throw new Error("Export failed: missing job id");Rt.value=it,i("export-started",it),Ku(it)}catch(E){if(w.value=!1,en=null,Mt){Ze.value="Export canceled.",ot.value=!1,Xe.value=0,Rt.value=null;return}try{const X=sa(de()),Q=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),me=URL.createObjectURL(Q),se=document.createElement("a");se.href=me,se.download=`video-recipe-${Date.now()}.json`,se.click(),setTimeout(()=>URL.revokeObjectURL(me),100)}finally{ot.value=!1,Xe.value=0,Rt.value=null,Ze.value=E instanceof Error?E.message:"Export failed"}}}const Ni=async g=>{await new Promise(E=>{window.setTimeout(E,g)})},Ti=g=>{if(!g||g.width<=0||g.height<=0)return null;try{return g.toDataURL("image/jpeg",.85)}catch{return null}},Pu=g=>{if(!g||typeof g!="object")return null;const X=g.pixiCanvas;if(X&&typeof X=="object"&&"value"in X){const Q=X.value;return Q instanceof HTMLCanvasElement?Q:null}return X instanceof HTMLCanvasElement?X:null},Wu=g=>{if(!g||typeof g!="object")return null;const E=g.duration;if(typeof E=="number"&&Number.isFinite(E))return E;if(E&&typeof E=="object"&&"value"in E){const X=E.value;if(typeof X=="number"&&Number.isFinite(X))return X}return null},ju=g=>{if(!g||typeof g!="object")return null;const X=g.videoElement;if(X&&typeof X=="object"&&"value"in X){const Q=X.value;return Q instanceof HTMLVideoElement?Q:null}return X instanceof HTMLVideoElement?X:null},As=g=>typeof g.params=="object"&&g.params!==null?g.params:{},Zu=g=>{const E=[];for(const X of g){const Q=As(X),me=X.filterId.trim().toLowerCase();if(me==="brightness"){const le=(Je(mt(Q,["value","brightness"],0),-1,1)+1)*100;E.push(`brightness(${le.toFixed(2)}%)`);continue}if(me==="contrast"){const se=Je(mt(Q,["value","contrast"],1),.1,4);E.push(`contrast(${(se*100).toFixed(2)}%)`);continue}if(me==="saturation"||me==="saturate"){const se=Je(mt(Q,["value","saturation"],1),0,4);E.push(`saturate(${(se*100).toFixed(2)}%)`);continue}if(me==="grayscale"){E.push("grayscale(100%)");continue}if(me==="sepia"){E.push("sepia(100%)");continue}if(me==="blur"||me==="gaussian-blur"||me==="kawase-blur"){const se=Je(mt(Q,["value","blur","radius"],0),0,30);se>.01&&E.push(`blur(${se.toFixed(2)}px)`);continue}if(me==="adjustment"){const se=mt(Q,["brightness"],1),le=mt(Q,["contrast"],1),Le=mt(Q,["saturation"],1);Math.abs(se-1)>.01&&E.push(`brightness(${(Je(se,0,5)*100).toFixed(2)}%)`),Math.abs(le-1)>.01&&E.push(`contrast(${(Je(le,.1,5)*100).toFixed(2)}%)`),Math.abs(Le-1)>.01&&E.push(`saturate(${(Je(Le,0,5)*100).toFixed(2)}%)`);continue}if(me==="cinematic"){E.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(me==="dramatic"){E.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(me==="dreamy"){E.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return E.join(" ")},Hu=g=>{const E=g.find(me=>me.filterId.trim().toLowerCase()==="noise");if(!E)return 0;const X=As(E),Q=mt(X,["noise","value","amount","intensity"],.2);return Q<=1?Je(Q,0,1):Je(Q/100,0,1)},Xu=(g,E,X,Q)=>{if(Q<=0)return;const me=g.getImageData(0,0,E,X),se=255*Q;for(let le=0;le<me.data.length;le+=4){const Le=(Math.random()*2-1)*se;me.data[le]=Je(me.data[le]+Le,0,255),me.data[le+1]=Je(me.data[le+1]+Le,0,255),me.data[le+2]=Je(me.data[le+2]+Le,0,255)}g.putImageData(me,0,0)},Ls=async g=>{g.readyState>=2&&g.videoWidth>0&&g.videoHeight>0||await new Promise(E=>{let X=!1,Q=0;const me=()=>{X||(X=!0,g.removeEventListener("loadedmetadata",se),g.removeEventListener("loadeddata",se),g.removeEventListener("canplay",se),window.clearTimeout(Q),E())},se=()=>{me()};g.addEventListener("loadedmetadata",se),g.addEventListener("loadeddata",se),g.addEventListener("canplay",se),Q=window.setTimeout(()=>me(),800),g.play().catch(()=>{})})},Gu=async(g,E)=>{await new Promise(X=>{let Q=!1,me=0;const se=()=>{Q||(Q=!0,g.removeEventListener("seeked",le),window.clearTimeout(me),X())},le=()=>{se()};if(Math.abs(g.currentTime-E)<.016){requestAnimationFrame(()=>se());return}g.addEventListener("seeked",le),me=window.setTimeout(()=>se(),700),g.currentTime=E})},Us=async(g,E)=>{await Ls(g);const X=Math.floor(g.videoWidth),Q=Math.floor(g.videoHeight);if(X<=0||Q<=0)return null;const me=Number.isFinite(g.duration)&&g.duration>0?g.duration:0,se=me>0?Je(E,0,me):0;await Gu(g,se);const le=document.createElement("canvas");le.width=X,le.height=Q;const Le=le.getContext("2d");if(!Le)return null;const vt=Zu(tt.value);vt!==""&&(Le.filter=vt);try{Le.drawImage(g,0,0,X,Q)}catch{return null}const tn=Hu(tt.value);return Xu(Le,X,Q,tn),Ti(le)},Ju=async(g,E)=>{const X=document.createElement("video");X.src=g,X.muted=!0,X.playsInline=!0,X.preload="auto",g.startsWith("blob:")||(X.crossOrigin="anonymous");try{return await Ls(X),await Us(X,E)}catch{return null}finally{X.pause(),X.removeAttribute("src"),X.load()}},Yu=async g=>{const E=N.value,X=Ti(Pu(E));if(X)return X;if(E!=null&&E.captureFrameAt)for(let se=0;se<4;se+=1){const le=Wu(E);if(le!==null&&le<=0&&se<2){await Ni(80);continue}const Le=await Promise.race([E.captureFrameAt(g),Ni(450).then(()=>null)]),vt=Ti(Le);if(vt)return vt;await Ni(80)}const Q=ju(E);if(Q){const se=await Us(Q,g);if(se)return se}const me=mi.value.trim();if(me!==""){const se=await Ju(me,g);if(se)return se}return null},Os=g=>g.map(E=>({...E,params:E.params&&typeof E.params=="object"?{...E.params}:E.params}));function zs(g){const E=Os(tt.value);if(!Mi(g)&&E.length>0&&Array.isArray(g.timeline)&&g.timeline.length>0){const Q=g.timeline[0];Q&&(g.timeline=[{...Q,filters:E},...g.timeline.slice(1)])}return g}const Mi=g=>Array.isArray(g.timeline)?g.timeline.some(E=>Array.isArray(E.filters)&&E.filters.length>0):!1,qu=g=>{if(!g||typeof g!="object")return null;const E=g.posterFrame;if(typeof E!="string")return null;const X=E.trim();return X!==""?X:null};async function Bi(){const g=sa(zs($t())),E=Os(tt.value),X=Mi(g)||E.length>0,Q=qu(a.initialRecipe);if(X){const me=V.value>0?V.value:.1;try{const se=await Yu(me);se?g.posterFrame=se:Q&&(g.posterFrame=Q)}catch{Q&&(g.posterFrame=Q)}}else delete g.posterFrame;return lt(),i("draft-saved",g),g}function Ps(){yt()&&(us(),Wt())}async function Ku(g){cn();const E=Ka();Za=window.setInterval(async()=>{try{if(Mt){cn();return}const X=await E.getJob(g),Q=Number(X.progress??0);if(Xe.value=Number.isFinite(Q)?Q:0,X.status==="completed"||X.status==="failed"||X.status==="cancelled")if(cn(),ot.value=!1,Rt.value=null,X.status==="completed")Xe.value=100,Qt.value=!0,Ze.value=null;else{const me=X.status==="cancelled"||typeof X.error_message=="string"&&/cancel/i.test(X.error_message);Ze.value=me?"Export canceled.":typeof X.error_message=="string"&&X.error_message.trim()!==""?X.error_message:"Export failed"}}catch(X){cn(),ot.value=!1,Rt.value=null,Ze.value=X instanceof Error?X.message:"Failed to check export progress"}},2e3)}function Ii(){const g=sa(de());try{const E=g.timeline??[]}catch{}_.value=g}let yn=null;function Wt(){yn&&clearTimeout(yn),yn=setTimeout(()=>{Ii(),yn=null},200)}e.watch(()=>U.value,Wt,{deep:!0}),e.watch(()=>fe.value,g=>{if(Z.value||!g)return;const E=(g==null?void 0:g.filters)??[];Jd(E)},{immediate:!0}),e.watch(()=>tt.value,g=>{Ge(g),Wt()},{deep:!0}),e.watch(()=>L.value,g=>{at(g),Wt()},{deep:!0}),e.watch(()=>P.value,g=>{const E=g.map(X=>({...X,source:typeof X.source=="string"?X.source:void 0}));Ct(E),Wt()},{deep:!0}),e.watch(()=>V.value,Wt),n({saveDraft:Bi,exportForUpload:Ou}),Ii(),e.onUnmounted(()=>{cn(),Mt=!0,yn&&(clearTimeout(yn),yn=null),f.value&&(f.value.destroy(),f.value=null),T.value=null,x.value=null,I.value=null});function Qu(){bt||!gi.value||(bt=new Vb({filters:ra.value,callbacks:{onApplyFilter:g=>{ia(g.id)},onRemoveFilter:g=>{ms(g)},onUpdateParam:(g,E,X)=>{ks(g,E,X)},onPreviewFilter:g=>{cs(g.id)}}}),bt.mount(gi.value),bt.setActiveFilters(ui.value))}e.watch(ui,g=>{bt==null||bt.setActiveFilters(g)},{deep:!0}),e.watch(ra,g=>{bt==null||bt.setFilters(g)});let dn=null;return e.onMounted(()=>{window.addEventListener("resize",D),window.addEventListener("keydown",Bs);const g=()=>{!An.value||dn||(dn=new ResizeObserver(E=>{E[0]&&(Ja.value=Math.round(E[0].contentRect.width))}),dn.observe(An.value))};g(),dn||e.nextTick(g),l.value&&(Si(),Pt||e.nextTick(Si)),a.media&&Ii(),l.value&&e.nextTick(()=>{Qu()}),e.nextTick(()=>{const E=document.querySelector(".video-editor");E&&E.getBoundingClientRect();const X=document.querySelector(".mobile-layout");X&&X.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",D),window.removeEventListener("keydown",Bs),dn==null||dn.disconnect(),dn=null,Pt==null||Pt(),Pt=null,bt==null||bt.destroy(),bt=null}),(g,E)=>{var X,Q,me,se;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",k2,[e.createElementVNode("div",_2,[e.createElementVNode("div",E2,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ne)}]),onClick:E[0]||(E[0]=(...le)=>e.unref(M)&&e.unref(M)(...le)),"aria-label":e.unref(ne)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(ne)?e.unref(lc):e.unref(dc)},null,8,["icon"])],10,x2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:Ps,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(qn)},null,8,["icon"])])]),e.createElementVNode("div",C2,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Bi,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ee)},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Tr)},null,8,["icon"]),E[13]||(E[13]=e.createElementVNode("span",null,"Save",-1))],8,S2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:E[1]||(E[1]=le=>Ds()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:ot.value||!e.unref(ee)},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Va)},null,8,["icon"])],8,V2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:E[2]||(E[2]=le=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Xn)},null,8,["icon"])])])]),e.createElementVNode("div",N2,[e.withDirectives(e.createVNode(Qs,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!h.value,class:"preview-host-child",source:mi.value,"fallback-duration":Bt.value,filters:hs.value,playhead:vs.value,"is-playing":e.unref(ne),"fit-mode":$.value,active:h.value,onPlayPause:e.unref(M),onFrameUpdate:Es,onDurationChange:Ya},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(yl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:ps.value,"enable-engine":p.value&&fs.value,"fit-mode":$.value,onTimeUpdate:_s,onPlayStateChange:xs,onDurationChange:Ya,onEngineReady:Fs},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),ot.value?(e.openBlock(),e.createElementBlock("div",T2,[e.createElementVNode("div",M2,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Xe.value)+"%",1),e.createElementVNode("div",B2,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Xe.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Rs},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:An,class:"timeline-section"},[e.createElementVNode("div",I2,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:yi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...E[14]||(E[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:bi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...E[15]||(E[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(bl,{playhead:e.unref(V),clips:e.unref(U),"selected-clip-id":((X=e.unref(fe))==null?void 0:X.id)??((Q=e.unref(U)[0])==null?void 0:Q.id)??null,duration:Bt.value,"zoom-level":e.unref(ie),"snap-enabled":sn.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(J),onTrim:e.unref(ke),onSplit:Ms,onClipSelect:wi,onClipMove:e.unref(xt),onClipLongPress:Cs,onSnapStateChange:Ss},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",F2,[e.createElementVNode("div",$2,[e.createElementVNode("span",R2,e.toDisplayString(tu.value),1),e.createElementVNode("span",D2,e.toDisplayString(nu.value),1)]),e.createElementVNode("div",A2,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!Qd.value,onClick:Ns}," Prev Cut ",8,L2),e.createElementVNode("div",U2,[e.createElementVNode("span",O2,"Playhead "+e.toDisplayString(au.value),1),e.createElementVNode("span",z2,"In "+e.toDisplayString(ou.value),1),e.createElementVNode("span",P2,"Out "+e.toDisplayString(iu.value),1),e.createElementVNode("span",W2,"Duration "+e.toDisplayString(ru.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:!eu.value,onClick:Ts}," Next Cut ",8,j2)]),e.createElementVNode("div",Z2,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:sn.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:Vs},e.toDisplayString(sn.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",H2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(Kd,le=>e.createElementVNode("button",{key:le,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(pe)===le}]),"data-testid":`btn-mobile-speed-${String(le).replace(".","-")}`,onClick:Le=>fu(le)},e.toDisplayString(le)+"x ",11,X2)),64))])]),e.createElementVNode("div",G2,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(ht),onClick:ki}," Undo ",8,J2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(Ot),onClick:_i}," Redo ",8,Y2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!pi.value,onClick:qa}," Split ",8,q2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!gs.value,onClick:Ei}," Duplicate ",8,K2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!fi.value,onClick:xi}," Delete ",8,Q2)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:gi,class:"controls-section mobile-controls"},null,512),Xa.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:gn},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:E[3]||(E[3]=e.withModifiers(()=>{},["stop"]))},[E[16]||(E[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",ek,[e.createElementVNode("span",tk,e.toDisplayString(su.value),1),e.createElementVNode("span",nk,e.toDisplayString(lu.value),1)]),e.createElementVNode("div",ak,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(ht),onClick:ki},"Undo",8,ok),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(Ot),onClick:_i},"Redo",8,ik),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!pi.value,onClick:qa},"Split",8,rk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!gs.value,onClick:Ei},"Duplicate",8,sk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!fi.value,onClick:xi},"Delete",8,lk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:gn},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",ck,[e.createElementVNode("div",dk,[e.createElementVNode("div",uk,[e.createElementVNode("div",mk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E[4]||(E[4]=le=>$.value=le),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...E[17]||(E[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,$.value]])])]),e.withDirectives(e.createVNode(Qs,{ref_key:"pixiPreviewDesktopRef",ref:y,"aria-hidden":!h.value,class:"preview-host-child",source:mi.value,"fallback-duration":Bt.value,filters:hs.value,playhead:vs.value,"is-playing":e.unref(ne),"fit-mode":$.value,active:h.value,onPlayPause:e.unref(M),onFrameUpdate:Es,onDurationChange:Ya},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,h.value]]),e.withDirectives(e.createVNode(yl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:ps.value,"enable-engine":p.value&&fs.value,"fit-mode":$.value,onTimeUpdate:_s,onPlayStateChange:xs,onDurationChange:Ya,onEngineReady:Fs},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),g.showThumbnailPicker?(e.openBlock(),e.createBlock(ty,{key:0,"media-uuid":s.value,duration:Bt.value,onSelect:$u},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",pk,[e.createElementVNode("div",fk,[e.createElementVNode("div",hk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.value,le=>(e.openBlock(),e.createElementBlock("button",{key:le.id,class:e.normalizeClass(["tab-btn",{active:d.value===le.id}]),onClick:Le=>d.value=le.id},e.toDisplayString(le.label),11,vk))),128))]),e.createElementVNode("div",gk,[e.withDirectives(e.createElementVNode("div",yk,[e.createVNode(m1,{filters:ra.value,"active-filters":ui.value,"thumbnail-url":qd.value,onApplyFilter:ia,onRemoveFilter:ms,onUpdateParam:ks,onPreviewFilter:wu},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",bk,[e.createVNode(_y,{overlays:L.value,onAddOverlay:_u,onUpdateOverlay:Eu,onRemoveOverlay:xu},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",wk,[e.createVNode(jy,{"selected-clips":A.value,"applied-transitions":R.value,onApplyTransition:Cu,onRemoveTransition:Su,onPreviewTransition:Vu},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",kk,[e.createVNode(Cb,{"audio-layers":P.value,"master-volume":B.value,onAddTrack:Nu,onUpdateTrack:Tu,onRemoveTrack:Mu,onUpdateVolume:Bu,onToggleMute:Iu,onUpdateMasterVolume:Fu},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",_k,[e.unref(ls)?(e.openBlock(),e.createBlock(C1,{key:0,filter:e.unref(ls),"current-frame":e.unref(ae),onUpdateParams:ku},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",Ek,[...E[18]||(E[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",xk,[e.createVNode(O1,{"can-export":e.unref(ee),"is-exporting":ot.value,"export-progress":Xe.value,onExport:Ds,onCancelExport:Rs,onSaveDraft:Bi,onReset:Ps},null,8,["can-export","is-exporting","export-progress"]),Qt.value?(e.openBlock(),e.createElementBlock("div",Ck," Export complete ")):e.createCommentVNode("",!0),Ze.value&&!Qt.value?(e.openBlock(),e.createElementBlock("div",Sk,e.toDisplayString(Ze.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Vk,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:An,class:"timeline-container"},[e.createElementVNode("div",Nk,[e.createElementVNode("label",null,[E[19]||(E[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ie),onInput:E[5]||(E[5]=le=>bu(le))},null,40,Tk)]),e.createElementVNode("span",Mk,e.toDisplayString(Math.round(e.unref(ie)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:sn.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:Vs},e.toDisplayString(sn.value?"Snap On":"Snap Off"),3)]),e.createVNode(bl,{playhead:e.unref(V),clips:e.unref(U),"selected-clip-id":((me=e.unref(fe))==null?void 0:me.id)??((se=e.unref(U)[0])==null?void 0:se.id)??null,duration:Bt.value,"zoom-level":e.unref(ie),"snap-enabled":sn.value,sensitivity:.25,"onUpdate:playhead":e.unref(J),onTrim:e.unref(ke),onSplit:Ms,onClipSelect:wi,onClipMove:e.unref(xt),onClipLongPress:Cs,onSnapStateChange:Ss},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(Vg,{"selected-clip":e.unref(fe),"can-split":pi.value,"can-delete":fi.value,"is-playing":e.unref(ne),"zoom-level":e.unref(ie),"playback-speed":e.unref(pe),onSplit:qa,onDelete:xi,onDuplicate:Ei,onZoomIn:gu,onZoomOut:yu,onZoomChange:Ci,onFitToWindow:vu,onPlayPause:e.unref(M),onFrameForward:e.unref(q),onFrameBackward:e.unref(ue),onSkipToStart:e.unref(ve),onSkipToEnd:e.unref(Te),onSpeedChange:e.unref($e)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),he.value?(e.openBlock(),e.createElementBlock("div",Bk,[e.createElementVNode("div",Ik,[e.createElementVNode("label",Fk,[E[20]||(E[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[6]||(E[6]=le=>Rn.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Rn.value]])]),e.createElementVNode("label",$k,[E[21]||(E[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[7]||(E[7]=le=>Dn.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Dn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(fe),onClick:E[8]||(E[8]=le=>ws("start"))}," Start = Playhead ",8,Rk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(fe),onClick:E[9]||(E[9]=le=>ws("end"))}," End = Playhead ",8,Dk),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(fe),onClick:du}," Apply Trim ",8,Ak)]),e.createElementVNode("div",Lk,[e.createElementVNode("label",Uk,[E[22]||(E[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E[10]||(E[10]=le=>rn.value=le),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ra.value,le=>(e.openBlock(),e.createElementBlock("option",{key:le.id,value:le.id},e.toDisplayString(le.name),9,Ok))),128))],512),[[e.vModelSelect,rn.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(fe)||rn.value==="",onClick:uu}," Apply Filter ",8,zk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(tt).length===0,onClick:mu}," Clear Filters ",8,Pk),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(fe),onClick:E[11]||(E[11]=le=>ia("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(fe),onClick:E[12]||(E[12]=le=>ia("grayscale"))}," QA: Grayscale ",8,jk)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),xr=Ce(Zk,[["__scopeId","data-v-f427827a"]]),Lt=o=>o===null||typeof o!="object"||Array.isArray(o)?null:o,Oe=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},Hk=(o,n)=>{if(n===null)return;const t=Lt(o.source)??{},a=Oe(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=Lt(r[0]);if(c!==null){const d=Oe(c.sourceIn)??0,u=Oe(c.sourceOut)??Oe(c.end)??Oe(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const h=Oe(c.end);h!==null&&h>0&&h<=1&&(c.end=n);const p=Oe(c.timelineEnd);p!==null&&p>0&&p<=1&&(c.timelineEnd=n)}}}const s=Oe(o.trimEnd)??Oe(o.trim_end);s!==null&&s>0&&s<=1&&(o.trimEnd=n);const l=Lt(o.trim);if(l!==null){const c=Oe(l.end);c!==null&&c>0&&c<=1&&(l.end=n,o.trim=l)}},Xk=(o,n)=>{if(!o)return!1;const t=Lt(o);if(t===null)return!1;const a=Lt(t.trim),i=Lt(t.source),s=Oe(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=Oe(t.trimStart)??Oe(t.trim_start)??Oe(a==null?void 0:a.start),m=Oe(t.trimEnd)??Oe(t.trim_end)??Oe(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=Oe(p.sourceIn),y=Oe(p.sourceOut);v!==null&&v>0&&(d=!0),y!==null&&s!==void 0&&y<s&&(d=!0)}}let h=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const v=Oe(p.speed);h=v!==null&&v!==1}}return l||c||d||h},wd=o=>{if(!o)return!1;const n=Lt(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)},Gk=(o,n={})=>{var h,p;const t=JSON.parse(JSON.stringify(o)),a=Array.isArray(t.timeline)?t.timeline:[],i=a.length>0?Lt(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=Oe(i.sourceIn),y=Oe(i.sourceOut);v!==null&&t.trimStart===void 0&&(t.trimStart=v),y!==null&&t.trimEnd===void 0&&(t.trimEnd=y)}const l=Lt(t.trim);if(t.trimStart===void 0){const v=Oe(l==null?void 0:l.start);v!==null&&(t.trimStart=v)}if(t.trimEnd===void 0){const v=Oe(l==null?void 0:l.end);v!==null&&(t.trimEnd=v)}const c=Lt(t.source),d=Oe(t.width)??Oe(c==null?void 0:c.original_width)??Oe((h=n.exportMeta)==null?void 0:h.width);d!==null&&(t.width=d);const u=Oe(t.height)??Oe(c==null?void 0:c.original_height)??Oe((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Lt(t.output);return t.fps=Oe(t.fps)??Oe(m==null?void 0:m.fps)??30,Hk(t,n.mediaDuration??null),t},Jk={key:0},Yk=["data-testid"],qk={class:"ve-mobile-header"},Kk=["data-testid"],Qk={class:"ve-mobile-title"},e_=["data-testid","disabled"],t_={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},n_={class:"ve-body"},a_=["data-testid"],o_=["aria-label"],i_={class:"ve-header"},r_={class:"ve-title"},s_=["data-testid"],l_={class:"ve-body"},c_={class:"ve-footer"},d_=["data-testid"],u_=["data-testid","disabled"],m_=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(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()}`,y=e.computed(()=>{var B;const A=(B=a.featureFlags)==null?void 0:B.export;return typeof A=="boolean"?A:a.workflowMode==="full"}),w=e.computed(()=>typeof a.mediaUuid=="string"&&a.mediaUuid.trim()!==""?a.mediaUuid.trim():a.media&&a.media.uuid.trim()!==""?a.media.uuid.trim():v),N=e.computed(()=>{const A={showThumbnailPicker:a.showThumbnailPicker,workflowMode:a.workflowMode,clientExportThreshold:a.clientExportThreshold,maxDuration:a.maxDuration,serverRenderEndpoint:a.serverRenderEndpoint};return a.featureFlags!==void 0&&(A.featureFlags=a.featureFlags),a.initialRecipe!==void 0&&(A.initialRecipe=a.initialRecipe),a.media!==void 0&&(A.media=a.media),A}),C=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",C)}),e.onUnmounted(()=>{window.removeEventListener("resize",C)}),e.onErrorCaptured(()=>(h.value=!0,!1));const b=A=>{const B=Array.isArray(A.timeline)?A.timeline:[];if(B.length===0)return 0;let D=0;for(const k of B){const F=Number(k.sourceIn),H=Number(k.sourceOut),j=Number(k.speed??1),te=Number.isFinite(j)&&j>0?j:1;if(Number.isFinite(F)&&Number.isFinite(H)&&H>F){D+=(H-F)/te;continue}const he=Number(k.timelineStart),ge=Number(k.timelineEnd);Number.isFinite(he)&&Number.isFinite(ge)&&ge>he&&(D+=ge-he)}return D},f=(A,B,D)=>{let k=null;const F=new Promise((H,j)=>{k=setTimeout(()=>j(new Error(`${D} timed out after ${B}ms`)),B)});return Promise.race([A,F]).finally(()=>{k!==null&&clearTimeout(k)})},_=()=>{var F;const D=(F=a.media)==null?void 0:F.duration;if(typeof D!="number"||!Number.isFinite(D)||D<=0)return 12e3;const k=Math.round(D*1e3);return Math.min(45e3,Math.max(12e3,k))},$=()=>{i("close"),i("update:open",!1)},T=()=>{m.value=!1,$()},x=A=>{i("recipe-generated",A)},I=A=>{i("export-started",A),i("save-started",A)},Z=A=>{i("video-exported",A)},S=A=>{i("thumbnail-selected",A)},L=(A,B,D)=>{i("save-recipe",A);const k={recipe:A,exportPayload:B};D!==void 0&&(k.toastDescription=D),i("save-complete",k),$()},R=A=>{m.value||(i("draft-saved",A),L(A,null))},P=async()=>{var A;if(!m.value){if(h.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),$();return}m.value=!0;try{const B=await f(p.value.saveDraft(),_(),"saveDraft");let D=null,k=!1,F;const H=b(B),j=H>0?H:((A=a.media)==null?void 0:A.duration)??0;if(y.value&&j>0&&j<=a.clientExportThreshold&&typeof p.value.exportForUpload=="function"){k=!0;const he=Math.min(9e4,Math.max(15e3,a.clientExportThreshold*2e3));try{D=await f(p.value.exportForUpload(B),he,"exportForUpload")}catch{D=null}}if(wd(B)&&D===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}k&&D===null&&(F="Video edits saved. Final render will happen when you share."),L(B,D,F)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),$()}finally{m.value=!1}}};return n({saveDraft:P}),(A,B)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",Jk,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",qk,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:T},e.toDisplayString(c.value),9,Kk),e.createElementVNode("h2",Qk,e.toDisplayString(A.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:P},e.toDisplayString(d.value),9,e_)):(e.openBlock(),e.createElementBlock("span",t_))]),e.createElementVNode("section",n_,[e.createVNode(xr,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":w.value},N.value,{onClose:T,onDraftSaved:R,onExportStarted:I,onRecipeGenerated:x,onThumbnailSelected:S,onVideoExported:Z}),null,16,["media-uuid"])])],8,Yk)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(T,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":A.title,"aria-modal":"true"},[e.createElementVNode("header",i_,[e.createElementVNode("h2",r_,e.toDisplayString(A.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:T}," ✕ ",8,s_)]),e.createElementVNode("section",l_,[e.createVNode(xr,e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":w.value},N.value,{onClose:T,onDraftSaved:R,onExportStarted:I,onRecipeGenerated:x,onThumbnailSelected:S,onVideoExported:Z}),null,16,["media-uuid"])]),e.createElementVNode("footer",c_,[e.renderSlot(A.$slots,"footer",{close:T,isSaving:m.value,save:P},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:T},e.toDisplayString(c.value),9,d_),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:P},e.toDisplayString(d.value),9,u_)):e.createCommentVNode("",!0)],!0)])],8,o_)],8,a_))])):e.createCommentVNode("",!0)]))}}),p_=Ce(m_,[["__scopeId","data-v-0ff40919"]]),f_={class:"video-editor-modal"},h_={class:"video-preview-container"},v_=["src"],g_={class:"video-overlay-controls"},y_=["aria-label"],b_={class:"time-display"},w_={class:"timeline-container"},k_={class:"clip-name"},__={class:"timeline-time-labels"},E_={class:"tool-tabs"},x_=["onClick"],C_={class:"tool-panel"},S_={key:0,class:"trim-panel"},V_={class:"trim-controls"},N_={key:1,class:"filters-panel"},T_={class:"filter-grid"},M_=["onClick"],B_={key:2,class:"text-panel"},I_={key:3,class:"transitions-panel"},F_={class:"transition-grid"},$_=["onClick"],R_={class:"action-buttons"},D_=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),y=e.ref(""),w=[{id:"trim",label:"Trim",icon:rc},{id:"filters",label:"Filters",icon:Hm},{id:"text",label:"Text",icon:uc},{id:"transitions",label:"Transitions",icon:ep}],N=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],C=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],b=e.ref();e.onMounted(()=>{var k,F;(k=t.media)!=null&&k.url?r.value=t.media.url:(F=t.media)!=null&&F.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 $(){s.value=!1}function T(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function x(k){if(!k||isNaN(k))return"00:00";const F=Math.floor(k/60),H=Math.floor(k%60);return`${F.toString().padStart(2,"0")}:${H.toString().padStart(2,"0")}`}function I(k){if(!i.value||!b.value)return;const F=b.value.getBoundingClientRect(),te=(k.clientX-F.left)/F.width*c.value;i.value.currentTime=Math.max(0,Math.min(te,c.value))}function Z(){u.value=l.value}function S(){m.value=l.value}function L(){u.value=0,m.value=c.value}function R(k){h.value=k;const F=j=>{if(!h.value||!b.value)return;const te=b.value.getBoundingClientRect(),ae=(j.clientX-te.left)/te.width*c.value;h.value==="start"?u.value=Math.max(0,Math.min(ae,m.value-1)):m.value=Math.max(u.value+1,Math.min(ae,c.value))},H=()=>{h.value=null,document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H)}function P(k){if(v.value=k,!i.value)return;const F={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=F[k]||"none"}function A(){}function B(k){}function D(){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:y.value?[{content:y.value}]:[],duration:m.value-u.value};a("save",k)}return(k,F)=>(e.openBlock(),e.createElementBlock("div",f_,[e.createElementVNode("div",h_,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:f,onTimeupdate:_,onEnded:$,controls:""},null,40,v_),e.createElementVNode("div",g_,[e.createElementVNode("button",{class:"play-pause-btn",onClick:T,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(O.IonIcon),{icon:s.value?e.unref(op):e.unref(lp)},null,8,["icon"])],8,y_),e.createElementVNode("div",b_,e.toDisplayString(x(l.value))+" / "+e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",w_,[e.createElementVNode("div",{class:"timeline-track",onClick:I,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",k_,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:F[0]||(F[0]=H=>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:F[1]||(F[1]=H=>R("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",__,[e.createElementVNode("span",null,e.toDisplayString(x(0)),1),e.createElementVNode("span",null,e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",E_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(w,H=>e.createElementVNode("button",{key:H.id,class:e.normalizeClass(["tool-tab",{active:p.value===H.id}]),onClick:j=>p.value=H.id},[e.createVNode(e.unref(O.IonIcon),{icon:H.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(H.label),1)],10,x_)),64))]),e.createElementVNode("div",C_,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",S_,[F[7]||(F[7]=e.createElementVNode("h3",null,"Trim Video",-1)),F[8]||(F[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",V_,[e.createElementVNode("button",{class:"btn-trim",onClick:Z},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Gs)},null,8,["icon"]),F[4]||(F[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:S},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Gs)},null,8,["icon"]),F[5]||(F[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:L},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),F[6]||(F[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",N_,[F[9]||(F[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",T_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(N,H=>e.createElementVNode("button",{key:H.id,class:e.normalizeClass(["filter-option",{active:v.value===H.id}]),onClick:j=>P(H.id)},e.toDisplayString(H.name),11,M_)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",B_,[F[10]||(F[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":F[2]||(F[2]=H=>y.value=H),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,y.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:A},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",I_,[F[11]||(F[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",F_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(C,H=>e.createElementVNode("button",{key:H.id,class:"transition-option",onClick:j=>(H.id,void 0)},e.toDisplayString(H.name),9,$_)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",R_,[e.createElementVNode("button",{class:"btn-cancel",onClick:F[3]||(F[3]=H=>k.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:D},"SAVE")])]))}}),A_=Ce(D_,[["__scopeId","data-v-b933f33b"]]),L_={class:"time-label"},U_=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",L_,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),O_=Ce(U_,[["__scopeId","data-v-0ef9c910"]]),z_=["data-track-index"],P_={class:"track-header"},W_={class:"track-label"},j_={class:"track-controls"},Z_=["data-testid","aria-label"],H_=["data-testid","onMousedown","onClick"],X_={class:"clip-content"},G_={class:"clip-name"},J_={key:0,class:"clip-thumbnail"},Y_=["src","alt"],q_=["onMousedown","aria-label"],K_=["onMousedown","aria-label"],Q_=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 N=w.timelineEnd-w.timelineStart,C=w.timelineStart/t.duration*100,b=N/t.duration*100;return{left:`${C}%`,width:`${b}%`,backgroundColor:u(w)}}function u(w){const N=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],C=parseInt(w.id.replace(/\D/g,""))%N.length;return N[C]}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,N){if(l.value)return;s.value=!0;const C=N.clientX,b=w.timelineStart,f=$=>{if(!s.value)return;const T=$.clientX-C,x=parseFloat(c.value.width),I=T/(t.zoom*100)*(t.duration/x),Z=Math.max(0,b+I);a("clip-move",w.id,Z)},_=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",_)}function y(w,N,C){l.value=N;const b=C.clientX,f=w.sourceIn,_=w.sourceOut,$=x=>{if(!l.value)return;const I=x.clientX-b,Z=parseFloat(c.value.width),S=I/(t.zoom*100)*(t.duration/Z);if(l.value==="start"){const L=Math.max(0,f+S);a("clip-trim",w.id,L,_)}else{const L=Math.max(f+1,_+S);a("clip-trim",w.id,f,L)}},T=()=>{l.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",T)}return(w,N)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":w.trackIndex},[e.createElementVNode("div",P_,[e.createElementVNode("span",W_,"Track "+e.toDisplayString(w.trackIndex+1),1),e.createElementVNode("div",j_,[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(O.IonIcon),{icon:r.value?e.unref(Ep):e.unref(kp)},null,8,["icon"])],8,Z_)):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,C=>(e.openBlock(),e.createElementBlock("div",{key:C.id,class:e.normalizeClass(["timeline-clip",{selected:C.id===i.value}]),style:e.normalizeStyle(d(C)),"data-testid":`clip-${C.id}`,onMousedown:b=>v(C,b),onClick:b=>h(C)},[e.createElementVNode("div",X_,[e.createElementVNode("span",G_,e.toDisplayString(m(C)),1),C.thumbnail?(e.openBlock(),e.createElementBlock("div",J_,[e.createElementVNode("img",{src:C.thumbnail,alt:m(C)},null,8,Y_)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(b=>y(C,"start",b),["stop"]),"aria-label":`Trim start of ${m(C)}`},null,40,q_),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(b=>y(C,"end",b),["stop"]),"aria-label":`Trim end of ${m(C)}`},null,40,K_)],46,H_))),128))],4)],8,z_))}}),eE=Ce(Q_,[["__scopeId","data-v-48e480d2"]]),tE={class:"video-timeline"},nE={class:"timeline-tracks"},aE=["aria-label","aria-valuenow","aria-valuemax"],oE={class:"timeline-controls"},iE={class:"zoom-level"},rE=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 y(){i.value=Math.min(i.value*1.2,5)}function w(){i.value=Math.max(i.value/1.2,.5)}function N(){s.value=!0;const b=_=>{if(!s.value||!l.value)return;const $=l.value.getBoundingClientRect(),I=Math.max(0,Math.min(_.clientX-$.left,$.width))/$.width*t.duration;a("seek",I)},f=()=>{s.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",f)}function C(b){let f=t.currentTime;switch(b.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}b.preventDefault(),a("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(b,f)=>(e.openBlock(),e.createElementBlock("div",tE,[e.createVNode(O_,{duration:b.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",nE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(_,$)=>(e.openBlock(),e.createBlock(eE,{key:`track-${$}`,"data-testid":`track-${$}`,clips:u($),"track-index":$,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:N,"data-testid":"playhead","aria-label":`Playhead at ${m(b.currentTime)}`,role:"slider","aria-valuenow":b.currentTime,"aria-valuemax":b.duration,tabindex:"0",onKeydown:C},null,44,aE),e.createElementVNode("div",oE,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:y},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Vr)},null,8,["icon"])]),e.createElementVNode("span",iE,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(O.IonIcon),{icon:e.unref(fp)},null,8,["icon"])])])]))}}),sE=Ce(rE,[["__scopeId","data-v-001df415"]]),lE={class:"video-filters-panel"},cE={class:"filter-controls"},dE=["for"],uE={class:"filter-slider-group"},mE=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],pE={class:"filter-value"},fE={class:"filter-actions"},hE={key:0,class:"filter-presets"},vE={class:"preset-list"},gE=["data-testid","aria-label","onClick"],yE=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",lE,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",cE,[(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,dE),e.createElementVNode("div",uE,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":y=>i[v.type]=y,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:y=>c(v.type)},null,40,mE),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",pE,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",fE,[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(O.IonIcon),{icon:e.unref(qn)},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(O.IonIcon),{icon:e.unref(Tr)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",hE,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",vE,[(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:y=>m(v)},e.toDisplayString(v.name),9,gE))),128))])])):e.createCommentVNode("",!0)]))}}),bE=Ce(yE,[["__scopeId","data-v-5ad2ac63"]]),wE={class:"video-text-panel"},kE={class:"text-input-group"},_E={class:"text-options"},EE={class:"option-row"},xE={class:"option-row"},CE={class:"option-row"},SE={class:"option-row"},VE={class:"checkbox-label"},NE={class:"option-row"},TE={class:"text-overlay-list"},ME={key:0,class:"empty-state"},BE=["data-testid"],IE={class:"overlay-preview"},FE={class:"overlay-controls"},$E=["data-testid","aria-label","onClick"],RE=["data-testid","aria-label","onClick"],DE=["data-testid","aria-label","onClick"],AE=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",wE,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",kE,[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(O.IonIcon),{icon:e.unref(Vr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",_E,[e.createElementVNode("div",EE,[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",xE,[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",CE,[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",SE,[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",VE,[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",NE,[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",TE,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",ME," 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",IE,[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",FE,[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(O.IonIcon),{icon:e.unref(Jm)},null,8,["icon"])],8,$E),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(O.IonIcon),{icon:e.unref(Gm)},null,8,["icon"])],8,RE),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(O.IonIcon),{icon:e.unref(gp)},null,8,["icon"])],8,DE)])],8,BE))),128))])]))}}),LE=Ce(AE,[["__scopeId","data-v-4d240e1e"]]),UE={class:"video-tools-panel"},OE={class:"tool-tabs"},zE=["data-testid","aria-label","aria-selected","onClick"],PE={class:"tool-content"},WE={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},jE={class:"trim-actions"},ZE={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},HE={class:"transition-types"},XE=["data-testid","aria-label","onClick"],GE={class:"transition-preview"},JE=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:rc},{id:"filters",name:"Filters",icon:fn},{id:"text",name:"Text",icon:uc},{id:"transitions",name:"Transitions",icon:qs}],t=[{id:"fade",name:"Fade",icon:Ui},{id:"slide-left",name:"Slide Left",icon:zm},{id:"slide-right",name:"Slide Right",icon:Pm},{id:"dissolve",name:"Dissolve",icon:Ui},{id:"wipe",name:"Wipe",icon:qs},{id:"zoom",name:"Zoom",icon:Ui}];return(a,i)=>(e.openBlock(),e.createElementBlock("div",UE,[e.createElementVNode("div",OE,[(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(O.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,zE)),64))]),e.createElementVNode("div",PE,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",WE,[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",jE,[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(O.IonIcon),{icon:e.unref(Js)},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(O.IonIcon),{icon:e.unref(Js)},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(O.IonIcon),{icon:e.unref(Xn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(bE,{key:1,onFilterChange:i[3]||(i[3]=r=>a.$emit("filter-change",r))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(LE,{key:2,onTextAdd:i[4]||(i[4]=r=>a.$emit("text-add",r))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",ZE,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",HE,[(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",GE,[e.createVNode(e.unref(O.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,XE)),64))])])):e.createCommentVNode("",!0)])]))}}),YE=Ce(JE,[["__scopeId","data-v-fc135306"]]),qE={class:"video-export-panel"},KE={class:"export-presets"},QE=["value"],ex={key:0,class:"preset-details"},tx={class:"detail-row"},nx={class:"detail-row"},ax={class:"detail-row"},ox={class:"advanced-options"},ix={class:"options-content"},rx={class:"option-group"},sx={class:"option-group"},lx={class:"option-group"},cx=["disabled"],dx={key:1,class:"export-progress"},ux={class:"progress-message"},mx={class:"progress-bar"},px=["aria-valuenow"],fx={class:"progress-percentage"},hx=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",qE,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",KE,[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,QE))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",ex,[e.createElementVNode("div",tx,[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",nx,[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",ax,[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",ox,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",ix,[e.createElementVNode("div",rx,[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",sx,[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",lx,[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(O.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Va)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,cx),d.isExporting?(e.openBlock(),e.createElementBlock("div",dx,[e.createElementVNode("div",ux,e.toDisplayString(l.value),1),e.createElementVNode("div",mx,[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,px)]),e.createElementVNode("div",fx,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),vx=Ce(hx,[["__scopeId","data-v-5caf8fe6"]]),gx=["data-testid"],yx={class:"progress-header"},bx={class:"file-info"},wx={class:"file-details"},kx={class:"file-name"},_x={class:"file-meta"},Ex={class:"file-size"},xx={key:0,class:"separator"},Cx={key:1,class:"upload-speed"},Sx={key:2,class:"separator"},Vx={key:3,class:"time-remaining"},Nx={class:"progress-actions"},Tx={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},Mx={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},Bx={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},Ix=["aria-valuenow","aria-label"],Fx={class:"progress-bar"},$x={class:"progress-percent"},Rx={key:1,class:"error-message","data-testid":"video-upload-error"},Dx={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},Ax=["src","alt"],Lx={key:0,class:"video-duration"},Ux=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(()=>mc),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,y=Math.floor(Math.log(h)/Math.log(v));return`${(h/Math.pow(v,y)).toFixed(1)} ${p[y]}`}function u(h){if(h===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],v=1024,y=Math.floor(Math.log(h)/Math.log(v));return`${(h/Math.pow(v,y)).toFixed(1)} ${p[y]}`}function m(h){const p=Math.floor(h/3600),v=Math.floor(h%3600/60),y=Math.floor(h%60);return p>0?`${p}:${v.toString().padStart(2,"0")}:${y.toString().padStart(2,"0")}`:`${v}:${y.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",yx,[e.createElementVNode("div",bx,[e.createVNode(e.unref(O.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",wx,[e.createElementVNode("h4",kx,e.toDisplayString(h.upload.filename),1),e.createElementVNode("p",_x,[e.createElementVNode("span",Ex,e.toDisplayString(d(h.upload.bytesTotal||0)),1),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",xx,"•")):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Cx,e.toDisplayString(u(h.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Sx,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Vx,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Nx,[h.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",Tx,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(oc)},null,8,["icon"])])):h.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",Mx,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Om),"aria-hidden":"true"},null,8,["icon"])])):h.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",Bx,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),h.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(O.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(O.IonIcon),{icon:e.unref(Xn),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(O.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(O.IonIcon),{icon:e.unref(qn),slot:"icon-only"},null,8,["icon"])]),_:1})):h.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(O.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(O.IonIcon),{icon:e.unref(Xn),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":h.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",Fx,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:h.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",$x,e.toDisplayString(Math.round(r.value))+"%",1)],8,Ix)):e.createCommentVNode("",!0),h.upload.error?(e.openBlock(),e.createElementBlock("div",Rx,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(xp)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(h.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",Dx,[e.createElementVNode("img",{src:l.value,alt:h.upload.filename},null,8,Ax),c.value?(e.openBlock(),e.createElementBlock("div",Lx,e.toDisplayString(m(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,gx))}}),Ox=Ce(Ux,[["__scopeId","data-v-9eacbf91"]]),Yi=4,zx=500,Px=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function li(o){return typeof o=="object"&&o!==null}function Dl(o){return li(o)?typeof o.upload_url=="string"&&typeof o.upload_id=="string"&&typeof o.media_uuid=="string"&&typeof o.expires_at=="string":!1}function Wx(o){if(Dl(o))return o;if(li(o)&&Dl(o.data))return o.data;throw new Error("Invalid upload response from backend")}function Al(o){return li(o)?typeof o.uuid=="string"&&typeof o.processing_status=="string":!1}function jx(o){if(Al(o))return o;if(li(o)&&Al(o.data))return o.data;throw new Error("Invalid media response from backend")}function so(o){return o?{...o}:{}}function Ll(o,n="PUT"){return typeof o.method=="string"&&o.method.trim()!==""?o.method.trim().toUpperCase():n}function Zx(o){return o.resumable===!0?!0:/tusupload/i.test(o.upload_url)}function Hx(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 Xx(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} ${Hx(i)}`).join(",")}function lo(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 Gx(o,n){return o instanceof Error?o:new Error(n)}function Jx(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 Ul(o){const n=Math.max(0,o-1),t=zx*Math.pow(2,n);return Math.min(5e3,t)}function Ol(o){return new Promise(n=>{window.setTimeout(n,o)})}async function zl(o,n){for(let t=1;t<=Yi;t+=1)try{const a=await n();if(a.ok||!Px.has(a.status)||t>=Yi)return a;await Ol(Ul(t))}catch(a){if(!Jx(a)||t>=Yi)throw a;await Ol(Ul(t))}throw new Error(`${o} failed after retry attempts`)}function Yx(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 S=Array.from(n.value.values());return S.length===0?0:S.reduce((R,P)=>R+P.progress,0)/S.length});function d(S){a.value=S}function u(){}async function m(S){var R;const L=S.filter(P=>h(P));if(L.length!==0&&((R=o.onFilesSelected)==null||R.call(o,L),o.autoUpload!==!1))for(const P of L)await p(P)}function h(S){return!(o.maxFileSize&&S.size>o.maxFileSize||o.allowedFormats&&o.allowedFormats.length>0&&!o.allowedFormats.includes(S.type))}async function p(S){var P,A,B;const L=Z(S);if(n.value.has(L)){const D=n.value.get(L);if((D==null?void 0:D.status)==="uploading")return}const R={id:L,file:S,filename:S.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:S.size,bytesUploaded:0};n.value.set(R.id,R),t.value.add(R.id);try{R.status="uploading",(P=o.onUploadStart)==null||P.call(o,R);const D=await v(S);o.resumable===!0||D.resumable===!0?await w(R,D):await y(R,D),R.status="processing",R.progress=100;const F=await _(D.media_uuid);R.status="completed",R.media=F,(A=o.onUploadComplete)==null||A.call(o,F)}catch(D){if(R.status!=="cancelled"){const k=Gx(D,"Upload failed");R.status="error",R.error=k.message,(B=o.onUploadError)==null||B.call(o,k,R)}}finally{t.value.delete(R.id),i.delete(R.id),r.delete(R.id)}}async function v(S){if(!a.value)throw new Error("API client not configured");const L={collection:o.collection||"videos",filename:S.name,size:S.size,mime_type:S.type,...o.ownerUuid!==void 0?{ownerUuid:o.ownerUuid}:{},...o.ownerType!==void 0?{ownerType:o.ownerType}:{}},R=await a.value.post("/api/v1/video/upload",L);return Wx(R)}async function y(S,L){const R=new XMLHttpRequest,P=Ll(L),A=so(L.headers);return new Promise((B,D)=>{R.upload.addEventListener("progress",k=>{var F;k.lengthComputable&&(lo(S,k.loaded),(F=o.onUploadProgress)==null||F.call(o,S))}),R.addEventListener("load",()=>{i.delete(S.id),R.status>=200&&R.status<300?B():D(new Error(`Upload failed with status ${R.status}`))}),R.addEventListener("error",()=>{i.delete(S.id),D(new Error("Upload failed"))}),R.addEventListener("abort",()=>{i.delete(S.id),D(new Error("Upload cancelled"))}),R.open(P,L.upload_url),Object.entries(A).forEach(([k,F])=>{R.setRequestHeader(k,F)}),!Object.keys(A).some(k=>k.toLowerCase()==="content-type")&&S.file.type&&R.setRequestHeader("Content-Type",S.file.type),i.set(S.id,R),R.send(S.file)})}async function w(S,L){var D;if(Zx(L)){await N(S,L);return}const R=o.chunkSize||5*1024*1024,P=C(S.file,R),A=new AbortController;r.set(S.id,A);const B=await f(L.upload_id);B&&(P.forEach(k=>{k.end<=B.bytesUploaded&&(k.uploaded=!0)}),lo(S,B.bytesUploaded));for(const k of P)k.uploaded||(await b(S,L,k,A),lo(S,k.end),(D=o.onUploadProgress)==null||D.call(o,S))}async function N(S,L){var H;const R=new AbortController;r.set(S.id,R);const P={...so(L.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(S.file.size),"Upload-Metadata":Xx(S,L)},A=await zl("Resumable upload initialization",()=>fetch(L.upload_url,{method:"POST",headers:P,signal:R.signal}));if(!A.ok)throw new Error(`Failed to initialize resumable upload: ${A.status}`);const B=A.headers.get("Location");if(!B)throw new Error("Resumable upload endpoint did not return upload location");const D=new URL(B,L.upload_url).toString(),k=o.chunkSize||5*1024*1024;let F=0;for(;F<S.file.size;){const j=Math.min(F+k,S.file.size),te=S.file.slice(F,j),he={...so(L.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(F),"Content-Type":"application/offset+octet-stream"},ge=await zl("Resumable chunk upload",()=>fetch(D,{method:"PATCH",headers:he,body:te,signal:R.signal}));if(ge.status===409){const V=Number(ge.headers.get("Upload-Offset")??"-1");if(Number.isFinite(V)&&V>=0){F=V;continue}}if(!ge.ok)throw new Error(`Resumable chunk upload failed: ${ge.status}`);const ae=Number(ge.headers.get("Upload-Offset")??String(j));F=Number.isFinite(ae)&&ae>F?ae:j,lo(S,F),(H=o.onUploadProgress)==null||H.call(o,S)}}function C(S,L){const R=[];let P=0,A=0;for(;P<S.size;){const B=Math.min(P+L,S.size);R.push({start:P,end:B,blob:S.slice(P,B),index:A,uploaded:!1}),P=B,A++}return R}async function b(S,L,R,P){const A={...so(L.headers),"Content-Range":`bytes ${R.start}-${R.end-1}/${S.file.size}`,"Content-Type":S.file.type||"application/octet-stream"},B=await fetch(L.upload_url,{method:Ll(L),headers:A,body:R.blob,signal:P.signal});if(!B.ok)throw new Error(`Chunk upload failed: ${B.status}`);R.uploaded=!0}async function f(S){return null}async function _(S){if(!a.value)throw new Error("API client not configured");const L=60;let R=0;for(;R<L;){const P=await a.value.get(`/api/v1/video/${S}`),A=jx(P),B=String(A.processing_status);if(B==="ready")return A;if(B==="failed"||B==="error")throw new Error("Video processing failed");await new Promise(D=>{window.setTimeout(D,5e3)}),R++}throw new Error("Video processing timeout")}function $(S){const L=n.value.get(S);if(!L)return;const R=i.get(S);R&&(R.abort(),i.delete(S));const P=r.get(S);P&&(P.abort(),r.delete(S)),L.status="cancelled",L.error="Upload cancelled",t.value.delete(S)}async function T(S){const L=n.value.get(S);L&&(L.status="pending",L.error="",L.progress=0,L.bytesUploaded=0,await p(L.file))}function x(S){n.value.delete(S),t.value.delete(S),i.delete(S),r.delete(S)}function I(){Array.from(n.value.entries()).forEach(([S,L])=>{L.status==="completed"&&n.value.delete(S)})}function Z(S){return`${S.name}-${S.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:m,validateFile:h,startUpload:p,cancelUpload:$,retryUpload:T,removeUpload:x,clearCompleted:I,setApiClient:d}}const qx=["accept","multiple"],Kx={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},Qx=["onKeydown"],eC={key:1,class:"upload-list","data-testid":"video-upload-list"},tC={class:"drag-content"},nC=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}=Yx({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 y(){i.value&&i.value.click()}function w(f){const _=f.target,$=Array.from(_.files||[]);$.length>0&&(c($),_.value="")}function N(f){var T;f.preventDefault(),r.value=!1;const $=Array.from(((T=f.dataTransfer)==null?void 0:T.files)||[]).filter(x=>x.type.startsWith("video/"));$.length>0&&c($)}function C(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",C),document.addEventListener("dragleave",b),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",C),document.removeEventListener("dragleave",b),document.removeEventListener("drop",f=>f.preventDefault())}),(f,_)=>(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,qx),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",Kx,[e.renderSlot(f.$slots,"trigger",{open:y},()=>[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:y,onKeydown:[e.withKeys(y,["enter"]),e.withKeys(e.withModifiers(y,["prevent"]),["space"])]},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(mc),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(O.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Vr),slot:"start","aria-hidden":"true"},null,8,["icon"]),_[2]||(_[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,Qx)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",eC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),$=>(e.openBlock(),e.createBlock(Ox,{key:$.id,upload:$,onCancel:T=>e.unref(d)($.id),onRetry:T=>e.unref(u)($.id),onRemove:T=>e.unref(m)($.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:N,onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:_[1]||(_[1]=$=>r.value=!1)},[e.createElementVNode("div",tC,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Va),"aria-hidden":"true"},null,8,["icon"]),_[3]||(_[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),aC=Ce(nC,[["__scopeId","data-v-ea7587f7"]]),oC=["aria-valuenow","aria-valuemax","aria-label"],iC={class:"progress-bar"},rC={class:"time-display","data-testid":"video-time-display"},sC={class:"current-time"},lC={class:"duration"},cC={class:"control-buttons"},dC={class:"controls-left"},uC=["aria-label"],mC={class:"controls-center"},pC={key:0,class:"volume-controls"},fC=["aria-label"],hC=["value"],vC={class:"controls-right"},gC={key:0,class:"quality-selector"},yC=["aria-expanded"],bC={class:"quality-label"},wC={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},kC=["data-testid","aria-label","onClick"],_C=["aria-label"],EC=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=O.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),$=t.buffered.end(f);if(t.currentTime>=_&&t.currentTime<=$)return{width:`${$/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?wp:yp);let p=null;function v(){i.value=!0,y()}function y(){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(),T=(f.clientX-_.left)/_.width*t.duration;a("seek",Math.max(0,Math.min(T,t.duration)))}function N(f){const _=f.target;a("setVolume",parseInt(_.value))}function C(f){a("selectQuality",f),r.value=!1}function b(f){if(!isFinite(f))return"0:00";const _=Math.floor(f/3600),$=Math.floor(f%3600/60),T=Math.floor(f%60);return _>0?`${_}:${$.toString().padStart(2,"0")}:${T.toString().padStart(2,"0")}`:`${$}:${T.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),y()}),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",iC,[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",rC,[e.createElementVNode("span",sC,e.toDisplayString(b(f.currentTime)),1),_[7]||(_[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",lC,e.toDisplayString(f.isLive?"LIVE":b(f.duration)),1)])],8,oC),e.createElementVNode("div",cC,[e.createElementVNode("div",dC,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:_[0]||(_[0]=$=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(O.IonIcon),{icon:f.playing?e.unref(ap):e.unref(ip),"aria-hidden":"true"},null,8,["icon"])],8,uC),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]=$=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(rp),"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]=$=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(cp),"aria-hidden":"true"},null,8,["icon"]),_[9]||(_[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",mC,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",pC,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:_[3]||(_[3]=$=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(O.IonIcon),{icon:h.value,"aria-hidden":"true"},null,8,["icon"])],8,fC),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:f.muted?0:f.volume,onInput:N,"aria-label":"Volume"},null,40,hC)]))]),e.createElementVNode("div",vC,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",gC,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:_[4]||(_[4]=$=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(hp),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",bC,e.toDisplayString(f.currentQuality),1)],8,yC),r.value?(e.openBlock(),e.createElementBlock("div",wC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,$=>(e.openBlock(),e.createElementBlock("button",{key:$.label,class:e.normalizeClass(["quality-option",{active:$.label===f.currentQuality}]),"data-testid":`btn-video-quality-${$.label}`,"aria-label":`Set quality to ${$.label}`,role:"menuitem",onClick:T=>C($)},e.toDisplayString($.label),11,kC))),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]=$=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(vp),"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]=$=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(O.IonIcon),{icon:f.fullscreen?e.unref(Xm):e.unref(Ym),"aria-hidden":"true"},null,8,["icon"])],8,_C)])])],2))}}),xC=Ce(EC,[["__scopeId","data-v-2ae77c13"]]);function CC(o={}){var te,he,ge;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||((te=o.media)==null?void 0:te.playback_url)||((he=o.media)==null?void 0:he.url)||""),y=e.ref(null),w=e.ref(o.isLive||!1),N=e.ref(null),C=e.ref(null);function b(ae){C.value=ae}if((ge=o.media)!=null&&ge.token_expires_at){const ae=new Date(o.media.token_expires_at);y.value=Number.isNaN(ae.getTime())?null:ae}async function f(){var V;const ae=w.value?t.value:n.value;if(ae)try{await ae.play(),a.value=!0,p.value=w.value?"live":"playing",(V=o.onPlay)==null||V.call(o)}catch{h.value="Failed to play video",p.value="error"}}function _(){var V;const ae=w.value?t.value:n.value;ae&&(ae.pause(),a.value=!1,p.value="paused",(V=o.onPause)==null||V.call(o))}function $(){a.value?_():f()}function T(ae){const V=w.value?t.value:n.value;if(!V||w.value)return;const U=Number.isFinite(V.duration)?V.duration:ae;V.currentTime=Math.max(0,Math.min(ae,U)),i.value=V.currentTime}function x(ae=10){const V=n.value;!V||w.value||T(V.currentTime+ae)}function I(ae=10){const V=n.value;!V||w.value||T(V.currentTime-ae)}function Z(){const ae=w.value?t.value:n.value;ae&&(ae.muted=!ae.muted,l.value=ae.muted)}function S(ae){const V=w.value?t.value:n.value;if(!V)return;const U=Math.max(0,Math.min(100,ae));V.volume=U/100,s.value=U,U>0&&V.muted&&(V.muted=!1,l.value=!1)}function L(ae){const V=n.value;!V||w.value||(V.playbackRate=ae,u.value=ae)}async function R(){const ae=document.querySelector(".video-player-container");if(ae)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ae.requestFullscreen(),c.value=!0)}catch{}}async function P(){const ae=w.value?t.value:n.value;if(ae)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ae.requestPictureInPicture()}catch{}}async function A(){var V;h.value=null,p.value="loading",(V=o.media)!=null&&V.provider&&o.media.provider!=="local"&&await B();const ae=w.value?t.value:n.value;ae&&(ae.load(),await f())}async function B(){if(!(!C.value||!o.media))try{m.value=!0;const ae=await C.value.get(`/api/v1/video/${o.media.uuid}/playback`);v.value=ae.playback_url,y.value=new Date(ae.token_expires_at);const V=w.value?t.value:n.value;if(V&&V.src!==v.value){const U=!V.paused,K=V.currentTime;V.src=v.value,w.value||(V.currentTime=K),U&&await f()}}catch{h.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function D(ae){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ae;return}try{t.value.src=ae}catch{h.value="Live streaming not supported in this browser",p.value="error"}}}function k(){N.value&&(N.value.destroy(),N.value=null)}function F(){var V;const ae=w.value?t.value:n.value;ae&&(i.value=ae.currentTime,r.value=ae.duration,(V=o.onTimeUpdate)==null||V.call(o,ae.currentTime))}const H=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ae=0;ae<d.value.length;ae++){const V=d.value.start(ae),U=d.value.end(ae);if(i.value>=V&&i.value<=U)return U/r.value*100}return 0});function j(){if(!y.value)return!1;const ae=new Date;return y.value.getTime()-ae.getTime()<5*60*1e3}return e.watch([n,t],([ae,V])=>{const U=w.value?V:ae;U&&(U.addEventListener("timeupdate",F),U.addEventListener("loadedmetadata",()=>{r.value=U.duration,p.value="ready"}),U.addEventListener("progress",()=>{d.value=U.buffered}),U.addEventListener("ended",()=>{var K;a.value=!1,p.value="ended",(K=o.onEnded)==null||K.call(o)}),U.addEventListener("error",K=>{var ee;p.value="error",(ee=o.onError)==null||ee.call(o,"Video playback error")}),U.volume=s.value/100,U.muted=l.value)}),e.onUnmounted(()=>{k();const ae=w.value?t.value:n.value;ae&&ae.removeEventListener("timeupdate",F)}),{videoEl:n,liveVideoEl:t,playing:a,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:H,playbackRate:u,isLoading:m,error:h,status:p,currentPlaybackUrl:v,tokenExpiresAt:y,play:f,pause:_,togglePlayPause:$,seek:T,skipForward:x,skipBackward:I,toggleMute:Z,setVolume:S,setPlaybackRate:L,toggleFullscreen:R,togglePiP:P,retry:A,refreshToken:B,setupLiveStream:D,setApiClient:b,shouldRefreshToken:j}}const SC=["src","poster","controls","autoplay","muted","loop","preload"],VC={key:1,ref:"livePlayerEl",class:"live-player"},NC=["controls","muted"],TC={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},MC={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},BC={key:3,class:"video-error","data-testid":"video-error",role:"alert"},IC={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},FC=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:y,currentPlaybackUrl:w,tokenExpiresAt:N,play:C,pause:b,seek:f,toggleMute:_,setVolume:$,toggleFullscreen:T,togglePlayPause:x,skipForward:I,skipBackward:Z,retry:S,refreshToken:L,setApiClient:R,shouldRefreshToken:P,setupLiveStream:A}=CC({...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 B(){await L()}const D=e.computed(()=>{const ee=["video-player-container"];return t.className&&ee.push(t.className),m.value&&ee.push("fullscreen"),t.isLive&&ee.push("is-live"),s.value&&ee.push("is-playing"),p.value&&ee.push("is-loading"),ee}),k=e.computed(()=>{var ee,ne;if(t.poster)return t.poster;if((ee=t.media)!=null&&ee.poster_url)return t.media.poster_url;if((ne=t.media)!=null&&ne.thumbnail_url)return t.media.thumbnail_url});function F(ee){const ne=ee.target;a("loadedmetadata",{duration:ne.duration,width:ne.videoWidth,height:ne.videoHeight})}function H(ee){const ne=ee.target;l.value=ne.currentTime,a("timeupdate",ne.currentTime)}function j(){s.value=!0,a("play")}function te(){s.value=!1,a("pause")}function he(){s.value=!1,a("ended")}function ge(ee){const ne=ee.target;let fe="Failed to load video";if(ne.error)switch(ne.error.code){case ne.error.MEDIA_ERR_ABORTED:fe="Video playback aborted";break;case ne.error.MEDIA_ERR_NETWORK:fe="Network error while loading video";break;case ne.error.MEDIA_ERR_DECODE:fe="Video decoding error";break;case ne.error.MEDIA_ERR_SRC_NOT_SUPPORTED:fe="Video format not supported";break}v.value=fe,a("error",fe)}function ae(ee){const ne=ee.target;h.value=ne.buffered,a("progress",ne.buffered)}function V(){p.value=!0}function U(){p.value=!1}e.watch(()=>t.apiClient,ee=>{ee&&R(ee)},{immediate:!0}),e.watch(()=>t.playbackUrl,ee=>{typeof ee=="string"&&ee.length>0&&(w.value=ee)},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.token_expires_at},ee=>{if(!ee){N.value=null;return}const ne=new Date(ee);N.value=Number.isNaN(ne.getTime())?null:ne},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.playback_url},async(ee,ne)=>{if(t.playbackUrl||!ee||ee===ne)return;const fe=i.value;if(!fe||t.isLive){w.value=ee;return}const ie=!fe.paused,pe=fe.currentTime;w.value=ee,await e.nextTick();try{fe.currentTime=pe}catch{}ie&&await C()},{immediate:!0});let K=null;return e.watch(()=>t.isLive,async ee=>{var fe;if(!ee)return;const ne=t.playbackUrl||((fe=t.media)==null?void 0:fe.playback_url)||"";ne&&await A(ne)},{immediate:!0}),e.onMounted(()=>{var ee;(ee=t.media)!=null&&ee.provider&&t.media.provider!=="local"&&(K=setInterval(()=>{P()&&B()},3e4)),O.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{K&&clearInterval(K)}),(ee,ne)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",D.value]),"data-testid":"video-player"},[ee.isLive?(e.openBlock(),e.createElementBlock("div",VC,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ee.controls&&!ee.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:j,onPause:te,onError:ge,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,NC),e.unref(y)==="live"?(e.openBlock(),e.createElementBlock("div",TC,[...ne[3]||(ne[3]=[e.createElementVNode("span",{class:"live-dot"},null,-1),e.createElementVNode("span",{class:"live-text"},"LIVE",-1)])])):e.createCommentVNode("",!0)],512)):(e.openBlock(),e.createElementBlock("video",{key:0,ref_key:"videoEl",ref:i,src:e.unref(w),poster:k.value,controls:ee.controls&&!ee.showCustomControls,autoplay:ee.autoplay,muted:e.unref(u),loop:ee.loop,preload:ee.preload,onLoadedmetadata:F,onTimeupdate:H,onPlay:j,onPause:te,onEnded:he,onError:ge,onProgress:ae,onWaiting:V,onCanplay:U,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,SC)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",MC,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",BC,[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Nr),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(O.IonButton),{size:"small",onClick:e.unref(S),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{icon:e.unref(qn),slot:"start","aria-hidden":"true"},null,8,["icon"]),ne[4]||(ne[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ee.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(xC,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(h),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ee.isLive,onPlay:e.unref(C),onPause:e.unref(b),onSeek:e.unref(f),onToggleMute:e.unref(_),onSetVolume:e.unref($),onToggleFullscreen:e.unref(T),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ee.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",IC,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ne[0]||(ne[0]=(...fe)=>e.unref(Z)&&e.unref(Z)(...fe))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ne[1]||(ne[1]=(...fe)=>e.unref(x)&&e.unref(x)(...fe))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ne[2]||(ne[2]=(...fe)=>e.unref(I)&&e.unref(I)(...fe))},null,32)])):e.createCommentVNode("",!0)],2))}}),kd=Ce(FC,[["__scopeId","data-v-b8db4951"]]),$C=Uo.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(A=>A.status==="live")),c=e.computed(()=>r.value.filter(A=>A.processing_status==="processing"));function d(A){o.value.set(A.uuid,A)}function u(A,B){const D=o.value.get(A);D&&o.value.set(A,{...D,...B})}function m(A){o.value.delete(A)}function h(A){return o.value.get(A)}function p(A){n.value.set(A.id,A)}function v(A,B){const D=n.value.get(A);D&&n.value.set(A,{...D,...B})}function y(A,B){const D=n.value.get(A);D&&n.value.set(A,{...D,status:B.status,viewer_count:B.viewer_count,peak_viewers:B.peak_viewers})}function w(A){n.value.delete(A)}function N(A){return n.value.get(A)}function C(A){return s.value.find(B=>B.media_uuid===A)}function b(A){t.value.set(A.id,A)}function f(A,B){const D=t.value.get(A);D&&t.value.set(A,{...D,...B})}function _(A){t.value.delete(A)}function $(A){return t.value.get(A)}function T(A){return Array.from(t.value.values()).filter(B=>B.media_uuid===A)}function x(A){a.value=A}function I(A){a.value&&(a.value={...a.value,...A})}function Z(){a.value=null}function S(A){i.value=A}function L(){o.value.clear(),n.value.clear(),t.value.clear(),a.value=null,i.value=!1}function R(A){o.value.clear(),A.forEach(B=>{o.value.set(B.uuid,B)})}function P(A){n.value.clear(),A.forEach(B=>{n.value.set(B.id,B)})}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:y,removeLiveStream:w,getLiveStream:N,getLiveStreamByMedia:C,addExportJob:b,updateExportJob:f,removeExportJob:_,getExportJob:$,getExportJobsByMedia:T,setEditorState:x,updateEditorState:I,clearEditorState:Z,setProcessing:S,clearAll:L,loadVideos:R,loadLiveStreams:P}});let En=null;function RC(o){En=o}const co={post:async(o,n)=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${o}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async o=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${o}`)},delete:async o=>{if(!En)throw new Error("HTTP client not configured");return await En(`/api/v1/video${o}`,{method:"DELETE"})}};function uo(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 qi(o,n){return o instanceof Error&&o.message?o.message:n}function DC(o){const n=$C(),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 Z;if(!((Z=t.value)!=null&&Z.playback_url))return null;const I=new URL(t.value.playback_url);return I.searchParams.set("live","true"),a.value&&I.searchParams.set("latency","low"),I.toString()}),y=e.computed(()=>{var I;return((I=t.value)==null?void 0:I.status)==="live"}),w=e.computed(()=>{var I;return((I=t.value)==null?void 0:I.status)==="idle"}),N=e.computed(()=>{var I;return((I=t.value)==null?void 0:I.status)==="ended"});async function C(I={}){s.value=!0,c.value=null;try{const Z=await co.post("/live",{title:r.value||I.title||"Live Stream",low_latency:I.low_latency??a.value,auto_record:I.auto_record??i.value,...I}),S=uo(Z);return t.value=S,n.setLiveStream(S),$(),S}catch(Z){throw c.value=qi(Z,"Failed to create stream"),Z instanceof Error?Z: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 I=await co.post(`/live/${t.value.id}/end`),Z=uo(I,t.value);return t.value=Z,n.setLiveStream(Z),T(),Z}catch(I){throw c.value=qi(I,"Failed to end stream"),I instanceof Error?I:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const I=await co.get(`/live/${t.value.id}`),Z=uo(I,t.value);u.value=Z.viewer_count,m.value=Z.peak_viewers,t.value=Z;const S={status:Z.status,viewer_count:Z.viewer_count,peak_viewers:Z.peak_viewers};Z.started_at&&(S.started_at=Z.started_at),Z.ended_at&&(S.ended_at=Z.ended_at),n.updateLiveStreamStats(Z.id,S),Z.status==="live"&&!d.value&&Z.started_at&&(d.value=new Date(Z.started_at)),Z.status==="ended"&&T()}catch{}}async function _(I){try{const Z=await co.get(`/live/${I}`),S=uo(Z,t.value);return{rtmp_url:S.rtmp_url,stream_key:S.stream_key,playback_url:S.playback_url||""}}catch(Z){throw c.value=qi(Z,"Failed to get stream credentials"),Z instanceof Error?Z:new Error(c.value)}}function $(I=5e3){T(),h=window.setInterval(()=>{f()},I)}function T(){h!==void 0&&(clearInterval(h),h=void 0)}async function x(){if(!o)return;const I=n.getLiveStreamByMedia(o);I&&(t.value=I,u.value=I.viewer_count,m.value=I.peak_viewers,I.status==="live"&&($(),I.started_at&&(d.value=new Date(I.started_at))))}return o&&x(),e.onUnmounted(()=>{T()}),{stream:t,lowLatency:a,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:y,isIdle:w,hasEnded:N,createStream:C,endStream:b,refreshStreamStatus:f,getStreamCredentials:_,startStatusPolling:$,stopStatusPolling:T}}const AC={class:"stream-status"},LC={class:"flex items-center justify-between"},UC={class:"flex items-center gap-3"},OC={key:0,class:"flex items-center"},zC={key:2,class:"text-sm text-gray-600"},PC={key:0,class:"flex items-center gap-2"},WC={class:"text-sm font-medium text-gray-700"},jC={key:0,class:"text-xs text-gray-500"},ZC=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",AC,[e.createElementVNode("div",LC,[e.createElementVNode("div",UC,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",OC,[...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",zC,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",PC,[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",WC,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",jC," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),HC=Ce(ZC,[["__scopeId","data-v-1d09c19f"]]),XC={class:"stream-credentials"},GC={class:"space-y-3"},JC={class:"credential-field"},YC={class:"flex gap-2"},qC=["value"],KC={class:"credential-field"},QC={class:"flex gap-2"},eS=["value","type"],tS=["aria-label"],nS={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},aS={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},oS={key:0,class:"mt-2 text-sm text-green-600"},iS=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",XC,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",GC,[e.createElementVNode("div",JC,[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",YC,[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,qC),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",KC,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",QC,[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,eS),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",aS,[...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",nS,[...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,tS),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",oS,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),rS=Ce(iS,[["__scopeId","data-v-306d92f6"]]),sS={class:"live-stream-manager","data-testid":"live-stream-manager"},lS={key:0,class:"stream-setup"},cS={class:"space-y-4"},dS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},uS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},mS=["disabled"],pS={key:0},fS={key:1,class:"flex items-center justify-center"},hS={key:1,class:"stream-active space-y-6"},vS={key:1,class:"video-preview"},gS={key:2,class:"analytics-panel"},yS={class:"grid grid-cols-2 gap-4"},bS={class:"bg-gray-50 p-3 rounded"},wS={class:"text-2xl font-bold text-gray-900"},kS={class:"bg-gray-50 p-3 rounded"},_S={class:"text-2xl font-bold text-gray-900"},ES={class:"stream-controls flex gap-3"},xS=["disabled"],CS={key:0},SS={key:1},VS={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},NS={class:"text-red-600 text-sm"},TS=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&&RC(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:y}=DC(t.mediaUuid),w=e.ref(!1);async function N(){var $;try{const T=await m({title:l.value,low_latency:r.value,auto_record:s.value});a("stream-created",T),($=t.onStreamCreated)==null||$.call(t,T)}catch(T){a("error",T)}}async function C(){var $;try{const T=await h();a("stream-ended",T),($=t.onStreamEnded)==null||$.call(t,T)}catch(T){a("error",T)}}function b(){i.value=null,l.value="",w.value=!1,u.value=null}async function f($,T){try{await navigator.clipboard.writeText($)}catch{}}let _;return e.onMounted(()=>{var $;(($=i.value)==null?void 0:$.status)==="live"&&(_=window.setInterval(()=>{y()},5e3))}),e.onUnmounted(()=>{_&&clearInterval(_)}),($,T)=>(e.openBlock(),e.createElementBlock("div",sS,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",hS,[e.createVNode(HC,{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(rS,{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",vS,[T[9]||(T[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(kd,{"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",gS,[T[12]||(T[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",yS,[e.createElementVNode("div",bS,[e.createElementVNode("div",wS,e.toDisplayString(e.unref(i).viewer_count),1),T[10]||(T[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",kS,[e.createElementVNode("div",_S,e.toDisplayString(e.unref(i).peak_viewers),1),T[11]||(T[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",ES,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:T[3]||(T[3]=x=>w.value=!w.value),class:"flex-1 py-2 px-4 bg-gray-200 text-gray-700 font-medium rounded-lg hover:bg-gray-300 transition-colors"},e.toDisplayString(w.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:C,disabled:e.unref(d),class:"flex-1 py-2 px-4 bg-red-600 text-white font-medium rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors","aria-label":"End live stream"},[e.unref(d)?(e.openBlock(),e.createElementBlock("span",SS,"Ending...")):(e.openBlock(),e.createElementBlock("span",CS,"End Stream"))],8,xS)):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",lS,[T[8]||(T[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",cS,[e.createElementVNode("div",dS,[T[4]||(T[4]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Low Latency Mode"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," 5-7 second delay (vs 15-20s standard) ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":T[0]||(T[0]=x=>e.isRef(r)?r.value=x:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable low latency mode"},null,512),[[e.vModelCheckbox,e.unref(r)]])]),e.createElementVNode("div",uS,[T[5]||(T[5]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Auto-Record Stream"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," Save stream as VOD for later viewing ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":T[1]||(T[1]=x=>e.isRef(s)?s.value=x:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[T[6]||(T[6]=e.createElementVNode("label",{for:"stream-title",class:"block text-sm font-medium text-gray-700 mb-2"}," Stream Title (optional) ",-1)),e.withDirectives(e.createElementVNode("input",{id:"stream-title","onUpdate:modelValue":T[2]||(T[2]=x=>e.isRef(l)?l.value=x:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:N,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",fS,[...T[7]||(T[7]=[e.createElementVNode("svg",{class:"animate-spin h-5 w-5 mr-2",viewBox:"0 0 24 24"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1),e.createTextVNode(" Creating... ",-1)])])):(e.openBlock(),e.createElementBlock("span",pS,"Create Stream"))],8,mS)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",VS,[e.createElementVNode("p",NS,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),MS=Ce(TS,[["__scopeId","data-v-26291f6f"]]),BS={class:"album-tree-node"},IS=["data-album-id","draggable","aria-selected","aria-expanded"],FS={key:1,class:"album-node__chevron-placeholder"},$S={key:2,"data-testid":"media-count",class:"album-node__count"},RS={key:0,class:"album-tree-node__children",role:"group"},DS=16,AS=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*DS}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 y(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 N(){a("drag-leave",t.album.id)}function C(b){t.draggable&&(b.preventDefault(),a("drop",t.album.id))}return(b,f)=>{var $;const _=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",BS,[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:y,onDragover:w,onDragleave:N,onDrop:C},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:v},[e.createVNode(e.unref(O.IonIcon),{icon:i.value?e.unref(jm):e.unref(Zm)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",FS)),e.createVNode(e.unref(O.IonIcon),{icon:e.unref(Qm),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",$S,e.toDisplayString(b.album.media_count),1)):e.createCommentVNode("",!0)],46,IS),i.value&&(($=b.album.children)!=null&&$.length)?(e.openBlock(),e.createElementBlock("div",RS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.album.children,T=>(e.openBlock(),e.createBlock(_,{key:T.id,album:T,depth:b.depth+1,"selected-id":b.selectedId,"expanded-ids":b.expandedIds,"focused-id":b.focusedId,draggable:b.draggable,"show-media-count":b.showMediaCount,compact:b.compact,onSelect:f[0]||(f[0]=x=>a("select",x)),onToggleExpand:f[1]||(f[1]=x=>a("toggle-expand",x))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),LS=Ce(AS,[["__scopeId","data-v-76be65a6"]]),ci=Uo.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,$=_?`/api/v1/albums?parent_id=${_}`:"/api/v1/albums?parent_id=null",T=await fetch($);if(!T.ok)throw new Error("Failed to fetch albums");((await T.json()).data||[]).forEach(Z=>{const S=o.value.findIndex(L=>L.id===Z.id);S>=0?o.value[S]=Z:o.value.push(Z)}),_!==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 T=(await _.json()).data,x=o.value.findIndex(I=>I.id===T.id);return x>=0?o.value[x]=T:o.value.push(T),T}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 T=(await _.json()).data||[];return n.value.set(f,T),T}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 T=n.value.get(f)||[],x=_.map(I=>T.find(Z=>Z.uuid===I)).filter(I=>I!==void 0);n.value.set(f,x)}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}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 T=(await _.json()).data;return o.value.push(T),T}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 $=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(_)});if(!$.ok)throw new Error("Failed to update album");const x=(await $.json()).data,I=o.value.findIndex(Z=>Z.id===x.id);return I>=0&&(o.value[I]=x),x}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}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 $=o.value.findIndex(T=>T.id===f);$>=0&&o.value.splice($,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 y(f){return i.value.has(f)}function w(f){return n.value.get(f)||[]}async function N(f,_){const $=o.value.findIndex(x=>x.id===f);if($<0)return;const T=o.value[$];o.value[$]={...T,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(x){throw o.value[$]=T,a.value=x instanceof Error?x.message:"Unknown error",x instanceof Error?x:new Error("Failed to move album")}}function C(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:y,getAlbumMedia:w,moveAlbum:N,setAlbums:C,reset:b}});function _d(){const o=ci(),{albums:n,albumsById:t,rootAlbums:a,loading:i,error:r}=Uo.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 Ed(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 y=v.shift();if(!y||p.has(y))continue;p.add(y);const w=n.get(y)||[];for(const N of w){if(N===h)return!0;v.push(N)}}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 US={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},OS={key:1,"data-testid":"error-state",class:"album-tree__error"},zS={key:2,"data-testid":"empty-state",class:"album-tree__empty"},PS={key:3,class:"album-tree__content",role:"group"},WS=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:y}=_d(),w=e.shallowRef(new Set(a.expandedIds)),N=e.ref(a.modelValue??null),C=e.ref(null),b=new Map,f=new Map;function _(V){b.clear(),f.clear();for(const U of V){b.set(U.id,U);const K=U.parent_id??null,ee=f.get(K)??[];ee.push(U.id),f.set(K,ee)}}e.watch(c,V=>{_(V)},{immediate:!0});const{dragState:$,canDropOn:T,startDrag:x,endDrag:I,setDropTarget:Z,clearDropTarget:S,executeDrop:L}=Ed({childrenByParentId:f,onMove:async(V,U)=>{await y(V,U),i("album-moved",{albumId:V,newParentId:U})}});e.watch(()=>a.modelValue,V=>{N.value=V??null}),e.watch(()=>a.expandedIds,V=>{w.value=new Set(V)}),e.onMounted(async()=>{await h({parent_id:null})});const R=e.computed(()=>d.value.map(V=>P(V)));function P(V){if(!w.value.has(V.id))return V;const U=p(V.id);return{...V,children:U.map(K=>P(K))}}const A=e.computed(()=>{const V=[];function U(K){var ee;for(const ne of K)V.push(ne),w.value.has(ne.id)&&((ee=ne.children)!=null&&ee.length)&&U(ne.children)}return U(R.value),V});function B(V){var ee;if(!A.value.length)return;const U=C.value?A.value.findIndex(ne=>ne.id===C.value):-1,K=U>=0?A.value[U]:null;switch(V.key){case"ArrowDown":V.preventDefault(),U<A.value.length-1?C.value=A.value[U+1].id:U===-1&&A.value.length>0&&(C.value=A.value[0].id);break;case"ArrowUp":V.preventDefault(),U>0&&(C.value=A.value[U-1].id);break;case"ArrowRight":V.preventDefault(),K&&(K.children_count>0&&!w.value.has(K.id)?D(K.id):w.value.has(K.id)&&((ee=K.children)!=null&&ee.length)&&(C.value=K.children[0].id));break;case"ArrowLeft":V.preventDefault(),K&&(w.value.has(K.id)&&K.children_count>0?D(K.id):K.parent_id&&(C.value=K.parent_id));break;case"Enter":case" ":V.preventDefault(),K&&k(K);break;case"Home":V.preventDefault(),A.value.length>0&&(C.value=A.value[0].id);break;case"End":V.preventDefault(),A.value.length>0&&(C.value=A.value[A.value.length-1].id);break}}async function D(V){w.value.has(V)?(w.value.delete(V),i("album-collapsed",V)):(v(V)||await h({parent_id:V}),w.value.add(V),i("album-expanded",V))}function k(V){N.value=V.id,i("update:modelValue",V.id),i("album-selected",V)}function F(V){a.draggable&&x(V)}function H(V){var K;if(!a.draggable)return;const U=(K=$.value)==null?void 0:K.draggedAlbumId;U&&(Z(V),T(U,V))}function j(){a.draggable&&S()}async function te(V){a.draggable&&(Z(V),await L())}function he(V){a.draggable&&(V.preventDefault(),Z(null))}async function ge(V){a.draggable&&(V.preventDefault(),Z(null),await L())}function ae(){I()}return n({focusedId:C}),(V,U)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:B,onDragover:he,onDrop:ge,onDragend:ae},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",US,[e.createVNode(e.unref(O.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",OS,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",PS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,K=>(e.openBlock(),e.createBlock(LS,{key:K.id,album:K,depth:0,"selected-id":N.value,"expanded-ids":w.value,"focused-id":C.value,draggable:r.value,"drag-state":r.value?e.unref($):null,"show-media-count":s.value,compact:l.value,onSelect:k,onToggleExpand:D,onDragStart:F,onDragOver:H,onDragLeave:j,onDrop:te},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",zS,[U[0]||(U[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(V.$slots,"empty-action",{},void 0,!0)]))],32))}}),xd=Ce(WS,[["__scopeId","data-v-ae3dea7a"]]),jS=300,ZS=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<jS){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(O.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:h},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(O.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.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(O.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(xd,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=y=>i.value=y),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(O.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{fill:"clear",onClick:m},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(O.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"]))}}),Cd=Ce(ZS,[["__scopeId","data-v-21676ec1"]]),HS={class:"ion-padding-start text-sm"},XS={class:"ion-padding-start text-sm"},GS={key:1},JS={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},YS={class:"flex items-center justify-between gap-3 pb-3"},qS={class:"text-base font-semibold text-gray-900"},KS={class:"ion-padding-start text-sm"},QS={class:"ion-padding-start text-sm"},eV={class:"flex justify-between pt-2"},tV={key:1},pa=255,fa=1e3,nV=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=ci(),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),y=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>pa?`Name must be ${pa} characters or less`:null:"Name is required":null),w=e.computed(()=>d.value.description&&c.value.description.length>fa?`Description must be ${fa} characters or less`:null),N=e.computed(()=>{const B=c.value.name.trim().length>0,D=c.value.name.length<=pa,k=c.value.description.length<=fa;return B&&D&&k&&!p.value}),C=e.computed(()=>{var B;return((B=u.value)==null?void 0:B.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 B=await i.fetchAlbum(t.albumId);h.value=B,c.value={name:B.name,description:B.description??"",parent_id:B.parent_id},B.parent_id&&(u.value={id:B.parent_id,name:"Parent Album"})}catch(B){a("error",B)}}function $(){d.value.name=!0}function T(){d.value.description=!0}function x(){m.value=!0}function I(B){u.value={id:B.id,name:B.name},c.value.parent_id=B.id,m.value=!1}function Z(){m.value=!1}function S(){a("close")}function L(){a("close")}async function R(){if(d.value.name=!0,d.value.description=!0,!(!N.value||p.value)){p.value=!0;try{const B={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const D=await i.updateAlbum(t.albumId,B);a("updated",D)}else{const D=await i.createAlbum(B);a("created",D)}a("close")}catch(B){a("error",B)}finally{p.value=!1}}}function P(){b.value&&(v.value=!0)}async function A(B){var k;if((((k=B.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(F){a("error",F)}finally{p.value=!1,v.value=!1}}}return(B,D)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[B.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(O.IonModal),{key:0,"is-open":B.isOpen,class:"album-manager-modal",onDidDismiss:L},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(O.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:S},{default:e.withCtx(()=>[...D[4]||(D[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(O.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(O.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...D[5]||(D[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(O.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":D[0]||(D[0]=k=>c.value.name=k),"data-testid":"name-input",maxlength:pa,onIonBlur:$},null,8,["modelValue"])]),_:1}),y.value?(e.openBlock(),e.createBlock(e.unref(O.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",HS,e.toDisplayString(y.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...D[6]||(D[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(O.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":D[1]||(D[1]=k=>c.value.description=k),"data-testid":"description-input",maxlength:fa,onIonBlur:T},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(O.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",XS,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...D[7]||(D[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(O.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(O.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!b.value,title:b.value?void 0:f.value,onClick:P},{default:e.withCtx(()=>[...D[8]||(D[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(O.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!N.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(O.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",GS,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",JS,[e.createElementVNode("div",YS,[e.createElementVNode("h2",qS,e.toDisplayString(s.value),1),e.createVNode(e.unref(O.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:S},{default:e.withCtx(()=>[...D[9]||(D[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(O.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...D[10]||(D[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(O.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":D[2]||(D[2]=k=>c.value.name=k),"data-testid":"name-input",maxlength:pa,onIonBlur:$},null,8,["modelValue"])]),_:1}),y.value?(e.openBlock(),e.createBlock(e.unref(O.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",KS,e.toDisplayString(y.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...D[11]||(D[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(O.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":D[3]||(D[3]=k=>c.value.description=k),"data-testid":"description-input",maxlength:fa,onIonBlur:T},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(O.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",QS,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonLabel),null,{default:e.withCtx(()=>[...D[12]||(D[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(O.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1}),e.createElementVNode("div",eV,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(O.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!b.value,title:b.value?void 0:f.value,onClick:P},{default:e.withCtx(()=>[...D[13]||(D[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(O.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!N.value,onClick:R},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(O.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",tV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Cd,{"is-open":m.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:Z,onConfirm:I},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(O.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:A},null,8,["is-open","message"])],64))}}),aV=Ce(nV,[["__scopeId","data-v-22083f3a"]]),oV={class:"album-media-grid"},iV={class:"aspect-square"},rV={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},sV={class:"text-gray-500"},lV=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],cV={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},dV={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},uV={class:"aspect-square relative"},mV=["src","alt"],pV={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},fV=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=ci(),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 L=t.columns;return["grid","gap-4",`grid-cols-${L.mobile??2}`,`sm:grid-cols-${L.sm??3}`,`md:grid-cols-${L.md??4}`,`lg:grid-cols-${L.lg??5}`,`xl:grid-cols-${L.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 L=await i.fetchAlbumMedia(t.albumId);r.value=L}catch{r.value=[]}finally{s.value=!1}}function y(L){return t.selectedItems.includes(L)}function w(L){a("toggle-select",L);const R=y(L.uuid)?t.selectedItems.filter(P=>P!==L.uuid):[...t.selectedItems,L.uuid];a("selection-change",R)}function N(L){if(L.conversions&&typeof L.conversions=="object"){const R=L.conversions.thumb;if(typeof R=="string")return R}return L.original_url}function C(L){l.value=L}function b(){l.value=null}function f(L){a("preview",L)}function _(L){a("edit",L)}function $(L){a("detach",L.uuid)}function T(){a("add")}function x(L,R){t.reorderable&&(c.value=R,L.dataTransfer&&(L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",String(R))))}function I(L,R){!t.reorderable||c.value===null||(L.preventDefault(),d.value=R)}function Z(L,R){if(!t.reorderable||c.value===null)return;L.preventDefault();const P=c.value;if(P!==R){const A=[...r.value],[B]=A.splice(P,1);A.splice(R,0,B),r.value=A;const D=A.map(k=>k.uuid);a("reorder",D),i.reorderAlbumMedia(t.albumId,D).catch(()=>{v()})}c.value=null,d.value=null}function S(){c.value=null,d.value=null}return(L,R)=>(e.openBlock(),e.createElementBlock("div",oV,[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,P=>(e.openBlock(),e.createBlock(e.unref(O.IonCard),{key:P,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",iV,[e.createVNode(e.unref(O.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",rV,[e.createVNode(e.unref(O.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",sV,e.toDisplayString(L.emptyText),1),e.createVNode(e.unref(O.IonButton),{"data-testid":"add-media-btn",onClick:T},{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,(P,A)=>(e.openBlock(),e.createElementBlock("div",{key:P.uuid,"data-media-id":P.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===A,"ring-2 ring-primary":d.value===A&&c.value!==A}]),draggable:L.reorderable,onDragstart:B=>x(B,A),onDragover:B=>I(B,A),onDrop:B=>Z(B,A),onDragend:S,onMouseenter:B=>C(P.uuid),onMouseleave:b},[d.value===A&&c.value!==A&&L.reorderable?(e.openBlock(),e.createElementBlock("div",cV)):e.createCommentVNode("",!0),L.reorderable?(e.openBlock(),e.createElementBlock("div",dV,[e.createVNode(e.unref(O.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),L.selectionMode?(e.openBlock(),e.createBlock(e.unref(O.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:y(P.uuid),class:"absolute top-2 left-2 z-20",onIonChange:B=>w(P)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(O.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",uV,[e.createElementVNode("img",{src:N(P),alt:P.file_name,class:"w-full h-full object-cover"},null,8,mV),L.showActions&&l.value===P.uuid?(e.openBlock(),e.createElementBlock("div",pV,[e.createVNode(e.unref(O.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:B=>f(P)},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(O.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:B=>_(P)},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(O.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:B=>$(P)},{default:e.withCtx(()=>[e.createVNode(e.unref(O.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,lV))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:T},[e.createVNode(e.unref(O.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))]))}}),hV=Ce(fV,[["__scopeId","data-v-d84b796a"]]),vV={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},gV={class:"media-album-inline-create__field"},yV={class:"media-album-inline-create__field"},bV=["value"],wV={key:1,class:"media-album-inline-create__autocomplete"},kV={class:"media-album-inline-create__autocomplete-input-wrap"},_V={key:0,class:"media-album-inline-create__autocomplete-list"},EV=["onMousedown"],xV={key:1,class:"media-album-inline-create__autocomplete-empty"},CV={class:"media-album-inline-create__actions"},SV=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(N=>N.name.toLowerCase().includes(w))}),u=e.computed(()=>{if(r.value==="")return"";const w=t.albums.find(N=>N.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)},y=()=>{i.value.trim()!==""&&(a("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(w,N)=>w.open?(e.openBlock(),e.createElementBlock("section",vV,[N[7]||(N[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",gV,[e.createElementVNode("span",null,e.toDisplayString(w.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[0]||(N[0]=C=>i.value=C),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",yV,[N[6]||(N[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),c.value?(e.openBlock(),e.createElementBlock("div",wV,[e.createElementVNode("div",kV,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[2]||(N[2]=C=>s.value=C),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"])},[...N[5]||(N[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",_V,[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,C=>(e.openBlock(),e.createElementBlock("li",{key:C.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":C.id===r.value}]),onMousedown:e.withModifiers(b=>m(C),["prevent"])},e.toDisplayString(C.name),43,EV))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("li",xV," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":N[1]||(N[1]=C=>r.value=C),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[N[4]||(N[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.albums,C=>(e.openBlock(),e.createElementBlock("option",{key:C.id,value:C.id},e.toDisplayString(C.name),9,bV))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",CV,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:N[3]||(N[3]=C=>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:y}," Create ")])])):e.createCommentVNode("",!0)}}),Sd=Ce(SV,[["__scopeId","data-v-a85162fe"]]),VV={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},NV=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",VV,[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)]))}}),Vd=Ce(NV,[["__scopeId","data-v-04620e64"]]),TV={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},MV={class:"media-preview-sheet__header"},BV=["src","alt"],IV=["src"],FV={class:"media-preview-sheet__actions"},$V=["disabled"],RV=["disabled"],DV=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",TV,[e.createElementVNode("header",MV,[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,BV)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,IV)),e.createElementVNode("div",FV,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>a("previous"))}," Previous ",8,$V),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,RV)])])):e.createCommentVNode("",!0)}}),Nd=Ce(DV,[["__scopeId","data-v-9a05f74e"]]),AV={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},LV={class:"media-album-grid__items"},UV={class:"media-album-grid__card-name"},OV={class:"media-album-grid__card-name"},zV=["data-testid","onClick"],PV={class:"media-album-grid__card-name"},WV={key:0,class:"media-album-grid__card-meta"},jV={key:0,class:"media-album-grid__empty"},ZV=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",AV,[e.createElementVNode("div",LV,[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",UV,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",OV,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",PV,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",WV,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,zV))),128))]),a.albums.length===0?(e.openBlock(),e.createElementBlock("p",jV," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),Td=Ce(ZV,[["__scopeId","data-v-129f67b1"]]),HV={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},XV=["accept"],GV={key:0,class:"media-upload-sheet__queue"},JV={class:"media-upload-sheet__queue-info"},YV={class:"media-upload-sheet__queue-status"},qV={class:"media-upload-sheet__progress-bar"},KV=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",HV,[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,XV)],34),c.queue.length>0?(e.openBlock(),e.createElementBlock("ul",GV,[(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",JV,[e.createElementVNode("strong",null,e.toDisplayString(u.file.name),1),e.createElementVNode("span",YV,e.toDisplayString(u.status),1)]),e.createElementVNode("div",qV,[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)}}),Md=Ce(KV,[["__scopeId","data-v-e238d615"]]),QV=["aria-label","aria-pressed","data-testid"],e4=["src","alt"],t4={key:1,class:"media-thumbnail-cell__video"},n4={class:"media-thumbnail-cell__video-name"},a4={key:2,class:"media-thumbnail-cell__selected-badge"},o4={key:3,class:"media-thumbnail-cell__status-badge"},i4=["aria-label"],r4=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,e4)):(e.openBlock(),e.createElementBlock("div",t4,[m[0]||(m[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",n4,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",a4," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",o4,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,QV),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,i4)],2))}}),Bd=Ce(r4,[["__scopeId","data-v-edd4f0ad"]]),s4={class:"virtual-media-grid"},l4={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},c4={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},d4={key:2,class:"virtual-media-grid__items"},u4=["disabled"],m4=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",s4,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",l4," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",c4,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",d4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(Bd,{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,u4)):e.createCommentVNode("",!0)]))}}),Id=Ce(m4,[["__scopeId","data-v-820b9a4f"]]);function Lo(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 Fd(o){var t;const n=o.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function qr(o){return o.type.startsWith("image/")}async function $d(o){return qr(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 Rd(o,n){const t=[];if(n.maxFileSize&&o.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Lo(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&o.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Lo(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=Fd(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(qr(o)&&(n.maxDimensions||n.minDimensions)){const a=await $d(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 Kr(o={}){const n=e.ref(o.rules||{});function t(c){n.value=c}async function a(c){return Rd(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 p4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function f4(o){if(o.type.startsWith("image/"))return URL.createObjectURL(o)}function Qr(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}=Kr(p);async function y(){if(h.value.size>=t)return;const L=Array.from(m.value.entries()).find(([A,B])=>B.status==="pending"&&!h.value.has(A));if(!L){Array.from(m.value.values()).every(B=>B.status==="completed"||B.status==="error")&&m.value.size>0&&(d==null||d());return}const[R,P]=L;await w(R,P)}async function w(L,R){h.value.add(L),R.status="uploading",R.abortController=new AbortController,m.value.set(L,{...R}),r==null||r(R);try{const P={onProgress:B=>{R.progress=B,m.value.set(L,{...R}),s==null||s(R)},signal:R.abortController.signal};i&&(P.collection=i);const A=await n.upload(R.file,P);u&&(R.status="attaching",m.value.set(L,{...R}),s==null||s(R),await u(R,A.media,n)),R.status="completed",R.progress=100,R.media=A.media,m.value.set(L,{...R}),l==null||l(R,A.media)}catch(P){P.name==="AbortError"?m.value.delete(L):(R.status="error",R.error=P.message,m.value.set(L,{...R}),c==null||c(R,P))}finally{h.value.delete(L),delete R.abortController,y()}}async function N(L){var A;const R=Array.from(L),P=[];for(const B of R){const D=await v(B),k=p4(),F=f4(B),H={id:k,file:B,progress:0,status:D.valid?"pending":"error"};!D.valid&&((A=D.errors[0])!=null&&A.message)&&(H.error=D.errors[0].message),F&&(H.previewUrl=F),m.value.set(k,H);const j={media:null,clientId:k,name:B.name,order:0,upload:H,errors:D.errors};P.push(j)}for(let B=0;B<t;B++)y();return P}function C(L){const R=m.value.get(L);R&&(R.abortController&&R.abortController.abort(),R.previewUrl&&URL.revokeObjectURL(R.previewUrl),m.value.delete(L),h.value.delete(L),y())}async function b(L){const R=m.value.get(L);!R||R.status!=="error"||(R.status="pending",R.progress=0,delete R.error,m.value.set(L,{...R}),y())}function f(){for(const[L,R]of m.value.entries())(R.status==="completed"||R.status==="error")&&(R.previewUrl&&URL.revokeObjectURL(R.previewUrl),m.value.delete(L))}function _(){for(const L of m.value.values())L.abortController&&L.abortController.abort(),L.previewUrl&&URL.revokeObjectURL(L.previewUrl);m.value.clear(),h.value.clear()}function $(L){return m.value.get(L)}const T=e.computed(()=>h.value.size>0),x=e.computed(()=>h.value.size),I=e.computed(()=>Array.from(m.value.values()).filter(L=>L.status==="pending").length),Z=e.computed(()=>m.value.size===0?!0:Array.from(m.value.values()).every(L=>L.status==="completed"||L.status==="error")),S=e.computed(()=>Array.from(m.value.values()));return{uploads:m,isUploading:T,activeCount:x,pendingCount:I,isComplete:Z,addFiles:N,cancelUpload:C,retryUpload:b,clearCompleted:f,clearAll:_,getUpload:$,uploadsArray:S}}function Bn(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function Ba(o){return typeof o=="string"?o:null}function Pl(o){return typeof o=="number"?o:null}function h4(o){return typeof o=="boolean"?o:null}function Dd(o){return Bn(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 v4(o){return!Bn(o)||typeof o.id!="string"||typeof o.status!="string"?null:o.status==="ready"?Dd(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 g4(o){return Bn(o)?{next_cursor:Ba(o.next_cursor),previous_cursor:Ba(o.previous_cursor),has_more:h4(o.has_more)??!1,per_page:Pl(o.per_page),count:Pl(o.count)}:null}function Wl(o){const n=Bn(o)?o:{},t=Array.isArray(n.data)?n.data.filter(Dd):[],a=Bn(n.meta)?n.meta:{},i=g4(a.pagination),r=(i==null?void 0:i.next_cursor)??Ba(a.next_cursor)??Ba(a.cursor),s=(i==null?void 0:i.has_more)??a.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(v4).filter(d=>d!==null):[],c={cursor:r,has_more:s};return i!==null&&(c.pagination=i),{data:t,meta:c,hydrated:l}}function jl(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 Zl(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 y4(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 b4(o){var n;return o instanceof Error?((n=o.response)==null?void 0:n.data)??null:null}function w4(o){if(!Bn(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 k4(o){var r;const n=b4(o),t=Bn(n)?n:null,a=((r=Ba(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=w4(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 Hl(o,n){const t=k4(n),a=y4(n);return{code:a===403?"permission_denied":o,message:t,retriable:a!==403,cause:n}}function es(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 y=>{m+=1;const w=m;u==null||u.abort();const N=new AbortController;u=N,y?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const C=await o.httpClient.get("/v1/media/library",{params:jl(o.view.value,o.filters.value,n,y?i.value:null),signal:N.signal});if(w!==m)return;const b=Wl(C);t.value=y?Zl([...t.value,...b.data]):b.data,a.value=b.hydrated,i.value=b.meta.cursor,r.value=b.meta.has_more}catch(C){if(N.signal.aborted||w!==m)return;const b=Hl(y?"load_more_failed":"query_failed",C);d.value=b,c.value=b.code==="permission_denied",y||(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 y=>{if(y.length===0)return a.value=[],[];try{const w=await o.httpClient.get("/v1/media/library",{params:jl(o.view.value,o.filters.value,1,null,y)}),N=Wl(w);return a.value=N.hydrated,N.hydrated}catch(w){return d.value=Hl("hydration_failed",w),[]}},prepend:y=>{t.value=Zl([y,...t.value])}}}const _4="mediables.media-library.";function E4(o){return!o||o.key.trim()===""?null:`${_4}${o.key}`}function Ki(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function x4(o,n){const t=Date.parse(o);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function Ad(o){const n=E4(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=Ki();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"||x4(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=Ki();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=Ki();l==null||l.removeItem(n)},sessionId:a}}function Ld(o){const n=e.ref(o);return{state:n,transition:a=>{n.value=a}}}function Ud(o){return{emitMetric:(t,a)=>{const i={name:t,timestamp:new Date().toISOString()};a!==void 0&&(i.payload=a),o==null||o(i)}}}function Zn(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function C4(o){const n=Zn(o)?o:{};return(Array.isArray(n.data)?n.data:Zn(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(o)?o:[]).map(a=>{if(!Zn(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 S4(o){const n=Zn(o)?o:{},t=Zn(n.data)?n.data:Zn(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 V4(o){return o==="ready"||o==="uploading"||o==="failed"}function mo(o,n="ready"){return{id:o.uuid,media:o,status:n,countsTowardMax:V4(n)}}function N4(o,n){return o.scope==="library"?!0:n.type==="album"&&n.albumId===o.albumId}function T4(o,n){return o.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===o.albumId}function Qi(o){return{code:"configuration_error",message:o,retriable:!1}}function Od(o){var he,ge,ae;const n=o.selectionMode??"multiple",t=o.maxSelection,a=o.uploadBehavior??"adapter",i=e.ref(o.initialView??{scope:"library"}),r=e.ref({sort:((he=o.initialFilters)==null?void 0:he.sort)??"newest",...(ge=o.initialFilters)!=null&&ge.query?{query:o.initialFilters.query}:{},...(ae=o.initialFilters)!=null&&ae.kinds?{kinds:o.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=Ad(o.sessionPolicy),{emitMetric:m}=Ud(o.telemetry),h=Ld("idle"),p=es({httpClient:o.deps.httpClient,view:i,filters:r}),v=e.computed(()=>l.value.map(V=>V.id)),y=e.computed(()=>{const V=c.value;return V===null?null:p.items.value[V]??null}),w=e.computed(()=>o.uploadTarget??{type:"library"}),N=Qr({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:V=>V.original_url,getThumbnailUrl:V=>V.thumbnail_url??V.preview_url??V.original_url},postUpload:async(V,U,K)=>{const ee=w.value;ee.type!=="album"||!ee.albumId||await K.attach(U.uuid,{modelType:"album",modelId:ee.albumId})},onUploadComplete:(V,U)=>{const K=w.value;N4(i.value,K)&&p.prepend(U),o.autoSelectUploaded&&T4(i.value,K)&&T(U),m("upload-complete",{mediaId:U.uuid,targetType:K.type,targetAlbumId:K.albumId})},onUploadError:(V,U)=>{d.value={code:"upload_failed",message:U.message,retriable:!0,cause:U}}}),C=e.computed(()=>N.isUploading.value),b=()=>{u.save({selectedIds:[...v.value],view:i.value,filters:r.value})},f=async V=>{const U=await p.hydrateSelection(V);l.value=U.map(K=>K.status==="ready"&&K.media?mo(K.media):{id:K.id,media:null,status:K.status,countsTowardMax:!1})},_=e.computed(()=>l.value.filter(V=>V.countsTowardMax).length),$=()=>n==="single"||t===void 0?!0:_.value<t,T=V=>{if(l.value.findIndex(K=>K.id===V.uuid)>=0){n==="multiple"?l.value=l.value.filter(K=>K.id!==V.uuid):l.value=[mo(V)],b();return}if(!$()){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=[mo(V)]:l.value=[...l.value,mo(V)],d.value=null,b()},x=async()=>{var U;h.transition("restoring");const V=u.restore();if(V===null){h.transition("ready");return}V.view&&(i.value=V.view),V.filters&&(r.value={sort:V.filters.sort??"newest",...V.filters.query?{query:V.filters.query}:{},...V.filters.kinds?{kinds:V.filters.kinds}:{}}),await p.loadInitial(),(((U=o.sessionPolicy)==null?void 0:U.restoreSelection)??!0)&&await f(V.selectedIds),h.transition("ready")};e.watch(()=>p.error.value,V=>{V!==null&&(d.value=V,h.transition("error"))});const I=async()=>{d.value=null,h.transition("idle"),await x(),p.items.value.length===0&&!p.loading.value&&!p.permissionDenied.value&&await p.loadInitial();const V=o.defaultSelectedIds??[];l.value.length===0&&V.length>0&&await f(V),h.transition("ready")},Z=async(V,U="user")=>{const K=i.value;i.value=V,U==="user"&&o.preserveSelectionOnViewChange===!1&&(l.value=[]),m("view-change",{from:K.scope,to:V.scope,reason:U}),await p.loadInitial(),b()},S=async()=>{const V=await o.deps.httpClient.get("/v1/albums");s.value=C4(V)},L=async(V,U)=>{try{const K={name:V,visibility:"private"};U&&U.trim()!==""&&(K.parent_id=U);const ee=await o.deps.httpClient.post("/v1/albums",K),ne=S4(ee);return ne===null?Qi("Album creation response was invalid."):(s.value=[ne,...s.value.filter(fe=>fe.id!==ne.id)],await Z({scope:"album",albumId:ne.id,albumName:ne.name},"inline-album-created"),ne)}catch(K){const ee={code:"album_create_failed",message:K instanceof Error?K.message:"Album creation failed.",retriable:!0,cause:K};return d.value=ee,ee}},R=async V=>{if(!o.enableUpload){d.value=Qi("Uploads are not enabled for this picker.");return}if(a!=="delegate"){if(!o.deps.uploadAdapter){d.value=Qi("Uploads require a configured upload adapter.");return}await N.addFiles(V)}},P=()=>{var K;const V=((K=o.validateSelection)==null?void 0:K.call(o,l.value))??null;if(V!==null){const ee={code:"selection_invalid",message:V,retriable:!0};return d.value=ee,ee}if(l.value.filter(ee=>ee.status==="ready"&&ee.media!==null).length===0){const ee={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ee,ee}return{orderedIds:v.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},A=V=>{const U=p.items.value.findIndex(K=>K.uuid===V.uuid);c.value=U>=0?U:null},B=()=>{c.value=null},D=()=>{c.value===null||c.value<=0||(c.value-=1)},k=()=>{c.value===null||c.value>=p.items.value.length-1||(c.value+=1)},F=V=>{l.value=l.value.filter(U=>U.id!==V),b()},H=async()=>{await p.refresh()},j=async V=>{r.value={...r.value,...V&&V.trim()!==""?{query:V.trim()}:{}},(!V||V.trim()==="")&&delete r.value.query,await p.loadInitial(),b()},te=async()=>{await Z({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:N.uploadsArray,isUploading:C,previewIndex:c,previewItem:y,initialize:I,refresh:H,loadMore:p.loadMore,setQuery:j,setView:Z,toggleSelection:T,removeSelected:F,confirmSelection:P,openPreview:A,closePreview:B,showPreviousPreview:D,showNextPreview:k,loadAlbums:S,createAlbum:L,addUploadFiles:R,goToLibrary:te,sessionId:u.sessionId}}const M4=["data-testid"],B4={class:"mlp-location-bar"},I4={class:"mlp-location-bar__left"},F4={class:"mlp-location-bar__label"},$4={class:"mlp-tabs","data-testid":"media-picker-tabs"},R4={key:0,class:"mlp-search-row"},D4=["placeholder"],A4={key:2,class:"mlp-overlay-panel"},L4={key:0,class:"mlp-error","data-testid":"media-picker-error"},U4={key:5,class:"mlp-bottom-bar"},O4={key:0,class:"mlp-bottom-bar__selection"},z4={class:"mlp-bottom-bar__count"},P4={class:"mlp-bottom-bar__thumbs"},W4=["src","alt"],j4={key:1,class:"mlp-bottom-bar__thumb-placeholder"},Z4=["aria-label","onClick"],H4={class:"mlp-bottom-bar__actions"},X4=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 B,D,k,F,H,j,te,he,ge,ae,V,U,K,ee,ne,fe,ie,pe;return{title:((B=a.labels)==null?void 0:B.title)??"Media library",searchPlaceholder:((D=a.labels)==null?void 0:D.searchPlaceholder)??"Search your media",viewLibrary:((k=a.labels)==null?void 0:k.viewLibrary)??"Library",browseAlbums:((F=a.labels)==null?void 0:F.browseAlbums)??"Albums",createAlbum:((H=a.labels)==null?void 0:H.createAlbum)??"Create album",createAlbumNameLabel:((j=a.labels)==null?void 0:j.createAlbumNameLabel)??"Album name",emptyLibrary:((te=a.labels)==null?void 0:te.emptyLibrary)??"No media found in your library.",emptyAlbum:((he=a.labels)==null?void 0:he.emptyAlbum)??"No media found in this album.",networkError:((ge=a.labels)==null?void 0:ge.networkError)??"Unable to load media right now.",retry:((ae=a.labels)==null?void 0:ae.retry)??"Retry",selectedCount:((V=a.labels)==null?void 0:V.selectedCount)??(ke=>`${ke} selected`),confirmAction:((U=a.labels)==null?void 0:U.confirmAction)??"Attach selected",cancel:((K=a.labels)==null?void 0:K.cancel)??"Cancel",dismiss:((ee=a.labels)==null?void 0:ee.dismiss)??"Remove",uploadLabel:((ne=a.labels)==null?void 0:ne.uploadLabel)??"Upload",albumUnavailableTitle:((fe=a.labels)==null?void 0:fe.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((ie=a.labels)==null?void 0:ie.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((pe=a.labels)==null?void 0:pe.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:B=>{var D;(D=a.telemetry)==null||D.call(a,B),i("metric",B)}},l=Od(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),y=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),N=e.computed(()=>l.view.value.scope==="album"),C=()=>{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=B=>{B!==null&&i("error",B)},_=B=>typeof B.code=="string",$=B=>typeof B=="object"&&B!==null&&"code"in B&&typeof B.code=="string",T=()=>{const B=l.confirmSelection();if(_(B)){f(B);return}i("confirm",{...B,dirty:p.value})},x=(B="user")=>{i("cancel",{dirty:p.value,reason:B,sessionId:l.sessionId})},I=async()=>{d.value="albums",await l.loadAlbums()},Z=async()=>{await l.goToLibrary(),d.value="albums",await l.loadAlbums()},S=B=>{l.setView({scope:"album",albumId:B.id,albumName:B.name}),d.value="media"},L=async(B,D)=>{const k=l.view.value,F=await l.createAlbum(B,D);if($(F)){f(F);return}u.value=!1,d.value="media",i("view-change",{from:k,to:{scope:"album",albumId:F.id,albumName:F.name},reason:"inline-album-created",restoredFromSession:!1})},R=async B=>{if(a.uploadBehavior==="delegate"){i("request-upload-files",{files:[...B],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(B)};function P(B){var D;return B?B.thumbnail_url??((D=B.conversion_urls)==null?void 0:D.thumb)??B.preview_url??B.original_url??B.url??null:null}function A(B){return B!=null&&B.mime_type?B.mime_type.startsWith("image/"):!1}return e.watch(()=>c.value,B=>{C(),h=window.setTimeout(()=>{l.setQuery(B)},250)}),e.watch(()=>l.selectedItems.value,()=>{b()},{deep:!0}),e.watch(()=>l.error.value,B=>{f(B)}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{C()}),n({refresh:l.refresh}),(B,D)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":B.testIdPrefix},[e.createElementVNode("header",B4,[e.createElementVNode("div",I4,[N.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mlp-location-bar__back","aria-label":"Back to library","data-testid":"btn-media-picker-back",onClick:Z},[...D[8]||(D[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",F4,e.toDisplayString(w.value),1)])]),e.createElementVNode("nav",$4,[B.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:D[0]||(D[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:D[1]||(D[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:I},e.toDisplayString(r.value.browseAlbums),3)]),d.value==="media"||d.value==="albums"?(e.openBlock(),e.createElementBlock("div",R4,[D[9]||(D[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":D[2]||(D[2]=k=>c.value=k),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,D4),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),B.enableUpload&&d.value==="upload"?(e.openBlock(),e.createBlock(Md,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:B.accept,"upload-label":r.value.uploadLabel,onClose:D[3]||(D[3]=k=>d.value="media"),onFilesSelected:R},null,8,["queue","accept","upload-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",A4,[e.createVNode(Sd,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:D[4]||(D[4]=k=>u.value=!1),onCreate:L},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(Vd,{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",L4,[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:D[5]||(D[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(Id,{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":`${B.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(Td,{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":B.enableAlbumCreation,onSelectLibrary:Z,onSelectAlbum:S,onCreateAlbum:D[6]||(D[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),B.showFooter?(e.openBlock(),e.createElementBlock("footer",U4,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",O4,[e.createElementVNode("span",z4,e.toDisplayString(y.value),1),e.createElementVNode("div",P4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,k=>{var F,H,j;return e.openBlock(),e.createElementBlock("div",{key:k.id,class:"mlp-bottom-bar__thumb-item"},[A(k.media)&&P(k.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:P(k.media),alt:((F=k.media)==null?void 0:F.alt_text)??((H=k.media)==null?void 0:H.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,W4)):(e.openBlock(),e.createElementBlock("div",j4,[...D[10]||(D[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} ${((j=k.media)==null?void 0:j.file_name)??k.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:te=>e.unref(l).removeSelected(k.id)},[...D[11]||(D[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,Z4)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",H4,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:D[7]||(D[7]=k=>x())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:T},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),B.enablePreview?(e.openBlock(),e.createBlock(Nd,{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,M4))}}),zd=Ce(X4,[["__scopeId","data-v-db2ced73"]]),G4={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},J4={class:"media-library-picker-modal__panel"},Y4=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",G4,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",J4,[e.createVNode(zd,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)}}),q4=Ce(Y4,[["__scopeId","data-v-a92e8703"]]),K4={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},Q4={class:"media-selection-tray__header"},e3={class:"media-selection-tray__title"},t3={class:"media-selection-tray__items"},n3={class:"media-selection-tray__item-preview"},a3=["src","alt"],o3={key:1,class:"media-selection-tray__file-icon"},i3={class:"media-selection-tray__item-copy"},r3=["aria-label","onClick"],s3=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",K4,[e.createElementVNode("header",Q4,[e.createElementVNode("h3",e3,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",t3,[(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",n3,[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,a3)):(e.openBlock(),e.createElementBlock("div",o3,[...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",i3,[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,r3)])}),128))])])):e.createCommentVNode("",!0)}}),l3=Ce(s3,[["__scopeId","data-v-f2a3d69d"]]);function ts(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=N=>{if(r.value++,l.value=null,i.value=null,t.value=!1,N!=null&&typeof N=="object"&&!(N instanceof Blob)&&("image"in N||"state"in N||"sessionKey"in N)){const C=N;a.value=C.image??null,s.value=C.state??null}else a.value=N??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 N=>{try{return t.value=!0,i.value=N,o.onSave&&await o.onSave(N),u(),N}catch(C){const b=C;throw l.value=b,o.onError&&o.onError(b),b}finally{t.value=!1}},h=()=>{o.onCancel&&o.onCancel(),u()},p=N=>{l.value=N,o.onError&&o.onError(N)},v=()=>{l.value=null},y=()=>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:y}}let er=null;function c3(o){return er||(er=ts(o)),er}function d3(o){return n=>new Promise((t,a)=>{ts({...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 ns(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 Cr(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 as(o){if(o){const t={};o.apiBaseUrl!==void 0&&(t.apiBaseUrl=o.apiBaseUrl),o.isAdmin!==void 0&&(t.isAdmin=o.isAdmin),Hn(t)}return{name:"mediables",async upload(t,a){const r=await St().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 St().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await St().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await St().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await St().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await St().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return St().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 St().deleteMedia(t)},async update(t,a){const r=await St().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),Hn(a)}}}let Co=null;function u3(){return Co||(Co=as()),Co}function m3(){Co=null}const p3={apiBaseUrl:"/media-library-pro"};function po(){var o;return typeof document>"u"?null:((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||null}function tr(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 os(o){const n={...p3,...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||po();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=tr(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||po();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(tr)}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||po();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||po();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 tr(c)},configure(a){Object.assign(n,a)}}}let So=null;function f3(){return So||(So=os()),So}function h3(){So=null}function Pd(o,n){switch(o){case"mediables":return as(n);case"spatie":return os(n);default:throw new Error(`Unknown adapter: ${o}`)}}function Wd(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(C,b,f){n&&("dataTransfer"in C&&C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",String(f))),d=C.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:b},c.value=!0,a==null||a(b,f))}function m(C,b){var f;if(!(!n||!l.value.isDragging)&&(C.preventDefault(),l.value.dropIndex!==b)){const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s);const $=(f=C.target)==null?void 0:f.closest("[data-index]");$==null||$.classList.add(s),l.value.dropIndex=b}}function h(){if(!l.value.isDragging)return;const{dragIndex:C,dropIndex:b,draggedItem:f}=l.value;d&&d.classList.remove(r);const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s),C!==null&&b!==null&&C!==b&&f&&(t==null||t({fromIndex:C,toIndex:b,item:f})),v(),i==null||i()}function p(){d&&d.classList.remove(r);const C=document.querySelector(`.${s}`);C==null||C.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 y(C,b,f){const _=[...C],[$]=_.splice(b,1);return _.splice(f,0,$),_.map((T,x)=>({...T,order:x}))}function w(C,b){return{draggable:n,"data-index":b,onDragstart:f=>u(f,C,b),onDragover:f=>m(f,b),onDragend:()=>h(),onDrop:f=>{f.preventDefault(),h()}}}function N(C){C.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",N)}),e.onUnmounted(()=>{document.removeEventListener("keydown",N),p()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:m,endDrag:h,cancelDrag:p,reorderItems:y,getDragProps:w}}function di(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:y,onUploadComplete:w,onUploadError:N,onRemove:C,onReorder:b,onError:f,onReadyToSubmitChange:_}=o,$={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},T=h||Pd(m),x=e.ref([]),I=e.ref(!1),Z=e.ref([]);function S(re){if(re.length===0)return[];const ce=re[0];return"media"in ce&&"clientId"in ce?re:Cr(re)}x.value=S(n);const{acceptString:L,canAddFiles:R}=Kr({rules:$}),P=Qr({adapter:T,maxConcurrent:p,rules:$,collection:i,onUploadStart:re=>{y==null||y(re)},onUploadComplete:(re,ce)=>{const _e=x.value.findIndex(Ve=>Ve.clientId===re.id);_e!==-1&&(x.value[_e]={...x.value[_e],media:ce,name:ce.name||ce.file_name,upload:{...re,status:"completed"}}),w==null||w(ce)},onUploadError:(re,ce)=>{const _e=x.value.findIndex(Ve=>Ve.clientId===re.id);_e!==-1&&(x.value[_e]={...x.value[_e],upload:{...re,status:"error",error:ce.message},errors:[{field:"upload",message:ce.message,code:"UPLOAD_ERROR"}]}),N==null||N({file:re.file,message:ce.message})},onQueueComplete:()=>{v==null||v(x.value)}}),{dragState:A,getDragProps:B,reorderItems:D}=Wd({enabled:c&&!d,onReorder:re=>{x.value=D(x.value,re.fromIndex,re.toIndex),b==null||b(x.value),v==null||v(x.value)}}),k=e.computed(()=>P.isUploading.value),F=e.computed(()=>!P.isUploading.value&&P.pendingCount.value===0),H=e.computed(()=>r?x.value.length>=r:!1),j=e.computed(()=>ns(x.value)),te=e.computed(()=>x.value.length),he=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch(F,re=>{_==null||_(re)});function ge(re){x.value=S(re),v==null||v(x.value)}async function ae(re){if(d)return;const ce=Array.from(re);if(!R(ce.length,x.value.length)){const He={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};Z.value=[He],f==null||f([He]);return}const _e=await P.addFiles(ce),Ve=x.value.length,ut=_e.map((He,xt)=>({...He,order:Ve+xt}));x.value=[...x.value,...ut],v==null||v(x.value)}function V(re){d||(re.upload&&(re.upload.status==="uploading"||re.upload.status==="pending")&&P.cancelUpload(re.clientId),x.value=x.value.filter(ce=>ce.clientId!==re.clientId),x.value=x.value.map((ce,_e)=>({...ce,order:_e})),C==null||C(re),v==null||v(x.value))}function U(re){const ce=x.value.find(_e=>_e.clientId===re);ce&&V(ce)}function K(){d||(P.clearAll(),x.value=[],v==null||v(x.value))}function ee(re,ce){d||!c||(x.value=D(x.value,re,ce),b==null||b(x.value),v==null||v(x.value))}function ne(re,ce){if(d)return;const _e=x.value.findIndex(Ve=>Ve.clientId===re);_e!==-1&&(x.value[_e]={...x.value[_e],...ce},v==null||v(x.value))}function fe(re){P.cancelUpload(re),U(re)}async function ie(re){await P.retryUpload(re)}async function pe(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const re={modelType:t,modelId:a,collection:i},ce=x.value.filter(_e=>_e.media&&!_e.markedForRemoval).map(_e=>_e.media.uuid);I.value=!0;try{await T.attachMany(ce,re),await T.reorder(re,ce)}finally{I.value=!1}}async function ke(){if(!t||!a)throw new Error("modelType and modelId are required for load()");const re={modelType:t,modelId:a,collection:i};I.value=!0;try{const ce=await T.fetchModelMedia(re);x.value=Cr(ce),v==null||v(x.value)}finally{I.value=!1}}return e.onMounted(()=>{t&&a&&n.length===0&&ke().catch(console.error)}),e.onUnmounted(()=>{P.clearAll()}),{items:x,setItems:ge,addFiles:ae,removeItem:V,removeItemById:U,clearAll:K,reorderItems:ee,updateItem:ne,cancelUpload:fe,retryUpload:ie,save:pe,load:ke,isLoading:I,isUploading:k,isReadyToSubmit:F,isAtMaxItems:H,errors:Z,dragState:A,getDragProps:B,adapter:T,formValues:j,acceptString:L,count:te,remainingSlots:he}}const v3=["aria-disabled"],g3=["accept","multiple","disabled"],y3={class:"media-dropzone__content"},b3={class:"media-dropzone__title"},w3={class:"media-dropzone__subtitle"},k3=["disabled"],_3={key:0,class:"media-dropzone__helper"},E3=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 y=[];return t.maxFileSize&&y.push(`Max size: ${Lo(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&y.push(`Max files: ${t.maxItems}`),y.join(" • ")});function c(y){y.preventDefault(),!t.disabled&&(i.value=!0)}function d(y){y.preventDefault(),i.value=!1}function u(y){y.preventDefault()}function m(y){var N;if(y.preventDefault(),i.value=!1,t.disabled)return;const w=(N=y.dataTransfer)==null?void 0:N.files;w&&w.length>0&&a("files",w)}function h(){var y;t.disabled||(y=r.value)==null||y.click()}function p(y){const w=y.target,N=w.files;N&&N.length>0&&a("files",N),w.value=""}function v(y){(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),h())}return(y,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":y.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:y.accept,multiple:y.multiple,disabled:y.disabled,class:"media-dropzone__input",onChange:p},null,40,g3),e.createElementVNode("div",y3,[e.renderSlot(y.$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",b3,[e.renderSlot(y.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(y.title),1)],!0)]),e.createElementVNode("p",w3,[e.renderSlot(y.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(y.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:y.disabled,onClick:e.withModifiers(h,["stop"])},[e.renderSlot(y.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(y.buttonText),1)],!0)],8,k3),l.value?(e.openBlock(),e.createElementBlock("p",_3,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,v3))}}),is=Ce(E3,[["__scopeId","data-v-b1366c1e"]]),x3=["data-index"],C3={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},S3={class:"media-item__thumbnail"},V3=["src","alt"],N3={key:1,class:"media-item__file-icon"},T3={key:2,class:"media-item__progress-overlay"},M3={class:"media-item__progress-text"},B3={key:3,class:"media-item__processing-overlay"},I3={key:4,class:"media-item__error-overlay"},F3={class:"media-item__info"},$3=["title"],R3={key:0,class:"media-item__size"},D3={key:1,class:"media-item__error-message"},A3={class:"media-item__actions"},L3=["disabled"],U3=["disabled"],O3=["disabled"],z3=["disabled"],P3=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 T,x;const b=((T=t.item.media)==null?void 0:T.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!b)return"";const f=1024,_=["Bytes","KB","MB","GB"],$=Math.floor(Math.log(b)/Math.log(f));return parseFloat((b/Math.pow(f,$)).toFixed(2))+" "+_[$]}),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 y(){t.disabled||a("remove",t.item)}function w(){t.disabled||a("edit",t.item)}function N(){t.disabled||a("retry",t.item)}function C(){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",C3,[...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",S3,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,V3)):(e.openBlock(),e.createElementBlock("div",N3,[...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",T3,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",M3,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",B3,[...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",I3,[...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",F3,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,$3),h.value?(e.openBlock(),e.createElementBlock("span",R3,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",D3,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",A3,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:b.disabled,"aria-label":"Cancel upload",onClick:C},[...f[6]||(f[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,L3)):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:N},[...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,U3)):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,O3)):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:y},[...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,z3)):e.createCommentVNode("",!0)])],42,x3))}}),rs=Ce(P3,[["__scopeId","data-v-ff81c9ec"]]),W3=["aria-label"],j3=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],Z3={key:0,class:"media-collection__footer"},H3={class:"media-collection__count"},X3={key:0},G3={key:0,class:"media-collection__uploading"},J3=["name","value"],Y3=["name","value"],q3=["name","value"],K3=["name","value"],Q3={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},eN=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:y,dragState:w,getDragProps:N,adapter:C,formValues:b,acceptString:f,count:_,remainingSlots:$}=di(i);e.provide("mediaAdapter",C),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,k=>{k!==r.value&&s(k)},{deep:!0});const T=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),x=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 I(k){l(k)}function Z(k){c(k)}function S(k){m(k.clientId)}function L(k){u(k.clientId)}function R(k){}function P(k,F,H){if(!t.sortable||t.disabled)return;const j=N(F,H);j.onDragstart&&j.onDragstart(k)}function A(k,F){if(!t.sortable||t.disabled)return;k.preventDefault();const H=r.value[F],j=N(H,F);j.onDragover&&j.onDragover(k)}function B(k,F){const H=N(k,F);H.onDragend&&H.onDragend()}function D(k,F){k.preventDefault();const H=r.value[F],j=N(H,F);j.onDrop&&j.onDrop(k)}return(k,F)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(k.$slots,"dropzone",{addFiles:e.unref(l)},()=>[T.value?(e.openBlock(),e.createBlock(is,{key:0,accept:e.unref(f),multiple:k.maxItems!==1,disabled:k.disabled,"max-file-size":k.maxFileSize,"max-items":e.unref($),onFiles:I},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),(H,j)=>e.renderSlot(k.$slots,"item",{key:H.clientId,item:H,index:j,remove:()=>Z(H)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(w).dropIndex===j}]),draggable:k.sortable&&!k.disabled,"data-index":j,onDragstart:te=>P(te,H,j),onDragover:te=>A(te,j),onDragend:te=>B(H,j),onDrop:te=>D(te,j)},[e.createVNode(rs,{item:H,adapter:e.unref(C),disabled:k.disabled,sortable:k.sortable,"show-remove":!k.readonly,"show-edit":!1,index:j,onRemove:Z,onRetry:S,onCancel:L,onEdit:R},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,j3)],!0)),128))],8,W3)):T.value?e.createCommentVNode("",!0):e.renderSlot(k.$slots,"empty",{key:1},()=>[F[0]||(F[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",Z3,[e.createElementVNode("span",H3,[e.createTextVNode(e.toDisplayString(e.unref(_))+" "+e.toDisplayString(e.unref(_)===1?"file":"files")+" ",1),k.maxItems?(e.openBlock(),e.createElementBlock("span",X3," / "+e.toDisplayString(k.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",G3," 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),(H,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${H.uuid}`,type:"hidden",name:`${k.name}[${j}][uuid]`,value:H.uuid},null,8,J3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(H,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${H.uuid}-name`,type:"hidden",name:`${k.name}[${j}][name]`,value:H.name},null,8,Y3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(H,j)=>(e.openBlock(),e.createElementBlock("input",{key:`${k.name}-${H.uuid}-order`,type:"hidden",name:`${k.name}[${j}][order]`,value:H.order},null,8,q3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(H,j)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${k.name}-${H.uuid}-props`},[H.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[${j}][custom_properties]`,value:JSON.stringify(H.custom_properties)},null,8,K3)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(y).length>0?(e.openBlock(),e.createElementBlock("div",Q3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),H=>(e.openBlock(),e.createElementBlock("p",{key:H.code||H.message,class:"media-collection__error"},e.toDisplayString(H.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),tN=Ce(eN,[["__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:T=>{t==null||t(T[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},p=di(h),v=e.computed(()=>p.items.value[0]||null),y=e.computed(()=>v.value!==null),w=e.computed(()=>p.formValues.value[0]||null);function N(T){T===null?p.clearAll():p.setItems([T])}async function C(T){const x=v.value;x&&p.removeItem(x),await p.addFiles([T])}function b(){v.value&&p.removeItem(v.value)}async function f(T){const x=v.value;x&&p.removeItem(x),await p.addFiles([T]);const I=p.items.value[0];I&&(a==null||a(x,I))}function _(){var T;(T=v.value)!=null&&T.upload&&p.cancelUpload(v.value.clientId)}async function $(){var T,x;((x=(T=v.value)==null?void 0:T.upload)==null?void 0:x.status)==="error"&&await p.retryUpload(v.value.clientId)}return{item:v,setItem:N,addFile:C,removeItem:b,replaceItem:f,cancelUpload:_,retryUpload:$,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:y,errors:p.errors,adapter:p.adapter,formValue:w,acceptString:p.acceptString}}const nN=["accept","disabled"],aN={class:"media-attachment__preview"},oN=["name","value"],iN=["name","value"],rN=["name","value"],sN=["name","value"],lN={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},cN=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:S=>{a("update:modelValue",S),a("change",S)},onUpload:S=>{a("upload",S)},onUploadComplete:S=>{a("upload-complete",S)},onUploadError:S=>{a("upload-error",S)},onRemove:S=>{a("remove",S)},onReplace:(S,L)=>{a("replace",L)},onError:S=>{a("validation-error",S)},onReadyToSubmitChange:S=>{a("is-ready-to-submit-change",S)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,hasItem:v,errors:y,adapter:w,formValue:N,acceptString:C}=ss(r);e.provide("mediaAdapter",w),e.watch(()=>t.modelValue,S=>{S!==s.value&&l(S)},{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 _(S){S.length>0&&c(S[0])}function $(){var S;(S=i.value)==null||S.click()}function T(S){const L=S.target,R=L.files;R&&R.length>0&&u(R[0]),L.value=""}function x(S){d()}function I(S){h()}function Z(S){m()}return(S,L)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(C),disabled:S.disabled,class:"media-attachment__hidden-input",onChange:T},null,40,nN),b.value?e.renderSlot(S.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(is,{accept:e.unref(C),multiple:!1,disabled:S.disabled,"max-file-size":S.maxFileSize,onFiles:_},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(S.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:$},()=>[e.createElementVNode("div",aN,[e.createVNode(rs,{item:e.unref(s),adapter:e.unref(w),disabled:S.disabled,sortable:!1,"show-remove":!S.readonly,"show-edit":!1,onRemove:x,onRetry:I,onCancel:Z},null,8,["item","adapter","disabled","show-remove"]),S.showReplaceButton&&!S.readonly&&!S.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:$},[...L[0]||(L[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(S.$slots,"empty",{key:2},()=>[L[1]||(L[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),S.generateFormFields&&e.unref(N)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${S.name}[uuid]`,value:e.unref(N).uuid},null,8,oN),e.createElementVNode("input",{type:"hidden",name:`${S.name}[name]`,value:e.unref(N).name},null,8,iN),e.createElementVNode("input",{type:"hidden",name:`${S.name}[order]`,value:e.unref(N).order},null,8,rN),e.unref(N).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${S.name}[custom_properties]`,value:JSON.stringify(e.unref(N).custom_properties)},null,8,sN)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(y).length>0?(e.openBlock(),e.createElementBlock("div",lN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),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))}}),dN=Ce(cN,[["__scopeId","data-v-26911174"]]),jd={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"}},uN=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:S=>{i("update:modelValue",S),i("change",S)},onUpload:S=>{i("upload",S)},onUploadComplete:S=>{i("upload-complete",S)},onUploadError:S=>{i("upload-error",S)},onRemove:S=>{i("remove",S)},onReorder:S=>{i("reorder",S)},onError:S=>{i("validation-error",S)},onReadyToSubmitChange:S=>{i("is-ready-to-submit-change",S)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:v,isUploading:y,isReadyToSubmit:w,isAtMaxItems:N,errors:C,dragState:b,getDragProps:f,adapter:_,formValues:$,acceptString:T}=di(r);e.provide("mediaAdapter",_),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const x=e.computed(()=>({...jd,...a.labels})),I=e.computed(()=>({accept:T.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||N.value})),Z=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:y.value,isReadyToSubmit:w.value,isAtMaxItems:N.value,errors:C.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(S=>d(S))},cancelUpload:h,retryUpload:p,labels:x.value,dropzoneProps:I.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:h,retryUpload:p,isLoading:v,isUploading:y,isReadyToSubmit:w,isAtMaxItems:N,errors:C,dragState:b,getDragProps:f,adapter:_,formValues:$,acceptString:T}),(S,L)=>e.renderSlot(S.$slots,"default",e.normalizeProps(e.guardReactiveProps(Z.value)))}}),mN=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:x=>{i("update:modelValue",x),i("change",x)},onUpload:x=>{i("upload",x)},onUploadComplete:x=>{i("upload-complete",x)},onUploadError:x=>{i("upload-error",x)},onRemove:x=>{i("remove",x)},onReplace:(x,I)=>{i("replace",I)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:v,isReadyToSubmit:y,hasItem:w,errors:N,adapter:C,formValue:b,acceptString:f}=ss(r);e.provide("mediaAdapter",C),e.watch(()=>a.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const _=e.computed(()=>({...jd,...a.labels})),$=e.computed(()=>({accept:f.value,multiple:!1,disabled:a.disabled||a.readonly||w.value})),T=e.computed(()=>({item:s.value,hasItem:w.value,isLoading:p.value,isUploading:v.value,isReadyToSubmit:y.value,errors:N.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,labels:_.value,dropzoneProps:$.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:h,isLoading:p,isUploading:v,isReadyToSubmit:y,hasItem:w,errors:N,adapter:C,formValue:b,acceptString:f}),(x,I)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(T.value)))}}),pN=["name","value"],fN=["name","value"],hN=["name","value"],vN=["name","value"],gN=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(()=>ns(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,pN),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,fN),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,hN),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,vN)):e.createCommentVNode("",!0)],64))),128))}}),yN=["data-testid"],bN=["data-testid"],wN=["id"],kN=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],_N=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,wN),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,kN)],8,bN))),128))],8,yN)):e.createCommentVNode("",!0)}}),EN=Ce(_N,[["__scopeId","data-v-a153768a"]]),xN="/v1/media/deletion/check",CN="/v1/media/deletion/delete",fo=100;function Xl(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 Zd(o){const n=o.checkEndpoint??xN,t=o.deleteEndpoint??CN,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=Xl(m);if(h.length===0)return r.value=[],[];if(h.length>fo){const p=new Error(`Cannot check more than ${fo} 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(y=>{var w,N,C,b;return{uuid:y.uuid,canDelete:((w=y.report)==null?void 0:w.canDelete)??!1,blocks:Array.isArray((N=y.report)==null?void 0:N.blocks)?y.report.blocks:[],cascade:Array.isArray((C=y.report)==null?void 0:C.cascade)?y.report.cascade:[],variantCount:typeof((b=y.report)==null?void 0:b.variantCount)=="number"?y.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=Xl(m);if(p.length===0){const v={results:[],summary:{}};return s.value=v,v}if(p.length>fo){const v=new Error(`Cannot delete more than ${fo} 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}),y={results:Array.isArray(v==null?void 0:v.results)?v.results:[],summary:(v==null?void 0:v.summary)??{}};return s.value=y,y}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 SN="/v1/user/media/trash";function VN(o){return`/v1/user/media/${encodeURIComponent(o)}/restore`}function Hd(o){const n=o.listEndpoint??SN,t=o.buildRestoreEndpoint??VN,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,y;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((y=w==null?void 0:w.meta)==null?void 0:y.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)),y={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"&&(y.message=v.message),y.status==="restored"&&(i.value=i.value.filter(w=>w.uuid!==p),r.value=Math.max(0,r.value-1)),y}catch(v){const y=NN(v);if(y&&typeof y.status=="string"){const w={status:y.status,duplicate_uuid:typeof y.duplicate_uuid=="string"?y.duplicate_uuid:null};return typeof y.message=="string"&&(w.message=y.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 NN(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 TN={class:"media-management-view","data-testid":"media-management-view"},MN={class:"media-management-view__header"},BN={class:"media-management-view__title"},IN={class:"media-management-view__actions"},FN={key:0,class:"media-management-view__badge"},$N={key:0,class:"media-management-view__panel","data-testid":"panel-library"},RN={key:0,class:"media-management-view__status","data-testid":"library-loading"},DN={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},AN={key:2,class:"media-management-view__empty","data-testid":"library-empty"},LN={key:3,class:"media-management-view__grid","data-testid":"library-grid"},UN=["data-testid"],ON=["data-testid","aria-pressed","onClick"],zN=["src","alt"],PN={key:1,class:"media-management-view__item-placeholder"},WN={class:"media-management-view__item-meta"},jN={class:"media-management-view__item-name"},ZN=["data-testid"],HN={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},XN={key:4,class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},GN={"data-testid":"bulk-count"},JN=["disabled"],YN={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},qN={key:0,class:"media-management-view__status","data-testid":"trash-loading"},KN={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},QN={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},e5=["data-testid"],t5={class:"media-management-view__item-thumb"},n5=["src","alt"],a5={class:"media-management-view__item-meta"},o5={class:"media-management-view__item-name"},i5={key:0,class:"media-management-view__item-meta-line"},r5=["data-testid","disabled","onClick"],s5=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 B,D,k,F,H,j,te,he,ge,ae,V,U;return{title:((B=a.labels)==null?void 0:B.title)??"My Media",libraryTab:((D=a.labels)==null?void 0:D.libraryTab)??"Library",trashTab:((k=a.labels)==null?void 0:k.trashTab)??"Trash",loading:((F=a.labels)==null?void 0:F.loading)??"Loading…",emptyLibrary:((H=a.labels)==null?void 0:H.emptyLibrary)??"No media yet — upload your first creation.",emptyTrash:((j=a.labels)==null?void 0:j.emptyTrash)??"Trash is empty.",orphanedBadge:((te=a.labels)==null?void 0:te.orphanedBadge)??"Not in use",selectedCount:((he=a.labels)==null?void 0:he.selectedCount)??(K=>`${K} selected`),deleteButton:((ge=a.labels)==null?void 0:ge.deleteButton)??"Delete",restoreButton:((ae=a.labels)==null?void 0:ae.restoreButton)??"Restore",purgeAfter:((V=a.labels)==null?void 0:V.purgeAfter)??(K=>`Purges ${K}`),ownerLabel:((U=a.labels)==null?void 0:U.ownerLabel)??(K=>`User ${K.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),y=e.computed(()=>s.value.restoreButton),w=e.ref("library"),N=e.ref({scope:"library"}),C=e.ref({}),b=es({httpClient:a.httpClient,view:N,filters:C,perPage:50}),f=e.computed(()=>b.items.value),_=e.computed(()=>b.loading.value),$=e.computed(()=>{var B;return((B=b.error.value)==null?void 0:B.message)??null}),T=fc(f),x=Zd({httpClient:a.httpClient}),I=Hd({httpClient:a.httpClient});function Z(B){return s.value.selectedCount(B)}function S(B){return s.value.purgeAfter(B)}function L(B){return s.value.ownerLabel(B)}async function R(){const B=T.selectedItems.value;if(B.length===0)return;const D=r.value.canDelete?B.filter(k=>r.value.canDelete(k)):B;if(D.length!==0&&!(a.confirmBulkDelete&&!await a.confirmBulkDelete(D)))try{const k=D.map(j=>j.uuid),H=(await x.deleteMany(k)).results.filter(j=>j.status==="trashed"||j.status==="already_trashed").map(j=>j.uuid);if(H.length>0){for(const j of H)T.deselect(j);i("deleted",H),await b.refresh(),r.value.showTrash!==!1&&await I.fetch(I.currentPage.value).catch(()=>{})}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function P(B){var D;try{const k=await I.restore(B);if(k.status==="restored"){i("restored",B),await b.refresh().catch(()=>{});return}if(k.status==="duplicate_conflict"){i("restore-conflict",{uuid:B,duplicateUuid:k.duplicate_uuid??null}),(D=a.onRestoreCollision)==null||D.call(a,B,k.duplicate_uuid??null);return}}catch(k){i("error",k instanceof Error?k:new Error(String(k)))}}async function A(){w.value="trash",I.items.value.length===0&&!I.isLoading.value&&await I.fetch().catch(B=>{i("error",B instanceof Error?B:new Error(String(B)))})}return e.watch(w,async B=>{B==="library"&&f.value.length===0&&!_.value&&await b.refresh().catch(()=>{})}),e.onMounted(async()=>{await b.refresh().catch(B=>{i("error",B instanceof Error?B:new Error(String(B)))}),r.value.showTrash!==!1&&I.fetch().catch(()=>{})}),n({refresh:()=>b.refresh(),refreshTrash:()=>I.fetch(),selection:T,deletion:x,trash:I}),(B,D)=>(e.openBlock(),e.createElementBlock("div",TN,[e.createElementVNode("header",MN,[e.createElementVNode("h2",BN,e.toDisplayString(l.value),1),e.createElementVNode("div",IN,[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:D[0]||(D[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:A},[e.createTextVNode(e.toDisplayString(d.value)+" ",1),e.unref(I).total.value>0?(e.openBlock(),e.createElementBlock("span",FN,e.toDisplayString(e.unref(I).total.value),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)])]),w.value==="library"?(e.openBlock(),e.createElementBlock("section",$N,[_.value?(e.openBlock(),e.createElementBlock("div",RN,e.toDisplayString(u.value),1)):$.value?(e.openBlock(),e.createElementBlock("div",DN,e.toDisplayString($.value),1)):f.value.length===0?(e.openBlock(),e.createElementBlock("div",AN,e.toDisplayString(m.value),1)):(e.openBlock(),e.createElementBlock("ul",LN,[(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(T).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(T).isSelected(k.uuid),onClick:F=>e.unref(T).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,zN)):(e.openBlock(),e.createElementBlock("span",PN,e.toDisplayString(k.file_name),1))],8,ON),e.createElementVNode("div",WN,[e.createElementVNode("span",jN,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(L(k)),9,ZN)):e.createCommentVNode("",!0),k.is_orphaned?(e.openBlock(),e.createElementBlock("span",HN,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0)])],10,UN))),128))])),e.unref(T).selectedCount.value>0&&r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("footer",XN,[e.createElementVNode("span",GN,e.toDisplayString(Z(e.unref(T).selectedCount.value)),1),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(x).isDeleting.value,onClick:R},e.toDisplayString(v.value),9,JN)])):e.createCommentVNode("",!0)])):w.value==="trash"?(e.openBlock(),e.createElementBlock("section",YN,[e.unref(I).isLoading.value?(e.openBlock(),e.createElementBlock("div",qN,e.toDisplayString(u.value),1)):e.unref(I).items.value.length===0?(e.openBlock(),e.createElementBlock("div",KN,e.toDisplayString(h.value),1)):(e.openBlock(),e.createElementBlock("ul",QN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(I).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",t5,[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,n5)):e.createCommentVNode("",!0)]),e.createElementVNode("div",a5,[e.createElementVNode("span",o5,e.toDisplayString(k.file_name),1),k.purge_after?(e.openBlock(),e.createElementBlock("span",i5,e.toDisplayString(S(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(I).isRestoring.value,onClick:F=>P(k.uuid)},e.toDisplayString(y.value),9,r5)],8,e5))),128))]))])):e.createCommentVNode("",!0)]))}}),l5=Ce(s5,[["__scopeId","data-v-ec535782"]]);exports.AlbumBrowser=Cd;exports.AlbumManager=aV;exports.AlbumMediaGrid=hV;exports.AlbumTree=xd;exports.ArrayBufferTarget=Fr;exports.ExistingMediaSelector=dh;exports.ImageEditor=nc;exports.ImageEditorModal=ac;exports.LiveStreamManager=MS;exports.ManagedMediaGallery=Lm;exports.MediaAlbumInlineCreate=Sd;exports.MediaAlbumUnavailableState=Vd;exports.MediaAttachment=dN;exports.MediaAttachmentMetadataFields=EN;exports.MediaCollection=tN;exports.MediaCollectionDropzone=is;exports.MediaCollectionItem=rs;exports.MediaLibraryPicker=zd;exports.MediaLibraryPickerModal=q4;exports.MediaManagementView=l5;exports.MediaPreviewSheet=Nd;exports.MediaSelectionTray=l3;exports.MediaSourceSheet=Td;exports.MediaThumbnailCell=Bd;exports.MediaUploadSheet=Md;exports.MediaWorkspace=$m;exports.ModelMediaManager=If;exports.Muxer=Mc;exports.VideoEditor=xr;exports.VideoEditorDialog=p_;exports.VideoEditorSimple=A_;exports.VideoExportPanel=vx;exports.VideoJobClient=Yr;exports.VideoPlayer=kd;exports.VideoTimeline=sE;exports.VideoToolsPanel=YE;exports.VideoUploader=aC;exports.VirtualMediaGrid=Id;exports._sfc_main=uN;exports._sfc_main$1=mN;exports._sfc_main$2=gN;exports.applyTemporaryMediaStoreConfig=ql;exports.configureMediaStore=Hn;exports.createAdapter=Pd;exports.createEmptyEditorState=fm;exports.createImageEditor=d3;exports.createMediablesAdapter=as;exports.createSpatieAdapter=os;exports.deserializeEditorState=pm;exports.formatFileSize=Lo;exports.fromMediaArray=Cr;exports.getFileExtension=Fd;exports.getImageDimensions=$d;exports.getMediablesAdapter=u3;exports.getSpatieAdapter=f3;exports.isImageFile=qr;exports.normalizeEditorState=Sr;exports.normalizeRecipeForServerRender=Gk;exports.recipeHasServerRenderableEdits=Xk;exports.recipeHasUnsupportedServerEdits=wd;exports.resetMediablesAdapter=m3;exports.resetSpatieAdapter=h3;exports.restoreMediaStoreConfig=Yl;exports.serializeEditorState=Gl;exports.snapshotMediaStoreConfig=Jl;exports.toFormValues=ns;exports.useAdminMediaStore=Kl;exports.useAlbumDragDrop=Ed;exports.useAlbumStore=ci;exports.useAlbums=_d;exports.useGlobalImageEditor=c3;exports.useImageEditorModal=ts;exports.useMediaAttachment=ss;exports.useMediaCollection=di;exports.useMediaDeletion=Zd;exports.useMediaDragSort=Wd;exports.useMediaLibraryPickerController=Od;exports.useMediaLibraryQuery=es;exports.useMediaLibrarySession=Ad;exports.useMediaLibraryStateMachine=Ld;exports.useMediaLibraryTelemetry=Ud;exports.useMediaStore=St;exports.useMediaTrash=Hd;exports.useMediaUploadQueue=Qr;exports.useMediaValidation=Kr;exports.validateFile=Rd;
|
|
342
|
-
//# sourceMappingURL=index-BUrSZVu3.cjs.map
|