2 lines
44 KiB
JavaScript
2 lines
44 KiB
JavaScript
import{_ as Ee,r as A,c as F,m as ue,a as g,g as u,b as e,j as $,d as Q,w as J,k as se,e as v,F as ne,af as _e,aR as Ce,t as w,Q as He,n as ce,i as ve,b5 as Ae,ac as We,o as ze,b6 as Ke,aP as Ge,b7 as P,b4 as Je,aO as Xe,aW as Re,ae as Ye,aU as Ze,aT as Pe}from"./index-QAlcqU00.js";import{F as me}from"./FPInput-D5RURom0.js";import{F as et}from"./FPCheckbox-DcRYwN3n.js";import{F as tt}from"./FPSelect-j7n_x8eB.js";import{F as Me}from"./FPBadge-DvOitM1C.js";const ot={class:"task-manager"},at={class:"flex items-center justify-between mb-4"},rt={key:0,class:"space-y-3"},st={class:"flex items-start space-x-3"},nt={class:"flex-1 min-w-0"},it={class:"mb-2"},lt=["onClick"],dt={key:0,class:"mb-2"},ct={class:"flex items-center space-x-4 text-xs text-gray-500"},ut={key:0},vt={key:1},mt={key:2},gt={key:1,class:"flex items-center space-x-2 mt-2"},pt=["onClick"],ft=["onClick"],yt=["onClick"],ht=["onMousedown"],wt={key:1,class:"text-center py-8 text-gray-500"},xt={key:2,class:"mt-6 p-4 bg-gray-50 rounded-lg"},bt={class:"flex items-center justify-between mb-2"},kt={class:"text-sm text-gray-600"},Rt={class:"w-full bg-gray-200 rounded-full h-2"},_t={class:"text-xs text-gray-500 mt-1"},Ct={key:3,class:"mt-4 border-t pt-4"},St={class:"flex flex-wrap gap-2"},$t=["onClick"],Tt={__name:"TaskManager",props:{modelValue:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},showTemplates:{type:Boolean,default:!0}},emits:["update:modelValue"],setup(p,{emit:_}){const x=p,X=_,l=A([...x.modelValue]),y=A(null),R=[{name:"Safety Check",description:"Verify all safety protocols and equipment"},{name:"Visual Inspection",description:"Perform visual inspection of equipment"},{name:"Clean Equipment",description:"Clean and sanitize equipment"},{name:"Test Function",description:"Test equipment functionality"},{name:"Document Results",description:"Document findings and results"},{name:"Parts Check",description:"Check parts inventory and condition"}],j=F(()=>l.value.filter(n=>n.completed).length),U=F(()=>l.value.length===0?0:Math.round(j.value/l.value.length*100)),D=()=>{const n={id:Date.now()+Math.random(),name:"",description:"",completed:!1,assignedTo:"",dueDate:null,estimatedTime:null,order:l.value.length,editing:!0};l.value.push(n),m(),We(()=>{const a=y.value;if(a&&a.length>0){const d=a[a.length-1];d==null||d.focus()}})},W=n=>{const a={id:Date.now()+Math.random(),name:n.name,description:n.description,completed:!1,assignedTo:"",dueDate:null,estimatedTime:null,order:l.value.length,editing:!1};l.value.push(a),m()},ae=n=>{l.value.splice(n,1),m()},f=n=>{const a=l.value[n],d={...a,id:Date.now()+Math.random(),name:`${a.name} (Copy)`,completed:!1,editing:!1};l.value.splice(n+1,0,d),m()},N=(n,a,d)=>{l.value[n]&&(l.value[n][a]=d,m())},I=n=>{x.disabled||(l.value[n].editing=!0)},q=n=>{l.value[n].editing=!1,m()},B=(n,a)=>{console.log("Drag started for task:",n)},V=n=>n?new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric"}):"",m=()=>{X("update:modelValue",l.value)};return ue(()=>x.modelValue,n=>{l.value=[...n]},{deep:!0}),(n,a)=>(u(),g("div",ot,[e("div",at,[a[1]||(a[1]=e("h3",{class:"text-lg font-medium text-gray-900"},"Tasks & Checklist",-1)),Q(v(ne),{variant:"outline",size:"sm",onClick:D,disabled:p.disabled},{default:J(()=>a[0]||(a[0]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),se(" Add Task ",-1)])),_:1,__:[0]},8,["disabled"])]),l.value.length>0?(u(),g("div",rt,[(u(!0),g(_e,null,Ce(l.value,(d,C)=>(u(),g("div",{key:d.id||C,class:ce(["task-item border border-gray-200 rounded-lg p-4 transition-all duration-200",{"bg-green-50 border-green-200":d.completed,"bg-white":!d.completed}])},[e("div",st,[Q(v(et),{modelValue:d.completed,"onUpdate:modelValue":[S=>d.completed=S,S=>N(C,"completed",S)],disabled:p.disabled,class:"mt-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("div",nt,[e("div",it,[d.editing?(u(),ve(v(me),{key:0,modelValue:d.name,"onUpdate:modelValue":S=>d.name=S,placeholder:"Enter task name",onBlur:S=>q(C),onKeyup:Ae(S=>q(C),["enter"]),class:"mb-2",ref_for:!0,ref_key:"taskNameInput",ref:y},null,8,["modelValue","onUpdate:modelValue","onBlur","onKeyup"])):(u(),g("h4",{key:1,class:ce(["font-medium text-gray-900 cursor-pointer hover:text-primary-600",{"line-through text-gray-500":d.completed}]),onClick:S=>I(C)},w(d.name||"Untitled Task"),11,lt))]),d.description||d.editing?(u(),g("div",dt,[d.editing?(u(),ve(v(me),{key:0,modelValue:d.description,"onUpdate:modelValue":S=>d.description=S,placeholder:"Enter task description (optional)",type:"textarea",rows:"2",onBlur:S=>q(C)},null,8,["modelValue","onUpdate:modelValue","onBlur"])):d.description?(u(),g("p",{key:1,class:ce(["text-sm text-gray-600",{"line-through":d.completed}])},w(d.description),3)):$("",!0)])):$("",!0),e("div",ct,[d.assignedTo?(u(),g("span",ut," Assigned to: "+w(d.assignedTo),1)):$("",!0),d.dueDate?(u(),g("span",vt," Due: "+w(V(d.dueDate)),1)):$("",!0),d.estimatedTime?(u(),g("span",mt," Est: "+w(d.estimatedTime)+"h ",1)):$("",!0)]),p.disabled?$("",!0):(u(),g("div",gt,[e("button",{onClick:S=>I(C),class:"text-xs text-primary-600 hover:text-primary-700"}," Edit ",8,pt),e("button",{onClick:S=>f(C),class:"text-xs text-gray-600 hover:text-gray-700"}," Duplicate ",8,ft),e("button",{onClick:S=>ae(C),class:"text-xs text-red-600 hover:text-red-700"}," Delete ",8,yt)]))]),p.disabled?$("",!0):(u(),g("div",{key:0,class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 p-1",onMousedown:S=>B(C)},a[2]||(a[2]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h16M4 18h16"})],-1)]),40,ht))])],2))),128))])):(u(),g("div",wt,a[3]||(a[3]=[e("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})],-1),e("p",{class:"text-sm"},"No tasks added yet",-1),e("p",{class:"text-xs text-gray-400 mt-1"},'Click "Add Task" to create your first task',-1)]))),l.value.length>0?(u(),g("div",xt,[e("div",bt,[a[4]||(a[4]=e("span",{class:"text-sm font-medium text-gray-700"},"Progress",-1)),e("span",kt,w(j.value)+"/"+w(l.value.length)+" completed",1)]),e("div",Rt,[e("div",{class:"bg-green-500 h-2 rounded-full transition-all duration-300",style:He({width:`${U.value}%`})},null,4)]),e("p",_t,w(U.value)+"% complete",1)])):$("",!0),!p.disabled&&p.showTemplates?(u(),g("div",Ct,[a[5]||(a[5]=e("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Quick Templates",-1)),e("div",St,[(u(),g(_e,null,Ce(R,d=>e("button",{key:d.name,onClick:C=>W(d),class:"px-3 py-1 text-xs bg-blue-50 text-blue-700 rounded-full hover:bg-blue-100 transition-colors"},w(d.name),9,$t)),64))])])):$("",!0)]))}},ra=Ee(Tt,[["__scopeId","data-v-6486dd79"]]),Dt={class:"parts-manager"},Mt={class:"flex items-center justify-between mb-4"},At={key:0,class:"space-y-3"},Et={class:"grid grid-cols-12 gap-4 items-center"},zt={class:"col-span-5"},Vt={key:1,class:"flex items-center"},Ft={class:"flex-1"},Ut={class:"font-medium text-gray-900"},Bt={key:0,class:"text-sm text-gray-600"},Pt={class:"text-xs text-gray-500"},Lt={class:"col-span-2"},Nt={class:"col-span-2 text-center"},jt={class:"col-span-2 text-center"},qt={class:"text-sm font-medium text-gray-900"},Ot={class:"col-span-1 flex justify-end"},Qt={class:"flex items-center space-x-1"},It=["onClick"],Ht=["onClick"],Wt=["onClick"],Kt={key:0,class:"mt-3 p-2 bg-red-100 border border-red-200 rounded"},Gt={class:"flex items-center"},Jt={class:"text-sm text-red-700"},Xt={key:1,class:"text-center py-8 text-gray-500"},Yt={key:2,class:"mt-6 p-4 bg-gray-50 rounded-lg"},Zt={class:"flex items-center justify-between mb-2"},eo={class:"text-sm text-gray-600"},to={class:"grid grid-cols-2 gap-4 text-sm"},oo={class:"ml-2 font-medium text-gray-900"},ao={__name:"PartsManager",props:{modelValue:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(p,{emit:_}){const x=p,X=_,l=A([...x.modelValue]),y=A([]),R=A(!1),j=F(()=>y.value.map(m=>{var n;return{value:m.id,title:`${m.partNumber} - ${m.name}`,subtitle:`Stock: ${m.quantity} | Cost: $${((n=m.unitCost)==null?void 0:n.toFixed(2))||"0.00"}`,data:m}})),U=F(()=>l.value.reduce((m,n)=>m+n.quantity*(n.unitCost||0),0)),D=F(()=>l.value.filter(m=>m.quantity>m.availableQuantity).length),W=async()=>{try{R.value=!0;const m=await Ke.getAll();y.value=m}catch(m){console.error("Failed to load parts:",m)}finally{R.value=!1}},ae=()=>{const m={id:Date.now()+Math.random(),partId:null,partNumber:"",name:"",description:"",location:"",quantity:1,availableQuantity:0,unitCost:0,editing:!0};l.value.push(m),V()},f=m=>{l.value.splice(m,1),V()},N=(m,n,a)=>{l.value[m]&&(l.value[m][n]=a,V())},I=(m,n)=>{var d;const a=y.value.find(C=>C.id===n);a&&l.value[m]&&(l.value[m]={...l.value[m],partId:a.id,partNumber:a.partNumber,name:a.name,description:a.description,location:((d=a.location)==null?void 0:d.name)||"Unknown",availableQuantity:a.quantity||0,unitCost:a.unitCost||0},V())},q=m=>{x.disabled||(l.value[m].editing=!0)},B=m=>{l.value[m].editing=!1,V()},V=()=>{X("update:modelValue",l.value)};return ue(()=>x.modelValue,m=>{l.value=[...m]},{deep:!0}),ze(()=>{W()}),(m,n)=>(u(),g("div",Dt,[e("div",Mt,[n[1]||(n[1]=e("h3",{class:"text-lg font-medium text-gray-900"},"Parts & Inventory",-1)),Q(v(ne),{variant:"outline",size:"sm",onClick:ae,disabled:p.disabled},{default:J(()=>n[0]||(n[0]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),se(" Add Part ",-1)])),_:1,__:[0]},8,["disabled"])]),l.value.length>0?(u(),g("div",At,[(u(!0),g(_e,null,Ce(l.value,(a,d)=>(u(),g("div",{key:a.id||d,class:ce(["part-item border border-gray-200 rounded-lg p-4 transition-all duration-200",{"border-red-200 bg-red-50":a.quantity>a.availableQuantity,"bg-white":a.quantity<=a.availableQuantity}])},[e("div",Et,[e("div",zt,[a.editing?(u(),ve(v(tt),{key:0,modelValue:a.partId,"onUpdate:modelValue":[C=>a.partId=C,C=>I(d,C)],placeholder:"Search for part...",options:j.value,loading:R.value,searchable:"",required:""},null,8,["modelValue","onUpdate:modelValue","options","loading"])):(u(),g("div",Vt,[e("div",Ft,[e("h4",Ut,w(a.partNumber)+" - "+w(a.name),1),a.description?(u(),g("p",Bt,w(a.description),1)):$("",!0),e("p",Pt," Location: "+w(a.location||"Not specified"),1)])]))]),e("div",Lt,[Q(v(me),{modelValue:a.quantity,"onUpdate:modelValue":[C=>a.quantity=C,C=>N(d,"quantity",C)],modelModifiers:{number:!0},type:"number",min:"1",max:a.availableQuantity,placeholder:"Qty",disabled:p.disabled,error:a.quantity>a.availableQuantity},null,8,["modelValue","onUpdate:modelValue","max","disabled","error"])]),e("div",Nt,[e("span",{class:ce(["text-sm font-medium",{"text-red-600":a.availableQuantity<5,"text-yellow-600":a.availableQuantity>=5&&a.availableQuantity<20,"text-green-600":a.availableQuantity>=20}])},w(a.availableQuantity||0)+" available ",3),n[2]||(n[2]=e("p",{class:"text-xs text-gray-500"},"in stock",-1))]),e("div",jt,[e("span",qt," $"+w((a.unitCost||0).toFixed(2)),1),n[3]||(n[3]=e("p",{class:"text-xs text-gray-500"},"per unit",-1))]),e("div",Ot,[e("div",Qt,[!a.editing&&!p.disabled?(u(),g("button",{key:0,onClick:C=>q(d),class:"p-1 text-gray-400 hover:text-gray-600 rounded",title:"Edit part"},n[4]||(n[4]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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,It)):$("",!0),a.editing?(u(),g("button",{key:1,onClick:C=>B(d),class:"p-1 text-green-500 hover:text-green-600 rounded",title:"Save changes"},n[5]||(n[5]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1)]),8,Ht)):$("",!0),p.disabled?$("",!0):(u(),g("button",{key:2,onClick:C=>f(d),class:"p-1 text-red-400 hover:text-red-600 rounded",title:"Remove part"},n[6]||(n[6]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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,Wt))])])]),a.quantity>a.availableQuantity?(u(),g("div",Kt,[e("div",Gt,[n[7]||(n[7]=e("svg",{class:"w-4 h-4 text-red-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.854-.833-2.598 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),e("span",Jt," Insufficient stock! Requested "+w(a.quantity)+", only "+w(a.availableQuantity)+" available. ",1)])])):$("",!0)],2))),128))])):(u(),g("div",Xt,n[8]||(n[8]=[e("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})],-1),e("p",{class:"text-sm"},"No parts added yet",-1),e("p",{class:"text-xs text-gray-400 mt-1"},'Click "Add Part" to include inventory items',-1)]))),l.value.length>0?(u(),g("div",Yt,[e("div",Zt,[n[9]||(n[9]=e("span",{class:"text-sm font-medium text-gray-700"},"Parts Summary",-1)),e("span",eo,w(l.value.length)+" part(s)",1)]),e("div",to,[e("div",null,[n[10]||(n[10]=e("span",{class:"text-gray-600"},"Total Estimated Cost:",-1)),e("span",oo,"$"+w(U.value.toFixed(2)),1)]),e("div",null,[n[11]||(n[11]=e("span",{class:"text-gray-600"},"Stock Issues:",-1)),e("span",{class:ce(["ml-2 font-medium",D.value>0?"text-red-600":"text-green-600"])},w(D.value>0?`${D.value} item(s)`:"None"),3)])])])):$("",!0)]))}},sa=Ee(ao,[["__scopeId","data-v-86dbbb2a"]]),ro=Ge("audioRecording",()=>{const p=A(new Map),_=A(new Map),x=A(new Map),X=A([]),l=A({}),y=A(!1),R=A(null),j=A(!1),U=A(0),D=A(new Map),W=A(new Map),ae=F(()=>r=>p.value.get(r)||[]),f=F(()=>r=>_.value.get(r)),N=F(()=>r=>_.value.has(r)),I=F(()=>r=>x.value.get(r)),q=F(()=>r=>(p.value.get(r)||[]).reduce((c,h)=>c+(h.duration||0),0)),B=F(()=>r=>(p.value.get(r)||[]).reduce((c,h)=>c+(h.size||0),0)),V=F(()=>r=>(p.value.get(r)||[]).filter(c=>c.transcription).length),m=F(()=>r=>D.value.get(r)),n=F(()=>r=>W.value.get(r)),a=async r=>{try{y.value=!0,R.value=null;const s=await P.getByWorkOrderId(r);return p.value.set(r,s),s}catch(s){throw R.value=s.message||"Failed to load recordings",s}finally{y.value=!1}},d=async(r,s)=>{try{y.value=!0,R.value=null;const c=await P.upload({...s,workOrderId:r}),h=p.value.get(r)||[];return p.value.set(r,[c,...h]),c}catch(c){throw R.value=c.message||"Failed to upload recording",c}finally{y.value=!1}},C=async(r,s,c)=>{try{y.value=!0,R.value=null;const h=await P.update(s,c),z=p.value.get(r)||[],oe=z.findIndex(de=>de.id===s);return oe!==-1&&(z[oe]=h,p.value.set(r,[...z])),h}catch(h){throw R.value=h.message||"Failed to update recording",h}finally{y.value=!1}},S=async(r,s)=>{try{y.value=!0,R.value=null,await P.delete(s);const h=(p.value.get(r)||[]).filter(z=>z.id!==s);return p.value.set(r,h),D.value.delete(s),W.value.delete(s),x.value.delete(s),!0}catch(c){throw R.value=c.message||"Failed to delete recording",c}finally{y.value=!1}},ee=async(r,s,c={})=>{try{if(y.value=!0,R.value=null,_.value.has(r))throw new Error("User already has an active recording session");const h=await P.startRecordingSession({userId:r,workOrderId:s,...c});return _.value.set(r,{...h,workOrderId:s,startTime:new Date,localDuration:0}),U.value=_.value.size,j.value=U.value>0,h}catch(h){throw R.value=h.message||"Failed to start recording session",h}finally{y.value=!1}},te=async(r,s)=>{try{y.value=!0,R.value=null;const c=_.value.get(r);if(!c)throw new Error("No active recording session found for user");const h=await P.stopRecordingSession(c.id,s),z=c.workOrderId,oe=p.value.get(z)||[];return p.value.set(z,[h,...oe]),_.value.delete(r),U.value=_.value.size,j.value=U.value>0,h}catch(c){throw R.value=c.message||"Failed to stop recording session",c}finally{y.value=!1}},ie=(r,s)=>{const c=_.value.get(r);c&&(c.localDuration=s,_.value.set(r,{...c}))},K=async(r,s={})=>{try{y.value=!0,R.value=null;const c=await P.transcribe(r,s);return x.value.set(r,{...c,status:"pending",startedAt:new Date().toISOString()}),O(r),c}catch(c){throw R.value=c.message||"Failed to start transcription",c}finally{y.value=!1}},O=async r=>{try{const s=await P.getTranscriptionStatus(r);x.value.set(r,s),s.status==="completed"?re(r,s.transcription):s.status==="processing"?setTimeout(()=>O(r),5e3):s.status==="failed"&&console.error("Transcription failed:",s.error)}catch(s){console.error("Failed to poll transcription status:",s)}},re=(r,s)=>{for(const[c,h]of p.value.entries()){const z=h.findIndex(oe=>oe.id===r);if(z!==-1){h[z]={...h[z],transcription:s.text,transcriptionConfidence:s.confidence,transcriptionLanguage:s.language,transcriptionUpdatedAt:new Date().toISOString()},p.value.set(c,[...h]);break}}};return{recordings:p,activeRecordingSessions:_,transcriptionJobs:x,audioFormats:X,transcriptionConfig:l,loading:y,error:R,globalRecordingActive:j,activeRecordingCount:U,waveformData:D,analysisData:W,getRecordingsForWorkOrder:ae,getActiveRecordingSession:f,hasActiveRecording:N,getTranscriptionStatus:I,getTotalDurationForWorkOrder:q,getTotalSizeForWorkOrder:B,getTranscribedCount:V,getWaveformData:m,getAnalysisData:n,loadRecordings:a,uploadRecording:d,updateRecording:C,deleteRecording:S,startRecordingSession:ee,stopRecordingSession:te,updateSessionDuration:ie,transcribeRecording:K,generateWaveform:async r=>{try{const s=await P.generateWaveform(r);return D.value.set(r,s),s}catch(s){return console.error("Failed to generate waveform:",s),null}},getAudioAnalysis:async r=>{try{const s=await P.getAudioAnalysis(r);return W.value.set(r,s),s}catch(s){return console.error("Failed to get audio analysis:",s),null}},convertAudioFormat:async(r,s)=>{try{y.value=!0,R.value=null;const c=await P.convertFormat(r,s),h=URL.createObjectURL(c),z=document.createElement("a");return z.href=h,z.download=`recording-${r}.${s}`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(h),!0}catch(c){throw R.value=c.message||"Failed to convert audio format",c}finally{y.value=!1}},searchRecordings:async(r,s={})=>{try{return y.value=!0,R.value=null,await P.searchByContent(r,s)}catch(c){throw R.value=c.message||"Failed to search recordings",c}finally{y.value=!1}},loadActiveSessions:async r=>{try{const s=await P.getActiveSessions(r);return s.forEach(c=>{_.value.set(c.userId,{...c,startTime:new Date(c.startTime),localDuration:0})}),U.value=_.value.size,j.value=U.value>0,s}catch(s){return console.error("Failed to load active recording sessions:",s),[]}},loadSupportedFormats:async()=>{try{const r=await P.getSupportedFormats();return X.value=r,r}catch(r){console.error("Failed to load supported audio formats:",r);const s=[{mimeType:"audio/webm",extension:"webm",maxSize:10485760},{mimeType:"audio/mp4",extension:"mp4",maxSize:10485760},{mimeType:"audio/ogg",extension:"ogg",maxSize:10485760}];return X.value=s,s}},loadTranscriptionConfig:async()=>{try{const r=await P.getTranscriptionConfig();return l.value=r,r}catch(r){console.error("Failed to load transcription config:",r);const s={enabled:!1,supportedLanguages:["en","es","fr"],maxFileSize:10485760,timeout:3e4};return l.value=s,s}},getStatistics:async r=>{try{return await P.getStatistics(r)}catch(s){throw R.value=s.message||"Failed to get recording statistics",s}},validateAudioFile:async r=>{try{return await P.validateAudioFile(r)}catch(s){throw R.value=s.message||"Failed to validate audio file",s}},bulkOperation:async(r,s,c={})=>{try{y.value=!0,R.value=null;const h=await P.bulkOperation(r,s,c);return s==="delete"&&r.forEach(z=>{for(const[oe,de]of p.value.entries()){const ke=de.filter(Se=>Se.id!==z);ke.length!==de.length&&p.value.set(oe,ke)}}),h}catch(h){throw R.value=h.message||"Failed to perform bulk operation",h}finally{y.value=!1}},clearWorkOrderData:r=>{p.value.delete(r)},clearUserSession:r=>{_.value.delete(r),U.value=_.value.size,j.value=U.value>0},clearError:()=>{R.value=null}}});function so(p={}){const{workOrderId:_=null,currentUser:x=null,autoTranscribe:X=!1,maxDuration:l=300,audioQuality:y="medium",enableVisualization:R=!0,enableServerSession:j=!1,autoSave:U=!1}=p,D=ro(),{loading:W,error:ae}=Je(D),f=A([]),N=A(!1),I=A(!1),q=A(!1),B=A(0),V=A(null),m=A(y),n=A(null);let a=null,d=[],C=null,S=null,ee=null,te=null,ie=null,K=null;const O=new Map,re={low:{sampleRate:8e3,bitRate:32e3},medium:{sampleRate:16e3,bitRate:64e3},high:{sampleRate:44100,bitRate:128e3}},ge=F(()=>f.value.reduce((t,o)=>t+(o.duration||0),0)),pe=F(()=>f.value.reduce((t,o)=>t+(o.size||0),0)),fe=F(()=>f.value.filter(t=>t.transcription).length),ye=F(()=>I.value&&!q.value),he=F(()=>x?D.hasActiveRecording(x.id):!1),we=F(()=>Ue(B.value)),xe=()=>{I.value=!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&window.MediaRecorder&&MediaRecorder.isTypeSupported("audio/webm")||MediaRecorder.isTypeSupported("audio/mp4"))},be=async()=>{try{const t=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:M(),echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});return q.value=!1,t}catch(t){throw console.error("Error requesting microphone permission:",t),q.value=!0,t.name==="NotAllowedError"?new Error("Microphone permission denied. Please allow access and try again."):t.name==="NotFoundError"?new Error("No microphone found. Please connect a microphone and try again."):new Error("Failed to access microphone: "+t.message)}},M=()=>(re[m.value]||re.medium).sampleRate,i=()=>["audio/webm","audio/mp4","audio/ogg"].find(o=>MediaRecorder.isTypeSupported(o))||"audio/webm",b=async()=>{if(!(!I.value||N.value))try{const t=await be();if(!t)return;const o=i(),k={mimeType:o},T=re[m.value];T.bitRate&&MediaRecorder.isTypeSupported(`${o};codecs=opus`)&&(k.audioBitsPerSecond=T.bitRate),a=new MediaRecorder(t,k),d=[],a.ondataavailable=E=>{E.data.size>0&&d.push(E.data)},a.onstop=async()=>{try{const E=new Blob(d,{type:a.mimeType});await h(E)}catch(E){throw console.error("Error saving recording:",E),E}finally{t.getTracks().forEach(E=>E.stop()),c()}},a.onerror=E=>{throw console.error("MediaRecorder error:",E.error),L(),new Error("Recording failed: "+E.error.message)},R&&s(t),a.start(1e3),N.value=!0,C=Date.now(),S=setInterval(()=>{B.value=Math.floor((Date.now()-C)/1e3),B.value>=l&&L()},1e3),j&&x&&_&&await D.startRecordingSession(x.id,_,{quality:m.value,maxDuration:l})}catch(t){throw console.error("Error starting recording:",t),N.value=!1,B.value=0,t}},L=async()=>{if(!(!N.value||!a))try{N.value=!1,S&&(clearInterval(S),S=null),K&&(cancelAnimationFrame(K),K=null),a.state==="recording"&&a.stop(),j&&x&&await D.stopRecordingSession(x.id,{duration:B.value,quality:m.value})}catch(t){throw console.error("Error stopping recording:",t),t}finally{B.value=0}},H=()=>{a&&a.state==="recording"&&a.pause(),S&&(clearInterval(S),S=null)},r=()=>{a&&a.state==="paused"&&(a.resume(),S=setInterval(()=>{B.value=Math.floor((Date.now()-C)/1e3),B.value>=l&&L()},1e3))},s=t=>{if(n.value)try{ee=new(window.AudioContext||window.webkitAudioContext),te=ee.createAnalyser(),ie=ee.createMediaStreamSource(t),te.fftSize=256;const o=te.frequencyBinCount,k=new Uint8Array(o);ie.connect(te);const T=n.value,E=T.getContext("2d"),G=()=>{if(!N.value)return;K=requestAnimationFrame(G),te.getByteFrequencyData(k),E.fillStyle="rgb(249, 250, 251)",E.fillRect(0,0,T.width,T.height);const Y=T.width/o*2.5;let le,Z=0;for(let Te=0;Te<o;Te++){le=k[Te]/255*T.height;const De=E.createLinearGradient(0,T.height-le,0,T.height);De.addColorStop(0,"rgb(34, 197, 94)"),De.addColorStop(1,"rgb(21, 128, 61)"),E.fillStyle=De,E.fillRect(Z,T.height-le,Y,le),Z+=Y+1}};G()}catch(o){console.error("Error setting up audio visualization:",o)}},c=()=>{ee&&(ee.close(),ee=null),te=null,ie=null},h=async t=>{try{const o=URL.createObjectURL(t),k=B.value,T=new Audio(o);return new Promise((E,G)=>{T.onloadedmetadata=async()=>{try{const Y=T.duration||k,le={audioUrl:o,audioBlob:t,duration:Y,size:t.size,title:"",description:"",createdAt:new Date().toISOString(),user:x,mimeType:t.type,volume:1,transcription:null,transcriptionConfidence:0,waveformData:null,quality:m.value,sampleRate:M()};let Z;_?Z=await D.uploadRecording(_,{audioBlob:t,filename:`recording-${Date.now()}.${t.type.split("/")[1]||"webm"}`,...le}):Z={id:Date.now()+Math.random(),...le},f.value=[Z,...f.value],X&&Z.id&&Fe(Z.id),Z.id&&R&&D.generateWaveform(Z.id),E(Z)}catch(Y){G(Y)}},T.onerror=()=>{G(new Error("Failed to load audio metadata"))}})}catch(o){throw console.error("Error saving recording:",o),o}},z=async t=>{var E;if(console.log("deleteRecording called with index:",t,"recordings length:",(E=f.value)==null?void 0:E.length),!Re(f)||!Array.isArray(f.value))return console.error("Invalid recordings state"),!1;if(t<0||t>=f.value.length)return console.error("Index out of bounds:",t,"length:",f.value.length),!1;const o=f.value[t];if(!o)return console.error("No recording found at index:",t),!1;const k=o.title||`Recording ${t+1}`;if(!confirm(`Are you sure you want to delete "${k}"?`))return console.log("Delete cancelled by user"),!1;try{if(console.log("Deleting recording:",o.id,o.title),V.value===o.id&&Ve(o.id),o.id&&_)try{await D.deleteRecording(_,o.id),console.log("Deleted from server successfully")}catch(G){console.warn("Server delete failed, continuing with local delete:",G)}return o.audioUrl&&URL.revokeObjectURL(o.audioUrl),o.id&&O.delete(o.id),f.value.splice(t,1),console.log("Recording deleted successfully. New length:",f.value.length),!0}catch(G){return console.error("Error deleting recording:",G),alert("Failed to delete recording: "+G.message),!1}},oe=t=>{if(console.log("editRecording called with index:",t),!Re(f)){console.error("recordings is not a valid ref");return}if(!Array.isArray(f.value)){console.error("recordings.value is not an array:",f.value);return}if(t<0||t>=f.value.length){console.error("Index out of bounds:",t,"length:",f.value.length);return}const o=f.value[t];if(!o){console.error("No recording found at index:",t);return}console.log("Setting edit mode for recording:",o.id,o.title);try{o.editing=!0,o.editTitle=o.title||"",o.editDescription=o.description||"",console.log("Edit mode set, recording.editing:",o.editing)}catch(k){console.error("Error setting edit mode:",k)}},de=async t=>{if(console.log("saveRecordingEdit called with index:",t),!Re(f)||!Array.isArray(f.value)){console.error("Invalid recordings state");return}if(t<0||t>=f.value.length){console.error("Index out of bounds:",t,"length:",f.value.length);return}const o=f.value[t];if(!o){console.error("No recording found at index:",t);return}try{const k={title:o.editTitle||"",description:o.editDescription||""};if(console.log("Saving recording edit:",k),o.id&&_)try{await D.updateRecording(_,o.id,k),console.log("Updated on server successfully")}catch(T){console.warn("Server update failed, continuing with local update:",T)}o.title=k.title,o.description=k.description,o.editing=!1,delete o.editTitle,delete o.editDescription,console.log("Recording edit saved successfully")}catch(k){console.error("Error saving recording edit:",k),alert("Failed to save changes: "+k.message)}},ke=t=>{if(console.log("cancelRecordingEdit called with index:",t),!Re(f)||!Array.isArray(f.value)){console.error("Invalid recordings state");return}if(t<0||t>=f.value.length){console.error("Index out of bounds:",t,"length:",f.value.length);return}const o=f.value[t];if(!o){console.error("No recording found at index:",t);return}try{o.editing=!1,delete o.editTitle,delete o.editDescription,console.log("Edit cancelled for recording")}catch(k){console.error("Error cancelling recording edit:",k)}},Se=async t=>{V.value===t.id?Ve(t.id):await Le(t)},Le=async t=>{try{O.forEach((k,T)=>{T!==t.id&&(k.pause(),k.currentTime=0)});let o=O.get(t.id);o||(o=new Audio(t.audioUrl),o.volume=t.volume||1,o.onended=()=>{V.value=null},o.onerror=()=>{console.error("Error playing audio"),V.value=null},O.set(t.id,o)),V.value=t.id,await o.play()}catch(o){throw console.error("Error starting playback:",o),V.value=null,o}},Ve=t=>{const o=O.get(t);o&&(o.pause(),o.currentTime=0),V.value=null},Ne=(t,o)=>{t.volume=parseFloat(o);const k=O.get(t.id);k&&(k.volume=t.volume)},je=(t,o)=>{const T=t.target.getBoundingClientRect(),G=(t.clientX-T.left)/T.width,Y=O.get(o.id);Y&&Y.duration&&(Y.currentTime=G*Y.duration)},Fe=async t=>{try{if(!t)return;await D.transcribeRecording(t,{language:"auto",enablePunctuation:!0,enableWordTimestamps:!1})}catch(o){throw console.error("Error starting transcription:",o),o}},qe=t=>{var k,T;if(!t.audioUrl)return;const o=document.createElement("a");o.href=t.audioUrl,o.download=`${t.title||"recording"}-${((k=t.createdAt)==null?void 0:k.split("T")[0])||"unknown"}.${((T=t.mimeType)==null?void 0:T.split("/")[1])||"webm"}`,document.body.appendChild(o),o.click(),document.body.removeChild(o)},Ue=t=>{if(!t||t<0)return"0:00";const o=Math.floor(t/60),k=Math.floor(t%60);return`${o}:${k.toString().padStart(2,"0")}`},Oe=t=>{if(!t)return"0 B";const o=["B","KB","MB","GB"],k=Math.floor(Math.log(t)/Math.log(1024));return`${Math.round(t/Math.pow(1024,k)*100)/100} ${o[k]}`},Qe=t=>t?new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}):"Unknown",$e=async()=>{if(!_)return[];try{const t=await D.loadRecordings(_);return f.value=t.map(o=>({...o,editing:!1})),f.value}catch(t){throw console.error("Error loading recordings:",t),t}},Ie=()=>{if(_)return $e()};ue(n,t=>{},{immediate:!0});const Be=()=>{N.value&&L(),S&&(clearInterval(S),S=null),K&&(cancelAnimationFrame(K),K=null),c(),O.forEach(t=>{t.pause()}),O.clear(),f.value.forEach(t=>{t.audioUrl&&URL.revokeObjectURL(t.audioUrl)})};return ze(()=>{xe(),_&&$e(),D.loadSupportedFormats(),D.loadTranscriptionConfig()}),Xe(Be),{recordings:f,isRecording:N,isSupported:I,needsPermission:q,recordingDuration:B,playingId:V,currentAudioQuality:m,waveformCanvas:n,loading:W,error:ae,totalDuration:ge,totalSize:pe,transcribedCount:fe,canRecord:ye,hasActiveRecording:he,currentDurationFormatted:we,startRecording:b,stopRecording:L,pauseRecording:H,resumeRecording:r,deleteRecording:z,editRecording:oe,saveRecordingEdit:de,cancelRecordingEdit:ke,downloadRecording:qe,togglePlayback:Se,updateVolume:Ne,seekToPosition:je,transcribeRecording:Fe,loadRecordings:$e,refreshRecordings:Ie,formatDuration:Ue,formatFileSize:Oe,formatDateTime:Qe,cleanup:Be}}const no={class:"audio-recorder"},io={class:"flex items-center justify-between mb-4"},lo={key:0,class:"text-sm text-gray-500"},co={class:"mb-6 p-4 border border-gray-200 rounded-lg"},uo={class:"flex items-center justify-between mb-4"},vo={class:"flex items-center space-x-4"},mo={key:0,class:"w-6 h-6",fill:"currentColor",viewBox:"0 0 24 24"},go={key:1,class:"w-6 h-6 bg-current rounded-full animate-pulse"},po={class:"ml-2"},fo={key:2,class:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-ping"},yo={key:0,class:"flex items-center text-lg font-mono text-red-600"},ho={key:0,class:"flex items-center space-x-2"},wo=["disabled"],xo={key:0,class:"mb-4"},bo={key:1,class:"p-3 bg-red-50 border border-red-200 rounded"},ko={key:2,class:"p-3 bg-yellow-50 border border-yellow-200 rounded"},Ro={key:0,class:"space-y-3"},_o={class:"flex items-center justify-between"},Co={class:"flex items-center space-x-4 flex-1"},So={key:0,class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},$o={key:1,class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},To={class:"flex-1"},Do={class:"flex items-center space-x-2"},Mo={class:"font-medium text-gray-900"},Ao={class:"flex items-center space-x-4 mt-1 text-sm text-gray-500"},Eo={key:0,class:"text-blue-600"},zo={key:1,class:"flex items-center"},Vo={key:0,class:"mt-2"},Fo=["onClick"],Uo={key:1,class:"mt-2 p-2 bg-gray-50 rounded text-sm"},Bo={class:"flex items-center justify-between mb-1"},Po={class:"text-gray-700"},Lo={key:2,class:"mt-2"},No={class:"flex space-x-2 mt-2"},jo={key:3,class:"mt-2 text-sm text-gray-600"},qo={class:"flex items-center space-x-2"},Oo={class:"flex items-center space-x-1"},Qo=["value","onInput"],Io={key:1,class:"text-center py-8 text-gray-500"},Ho={key:2,class:"mt-6 p-4 bg-gray-50 rounded-lg"},Wo={class:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm"},Ko={class:"font-medium text-gray-900"},Go={class:"font-medium text-gray-900"},Jo={class:"font-medium text-gray-900"},Xo={class:"font-medium text-gray-900"},Yo={__name:"AudioRecorder",props:{modelValue:{type:Array,default:()=>[]},currentUser:{type:Object,default:null},disabled:{type:Boolean,default:!1},autoTranscribe:{type:Boolean,default:!1},maxDuration:{type:Number,default:300},workOrderId:{type:[String,Number],default:null},audioQuality:{type:String,default:"medium"},enableVisualization:{type:Boolean,default:!0},enableServerSession:{type:Boolean,default:!1},autoSave:{type:Boolean,default:!1}},emits:["update:modelValue","recording-saved"],setup(p,{emit:_}){const x=p,X=_,{recordings:l,isRecording:y,isSupported:R,needsPermission:j,playingId:U,currentAudioQuality:D,waveformCanvas:W,totalDuration:ae,totalSize:f,transcribedCount:N,canRecord:I,currentDurationFormatted:q,startRecording:B,stopRecording:V,deleteRecording:m,editRecording:n,saveRecordingEdit:a,cancelRecordingEdit:d,downloadRecording:C,togglePlayback:S,updateVolume:ee,seekToPosition:te,formatDuration:ie,formatFileSize:K,formatDateTime:O}=so({workOrderId:x.workOrderId,currentUser:x.currentUser,autoTranscribe:x.autoTranscribe,maxDuration:x.maxDuration,audioQuality:x.audioQuality,enableVisualization:x.enableVisualization,enableServerSession:x.enableServerSession,autoSave:x.autoSave}),re=A(x.audioQuality),ge=async()=>{try{y.value?await V():await B()}catch(M){console.error("Error toggling recording:",M)}},pe=()=>{D.value=re.value},fe=M=>{try{console.log("handleEditRecording called with index:",M),typeof n=="function"?n(M):console.error("editRecording function not available")}catch(i){console.error("Error in handleEditRecording:",i)}},ye=async M=>{try{console.log("handleDeleteRecording called with index:",M),typeof m=="function"?await m(M):console.error("deleteRecording function not available")}catch(i){console.error("Error in handleDeleteRecording:",i)}},he=async M=>{try{console.log("handleSaveRecordingEdit called with index:",M),typeof a=="function"?await a(M):console.error("saveRecordingEdit function not available")}catch(i){console.error("Error in handleSaveRecordingEdit:",i)}},we=M=>{try{console.log("handleCancelRecordingEdit called with index:",M),typeof d=="function"?d(M):console.error("cancelRecordingEdit function not available")}catch(i){console.error("Error in handleCancelRecordingEdit:",i)}},xe=()=>{X("update:modelValue",l.value)},be=()=>{x.modelValue&&x.modelValue.length>0&&(console.log("Initializing recordings from modelValue:",x.modelValue.length),l.value=[...x.modelValue])};return ue(()=>x.modelValue,M=>{M&&Array.isArray(M)&&(M.length!==l.value.length||M.some((b,L)=>{const H=l.value[L];return!H||b.id!==H.id}))&&(console.log("External modelValue change detected, updating recordings:",M.length),l.value=[...M])},{immediate:!1}),ue(l,()=>{console.log("Recordings changed internally, emitting update:",l.value.length),xe()},{deep:!0}),ze(()=>{be()}),(M,i)=>(u(),g("div",no,[e("div",io,[i[1]||(i[1]=e("div",null,[e("h3",{class:"text-lg font-medium text-gray-900"},"Audio Notes"),e("p",{class:"text-sm text-gray-600"},"Record voice notes for work order documentation")],-1)),v(l).length>0?(u(),g("div",lo,w(v(l).length)+" recording"+w(v(l).length!==1?"s":""),1)):$("",!0)]),e("div",co,[e("div",uo,[e("div",vo,[Q(v(ne),{variant:v(y)?"danger":"primary",size:"lg",onClick:ge,disabled:p.disabled||!v(I),class:"relative"},{default:J(()=>[v(y)?(u(),g("div",go)):(u(),g("svg",mo,i[2]||(i[2]=[e("path",{d:"M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"},null,-1)]))),e("span",po,w(v(y)?"Stop Recording":"Start Recording"),1),v(y)?(u(),g("div",fo)):$("",!0)]),_:1},8,["variant","disabled"]),v(y)?(u(),g("div",yo,[i[3]||(i[3]=e("svg",{class:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})],-1)),se(" "+w(v(q)),1)])):$("",!0)]),v(y)?$("",!0):(u(),g("div",ho,[i[5]||(i[5]=e("label",{class:"text-sm text-gray-600"},"Quality:",-1)),Ye(e("select",{"onUpdate:modelValue":i[0]||(i[0]=b=>re.value=b),class:"text-sm border border-gray-300 rounded px-2 py-1",disabled:v(y),onChange:pe},i[4]||(i[4]=[e("option",{value:"low"},"Low (8kHz)",-1),e("option",{value:"medium"},"Medium (16kHz)",-1),e("option",{value:"high"},"High (44kHz)",-1)]),40,wo),[[Ze,re.value]])]))]),v(y)?(u(),g("div",xo,[e("canvas",{ref_key:"waveformCanvas",ref:W,class:"w-full h-16 border border-gray-300 rounded bg-gray-50",width:"600",height:"64"},null,512),i[6]||(i[6]=e("div",{class:"text-xs text-gray-500 text-center mt-1"}," Live audio visualization ",-1))])):$("",!0),v(R)?$("",!0):(u(),g("div",bo,i[7]||(i[7]=[Pe('<div class="flex" data-v-d8ad1d92><svg class="w-5 h-5 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" data-v-d8ad1d92><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.854-.833-2.598 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" data-v-d8ad1d92></path></svg><div class="ml-3" data-v-d8ad1d92><p class="text-sm text-red-800" data-v-d8ad1d92> Audio recording is not supported in your browser. Please use a modern browser with MediaRecorder API support. </p></div></div>',1)]))),v(j)?(u(),g("div",ko,i[8]||(i[8]=[Pe('<div class="flex" data-v-d8ad1d92><svg class="w-5 h-5 text-yellow-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" data-v-d8ad1d92><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" data-v-d8ad1d92></path></svg><div class="ml-3" data-v-d8ad1d92><p class="text-sm text-yellow-800" data-v-d8ad1d92> Microphone access is required for audio recording. Please allow microphone permissions when prompted. </p></div></div>',1)]))):$("",!0)]),v(l).length>0?(u(),g("div",Ro,[i[19]||(i[19]=e("h4",{class:"text-sm font-medium text-gray-900"},"Recorded Audio Notes",-1)),(u(!0),g(_e,null,Ce(v(l),(b,L)=>(u(),g("div",{key:b.id||L,class:"recording-item border border-gray-200 rounded-lg p-4 transition-all duration-200 hover:border-gray-300"},[e("div",_o,[e("div",Co,[Q(v(ne),{variant:v(U)===b.id?"primary":"outline",size:"sm",onClick:()=>v(S)(b),disabled:p.disabled},{default:J(()=>[v(U)!==b.id?(u(),g("svg",So,i[9]||(i[9]=[e("path",{d:"M8 5v14l11-7z"},null,-1)]))):(u(),g("svg",$o,i[10]||(i[10]=[e("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"},null,-1)])))]),_:2},1032,["variant","onClick","disabled"]),e("div",To,[e("div",Do,[e("h5",Mo,w(b.title||`Recording ${L+1}`),1),Q(v(Me),{variant:"secondary",size:"sm"},{default:J(()=>[se(w(v(K)(b.size||0)),1)]),_:2},1024),Q(v(Me),{variant:"info",size:"sm"},{default:J(()=>[se(w(v(ie)(b.duration||0)),1)]),_:2},1024)]),e("div",Ao,[e("span",null,w(v(O)(b.createdAt)),1),b.transcription?(u(),g("span",Eo,"Transcribed")):$("",!0),b.user?(u(),g("span",zo,[i[11]||(i[11]=e("svg",{class:"w-3 h-3 mr-1",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"})],-1)),se(" "+w(b.user.firstName)+" "+w(b.user.lastName),1)])):$("",!0)]),b.waveformData?(u(),g("div",Vo,[e("canvas",{ref_for:!0,ref:`waveform-${b.id}`,class:"w-full h-8 cursor-pointer",width:"400",height:"32",onClick:H=>v(te)(H,b)},null,8,Fo)])):$("",!0),b.transcription?(u(),g("div",Uo,[e("div",Bo,[i[12]||(i[12]=e("span",{class:"text-xs font-medium text-gray-600"},"TRANSCRIPTION",-1)),Q(v(Me),{variant:b.transcriptionConfidence>.8?"success":"warning",size:"sm"},{default:J(()=>[se(w(Math.round(b.transcriptionConfidence*100))+"% confidence ",1)]),_:2},1032,["variant"])]),e("p",Po,w(b.transcription),1)])):$("",!0),b.editing?(u(),g("div",Lo,[Q(v(me),{modelValue:b.editTitle,"onUpdate:modelValue":H=>b.editTitle=H,placeholder:"Recording title...",size:"sm",onKeyup:[Ae(()=>v(a)(L),["enter"]),Ae(()=>v(d)(L),["escape"])]},null,8,["modelValue","onUpdate:modelValue","onKeyup"]),Q(v(me),{modelValue:b.editDescription,"onUpdate:modelValue":H=>b.editDescription=H,type:"textarea",rows:"2",placeholder:"Add description...",class:"mt-2",size:"sm"},null,8,["modelValue","onUpdate:modelValue"]),e("div",No,[Q(v(ne),{variant:"primary",size:"sm",onClick:()=>he(L)},{default:J(()=>i[13]||(i[13]=[se(" Save ",-1)])),_:2,__:[13]},1032,["onClick"]),Q(v(ne),{variant:"outline",size:"sm",onClick:()=>we(L)},{default:J(()=>i[14]||(i[14]=[se(" Cancel ",-1)])),_:2,__:[14]},1032,["onClick"])])])):b.description?(u(),g("div",jo,w(b.description),1)):$("",!0)])]),e("div",qo,[e("div",Oo,[i[15]||(i[15]=e("svg",{class:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})],-1)),e("input",{type:"range",min:"0",max:"1",step:"0.1",value:b.volume||1,onInput:H=>v(ee)(b,H.target.value),class:"w-16 h-1"},null,40,Qo)]),p.disabled?$("",!0):(u(),ve(v(ne),{key:0,variant:"ghost",size:"sm",onClick:()=>fe(L),title:"Edit recording details"},{default:J(()=>i[16]||(i[16]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)])),_:2,__:[16]},1032,["onClick"])),Q(v(ne),{variant:"ghost",size:"sm",onClick:()=>v(C)(b),title:"Download recording"},{default:J(()=>i[17]||(i[17]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1)])),_:2,__:[17]},1032,["onClick"]),p.disabled?$("",!0):(u(),ve(v(ne),{key:1,variant:"ghost",size:"sm",onClick:()=>ye(L),title:"Delete recording",class:"text-red-600 hover:text-red-800"},{default:J(()=>i[18]||(i[18]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)])),_:2,__:[18]},1032,["onClick"]))])])]))),128))])):(u(),g("div",Io,i[20]||(i[20]=[e("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"})],-1),e("p",{class:"text-sm"},"No audio recordings",-1),e("p",{class:"text-xs text-gray-400 mt-1"},'Click "Start Recording" to add voice notes',-1)]))),v(l).length>0?(u(),g("div",Ho,[i[25]||(i[25]=e("h4",{class:"text-sm font-medium text-gray-900 mb-3"},"Recording Summary",-1)),e("div",Wo,[e("div",null,[e("div",Ko,w(v(l).length),1),i[21]||(i[21]=e("div",{class:"text-gray-500"},"Total Recordings",-1))]),e("div",null,[e("div",Go,w(v(ie)(v(ae))),1),i[22]||(i[22]=e("div",{class:"text-gray-500"},"Total Duration",-1))]),e("div",null,[e("div",Jo,w(v(K)(v(f))),1),i[23]||(i[23]=e("div",{class:"text-gray-500"},"Total Size",-1))]),e("div",null,[e("div",Xo,w(v(N)),1),i[24]||(i[24]=e("div",{class:"text-gray-500"},"Transcribed",-1))])])])):$("",!0)]))}},na=Ee(Yo,[["__scopeId","data-v-d8ad1d92"]]);export{na as A,sa as P,ra as T};
|