@qwanyx/stack 0.2.73 → 0.2.74
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 +0 -3
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -182,7 +182,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
182
182
|
}
|
|
183
183
|
`})]})}const Dg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Ag({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:i=!0,onCreate:s,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Dg,...d},[g,m]=b.useState(!1),[x,w]=b.useState(""),y=b.useRef(null),C=b.useRef(null);b.useEffect(()=>{function T(F){y.current&&!y.current.contains(F.target)&&(m(!1),w(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var F;return((F=T.label)==null?void 0:F.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=i&&x.trim()&&!r.some(T=>{var F;return((F=T.label)==null?void 0:F.toLowerCase())===x.toLowerCase()}),_=e.map(T=>r.find(F=>F.id===T)).filter(Boolean),v=b.useCallback(T=>{var F;c>0&&e.length>=c||(t([...e,T]),w(""),c===1?m(!1):(F=C.current)==null||F.focus())},[e,t,c]),E=b.useCallback(T=>{t(e.filter(F=>F!==T))},[e,t]),B=b.useCallback(async()=>{if(!D)return;const T=await(s==null?void 0:s(x.trim()));T&&v(T.id),w("")},[D,x,s,v]),N=b.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?B():S.length>0&&v(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):T.key==="Escape"&&(m(!1),w(""))},[D,S,x,e,B,v,E]);return h.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[_.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),E(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:C,type:"text",value:x,onChange:T=>{w(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:N,placeholder:_.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!D?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(T=>h.jsxs("div",{onClick:()=>v(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:F=>{F.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:F=>{F.currentTarget.style.background=""},children:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:F=>{F.currentTarget.style.opacity="1",F.currentTarget.style.color="#ef4444"},onMouseLeave:F=>{F.currentTarget.style.opacity="0.5",F.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:B,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Tg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Ng({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:i,onClear:s,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Tg,...u},[d,f]=b.useState(""),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(null),w=b.useMemo(()=>e&&r.find(v=>v.id===e)||null,[e,r]),y=b.useMemo(()=>{if(!d.trim())return r;const v=d.toLowerCase();return r.filter(E=>{var B,N;return((B=E.label)==null?void 0:B.toLowerCase().includes(v))||((N=E.notes)==null?void 0:N.toLowerCase().includes(v))})},[r,d]);b.useEffect(()=>{const v=E=>{m.current&&!m.current.contains(E.target)&&g(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const C=v=>{i&&i(v),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},_=v=>{f(v.target.value),p||g(!0)};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:w&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.label}),w.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.notes})]}),s&&h.jsx("button",{onClick:v=>{v.stopPropagation(),s()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:_,onFocus:D,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:v=>{v.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:y.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):y.map((v,E)=>h.jsxs("div",{onClick:()=>C(v),style:{padding:"10px 14px",cursor:"pointer",borderBottom:E<y.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:B=>{B.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:B=>{B.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.color||c.text,marginBottom:v.notes?"2px":0},children:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]},v.id))})]})}function Bg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:i,renderItem:s,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=b.useState(null),[x,w]=b.useState(null),[y,C]=b.useState(null),S=b.useRef(null),D=e.reduce((F,j)=>{let k=r.filter(R=>n(R)===j.id);return i&&(k=k.sort((R,M)=>i(R)-i(M))),F[j.id]=k,F},{}),_=b.useCallback((F,j)=>{const k=t(j),R=n(j);m(k),S.current=R,F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",k),requestAnimationFrame(()=>{const M=F.target;M.style.opacity="0.5"})},[t,n]),v=b.useCallback(F=>{const j=F.target;j.style.opacity="1",m(null),w(null),C(null),S.current=null},[]),E=b.useCallback((F,j,k)=>{F.preventDefault(),F.dataTransfer.dropEffect="move",w(j),C(k)},[]),B=b.useCallback(F=>{const j=F.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(w(null),C(null))},[]),N=b.useCallback((F,j,k)=>{if(F.preventDefault(),!g)return;const R=S.current;R===j?l==null||l(g,j,k):R&&o(g,R,j,k),m(null),w(null),C(null),S.current=null},[g,o,l]),T=(F,j)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[F.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:F.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:F.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(F=>{const j=D[F.id]||[],k=x===F.id;return h.jsxs("div",{"data-kanban-column":F.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:R=>{R.preventDefault(),g&&!k&&w(F.id)},onDragLeave:B,onDrop:R=>N(R,F.id,y??j.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(F,j.length):T(F,j.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${k?"bg-blue-50":""}`,children:[j.map((R,M)=>{const O=t(R),V=g===O,W=k&&y===M&&!V;return h.jsxs("div",{children:[W&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:te=>_(te,R),onDragEnd:v,onDragOver:te=>E(te,F.id,M),onClick:()=>a==null?void 0:a(R),className:`cursor-grab active:cursor-grabbing transition-all ${V?"opacity-50 scale-95":""} ${p}`,children:s(R,V)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:R=>{R.preventDefault(),E(R,F.id,j.length)},children:k&&y===j.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&k&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(F)})]},F.id)})})}const Rg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Mg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Fg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function jg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Lg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:i=60,getItemTime:s,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Rg,...g},{allDayItems:x,timedItems:w}=b.useMemo(()=>{const v=[],E=[];for(const B of r)l(B)?v.push(B):E.push(B);return{allDayItems:v,timedItems:E}},[r,l]),y=b.useMemo(()=>{const v=[];for(let E=t;E<=n;E++)v.push(E);return v},[t,n]),C=(n-t+1)*i,S=b.useCallback(v=>{const E=s(v);if(!E)return null;const B=Mg(E);if(!B)return null;const{hours:N,minutes:T}=B,F=Math.max(t,Math.min(n,N)),j=N<t?0:T,k=(F-t)*i+j/60*i,R=o(v),M=Math.max(20,R/60*i);return{top:k,height:M}},[s,o,t,n,i]),D=b.useMemo(()=>{if(!f||!jg(e))return null;const v=new Date,E=v.getHours(),B=v.getMinutes();return E<t||E>n?null:(E-t)*i+B/60*i},[e,f,t,n,i]),_=b.useCallback(v=>{if(!d)return;const E=v.currentTarget.getBoundingClientRect(),N=(v.clientY-E.top)/i*60,T=Math.floor(N/60)+t,F=Math.round(N%60/15)*15,j=Math.min(n,Math.max(t,T)),k=F>=60?0:F,R=`${j.toString().padStart(2,"0")}:${k.toString().padStart(2,"0")}`;d(R)},[d,i,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>h.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},a(v)))})]}),h.jsxs("div",{style:{position:"relative",height:C},children:[y.map((v,E)=>h.jsxs("div",{style:{position:"absolute",top:E*i,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Fg(v)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<y.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:i/2,height:"1px",background:m.halfHourLineColor}})]},v)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:_}),D!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:D,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),w.map(v=>{const E=S(v);return E?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:B=>{B.stopPropagation(),c==null||c(v)},children:u(v)},a(v)):null})]})]})}function Gc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:i="widget",hideSaveButton:s=!1,maxDuration:o=180}){const l=i==="widget",[a,u]=b.useState("idle"),[c,d]=b.useState(0),[f,p]=b.useState(0),[g,m]=b.useState(!1),[x,w]=b.useState(0),[y,C]=b.useState(null),[S,D]=b.useState(!1),[_,v]=b.useState(null),[E,B]=b.useState(!0),[N,T]=b.useState([]),[F,j]=b.useState({completed:0,total:0}),k=b.useRef(!1),R=b.useRef(!0);b.useEffect(()=>{R.current=E},[E]);const M=b.useRef(null),O=b.useRef(null),V=b.useRef(null),W=b.useRef(null),te=b.useRef(null),q=b.useRef([]),Q=b.useRef(null),U=b.useRef(null),oe=b.useRef(null),ce=b.useRef(null),fe=b.useRef(!1),ge=b.useRef([]),De=b.useRef(null),xe=b.useRef(null),X=b.useRef([]),Ce=b.useRef([]),re=b.useRef("insert"),Me=b.useRef(!1),Se=b.useRef(0),ke=b.useRef(0),Ie=b.useRef(0),Le=J=>{const L=Math.floor(J/60),ue=Math.floor(J%60);return`${L.toString().padStart(2,"0")}:${ue.toString().padStart(2,"0")}`},ae=async J=>{const L=await J.arrayBuffer(),ue=new AudioContext,he=await ue.decodeAudioData(L);return await ue.close(),he},ee=J=>{const L=J.numberOfChannels,ue=J.sampleRate,he=1,G=16,we=G/8,be=L*we,ve=ue*be,Fe=J.length*be,Ue=new ArrayBuffer(44+Fe),_e=new DataView(Ue),Ee=(Ve,Oe)=>{for(let ut=0;ut<Oe.length;ut++)_e.setUint8(Ve+ut,Oe.charCodeAt(ut))};Ee(0,"RIFF"),_e.setUint32(4,36+Fe,!0),Ee(8,"WAVE"),Ee(12,"fmt "),_e.setUint32(16,16,!0),_e.setUint16(20,he,!0),_e.setUint16(22,L,!0),_e.setUint32(24,ue,!0),_e.setUint32(28,ve,!0),_e.setUint16(32,be,!0),_e.setUint16(34,G,!0),Ee(36,"data"),_e.setUint32(40,Fe,!0);const et=[];for(let Ve=0;Ve<L;Ve++)et.push(J.getChannelData(Ve));let nt=44;for(let Ve=0;Ve<J.length;Ve++)for(let Oe=0;Oe<L;Oe++){const ut=Math.max(-1,Math.min(1,et[Oe][Ve])),ct=ut<0?ut*32768:ut*32767;_e.setInt16(nt,ct,!0),nt+=2}return new Blob([Ue],{type:"audio/wav"})},I=async(J,L,ue,he)=>{const G=new AudioContext,we=J.sampleRate,be=Math.max(J.numberOfChannels,L.numberOfChannels),ve=Math.min(ue,J.length),Fe=Math.max(0,J.length-ue),Ue=he==="insert"?ve+L.length+Fe:ve+L.length,_e=G.createBuffer(be,Ue,we);for(let Ee=0;Ee<be;Ee++){const et=_e.getChannelData(Ee),nt=Ee<J.numberOfChannels?J.getChannelData(Ee):J.getChannelData(0);for(let Oe=0;Oe<ve;Oe++)et[Oe]=nt[Oe];const Ve=Ee<L.numberOfChannels?L.getChannelData(Ee):L.getChannelData(0);for(let Oe=0;Oe<L.length;Oe++)et[ve+Oe]=Ve[Oe];if(he==="insert")for(let Oe=0;Oe<Fe;Oe++)et[ve+L.length+Oe]=nt[ue+Oe]}return await G.close(),_e},$e=b.useCallback(()=>{const J=M.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const ue=J.getBoundingClientRect(),he=ue.width,G=ue.height,we=ge.current,be=f||c||1,ve=a==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,he,G);const Fe=8,Ue="rgba(0, 0, 0, 0.4)",_e=L.createLinearGradient(0,0,0,Fe);_e.addColorStop(0,Ue),_e.addColorStop(1,"transparent"),L.fillStyle=_e,L.fillRect(0,0,he,Fe);const Ee=L.createLinearGradient(0,G-Fe,0,G);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,Ue),L.fillStyle=Ee,L.fillRect(0,G-Fe,he,Fe);const et=L.createLinearGradient(0,0,Fe,0);et.addColorStop(0,Ue),et.addColorStop(1,"transparent"),L.fillStyle=et,L.fillRect(0,0,Fe,G);const nt=L.createLinearGradient(he-Fe,0,he,0);nt.addColorStop(0,"transparent"),nt.addColorStop(1,Ue),L.fillStyle=nt,L.fillRect(he-Fe,0,Fe,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(he,G/2),L.stroke();const Ve=he/2;if(we.length>0)if(a==="recording")for(let ct=0;ct<we.length;ct++){const Dt=we.length-1-ct,Zt=Ve-Dt*4;if(Zt<-3||Zt>he)continue;const Rt=we[ct]*(G/2-12),A=G/2-Rt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,Rt*2)}else{const ct=be>0?ve/be*we.length:0;for(let Dt=0;Dt<we.length;Dt++){const Zt=ct-Dt,Rt=Ve-Zt*4;if(Rt<-3||Rt>he)continue;const A=we[Dt]*(G/2-12),z=G/2-A;L.fillStyle=Dt<=ct?"#10b981":"#4b5563",L.fillRect(Rt,z,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ve,0),L.lineTo(Ve,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(ve),Ve,G-6),a==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[a,x,c,f]),qe=()=>{const J=te.current;if(!J||!fe.current)return;const L=J.frequencyBinCount,ue=new Uint8Array(L);J.getByteTimeDomainData(ue);let he=0;for(let be=0;be<L;be++){const ve=(ue[be]-128)/128;he+=ve*ve}const G=Math.sqrt(he/L),we=Math.min(1,G*3);ge.current.push(we),$e(),fe.current&&(U.current=requestAnimationFrame(qe))},$=async()=>{try{C(null),D(!1),De.current===null&&(ge.current=[]);const J=await navigator.mediaDevices.getUserMedia({audio:!0});V.current=J;const L=new AudioContext;W.current=L;const ue=L.createAnalyser();ue.fftSize=2048,te.current=ue,L.createMediaStreamSource(J).connect(ue);const G=new MediaRecorder(J);O.current=G,q.current=[],G.ondataavailable=we=>{we.data.size>0&&q.current.push(we.data)},G.onstop=async()=>{try{if(fe.current=!1,q.current.length===0){C("No audio was recorded. Please try again."),u("idle"),J.getTracks().forEach(_e=>_e.stop());return}const we=new Blob(q.current,{type:"audio/webm"});let be,ve;if(De.current!==null&&xe.current)try{const _e=await ae(we),Ee=xe.current.sampleRate,et=Math.floor(De.current*Ee),nt=await I(xe.current,_e,et,re.current);be=ee(nt),ve=nt.length/nt.sampleRate,re.current==="insert"&&(ge.current=[...ge.current,...Ce.current]),De.current=null,xe.current=null,X.current=[],Ce.current=[]}catch{be=we,ve=Se.current>0?Se.current:1}else be=we,ve=Se.current>0?Se.current:1;if(ce.current=be,J.getTracks().forEach(_e=>_e.stop()),R.current&&t){T(_e=>[..._e,be]),j(_e=>({..._e,total:_e.total+1})),ce.current=null,ge.current=[],w(0),p(0),d(0),u("idle");return}const Fe=URL.createObjectURL(be),Ue=new Audio(Fe);Ue.ontimeupdate=()=>{w(Ue.currentTime)},Ue.onended=()=>{m(!1)},oe.current=Ue,p(ve),w(ve),u("editing")}catch{C("Failed to process recording"),u("idle")}},G.start(100),fe.current=!0,u("recording"),d(0),Se.current=0,Q.current=setInterval(()=>{Se.current+=1,d(Se.current),Se.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),fe.current=!1,v(null),Q.current&&(clearInterval(Q.current),Q.current=null),U.current&&(cancelAnimationFrame(U.current),U.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},le=()=>{fe.current=!1,D(!1),v(null),U.current&&(cancelAnimationFrame(U.current),U.current=null),Q.current&&(clearInterval(Q.current),Q.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},me=J=>{const L=M.current;if(!L)return;const ue=f||c;if(ue<=0)return;const he=ge.current;if(he.length===0)return;const G=L.getBoundingClientRect(),we=J-ke.current,be=4,ve=G.width/L.width,Fe=he.length/ue*be,Ue=-we/(Fe*ve),_e=Ie.current+Ue,Ee=Math.max(0,Math.min(_e,ue));oe.current&&(oe.current.currentTime=Ee),w(Ee)},ye=()=>{oe.current&&(oe.current.currentTime=0),w(0)},We=()=>{const J=f||c;oe.current&&(oe.current.currentTime=J),w(J)},mt=()=>{const J=oe.current;J&&(g?(J.pause(),w(J.currentTime),m(!1)):(J.currentTime=x,J.play().catch(()=>{}),m(!0)))},yt=async J=>{if(!ce.current){$();return}try{oe.current&&(oe.current.pause(),m(!1)),re.current=J,xe.current=await ae(ce.current);const L=f||c;De.current=x;const ue=L>0?x/L:0,he=Math.floor(ue*ge.current.length);X.current=ge.current.slice(0,he),Ce.current=ge.current.slice(he),ge.current=[...X.current],$()}catch{C("Failed to prepare recording. Please try again.")}},ie=()=>{oe.current&&(oe.current.pause(),oe.current=null),ce.current=null,xe.current=null,De.current=null,X.current=[],m(!1),w(0),p(0),d(0),$()},de=()=>{ce.current?r(ce.current,f||c):alert("No audio recorded yet!")};b.useEffect(()=>{a==="recording"&&M.current&&te.current&&fe.current&&(U.current=requestAnimationFrame(qe))},[a]),b.useEffect(()=>{const J=M.current;if(!J)return;const L=()=>{const ue=window.devicePixelRatio||1,he=J.getBoundingClientRect();J.width=he.width*ue,J.height=he.height*ue;const G=J.getContext("2d");G&&G.scale(ue,ue)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),b.useEffect(()=>{if(a==="idle"){const J=M.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const ue=J.getBoundingClientRect(),he=ue.width,G=ue.height;L.fillStyle="#2d3b35",L.fillRect(0,0,he,G);const we=8,be="rgba(0, 0, 0, 0.4)",ve=L.createLinearGradient(0,0,0,we);ve.addColorStop(0,be),ve.addColorStop(1,"transparent"),L.fillStyle=ve,L.fillRect(0,0,he,we);const Fe=L.createLinearGradient(0,G-we,0,G);Fe.addColorStop(0,"transparent"),Fe.addColorStop(1,be),L.fillStyle=Fe,L.fillRect(0,G-we,he,we);const Ue=L.createLinearGradient(0,0,we,0);Ue.addColorStop(0,be),Ue.addColorStop(1,"transparent"),L.fillStyle=Ue,L.fillRect(0,0,we,G);const _e=L.createLinearGradient(he-we,0,he,0);_e.addColorStop(0,"transparent"),_e.addColorStop(1,be),L.fillStyle=_e,L.fillRect(he-we,0,we,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(he,G/2),L.stroke();const Ee=he/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ee,0),L.lineTo(Ee,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Ee,G-6)}},[a]);const He=b.useCallback(J=>{T(L=>[...L,J]),j(L=>({...L,total:L.total+1}))},[]);if(b.useEffect(()=>{(async()=>{if(k.current||N.length===0||!t)return;k.current=!0;const L=N[0];try{const ue=await t(L);ue&&n&&n(ue)}catch(ue){console.error("Transcription failed:",ue)}finally{T(ue=>ue.slice(1)),j(ue=>({...ue,completed:ue.completed+1})),k.current=!1}})()},[N,t,n]),b.useEffect(()=>()=>{fe.current=!1,Q.current&&clearInterval(Q.current),U.current&&cancelAnimationFrame(U.current),V.current&&V.current.getTracks().forEach(J=>J.stop()),W.current&&W.current.state!=="closed"&&W.current.close()},[]),b.useEffect(()=>{if(a==="editing"&&g){let J;const L=()=>{const ue=oe.current;if(ue&&g){const he=M.current;if(he){const G=he.getContext("2d");if(G){const we=he.getBoundingClientRect(),be=we.width,ve=we.height,Fe=ge.current,Ue=f||c||1,_e=ue.currentTime;G.fillStyle="#2d3b35",G.fillRect(0,0,be,ve);const Ee=8,et="rgba(0, 0, 0, 0.4)",nt=G.createLinearGradient(0,0,0,Ee);nt.addColorStop(0,et),nt.addColorStop(1,"transparent"),G.fillStyle=nt,G.fillRect(0,0,be,Ee);const Ve=G.createLinearGradient(0,ve-Ee,0,ve);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,et),G.fillStyle=Ve,G.fillRect(0,ve-Ee,be,Ee);const Oe=G.createLinearGradient(0,0,Ee,0);Oe.addColorStop(0,et),Oe.addColorStop(1,"transparent"),G.fillStyle=Oe,G.fillRect(0,0,Ee,ve);const ut=G.createLinearGradient(be-Ee,0,be,0);ut.addColorStop(0,"transparent"),ut.addColorStop(1,et),G.fillStyle=ut,G.fillRect(be-Ee,0,Ee,ve),G.strokeStyle="#5a6b62",G.lineWidth=1,G.beginPath(),G.moveTo(0,ve/2),G.lineTo(be,ve/2),G.stroke();const ct=be/2,Dt=3,Zt=4,Rt=Ue>0?_e/Ue*Fe.length:0;for(let Z=0;Z<Fe.length;Z++){const pe=Rt-Z,Be=ct-pe*Zt;if(Be<-Dt||Be>be)continue;const Pe=Fe[Z]*(ve/2-12),Te=ve/2-Pe;G.fillStyle=Z<=Rt?"#10b981":"#4b5563",G.fillRect(Be,Te,Dt,Pe*2)}G.strokeStyle="#ef4444",G.lineWidth=1,G.beginPath(),G.moveTo(ct,0),G.lineTo(ct,ve),G.stroke(),G.fillStyle="#fff",G.font="bold 18px monospace",G.textAlign="center";const A=Math.floor(_e/60),z=Math.floor(_e%60);G.fillText(`${A.toString().padStart(2,"0")}:${z.toString().padStart(2,"0")}`,ct,ve-6),G.textAlign="left"}}J=requestAnimationFrame(L)}};return J=requestAnimationFrame(L),()=>cancelAnimationFrame(J)}},[a,g,f,c]),b.useEffect(()=>{a==="editing"&&!g&&$e()},[a,x,g,$e]),y)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:y}),h.jsx("button",{onClick:()=>{C(null),$()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Je={...Xe,opacity:.3,cursor:"not-allowed"},Bt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Bt,children:[h.jsx("canvas",{ref:M,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:J=>{if(a==="editing"){Me.current=!0,ke.current=J.clientX,Ie.current=x;const L=he=>{Me.current&&me(he.clientX)},ue=()=>{Me.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",ue)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",ue)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"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:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ye,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const J=O.current;J&&(J.state==="recording"?(J.pause(),D(!0)):J.state==="paused"&&(J.resume(),D(!1)))}else mt()},disabled:a==="idle",style:a==="idle"?Je:Xe,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:We,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.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))"}}),h.jsx("button",{onClick:()=>{_==="insert"?le():a==="idle"?(v("insert"),$()):a==="editing"&&(v("insert"),yt("insert"))},disabled:a==="recording"&&_!=="insert"||g,style:a==="recording"&&_!=="insert"||g?Je:Xe,title:_==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{R.current||(_==="mic"?le():a==="idle"?(v("mic"),$()):a==="editing"&&(v("mic"),yt("replace")))},onMouseDown:()=>{R.current&&a==="idle"&&!g&&(v("mic"),$())},onMouseUp:()=>{R.current&&a==="recording"&&_==="mic"&&le()},onMouseLeave:()=>{R.current&&a==="recording"&&_==="mic"&&le()},onTouchStart:()=>{R.current&&a==="idle"&&!g&&(v("mic"),$())},onTouchEnd:()=>{R.current&&a==="recording"&&_==="mic"&&le()},disabled:a==="recording"&&_!=="mic"||g,style:a==="recording"&&_!=="mic"||g?Je:Xe,title:E?"Hold to record (walkie-talkie)":_==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{_==="startover"?le():a==="editing"&&(v("startover"),ie())},disabled:a==="idle"||a==="recording"&&_!=="startover"||g,style:a==="idle"||a==="recording"&&_!=="startover"||g?Je:Xe,title:_==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[F.total>0&&F.completed<F.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),F.completed,"/",F.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>B(!E),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:E?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:E?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:E?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ce.current&&He(ce.current)},disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!s&&h.jsx("button",{onClick:de,disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),F.total>0&&F.completed<F.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${F.completed/F.total*100}%`,transition:"width 0.3s ease"}})})]})}function Pg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:i,placeholder:s="Type or record...",className:o="",rows:l}){const[a,u]=b.useState(!1),[c,d]=b.useState(null),[f,p]=b.useState(!1),g=b.useRef(null),m=y=>{t(e?`${e}
|
|
184
184
|
|
|
185
|
-
${y}`:y)},x=async y=>{if(!(!e.trim()||a||!i)){u(!0),d(y),p(!1);try{const C=await i(y,e);t(C)}catch(C){console.error(`${y} failed:`,C)}finally{u(!1),d(null)}}},w=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Gc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),i&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:w,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:s,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const mi={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Ig({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:i="image/jpeg",outputQuality:s=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,w]=b.useState(0),[y,C]=b.useState({x:0,y:0,width:100,height:100}),[S,D]=b.useState(!1),[_,v]=b.useState(null),[E,B]=b.useState({x:0,y:0}),[N,T]=b.useState({x:0,y:0,width:100,height:100}),F=o==="dark",j=b.useCallback(()=>{const X=u.current;return X?x===90||x===270?{width:X.height,height:X.width}:{width:X.width,height:X.height}:{width:100,height:100}},[x]),k=b.useCallback((X,Ce)=>{const re=X/Ce,Me=.05;for(const[Se,ke]of Object.entries(mi))if(ke!==null&&Math.abs(re-ke)/ke<Me)return Se;return"free"},[]);b.useEffect(()=>{const X=new Image;X.crossOrigin="anonymous",X.onload=()=>{u.current=X;const Ce=k(X.width,X.height);m(Ce),d(!1)},X.onerror=()=>{p("Failed to load image"),d(!1)},X.src=r},[r,k]);const R=b.useCallback(()=>{const{width:X,height:Ce}=j(),re=mi[g];if(re===null){C({x:0,y:0,width:100,height:100});return}const Me=X/Ce;let Se,ke;Me>re?(ke=100,Se=re/Me*100):(Se=100,ke=Me/re*100);const Ie=(100-Se)/2,Le=(100-ke)/2;C({x:Ie,y:Le,width:Se,height:ke})},[g,j]);b.useEffect(()=>{u.current&&R()},[g,x,R]),b.useEffect(()=>{const X=a.current,Ce=u.current;if(!X||!Ce||c)return;const re=X.getContext("2d");if(!re)return;const Me=l.current;if(!Me)return;const Se=Me.clientWidth,ke=Me.clientHeight-140,{width:Ie,height:Le}=j(),ae=Ie/Le;let ee,I;Se/ke>ae?(I=Math.min(ke,Le),ee=I*ae):(ee=Math.min(Se,Ie),I=ee/ae),ee>Se&&(ee=Se,I=ee/ae),I>ke&&(I=ke,ee=I*ae),X.width=ee,X.height=I,re.clearRect(0,0,ee,I),re.save(),re.translate(ee/2,I/2),re.rotate(x*Math.PI/180);let $e,qe;x===90||x===270?($e=I,qe=ee):($e=ee,qe=I),re.drawImage(Ce,-$e/2,-qe/2,$e,qe),re.restore(),re.fillStyle="rgba(0, 0, 0, 0.6)";const $=y.x/100*ee,le=y.y/100*I,me=y.width/100*ee,ye=y.height/100*I;re.fillRect(0,0,ee,le),re.fillRect(0,le+ye,ee,I-le-ye),re.fillRect(0,le,$,ye),re.fillRect($+me,le,ee-$-me,ye),re.strokeStyle="#fff",re.lineWidth=2,re.strokeRect($,le,me,ye),re.strokeStyle="rgba(255, 255, 255, 0.3)",re.lineWidth=1,re.beginPath(),re.moveTo($+me/3,le),re.lineTo($+me/3,le+ye),re.moveTo($+me*2/3,le),re.lineTo($+me*2/3,le+ye),re.moveTo($,le+ye/3),re.lineTo($+me,le+ye/3),re.moveTo($,le+ye*2/3),re.lineTo($+me,le+ye*2/3),re.stroke();const We=14;re.fillStyle="#fff",re.strokeStyle="#333",re.lineWidth=1,[{x:$,y:le},{x:$+me,y:le},{x:$,y:le+ye},{x:$+me,y:le+ye}].forEach(yt=>{re.fillRect(yt.x-We/2,yt.y-We/2,We,We),re.strokeRect(yt.x-We/2,yt.y-We/2,We,We)})},[y,x,c,j]);const M=X=>{const Ce=a.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Me=(X.clientX-re.left)/re.width*100,Se=(X.clientY-re.top)/re.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Me-Le.x)<ke&&Math.abs(Se-Le.y)<ke){v(Le.name),B({x:Me,y:Se}),T({...y});return}Me>=y.x&&Me<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(D(!0),B({x:Me,y:Se}),T({...y}))},O=X=>{const Ce=a.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Me=(X.clientX-re.left)/re.width*100,Se=(X.clientY-re.top)/re.height*100;if(S){const ke=Me-E.x,Ie=Se-E.y;let Le=N.x+ke,ae=N.y+Ie;Le=Math.max(0,Math.min(Le,100-N.width)),ae=Math.max(0,Math.min(ae,100-N.height)),C({...N,x:Le,y:ae})}else if(_){const ke=mi[g],{width:Ie,height:Le}=j(),ae=Ie/Le,ee=ke?ke/ae:null;let I={...N};const $e=Me-E.x,qe=Se-E.y;if(_==="se")I.width=Math.max(10,Math.min(100-I.x,N.width+$e)),ee?(I.height=I.width/ee,I.y+I.height>100&&(I.height=100-I.y,I.width=I.height*ee)):I.height=Math.max(10,Math.min(100-I.y,N.height+qe));else if(_==="sw"){const $=-$e,le=Math.max(10,N.width+$),me=N.x+N.width-le;me>=0&&(I.width=le,I.x=me,ee?(I.height=I.width/ee,I.y+I.height>100&&(I.height=100-I.y,I.width=I.height*ee,I.x=N.x+N.width-I.width)):I.height=Math.max(10,Math.min(100-I.y,N.height+qe)))}else if(_==="ne")if(I.width=Math.max(10,Math.min(100-I.x,N.width+$e)),ee){const $=I.width/ee,le=N.y+N.height-$;le>=0?(I.height=$,I.y=le):(I.y=0,I.height=N.y+N.height,I.width=I.height*ee)}else{const $=-qe,le=Math.max(10,N.height+$),me=N.y+N.height-le;me>=0&&(I.height=le,I.y=me)}else if(_==="nw"){const $=-$e,le=Math.max(10,N.width+$),me=N.x+N.width-le;if(me>=0)if(I.width=le,I.x=me,ee){const ye=I.width/ee,We=N.y+N.height-ye;We>=0?(I.height=ye,I.y=We):(I.y=0,I.height=N.y+N.height,I.width=I.height*ee,I.x=N.x+N.width-I.width)}else{const ye=-qe,We=Math.max(10,N.height+ye),mt=N.y+N.height-We;mt>=0&&(I.height=We,I.y=mt)}}I.x=Math.max(0,I.x),I.y=Math.max(0,I.y),I.width=Math.min(I.width,100-I.x),I.height=Math.min(I.height,100-I.y),C(I)}},V=()=>{D(!1),v(null)},W=X=>{w(Ce=>X==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const X=u.current;if(!X)return;const{width:Ce,height:re}=j(),Me=y.x/100*Ce,Se=y.y/100*re,ke=y.width/100*Ce,Ie=y.height/100*re,Le=document.createElement("canvas"),ae=Le.getContext("2d");if(!ae)return;Le.width=ke,Le.height=Ie;const ee=document.createElement("canvas"),I=ee.getContext("2d");I&&(ee.width=Ce,ee.height=re,I.save(),I.translate(Ce/2,re/2),I.rotate(x*Math.PI/180),I.drawImage(X,-X.width/2,-X.height/2,X.width,X.height),I.restore(),ae.drawImage(ee,Me,Se,ke,Ie,0,0,ke,Ie),Le.toBlob($e=>{$e&&e($e)},i,s))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:F?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Q={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},U={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${F?"#333":"#ddd"}`,background:F?"#242424":"#fff",flexShrink:0},oe={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ce={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},fe={...ce,background:"#E67E22",color:"#fff"},ge={...ce,background:F?"#333":"#e5e5e5",color:F?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:F?"#333":"#e5e5e5",color:F?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=X=>({padding:"8px 14px",borderRadius:"6px",border:X?"2px solid #E67E22":"2px solid transparent",background:X?"#E67E22":F?"#333":"#e5e5e5",color:X?"#fff":F?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:F?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:q,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":_?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:M,onMouseMove:O,onMouseUp:V,onMouseLeave:V})}),h.jsxs("div",{style:U,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(mi).map(X=>h.jsx("button",{onClick:()=>m(X),style:xe(g===X),children:X==="free"?"Libre":X},X))}),h.jsxs("div",{style:oe,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>W("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>W("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:ge,children:"Annuler"}),h.jsx("button",{onClick:te,style:fe,children:"Enregistrer"})]})]})]})]})}var Og={value:()=>{}};function ca(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Si(t)}function Si(r){this._=r}function zg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");if(i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Si.prototype=ca.prototype={constructor:Si,on:function(r,e){var t=this._,n=zg(r+"",t),i,s=-1,o=n.length;if(arguments.length<2){for(;++s<o;)if((i=(r=n[s]).type)&&(i=$g(t[i],r.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(r=n[s]).type)t[i]=Ol(t[i],r.name,e);else if(e==null)for(i in t)t[i]=Ol(t[i],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Si(r)},call:function(r,e){if((i=arguments.length-2)>0)for(var t=new Array(i),n=0,i,s;n<i;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(s=this._[r],n=0,i=s.length;n<i;++n)s[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],i=0,s=n.length;i<s;++i)n[i].value.apply(e,t)}};function $g(r,e){for(var t=0,n=r.length,i;t<n;++t)if((i=r[t]).name===e)return i.value}function Ol(r,e,t){for(var n=0,i=r.length;n<i;++n)if(r[n].name===e){r[n]=Og,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var vo="http://www.w3.org/1999/xhtml";const zl={svg:"http://www.w3.org/2000/svg",xhtml:vo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ws(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function qg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===vo&&e.documentElement.namespaceURI===vo?e.createElement(r):e.createElementNS(t,r)}}function Ug(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Kc(r){var e=ws(r);return(e.local?Ug:qg)(e)}function Wg(){}function da(r){return r==null?Wg:function(){return this.querySelector(r)}}function Hg(r){typeof r!="function"&&(r=da(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=new Array(o),a,u,c=0;c<o;++c)(a=s[c])&&(u=r.call(a,a.__data__,c,s))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Et(n,this._parents)}function Vg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Gg(){return[]}function Yc(r){return r==null?Gg:function(){return this.querySelectorAll(r)}}function Kg(r){return function(){return Vg(r.apply(this,arguments))}}function Yg(r){typeof r=="function"?r=Kg(r):r=Yc(r);for(var e=this._groups,t=e.length,n=[],i=[],s=0;s<t;++s)for(var o=e[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),i.push(a));return new Et(n,i)}function Qc(r){return function(){return this.matches(r)}}function Xc(r){return function(e){return e.matches(r)}}var Qg=Array.prototype.find;function Xg(r){return function(){return Qg.call(this.children,r)}}function Jg(){return this.firstElementChild}function Zg(r){return this.select(r==null?Jg:Xg(typeof r=="function"?r:Xc(r)))}var e0=Array.prototype.filter;function t0(){return Array.from(this.children)}function r0(r){return function(){return e0.call(this.children,r)}}function n0(r){return this.selectAll(r==null?t0:r0(typeof r=="function"?r:Xc(r)))}function i0(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=[],a,u=0;u<o;++u)(a=s[u])&&r.call(a,a.__data__,u,s)&&l.push(a);return new Et(n,this._parents)}function Jc(r){return new Array(r.length)}function s0(){return new Et(this._enter||this._groups.map(Jc),this._parents)}function Xi(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Xi.prototype={constructor:Xi,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function o0(r){return function(){return r}}function a0(r,e,t,n,i,s){for(var o=0,l,a=e.length,u=s.length;o<u;++o)(l=e[o])?(l.__data__=s[o],n[o]=l):t[o]=new Xi(r,s[o]);for(;o<a;++o)(l=e[o])&&(i[o]=l)}function l0(r,e,t,n,i,s,o){var l,a,u=new Map,c=e.length,d=s.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?i[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,s[l],l,s)+"",(a=u.get(p))?(n[l]=a,a.__data__=s[l],u.delete(p)):t[l]=new Xi(r,s[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(i[l]=a)}function u0(r){return r.__data__}function c0(r,e){if(!arguments.length)return Array.from(this,u0);var t=e?l0:a0,n=this._parents,i=this._groups;typeof r!="function"&&(r=o0(r));for(var s=i.length,o=new Array(s),l=new Array(s),a=new Array(s),u=0;u<s;++u){var c=n[u],d=i[u],f=d.length,p=d0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),w=a[u]=new Array(f);t(c,d,m,x,w,p,e);for(var y=0,C=0,S,D;y<g;++y)if(S=m[y]){for(y>=C&&(C=y+1);!(D=x[C])&&++C<g;);S._next=D||null}}return o=new Et(o,n),o._enter=l,o._exit=a,o}function d0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function f0(){return new Et(this._exit||this._groups.map(Jc),this._parents)}function h0(r,e,t){var n=this.enter(),i=this,s=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(i=e(i),i&&(i=i.selection())),t==null?s.remove():t(s),n&&i?n.merge(i).order():i}function p0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,i=t.length,s=n.length,o=Math.min(i,s),l=new Array(i),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<i;++a)l[a]=t[a];return new Et(l,this._parents)}function g0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],i=n.length-1,s=n[i],o;--i>=0;)(o=n[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function m0(r){r||(r=y0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s){for(var o=t[s],l=o.length,a=i[s]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Et(i,this._parents).order()}function y0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function x0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function b0(){return Array.from(this)}function v0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],i=0,s=n.length;i<s;++i){var o=n[i];if(o)return o}return null}function _0(){let r=0;for(const e of this)++r;return r}function w0(){return!this.node()}function C0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,o=i.length,l;s<o;++s)(l=i[s])&&r.call(l,l.__data__,s,i);return this}function S0(r){return function(){this.removeAttribute(r)}}function k0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function E0(r,e){return function(){this.setAttribute(r,e)}}function D0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function A0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function N0(r,e){var t=ws(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?k0:S0:typeof e=="function"?t.local?T0:A0:t.local?D0:E0)(t,e))}function Zc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function B0(r){return function(){this.style.removeProperty(r)}}function R0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function M0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?B0:typeof e=="function"?M0:R0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Zc(r).getComputedStyle(r,null).getPropertyValue(e)}function j0(r){return function(){delete this[r]}}function L0(r,e){return function(){this[r]=e}}function P0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function I0(r,e){return arguments.length>1?this.each((e==null?j0:typeof e=="function"?P0:L0)(r,e)):this.node()[r]}function ed(r){return r.trim().split(/^|\s+/)}function fa(r){return r.classList||new td(r)}function td(r){this._node=r,this._names=ed(r.getAttribute("class")||"")}td.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function rd(r,e){for(var t=fa(r),n=-1,i=e.length;++n<i;)t.add(e[n])}function nd(r,e){for(var t=fa(r),n=-1,i=e.length;++n<i;)t.remove(e[n])}function O0(r){return function(){rd(this,r)}}function z0(r){return function(){nd(this,r)}}function $0(r,e){return function(){(e.apply(this,arguments)?rd:nd)(this,r)}}function q0(r,e){var t=ed(r+"");if(arguments.length<2){for(var n=fa(this.node()),i=-1,s=t.length;++i<s;)if(!n.contains(t[i]))return!1;return!0}return this.each((typeof e=="function"?$0:e?O0:z0)(t,e))}function U0(){this.textContent=""}function W0(r){return function(){this.textContent=r}}function H0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function V0(r){return arguments.length?this.each(r==null?U0:(typeof r=="function"?H0:W0)(r)):this.node().textContent}function G0(){this.innerHTML=""}function K0(r){return function(){this.innerHTML=r}}function Y0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function Q0(r){return arguments.length?this.each(r==null?G0:(typeof r=="function"?Y0:K0)(r)):this.node().innerHTML}function X0(){this.nextSibling&&this.parentNode.appendChild(this)}function J0(){return this.each(X0)}function Z0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function em(){return this.each(Z0)}function tm(r){var e=typeof r=="function"?r:Kc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rm(){return null}function nm(r,e){var t=typeof r=="function"?r:Kc(r),n=e==null?rm:typeof e=="function"?e:da(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function sm(){return this.each(im)}function om(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function am(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(r){return this.select(r?am:om)}function um(r){return arguments.length?this.property("__data__",r):this.node().__data__}function cm(r){return function(e){r.call(this,e,this.__data__)}}function dm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,i=e.length,s;t<i;++t)s=e[t],(!r.type||s.type===r.type)&&s.name===r.name?this.removeEventListener(s.type,s.listener,s.options):e[++n]=s;++n?e.length=n:delete this.__on}}}function hm(r,e,t){return function(){var n=this.__on,i,s=cm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((i=n[o]).type===r.type&&i.name===r.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=t),i.value=e;return}}this.addEventListener(r.type,s,t),i={type:r.type,name:r.name,value:e,listener:s,options:t},n?n.push(i):this.__on=[i]}}function pm(r,e,t){var n=dm(r+""),i,s=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(i=0,c=l[a];i<s;++i)if((o=n[i]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?hm:fm,i=0;i<s;++i)this.each(l(n[i],e,t));return this}function id(r,e,t){var n=Zc(r),i=n.CustomEvent;typeof i=="function"?i=new i(e,t):(i=n.document.createEvent("Event"),t?(i.initEvent(e,t.bubbles,t.cancelable),i.detail=t.detail):i.initEvent(e,!1,!1)),r.dispatchEvent(i)}function gm(r,e){return function(){return id(this,r,e)}}function mm(r,e){return function(){return id(this,r,e.apply(this,arguments))}}function ym(r,e){return this.each((typeof e=="function"?mm:gm)(r,e))}function*xm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],i=0,s=n.length,o;i<s;++i)(o=n[i])&&(yield o)}var sd=[null];function Et(r,e){this._groups=r,this._parents=e}function si(){return new Et([[document.documentElement]],sd)}function bm(){return this}Et.prototype=si.prototype={constructor:Et,select:Hg,selectAll:Yg,selectChild:Zg,selectChildren:n0,filter:i0,data:c0,enter:s0,exit:f0,join:h0,merge:p0,selection:bm,order:g0,sort:m0,call:x0,nodes:b0,node:v0,size:_0,empty:w0,each:C0,attr:N0,style:F0,property:I0,classed:q0,text:V0,html:Q0,raise:J0,lower:em,append:tm,insert:nm,remove:sm,clone:lm,datum:um,on:pm,dispatch:ym,[Symbol.iterator]:xm};function Lt(r){return typeof r=="string"?new Et([[document.querySelector(r)]],[document.documentElement]):new Et([[r]],sd)}function vm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=vm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[r.clientX-i.left-e.clientLeft,r.clientY-i.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function wo(r){r.preventDefault(),r.stopImmediatePropagation()}function _m(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",wo,_o);"onselectstart"in e?t.on("selectstart.drag",wo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function wm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",wo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function ha(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function od(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function oi(){}var $n=.7,Ji=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Cm=/^#([0-9a-f]{3,8})$/,Sm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),km=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Em=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Dm=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Am=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Tm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ha(oi,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:Nm,formatHsl:Bm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function Nm(){return this.rgb().formatHex8()}function Bm(){return ad(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Cm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new _t(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?yi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?yi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Sm.exec(r))?new _t(e[1],e[2],e[3],1):(e=km.exec(r))?new _t(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Em.exec(r))?yi(e[1],e[2],e[3],e[4]):(e=Dm.exec(r))?yi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Am.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Tm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new _t(NaN,NaN,NaN,0):null}function Wl(r){return new _t(r>>16&255,r>>8&255,r&255,1)}function yi(r,e,t,n){return n<=0&&(r=e=t=NaN),new _t(r,e,t,n)}function Rm(r){return r instanceof oi||(r=Un(r)),r?(r=r.rgb(),new _t(r.r,r.g,r.b,r.opacity)):new _t}function Co(r,e,t,n){return arguments.length===1?Rm(r):new _t(r,e,t,n??1)}function _t(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}ha(_t,Co,od(oi,{brighter(r){return r=r==null?Ji:Math.pow(Ji,r),new _t(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new _t(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new _t(Tr(this.r),Tr(this.g),Tr(this.b),Zi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Mm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Mm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Zi(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Zi(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function ad(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof oi||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,i=Math.min(e,t,n),s=Math.max(e,t,n),o=NaN,l=s-i,a=(s+i)/2;return l?(e===s?o=(t-n)/l+(t<n)*6:t===s?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?s+i:2-s-i,o*=60):l=a>0&&a<1?0:o,new Pt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?ad(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}ha(Pt,Fm,od(oi,{brighter(r){return r=r==null?Ji:Math.pow(Ji,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,i=2*t-n;return new _t(Us(r>=240?r-240:r+120,i,n),Us(r,i,n),Us(r<120?r+240:r-120,i,n),this.opacity)},clamp(){return new Pt(Kl(this.h),xi(this.s),xi(this.l),Zi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Zi(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${xi(this.s)*100}%, ${xi(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function xi(r){return Math.max(0,Math.min(1,r||0))}function Us(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ld=r=>()=>r;function jm(r,e){return function(t){return r+t*e}}function Lm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Pm(r){return(r=+r)==1?ud:function(e,t){return t-e?Lm(e,t,r):ld(isNaN(e)?t:e)}}function ud(r,e){var t=e-r;return t?jm(r,t):ld(isNaN(r)?e:r)}const Yl=function r(e){var t=Pm(e);function n(i,s){var o=t((i=Co(i)).r,(s=Co(s)).r),l=t(i.g,s.g),a=t(i.b,s.b),u=ud(i.opacity,s.opacity);return function(c){return i.r=o(c),i.g=l(c),i.b=a(c),i.opacity=u(c),i+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ws=new RegExp(So.source,"g");function Im(r){return function(){return r}}function Om(r){return function(e){return r(e)+""}}function zm(r,e){var t=So.lastIndex=Ws.lastIndex=0,n,i,s,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=So.exec(r))&&(i=Ws.exec(e));)(s=i.index)>t&&(s=e.slice(t,s),l[o]?l[o]+=s:l[++o]=s),(n=n[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,a.push({i:o,x:fr(n,i)})),t=Ws.lastIndex;return t<e.length&&(s=e.slice(t),l[o]?l[o]+=s:l[++o]=s),l.length<2?a[0]?Om(a[0].x):Im(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Ql=180/Math.PI,ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cd(r,e,t,n,i,s){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var bi;function $m(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?ko:cd(e.a,e.b,e.c,e.d,e.e,e.f)}function qm(r){return r==null||(bi||(bi=document.createElementNS("http://www.w3.org/2000/svg","g")),bi.setAttribute("transform",r),!(r=bi.transform.baseVal.consolidate()))?ko:(r=r.matrix,cd(r.a,r.b,r.c,r.d,r.e,r.f))}function dd(r,e,t,n){function i(u){return u.length?u.pop()+" ":""}function s(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(i(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(i(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(i(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(i(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(i(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(i(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),s(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Um=dd($m,"px, ","px)","deg)"),Wm=dd(qm,", ",")",")"),Hm=1e-12;function Xl(r){return((r=Math.exp(r))+1/r)/2}function Vm(r){return((r=Math.exp(r))-1/r)/2}function Gm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Km=function r(e,t,n){function i(s,o){var l=s[0],a=s[1],u=s[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,w;if(m<Hm)w=Math.log(f/u)/e,x=function(v){return[l+v*p,a+v*g,u*Math.exp(e*v*w)]};else{var y=Math.sqrt(m),C=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(C*C+1)-C),_=Math.log(Math.sqrt(S*S+1)-S);w=(_-D)/e,x=function(v){var E=v*w,B=Xl(D),N=u/(t*y)*(B*Gm(e*E+D)-Vm(D));return[l+N*p,a+N*g,u*B/Xl(e*E+D)]}}return x.duration=w*1e3*e/Math.SQRT2,x}return i.rho=function(s){var o=Math.max(.001,+s),l=o*o,a=l*l;return r(o,l,a)},i}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,fd=1e3,es,Sn,ts=0,Lr=0,Cs=0,Wn=typeof performance=="object"&&performance.now?performance:Date,hd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function pa(){return Lr||(hd(Ym),Lr=Wn.now()+Cs)}function Ym(){Lr=0}function rs(){this._call=this._time=this._next=null}rs.prototype=pd.prototype={constructor:rs,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?pa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:es=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function pd(r,e,t){var n=new rs;return n.restart(r,e,t),n}function Qm(){pa(),++nn;for(var r=es,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Jl(){Lr=(ts=Wn.now())+Cs,nn=Cn=0;try{Qm()}finally{nn=0,Jm(),Lr=0}}function Xm(){var r=Wn.now(),e=r-ts;e>fd&&(Cs-=e,ts=r)}function Jm(){for(var r,e=es,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:es=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Jl,r-Wn.now()-Cs)),yn&&(yn=clearInterval(yn))):(yn||(ts=Wn.now(),yn=setInterval(Xm,fd)),nn=1,hd(Jl))}}function Zl(r,e,t){var n=new rs;return e=e==null?0:+e,n.restart(i=>{n.stop(),r(i+e)},e,t),n}var Zm=ca("start","end","cancel","interrupt"),e2=[],gd=0,eu=1,Do=2,ki=3,tu=4,Ao=5,Ei=6;function Ss(r,e,t,n,i,s){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;t2(r,t,{name:e,index:n,group:i,on:Zm,tween:e2,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gd})}function ga(r,e){var t=qt(r,e);if(t.state>gd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>ki)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function t2(r,e,t){var n=r.__transition,i;n[e]=t,t.timer=pd(s,0,t.time);function s(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===ki)return Zl(o);p.state===tu?(p.state=Ei,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=Ei,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===ki&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Do,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Do){for(t.state=ki,i=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(i[++d]=p);i.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Ao,1),d=-1,f=i.length;++d<f;)i[d].call(r,c);t.state===Ao&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Ei,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Di(r,e){var t=r.__transition,n,i,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){s=!1;continue}i=n.state>Do&&n.state<Ao,n.state=Ei,n.timer.stop(),n.on.call(i?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}s&&delete r.__transition}}function r2(r){return this.each(function(){Di(this,r)})}function n2(r,e){var t,n;return function(){var i=Jt(this,r),s=i.tween;if(s!==t){n=t=s;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}i.tween=n}}function i2(r,e,t){var n,i;if(typeof t!="function")throw new Error;return function(){var s=Jt(this,r),o=s.tween;if(o!==n){i=(n=o).slice();for(var l={name:e,value:t},a=0,u=i.length;a<u;++a)if(i[a].name===e){i[a]=l;break}a===u&&i.push(l)}s.tween=i}}function s2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(this.node(),t).tween,i=0,s=n.length,o;i<s;++i)if((o=n[i]).name===r)return o.value;return null}return this.each((e==null?n2:i2)(t,r,e))}function ma(r,e,t){var n=r._id;return r.each(function(){var i=Jt(this,n);(i.value||(i.value={}))[e]=t.apply(this,arguments)}),function(i){return qt(i,n).value[e]}}function md(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):zm)(r,e)}function o2(r){return function(){this.removeAttribute(r)}}function a2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function l2(r,e,t){var n,i=t+"",s;return function(){var o=this.getAttribute(r);return o===i?null:o===n?s:s=e(n=o,t)}}function u2(r,e,t){var n,i=t+"",s;return function(){var o=this.getAttributeNS(r.space,r.local);return o===i?null:o===n?s:s=e(n=o,t)}}function c2(r,e,t){var n,i,s;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l)))}}function d2(r,e,t){var n,i,s;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l)))}}function f2(r,e){var t=ws(r),n=t==="transform"?Wm:md;return this.attrTween(r,typeof e=="function"?(t.local?d2:c2)(t,n,ma(this,"attr."+r,e)):e==null?(t.local?a2:o2)(t):(t.local?u2:l2)(t,n,e))}function h2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function p2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function g2(r,e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&p2(r,s)),t}return i._value=e,i}function m2(r,e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&h2(r,s)),t}return i._value=e,i}function y2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=ws(r);return this.tween(t,(n.local?g2:m2)(n,e))}function x2(r,e){return function(){ga(this,r).delay=+e.apply(this,arguments)}}function b2(r,e){return e=+e,function(){ga(this,r).delay=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?x2:b2)(e,r)):qt(this.node(),e).delay}function _2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function w2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function C2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?_2:w2)(e,r)):qt(this.node(),e).duration}function S2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function k2(r){var e=this._id;return arguments.length?this.each(S2(e,r)):qt(this.node(),e).ease}function E2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function D2(r){if(typeof r!="function")throw new Error;return this.each(E2(this._id,r))}function A2(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=[],a,u=0;u<o;++u)(a=s[u])&&r.call(a,a.__data__,u,s)&&l.push(a);return new sr(n,this._parents,this._name,this._id)}function T2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,i=t.length,s=Math.min(n,i),o=new Array(n),l=0;l<s;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new sr(o,this._parents,this._name,this._id)}function N2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function B2(r,e,t){var n,i,s=N2(e)?ga:Jt;return function(){var o=s(this,r),l=o.on;l!==n&&(i=(n=l).copy()).on(e,t),o.on=i}}function R2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(B2(t,r,e))}function M2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",M2(this._id))}function j2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=da(r));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],a=l.length,u=s[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ss(u[f],e,t,f,u,qt(c,t)));return new sr(s,this._parents,e,t)}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Yc(r));for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ss(p,e,t,m,f,g);s.push(f),o.push(c)}return new sr(s,o,e,t)}var P2=si.prototype.constructor;function I2(){return new P2(this._groups,this._parents)}function O2(r,e){var t,n,i;return function(){var s=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return s===o?null:s===t&&o===n?i:i=e(t=s,n=o)}}function yd(r){return function(){this.style.removeProperty(r)}}function z2(r,e,t){var n,i=t+"",s;return function(){var o=rn(this,r);return o===i?null:o===n?s:s=e(n=o,t)}}function $2(r,e,t){var n,i,s;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l))}}function q2(r,e){var t,n,i,s="style."+e,o="end."+s,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[s]==null?l||(l=yd(e)):void 0;(u!==t||i!==c)&&(n=(t=u).copy()).on(o,i=c),a.on=n}}function U2(r,e,t){var n=(r+="")=="transform"?Um:md;return e==null?this.styleTween(r,O2(r,n)).on("end.style."+r,yd(r)):typeof e=="function"?this.styleTween(r,$2(r,n,ma(this,"style."+r,e))).each(q2(this._id,r)):this.styleTween(r,z2(r,n,e),t).on("end.style."+r,null)}function W2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function H2(r,e,t){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&W2(r,o,t)),n}return s._value=e,s}function V2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,H2(r,e,t??""))}function G2(r){return function(){this.textContent=r}}function K2(r){return function(){var e=r(this);this.textContent=e??""}}function Y2(r){return this.tween("text",typeof r=="function"?K2(ma(this,"text",r)):G2(r==null?"":r+""))}function Q2(r){return function(e){this.textContent=r.call(this,e)}}function X2(r){var e,t;function n(){var i=r.apply(this,arguments);return i!==t&&(e=(t=i)&&Q2(i)),e}return n._value=r,n}function J2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,X2(r))}function Z2(){for(var r=this._name,e=this._id,t=xd(),n=this._groups,i=n.length,s=0;s<i;++s)for(var o=n[s],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=qt(a,e);Ss(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new sr(n,this._parents,r,t)}function ey(){var r,e,t=this,n=t._id,i=t.size();return new Promise(function(s,o){var l={value:o},a={value:function(){--i===0&&s()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),i===0&&s()})}var ty=0;function sr(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function xd(){return++ty}var tr=si.prototype;sr.prototype={constructor:sr,select:j2,selectAll:L2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:A2,merge:T2,selection:I2,transition:Z2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:R2,attr:f2,attrTween:y2,style:U2,styleTween:V2,text:Y2,textTween:J2,remove:F2,tween:s2,delay:v2,duration:C2,ease:k2,easeVarying:D2,end:ey,[Symbol.iterator]:tr[Symbol.iterator]};function ry(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ny={time:null,delay:0,duration:250,ease:ry};function iy(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function sy(r){var e,t;r instanceof sr?(e=r._id,r=r._name):(e=xd(),(t=ny).time=pa(),r=r==null?null:r+"");for(var n=this._groups,i=n.length,s=0;s<i;++s)for(var o=n[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ss(a,r,e,u,o,t||iy(a,e));return new sr(n,this._parents,r,e)}si.prototype.interrupt=r2;si.prototype.transition=sy;const vi=r=>()=>r;function oy(r,{sourceEvent:e,target:t,transform:n,dispatch:i}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:i}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ns=new nr(1,0,0);nr.prototype;function Hs(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ay(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function ly(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ns}function uy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function cy(){return navigator.maxTouchPoints||"ontouchstart"in this}function dy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],i=r.invertX(e[1][0])-t[1][0],s=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(i>n?(n+i)/2:Math.min(0,n)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function fy(){var r=ay,e=ly,t=dy,n=uy,i=cy,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Km,u=ca("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function w(k){k.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",N).filter(i).on("touchstart.zoom",T).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(k,R,M,O){var V=k.selection?k.selection():k;V.property("__zoom",ru),k!==V?D(k,R,M,O):V.interrupt().each(function(){_(this,arguments).event(O).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},w.scaleBy=function(k,R,M,O){w.scaleTo(k,function(){var V=this.__zoom.k,W=typeof R=="function"?R.apply(this,arguments):R;return V*W},M,O)},w.scaleTo=function(k,R,M,O){w.transform(k,function(){var V=e.apply(this,arguments),W=this.__zoom,te=M==null?S(V):typeof M=="function"?M.apply(this,arguments):M,q=W.invert(te),Q=typeof R=="function"?R.apply(this,arguments):R;return t(C(y(W,Q),te,q),V,o)},M,O)},w.translateBy=function(k,R,M,O){w.transform(k,function(){return t(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof M=="function"?M.apply(this,arguments):M),e.apply(this,arguments),o)},null,O)},w.translateTo=function(k,R,M,O,V){w.transform(k,function(){var W=e.apply(this,arguments),te=this.__zoom,q=O==null?S(W):typeof O=="function"?O.apply(this,arguments):O;return t(ns.translate(q[0],q[1]).scale(te.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof M=="function"?-M.apply(this,arguments):-M),W,o)},O,V)};function y(k,R){return R=Math.max(s[0],Math.min(s[1],R)),R===k.k?k:new nr(R,k.x,k.y)}function C(k,R,M){var O=R[0]-M[0]*k.k,V=R[1]-M[1]*k.k;return O===k.x&&V===k.y?k:new nr(k.k,O,V)}function S(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function D(k,R,M,O){k.on("start.zoom",function(){_(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(O).end()}).tween("zoom",function(){var V=this,W=arguments,te=_(V,W).event(O),q=e.apply(V,W),Q=M==null?S(q):typeof M=="function"?M.apply(V,W):M,U=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),oe=V.__zoom,ce=typeof R=="function"?R.apply(V,W):R,fe=a(oe.invert(Q).concat(U/oe.k),ce.invert(Q).concat(U/ce.k));return function(ge){if(ge===1)ge=ce;else{var De=fe(ge),xe=U/De[2];ge=new nr(xe,Q[0]-De[0]*xe,Q[1]-De[1]*xe)}te.zoom(null,ge)}})}function _(k,R,M){return!M&&k.__zooming||new v(k,R)}function v(k,R){this.that=k,this.args=R,this.active=0,this.sourceEvent=null,this.extent=e.apply(k,R),this.taps=0}v.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,R){return this.mouse&&k!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var R=Lt(this.that).datum();u.call(k,this.that,new oy(k,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:u}),R)}};function E(k,...R){if(!r.apply(this,arguments))return;var M=_(this,R).event(k),O=this.__zoom,V=Math.max(s[0],Math.min(s[1],O.k*Math.pow(2,n.apply(this,arguments)))),W=wr(k);if(M.wheel)(M.mouse[0][0]!==W[0]||M.mouse[0][1]!==W[1])&&(M.mouse[1]=O.invert(M.mouse[0]=W)),clearTimeout(M.wheel);else{if(O.k===V)return;M.mouse=[W,O.invert(W)],Di(this),M.start()}xn(k),M.wheel=setTimeout(te,g),M.zoom("mouse",t(C(y(O,V),M.mouse[0],M.mouse[1]),M.extent,o));function te(){M.wheel=null,M.end()}}function B(k,...R){if(f||!r.apply(this,arguments))return;var M=k.currentTarget,O=_(this,R,!0).event(k),V=Lt(k.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",U,!0),W=wr(k,M),te=k.clientX,q=k.clientY;_m(k.view),Hs(k),O.mouse=[W,this.__zoom.invert(W)],Di(this),O.start();function Q(oe){if(xn(oe),!O.moved){var ce=oe.clientX-te,fe=oe.clientY-q;O.moved=ce*ce+fe*fe>m}O.event(oe).zoom("mouse",t(C(O.that.__zoom,O.mouse[0]=wr(oe,M),O.mouse[1]),O.extent,o))}function U(oe){V.on("mousemove.zoom mouseup.zoom",null),wm(oe.view,O.moved),xn(oe),O.event(oe).end()}}function N(k,...R){if(r.apply(this,arguments)){var M=this.__zoom,O=wr(k.changedTouches?k.changedTouches[0]:k,this),V=M.invert(O),W=M.k*(k.shiftKey?.5:2),te=t(C(y(M,W),O,V),e.apply(this,R),o);xn(k),l>0?Lt(this).transition().duration(l).call(D,te,O,k):Lt(this).call(w.transform,te,O,k)}}function T(k,...R){if(r.apply(this,arguments)){var M=k.touches,O=M.length,V=_(this,R,k.changedTouches.length===O).event(k),W,te,q,Q;for(Hs(k),te=0;te<O;++te)q=M[te],Q=wr(q,this),Q=[Q,this.__zoom.invert(Q),q.identifier],V.touch0?!V.touch1&&V.touch0[2]!==Q[2]&&(V.touch1=Q,V.taps=0):(V.touch0=Q,W=!0,V.taps=1+!!c);c&&(c=clearTimeout(c)),W&&(V.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Di(this),V.start())}}function F(k,...R){if(this.__zooming){var M=_(this,R).event(k),O=k.changedTouches,V=O.length,W,te,q,Q;for(xn(k),W=0;W<V;++W)te=O[W],q=wr(te,this),M.touch0&&M.touch0[2]===te.identifier?M.touch0[0]=q:M.touch1&&M.touch1[2]===te.identifier&&(M.touch1[0]=q);if(te=M.that.__zoom,M.touch1){var U=M.touch0[0],oe=M.touch0[1],ce=M.touch1[0],fe=M.touch1[1],ge=(ge=ce[0]-U[0])*ge+(ge=ce[1]-U[1])*ge,De=(De=fe[0]-oe[0])*De+(De=fe[1]-oe[1])*De;te=y(te,Math.sqrt(ge/De)),q=[(U[0]+ce[0])/2,(U[1]+ce[1])/2],Q=[(oe[0]+fe[0])/2,(oe[1]+fe[1])/2]}else if(M.touch0)q=M.touch0[0],Q=M.touch0[1];else return;M.zoom("touch",t(C(te,q,Q),M.extent,o))}}function j(k,...R){if(this.__zooming){var M=_(this,R).event(k),O=k.changedTouches,V=O.length,W,te;for(Hs(k),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),W=0;W<V;++W)te=O[W],M.touch0&&M.touch0[2]===te.identifier?delete M.touch0:M.touch1&&M.touch1[2]===te.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var q=Lt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return w.wheelDelta=function(k){return arguments.length?(n=typeof k=="function"?k:vi(+k),w):n},w.filter=function(k){return arguments.length?(r=typeof k=="function"?k:vi(!!k),w):r},w.touchable=function(k){return arguments.length?(i=typeof k=="function"?k:vi(!!k),w):i},w.extent=function(k){return arguments.length?(e=typeof k=="function"?k:vi([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),w):e},w.scaleExtent=function(k){return arguments.length?(s[0]=+k[0],s[1]=+k[1],w):[s[0],s[1]]},w.translateExtent=function(k){return arguments.length?(o[0][0]=+k[0][0],o[1][0]=+k[1][0],o[0][1]=+k[0][1],o[1][1]=+k[1][1],w):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},w.constrain=function(k){return arguments.length?(t=k,w):t},w.duration=function(k){return arguments.length?(l=+k,w):l},w.interpolate=function(k){return arguments.length?(a=k,w):a},w.on=function(){var k=u.on.apply(u,arguments);return k===u?w:k},w.clickDistance=function(k){return arguments.length?(m=(k=+k)*k,w):Math.sqrt(m)},w.tapDistance=function(k){return arguments.length?(x=+k,w):x},w}function bd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:i=!0,pannable:s=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=fy().scaleExtent([e,t]).filter(y=>!i&&y.type==="wheel"||!s&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?i:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:s:!0).on("zoom",y=>{const C={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(C),o==null||o(C)});a.current=x;const w=Lt(l.current);return w.call(x),w.on("dblclick.zoom",null),n&&w.call(x.transform,ns.translate(n.x,n.y).scale(n.k)),()=>{w.on(".zoom",null)}},[e,t,i,s]),b.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const w={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(w),o==null||o(w)})},[o]);const d=b.useCallback((x,w,y,C=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),D=ns.translate(x,w).scale(y);S.call(a.current.transform,D)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,w=50)=>{if(!l.current||!a.current||x.length===0)return;const C=l.current.getBoundingClientRect();let S=1/0,D=1/0,_=-1/0,v=-1/0;for(const O of x){const V=O.width||200,W=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),_=Math.max(_,O.x+V),v=Math.max(v,O.y+W)}const E=_-S,B=v-D,N=(C.width-w*2)/E,T=(C.height-w*2)/B,F=Math.min(N,T,t),j=(S+_)/2,k=(D+v)/2,R=C.width/2-j*F,M=C.height/2-k*F;d(R,M,F,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function vd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:i,disabled:s=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((C,S)=>{const D=g.current;return{x:(C-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=b.useCallback((C,S)=>{if(s)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,_=parseFloat(D.dataset.x||"0"),v=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:_,nodeY:v},p.current={x:_,y:v},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[s,m,t]),w=b.useCallback(C=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,_=C.clientX-D.x,v=C.clientY-D.y,E=_/S.k,B=v/S.k,N=D.nodeX+E,T=D.nodeY+B;p.current={x:N,y:T},d({x:E,y:B}),n==null||n(o,N,T,E,B)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const C=p.current;i==null||i(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,i]);return b.useEffect(()=>{if(!a)return;const C=D=>{w(D)},S=()=>{y()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,w,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:w,endDrag:y}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,onSelectionChange:i}=r,[s,o]=b.useState(new Set),[l,a]=b.useState(null),[u,c]=b.useState(!1),d=b.useRef(null),f=b.useRef(e),p=b.useRef(t);b.useEffect(()=>{f.current=e},[e]),b.useEffect(()=>{p.current=t},[t]);const g=b.useCallback((_,v)=>{const E=f.current;return{x:(_-E.x)/E.k,y:(v-E.y)/E.k}},[]),m=b.useCallback((_,v)=>{const E=p.current.get(_);if(!E)return!1;const B=E.width||200,N=E.height||100;return E.x<v.x+v.width&&E.x+B>v.x&&E.y<v.y+v.height&&E.y+N>v.y},[]),x=b.useCallback(_=>{if(n||_.target.closest("[data-qmap-node]"))return;_.preventDefault();const E=g(_.clientX,_.clientY);d.current=E,a({x:E.x,y:E.y,width:0,height:0}),c(!0),_.shiftKey||o(new Set)},[n,g]),w=b.useCallback(_=>{if(!u||!d.current)return;const v=d.current,E=g(_.clientX,_.clientY),B={x:Math.min(v.x,E.x),y:Math.min(v.y,E.y),width:Math.abs(E.x-v.x),height:Math.abs(E.y-v.y)};a(B);const N=new Set;for(const[T]of p.current)m(T,B)&&N.add(T);o(N)},[u,g,m]),y=b.useCallback(()=>{u&&(i==null||i(Array.from(s)),c(!1),a(null),d.current=null)},[u,s,i]);b.useEffect(()=>{if(!u)return;const _=E=>{w(E)},v=()=>{y()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",v),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",v)}},[u,w,y]);const C=b.useCallback((_,v=!1)=>{o(E=>{const B=new Set(v?E:[]);return E.has(_)&&v?B.delete(_):B.add(_),i==null||i(Array.from(B)),B})},[i]),S=b.useCallback(()=>{const _=new Set(p.current.keys());o(_),i==null||i(Array.from(_))},[i]),D=b.useCallback(()=>{o(new Set),i==null||i([])},[i]);return{selectedIds:s,setSelectedIds:o,selectionBox:l,isSelecting:u,startSelection:x,updateSelection:w,endSelection:y,toggleSelect:C,selectAll:S,clearSelection:D}}const wd=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:i,draggable:s,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{s&&y.button===0&&o(e,y)},[e,s,o]),f=b.useCallback(y=>{i||l==null||l(y)},[i,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,w=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:w!==0?`rotate(${w}deg)`:void 0,transformOrigin:"center center",cursor:s?i?"grabbing":"grab":"pointer",userSelect:"none",outline:n?"2px solid #3b82f6":void 0,outlineOffset:"2px",opacity:i?.8:1,zIndex:i?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Cd(r,e,t="bezier"){const n=Hn(r),i=Hn(e),s=To(r,i),o=To(e,n);switch(t){case"straight":return`M ${s.x} ${s.y} L ${o.x} ${o.y}`;case"orthogonal":return py(s,o);case"bezier":default:return hy(s,o)}}function hy(r,e){const t=e.x-r.x,n=e.y-r.y,i=Math.sqrt(t*t+n*n),s=Math.min(i*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+s*Math.sign(t),a=r.y,u=e.x-s*Math.sign(t),c=e.y):(l=r.x,a=r.y+s*Math.sign(n),u=e.x,c=e.y-s*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function py(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const s=r.x+t/2;return`M ${r.x} ${r.y} H ${s} V ${e.y} H ${e.x}`}else{const s=r.y+n/2;return`M ${r.x} ${r.y} V ${s} H ${e.x} V ${e.y}`}}function Hn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function To(r,e){const t=r.width||200,n=r.height||100,i=Hn(r),s=e.x-i.x,o=e.y-i.y;if(s===0&&o===0)return i;const l=t/2,a=n/2,u=Math.abs(o/(s||.001)),c=a/l;let d,f;return u<c?(d=i.x+(s>0?l:-l),f=i.y+o*l/Math.abs(s)):(f=i.y+(o>0?a:-a),d=i.x+s*a/Math.abs(o)),{x:d,y:f}}function gy(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return Hn(r)}}function my(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function yy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function xy(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r){const o=s.width||200,l=s.height||100;e=Math.min(e,s.x),t=Math.min(t,s.y),n=Math.max(n,s.x+o),i=Math.max(i,s.y+l)}return{x:e,y:t,width:n-e,height:i-t}}function by(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function vy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Sd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:i,color:s,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>Cd(t,n,i),[t,n,i]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||s,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(_y,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function _y({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const kd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:i,defaultWidth:s,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=b.useMemo(()=>{if(t.size===0)return"0 0 1000 1000";let u=1/0,c=1/0,d=-1/0,f=-1/0;for(const p of t.values()){const g=p.width||200,m=p.height||100;u=Math.min(u,p.x-100),c=Math.min(c,p.y-100),d=Math.max(d,p.x+g+100),f=Math.max(f,p.y+m+100)}return u-=1e3,c-=1e3,d+=1e3,f+=1e3,`${u} ${c} ${d-u} ${f-c}`},[t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:a,preserveAspectRatio:"none",children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(u=>{const c=t.get(u.source),d=t.get(u.target);return h.jsx(Sd,{edge:u,sourcePosition:c,targetPosition:d,style:u.style||n,color:u.color||i,width:u.width||s,onClick:o},u.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Ed=b.memo(function({box:e,transform:t}){const n=b.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),wy=200,Cy=100,Sy="bezier",ky="#94a3b8",Ey=2,Dy=.1,Ay=4;function Ty({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:i=wy,defaultNodeHeight:s=Cy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,onSelectionChange:c,onEdgeClick:d,onViewChange:f,onTransformChange:p,minZoom:g=Dy,maxZoom:m=Ay,initialTransform:x,defaultEdgeStyle:w=Sy,defaultEdgeColor:y=ky,defaultEdgeWidth:C=Ey,draggable:S=!0,selectable:D=!0,zoomable:_=!0,pannable:v=!0,className:E="",style:B,background:N="#f8fafc",showGrid:T=!1,gridSize:F=20}){const j=r.data||{positions:{}},k=j.positions||{},R=b.useMemo(()=>{const ae=new Map;for(const ee of e){const I=k[ee._id]||{x:0,y:0};ae.set(ee._id,{x:I.x,y:I.y,width:I.width||i,height:I.height||s,rotation:I.rotation||0})}return ae},[e,k,i,s]),{transform:M,containerRef:O,zoomIn:V,zoomOut:W,resetZoom:te,fitToContent:q}=bd({minZoom:g,maxZoom:m,initialTransform:x||j.transform,zoomable:_,pannable:v,onTransformChange:ae=>{p==null||p(ae);const ee={...j,transform:ae};f==null||f(ee)}}),[Q,U]=b.useState(new Map),{draggedNodeId:oe,startDrag:ce}=vd({transform:M,disabled:!S,onDragStart:ae=>{const ee=R.get(ae);ee&&U(new Map([[ae,{x:ee.x,y:ee.y}]]))},onDragMove:(ae,ee,I)=>{U(new Map([[ae,{x:ee,y:I}]]))},onDragEnd:(ae,ee,I)=>{U(new Map),o==null||o(ae,ee,I)}}),{selectedIds:fe,selectionBox:ge,isSelecting:De,startSelection:xe,toggleSelect:X,clearSelection:Ce}=_d({transform:M,nodePositions:R,disabled:!D,onSelectionChange:c}),re=b.useCallback(ae=>{const ee=R.get(ae)||{x:0,y:0,width:i,height:s},I=Q.get(ae);return I?{...ee,x:I.x,y:I.y}:ee},[R,Q,i,s]),Me=b.useMemo(()=>{const ae=new Map;for(const ee of R.keys())ae.set(ee,re(ee));return ae},[R,re]),Se=b.useCallback((ae,ee)=>{X(ae._id,ee.shiftKey),l==null||l(ae,ee)},[X,l]),ke=b.useCallback(ae=>{ae.target.closest("[data-qmap-node]")||Ce()},[Ce]),Ie=b.useCallback(ae=>{ae.button===0&&(ae.target.closest("[data-qmap-node]")||xe(ae))},[xe]),Le=T?`
|
|
185
|
+
${y}`:y)},x=async y=>{if(!(!e.trim()||a||!i)){u(!0),d(y),p(!1);try{const C=await i(y,e);t(C)}catch(C){console.error(`${y} failed:`,C)}finally{u(!1),d(null)}}},w=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Gc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),i&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:w,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:s,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const mi={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Ig({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:i="image/jpeg",outputQuality:s=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,w]=b.useState(0),[y,C]=b.useState({x:0,y:0,width:100,height:100}),[S,D]=b.useState(!1),[_,v]=b.useState(null),[E,B]=b.useState({x:0,y:0}),[N,T]=b.useState({x:0,y:0,width:100,height:100}),F=o==="dark",j=b.useCallback(()=>{const X=u.current;return X?x===90||x===270?{width:X.height,height:X.width}:{width:X.width,height:X.height}:{width:100,height:100}},[x]),k=b.useCallback((X,Ce)=>{const re=X/Ce,Me=.05;for(const[Se,ke]of Object.entries(mi))if(ke!==null&&Math.abs(re-ke)/ke<Me)return Se;return"free"},[]);b.useEffect(()=>{const X=new Image;X.crossOrigin="anonymous",X.onload=()=>{u.current=X;const Ce=k(X.width,X.height);m(Ce),d(!1)},X.onerror=()=>{p("Failed to load image"),d(!1)},X.src=r},[r,k]);const R=b.useCallback(()=>{const{width:X,height:Ce}=j(),re=mi[g];if(re===null){C({x:0,y:0,width:100,height:100});return}const Me=X/Ce;let Se,ke;Me>re?(ke=100,Se=re/Me*100):(Se=100,ke=Me/re*100);const Ie=(100-Se)/2,Le=(100-ke)/2;C({x:Ie,y:Le,width:Se,height:ke})},[g,j]);b.useEffect(()=>{u.current&&R()},[g,x,R]),b.useEffect(()=>{const X=a.current,Ce=u.current;if(!X||!Ce||c)return;const re=X.getContext("2d");if(!re)return;const Me=l.current;if(!Me)return;const Se=Me.clientWidth,ke=Me.clientHeight-140,{width:Ie,height:Le}=j(),ae=Ie/Le;let ee,I;Se/ke>ae?(I=Math.min(ke,Le),ee=I*ae):(ee=Math.min(Se,Ie),I=ee/ae),ee>Se&&(ee=Se,I=ee/ae),I>ke&&(I=ke,ee=I*ae),X.width=ee,X.height=I,re.clearRect(0,0,ee,I),re.save(),re.translate(ee/2,I/2),re.rotate(x*Math.PI/180);let $e,qe;x===90||x===270?($e=I,qe=ee):($e=ee,qe=I),re.drawImage(Ce,-$e/2,-qe/2,$e,qe),re.restore(),re.fillStyle="rgba(0, 0, 0, 0.6)";const $=y.x/100*ee,le=y.y/100*I,me=y.width/100*ee,ye=y.height/100*I;re.fillRect(0,0,ee,le),re.fillRect(0,le+ye,ee,I-le-ye),re.fillRect(0,le,$,ye),re.fillRect($+me,le,ee-$-me,ye),re.strokeStyle="#fff",re.lineWidth=2,re.strokeRect($,le,me,ye),re.strokeStyle="rgba(255, 255, 255, 0.3)",re.lineWidth=1,re.beginPath(),re.moveTo($+me/3,le),re.lineTo($+me/3,le+ye),re.moveTo($+me*2/3,le),re.lineTo($+me*2/3,le+ye),re.moveTo($,le+ye/3),re.lineTo($+me,le+ye/3),re.moveTo($,le+ye*2/3),re.lineTo($+me,le+ye*2/3),re.stroke();const We=14;re.fillStyle="#fff",re.strokeStyle="#333",re.lineWidth=1,[{x:$,y:le},{x:$+me,y:le},{x:$,y:le+ye},{x:$+me,y:le+ye}].forEach(yt=>{re.fillRect(yt.x-We/2,yt.y-We/2,We,We),re.strokeRect(yt.x-We/2,yt.y-We/2,We,We)})},[y,x,c,j]);const M=X=>{const Ce=a.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Me=(X.clientX-re.left)/re.width*100,Se=(X.clientY-re.top)/re.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Me-Le.x)<ke&&Math.abs(Se-Le.y)<ke){v(Le.name),B({x:Me,y:Se}),T({...y});return}Me>=y.x&&Me<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(D(!0),B({x:Me,y:Se}),T({...y}))},O=X=>{const Ce=a.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Me=(X.clientX-re.left)/re.width*100,Se=(X.clientY-re.top)/re.height*100;if(S){const ke=Me-E.x,Ie=Se-E.y;let Le=N.x+ke,ae=N.y+Ie;Le=Math.max(0,Math.min(Le,100-N.width)),ae=Math.max(0,Math.min(ae,100-N.height)),C({...N,x:Le,y:ae})}else if(_){const ke=mi[g],{width:Ie,height:Le}=j(),ae=Ie/Le,ee=ke?ke/ae:null;let I={...N};const $e=Me-E.x,qe=Se-E.y;if(_==="se")I.width=Math.max(10,Math.min(100-I.x,N.width+$e)),ee?(I.height=I.width/ee,I.y+I.height>100&&(I.height=100-I.y,I.width=I.height*ee)):I.height=Math.max(10,Math.min(100-I.y,N.height+qe));else if(_==="sw"){const $=-$e,le=Math.max(10,N.width+$),me=N.x+N.width-le;me>=0&&(I.width=le,I.x=me,ee?(I.height=I.width/ee,I.y+I.height>100&&(I.height=100-I.y,I.width=I.height*ee,I.x=N.x+N.width-I.width)):I.height=Math.max(10,Math.min(100-I.y,N.height+qe)))}else if(_==="ne")if(I.width=Math.max(10,Math.min(100-I.x,N.width+$e)),ee){const $=I.width/ee,le=N.y+N.height-$;le>=0?(I.height=$,I.y=le):(I.y=0,I.height=N.y+N.height,I.width=I.height*ee)}else{const $=-qe,le=Math.max(10,N.height+$),me=N.y+N.height-le;me>=0&&(I.height=le,I.y=me)}else if(_==="nw"){const $=-$e,le=Math.max(10,N.width+$),me=N.x+N.width-le;if(me>=0)if(I.width=le,I.x=me,ee){const ye=I.width/ee,We=N.y+N.height-ye;We>=0?(I.height=ye,I.y=We):(I.y=0,I.height=N.y+N.height,I.width=I.height*ee,I.x=N.x+N.width-I.width)}else{const ye=-qe,We=Math.max(10,N.height+ye),mt=N.y+N.height-We;mt>=0&&(I.height=We,I.y=mt)}}I.x=Math.max(0,I.x),I.y=Math.max(0,I.y),I.width=Math.min(I.width,100-I.x),I.height=Math.min(I.height,100-I.y),C(I)}},V=()=>{D(!1),v(null)},W=X=>{w(Ce=>X==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const X=u.current;if(!X)return;const{width:Ce,height:re}=j(),Me=y.x/100*Ce,Se=y.y/100*re,ke=y.width/100*Ce,Ie=y.height/100*re,Le=document.createElement("canvas"),ae=Le.getContext("2d");if(!ae)return;Le.width=ke,Le.height=Ie;const ee=document.createElement("canvas"),I=ee.getContext("2d");I&&(ee.width=Ce,ee.height=re,I.save(),I.translate(Ce/2,re/2),I.rotate(x*Math.PI/180),I.drawImage(X,-X.width/2,-X.height/2,X.width,X.height),I.restore(),ae.drawImage(ee,Me,Se,ke,Ie,0,0,ke,Ie),Le.toBlob($e=>{$e&&e($e)},i,s))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:F?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Q={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},U={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${F?"#333":"#ddd"}`,background:F?"#242424":"#fff",flexShrink:0},oe={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ce={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},fe={...ce,background:"#E67E22",color:"#fff"},ge={...ce,background:F?"#333":"#e5e5e5",color:F?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:F?"#333":"#e5e5e5",color:F?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=X=>({padding:"8px 14px",borderRadius:"6px",border:X?"2px solid #E67E22":"2px solid transparent",background:X?"#E67E22":F?"#333":"#e5e5e5",color:X?"#fff":F?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:F?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:q,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":_?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:M,onMouseMove:O,onMouseUp:V,onMouseLeave:V})}),h.jsxs("div",{style:U,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(mi).map(X=>h.jsx("button",{onClick:()=>m(X),style:xe(g===X),children:X==="free"?"Libre":X},X))}),h.jsxs("div",{style:oe,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>W("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>W("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:ge,children:"Annuler"}),h.jsx("button",{onClick:te,style:fe,children:"Enregistrer"})]})]})]})]})}var Og={value:()=>{}};function ca(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Si(t)}function Si(r){this._=r}function zg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");if(i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Si.prototype=ca.prototype={constructor:Si,on:function(r,e){var t=this._,n=zg(r+"",t),i,s=-1,o=n.length;if(arguments.length<2){for(;++s<o;)if((i=(r=n[s]).type)&&(i=$g(t[i],r.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(r=n[s]).type)t[i]=Ol(t[i],r.name,e);else if(e==null)for(i in t)t[i]=Ol(t[i],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Si(r)},call:function(r,e){if((i=arguments.length-2)>0)for(var t=new Array(i),n=0,i,s;n<i;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(s=this._[r],n=0,i=s.length;n<i;++n)s[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],i=0,s=n.length;i<s;++i)n[i].value.apply(e,t)}};function $g(r,e){for(var t=0,n=r.length,i;t<n;++t)if((i=r[t]).name===e)return i.value}function Ol(r,e,t){for(var n=0,i=r.length;n<i;++n)if(r[n].name===e){r[n]=Og,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var vo="http://www.w3.org/1999/xhtml";const zl={svg:"http://www.w3.org/2000/svg",xhtml:vo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ws(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function qg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===vo&&e.documentElement.namespaceURI===vo?e.createElement(r):e.createElementNS(t,r)}}function Ug(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Kc(r){var e=ws(r);return(e.local?Ug:qg)(e)}function Wg(){}function da(r){return r==null?Wg:function(){return this.querySelector(r)}}function Hg(r){typeof r!="function"&&(r=da(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=new Array(o),a,u,c=0;c<o;++c)(a=s[c])&&(u=r.call(a,a.__data__,c,s))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Et(n,this._parents)}function Vg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Gg(){return[]}function Yc(r){return r==null?Gg:function(){return this.querySelectorAll(r)}}function Kg(r){return function(){return Vg(r.apply(this,arguments))}}function Yg(r){typeof r=="function"?r=Kg(r):r=Yc(r);for(var e=this._groups,t=e.length,n=[],i=[],s=0;s<t;++s)for(var o=e[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),i.push(a));return new Et(n,i)}function Qc(r){return function(){return this.matches(r)}}function Xc(r){return function(e){return e.matches(r)}}var Qg=Array.prototype.find;function Xg(r){return function(){return Qg.call(this.children,r)}}function Jg(){return this.firstElementChild}function Zg(r){return this.select(r==null?Jg:Xg(typeof r=="function"?r:Xc(r)))}var e0=Array.prototype.filter;function t0(){return Array.from(this.children)}function r0(r){return function(){return e0.call(this.children,r)}}function n0(r){return this.selectAll(r==null?t0:r0(typeof r=="function"?r:Xc(r)))}function i0(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=[],a,u=0;u<o;++u)(a=s[u])&&r.call(a,a.__data__,u,s)&&l.push(a);return new Et(n,this._parents)}function Jc(r){return new Array(r.length)}function s0(){return new Et(this._enter||this._groups.map(Jc),this._parents)}function Xi(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Xi.prototype={constructor:Xi,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function o0(r){return function(){return r}}function a0(r,e,t,n,i,s){for(var o=0,l,a=e.length,u=s.length;o<u;++o)(l=e[o])?(l.__data__=s[o],n[o]=l):t[o]=new Xi(r,s[o]);for(;o<a;++o)(l=e[o])&&(i[o]=l)}function l0(r,e,t,n,i,s,o){var l,a,u=new Map,c=e.length,d=s.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?i[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,s[l],l,s)+"",(a=u.get(p))?(n[l]=a,a.__data__=s[l],u.delete(p)):t[l]=new Xi(r,s[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(i[l]=a)}function u0(r){return r.__data__}function c0(r,e){if(!arguments.length)return Array.from(this,u0);var t=e?l0:a0,n=this._parents,i=this._groups;typeof r!="function"&&(r=o0(r));for(var s=i.length,o=new Array(s),l=new Array(s),a=new Array(s),u=0;u<s;++u){var c=n[u],d=i[u],f=d.length,p=d0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),w=a[u]=new Array(f);t(c,d,m,x,w,p,e);for(var y=0,C=0,S,D;y<g;++y)if(S=m[y]){for(y>=C&&(C=y+1);!(D=x[C])&&++C<g;);S._next=D||null}}return o=new Et(o,n),o._enter=l,o._exit=a,o}function d0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function f0(){return new Et(this._exit||this._groups.map(Jc),this._parents)}function h0(r,e,t){var n=this.enter(),i=this,s=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(i=e(i),i&&(i=i.selection())),t==null?s.remove():t(s),n&&i?n.merge(i).order():i}function p0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,i=t.length,s=n.length,o=Math.min(i,s),l=new Array(i),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<i;++a)l[a]=t[a];return new Et(l,this._parents)}function g0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],i=n.length-1,s=n[i],o;--i>=0;)(o=n[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function m0(r){r||(r=y0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s){for(var o=t[s],l=o.length,a=i[s]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Et(i,this._parents).order()}function y0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function x0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function b0(){return Array.from(this)}function v0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],i=0,s=n.length;i<s;++i){var o=n[i];if(o)return o}return null}function _0(){let r=0;for(const e of this)++r;return r}function w0(){return!this.node()}function C0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,o=i.length,l;s<o;++s)(l=i[s])&&r.call(l,l.__data__,s,i);return this}function S0(r){return function(){this.removeAttribute(r)}}function k0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function E0(r,e){return function(){this.setAttribute(r,e)}}function D0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function A0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function N0(r,e){var t=ws(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?k0:S0:typeof e=="function"?t.local?T0:A0:t.local?D0:E0)(t,e))}function Zc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function B0(r){return function(){this.style.removeProperty(r)}}function R0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function M0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?B0:typeof e=="function"?M0:R0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Zc(r).getComputedStyle(r,null).getPropertyValue(e)}function j0(r){return function(){delete this[r]}}function L0(r,e){return function(){this[r]=e}}function P0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function I0(r,e){return arguments.length>1?this.each((e==null?j0:typeof e=="function"?P0:L0)(r,e)):this.node()[r]}function ed(r){return r.trim().split(/^|\s+/)}function fa(r){return r.classList||new td(r)}function td(r){this._node=r,this._names=ed(r.getAttribute("class")||"")}td.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function rd(r,e){for(var t=fa(r),n=-1,i=e.length;++n<i;)t.add(e[n])}function nd(r,e){for(var t=fa(r),n=-1,i=e.length;++n<i;)t.remove(e[n])}function O0(r){return function(){rd(this,r)}}function z0(r){return function(){nd(this,r)}}function $0(r,e){return function(){(e.apply(this,arguments)?rd:nd)(this,r)}}function q0(r,e){var t=ed(r+"");if(arguments.length<2){for(var n=fa(this.node()),i=-1,s=t.length;++i<s;)if(!n.contains(t[i]))return!1;return!0}return this.each((typeof e=="function"?$0:e?O0:z0)(t,e))}function U0(){this.textContent=""}function W0(r){return function(){this.textContent=r}}function H0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function V0(r){return arguments.length?this.each(r==null?U0:(typeof r=="function"?H0:W0)(r)):this.node().textContent}function G0(){this.innerHTML=""}function K0(r){return function(){this.innerHTML=r}}function Y0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function Q0(r){return arguments.length?this.each(r==null?G0:(typeof r=="function"?Y0:K0)(r)):this.node().innerHTML}function X0(){this.nextSibling&&this.parentNode.appendChild(this)}function J0(){return this.each(X0)}function Z0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function em(){return this.each(Z0)}function tm(r){var e=typeof r=="function"?r:Kc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rm(){return null}function nm(r,e){var t=typeof r=="function"?r:Kc(r),n=e==null?rm:typeof e=="function"?e:da(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function sm(){return this.each(im)}function om(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function am(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(r){return this.select(r?am:om)}function um(r){return arguments.length?this.property("__data__",r):this.node().__data__}function cm(r){return function(e){r.call(this,e,this.__data__)}}function dm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,i=e.length,s;t<i;++t)s=e[t],(!r.type||s.type===r.type)&&s.name===r.name?this.removeEventListener(s.type,s.listener,s.options):e[++n]=s;++n?e.length=n:delete this.__on}}}function hm(r,e,t){return function(){var n=this.__on,i,s=cm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((i=n[o]).type===r.type&&i.name===r.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=t),i.value=e;return}}this.addEventListener(r.type,s,t),i={type:r.type,name:r.name,value:e,listener:s,options:t},n?n.push(i):this.__on=[i]}}function pm(r,e,t){var n=dm(r+""),i,s=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(i=0,c=l[a];i<s;++i)if((o=n[i]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?hm:fm,i=0;i<s;++i)this.each(l(n[i],e,t));return this}function id(r,e,t){var n=Zc(r),i=n.CustomEvent;typeof i=="function"?i=new i(e,t):(i=n.document.createEvent("Event"),t?(i.initEvent(e,t.bubbles,t.cancelable),i.detail=t.detail):i.initEvent(e,!1,!1)),r.dispatchEvent(i)}function gm(r,e){return function(){return id(this,r,e)}}function mm(r,e){return function(){return id(this,r,e.apply(this,arguments))}}function ym(r,e){return this.each((typeof e=="function"?mm:gm)(r,e))}function*xm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],i=0,s=n.length,o;i<s;++i)(o=n[i])&&(yield o)}var sd=[null];function Et(r,e){this._groups=r,this._parents=e}function si(){return new Et([[document.documentElement]],sd)}function bm(){return this}Et.prototype=si.prototype={constructor:Et,select:Hg,selectAll:Yg,selectChild:Zg,selectChildren:n0,filter:i0,data:c0,enter:s0,exit:f0,join:h0,merge:p0,selection:bm,order:g0,sort:m0,call:x0,nodes:b0,node:v0,size:_0,empty:w0,each:C0,attr:N0,style:F0,property:I0,classed:q0,text:V0,html:Q0,raise:J0,lower:em,append:tm,insert:nm,remove:sm,clone:lm,datum:um,on:pm,dispatch:ym,[Symbol.iterator]:xm};function Lt(r){return typeof r=="string"?new Et([[document.querySelector(r)]],[document.documentElement]):new Et([[r]],sd)}function vm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=vm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[r.clientX-i.left-e.clientLeft,r.clientY-i.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function wo(r){r.preventDefault(),r.stopImmediatePropagation()}function _m(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",wo,_o);"onselectstart"in e?t.on("selectstart.drag",wo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function wm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",wo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function ha(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function od(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function oi(){}var $n=.7,Ji=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Cm=/^#([0-9a-f]{3,8})$/,Sm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),km=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Em=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Dm=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Am=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Tm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ha(oi,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:Nm,formatHsl:Bm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function Nm(){return this.rgb().formatHex8()}function Bm(){return ad(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Cm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new _t(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?yi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?yi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Sm.exec(r))?new _t(e[1],e[2],e[3],1):(e=km.exec(r))?new _t(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Em.exec(r))?yi(e[1],e[2],e[3],e[4]):(e=Dm.exec(r))?yi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Am.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Tm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new _t(NaN,NaN,NaN,0):null}function Wl(r){return new _t(r>>16&255,r>>8&255,r&255,1)}function yi(r,e,t,n){return n<=0&&(r=e=t=NaN),new _t(r,e,t,n)}function Rm(r){return r instanceof oi||(r=Un(r)),r?(r=r.rgb(),new _t(r.r,r.g,r.b,r.opacity)):new _t}function Co(r,e,t,n){return arguments.length===1?Rm(r):new _t(r,e,t,n??1)}function _t(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}ha(_t,Co,od(oi,{brighter(r){return r=r==null?Ji:Math.pow(Ji,r),new _t(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new _t(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new _t(Tr(this.r),Tr(this.g),Tr(this.b),Zi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Mm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Mm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Zi(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Zi(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function ad(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof oi||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,i=Math.min(e,t,n),s=Math.max(e,t,n),o=NaN,l=s-i,a=(s+i)/2;return l?(e===s?o=(t-n)/l+(t<n)*6:t===s?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?s+i:2-s-i,o*=60):l=a>0&&a<1?0:o,new Pt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?ad(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}ha(Pt,Fm,od(oi,{brighter(r){return r=r==null?Ji:Math.pow(Ji,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,i=2*t-n;return new _t(Us(r>=240?r-240:r+120,i,n),Us(r,i,n),Us(r<120?r+240:r-120,i,n),this.opacity)},clamp(){return new Pt(Kl(this.h),xi(this.s),xi(this.l),Zi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Zi(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${xi(this.s)*100}%, ${xi(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function xi(r){return Math.max(0,Math.min(1,r||0))}function Us(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ld=r=>()=>r;function jm(r,e){return function(t){return r+t*e}}function Lm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Pm(r){return(r=+r)==1?ud:function(e,t){return t-e?Lm(e,t,r):ld(isNaN(e)?t:e)}}function ud(r,e){var t=e-r;return t?jm(r,t):ld(isNaN(r)?e:r)}const Yl=function r(e){var t=Pm(e);function n(i,s){var o=t((i=Co(i)).r,(s=Co(s)).r),l=t(i.g,s.g),a=t(i.b,s.b),u=ud(i.opacity,s.opacity);return function(c){return i.r=o(c),i.g=l(c),i.b=a(c),i.opacity=u(c),i+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ws=new RegExp(So.source,"g");function Im(r){return function(){return r}}function Om(r){return function(e){return r(e)+""}}function zm(r,e){var t=So.lastIndex=Ws.lastIndex=0,n,i,s,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=So.exec(r))&&(i=Ws.exec(e));)(s=i.index)>t&&(s=e.slice(t,s),l[o]?l[o]+=s:l[++o]=s),(n=n[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,a.push({i:o,x:fr(n,i)})),t=Ws.lastIndex;return t<e.length&&(s=e.slice(t),l[o]?l[o]+=s:l[++o]=s),l.length<2?a[0]?Om(a[0].x):Im(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Ql=180/Math.PI,ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cd(r,e,t,n,i,s){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var bi;function $m(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?ko:cd(e.a,e.b,e.c,e.d,e.e,e.f)}function qm(r){return r==null||(bi||(bi=document.createElementNS("http://www.w3.org/2000/svg","g")),bi.setAttribute("transform",r),!(r=bi.transform.baseVal.consolidate()))?ko:(r=r.matrix,cd(r.a,r.b,r.c,r.d,r.e,r.f))}function dd(r,e,t,n){function i(u){return u.length?u.pop()+" ":""}function s(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(i(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(i(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(i(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(i(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(i(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(i(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),s(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Um=dd($m,"px, ","px)","deg)"),Wm=dd(qm,", ",")",")"),Hm=1e-12;function Xl(r){return((r=Math.exp(r))+1/r)/2}function Vm(r){return((r=Math.exp(r))-1/r)/2}function Gm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Km=function r(e,t,n){function i(s,o){var l=s[0],a=s[1],u=s[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,w;if(m<Hm)w=Math.log(f/u)/e,x=function(v){return[l+v*p,a+v*g,u*Math.exp(e*v*w)]};else{var y=Math.sqrt(m),C=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(C*C+1)-C),_=Math.log(Math.sqrt(S*S+1)-S);w=(_-D)/e,x=function(v){var E=v*w,B=Xl(D),N=u/(t*y)*(B*Gm(e*E+D)-Vm(D));return[l+N*p,a+N*g,u*B/Xl(e*E+D)]}}return x.duration=w*1e3*e/Math.SQRT2,x}return i.rho=function(s){var o=Math.max(.001,+s),l=o*o,a=l*l;return r(o,l,a)},i}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,fd=1e3,es,Sn,ts=0,Lr=0,Cs=0,Wn=typeof performance=="object"&&performance.now?performance:Date,hd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function pa(){return Lr||(hd(Ym),Lr=Wn.now()+Cs)}function Ym(){Lr=0}function rs(){this._call=this._time=this._next=null}rs.prototype=pd.prototype={constructor:rs,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?pa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:es=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function pd(r,e,t){var n=new rs;return n.restart(r,e,t),n}function Qm(){pa(),++nn;for(var r=es,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Jl(){Lr=(ts=Wn.now())+Cs,nn=Cn=0;try{Qm()}finally{nn=0,Jm(),Lr=0}}function Xm(){var r=Wn.now(),e=r-ts;e>fd&&(Cs-=e,ts=r)}function Jm(){for(var r,e=es,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:es=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Jl,r-Wn.now()-Cs)),yn&&(yn=clearInterval(yn))):(yn||(ts=Wn.now(),yn=setInterval(Xm,fd)),nn=1,hd(Jl))}}function Zl(r,e,t){var n=new rs;return e=e==null?0:+e,n.restart(i=>{n.stop(),r(i+e)},e,t),n}var Zm=ca("start","end","cancel","interrupt"),e2=[],gd=0,eu=1,Do=2,ki=3,tu=4,Ao=5,Ei=6;function Ss(r,e,t,n,i,s){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;t2(r,t,{name:e,index:n,group:i,on:Zm,tween:e2,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gd})}function ga(r,e){var t=qt(r,e);if(t.state>gd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>ki)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function t2(r,e,t){var n=r.__transition,i;n[e]=t,t.timer=pd(s,0,t.time);function s(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===ki)return Zl(o);p.state===tu?(p.state=Ei,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=Ei,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===ki&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Do,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Do){for(t.state=ki,i=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(i[++d]=p);i.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Ao,1),d=-1,f=i.length;++d<f;)i[d].call(r,c);t.state===Ao&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Ei,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Di(r,e){var t=r.__transition,n,i,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){s=!1;continue}i=n.state>Do&&n.state<Ao,n.state=Ei,n.timer.stop(),n.on.call(i?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}s&&delete r.__transition}}function r2(r){return this.each(function(){Di(this,r)})}function n2(r,e){var t,n;return function(){var i=Jt(this,r),s=i.tween;if(s!==t){n=t=s;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}i.tween=n}}function i2(r,e,t){var n,i;if(typeof t!="function")throw new Error;return function(){var s=Jt(this,r),o=s.tween;if(o!==n){i=(n=o).slice();for(var l={name:e,value:t},a=0,u=i.length;a<u;++a)if(i[a].name===e){i[a]=l;break}a===u&&i.push(l)}s.tween=i}}function s2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(this.node(),t).tween,i=0,s=n.length,o;i<s;++i)if((o=n[i]).name===r)return o.value;return null}return this.each((e==null?n2:i2)(t,r,e))}function ma(r,e,t){var n=r._id;return r.each(function(){var i=Jt(this,n);(i.value||(i.value={}))[e]=t.apply(this,arguments)}),function(i){return qt(i,n).value[e]}}function md(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):zm)(r,e)}function o2(r){return function(){this.removeAttribute(r)}}function a2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function l2(r,e,t){var n,i=t+"",s;return function(){var o=this.getAttribute(r);return o===i?null:o===n?s:s=e(n=o,t)}}function u2(r,e,t){var n,i=t+"",s;return function(){var o=this.getAttributeNS(r.space,r.local);return o===i?null:o===n?s:s=e(n=o,t)}}function c2(r,e,t){var n,i,s;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l)))}}function d2(r,e,t){var n,i,s;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l)))}}function f2(r,e){var t=ws(r),n=t==="transform"?Wm:md;return this.attrTween(r,typeof e=="function"?(t.local?d2:c2)(t,n,ma(this,"attr."+r,e)):e==null?(t.local?a2:o2)(t):(t.local?u2:l2)(t,n,e))}function h2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function p2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function g2(r,e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&p2(r,s)),t}return i._value=e,i}function m2(r,e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&h2(r,s)),t}return i._value=e,i}function y2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=ws(r);return this.tween(t,(n.local?g2:m2)(n,e))}function x2(r,e){return function(){ga(this,r).delay=+e.apply(this,arguments)}}function b2(r,e){return e=+e,function(){ga(this,r).delay=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?x2:b2)(e,r)):qt(this.node(),e).delay}function _2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function w2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function C2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?_2:w2)(e,r)):qt(this.node(),e).duration}function S2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function k2(r){var e=this._id;return arguments.length?this.each(S2(e,r)):qt(this.node(),e).ease}function E2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function D2(r){if(typeof r!="function")throw new Error;return this.each(E2(this._id,r))}function A2(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),i=0;i<t;++i)for(var s=e[i],o=s.length,l=n[i]=[],a,u=0;u<o;++u)(a=s[u])&&r.call(a,a.__data__,u,s)&&l.push(a);return new sr(n,this._parents,this._name,this._id)}function T2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,i=t.length,s=Math.min(n,i),o=new Array(n),l=0;l<s;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new sr(o,this._parents,this._name,this._id)}function N2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function B2(r,e,t){var n,i,s=N2(e)?ga:Jt;return function(){var o=s(this,r),l=o.on;l!==n&&(i=(n=l).copy()).on(e,t),o.on=i}}function R2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(B2(t,r,e))}function M2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",M2(this._id))}function j2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=da(r));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],a=l.length,u=s[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ss(u[f],e,t,f,u,qt(c,t)));return new sr(s,this._parents,e,t)}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Yc(r));for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ss(p,e,t,m,f,g);s.push(f),o.push(c)}return new sr(s,o,e,t)}var P2=si.prototype.constructor;function I2(){return new P2(this._groups,this._parents)}function O2(r,e){var t,n,i;return function(){var s=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return s===o?null:s===t&&o===n?i:i=e(t=s,n=o)}}function yd(r){return function(){this.style.removeProperty(r)}}function z2(r,e,t){var n,i=t+"",s;return function(){var o=rn(this,r);return o===i?null:o===n?s:s=e(n=o,t)}}function $2(r,e,t){var n,i,s;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===i?s:(i=a,s=e(n=o,l))}}function q2(r,e){var t,n,i,s="style."+e,o="end."+s,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[s]==null?l||(l=yd(e)):void 0;(u!==t||i!==c)&&(n=(t=u).copy()).on(o,i=c),a.on=n}}function U2(r,e,t){var n=(r+="")=="transform"?Um:md;return e==null?this.styleTween(r,O2(r,n)).on("end.style."+r,yd(r)):typeof e=="function"?this.styleTween(r,$2(r,n,ma(this,"style."+r,e))).each(q2(this._id,r)):this.styleTween(r,z2(r,n,e),t).on("end.style."+r,null)}function W2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function H2(r,e,t){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&W2(r,o,t)),n}return s._value=e,s}function V2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,H2(r,e,t??""))}function G2(r){return function(){this.textContent=r}}function K2(r){return function(){var e=r(this);this.textContent=e??""}}function Y2(r){return this.tween("text",typeof r=="function"?K2(ma(this,"text",r)):G2(r==null?"":r+""))}function Q2(r){return function(e){this.textContent=r.call(this,e)}}function X2(r){var e,t;function n(){var i=r.apply(this,arguments);return i!==t&&(e=(t=i)&&Q2(i)),e}return n._value=r,n}function J2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,X2(r))}function Z2(){for(var r=this._name,e=this._id,t=xd(),n=this._groups,i=n.length,s=0;s<i;++s)for(var o=n[s],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=qt(a,e);Ss(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new sr(n,this._parents,r,t)}function ey(){var r,e,t=this,n=t._id,i=t.size();return new Promise(function(s,o){var l={value:o},a={value:function(){--i===0&&s()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),i===0&&s()})}var ty=0;function sr(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function xd(){return++ty}var tr=si.prototype;sr.prototype={constructor:sr,select:j2,selectAll:L2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:A2,merge:T2,selection:I2,transition:Z2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:R2,attr:f2,attrTween:y2,style:U2,styleTween:V2,text:Y2,textTween:J2,remove:F2,tween:s2,delay:v2,duration:C2,ease:k2,easeVarying:D2,end:ey,[Symbol.iterator]:tr[Symbol.iterator]};function ry(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ny={time:null,delay:0,duration:250,ease:ry};function iy(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function sy(r){var e,t;r instanceof sr?(e=r._id,r=r._name):(e=xd(),(t=ny).time=pa(),r=r==null?null:r+"");for(var n=this._groups,i=n.length,s=0;s<i;++s)for(var o=n[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ss(a,r,e,u,o,t||iy(a,e));return new sr(n,this._parents,r,e)}si.prototype.interrupt=r2;si.prototype.transition=sy;const vi=r=>()=>r;function oy(r,{sourceEvent:e,target:t,transform:n,dispatch:i}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:i}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ns=new nr(1,0,0);nr.prototype;function Hs(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ay(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function ly(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ns}function uy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function cy(){return navigator.maxTouchPoints||"ontouchstart"in this}function dy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],i=r.invertX(e[1][0])-t[1][0],s=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(i>n?(n+i)/2:Math.min(0,n)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function fy(){var r=ay,e=ly,t=dy,n=uy,i=cy,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Km,u=ca("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function w(k){k.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",N).filter(i).on("touchstart.zoom",T).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(k,R,M,O){var V=k.selection?k.selection():k;V.property("__zoom",ru),k!==V?D(k,R,M,O):V.interrupt().each(function(){_(this,arguments).event(O).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},w.scaleBy=function(k,R,M,O){w.scaleTo(k,function(){var V=this.__zoom.k,W=typeof R=="function"?R.apply(this,arguments):R;return V*W},M,O)},w.scaleTo=function(k,R,M,O){w.transform(k,function(){var V=e.apply(this,arguments),W=this.__zoom,te=M==null?S(V):typeof M=="function"?M.apply(this,arguments):M,q=W.invert(te),Q=typeof R=="function"?R.apply(this,arguments):R;return t(C(y(W,Q),te,q),V,o)},M,O)},w.translateBy=function(k,R,M,O){w.transform(k,function(){return t(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof M=="function"?M.apply(this,arguments):M),e.apply(this,arguments),o)},null,O)},w.translateTo=function(k,R,M,O,V){w.transform(k,function(){var W=e.apply(this,arguments),te=this.__zoom,q=O==null?S(W):typeof O=="function"?O.apply(this,arguments):O;return t(ns.translate(q[0],q[1]).scale(te.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof M=="function"?-M.apply(this,arguments):-M),W,o)},O,V)};function y(k,R){return R=Math.max(s[0],Math.min(s[1],R)),R===k.k?k:new nr(R,k.x,k.y)}function C(k,R,M){var O=R[0]-M[0]*k.k,V=R[1]-M[1]*k.k;return O===k.x&&V===k.y?k:new nr(k.k,O,V)}function S(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function D(k,R,M,O){k.on("start.zoom",function(){_(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(O).end()}).tween("zoom",function(){var V=this,W=arguments,te=_(V,W).event(O),q=e.apply(V,W),Q=M==null?S(q):typeof M=="function"?M.apply(V,W):M,U=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),oe=V.__zoom,ce=typeof R=="function"?R.apply(V,W):R,fe=a(oe.invert(Q).concat(U/oe.k),ce.invert(Q).concat(U/ce.k));return function(ge){if(ge===1)ge=ce;else{var De=fe(ge),xe=U/De[2];ge=new nr(xe,Q[0]-De[0]*xe,Q[1]-De[1]*xe)}te.zoom(null,ge)}})}function _(k,R,M){return!M&&k.__zooming||new v(k,R)}function v(k,R){this.that=k,this.args=R,this.active=0,this.sourceEvent=null,this.extent=e.apply(k,R),this.taps=0}v.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,R){return this.mouse&&k!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var R=Lt(this.that).datum();u.call(k,this.that,new oy(k,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:u}),R)}};function E(k,...R){if(!r.apply(this,arguments))return;var M=_(this,R).event(k),O=this.__zoom,V=Math.max(s[0],Math.min(s[1],O.k*Math.pow(2,n.apply(this,arguments)))),W=wr(k);if(M.wheel)(M.mouse[0][0]!==W[0]||M.mouse[0][1]!==W[1])&&(M.mouse[1]=O.invert(M.mouse[0]=W)),clearTimeout(M.wheel);else{if(O.k===V)return;M.mouse=[W,O.invert(W)],Di(this),M.start()}xn(k),M.wheel=setTimeout(te,g),M.zoom("mouse",t(C(y(O,V),M.mouse[0],M.mouse[1]),M.extent,o));function te(){M.wheel=null,M.end()}}function B(k,...R){if(f||!r.apply(this,arguments))return;var M=k.currentTarget,O=_(this,R,!0).event(k),V=Lt(k.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",U,!0),W=wr(k,M),te=k.clientX,q=k.clientY;_m(k.view),Hs(k),O.mouse=[W,this.__zoom.invert(W)],Di(this),O.start();function Q(oe){if(xn(oe),!O.moved){var ce=oe.clientX-te,fe=oe.clientY-q;O.moved=ce*ce+fe*fe>m}O.event(oe).zoom("mouse",t(C(O.that.__zoom,O.mouse[0]=wr(oe,M),O.mouse[1]),O.extent,o))}function U(oe){V.on("mousemove.zoom mouseup.zoom",null),wm(oe.view,O.moved),xn(oe),O.event(oe).end()}}function N(k,...R){if(r.apply(this,arguments)){var M=this.__zoom,O=wr(k.changedTouches?k.changedTouches[0]:k,this),V=M.invert(O),W=M.k*(k.shiftKey?.5:2),te=t(C(y(M,W),O,V),e.apply(this,R),o);xn(k),l>0?Lt(this).transition().duration(l).call(D,te,O,k):Lt(this).call(w.transform,te,O,k)}}function T(k,...R){if(r.apply(this,arguments)){var M=k.touches,O=M.length,V=_(this,R,k.changedTouches.length===O).event(k),W,te,q,Q;for(Hs(k),te=0;te<O;++te)q=M[te],Q=wr(q,this),Q=[Q,this.__zoom.invert(Q),q.identifier],V.touch0?!V.touch1&&V.touch0[2]!==Q[2]&&(V.touch1=Q,V.taps=0):(V.touch0=Q,W=!0,V.taps=1+!!c);c&&(c=clearTimeout(c)),W&&(V.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Di(this),V.start())}}function F(k,...R){if(this.__zooming){var M=_(this,R).event(k),O=k.changedTouches,V=O.length,W,te,q,Q;for(xn(k),W=0;W<V;++W)te=O[W],q=wr(te,this),M.touch0&&M.touch0[2]===te.identifier?M.touch0[0]=q:M.touch1&&M.touch1[2]===te.identifier&&(M.touch1[0]=q);if(te=M.that.__zoom,M.touch1){var U=M.touch0[0],oe=M.touch0[1],ce=M.touch1[0],fe=M.touch1[1],ge=(ge=ce[0]-U[0])*ge+(ge=ce[1]-U[1])*ge,De=(De=fe[0]-oe[0])*De+(De=fe[1]-oe[1])*De;te=y(te,Math.sqrt(ge/De)),q=[(U[0]+ce[0])/2,(U[1]+ce[1])/2],Q=[(oe[0]+fe[0])/2,(oe[1]+fe[1])/2]}else if(M.touch0)q=M.touch0[0],Q=M.touch0[1];else return;M.zoom("touch",t(C(te,q,Q),M.extent,o))}}function j(k,...R){if(this.__zooming){var M=_(this,R).event(k),O=k.changedTouches,V=O.length,W,te;for(Hs(k),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),W=0;W<V;++W)te=O[W],M.touch0&&M.touch0[2]===te.identifier?delete M.touch0:M.touch1&&M.touch1[2]===te.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var q=Lt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return w.wheelDelta=function(k){return arguments.length?(n=typeof k=="function"?k:vi(+k),w):n},w.filter=function(k){return arguments.length?(r=typeof k=="function"?k:vi(!!k),w):r},w.touchable=function(k){return arguments.length?(i=typeof k=="function"?k:vi(!!k),w):i},w.extent=function(k){return arguments.length?(e=typeof k=="function"?k:vi([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),w):e},w.scaleExtent=function(k){return arguments.length?(s[0]=+k[0],s[1]=+k[1],w):[s[0],s[1]]},w.translateExtent=function(k){return arguments.length?(o[0][0]=+k[0][0],o[1][0]=+k[1][0],o[0][1]=+k[0][1],o[1][1]=+k[1][1],w):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},w.constrain=function(k){return arguments.length?(t=k,w):t},w.duration=function(k){return arguments.length?(l=+k,w):l},w.interpolate=function(k){return arguments.length?(a=k,w):a},w.on=function(){var k=u.on.apply(u,arguments);return k===u?w:k},w.clickDistance=function(k){return arguments.length?(m=(k=+k)*k,w):Math.sqrt(m)},w.tapDistance=function(k){return arguments.length?(x=+k,w):x},w}function bd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:i=!0,pannable:s=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=fy().scaleExtent([e,t]).filter(y=>!i&&y.type==="wheel"||!s&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?i:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:s:!0).on("zoom",y=>{const C={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(C),o==null||o(C)});a.current=x;const w=Lt(l.current);return w.call(x),w.on("dblclick.zoom",null),n&&w.call(x.transform,ns.translate(n.x,n.y).scale(n.k)),()=>{w.on(".zoom",null)}},[e,t,i,s]),b.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const w={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(w),o==null||o(w)})},[o]);const d=b.useCallback((x,w,y,C=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),D=ns.translate(x,w).scale(y);S.call(a.current.transform,D)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,w=50)=>{if(!l.current||!a.current||x.length===0)return;const C=l.current.getBoundingClientRect();let S=1/0,D=1/0,_=-1/0,v=-1/0;for(const O of x){const V=O.width||200,W=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),_=Math.max(_,O.x+V),v=Math.max(v,O.y+W)}const E=_-S,B=v-D,N=(C.width-w*2)/E,T=(C.height-w*2)/B,F=Math.min(N,T,t),j=(S+_)/2,k=(D+v)/2,R=C.width/2-j*F,M=C.height/2-k*F;d(R,M,F,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function vd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:i,disabled:s=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((C,S)=>{const D=g.current;return{x:(C-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=b.useCallback((C,S)=>{if(s)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,_=parseFloat(D.dataset.x||"0"),v=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:_,nodeY:v},p.current={x:_,y:v},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[s,m,t]),w=b.useCallback(C=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,_=C.clientX-D.x,v=C.clientY-D.y,E=_/S.k,B=v/S.k,N=D.nodeX+E,T=D.nodeY+B;p.current={x:N,y:T},d({x:E,y:B}),n==null||n(o,N,T,E,B)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const C=p.current;i==null||i(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,i]);return b.useEffect(()=>{if(!a)return;const C=D=>{w(D)},S=()=>{y()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,w,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:w,endDrag:y}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,onSelectionChange:i}=r,[s,o]=b.useState(new Set),[l,a]=b.useState(null),[u,c]=b.useState(!1),d=b.useRef(null),f=b.useRef(e),p=b.useRef(t);b.useEffect(()=>{f.current=e},[e]),b.useEffect(()=>{p.current=t},[t]);const g=b.useCallback((_,v)=>{const E=f.current;return{x:(_-E.x)/E.k,y:(v-E.y)/E.k}},[]),m=b.useCallback((_,v)=>{const E=p.current.get(_);if(!E)return!1;const B=E.width||200,N=E.height||100;return E.x<v.x+v.width&&E.x+B>v.x&&E.y<v.y+v.height&&E.y+N>v.y},[]),x=b.useCallback(_=>{if(n||_.target.closest("[data-qmap-node]"))return;_.preventDefault();const E=g(_.clientX,_.clientY);d.current=E,a({x:E.x,y:E.y,width:0,height:0}),c(!0),_.shiftKey||o(new Set)},[n,g]),w=b.useCallback(_=>{if(!u||!d.current)return;const v=d.current,E=g(_.clientX,_.clientY),B={x:Math.min(v.x,E.x),y:Math.min(v.y,E.y),width:Math.abs(E.x-v.x),height:Math.abs(E.y-v.y)};a(B);const N=new Set;for(const[T]of p.current)m(T,B)&&N.add(T);o(N)},[u,g,m]),y=b.useCallback(()=>{u&&(i==null||i(Array.from(s)),c(!1),a(null),d.current=null)},[u,s,i]);b.useEffect(()=>{if(!u)return;const _=E=>{w(E)},v=()=>{y()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",v),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",v)}},[u,w,y]);const C=b.useCallback((_,v=!1)=>{o(E=>{const B=new Set(v?E:[]);return E.has(_)&&v?B.delete(_):B.add(_),i==null||i(Array.from(B)),B})},[i]),S=b.useCallback(()=>{const _=new Set(p.current.keys());o(_),i==null||i(Array.from(_))},[i]),D=b.useCallback(()=>{o(new Set),i==null||i([])},[i]);return{selectedIds:s,setSelectedIds:o,selectionBox:l,isSelecting:u,startSelection:x,updateSelection:w,endSelection:y,toggleSelect:C,selectAll:S,clearSelection:D}}const wd=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:i,draggable:s,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{s&&y.button===0&&o(e,y)},[e,s,o]),f=b.useCallback(y=>{i||l==null||l(y)},[i,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,w=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:w!==0?`rotate(${w}deg)`:void 0,transformOrigin:"center center",cursor:s?i?"grabbing":"grab":"pointer",userSelect:"none",opacity:i?.8:1,zIndex:i?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Cd(r,e,t="bezier"){const n=Hn(r),i=Hn(e),s=To(r,i),o=To(e,n);switch(t){case"straight":return`M ${s.x} ${s.y} L ${o.x} ${o.y}`;case"orthogonal":return py(s,o);case"bezier":default:return hy(s,o)}}function hy(r,e){const t=e.x-r.x,n=e.y-r.y,i=Math.sqrt(t*t+n*n),s=Math.min(i*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+s*Math.sign(t),a=r.y,u=e.x-s*Math.sign(t),c=e.y):(l=r.x,a=r.y+s*Math.sign(n),u=e.x,c=e.y-s*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function py(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const s=r.x+t/2;return`M ${r.x} ${r.y} H ${s} V ${e.y} H ${e.x}`}else{const s=r.y+n/2;return`M ${r.x} ${r.y} V ${s} H ${e.x} V ${e.y}`}}function Hn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function To(r,e){const t=r.width||200,n=r.height||100,i=Hn(r),s=e.x-i.x,o=e.y-i.y;if(s===0&&o===0)return i;const l=t/2,a=n/2,u=Math.abs(o/(s||.001)),c=a/l;let d,f;return u<c?(d=i.x+(s>0?l:-l),f=i.y+o*l/Math.abs(s)):(f=i.y+(o>0?a:-a),d=i.x+s*a/Math.abs(o)),{x:d,y:f}}function gy(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return Hn(r)}}function my(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function yy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function xy(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r){const o=s.width||200,l=s.height||100;e=Math.min(e,s.x),t=Math.min(t,s.y),n=Math.max(n,s.x+o),i=Math.max(i,s.y+l)}return{x:e,y:t,width:n-e,height:i-t}}function by(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function vy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Sd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:i,color:s,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>Cd(t,n,i),[t,n,i]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||s,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(_y,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function _y({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const kd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:i,defaultWidth:s,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=b.useMemo(()=>{if(t.size===0)return"0 0 1000 1000";let u=1/0,c=1/0,d=-1/0,f=-1/0;for(const p of t.values()){const g=p.width||200,m=p.height||100;u=Math.min(u,p.x-100),c=Math.min(c,p.y-100),d=Math.max(d,p.x+g+100),f=Math.max(f,p.y+m+100)}return u-=1e3,c-=1e3,d+=1e3,f+=1e3,`${u} ${c} ${d-u} ${f-c}`},[t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:a,preserveAspectRatio:"none",children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(u=>{const c=t.get(u.source),d=t.get(u.target);return h.jsx(Sd,{edge:u,sourcePosition:c,targetPosition:d,style:u.style||n,color:u.color||i,width:u.width||s,onClick:o},u.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Ed=b.memo(function({box:e,transform:t}){const n=b.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),wy=200,Cy=100,Sy="bezier",ky="#94a3b8",Ey=2,Dy=.1,Ay=4;function Ty({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:i=wy,defaultNodeHeight:s=Cy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,onSelectionChange:c,onEdgeClick:d,onViewChange:f,onTransformChange:p,minZoom:g=Dy,maxZoom:m=Ay,initialTransform:x,defaultEdgeStyle:w=Sy,defaultEdgeColor:y=ky,defaultEdgeWidth:C=Ey,draggable:S=!0,selectable:D=!0,zoomable:_=!0,pannable:v=!0,className:E="",style:B,background:N="#f8fafc",showGrid:T=!1,gridSize:F=20}){const j=r.data||{positions:{}},k=j.positions||{},R=b.useMemo(()=>{const ae=new Map;for(const ee of e){const I=k[ee._id]||{x:0,y:0};ae.set(ee._id,{x:I.x,y:I.y,width:I.width||i,height:I.height||s,rotation:I.rotation||0})}return ae},[e,k,i,s]),{transform:M,containerRef:O,zoomIn:V,zoomOut:W,resetZoom:te,fitToContent:q}=bd({minZoom:g,maxZoom:m,initialTransform:x||j.transform,zoomable:_,pannable:v,onTransformChange:ae=>{p==null||p(ae);const ee={...j,transform:ae};f==null||f(ee)}}),[Q,U]=b.useState(new Map),{draggedNodeId:oe,startDrag:ce}=vd({transform:M,disabled:!S,onDragStart:ae=>{const ee=R.get(ae);ee&&U(new Map([[ae,{x:ee.x,y:ee.y}]]))},onDragMove:(ae,ee,I)=>{U(new Map([[ae,{x:ee,y:I}]]))},onDragEnd:(ae,ee,I)=>{U(new Map),o==null||o(ae,ee,I)}}),{selectedIds:fe,selectionBox:ge,isSelecting:De,startSelection:xe,toggleSelect:X,clearSelection:Ce}=_d({transform:M,nodePositions:R,disabled:!D,onSelectionChange:c}),re=b.useCallback(ae=>{const ee=R.get(ae)||{x:0,y:0,width:i,height:s},I=Q.get(ae);return I?{...ee,x:I.x,y:I.y}:ee},[R,Q,i,s]),Me=b.useMemo(()=>{const ae=new Map;for(const ee of R.keys())ae.set(ee,re(ee));return ae},[R,re]),Se=b.useCallback((ae,ee)=>{X(ae._id,ee.shiftKey),l==null||l(ae,ee)},[X,l]),ke=b.useCallback(ae=>{ae.target.closest("[data-qmap-node]")||Ce()},[Ce]),Ie=b.useCallback(ae=>{ae.button===0&&(ae.target.closest("[data-qmap-node]")||xe(ae))},[xe]),Le=T?`
|
|
186
186
|
linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
|
|
187
187
|
linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px)
|
|
188
188
|
`:void 0;return h.jsxs("div",{ref:O,className:`qmap-container ${E}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:N,backgroundImage:Le,backgroundSize:T?`${F}px ${F}px`:void 0,cursor:De?"crosshair":v?"grab":"default",...B},onMouseDown:Ie,onClick:ke,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${M.x}px, ${M.y}px) scale(${M.k})`,willChange:"transform"},children:[h.jsx(kd,{edges:t,nodePositions:Me,defaultStyle:w,defaultColor:y,defaultWidth:C,onEdgeClick:d}),e.map(ae=>{const ee=re(ae._id),I=fe.has(ae._id),$e=oe===ae._id;return h.jsx(wd,{nodeId:ae._id,position:ee,isSelected:I,isDragging:$e,draggable:S,onDragStart:ce,onClick:qe=>Se(ae,qe),onDoubleClick:qe=>a==null?void 0:a(ae,qe),onContextMenu:qe=>u==null?void 0:u(ae,qe),children:n(ae,I,ee)},ae._id)})]}),ge&&h.jsx(Ed,{box:ge,transform:M}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:V,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),h.jsx("button",{onClick:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),h.jsx("button",{onClick:te,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),h.jsx("button",{onClick:()=>q(Array.from(R.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=ua;exports.$isQRCodeNode=xg;exports.AnimatedCardFlip=xf;exports.ApiClient=ou;exports.AudioEditor=Gc;exports.AuthFlow=du;exports.AuthFlowModal=ff;exports.AuthManager=bt;exports.AuthProvider=nf;exports.AuthService=No;exports.Card=gf;exports.ComboBox=Ag;exports.ComboStack=Ng;exports.DataOperations=_i;exports.Detail=mf;exports.ForgotPasswordForm=uu;exports.GraphClient=Rd;exports.ImageEditor=Ig;exports.KanbanBoard=Bg;exports.LoginForm=Ro;exports.LoginModal=af;exports.Mail=vf;exports.MailClient=su;exports.MailComposer=Eg;exports.MailEditor=Vc;exports.QMap=Ty;exports.QMapEdgeComponent=Sd;exports.QMapEdgeLayer=kd;exports.QMapNode=wd;exports.QMapSelectionBox=Ed;exports.QRCodeNode=un;exports.RegisterForm=lu;exports.ResetPasswordForm=cu;exports.SelectableList=_f;exports.Stack=pf;exports.Timeline=Lg;exports.VerifyCodeForm=Ks;exports.VoiceTextEditor=Pg;exports.calculateBoundingBox=xy;exports.calculateEdgePath=Cd;exports.distance=by;exports.distanceSquared=vy;exports.getApiClient=Bo;exports.getAuthService=Zd;exports.getConnectionPoint=To;exports.getNodeCenter=Hn;exports.getNodeSidePoint=gy;exports.initializeApiClient=ef;exports.initializeAuthService=Jd;exports.pointInRect=my;exports.rectsIntersect=yy;exports.useAuth=sf;exports.useMutation=hf;exports.useNodeDrag=vd;exports.useQuery=fu;exports.useSelection=_d;exports.useZoomPan=bd;
|
package/dist/index.esm.js
CHANGED
|
@@ -19135,9 +19135,6 @@ const Q2 = us(function({
|
|
|
19135
19135
|
transformOrigin: "center center",
|
|
19136
19136
|
cursor: s ? i ? "grabbing" : "grab" : "pointer",
|
|
19137
19137
|
userSelect: "none",
|
|
19138
|
-
// Visual feedback for selection
|
|
19139
|
-
outline: n ? "2px solid #3b82f6" : void 0,
|
|
19140
|
-
outlineOffset: "2px",
|
|
19141
19138
|
// Visual feedback for dragging
|
|
19142
19139
|
opacity: i ? 0.8 : 1,
|
|
19143
19140
|
zIndex: i ? 1e3 : n ? 100 : 1,
|
package/package.json
CHANGED