@qwanyx/stack 0.2.34 → 0.2.35

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 CHANGED
@@ -145,4 +145,4 @@ React keys must be passed directly to JSX without using spread:
145
145
  from { transform: rotate(0deg); }
146
146
  to { transform: rotate(360deg); }
147
147
  }
148
- `})]})}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},[p,m]=w.useState(!1),[x,D]=w.useState(""),y=w.useRef(null),A=w.useRef(null);w.useEffect(()=>{function N(L){y.current&&!y.current.contains(L.target)&&(m(!1),D(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var L;return((L=N.label)==null?void 0:L.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),E=s&&x.trim()&&!r.some(N=>{var L;return((L=N.label)==null?void 0:L.toLowerCase())===x.toLowerCase()}),v=e.map(N=>r.find(L=>L.id===N)).filter(Boolean),_=w.useCallback(N=>{var L;c>0&&e.length>=c||(t([...e,N]),D(""),(L=A.current)==null||L.focus())},[e,t,c]),S=w.useCallback(N=>{t(e.filter(L=>L!==N))},[e,t]),T=w.useCallback(async()=>{if(!E)return;const N=await(o==null?void 0:o(x.trim()));N&&_(N.id),D("")},[E,x,o,_]),z=w.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),E?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?S(e[e.length-1]):N.key==="Escape"&&(m(!1),D(""))},[E,C,x,e,T,_,S]);return g.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&g.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),g.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${p?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=>g.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&&g.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),S(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),g.jsx("input",{ref:A,type:"text",value:x,onChange:N=>{D(N.target.value),p||m(!0)},onFocus:()=>m(!0),onKeyDown:z,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}})]}),p&&!u&&g.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&&!E?g.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):g.jsxs(g.Fragment,{children:[C.map(N=>g.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:L=>{L.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:L=>{L.currentTarget.style.background=""},children:[N.label,i&&l&&g.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:L=>{L.currentTarget.style.opacity="1",L.currentTarget.style.color="#ef4444"},onMouseLeave:L=>{L.currentTarget.style.opacity="0.5",L.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),E&&g.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 "',x.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[p,m]=w.useState(null),[x,D]=w.useState(null),[y,A]=w.useState(null),C=w.useRef(null),E=e.reduce((L,P)=>{let j=r.filter(R=>n(R)===P.id);return s&&(j=j.sort((R,X)=>s(R)-s(X))),L[P.id]=j,L},{}),v=w.useCallback((L,P)=>{const j=t(P),R=n(P);m(j),C.current=R,L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",j),requestAnimationFrame(()=>{const X=L.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(L=>{const P=L.target;P.style.opacity="1",m(null),D(null),A(null),C.current=null},[]),S=w.useCallback((L,P,j)=>{L.preventDefault(),L.dataTransfer.dropEffect="move",D(P),A(j)},[]),T=w.useCallback(L=>{const P=L.relatedTarget;P!=null&&P.closest("[data-kanban-column]")||(D(null),A(null))},[]),z=w.useCallback((L,P,j)=>{if(L.preventDefault(),!p)return;const R=C.current;R===P?l==null||l(p,P,j):R&&i(p,R,P,j),m(null),D(null),A(null),C.current=null},[p,i,l]),N=(L,P)=>g.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[L.color&&g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:L.color}}),g.jsx("span",{className:"font-medium text-sm text-neutral-700",children:L.label})]}),g.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:P})]});return g.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(L=>{const P=E[L.id]||[],j=x===L.id;return g.jsxs("div",{"data-kanban-column":L.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:R=>{R.preventDefault(),p&&!j&&D(L.id)},onDragLeave:T,onDrop:R=>z(R,L.id,y??P.length),children:[g.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(L,P.length):N(L,P.length)}),g.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${j?"bg-blue-50":""}`,children:[P.map((R,X)=>{const ge=t(R),ie=p===ge,De=j&&y===X&&!ie;return g.jsxs("div",{children:[De&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),g.jsx("div",{draggable:!0,onDragStart:Ce=>v(Ce,R),onDragEnd:_,onDragOver:Ce=>S(Ce,L.id,X),onClick:()=>a==null?void 0:a(R),className:`cursor-grab active:cursor-grabbing transition-all ${ie?"opacity-50 scale-95":""} ${h}`,children:o(R,ie)})]},ge)}),g.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:R=>{R.preventDefault(),S(R,L.id,P.length)},children:j&&y===P.length&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),P.length===0&&j&&g.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:g.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&g.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(L)})]},L.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:p={}}){const m={...hf,...p},{allDayItems:x,timedItems:D}=w.useMemo(()=>{const _=[],S=[];for(const T of r)l(T)?_.push(T):S.push(T);return{allDayItems:_,timedItems:S}},[r,l]),y=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),A=(n-t+1)*s,C=w.useCallback(_=>{const S=o(_);if(!S)return null;const T=pf(S);if(!T)return null;const{hours:z,minutes:N}=T,L=Math.max(t,Math.min(n,z)),P=z<t?0:N,j=(L-t)*s+P/60*s,R=i(_),X=Math.max(20,R/60*s);return{top:j,height:X}},[o,i,t,n,s]),E=w.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=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),z=(_.clientY-S.top)/s*60,N=Math.floor(z/60)+t,L=Math.round(z%60/15)*15,P=Math.min(n,Math.max(t,N)),j=L>=60?0:L,R=`${P.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`;d(R)},[d,s,t,n]);return g.jsxs("div",{className:h,style:{background:m.background},children:[x.length>0&&g.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[g.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),g.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(_=>g.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),g.jsxs("div",{style:{position:"relative",height:A},children:[y.map((_,S)=>g.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[g.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<y.length-1&&g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:v}),E!==null&&g.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:E,zIndex:20,pointerEvents:"none"},children:[g.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),g.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),D.map(_=>{const S=C(_);return S?g.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]=w.useState("idle"),[u,c]=w.useState(0),[d,f]=w.useState(0),[h,p]=w.useState(!1),[m,x]=w.useState(0),[D,y]=w.useState(null),[A,C]=w.useState(!1),[E,v]=w.useState(null),_=w.useRef(null),S=w.useRef(null),T=w.useRef(null),z=w.useRef(null),N=w.useRef(null),L=w.useRef([]),P=w.useRef(null),j=w.useRef(null),R=w.useRef(null),X=w.useRef(null),ge=w.useRef(!1),ie=w.useRef([]),De=w.useRef(null),Ce=w.useRef(null),Ie=w.useRef([]),ze=w.useRef([]),Me=w.useRef("insert"),Ve=w.useRef(!1),be=w.useRef(0),he=w.useRef(0),Le=w.useRef(0),je=U=>{const B=Math.floor(U/60),Z=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`},me=async U=>{const B=await U.arrayBuffer(),Z=new AudioContext,J=await Z.decodeAudioData(B);return await Z.close(),J},He=U=>{const B=U.numberOfChannels,Z=U.sampleRate,J=1,k=16,$=k/8,H=B*$,Q=Z*H,ee=U.length*H,oe=new ArrayBuffer(44+ee),re=new DataView(oe),te=(fe,ue)=>{for(let Re=0;Re<ue.length;Re++)re.setUint8(fe+Re,ue.charCodeAt(Re))};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,Z,!0),re.setUint32(28,Q,!0),re.setUint16(32,H,!0),re.setUint16(34,k,!0),te(36,"data"),re.setUint32(40,ee,!0);const ye=[];for(let fe=0;fe<B;fe++)ye.push(U.getChannelData(fe));let Se=44;for(let fe=0;fe<U.length;fe++)for(let ue=0;ue<B;ue++){const Re=Math.max(-1,Math.min(1,ye[ue][fe])),Pe=Re<0?Re*32768:Re*32767;re.setInt16(Se,Pe,!0),Se+=2}return new Blob([oe],{type:"audio/wav"})},Tt=async(U,B,Z,J)=>{const k=new AudioContext,$=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(Z,U.length),ee=Math.max(0,U.length-Z),oe=J==="insert"?Q+B.length+ee:Q+B.length,re=k.createBuffer(H,oe,$);for(let te=0;te<H;te++){const ye=re.getChannelData(te),Se=te<U.numberOfChannels?U.getChannelData(te):U.getChannelData(0);for(let ue=0;ue<Q;ue++)ye[ue]=Se[ue];const fe=te<B.numberOfChannels?B.getChannelData(te):B.getChannelData(0);for(let ue=0;ue<B.length;ue++)ye[Q+ue]=fe[ue];if(J==="insert")for(let ue=0;ue<ee;ue++)ye[Q+B.length+ue]=Se[Z+ue]}return await k.close(),re},bt=w.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const Z=U.getBoundingClientRect(),J=Z.width,k=Z.height,$=ie.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,k);const ee=8,oe="rgba(0, 0, 0, 0.4)",re=B.createLinearGradient(0,0,0,ee);re.addColorStop(0,oe),re.addColorStop(1,"transparent"),B.fillStyle=re,B.fillRect(0,0,J,ee);const te=B.createLinearGradient(0,k-ee,0,k);te.addColorStop(0,"transparent"),te.addColorStop(1,oe),B.fillStyle=te,B.fillRect(0,k-ee,J,ee);const ye=B.createLinearGradient(0,0,ee,0);ye.addColorStop(0,oe),ye.addColorStop(1,"transparent"),B.fillStyle=ye,B.fillRect(0,0,ee,k);const Se=B.createLinearGradient(J-ee,0,J,0);Se.addColorStop(0,"transparent"),Se.addColorStop(1,oe),B.fillStyle=Se,B.fillRect(J-ee,0,ee,k),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,k/2),B.lineTo(J,k/2),B.stroke();const fe=J/2;if($.length>0)if(l==="recording")for(let Pe=0;Pe<$.length;Pe++){const lt=$.length-1-Pe,_t=fe-lt*4;if(_t<-3||_t>J)continue;const dt=$[Pe]*(k/2-12),Nt=k/2-dt;B.fillStyle="#10b981",B.fillRect(_t,Nt,3,dt*2)}else{const Pe=H>0?Q/H*$.length:0;for(let lt=0;lt<$.length;lt++){const _t=Pe-lt,dt=fe-_t*4;if(dt<-3||dt>J)continue;const Nt=$[lt]*(k/2-12),fr=k/2-Nt;B.fillStyle=lt<=Pe?"#10b981":"#4b5563",B.fillRect(dt,fr,3,Nt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(fe,0),B.lineTo(fe,k),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(je(Q),fe,k-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]),Mt=()=>{const U=N.current;if(!U||!ge.current)return;const B=U.frequencyBinCount,Z=new Uint8Array(B);U.getByteTimeDomainData(Z);let J=0;for(let H=0;H<B;H++){const Q=(Z[H]-128)/128;J+=Q*Q}const k=Math.sqrt(J/B),$=Math.min(1,k*3);ie.current.push($),bt(),ge.current&&(j.current=requestAnimationFrame(Mt))},it=async()=>{try{y(null),C(!1),De.current===null&&(ie.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;z.current=B;const Z=B.createAnalyser();Z.fftSize=2048,N.current=Z,B.createMediaStreamSource(U).connect(Z);const k=new MediaRecorder(U);S.current=k,L.current=[],k.ondataavailable=$=>{$.data.size>0&&L.current.push($.data)},k.onstop=async()=>{try{if(ge.current=!1,L.current.length===0){y("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(re=>re.stop());return}const $=new Blob(L.current,{type:"audio/webm"});let H,Q;if(De.current!==null&&Ce.current)try{const re=await me($),te=Ce.current.sampleRate,ye=Math.floor(De.current*te),Se=await Tt(Ce.current,re,ye,Me.current);H=He(Se),Q=Se.length/Se.sampleRate,Me.current==="insert"&&(ie.current=[...ie.current,...ze.current]),De.current=null,Ce.current=null,Ie.current=[],ze.current=[]}catch{H=$,Q=be.current>0?be.current:1}else H=$,Q=be.current>0?be.current:1;X.current=H;const ee=URL.createObjectURL(H),oe=new Audio(ee);oe.ontimeupdate=()=>{x(oe.currentTime)},oe.onended=()=>{p(!1)},R.current=oe,f(Q),x(Q),a("editing"),U.getTracks().forEach(re=>re.stop())}catch{y("Failed to process recording"),a("idle")}},k.start(100),ge.current=!0,a("recording"),c(0),be.current=0,P.current=setInterval(()=>{be.current+=1,c(be.current)},1e3)}catch{y("Could not access microphone. Please allow microphone access.")}},ot=()=>{ge.current=!1,C(!1),v(null),j.current&&(cancelAnimationFrame(j.current),j.current=null),P.current&&(clearInterval(P.current),P.current=null),S.current&&S.current.state!=="inactive"&&S.current.stop()},Je=U=>{const B=_.current;if(!B)return;const Z=d||u;if(Z<=0)return;const J=ie.current;if(J.length===0)return;const k=B.getBoundingClientRect(),$=U-he.current,H=4,Q=k.width/B.width,ee=J.length/Z*H,oe=-$/(ee*Q),re=Le.current+oe,te=Math.max(0,Math.min(re,Z));R.current&&(R.current.currentTime=te),x(te)},tt=()=>{R.current&&(R.current.currentTime=0),x(0)},Bt=()=>{const U=d||u;R.current&&(R.current.currentTime=U),x(U)},V=()=>{const U=R.current;U&&(h?(U.pause(),x(U.currentTime),p(!1)):(U.currentTime=m,U.play().catch(()=>{}),p(!0)))},Be=async U=>{if(!X.current){it();return}try{R.current&&(R.current.pause(),p(!1)),Me.current=U,Ce.current=await me(X.current);const B=d||u;De.current=m;const Z=B>0?m/B:0,J=Math.floor(Z*ie.current.length);Ie.current=ie.current.slice(0,J),ze.current=ie.current.slice(J),ie.current=[...Ie.current],it()}catch{y("Failed to prepare recording. Please try again.")}},rt=()=>{R.current&&(R.current.pause(),R.current=null),X.current=null,Ce.current=null,De.current=null,Ie.current=[],p(!1),x(0),f(0),c(0),it()},ct=()=>{X.current?r(X.current,d||u):alert("No audio recorded yet!")};if(w.useEffect(()=>{l==="recording"&&_.current&&N.current&&ge.current&&(j.current=requestAnimationFrame(Mt))},[l]),w.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const Z=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*Z,U.height=J.height*Z;const k=U.getContext("2d");k&&k.scale(Z,Z)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),w.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const Z=U.getBoundingClientRect(),J=Z.width,k=Z.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,k);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,k-$,0,k);ee.addColorStop(0,"transparent"),ee.addColorStop(1,H),B.fillStyle=ee,B.fillRect(0,k-$,J,$);const oe=B.createLinearGradient(0,0,$,0);oe.addColorStop(0,H),oe.addColorStop(1,"transparent"),B.fillStyle=oe,B.fillRect(0,0,$,k);const re=B.createLinearGradient(J-$,0,J,0);re.addColorStop(0,"transparent"),re.addColorStop(1,H),B.fillStyle=re,B.fillRect(J-$,0,$,k),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,k/2),B.lineTo(J,k/2),B.stroke();const te=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(te,0),B.lineTo(te,k),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",te,k-6)}},[l]),w.useEffect(()=>()=>{ge.current=!1,P.current&&clearInterval(P.current),j.current&&cancelAnimationFrame(j.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),z.current&&z.current.state!=="closed"&&z.current.close()},[]),w.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const Z=R.current;if(Z&&h){const J=_.current;if(J){const k=J.getContext("2d");if(k){const $=J.getBoundingClientRect(),H=$.width,Q=$.height,ee=ie.current,oe=d||u||1,re=Z.currentTime;k.fillStyle="#2d3b35",k.fillRect(0,0,H,Q);const te=8,ye="rgba(0, 0, 0, 0.4)",Se=k.createLinearGradient(0,0,0,te);Se.addColorStop(0,ye),Se.addColorStop(1,"transparent"),k.fillStyle=Se,k.fillRect(0,0,H,te);const fe=k.createLinearGradient(0,Q-te,0,Q);fe.addColorStop(0,"transparent"),fe.addColorStop(1,ye),k.fillStyle=fe,k.fillRect(0,Q-te,H,te);const ue=k.createLinearGradient(0,0,te,0);ue.addColorStop(0,ye),ue.addColorStop(1,"transparent"),k.fillStyle=ue,k.fillRect(0,0,te,Q);const Re=k.createLinearGradient(H-te,0,H,0);Re.addColorStop(0,"transparent"),Re.addColorStop(1,ye),k.fillStyle=Re,k.fillRect(H-te,0,te,Q),k.strokeStyle="#5a6b62",k.lineWidth=1,k.beginPath(),k.moveTo(0,Q/2),k.lineTo(H,Q/2),k.stroke();const Pe=H/2,lt=3,_t=4,dt=oe>0?re/oe*ee.length:0;for(let Qt=0;Qt<ee.length;Qt++){const ys=dt-Qt,hr=Pe-ys*_t;if(hr<-lt||hr>H)continue;const Fr=ee[Qt]*(Q/2-12),xs=Q/2-Fr;k.fillStyle=Qt<=dt?"#10b981":"#4b5563",k.fillRect(hr,xs,lt,Fr*2)}k.strokeStyle="#ef4444",k.lineWidth=1,k.beginPath(),k.moveTo(Pe,0),k.lineTo(Pe,Q),k.stroke(),k.fillStyle="#fff",k.font="bold 18px monospace",k.textAlign="center";const Nt=Math.floor(re/60),fr=Math.floor(re%60);k.fillText(`${Nt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,Pe,Q-6),k.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),w.useEffect(()=>{l==="editing"&&!h&&bt()},[l,m,h,bt]),D)return g.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[g.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:D}),g.jsx("button",{onClick:()=>{y(null),it()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const qe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Qe={...qe,opacity:.3,cursor:"not-allowed"},$t=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",height:"100%",display:"flex",flexDirection:"column"};return g.jsxs("div",{style:$t,children:[g.jsx("canvas",{ref:_,style:{width:"100%",height:"80px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Ve.current=!0,he.current=U.clientX,Le.current=m;const B=J=>{Ve.current&&Je(J.clientX)},Z=()=>{Ve.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",Z)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",Z)}}}),g.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"12px 16px":"8px 12px",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:[g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[g.jsx("button",{onClick:tt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Qe:qe,title:"Go to start",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),g.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 V()},disabled:l==="idle",style:l==="idle"?Qe:qe,title:h||l==="recording"&&!A?"Pause":"Play",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!A?"pause":"play_arrow"})}),g.jsx("button",{onClick:Bt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Qe:qe,title:"Go to end",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),g.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))"}}),g.jsx("button",{onClick:()=>{E==="insert"?ot():l==="idle"?(v("insert"),it()):l==="editing"&&(v("insert"),Be("insert"))},disabled:l==="recording"&&E!=="insert"||h,style:l==="recording"&&E!=="insert"||h?Qe:qe,title:E==="insert"?"Stop recording":"Insert recording",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),g.jsx("button",{onClick:()=>{E==="mic"?ot():l==="idle"?(v("mic"),it()):l==="editing"&&(v("mic"),Be("replace"))},disabled:l==="recording"&&E!=="mic"||h,style:l==="recording"&&E!=="mic"||h?Qe:qe,title:E==="mic"?"Stop recording":"Record",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),g.jsx("button",{onClick:()=>{E==="startover"?ot():l==="editing"&&(v("startover"),rt())},disabled:l==="idle"||l==="recording"&&E!=="startover"||h,style:l==="idle"||l==="recording"&&E!=="startover"||h?Qe:qe,title:E==="startover"?"Stop recording":"Start over",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&g.jsx("button",{onClick:()=>X.current&&t(X.current),disabled:l!=="editing"||n,style:l!=="editing"||n?Qe:qe,title:n?"Transcribing...":"Transcribe audio",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&g.jsx("button",{onClick:ct,disabled:l!=="editing",style:l!=="editing"?Qe:qe,title:"Save recording",children:g.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=$a;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;
148
+ `})]})}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},[p,m]=w.useState(!1),[x,D]=w.useState(""),y=w.useRef(null),A=w.useRef(null);w.useEffect(()=>{function N(L){y.current&&!y.current.contains(L.target)&&(m(!1),D(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var L;return((L=N.label)==null?void 0:L.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),E=s&&x.trim()&&!r.some(N=>{var L;return((L=N.label)==null?void 0:L.toLowerCase())===x.toLowerCase()}),v=e.map(N=>r.find(L=>L.id===N)).filter(Boolean),_=w.useCallback(N=>{var L;c>0&&e.length>=c||(t([...e,N]),D(""),(L=A.current)==null||L.focus())},[e,t,c]),S=w.useCallback(N=>{t(e.filter(L=>L!==N))},[e,t]),T=w.useCallback(async()=>{if(!E)return;const N=await(o==null?void 0:o(x.trim()));N&&_(N.id),D("")},[E,x,o,_]),z=w.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),E?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?S(e[e.length-1]):N.key==="Escape"&&(m(!1),D(""))},[E,C,x,e,T,_,S]);return g.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&g.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),g.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${p?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=>g.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&&g.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),S(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),g.jsx("input",{ref:A,type:"text",value:x,onChange:N=>{D(N.target.value),p||m(!0)},onFocus:()=>m(!0),onKeyDown:z,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}})]}),p&&!u&&g.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&&!E?g.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):g.jsxs(g.Fragment,{children:[C.map(N=>g.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:L=>{L.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:L=>{L.currentTarget.style.background=""},children:[N.label,i&&l&&g.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:L=>{L.currentTarget.style.opacity="1",L.currentTarget.style.color="#ef4444"},onMouseLeave:L=>{L.currentTarget.style.opacity="0.5",L.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),E&&g.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 "',x.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[p,m]=w.useState(null),[x,D]=w.useState(null),[y,A]=w.useState(null),C=w.useRef(null),E=e.reduce((L,P)=>{let j=r.filter(R=>n(R)===P.id);return s&&(j=j.sort((R,X)=>s(R)-s(X))),L[P.id]=j,L},{}),v=w.useCallback((L,P)=>{const j=t(P),R=n(P);m(j),C.current=R,L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",j),requestAnimationFrame(()=>{const X=L.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(L=>{const P=L.target;P.style.opacity="1",m(null),D(null),A(null),C.current=null},[]),S=w.useCallback((L,P,j)=>{L.preventDefault(),L.dataTransfer.dropEffect="move",D(P),A(j)},[]),T=w.useCallback(L=>{const P=L.relatedTarget;P!=null&&P.closest("[data-kanban-column]")||(D(null),A(null))},[]),z=w.useCallback((L,P,j)=>{if(L.preventDefault(),!p)return;const R=C.current;R===P?l==null||l(p,P,j):R&&i(p,R,P,j),m(null),D(null),A(null),C.current=null},[p,i,l]),N=(L,P)=>g.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[L.color&&g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:L.color}}),g.jsx("span",{className:"font-medium text-sm text-neutral-700",children:L.label})]}),g.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:P})]});return g.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(L=>{const P=E[L.id]||[],j=x===L.id;return g.jsxs("div",{"data-kanban-column":L.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:R=>{R.preventDefault(),p&&!j&&D(L.id)},onDragLeave:T,onDrop:R=>z(R,L.id,y??P.length),children:[g.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(L,P.length):N(L,P.length)}),g.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${j?"bg-blue-50":""}`,children:[P.map((R,X)=>{const ge=t(R),ie=p===ge,De=j&&y===X&&!ie;return g.jsxs("div",{children:[De&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),g.jsx("div",{draggable:!0,onDragStart:Ce=>v(Ce,R),onDragEnd:_,onDragOver:Ce=>S(Ce,L.id,X),onClick:()=>a==null?void 0:a(R),className:`cursor-grab active:cursor-grabbing transition-all ${ie?"opacity-50 scale-95":""} ${h}`,children:o(R,ie)})]},ge)}),g.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:R=>{R.preventDefault(),S(R,L.id,P.length)},children:j&&y===P.length&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),P.length===0&&j&&g.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:g.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&g.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(L)})]},L.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:p={}}){const m={...hf,...p},{allDayItems:x,timedItems:D}=w.useMemo(()=>{const _=[],S=[];for(const T of r)l(T)?_.push(T):S.push(T);return{allDayItems:_,timedItems:S}},[r,l]),y=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),A=(n-t+1)*s,C=w.useCallback(_=>{const S=o(_);if(!S)return null;const T=pf(S);if(!T)return null;const{hours:z,minutes:N}=T,L=Math.max(t,Math.min(n,z)),P=z<t?0:N,j=(L-t)*s+P/60*s,R=i(_),X=Math.max(20,R/60*s);return{top:j,height:X}},[o,i,t,n,s]),E=w.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=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),z=(_.clientY-S.top)/s*60,N=Math.floor(z/60)+t,L=Math.round(z%60/15)*15,P=Math.min(n,Math.max(t,N)),j=L>=60?0:L,R=`${P.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`;d(R)},[d,s,t,n]);return g.jsxs("div",{className:h,style:{background:m.background},children:[x.length>0&&g.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[g.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),g.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(_=>g.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),g.jsxs("div",{style:{position:"relative",height:A},children:[y.map((_,S)=>g.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[g.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<y.length-1&&g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:v}),E!==null&&g.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:E,zIndex:20,pointerEvents:"none"},children:[g.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),g.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),D.map(_=>{const S=C(_);return S?g.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]=w.useState("idle"),[u,c]=w.useState(0),[d,f]=w.useState(0),[h,p]=w.useState(!1),[m,x]=w.useState(0),[D,y]=w.useState(null),[A,C]=w.useState(!1),[E,v]=w.useState(null),_=w.useRef(null),S=w.useRef(null),T=w.useRef(null),z=w.useRef(null),N=w.useRef(null),L=w.useRef([]),P=w.useRef(null),j=w.useRef(null),R=w.useRef(null),X=w.useRef(null),ge=w.useRef(!1),ie=w.useRef([]),De=w.useRef(null),Ce=w.useRef(null),Ie=w.useRef([]),ze=w.useRef([]),Me=w.useRef("insert"),Ve=w.useRef(!1),be=w.useRef(0),he=w.useRef(0),Le=w.useRef(0),je=U=>{const B=Math.floor(U/60),Z=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`},me=async U=>{const B=await U.arrayBuffer(),Z=new AudioContext,J=await Z.decodeAudioData(B);return await Z.close(),J},He=U=>{const B=U.numberOfChannels,Z=U.sampleRate,J=1,k=16,$=k/8,H=B*$,Q=Z*H,ee=U.length*H,oe=new ArrayBuffer(44+ee),re=new DataView(oe),te=(fe,ue)=>{for(let Re=0;Re<ue.length;Re++)re.setUint8(fe+Re,ue.charCodeAt(Re))};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,Z,!0),re.setUint32(28,Q,!0),re.setUint16(32,H,!0),re.setUint16(34,k,!0),te(36,"data"),re.setUint32(40,ee,!0);const ye=[];for(let fe=0;fe<B;fe++)ye.push(U.getChannelData(fe));let Se=44;for(let fe=0;fe<U.length;fe++)for(let ue=0;ue<B;ue++){const Re=Math.max(-1,Math.min(1,ye[ue][fe])),Pe=Re<0?Re*32768:Re*32767;re.setInt16(Se,Pe,!0),Se+=2}return new Blob([oe],{type:"audio/wav"})},Tt=async(U,B,Z,J)=>{const k=new AudioContext,$=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(Z,U.length),ee=Math.max(0,U.length-Z),oe=J==="insert"?Q+B.length+ee:Q+B.length,re=k.createBuffer(H,oe,$);for(let te=0;te<H;te++){const ye=re.getChannelData(te),Se=te<U.numberOfChannels?U.getChannelData(te):U.getChannelData(0);for(let ue=0;ue<Q;ue++)ye[ue]=Se[ue];const fe=te<B.numberOfChannels?B.getChannelData(te):B.getChannelData(0);for(let ue=0;ue<B.length;ue++)ye[Q+ue]=fe[ue];if(J==="insert")for(let ue=0;ue<ee;ue++)ye[Q+B.length+ue]=Se[Z+ue]}return await k.close(),re},bt=w.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const Z=U.getBoundingClientRect(),J=Z.width,k=Z.height,$=ie.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,k);const ee=8,oe="rgba(0, 0, 0, 0.4)",re=B.createLinearGradient(0,0,0,ee);re.addColorStop(0,oe),re.addColorStop(1,"transparent"),B.fillStyle=re,B.fillRect(0,0,J,ee);const te=B.createLinearGradient(0,k-ee,0,k);te.addColorStop(0,"transparent"),te.addColorStop(1,oe),B.fillStyle=te,B.fillRect(0,k-ee,J,ee);const ye=B.createLinearGradient(0,0,ee,0);ye.addColorStop(0,oe),ye.addColorStop(1,"transparent"),B.fillStyle=ye,B.fillRect(0,0,ee,k);const Se=B.createLinearGradient(J-ee,0,J,0);Se.addColorStop(0,"transparent"),Se.addColorStop(1,oe),B.fillStyle=Se,B.fillRect(J-ee,0,ee,k),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,k/2),B.lineTo(J,k/2),B.stroke();const fe=J/2;if($.length>0)if(l==="recording")for(let Pe=0;Pe<$.length;Pe++){const lt=$.length-1-Pe,_t=fe-lt*4;if(_t<-3||_t>J)continue;const dt=$[Pe]*(k/2-12),Nt=k/2-dt;B.fillStyle="#10b981",B.fillRect(_t,Nt,3,dt*2)}else{const Pe=H>0?Q/H*$.length:0;for(let lt=0;lt<$.length;lt++){const _t=Pe-lt,dt=fe-_t*4;if(dt<-3||dt>J)continue;const Nt=$[lt]*(k/2-12),fr=k/2-Nt;B.fillStyle=lt<=Pe?"#10b981":"#4b5563",B.fillRect(dt,fr,3,Nt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(fe,0),B.lineTo(fe,k),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(je(Q),fe,k-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]),Mt=()=>{const U=N.current;if(!U||!ge.current)return;const B=U.frequencyBinCount,Z=new Uint8Array(B);U.getByteTimeDomainData(Z);let J=0;for(let H=0;H<B;H++){const Q=(Z[H]-128)/128;J+=Q*Q}const k=Math.sqrt(J/B),$=Math.min(1,k*3);ie.current.push($),bt(),ge.current&&(j.current=requestAnimationFrame(Mt))},it=async()=>{try{y(null),C(!1),De.current===null&&(ie.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;z.current=B;const Z=B.createAnalyser();Z.fftSize=2048,N.current=Z,B.createMediaStreamSource(U).connect(Z);const k=new MediaRecorder(U);S.current=k,L.current=[],k.ondataavailable=$=>{$.data.size>0&&L.current.push($.data)},k.onstop=async()=>{try{if(ge.current=!1,L.current.length===0){y("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(re=>re.stop());return}const $=new Blob(L.current,{type:"audio/webm"});let H,Q;if(De.current!==null&&Ce.current)try{const re=await me($),te=Ce.current.sampleRate,ye=Math.floor(De.current*te),Se=await Tt(Ce.current,re,ye,Me.current);H=He(Se),Q=Se.length/Se.sampleRate,Me.current==="insert"&&(ie.current=[...ie.current,...ze.current]),De.current=null,Ce.current=null,Ie.current=[],ze.current=[]}catch{H=$,Q=be.current>0?be.current:1}else H=$,Q=be.current>0?be.current:1;X.current=H;const ee=URL.createObjectURL(H),oe=new Audio(ee);oe.ontimeupdate=()=>{x(oe.currentTime)},oe.onended=()=>{p(!1)},R.current=oe,f(Q),x(Q),a("editing"),U.getTracks().forEach(re=>re.stop())}catch{y("Failed to process recording"),a("idle")}},k.start(100),ge.current=!0,a("recording"),c(0),be.current=0,P.current=setInterval(()=>{be.current+=1,c(be.current)},1e3)}catch{y("Could not access microphone. Please allow microphone access.")}},ot=()=>{ge.current=!1,C(!1),v(null),j.current&&(cancelAnimationFrame(j.current),j.current=null),P.current&&(clearInterval(P.current),P.current=null),S.current&&S.current.state!=="inactive"&&S.current.stop()},Je=U=>{const B=_.current;if(!B)return;const Z=d||u;if(Z<=0)return;const J=ie.current;if(J.length===0)return;const k=B.getBoundingClientRect(),$=U-he.current,H=4,Q=k.width/B.width,ee=J.length/Z*H,oe=-$/(ee*Q),re=Le.current+oe,te=Math.max(0,Math.min(re,Z));R.current&&(R.current.currentTime=te),x(te)},tt=()=>{R.current&&(R.current.currentTime=0),x(0)},Bt=()=>{const U=d||u;R.current&&(R.current.currentTime=U),x(U)},V=()=>{const U=R.current;U&&(h?(U.pause(),x(U.currentTime),p(!1)):(U.currentTime=m,U.play().catch(()=>{}),p(!0)))},Be=async U=>{if(!X.current){it();return}try{R.current&&(R.current.pause(),p(!1)),Me.current=U,Ce.current=await me(X.current);const B=d||u;De.current=m;const Z=B>0?m/B:0,J=Math.floor(Z*ie.current.length);Ie.current=ie.current.slice(0,J),ze.current=ie.current.slice(J),ie.current=[...Ie.current],it()}catch{y("Failed to prepare recording. Please try again.")}},rt=()=>{R.current&&(R.current.pause(),R.current=null),X.current=null,Ce.current=null,De.current=null,Ie.current=[],p(!1),x(0),f(0),c(0),it()},ct=()=>{X.current?r(X.current,d||u):alert("No audio recorded yet!")};if(w.useEffect(()=>{l==="recording"&&_.current&&N.current&&ge.current&&(j.current=requestAnimationFrame(Mt))},[l]),w.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const Z=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*Z,U.height=J.height*Z;const k=U.getContext("2d");k&&k.scale(Z,Z)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),w.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const Z=U.getBoundingClientRect(),J=Z.width,k=Z.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,k);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,k-$,0,k);ee.addColorStop(0,"transparent"),ee.addColorStop(1,H),B.fillStyle=ee,B.fillRect(0,k-$,J,$);const oe=B.createLinearGradient(0,0,$,0);oe.addColorStop(0,H),oe.addColorStop(1,"transparent"),B.fillStyle=oe,B.fillRect(0,0,$,k);const re=B.createLinearGradient(J-$,0,J,0);re.addColorStop(0,"transparent"),re.addColorStop(1,H),B.fillStyle=re,B.fillRect(J-$,0,$,k),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,k/2),B.lineTo(J,k/2),B.stroke();const te=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(te,0),B.lineTo(te,k),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",te,k-6)}},[l]),w.useEffect(()=>()=>{ge.current=!1,P.current&&clearInterval(P.current),j.current&&cancelAnimationFrame(j.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),z.current&&z.current.state!=="closed"&&z.current.close()},[]),w.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const Z=R.current;if(Z&&h){const J=_.current;if(J){const k=J.getContext("2d");if(k){const $=J.getBoundingClientRect(),H=$.width,Q=$.height,ee=ie.current,oe=d||u||1,re=Z.currentTime;k.fillStyle="#2d3b35",k.fillRect(0,0,H,Q);const te=8,ye="rgba(0, 0, 0, 0.4)",Se=k.createLinearGradient(0,0,0,te);Se.addColorStop(0,ye),Se.addColorStop(1,"transparent"),k.fillStyle=Se,k.fillRect(0,0,H,te);const fe=k.createLinearGradient(0,Q-te,0,Q);fe.addColorStop(0,"transparent"),fe.addColorStop(1,ye),k.fillStyle=fe,k.fillRect(0,Q-te,H,te);const ue=k.createLinearGradient(0,0,te,0);ue.addColorStop(0,ye),ue.addColorStop(1,"transparent"),k.fillStyle=ue,k.fillRect(0,0,te,Q);const Re=k.createLinearGradient(H-te,0,H,0);Re.addColorStop(0,"transparent"),Re.addColorStop(1,ye),k.fillStyle=Re,k.fillRect(H-te,0,te,Q),k.strokeStyle="#5a6b62",k.lineWidth=1,k.beginPath(),k.moveTo(0,Q/2),k.lineTo(H,Q/2),k.stroke();const Pe=H/2,lt=3,_t=4,dt=oe>0?re/oe*ee.length:0;for(let Qt=0;Qt<ee.length;Qt++){const ys=dt-Qt,hr=Pe-ys*_t;if(hr<-lt||hr>H)continue;const Fr=ee[Qt]*(Q/2-12),xs=Q/2-Fr;k.fillStyle=Qt<=dt?"#10b981":"#4b5563",k.fillRect(hr,xs,lt,Fr*2)}k.strokeStyle="#ef4444",k.lineWidth=1,k.beginPath(),k.moveTo(Pe,0),k.lineTo(Pe,Q),k.stroke(),k.fillStyle="#fff",k.font="bold 18px monospace",k.textAlign="center";const Nt=Math.floor(re/60),fr=Math.floor(re%60);k.fillText(`${Nt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,Pe,Q-6),k.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),w.useEffect(()=>{l==="editing"&&!h&&bt()},[l,m,h,bt]),D)return g.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[g.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:D}),g.jsx("button",{onClick:()=>{y(null),it()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const qe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Qe={...qe,opacity:.3,cursor:"not-allowed"},$t=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",height:"100%",display:"flex",flexDirection:"column"};return g.jsxs("div",{style:$t,children:[g.jsx("canvas",{ref:_,style:{width:"100%",height:"64px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Ve.current=!0,he.current=U.clientX,Le.current=m;const B=J=>{Ve.current&&Je(J.clientX)},Z=()=>{Ve.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",Z)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",Z)}}}),g.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:[g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[g.jsx("button",{onClick:tt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Qe:qe,title:"Go to start",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),g.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 V()},disabled:l==="idle",style:l==="idle"?Qe:qe,title:h||l==="recording"&&!A?"Pause":"Play",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!A?"pause":"play_arrow"})}),g.jsx("button",{onClick:Bt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Qe:qe,title:"Go to end",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),g.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))"}}),g.jsx("button",{onClick:()=>{E==="insert"?ot():l==="idle"?(v("insert"),it()):l==="editing"&&(v("insert"),Be("insert"))},disabled:l==="recording"&&E!=="insert"||h,style:l==="recording"&&E!=="insert"||h?Qe:qe,title:E==="insert"?"Stop recording":"Insert recording",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),g.jsx("button",{onClick:()=>{E==="mic"?ot():l==="idle"?(v("mic"),it()):l==="editing"&&(v("mic"),Be("replace"))},disabled:l==="recording"&&E!=="mic"||h,style:l==="recording"&&E!=="mic"||h?Qe:qe,title:E==="mic"?"Stop recording":"Record",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),g.jsx("button",{onClick:()=>{E==="startover"?ot():l==="editing"&&(v("startover"),rt())},disabled:l==="idle"||l==="recording"&&E!=="startover"||h,style:l==="idle"||l==="recording"&&E!=="startover"||h?Qe:qe,title:E==="startover"?"Stop recording":"Start over",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&g.jsx("button",{onClick:()=>X.current&&t(X.current),disabled:l!=="editing"||n,style:l!=="editing"||n?Qe:qe,title:n?"Transcribing...":"Transcribe audio",children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&g.jsx("button",{onClick:ct,disabled:l!=="editing",style:l!=="editing"?Qe:qe,title:"Save recording",children:g.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=$a;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
@@ -13380,7 +13380,7 @@ function Nf({ onComplete: r, onCancel: e, onTranscribe: t, transcribing: n, vari
13380
13380
  "canvas",
13381
13381
  {
13382
13382
  ref: b,
13383
- style: { width: "100%", height: "80px", cursor: "pointer", flexShrink: 0 },
13383
+ style: { width: "100%", height: "64px", cursor: "pointer", flexShrink: 0 },
13384
13384
  onMouseDown: (q) => {
13385
13385
  if (l === "editing") {
13386
13386
  Qe.current = !0, ge.current = q.clientX, Re.current = m;
@@ -13401,7 +13401,7 @@ function Nf({ onComplete: r, onCancel: e, onTranscribe: t, transcribing: n, vari
13401
13401
  display: "flex",
13402
13402
  alignItems: "center",
13403
13403
  justifyContent: "space-between",
13404
- padding: i ? "12px 16px" : "8px 12px",
13404
+ padding: i ? "10px 12px" : "8px",
13405
13405
  borderTop: "1px solid #d4d4d4",
13406
13406
  background: "linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",
13407
13407
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "Modern HyperCard for React - All-in-one data management (REST + Graph API + Auth + Hooks + UI)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",