@qwanyx/stack 0.2.38 → 0.2.39
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/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -150,4 +150,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
150
150
|
from { transform: rotate(0deg); }
|
|
151
151
|
to { transform: rotate(360deg); }
|
|
152
152
|
}
|
|
153
|
-
`})]})}const cf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function df({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...cf,...d},[g,m]=D.useState(!1),[y,w]=D.useState(""),x=D.useRef(null),E=D.useRef(null);D.useEffect(()=>{function N(j){x.current&&!x.current.contains(j.target)&&(m(!1),w(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(y.toLowerCase()))&&!e.includes(N.id)}),k=s&&y.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===y.toLowerCase()}),v=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),_=D.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),w(""),(j=E.current)==null||j.focus())},[e,t,c]),S=D.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),T=D.useCallback(async()=>{if(!k)return;const N=await(o==null?void 0:o(y.trim()));N&&_(N.id),w("")},[k,y,o,_]),I=D.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!y&&e.length>0?S(e[e.length-1]):N.key==="Escape"&&(m(!1),w(""))},[k,C,y,e,T,_,S]);return p.jsxs("div",{ref:x,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[v.map(N=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||h.chipBackground,color:N.color?"#fff":h.chipText},children:[N.label,!u&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),S(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),p.jsx("input",{ref:E,type:"text",value:y,onChange:N=>{w(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:v.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:y?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[C.map(N=>p.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,i&&l&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),k&&p.jsxs("div",{onClick:T,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:C.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',y.trim(),'"']})]})})]})}function ff({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=D.useState(null),[y,w]=D.useState(null),[x,E]=D.useState(null),C=D.useRef(null),k=e.reduce((j,R)=>{let L=r.filter(O=>n(O)===R.id);return s&&(L=L.sort((O,Y)=>s(O)-s(Y))),j[R.id]=L,j},{}),v=D.useCallback((j,R)=>{const L=t(R),O=n(R);m(L),C.current=O,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const Y=j.target;Y.style.opacity="0.5"})},[t,n]),_=D.useCallback(j=>{const R=j.target;R.style.opacity="1",m(null),w(null),E(null),C.current=null},[]),S=D.useCallback((j,R,L)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",w(R),E(L)},[]),T=D.useCallback(j=>{const R=j.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(w(null),E(null))},[]),I=D.useCallback((j,R,L)=>{if(j.preventDefault(),!g)return;const O=C.current;O===R?l==null||l(g,R,L):O&&i(g,O,R,L),m(null),w(null),E(null),C.current=null},[g,i,l]),N=(j,R)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const R=k[j.id]||[],L=y===j.id;return p.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:O=>{O.preventDefault(),g&&!L&&w(j.id)},onDragLeave:T,onDrop:O=>I(O,j.id,x??R.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,R.length):N(j,R.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[R.map((O,Y)=>{const ce=t(O),se=g===ce,ie=L&&x===Y&&!se;return p.jsxs("div",{children:[ie&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:xe=>v(xe,O),onDragEnd:_,onDragOver:xe=>S(xe,j.id,Y),onClick:()=>a==null?void 0:a(O),className:`cursor-grab active:cursor-grabbing transition-all ${se?"opacity-50 scale-95":""} ${h}`,children:o(O,se)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:O=>{O.preventDefault(),S(O,j.id,R.length)},children:L&&x===R.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(j)})]},j.id)})})}const hf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function pf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function gf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function mf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function yf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...hf,...g},{allDayItems:y,timedItems:w}=D.useMemo(()=>{const _=[],S=[];for(const T of r)l(T)?_.push(T):S.push(T);return{allDayItems:_,timedItems:S}},[r,l]),x=D.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,C=D.useCallback(_=>{const S=o(_);if(!S)return null;const T=pf(S);if(!T)return null;const{hours:I,minutes:N}=T,j=Math.max(t,Math.min(n,I)),R=I<t?0:N,L=(j-t)*s+R/60*s,O=i(_),Y=Math.max(20,O/60*s);return{top:L,height:Y}},[o,i,t,n,s]),k=D.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,S=_.getHours(),T=_.getMinutes();return S<t||S>n?null:(S-t)*s+T/60*s},[e,f,t,n,s]),v=D.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,N=Math.floor(I/60)+t,j=Math.round(I%60/15)*15,R=Math.min(n,Math.max(t,N)),L=j>=60?0:j,O=`${R.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d(O)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[y.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:y.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[x.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<x.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:v}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),w.map(_=>{const S=C(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:T=>{T.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,transcribing:n,variant:s="widget",hideSaveButton:o=!1}){const i=s==="widget",[l,a]=D.useState("idle"),[u,c]=D.useState(0),[d,f]=D.useState(0),[h,g]=D.useState(!1),[m,y]=D.useState(0),[w,x]=D.useState(null),[E,C]=D.useState(!1),[k,v]=D.useState(null),_=D.useRef(null),S=D.useRef(null),T=D.useRef(null),I=D.useRef(null),N=D.useRef(null),j=D.useRef([]),R=D.useRef(null),L=D.useRef(null),O=D.useRef(null),Y=D.useRef(null),ce=D.useRef(!1),se=D.useRef([]),ie=D.useRef(null),xe=D.useRef(null),he=D.useRef([]),be=D.useRef([]),De=D.useRef("insert"),Le=D.useRef(!1),Se=D.useRef(0),_e=D.useRef(0),qe=D.useRef(0),Me=U=>{const B=Math.floor(U/60),X=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`},pe=async U=>{const B=await U.arrayBuffer(),X=new AudioContext,J=await X.decodeAudioData(B);return await X.close(),J},Re=U=>{const B=U.numberOfChannels,X=U.sampleRate,J=1,A=16,$=A/8,H=B*$,Q=X*H,ee=U.length*H,le=new ArrayBuffer(44+ee),re=new DataView(le),te=(me,de)=>{for(let Ie=0;Ie<de.length;Ie++)re.setUint8(me+Ie,de.charCodeAt(Ie))};te(0,"RIFF"),re.setUint32(4,36+ee,!0),te(8,"WAVE"),te(12,"fmt "),re.setUint32(16,16,!0),re.setUint16(20,J,!0),re.setUint16(22,B,!0),re.setUint32(24,X,!0),re.setUint32(28,Q,!0),re.setUint16(32,H,!0),re.setUint16(34,A,!0),te(36,"data"),re.setUint32(40,ee,!0);const Ce=[];for(let me=0;me<B;me++)Ce.push(U.getChannelData(me));let Te=44;for(let me=0;me<U.length;me++)for(let de=0;de<B;de++){const Ie=Math.max(-1,Math.min(1,Ce[de][me])),$e=Ie<0?Ie*32768:Ie*32767;re.setInt16(Te,$e,!0),Te+=2}return new Blob([le],{type:"audio/wav"})},lt=async(U,B,X,J)=>{const A=new AudioContext,$=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(X,U.length),ee=Math.max(0,U.length-X),le=J==="insert"?Q+B.length+ee:Q+B.length,re=A.createBuffer(H,le,$);for(let te=0;te<H;te++){const Ce=re.getChannelData(te),Te=te<U.numberOfChannels?U.getChannelData(te):U.getChannelData(0);for(let de=0;de<Q;de++)Ce[de]=Te[de];const me=te<B.numberOfChannels?B.getChannelData(te):B.getChannelData(0);for(let de=0;de<B.length;de++)Ce[Q+de]=me[de];if(J==="insert")for(let de=0;de<ee;de++)Ce[Q+B.length+de]=Te[X+de]}return await A.close(),re},xt=D.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height,$=se.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const ee=8,le="rgba(0, 0, 0, 0.4)",re=B.createLinearGradient(0,0,0,ee);re.addColorStop(0,le),re.addColorStop(1,"transparent"),B.fillStyle=re,B.fillRect(0,0,J,ee);const te=B.createLinearGradient(0,A-ee,0,A);te.addColorStop(0,"transparent"),te.addColorStop(1,le),B.fillStyle=te,B.fillRect(0,A-ee,J,ee);const Ce=B.createLinearGradient(0,0,ee,0);Ce.addColorStop(0,le),Ce.addColorStop(1,"transparent"),B.fillStyle=Ce,B.fillRect(0,0,ee,A);const Te=B.createLinearGradient(J-ee,0,J,0);Te.addColorStop(0,"transparent"),Te.addColorStop(1,le),B.fillStyle=Te,B.fillRect(J-ee,0,ee,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const me=J/2;if($.length>0)if(l==="recording")for(let $e=0;$e<$.length;$e++){const st=$.length-1-$e,vt=me-st*4;if(vt<-3||vt>J)continue;const ct=$[$e]*(A/2-12),Bt=A/2-ct;B.fillStyle="#10b981",B.fillRect(vt,Bt,3,ct*2)}else{const $e=H>0?Q/H*$.length:0;for(let st=0;st<$.length;st++){const vt=$e-st,ct=me-vt*4;if(ct<-3||ct>J)continue;const Bt=$[st]*(A/2-12),fr=A/2-Bt;B.fillStyle=st<=$e?"#10b981":"#4b5563",B.fillRect(ct,fr,3,Bt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(me,0),B.lineTo(me,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(Me(Q),me,A-6),l==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[l,m,u,d]),Ot=()=>{const U=N.current;if(!U||!ce.current)return;const B=U.frequencyBinCount,X=new Uint8Array(B);U.getByteTimeDomainData(X);let J=0;for(let H=0;H<B;H++){const Q=(X[H]-128)/128;J+=Q*Q}const A=Math.sqrt(J/B),$=Math.min(1,A*3);se.current.push($),xt(),ce.current&&(L.current=requestAnimationFrame(Ot))},tt=async()=>{try{x(null),C(!1),ie.current===null&&(se.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;I.current=B;const X=B.createAnalyser();X.fftSize=2048,N.current=X,B.createMediaStreamSource(U).connect(X);const A=new MediaRecorder(U);S.current=A,j.current=[],A.ondataavailable=$=>{$.data.size>0&&j.current.push($.data)},A.onstop=async()=>{try{if(ce.current=!1,j.current.length===0){x("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(re=>re.stop());return}const $=new Blob(j.current,{type:"audio/webm"});let H,Q;if(ie.current!==null&&xe.current)try{const re=await pe($),te=xe.current.sampleRate,Ce=Math.floor(ie.current*te),Te=await lt(xe.current,re,Ce,De.current);H=Re(Te),Q=Te.length/Te.sampleRate,De.current==="insert"&&(se.current=[...se.current,...be.current]),ie.current=null,xe.current=null,he.current=[],be.current=[]}catch{H=$,Q=Se.current>0?Se.current:1}else H=$,Q=Se.current>0?Se.current:1;Y.current=H;const ee=URL.createObjectURL(H),le=new Audio(ee);le.ontimeupdate=()=>{y(le.currentTime)},le.onended=()=>{g(!1)},O.current=le,f(Q),y(Q),a("editing"),U.getTracks().forEach(re=>re.stop())}catch{x("Failed to process recording"),a("idle")}},A.start(100),ce.current=!0,a("recording"),c(0),Se.current=0,R.current=setInterval(()=>{Se.current+=1,c(Se.current)},1e3)}catch{x("Could not access microphone. Please allow microphone access.")}},rt=()=>{ce.current=!1,C(!1),v(null),L.current&&(cancelAnimationFrame(L.current),L.current=null),R.current&&(clearInterval(R.current),R.current=null),S.current&&S.current.state!=="inactive"&&S.current.stop()},at=U=>{const B=_.current;if(!B)return;const X=d||u;if(X<=0)return;const J=se.current;if(J.length===0)return;const A=B.getBoundingClientRect(),$=U-_e.current,H=4,Q=A.width/B.width,ee=J.length/X*H,le=-$/(ee*Q),re=qe.current+le,te=Math.max(0,Math.min(re,X));O.current&&(O.current.currentTime=te),y(te)},Mt=()=>{O.current&&(O.current.currentTime=0),y(0)},It=()=>{const U=d||u;O.current&&(O.current.currentTime=U),y(U)},bt=()=>{const U=O.current;U&&(h?(U.pause(),y(U.currentTime),g(!1)):(U.currentTime=m,U.play().catch(()=>{}),g(!0)))},ut=async U=>{if(!Y.current){tt();return}try{O.current&&(O.current.pause(),g(!1)),De.current=U,xe.current=await pe(Y.current);const B=d||u;ie.current=m;const X=B>0?m/B:0,J=Math.floor(X*se.current.length);he.current=se.current.slice(0,J),be.current=se.current.slice(J),se.current=[...he.current],tt()}catch{x("Failed to prepare recording. Please try again.")}},nt=()=>{O.current&&(O.current.pause(),O.current=null),Y.current=null,xe.current=null,ie.current=null,he.current=[],g(!1),y(0),f(0),c(0),tt()},_t=()=>{Y.current?r(Y.current,d||u):alert("No audio recorded yet!")};if(D.useEffect(()=>{l==="recording"&&_.current&&N.current&&ce.current&&(L.current=requestAnimationFrame(Ot))},[l]),D.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const X=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*X,U.height=J.height*X;const A=U.getContext("2d");A&&A.scale(X,X)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),D.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const $=8,H="rgba(0, 0, 0, 0.4)",Q=B.createLinearGradient(0,0,0,$);Q.addColorStop(0,H),Q.addColorStop(1,"transparent"),B.fillStyle=Q,B.fillRect(0,0,J,$);const ee=B.createLinearGradient(0,A-$,0,A);ee.addColorStop(0,"transparent"),ee.addColorStop(1,H),B.fillStyle=ee,B.fillRect(0,A-$,J,$);const le=B.createLinearGradient(0,0,$,0);le.addColorStop(0,H),le.addColorStop(1,"transparent"),B.fillStyle=le,B.fillRect(0,0,$,A);const re=B.createLinearGradient(J-$,0,J,0);re.addColorStop(0,"transparent"),re.addColorStop(1,H),B.fillStyle=re,B.fillRect(J-$,0,$,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const te=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(te,0),B.lineTo(te,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",te,A-6)}},[l]),D.useEffect(()=>()=>{ce.current=!1,R.current&&clearInterval(R.current),L.current&&cancelAnimationFrame(L.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),I.current&&I.current.state!=="closed"&&I.current.close()},[]),D.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const X=O.current;if(X&&h){const J=_.current;if(J){const A=J.getContext("2d");if(A){const $=J.getBoundingClientRect(),H=$.width,Q=$.height,ee=se.current,le=d||u||1,re=X.currentTime;A.fillStyle="#2d3b35",A.fillRect(0,0,H,Q);const te=8,Ce="rgba(0, 0, 0, 0.4)",Te=A.createLinearGradient(0,0,0,te);Te.addColorStop(0,Ce),Te.addColorStop(1,"transparent"),A.fillStyle=Te,A.fillRect(0,0,H,te);const me=A.createLinearGradient(0,Q-te,0,Q);me.addColorStop(0,"transparent"),me.addColorStop(1,Ce),A.fillStyle=me,A.fillRect(0,Q-te,H,te);const de=A.createLinearGradient(0,0,te,0);de.addColorStop(0,Ce),de.addColorStop(1,"transparent"),A.fillStyle=de,A.fillRect(0,0,te,Q);const Ie=A.createLinearGradient(H-te,0,H,0);Ie.addColorStop(0,"transparent"),Ie.addColorStop(1,Ce),A.fillStyle=Ie,A.fillRect(H-te,0,te,Q),A.strokeStyle="#5a6b62",A.lineWidth=1,A.beginPath(),A.moveTo(0,Q/2),A.lineTo(H,Q/2),A.stroke();const $e=H/2,st=3,vt=4,ct=le>0?re/le*ee.length:0;for(let Qt=0;Qt<ee.length;Qt++){const ys=ct-Qt,hr=$e-ys*vt;if(hr<-st||hr>H)continue;const Fr=ee[Qt]*(Q/2-12),xs=Q/2-Fr;A.fillStyle=Qt<=ct?"#10b981":"#4b5563",A.fillRect(hr,xs,st,Fr*2)}A.strokeStyle="#ef4444",A.lineWidth=1,A.beginPath(),A.moveTo($e,0),A.lineTo($e,Q),A.stroke(),A.fillStyle="#fff",A.font="bold 18px monospace",A.textAlign="center";const Bt=Math.floor(re/60),fr=Math.floor(re%60);A.fillText(`${Bt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,$e,Q-6),A.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),D.useEffect(()=>{l==="editing"&&!h&&xt()},[l,m,h,xt]),w)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:w}),p.jsx("button",{onClick:()=>{x(null),tt()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const G={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},ve={...G,opacity:.3,cursor:"not-allowed"},He=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:He,children:[p.jsx("canvas",{ref:_,style:{width:"100%",height:"64px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Le.current=!0,_e.current=U.clientX,qe.current=m;const B=J=>{Le.current&&at(J.clientX)},X=()=>{Le.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",X)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"10px 12px":"8px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Mt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?ve:G,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(l==="recording"){const U=S.current;U&&(U.state==="recording"?(U.pause(),C(!0)):U.state==="paused"&&(U.resume(),C(!1)))}else bt()},disabled:l==="idle",style:l==="idle"?ve:G,title:h||l==="recording"&&!E?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!E?"pause":"play_arrow"})}),p.jsx("button",{onClick:It,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?ve:G,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),p.jsx("button",{onClick:()=>{k==="insert"?rt():l==="idle"?(v("insert"),tt()):l==="editing"&&(v("insert"),ut("insert"))},disabled:l==="recording"&&k!=="insert"||h,style:l==="recording"&&k!=="insert"||h?ve:G,title:k==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{k==="mic"?rt():l==="idle"?(v("mic"),tt()):l==="editing"&&(v("mic"),ut("replace"))},disabled:l==="recording"&&k!=="mic"||h,style:l==="recording"&&k!=="mic"||h?ve:G,title:k==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{k==="startover"?rt():l==="editing"&&(v("startover"),nt())},disabled:l==="idle"||l==="recording"&&k!=="startover"||h,style:l==="idle"||l==="recording"&&k!=="startover"||h?ve:G,title:k==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&p.jsx("button",{onClick:()=>Y.current&&t(Y.current),disabled:l!=="editing"||n,style:l!=="editing"||n?ve:G,title:n?"Transcribing...":"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&p.jsx("button",{onClick:_t,disabled:l!=="editing",style:l!=="editing"?ve:G,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=al;exports.AudioEditor=xf;exports.AuthManager=ll;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Bn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ol;exports.MailComposer=uf;exports.MailEditor=Ba;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=oi;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=ul;
|
|
153
|
+
`})]})}const cf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function df({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...cf,...d},[g,m]=D.useState(!1),[y,w]=D.useState(""),x=D.useRef(null),E=D.useRef(null);D.useEffect(()=>{function N(j){x.current&&!x.current.contains(j.target)&&(m(!1),w(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(y.toLowerCase()))&&!e.includes(N.id)}),k=s&&y.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===y.toLowerCase()}),v=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),_=D.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),w(""),(j=E.current)==null||j.focus())},[e,t,c]),S=D.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),T=D.useCallback(async()=>{if(!k)return;const N=await(o==null?void 0:o(y.trim()));N&&_(N.id),w("")},[k,y,o,_]),I=D.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!y&&e.length>0?S(e[e.length-1]):N.key==="Escape"&&(m(!1),w(""))},[k,C,y,e,T,_,S]);return p.jsxs("div",{ref:x,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[v.map(N=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||h.chipBackground,color:N.color?"#fff":h.chipText},children:[N.label,!u&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),S(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),p.jsx("input",{ref:E,type:"text",value:y,onChange:N=>{w(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:v.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:y?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[C.map(N=>p.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,i&&l&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),k&&p.jsxs("div",{onClick:T,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:C.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',y.trim(),'"']})]})})]})}function ff({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=D.useState(null),[y,w]=D.useState(null),[x,E]=D.useState(null),C=D.useRef(null),k=e.reduce((j,R)=>{let L=r.filter(O=>n(O)===R.id);return s&&(L=L.sort((O,Y)=>s(O)-s(Y))),j[R.id]=L,j},{}),v=D.useCallback((j,R)=>{const L=t(R),O=n(R);m(L),C.current=O,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const Y=j.target;Y.style.opacity="0.5"})},[t,n]),_=D.useCallback(j=>{const R=j.target;R.style.opacity="1",m(null),w(null),E(null),C.current=null},[]),S=D.useCallback((j,R,L)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",w(R),E(L)},[]),T=D.useCallback(j=>{const R=j.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(w(null),E(null))},[]),I=D.useCallback((j,R,L)=>{if(j.preventDefault(),!g)return;const O=C.current;O===R?l==null||l(g,R,L):O&&i(g,O,R,L),m(null),w(null),E(null),C.current=null},[g,i,l]),N=(j,R)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const R=k[j.id]||[],L=y===j.id;return p.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:O=>{O.preventDefault(),g&&!L&&w(j.id)},onDragLeave:T,onDrop:O=>I(O,j.id,x??R.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,R.length):N(j,R.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[R.map((O,Y)=>{const ce=t(O),se=g===ce,ie=L&&x===Y&&!se;return p.jsxs("div",{children:[ie&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:xe=>v(xe,O),onDragEnd:_,onDragOver:xe=>S(xe,j.id,Y),onClick:()=>a==null?void 0:a(O),className:`cursor-grab active:cursor-grabbing transition-all ${se?"opacity-50 scale-95":""} ${h}`,children:o(O,se)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:O=>{O.preventDefault(),S(O,j.id,R.length)},children:L&&x===R.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(j)})]},j.id)})})}const hf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function pf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function gf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function mf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function yf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...hf,...g},{allDayItems:y,timedItems:w}=D.useMemo(()=>{const _=[],S=[];for(const T of r)l(T)?_.push(T):S.push(T);return{allDayItems:_,timedItems:S}},[r,l]),x=D.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,C=D.useCallback(_=>{const S=o(_);if(!S)return null;const T=pf(S);if(!T)return null;const{hours:I,minutes:N}=T,j=Math.max(t,Math.min(n,I)),R=I<t?0:N,L=(j-t)*s+R/60*s,O=i(_),Y=Math.max(20,O/60*s);return{top:L,height:Y}},[o,i,t,n,s]),k=D.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,S=_.getHours(),T=_.getMinutes();return S<t||S>n?null:(S-t)*s+T/60*s},[e,f,t,n,s]),v=D.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,N=Math.floor(I/60)+t,j=Math.round(I%60/15)*15,R=Math.min(n,Math.max(t,N)),L=j>=60?0:j,O=`${R.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d(O)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[y.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:y.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[x.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<x.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:v}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),w.map(_=>{const S=C(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:T=>{T.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,transcribing:n,variant:s="widget",hideSaveButton:o=!1}){const i=s==="widget",[l,a]=D.useState("idle"),[u,c]=D.useState(0),[d,f]=D.useState(0),[h,g]=D.useState(!1),[m,y]=D.useState(0),[w,x]=D.useState(null),[E,C]=D.useState(!1),[k,v]=D.useState(null),_=D.useRef(null),S=D.useRef(null),T=D.useRef(null),I=D.useRef(null),N=D.useRef(null),j=D.useRef([]),R=D.useRef(null),L=D.useRef(null),O=D.useRef(null),Y=D.useRef(null),ce=D.useRef(!1),se=D.useRef([]),ie=D.useRef(null),xe=D.useRef(null),he=D.useRef([]),be=D.useRef([]),De=D.useRef("insert"),Le=D.useRef(!1),Se=D.useRef(0),_e=D.useRef(0),qe=D.useRef(0),Me=U=>{const B=Math.floor(U/60),X=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`},pe=async U=>{const B=await U.arrayBuffer(),X=new AudioContext,J=await X.decodeAudioData(B);return await X.close(),J},Re=U=>{const B=U.numberOfChannels,X=U.sampleRate,J=1,A=16,$=A/8,H=B*$,Q=X*H,ee=U.length*H,le=new ArrayBuffer(44+ee),re=new DataView(le),te=(me,de)=>{for(let Ie=0;Ie<de.length;Ie++)re.setUint8(me+Ie,de.charCodeAt(Ie))};te(0,"RIFF"),re.setUint32(4,36+ee,!0),te(8,"WAVE"),te(12,"fmt "),re.setUint32(16,16,!0),re.setUint16(20,J,!0),re.setUint16(22,B,!0),re.setUint32(24,X,!0),re.setUint32(28,Q,!0),re.setUint16(32,H,!0),re.setUint16(34,A,!0),te(36,"data"),re.setUint32(40,ee,!0);const Ce=[];for(let me=0;me<B;me++)Ce.push(U.getChannelData(me));let Te=44;for(let me=0;me<U.length;me++)for(let de=0;de<B;de++){const Ie=Math.max(-1,Math.min(1,Ce[de][me])),$e=Ie<0?Ie*32768:Ie*32767;re.setInt16(Te,$e,!0),Te+=2}return new Blob([le],{type:"audio/wav"})},lt=async(U,B,X,J)=>{const A=new AudioContext,$=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(X,U.length),ee=Math.max(0,U.length-X),le=J==="insert"?Q+B.length+ee:Q+B.length,re=A.createBuffer(H,le,$);for(let te=0;te<H;te++){const Ce=re.getChannelData(te),Te=te<U.numberOfChannels?U.getChannelData(te):U.getChannelData(0);for(let de=0;de<Q;de++)Ce[de]=Te[de];const me=te<B.numberOfChannels?B.getChannelData(te):B.getChannelData(0);for(let de=0;de<B.length;de++)Ce[Q+de]=me[de];if(J==="insert")for(let de=0;de<ee;de++)Ce[Q+B.length+de]=Te[X+de]}return await A.close(),re},xt=D.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height,$=se.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const ee=8,le="rgba(0, 0, 0, 0.4)",re=B.createLinearGradient(0,0,0,ee);re.addColorStop(0,le),re.addColorStop(1,"transparent"),B.fillStyle=re,B.fillRect(0,0,J,ee);const te=B.createLinearGradient(0,A-ee,0,A);te.addColorStop(0,"transparent"),te.addColorStop(1,le),B.fillStyle=te,B.fillRect(0,A-ee,J,ee);const Ce=B.createLinearGradient(0,0,ee,0);Ce.addColorStop(0,le),Ce.addColorStop(1,"transparent"),B.fillStyle=Ce,B.fillRect(0,0,ee,A);const Te=B.createLinearGradient(J-ee,0,J,0);Te.addColorStop(0,"transparent"),Te.addColorStop(1,le),B.fillStyle=Te,B.fillRect(J-ee,0,ee,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const me=J/2;if($.length>0)if(l==="recording")for(let $e=0;$e<$.length;$e++){const st=$.length-1-$e,vt=me-st*4;if(vt<-3||vt>J)continue;const ct=$[$e]*(A/2-12),Bt=A/2-ct;B.fillStyle="#10b981",B.fillRect(vt,Bt,3,ct*2)}else{const $e=H>0?Q/H*$.length:0;for(let st=0;st<$.length;st++){const vt=$e-st,ct=me-vt*4;if(ct<-3||ct>J)continue;const Bt=$[st]*(A/2-12),fr=A/2-Bt;B.fillStyle=st<=$e?"#10b981":"#4b5563",B.fillRect(ct,fr,3,Bt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(me,0),B.lineTo(me,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(Me(Q),me,A-6),l==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[l,m,u,d]),Ot=()=>{const U=N.current;if(!U||!ce.current)return;const B=U.frequencyBinCount,X=new Uint8Array(B);U.getByteTimeDomainData(X);let J=0;for(let H=0;H<B;H++){const Q=(X[H]-128)/128;J+=Q*Q}const A=Math.sqrt(J/B),$=Math.min(1,A*3);se.current.push($),xt(),ce.current&&(L.current=requestAnimationFrame(Ot))},tt=async()=>{try{x(null),C(!1),ie.current===null&&(se.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;I.current=B;const X=B.createAnalyser();X.fftSize=2048,N.current=X,B.createMediaStreamSource(U).connect(X);const A=new MediaRecorder(U);S.current=A,j.current=[],A.ondataavailable=$=>{$.data.size>0&&j.current.push($.data)},A.onstop=async()=>{try{if(ce.current=!1,j.current.length===0){x("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(re=>re.stop());return}const $=new Blob(j.current,{type:"audio/webm"});let H,Q;if(ie.current!==null&&xe.current)try{const re=await pe($),te=xe.current.sampleRate,Ce=Math.floor(ie.current*te),Te=await lt(xe.current,re,Ce,De.current);H=Re(Te),Q=Te.length/Te.sampleRate,De.current==="insert"&&(se.current=[...se.current,...be.current]),ie.current=null,xe.current=null,he.current=[],be.current=[]}catch{H=$,Q=Se.current>0?Se.current:1}else H=$,Q=Se.current>0?Se.current:1;Y.current=H;const ee=URL.createObjectURL(H),le=new Audio(ee);le.ontimeupdate=()=>{y(le.currentTime)},le.onended=()=>{g(!1)},O.current=le,f(Q),y(Q),a("editing"),U.getTracks().forEach(re=>re.stop())}catch{x("Failed to process recording"),a("idle")}},A.start(100),ce.current=!0,a("recording"),c(0),Se.current=0,R.current=setInterval(()=>{Se.current+=1,c(Se.current)},1e3)}catch{x("Could not access microphone. Please allow microphone access.")}},rt=()=>{ce.current=!1,C(!1),v(null),L.current&&(cancelAnimationFrame(L.current),L.current=null),R.current&&(clearInterval(R.current),R.current=null),S.current&&S.current.state!=="inactive"&&S.current.stop()},at=U=>{const B=_.current;if(!B)return;const X=d||u;if(X<=0)return;const J=se.current;if(J.length===0)return;const A=B.getBoundingClientRect(),$=U-_e.current,H=4,Q=A.width/B.width,ee=J.length/X*H,le=-$/(ee*Q),re=qe.current+le,te=Math.max(0,Math.min(re,X));O.current&&(O.current.currentTime=te),y(te)},Mt=()=>{O.current&&(O.current.currentTime=0),y(0)},It=()=>{const U=d||u;O.current&&(O.current.currentTime=U),y(U)},bt=()=>{const U=O.current;U&&(h?(U.pause(),y(U.currentTime),g(!1)):(U.currentTime=m,U.play().catch(()=>{}),g(!0)))},ut=async U=>{if(!Y.current){tt();return}try{O.current&&(O.current.pause(),g(!1)),De.current=U,xe.current=await pe(Y.current);const B=d||u;ie.current=m;const X=B>0?m/B:0,J=Math.floor(X*se.current.length);he.current=se.current.slice(0,J),be.current=se.current.slice(J),se.current=[...he.current],tt()}catch{x("Failed to prepare recording. Please try again.")}},nt=()=>{O.current&&(O.current.pause(),O.current=null),Y.current=null,xe.current=null,ie.current=null,he.current=[],g(!1),y(0),f(0),c(0),tt()},_t=()=>{Y.current?r(Y.current,d||u):alert("No audio recorded yet!")};if(D.useEffect(()=>{l==="recording"&&_.current&&N.current&&ce.current&&(L.current=requestAnimationFrame(Ot))},[l]),D.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const X=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*X,U.height=J.height*X;const A=U.getContext("2d");A&&A.scale(X,X)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),D.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const $=8,H="rgba(0, 0, 0, 0.4)",Q=B.createLinearGradient(0,0,0,$);Q.addColorStop(0,H),Q.addColorStop(1,"transparent"),B.fillStyle=Q,B.fillRect(0,0,J,$);const ee=B.createLinearGradient(0,A-$,0,A);ee.addColorStop(0,"transparent"),ee.addColorStop(1,H),B.fillStyle=ee,B.fillRect(0,A-$,J,$);const le=B.createLinearGradient(0,0,$,0);le.addColorStop(0,H),le.addColorStop(1,"transparent"),B.fillStyle=le,B.fillRect(0,0,$,A);const re=B.createLinearGradient(J-$,0,J,0);re.addColorStop(0,"transparent"),re.addColorStop(1,H),B.fillStyle=re,B.fillRect(J-$,0,$,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const te=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(te,0),B.lineTo(te,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",te,A-6)}},[l]),D.useEffect(()=>()=>{ce.current=!1,R.current&&clearInterval(R.current),L.current&&cancelAnimationFrame(L.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),I.current&&I.current.state!=="closed"&&I.current.close()},[]),D.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const X=O.current;if(X&&h){const J=_.current;if(J){const A=J.getContext("2d");if(A){const $=J.getBoundingClientRect(),H=$.width,Q=$.height,ee=se.current,le=d||u||1,re=X.currentTime;A.fillStyle="#2d3b35",A.fillRect(0,0,H,Q);const te=8,Ce="rgba(0, 0, 0, 0.4)",Te=A.createLinearGradient(0,0,0,te);Te.addColorStop(0,Ce),Te.addColorStop(1,"transparent"),A.fillStyle=Te,A.fillRect(0,0,H,te);const me=A.createLinearGradient(0,Q-te,0,Q);me.addColorStop(0,"transparent"),me.addColorStop(1,Ce),A.fillStyle=me,A.fillRect(0,Q-te,H,te);const de=A.createLinearGradient(0,0,te,0);de.addColorStop(0,Ce),de.addColorStop(1,"transparent"),A.fillStyle=de,A.fillRect(0,0,te,Q);const Ie=A.createLinearGradient(H-te,0,H,0);Ie.addColorStop(0,"transparent"),Ie.addColorStop(1,Ce),A.fillStyle=Ie,A.fillRect(H-te,0,te,Q),A.strokeStyle="#5a6b62",A.lineWidth=1,A.beginPath(),A.moveTo(0,Q/2),A.lineTo(H,Q/2),A.stroke();const $e=H/2,st=3,vt=4,ct=le>0?re/le*ee.length:0;for(let Qt=0;Qt<ee.length;Qt++){const ys=ct-Qt,hr=$e-ys*vt;if(hr<-st||hr>H)continue;const Fr=ee[Qt]*(Q/2-12),xs=Q/2-Fr;A.fillStyle=Qt<=ct?"#10b981":"#4b5563",A.fillRect(hr,xs,st,Fr*2)}A.strokeStyle="#ef4444",A.lineWidth=1,A.beginPath(),A.moveTo($e,0),A.lineTo($e,Q),A.stroke(),A.fillStyle="#fff",A.font="bold 18px monospace",A.textAlign="center";const Bt=Math.floor(re/60),fr=Math.floor(re%60);A.fillText(`${Bt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,$e,Q-6),A.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),D.useEffect(()=>{l==="editing"&&!h&&xt()},[l,m,h,xt]),w)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:w}),p.jsx("button",{onClick:()=>{x(null),tt()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const G={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},ve={...G,opacity:.3,cursor:"not-allowed"},He=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:He,children:[p.jsx("canvas",{ref:_,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Le.current=!0,_e.current=U.clientX,qe.current=m;const B=J=>{Le.current&&at(J.clientX)},X=()=>{Le.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",X)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Mt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?ve:G,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(l==="recording"){const U=S.current;U&&(U.state==="recording"?(U.pause(),C(!0)):U.state==="paused"&&(U.resume(),C(!1)))}else bt()},disabled:l==="idle",style:l==="idle"?ve:G,title:h||l==="recording"&&!E?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!E?"pause":"play_arrow"})}),p.jsx("button",{onClick:It,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?ve:G,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),p.jsx("button",{onClick:()=>{k==="insert"?rt():l==="idle"?(v("insert"),tt()):l==="editing"&&(v("insert"),ut("insert"))},disabled:l==="recording"&&k!=="insert"||h,style:l==="recording"&&k!=="insert"||h?ve:G,title:k==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{k==="mic"?rt():l==="idle"?(v("mic"),tt()):l==="editing"&&(v("mic"),ut("replace"))},disabled:l==="recording"&&k!=="mic"||h,style:l==="recording"&&k!=="mic"||h?ve:G,title:k==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{k==="startover"?rt():l==="editing"&&(v("startover"),nt())},disabled:l==="idle"||l==="recording"&&k!=="startover"||h,style:l==="idle"||l==="recording"&&k!=="startover"||h?ve:G,title:k==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&p.jsx("button",{onClick:()=>Y.current&&t(Y.current),disabled:l!=="editing"||n,style:l!=="editing"||n?ve:G,title:n?"Transcribing...":"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&p.jsx("button",{onClick:_t,disabled:l!=="editing",style:l!=="editing"?ve:G,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=al;exports.AudioEditor=xf;exports.AuthManager=ll;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Bn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ol;exports.MailComposer=uf;exports.MailEditor=Ba;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=oi;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=ul;
|
package/dist/index.esm.js
CHANGED
|
@@ -13579,7 +13579,7 @@ function Nf({ onComplete: r, onCancel: e, onTranscribe: t, transcribing: n, vari
|
|
|
13579
13579
|
"canvas",
|
|
13580
13580
|
{
|
|
13581
13581
|
ref: _,
|
|
13582
|
-
style: { width: "100%", height: "
|
|
13582
|
+
style: { width: "100%", height: "32px", cursor: "pointer", flexShrink: 0 },
|
|
13583
13583
|
onMouseDown: (q) => {
|
|
13584
13584
|
if (l === "editing") {
|
|
13585
13585
|
Oe.current = !0, we.current = q.clientX, Ge.current = m;
|
|
@@ -13600,7 +13600,7 @@ function Nf({ onComplete: r, onCancel: e, onTranscribe: t, transcribing: n, vari
|
|
|
13600
13600
|
display: "flex",
|
|
13601
13601
|
alignItems: "center",
|
|
13602
13602
|
justifyContent: "space-between",
|
|
13603
|
-
padding: i ? "
|
|
13603
|
+
padding: i ? "6px 8px" : "4px",
|
|
13604
13604
|
borderTop: "1px solid #d4d4d4",
|
|
13605
13605
|
background: "linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",
|
|
13606
13606
|
boxShadow: "inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",
|
package/package.json
CHANGED