@popmelt.com/core 0.7.1 → 0.7.2

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  var md=Object.defineProperty,hd=Object.defineProperties;var yd=Object.getOwnPropertyDescriptors;var fi=Object.getOwnPropertySymbols;var Ta=Object.prototype.hasOwnProperty,Ma=Object.prototype.propertyIsEnumerable;var ka=(e,t,n)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))Ta.call(t,n)&&ka(e,n,t[n]);if(fi)for(var n of fi(t))Ma.call(t,n)&&ka(e,n,t[n]);return e},y=(e,t)=>hd(e,yd(t));var uo=e=>typeof e=="symbol"?e:e+"",Dn=(e,t)=>{var n={};for(var o in e)Ta.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&fi)for(var o of fi(e))t.indexOf(o)<0&&Ma.call(e,o)&&(n[o]=e[o]);return n};import{createContext as Km,useCallback as $t,useContext as Xm,useEffect as Pt,useMemo as vo,useRef as on,useState as Et}from"react";import{useCallback as Wa,useEffect as xd,useSyncExternalStore as Sd}from"react";var Sn="http://localhost:1111";function Rn(e,t={},n=15e3){let o=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>o.abort());let r=setTimeout(()=>o.abort(),n);return fetch(e,y(f({},t),{signal:o.signal})).finally(()=>clearTimeout(r))}async function Ra(e=Sn){try{let t=await Rn(`${e}/capabilities`,{},5e3);return t.ok?await t.json():null}catch(t){return null}}async function _o(e=Sn){try{let t=new AbortController,n=setTimeout(()=>t.abort(),2e3),o=await fetch(`${e}/status`,{signal:t.signal});return clearTimeout(n),o.ok?await o.json():null}catch(t){return null}}async function Ia(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),500),o=await fetch(`http://localhost:${e}/status`,{signal:t.signal});return clearTimeout(n),o.ok?await o.json():null}catch(t){return null}}async function bd(e){return _o(e)}async function La(e,t){if(e&&e!=="http://localhost:1111")try{let c=new URL(e),u=await bd(e);if(!u&&!t)return null;if(!(!u&&t)){if(!(u&&t&&u.projectId!==t)){if(u)return{url:e,port:parseInt(c.port,10)||1111,projectId:u.projectId}}}}catch(c){if(!t)return null}let s=typeof window!="undefined"?window.location.origin:null,i=await Ia(1111);if(i){if(t&&i.projectId===t)return{url:"http://localhost:1111",port:1111,projectId:i.projectId};if(i.devOrigin&&s&&i.devOrigin===s)return{url:"http://localhost:1111",port:1111,projectId:i.projectId}}let l=Array.from({length:8},(c,u)=>{let p=1112+u;return Ia(p).then(g=>g?{status:g,port:p}:null)}),a=(await Promise.all(l)).filter(c=>c!==null),d=[];i&&d.push({port:1111,devOrigin:i.devOrigin,projectId:i.projectId});for(let c of a)d.push({port:c.port,devOrigin:c.status.devOrigin,projectId:c.status.projectId});if(t){let c=d.find(u=>u.projectId===t);if(c)return{url:`http://localhost:${c.port}`,port:c.port,projectId:c.projectId}}if(s){let c=d.find(u=>u.devOrigin===s);if(c)return{url:`http://localhost:${c.port}`,port:c.port,projectId:c.projectId}}return d.length===1?{url:`http://localhost:${d[0].port}`,port:d[0].port,projectId:d[0].projectId}:null}async function gi(e=Sn,t,n=-1){try{let o=await Rn(`${e}/jobs/${t}/events?afterSeq=${n}`,{},5e3);return o.ok?await o.json():null}catch(o){return null}}async function Aa(e,t,n=Sn,o,r,s,i,l){let a=new FormData;if(e instanceof Map){let c=!0;for(let[u,p]of e){let g=encodeURIComponent(u);a.append(`screenshot-${g}`,p,`screenshot-${g}.webp`),c&&(a.append("screenshot",p,"screenshot.webp"),c=!1)}c&&a.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else a.append("screenshot",e,"screenshot.webp");if(a.append("feedback",t),o&&a.append("color",o),r&&a.append("provider",r),s&&a.append("model",s),l&&a.append("sourceId",l),i)for(let[c,u]of i)for(let p=0;p<u.length;p++)a.append(`image-${c}-${p}`,u[p],`image-${c}-${p}.webp`);let d=await Rn(`${n}/send`,{method:"POST",body:a},3e4);if(!d.ok){let c=await d.text();throw new Error(`Bridge returned ${d.status}: ${c}`)}return d.json()}async function Pa(e,t=Sn){let n=await Rn(`${t}/model/component`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!n.ok){let o=await n.text();throw new Error(`Bridge returned ${n.status}: ${o}`)}return n.json()}async function Oa(e,t=Sn){let n=await Rn(`${t}/model/component`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!n.ok){let o=await n.text();throw new Error(`Bridge returned ${n.status}: ${o}`)}return n.json()}async function ls(e,t,n=Sn){let o=await Rn(`${n}/model/token`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,value:t})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function Ba(e,t=Sn){let n=await Rn(`${t}/model/token`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})},1e4);if(!n.ok){let o=await n.text();throw new Error(`Bridge returned ${n.status}: ${o}`)}return n.json()}async function Tr(e=Sn){var t;try{let n=await Rn(`${e}/model`,{},5e3);return n.ok&&(t=(await n.json()).model)!=null?t:null}catch(n){return null}}async function Da(e=Sn){let t=await Rn(`${e}/evals`,{},5e3);return t.ok?t.json():{version:1,updatedAt:0,cases:[]}}async function mi(e,t,n=Sn){var s;let o=await Rn(`${n}/evals/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},5e3);return o.ok&&(s=(await o.json()).eval)!=null?s:null}function _a(e,t,n=Sn){return mi(e,{status:t},n)}async function Ha(e,t,n,o=Sn,r,s,i){let l=new FormData;l.append("screenshot",t,"eval-run.webp"),l.append("feedback",JSON.stringify(n)),r&&l.append("provider",r),s&&l.append("model",s),i&&l.append("sourceId",i);let a=await Rn(`${o}/evals/${encodeURIComponent(e)}/run`,{method:"POST",body:l},3e4);if(!a.ok){let d=await a.text();throw new Error(`Bridge returned ${a.status}: ${d}`)}return a.json()}function vd(e){return new Promise(t=>setTimeout(t,e))}async function cs(e=Sn,t,n=15e3){let o=Date.now();try{let i=await Rn(`${e}/restart`,{method:"POST"},5e3);if(!i.ok){let l=await i.text().catch(()=>"");return{ok:!1,error:l?`Bridge restart returned ${i.status}: ${l}`:`Bridge restart returned ${i.status}`,elapsedMs:Date.now()-o}}}catch(i){return{ok:!1,error:i instanceof Error?i.message:"Bridge restart request failed",elapsedMs:Date.now()-o}}let r=null;for(;Date.now()-o<n;)if(await vd(350),r=await _o(e),!!(r!=null&&r.ok)&&!(t&&r.version!==t))return{ok:!0,status:r,elapsedMs:Date.now()-o};return{ok:!1,error:`Bridge did not come back${t?` with version ${t}`:""} within ${Math.round(n/1e3)}s`,status:r,elapsedMs:Date.now()-o}}async function Na(e=Sn){return(await cs(e)).ok}async function za(e=Sn,t,n){let o=await Rn(`${e}/model/synthesize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:n})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function Fa(e=Sn,t,n){let o=await Rn(`${e}/evals/synthesize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:n})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function $a(e,t,n=Sn,o,r,s,i,l){let a;if(i&&i.length>0){let d=new FormData,c=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});d.append("screenshot",c,"screenshot.png"),d.append("feedback",JSON.stringify({threadId:e,reply:t,color:o,provider:r,model:s,sourceId:l}));for(let u=0;u<i.length;u++)d.append(`image-reply-${u}`,i[u],`reply-image-${u}.webp`);a=await Rn(`${n}/reply`,{method:"POST",body:d},3e4)}else a=await Rn(`${n}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:o,provider:r,model:s,sourceId:l})},3e4);if(!a.ok){let d=await a.text();throw new Error(`Bridge returned ${a.status}: ${d}`)}return a.json()}var xi={};var sr=typeof xi!="undefined"?xi.hot:void 0,Ga,Ya,Ja,Si=(Ja=(Ya=(Ga=sr==null?void 0:sr.data)==null?void 0:Ga.sourceId)!=null?Ya:typeof localStorage!="undefined"&&localStorage.getItem("popmelt-source-id"))!=null?Ja:typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2);sr!=null&&sr.data&&(sr.data.sourceId=Si);try{typeof localStorage!="undefined"&&localStorage.setItem("popmelt-source-id",Si)}catch(e){}function wi(){return Si}var ar=typeof xi!="undefined"?xi.hot:void 0,tn=ar==null?void 0:ar.data,wd={isConnected:!1,status:"disconnected",jobResponses:{},jobThinking:{},activeJobIds:[],activeJobThreads:{},currentResponse:"",currentThinking:"",events:[],activeJobId:null,lastCompletedJobId:null,lastResponseText:null,lastThreadId:null,lastErrorByJob:{},pendingQuestions:[],incrementalResolutions:[],capabilitiesVersion:0},Va,Lr=(Va=tn==null?void 0:tn.store)!=null?Va:f({},wd),Ua,yi=(Ua=tn==null?void 0:tn.listeners)!=null?Ua:new Set,Ka,rr=(Ka=tn==null?void 0:tn.activeEs)!=null?Ka:null,Xa,us=(Xa=tn==null?void 0:tn.activeBridgeUrl)!=null?Xa:null,nr=null,qa,bi=(qa=tn==null?void 0:tn.connectionGeneration)!=null?qa:0;ar!=null&&ar.data&&Object.defineProperties(ar.data,{store:{get:()=>Lr,configurable:!0},listeners:{get:()=>yi,configurable:!0},activeEs:{get:()=>rr,configurable:!0},activeBridgeUrl:{get:()=>us,configurable:!0},connectionGeneration:{get:()=>bi,configurable:!0},discoveredBridgeUrl:{get:()=>ir,configurable:!0},discoveredBridgeProjectId:{get:()=>Ir,configurable:!0}});var vi=new Set,Rr=new Map,Jo={};function or(e,t){var o;if(!e)return!1;if(vi.has(e)){let r=Rr.get(e);return r||(r=[],Rr.set(e,r)),r.push({type:(o=t.type)!=null?o:"",data:t}),!0}let n=Jo[e];return n!==void 0&&typeof t.seq=="number"&&t.seq<=n}async function Cd(e,t,n){let o=()=>n!==bi;for(let r of t){if(o())return;vi.add(r),Rr.set(r,[])}await Promise.all(t.map(async r=>{var s;try{let i=await gi(e,r);if(o())return;let l=(s=Rr.get(r))!=null?s:[];if(i){if(cn(a=>{let d=y(f({},a.jobResponses),{[r]:i.accumulated.response}),c=y(f({},a.jobThinking),{[r]:i.accumulated.thinking}),u=[...a.events];for(let p of i.events)p.type==="done"||p.type==="error"||u.push({type:p.type,data:p,timestamp:Date.now()});return y(f({},a),{jobResponses:d,jobThinking:c,currentResponse:r===a.activeJobId?i.accumulated.response:a.currentResponse,currentThinking:r===a.activeJobId?i.accumulated.thinking:a.currentThinking,events:u})}),Jo[r]=i.currentSeq,!i.jobActive){let a=i.events.find(d=>d.type==="done"||d.type==="error");a&&ds(a.type,a,r)}for(let a of l)typeof a.data.seq=="number"&&a.data.seq<=i.currentSeq||ds(a.type,a.data,r)}else for(let a of l)ds(a.type,a.data,r)}finally{vi.delete(r),Rr.delete(r)}}))}function ds(e,t,n){var o;if(e==="delta"){let r=t.text||"";cn(s=>y(f({},s),{jobResponses:y(f({},s.jobResponses),{[n]:(s.jobResponses[n]||"")+r}),currentResponse:n===s.activeJobId?s.currentResponse+r:s.currentResponse,events:[...s.events,{type:"delta",data:t,timestamp:Date.now()}]}))}else if(e==="thinking"){let r=t.text||"";cn(s=>y(f({},s),{jobThinking:y(f({},s.jobThinking),{[n]:(s.jobThinking[n]||"")+r}),currentThinking:n===s.activeJobId?s.currentThinking+r:s.currentThinking,events:[...s.events,{type:"thinking",data:t,timestamp:Date.now()}]}))}else if(e==="done")delete Jo[n],cn(r=>{var c;let s=r.activeJobIds.filter(u=>u!==n),i=f({},r.jobResponses),l=f({},r.jobThinking),a=i[n];delete i[n],delete l[n];let d=n===r.activeJobId?s.length>0?s[s.length-1]:null:r.activeJobId;return y(f(y(f({},r),{activeJobIds:s,activeJobId:d,jobResponses:i,jobThinking:l,lastCompletedJobId:n,lastResponseText:a||r.currentResponse||t.responseText||null,lastThreadId:(c=t.threadId)!=null?c:null}),n===r.activeJobId?{currentResponse:d&&i[d]||"",currentThinking:d&&l[d]||""}:{}),{events:[...r.events,{type:"done",data:t,timestamp:Date.now()}]})});else if(e==="error"){delete Jo[n];let r=(o=t.message)!=null?o:"";cn(s=>{let i=s.activeJobIds.filter(a=>a!==n),l=i.length>0?s.status:"error";return y(f({},s),{status:l,activeJobIds:i,lastCompletedJobId:n,lastErrorByJob:r?y(f({},s.lastErrorByJob),{[n]:r}):s.lastErrorByJob,events:[...s.events,{type:"error",data:t,timestamp:Date.now()}]})})}else cn(r=>y(f({},r),{events:[...r.events,{type:e,data:t,timestamp:Date.now()}]}))}var Za,ir=(Za=tn==null?void 0:tn.discoveredBridgeUrl)!=null?Za:null,Qa,Ir=(Qa=tn==null?void 0:tn.discoveredBridgeProjectId)!=null?Qa:null,Mr=null,hi=null;async function Ed(e,t){return ir&&(!t||Ir===t)?ir:(t&&Ir&&Ir!==t&&(ir=null,Ir=null),Mr&&hi===(t!=null?t:null)||(hi=t!=null?t:null,Mr=La(e,t).then(n=>{var o,r,s;return ir=(o=n==null?void 0:n.url)!=null?o:null,Ir=(s=(r=n==null?void 0:n.projectId)!=null?r:t)!=null?s:null,Mr=null,hi=null,ir}).catch(()=>(Mr=null,hi=null,null))),Mr)}function el(){return ir}function ja(){return Lr}function kd(e){return yi.add(e),()=>{yi.delete(e)}}function cn(e){Lr=e(Lr);for(let t of yi)t()}function tl(e){if(rr&&rr.readyState!==EventSource.CLOSED&&us===e)return;rr&&(rr.close(),rr=null),nr&&(clearTimeout(nr),nr=null),us=e;let t=++bi,n=new EventSource(`${e}/events?sourceId=${Si}`);rr=n;let o=()=>t!==bi;n.addEventListener("connected",()=>{o()||_o(e).then(r=>{var p,g;if(o())return;let s=(p=r==null?void 0:r.activeJobs)!=null?p:r!=null&&r.activeJob?[r.activeJob]:[],i=new Set(s.map(v=>v.id)),l=(g=r==null?void 0:r.recentJobs)!=null?g:[],a=new Map(l.map(v=>[v.id,v])),d=s.length>0;cn(v=>{let x=f({},v.lastErrorByJob),w=v.activeJobIds.filter(H=>!i.has(H));for(let H of w){let O=a.get(H);(O==null?void 0:O.status)==="error"&&O.error&&(x[H]=O.error)}let I=v.activeJobIds.filter(H=>i.has(H));for(let H of i)I.includes(H)||I.push(H);let N={};for(let H of s)H.threadId&&(N[H.id]=H.threadId);return y(f({},v),{isConnected:!0,status:d?"streaming":w.length>0||v.status==="disconnected"?"idle":v.status,activeJobId:d?s[s.length-1].id:I.length>0?I[I.length-1]:null,activeJobIds:I,activeJobThreads:N,lastErrorByJob:x,lastCompletedJobId:w.length>0?w[w.length-1]:v.lastCompletedJobId})});let c=Lr.activeJobIds.filter(v=>!i.has(v)),u=[...Array.from(i),...c];u.length>0&&Cd(e,u,t).catch(()=>{})})}),n.addEventListener("job_started",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;if(or(i,s))return;let l=s.threadId;cn(a=>{var d,c,u,p;return y(f({},a),{status:"streaming",activeJobId:i,activeJobIds:a.activeJobIds.includes(i)?a.activeJobIds:[...a.activeJobIds,i],activeJobThreads:l?y(f({},a.activeJobThreads),{[i]:l}):a.activeJobThreads,jobResponses:y(f({},a.jobResponses),{[i]:(d=a.jobResponses[i])!=null?d:""}),jobThinking:y(f({},a.jobThinking),{[i]:(c=a.jobThinking[i])!=null?c:""}),currentResponse:(u=a.jobResponses[i])!=null?u:"",currentThinking:(p=a.jobThinking[i])!=null?p:"",lastResponseText:null,lastThreadId:null,events:[...a.events,{type:"job_started",data:s,timestamp:Date.now()}]})})}),n.addEventListener("delta",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;if(or(i,s))return;let l=s.text||"";cn(a=>y(f({},a),{jobResponses:i?y(f({},a.jobResponses),{[i]:(a.jobResponses[i]||"")+l}):a.jobResponses,currentResponse:!i||i===a.activeJobId?a.currentResponse+l:a.currentResponse,events:[...a.events,{type:"delta",data:s,timestamp:Date.now()}]}))}),n.addEventListener("thinking",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;if(or(i,s))return;let l=s.text||"";cn(a=>y(f({},a),{jobThinking:i?y(f({},a.jobThinking),{[i]:(a.jobThinking[i]||"")+l}):a.jobThinking,currentThinking:!i||i===a.activeJobId?a.currentThinking+l:a.currentThinking,events:[...a.events,{type:"thinking",data:s,timestamp:Date.now()}]}))}),n.addEventListener("tool_use",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;or(i,s)||cn(l=>y(f({},l),{events:[...l.events,{type:"tool_use",data:s,timestamp:Date.now()}]}))}),n.addEventListener("done",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;or(i,s)||(i&&delete Jo[i],cn(l=>{var v;let a=i?l.activeJobIds.filter(x=>x!==i):l.activeJobIds,d=f({},l.jobResponses),c=f({},l.jobThinking),u=f({},l.activeJobThreads),p=i?d[i]:void 0;i&&(delete d[i],delete c[i],delete u[i]);let g=i===l.activeJobId?a.length>0?a[a.length-1]:null:l.activeJobId;return y(f(y(f({},l),{activeJobIds:a,activeJobId:g,jobResponses:d,jobThinking:c,lastCompletedJobId:i!=null?i:l.activeJobId,lastResponseText:p||l.currentResponse||s.responseText||null,lastThreadId:(v=s.threadId)!=null?v:null}),i===l.activeJobId?{currentResponse:g&&d[g]||"",currentThinking:g&&c[g]||""}:{}),{events:[...l.events,{type:"done",data:s,timestamp:Date.now()}]})}))}),n.addEventListener("question",r=>{if(o())return;let s=JSON.parse(r.data),i=s.jobId;or(i,s)||cn(l=>y(f({},l),{pendingQuestions:[...l.pendingQuestions,{jobId:s.jobId,threadId:s.threadId,question:s.question,annotationIds:s.annotationIds,timestamp:Date.now()}],events:[...l.events,{type:"question",data:s,timestamp:Date.now()}]}))}),n.addEventListener("capabilities_changed",()=>{o()||cn(r=>y(f({},r),{capabilitiesVersion:r.capabilitiesVersion+1}))}),n.addEventListener("queue_drained",()=>{if(!o()){for(let r of Object.keys(Jo))delete Jo[r];vi.clear(),Rr.clear(),cn(r=>y(f({},r),{status:r.status==="error"?"error":"idle",activeJobId:null,activeJobIds:[],activeJobThreads:{},currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastErrorByJob:{},incrementalResolutions:[]}))}}),n.addEventListener("error",r=>{var s,i;if(!o()){if(n.readyState===EventSource.CLOSED)cn(l=>y(f({},l),{isConnected:!1,status:"disconnected"})),nr&&(clearTimeout(nr),nr=null),nr=setTimeout(()=>{_o(e).then(l=>{l&&tl(e)})},5e3);else if(r instanceof MessageEvent){let l=JSON.parse(r.data),a=(s=l.jobId)!=null?s:null;if(or(a!=null?a:void 0,l))return;a&&delete Jo[a];let d=(i=l.message)!=null?i:"";cn(c=>{let u=a?c.activeJobIds.filter(g=>g!==a):c.activeJobIds,p=u.length>0?c.status:"error";return y(f({},c),{status:p,activeJobIds:u,lastCompletedJobId:a!=null?a:c.activeJobId,lastErrorByJob:a&&d?y(f({},c.lastErrorByJob),{[a]:d}):c.lastErrorByJob,events:[...c.events,{type:"error",data:l,timestamp:Date.now()}]})})}}}),n.onerror=()=>{o()||n.readyState===EventSource.CLOSED&&cn(r=>y(f({},r),{isConnected:!1,status:"disconnected"}))}}function nl(e="http://localhost:1111",t=!0,n){let o=Sd(kd,ja,ja);xd(()=>{t&&Ed(e,n).then(i=>{i&&_o(i).then(l=>{l&&tl(i)})})},[e,t,n]);let r=Wa(()=>{cn(()=>y(f({},Lr),{events:[],currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastResponseText:null,lastThreadId:null,lastErrorByJob:{},incrementalResolutions:[]}))},[]),s=Wa(i=>{cn(l=>y(f({},l),{pendingQuestions:l.pendingQuestions.filter(a=>a.threadId!==i)}))},[]);return y(f({},o),{clearEvents:r,dismissQuestion:s})}import{useEffect as Td,useReducer as Md}from"react";var Id={isAnnotating:!1,activeTool:"inspector",activeColor:"oklch(0.628 0.258 29)",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,inspectedElement:null,styleModifications:[],spacingTokenChanges:[],spacingTokenMods:[]};function Ci(){return Math.random().toString(36).substring(2,9)}function ol(e){return e.status?e:e.captured?y(f({},e),{status:"in_flight"}):y(f({},e),{status:"pending"})}function _n(e){return y(f({},e),{undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}],redoStack:[]})}function Rd(e,t){return y(f({},e),{isAnnotating:t})}function Ld(e,t){return y(f({},e),{activeTool:t,inspectedElement:null})}function Ad(e,t){return y(f({},e),{activeColor:t})}function Pd(e,t){return y(f({},e),{strokeWidth:t})}function Od(e,t){return y(f({},e),{currentPath:[t]})}function Bd(e,t){return y(f({},e),{currentPath:[...e.currentPath,t]})}function Dd(e){return y(f({},e),{currentPath:[]})}function _d(e,t){if(e.currentPath.length<2&&e.activeTool!=="text")return y(f({},e),{currentPath:[]});let n={id:Ci(),type:e.activeTool,points:e.currentPath,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",pathname:typeof window!="undefined"?window.location.pathname:"/",groupId:t==null?void 0:t.groupId,elements:t==null?void 0:t.elements},o=_n(e);return y(f({},o),{annotations:[...e.annotations,n],currentPath:[]})}function Hd(e,t){var r;let n=f({id:(r=t.id)!=null?r:Ci(),type:"text",points:[t.point],text:t.text,fontSize:t.fontSize||12,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",pathname:typeof window!="undefined"?window.location.pathname:"/",groupId:t.groupId,linkedSelector:t.linkedSelector,linkedAnchor:t.linkedAnchor,elements:t.elements},t.imageCount?{imageCount:t.imageCount}:{}),o=t.groupId?e:_n(e);return y(f({},o),{annotations:[...e.annotations,n]})}function Nd(e,t){let n=_n(e);return y(f({},n),{annotations:e.annotations.map(o=>o.id===t.id?f(y(f({},o),{text:t.text}),t.imageCount!=null?{imageCount:t.imageCount}:{}):o)})}function zd(e,t){return y(f({},e),{annotations:e.annotations.map(n=>n.id===t.id?y(f({},n),{fontSize:Math.max(12,Math.min(72,t.fontSize))}):n)})}function Fd(e,t){let n=_n(e),o=e.annotations.find(s=>s.id===t.id),r=o==null?void 0:o.groupId;return y(f({},n),{annotations:e.annotations.filter(s=>s.id!==t.id&&!(r&&s.groupId===r))})}function $d(e,t){let n=t.saveUndo?_n(e):e,o=e.annotations.find(s=>s.id===t.id),r=o==null?void 0:o.groupId;return y(f({},n),{annotations:e.annotations.map(s=>{if(!(s.id===t.id||r&&s.groupId===r))return s;let l=t.delta.x,a=t.delta.y;return y(f({},s),{points:s.points.map(d=>({x:d.x+l,y:d.y+a}))})})})}function Wd(e,t){let n=t.saveUndo?_n(e):e,o=e.annotations.find(i=>i.id===t.id);if(!o||o.type==="text"||o.points.length<2)return e;let r=0,s=0;if(o.type==="rectangle"&&o.groupId){let i=t.points,l=Math.min(i[0].x,i[1].x),a=Math.max(i[0].y,i[1].y),d=o.points[0],c=o.points[o.points.length-1],u=Math.min(d.x,c.x),p=Math.max(d.y,c.y);r=l-u,s=a-p}return y(f({},n),{annotations:e.annotations.map(i=>i.id===t.id?y(f({},i),{points:t.points}):o.groupId&&i.groupId===o.groupId&&i.type==="text"?y(f({},i),{points:i.points.map(l=>({x:l.x+r,y:l.y+s}))}):i)})}function jd(e,t){let n=_n(e);return y(f({},n),{annotations:[...e.annotations,...t.annotations.map(ol)]})}function Gd(e,t){let n=new Set,o=[];for(let r of t.annotations)n.has(r.id)||(n.add(r.id),o.push(ol(r)));return y(f({},e),{annotations:o})}function Yd(e){if(e.undoStack.length===0)return e;let t=e.undoStack[e.undoStack.length-1];return y(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function Jd(e){if(e.redoStack.length===0)return e;let t=e.redoStack[e.redoStack.length-1];return y(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function Vd(e,t){let{id:n,addToSelection:o}=t;if(n===null)return y(f({},e),{selectedAnnotationIds:[],lastSelectedId:null});if(o)if(e.selectedAnnotationIds.includes(n)){let s=e.selectedAnnotationIds.filter(i=>i!==n);return y(f({},e),{selectedAnnotationIds:s,lastSelectedId:s.length>0?s[s.length-1]:null})}else return y(f({},e),{selectedAnnotationIds:[...e.selectedAnnotationIds,n],lastSelectedId:n});return y(f({},e),{selectedAnnotationIds:[n],lastSelectedId:n})}function Ud(e,t){let n=new Set;for(let o of e.selectedAnnotationIds){let r=e.annotations.find(s=>s.id===o);r!=null&&r.groupId&&n.add(r.groupId)}return y(f({},e),{annotations:e.annotations.map(o=>{let r=e.selectedAnnotationIds.includes(o.id),s=o.groupId&&n.has(o.groupId);return!r&&!s?o:y(f({},o),{color:t.color})})})}function Kd(e){return y(f({},e),{annotations:e.annotations.map(t=>y(f({},t),{captured:!0,status:t.status==="pending"||!t.status?"in_flight":t.status})),styleModifications:e.styleModifications.map(t=>y(f({},t),{captured:!0})),spacingTokenChanges:e.spacingTokenChanges.map(t=>y(f({},t),{captured:!0}))})}function Xd(e){return y(f({},e),{annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,spacingTokenChanges:[],spacingTokenMods:[]})}function qd(e,t){return y(f({},e),{inspectedElement:t})}function Zd(e,t){let{selector:n,element:o,property:r,original:s,modified:i}=t,l=e.styleModifications.findIndex(a=>a.selector===n);if(s===i&&l<0)return e;if(l>=0){let a=e.styleModifications[l];if(a.captured){let g=_n(e),v=g.styleModifications.map((x,w)=>w===l?y(f({},x),{changes:[{property:r,original:s,modified:i}],captured:!1}):x);return y(f({},g),{styleModifications:v})}let d=a.changes.findIndex(g=>g.property===r),c,u=e;if(d>=0){let g=a.changes[d];i===g.original?c=a.changes.filter((v,x)=>x!==d):c=a.changes.map((v,x)=>x===d?y(f({},v),{modified:i}):v)}else{if(s===i)return e;u=_n(e),c=[...a.changes,{property:r,original:s,modified:i}]}if(c.length===0)return y(f({},u),{styleModifications:u.styleModifications.filter((g,v)=>v!==l)});let p=u.styleModifications.map((g,v)=>v===l?y(f({},g),{changes:c}):g);return y(f({},u),{styleModifications:p})}else{let a=_n(e),d={selector:n,element:o,changes:[{property:r,original:s,modified:i}]};return y(f({},a),{styleModifications:[...a.styleModifications,d]})}}function Qd(e,t){let{selector:n,durableSelector:o,element:r,changes:s}=t,i=s.filter(d=>d.original!==d.modified);if(i.length===0)return e;let l=_n(e),a=l.styleModifications.findIndex(d=>d.selector===n);if(a>=0){let d=l.styleModifications[a],c=d.captured?[]:[...d.changes];for(let u of i){let p=c.findIndex(g=>g.property===u.property);p>=0?u.modified===c[p].original?c=c.filter((g,v)=>v!==p):c=c.map((g,v)=>v===p?y(f({},g),{modified:u.modified}):g):c.push(u)}return c.length===0?y(f({},l),{styleModifications:l.styleModifications.filter((u,p)=>p!==a)}):y(f({},l),{styleModifications:l.styleModifications.map((u,p)=>p===a?y(f({},u),{changes:c,captured:!1}):u)})}else return y(f({},l),{styleModifications:[...l.styleModifications,{selector:n,durableSelector:o,element:r,changes:i}]})}function eu(e,t){let{selector:n,property:o}=t,r=_n(e),s=r.styleModifications.map(i=>i.selector!==n?i:y(f({},i),{changes:i.changes.filter(l=>l.property!==o)})).filter(i=>i.changes.length>0);return y(f({},r),{styleModifications:s})}function tu(e){if(e.styleModifications.length===0)return y(f({},e),{inspectedElement:null});let t=_n(e);return y(f({},t),{styleModifications:[],inspectedElement:null})}function nu(e,t){return y(f({},e),{styleModifications:t})}function ou(e,t){let{updates:n}=t,o=new Map(n.map(r=>[r.id,r]));return y(f({},e),{annotations:e.annotations.map(r=>{let s=o.get(r.id);return s?f(y(f({},r),{points:[s.point,...r.points.slice(1)]}),s.linkedAnchor?{linkedAnchor:s.linkedAnchor}:{}):r})})}function ru(e,t){let n=new Set(t.ids);return y(f({},e),{annotations:e.annotations.map(o=>n.has(o.id)?y(f({},o),{status:t.status}):o)})}function iu(e,t){let n=new Set(t.ids),o=new Set;for(let r of e.annotations)n.has(r.id)&&r.groupId&&o.add(r.groupId);return y(f({},e),{annotations:e.annotations.map(r=>n.has(r.id)||r.groupId&&o.has(r.groupId)?y(f({},r),{threadId:t.threadId}):r)})}function su(e,t){let n=new Set(t.ids),o=new Set;for(let r of e.annotations)n.has(r.id)&&r.groupId&&o.add(r.groupId);return y(f({},e),{annotations:e.annotations.map(r=>n.has(r.id)||r.groupId&&o.has(r.groupId)?y(f({},r),{status:"waiting_input",question:t.question,threadId:t.threadId}):r)})}function au(e,t){let n=new Map(t.resolutions.map(r=>[r.annotationId,r])),o=new Map;for(let r of e.annotations){let s=n.get(r.id);s&&r.groupId&&o.set(r.groupId,s)}return y(f({},e),{annotations:e.annotations.map(r=>{var i,l,a;let s=n.get(r.id)||(r.groupId?o.get(r.groupId):void 0);return s?y(f({},r),{status:s.status,resolutionSummary:s.summary,scope:(l=(i=s.finalScope)!=null?i:s.inferredScope)!=null?l:null,replyCount:((a=r.replyCount)!=null?a:0)+1,question:void 0,threadId:r.threadId||t.threadId}):r})})}function lu(e,t){let{linkedSelectors:n,styleSelectors:o}=t,r=new Set(n),s=new Set(o),i=new Set,l=new Set;for(let p of e.annotations)p.linkedSelector&&r.has(p.linkedSelector)&&(i.add(p.id),p.groupId&&l.add(p.groupId));for(let p of e.annotations)p.groupId&&l.has(p.groupId)&&i.add(p.id);let a=e.annotations.filter(p=>!i.has(p.id)),d=e.styleModifications.filter(p=>!s.has(p.selector));if(a.length===e.annotations.length&&d.length===e.styleModifications.length)return e;let c=e.selectedAnnotationIds.filter(p=>!i.has(p)),u=e.inspectedElement&&s.has(e.inspectedElement.info.selector)?null:e.inspectedElement;return y(f({},e),{annotations:a,styleModifications:d,selectedAnnotationIds:c,lastSelectedId:c.length>0?c[c.length-1]:null,inspectedElement:u})}function cu(e,t){let n=e.spacingTokenChanges.findIndex(o=>o.tokenPath===t.tokenPath);return n>=0?y(f({},e),{spacingTokenChanges:e.spacingTokenChanges.map((o,r)=>r===n?t:o)}):y(f({},e),{spacingTokenChanges:[...e.spacingTokenChanges,t]})}function du(e,t){return y(f({},e),{spacingTokenChanges:t})}function uu(e,t){let n=_n(e),o=e.spacingTokenMods.findIndex(s=>s.tokenPath===t.tokenPath),r;if(o>=0){let s=e.spacingTokenMods[o],i=y(f({},t),{originalValue:s.originalValue,originalPx:s.originalPx});r=e.spacingTokenMods.map((l,a)=>a===o?i:l)}else r=[...e.spacingTokenMods,t];return y(f({},n),{spacingTokenMods:r})}function pu(e,t){let n=_n(e),o=e.spacingTokenMods.findIndex(a=>a.tokenPath===t.tokenPath),r=o>=0?e.spacingTokenMods[o].originalValue:t.originalValue,s=o>=0?e.spacingTokenMods[o].originalPx:parseFloat(t.originalValue)||0,i={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:o>=0?e.spacingTokenMods[o].targets:[],originalPx:s,currentPx:0},l;return o>=0?l=e.spacingTokenMods.map((a,d)=>d===o?i:a):l=[...e.spacingTokenMods,i],y(f({},n),{spacingTokenMods:l})}var fu={SET_ANNOTATING:Rd,SET_TOOL:Ld,SET_COLOR:Ad,SET_STROKE_WIDTH:Pd,START_PATH:Od,CONTINUE_PATH:Bd,CANCEL_PATH:Dd,FINISH_PATH:_d,ADD_TEXT:Hd,UPDATE_TEXT:Nd,UPDATE_TEXT_SIZE:zd,DELETE_ANNOTATION:Fd,MOVE_ANNOTATION:$d,RESIZE_ANNOTATION:Wd,PASTE_ANNOTATIONS:jd,RESTORE_ANNOTATIONS:Gd,UNDO:Yd,REDO:Jd,SELECT_ANNOTATION:Vd,UPDATE_ANNOTATION_COLOR:Ud,MARK_CAPTURED:Kd,CLEAR:Xd,SELECT_ELEMENT:qd,MODIFY_STYLE:Zd,MODIFY_STYLES_BATCH:Qd,CLEAR_STYLE:eu,CLEAR_ALL_STYLES:tu,RESTORE_STYLE_MODIFICATIONS:nu,UPDATE_LINKED_POSITIONS:ou,CLEANUP_ORPHANED:lu,SET_ANNOTATION_STATUS:ru,SET_ANNOTATION_THREAD:iu,SET_ANNOTATION_QUESTION:su,APPLY_RESOLUTIONS:au,ADD_SPACING_TOKEN_CHANGE:cu,RESTORE_SPACING_TOKEN_CHANGES:du,MODIFY_SPACING_TOKEN:uu,DELETE_SPACING_TOKEN:pu};function gu(e,t){let n=fu[t.type];return n?n(e,t.payload):e}function rl(){let[e,t]=Md(gu,Id);return Td(()=>{let n=o=>{(o.metaKey||o.ctrlKey)&&o.key==="z"&&(o.preventDefault(),o.shiftKey?t({type:"REDO"}):t({type:"UNDO"}))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}import{useSyncExternalStore as mu}from"react";if(typeof window!="undefined"&&!window.__popmeltPathPatch){window.__popmeltPathPatch=!0;for(let e of["pushState","replaceState"]){let t=History.prototype[e];History.prototype[e]=function(...n){let o=window.location.pathname;t.apply(this,n),window.dispatchEvent(new CustomEvent("popmelt:locationchange",{detail:{prevPath:o}}))}}}function hu(e){return window.addEventListener("popstate",e),window.addEventListener("popmelt:locationchange",e),()=>{window.removeEventListener("popstate",e),window.removeEventListener("popmelt:locationchange",e)}}function yu(){return window.location.pathname}function Ar(){return mu(hu,yu,()=>"/")}var il="popmelt-toolbar-snap-position";function lr(e){return e.startsWith("top-")}function cr(e){return e.endsWith("-right")}function Zr(e){return e.endsWith("-center")}function sl(){try{let e=localStorage.getItem(il);if(e&&bu(e))return e}catch(e){}return"bottom-right"}function al(e){try{localStorage.setItem(il,e)}catch(t){}}function bu(e){return["bottom-right","bottom-center","bottom-left","top-right","top-center","top-left"].includes(e)}function ll(e,t,n){let o=lr(e)?16:n-16-54;return Zr(e)?{position:"fixed",top:o,left:t/2,transform:"translateX(-50%)"}:cr(e)?{position:"fixed",top:o,right:16,left:"auto"}:{position:"fixed",top:o,left:16,right:"auto"}}function cl(e,t,n){let r=lr(e)?{top:82}:{bottom:82},s;return Zr(e)?s={left:t/2,transform:"translateX(-50%)"}:cr(e)?s={right:16}:s={left:16},f(f({position:"fixed"},r),s)}function dl(e,t,n){let o=lr(e),r=o?{top:78}:{bottom:78},s,i;return Zr(e)?(s={left:"50%",transform:"translateX(-50%)"},i="center"):cr(e)?(s={right:16},i="flex-end"):(s={left:16},i="flex-start"),y(f(f({position:"fixed"},r),s),{zIndex:9999,display:"flex",flexDirection:"column",alignItems:i})}function Ei(e){let t=lr(e),n=cr(e)||Zr(e);return{position:"fixed",top:t&&n?82:16,right:16,bottom:!t&&n?82:16}}function ul(e,t,n){let r=lr(e),s,i;cr(e)||Zr(e)?(s=t-16,i=s-326):(i=16,s=i+326);let l=r?82:n-16-54-12;return{left:i,right:s,y:l}}var pl=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"];import{domToCanvas as vu}from"modern-screenshot";function ps(e){let t=document.createElement("canvas").getContext("2d");return t?(t.fillStyle=e,t.fillStyle):"#888888"}function fs(e,t=[],n,o){let r=new Map,s=[];for(let l of e)if(l.groupId){let a=r.get(l.groupId)||[];a.push(l),r.set(l.groupId,a)}else s.push(l);let i=[];for(let[l,a]of r){let d=a.find(u=>u.type!=="text"),c=a.find(u=>u.type==="text");if(d){let u=d.linkedSelector||(c==null?void 0:c.linkedSelector),p=(c==null?void 0:c.imageCount)||d.imageCount,g=d.pathname||(c==null?void 0:c.pathname);i.push(f(y(f(f({id:d.id,type:d.type,instruction:c==null?void 0:c.text},u?{linkedSelector:u}:{}),g?{pathname:g}:{}),{elements:d.elements||[]}),p?{imageCount:p}:{}))}}for(let l of s)i.push(f(y(f(f({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0},l.linkedSelector?{linkedSelector:l.linkedSelector}:{}),l.pathname?{pathname:l.pathname}:{}),{elements:l.elements||[]}),l.imageCount?{imageCount:l.imageCount}:{}));return f(f({timestamp:new Date().toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:i,styleModifications:t},n?{inspectedElement:n}:{}),o&&o.length>0?{spacingTokenChanges:o}:{})}function xu(e){if(!e.points||e.points.length===0)return null;let t=e.points.map(o=>o.x),n=e.points.map(o=>o.y);return{minX:Math.min(...t),minY:Math.min(...n),maxX:Math.max(...t),maxY:Math.max(...n)}}function Su(e,t){if(e.length===0)return[];let n=e.map(c=>({annotation:c,bounds:xu(c)})).filter(c=>c.bounds!==null);if(n.length===0)return[];n.sort((c,u)=>c.bounds.minY-u.bounds.minY);let o=Math.min(...n.map(c=>c.bounds.minY)),r=Math.max(...n.map(c=>c.bounds.maxY));if(r-o<=t){let c=(o+r)/2,u=Math.max(0,c-t/2);return[{top:u,bottom:u+t,annotations:e}]}let s=[],i=50,l=Math.max(0,o-i),a=[],d=l;for(let{annotation:c,bounds:u}of n){let p=u.maxY+i;if(p-l<=t)a.push(c),d=Math.max(d,p);else{if(a.length>0){let g=(l+d)/2,v=Math.max(0,g-t/2);s.push({top:v,bottom:v+t,annotations:a})}l=Math.max(0,u.minY-i),a=[c],d=u.maxY+i}}if(a.length>0){let c=(l+d)/2,u=Math.max(0,c-t/2);s.push({top:u,bottom:u+t,annotations:a})}return s}function wu(e){let t=new Map;for(let n of e)if(n.linkedSelector)try{let o=document.querySelector(n.linkedSelector);if(o){let r=o.getBoundingClientRect();t.set(n.id,{x:r.left+window.scrollX,y:r.top+window.scrollY,width:r.width,height:r.height})}}catch(o){}return t}function Cu(e,t,n,o,r){if(e.save(),e.scale(o,o),r)for(let s of t){let i=r.get(s.id);if(!i)continue;let l=i.y-n;e.fillStyle=s.color,e.globalAlpha=.05,e.fillRect(i.x,l,i.width,i.height),e.globalAlpha=1,e.strokeStyle=s.color,e.lineWidth=1,e.setLineDash([2,4]),e.strokeRect(i.x,l,i.width,i.height),e.setLineDash([])}for(let s of t){let i=s.points.map(l=>({x:l.x,y:l.y-n}));switch(e.strokeStyle=s.color,e.fillStyle=s.color,e.lineWidth=s.strokeWidth,e.lineCap="round",e.lineJoin="round",s.type){case"freehand":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let l=1;l<i.length;l++)e.lineTo(i[l].x,i[l].y);e.stroke();break;case"line":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[i.length-1].x,i[i.length-1].y),e.stroke();break;case"rectangle":{if(i.length<2)break;let l=i[0],a=i[i.length-1],d=Math.min(l.x,a.x),c=Math.min(l.y,a.y),u=Math.abs(a.x-l.x),p=Math.abs(a.y-l.y);e.strokeRect(d,c,u,p);break}case"circle":{if(i.length<2)break;let l=i[0],a=i[i.length-1],d=(l.x+a.x)/2,c=(l.y+a.y)/2,u=Math.abs(a.x-l.x)/2,p=Math.abs(a.y-l.y)/2;e.beginPath(),e.ellipse(d,c,u,p,0,0,Math.PI*2),e.stroke();break}case"text":{if(!s.text||i.length<1)break;let l=i[0],a=s.fontSize||16;e.font=`${a}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,e.fillStyle=s.color;let c=(s.imageCount&&s.imageCount>0?`[${s.imageCount} image${s.imageCount>1?"s":""}] ${s.text}`:s.text).split(`
3
- `),u=a*1.2,p=4,g=0;for(let v of c)g=Math.max(g,e.measureText(v).width);e.fillRect(l.x-p,l.y-p,g+p*2,c.length*u+p*2),e.fillStyle="#ffffff",c.forEach((v,x)=>{e.fillText(v,l.x,l.y+a+x*u)});break}}}e.restore()}async function Pr(e,t,n=[],o){var r;try{let s=(r=o==null?void 0:o.dpr)!=null?r:window.devicePixelRatio||1,i=window.innerWidth,l=window.innerHeight,a=n.filter(p=>{var g;return((g=p.status)!=null?g:"pending")==="pending"});console.log("[Screenshot] Starting capture with",a.length,"active annotations (filtered",n.length-a.length,"captured)");let d=wu(a),c=Su(a,l);if(c.length===0){let p=await fl(e,[],window.scrollY,i,l,s,d);return p?[p]:[]}let u=[];for(let p=0;p<c.length;p++){let g=c[p],v=await fl(e,g.annotations,g.top,i,l,s,d);v?u.push(v):console.warn(`[Screenshot] Region ${p+1} failed to capture`)}return console.log("[Screenshot] Capture complete"),u}catch(s){return console.error("[Screenshot] Capture failed:",s),[]}}async function fl(e,t,n,o,r,s,i){try{let l=getComputedStyle(document.documentElement).backgroundColor,d=await vu(e,{filter:p=>!(p instanceof HTMLElement&&(p.id==="devtools-canvas"||p.id==="devtools-toolbar"||p.id==="devtools-scrim"||p.dataset.devtools!==void 0)),scale:s,backgroundColor:l&&l!=="rgba(0, 0, 0, 0)"&&l!=="transparent"?l:"#ffffff",width:o,height:r,style:{transform:`translate(${-window.scrollX}px, ${-n}px)`}}),c=document.createElement("canvas");c.width=o*s,c.height=r*s;let u=c.getContext("2d");return u?(u.drawImage(d,0,0,o*s,r*s,0,0,o*s,r*s),Cu(u,t,n,s,i),new Promise(p=>{c.toBlob(g=>p(g),"image/webp",.8)})):null}catch(l){return console.error("Region capture failed:",l),null}}async function Qr(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=await Promise.all(e.map(l=>new Promise((a,d)=>{let c=new Image;c.onload=()=>a(c),c.onerror=d,c.src=URL.createObjectURL(l)}))),n=t[0].width,o=t.reduce((l,a)=>l+a.height,0),r=document.createElement("canvas");r.width=n,r.height=o;let s=r.getContext("2d");if(!s)return null;let i=0;for(let l of t)s.drawImage(l,0,i),i+=l.height,URL.revokeObjectURL(l.src);return new Promise(l=>{r.toBlob(a=>l(a),"image/webp",.8)})}async function gl(e,t,n){try{let o=Array.isArray(e)?e:[e];if(o.length===0)return!1;let r=await Qr(o);if(!r)return!1;let s=r;if(r.type!=="image/png"){let d=new Image,c=URL.createObjectURL(r);await new Promise(p=>{d.onload=()=>p(),d.src=c}),URL.revokeObjectURL(c);let u=document.createElement("canvas");u.width=d.naturalWidth,u.height=d.naturalHeight,u.getContext("2d").drawImage(d,0,0),s=await new Promise(p=>u.toBlob(g=>p(g),"image/png"))}let i={"image/png":s},l=t&&t.length>0,a=n&&n.length>0;if(l||a){let d=t?t.filter(c=>{var u;return((u=c.status)!=null?u:"pending")==="pending"}):[];if(d.length>0||a){let c=fs(d,n||[]),u=new Blob([JSON.stringify(c,null,2)],{type:"text/plain"});i["text/plain"]=u}}return await navigator.clipboard.write([new ClipboardItem(i)]),!0}catch(o){return console.warn("Clipboard write failed:",o),!1}}var ki="0.7.1";import{useCallback as un,useEffect as kn,useMemo as Vi,useRef as Qt,useState as bt}from"react";import{useCallback as Dr,useRef as ku}from"react";function gs(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!r||!s)return;let i=(r.x+s.x)/2,l=(r.y+s.y)/2,a=Math.abs(s.x-r.x)/2,d=Math.abs(s.y-r.y)/2;e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.ellipse(i,l,a,d,0,0,Math.PI*2),e.stroke()}function ms(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!(!r||!s)){e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.moveTo(r.x,r.y);for(let i=1;i<t.length-1;i++){let l=t[i],a=t[i+1];if(!l||!a)continue;let d=(l.x+a.x)/2,c=(l.y+a.y)/2;e.quadraticCurveTo(l.x,l.y,d,c)}e.lineTo(s.x,s.y),e.stroke()}}function hs(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];!r||!s||(e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.moveTo(r.x,r.y),e.lineTo(s.x,s.y),e.stroke())}function ys(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!r||!s)return;let i=Math.min(r.x,s.x),l=Math.min(r.y,s.y),a=Math.abs(s.x-r.x),d=Math.abs(s.y-r.y);e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.strokeRect(i,l,a,d)}var Zt='"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';function Eu(e,t,n){if(!t||e.measureText(t).width<=n)return[t];let o=t.split(/\s+/),r=[],s="";for(let i of o){let l=s?s+" "+i:i;s&&e.measureText(l).width>n?(r.push(s),s=i):s=l}return s&&r.push(s),r.length>0?r:[t]}function Or(e){let t=window.innerWidth-e-16;return Math.max(60,Math.min(400,t))}function ml(e,t,n){let o=[];for(let r of t)o.push(...Eu(e,r,n));return o}function Br(e,t,n){if(e.measureText(t).width<=n)return t;let o="\u2026";for(let r=t.length-1;r>0;r--){let s=t.slice(0,r)+o;if(e.measureText(s).width<=n)return s}return o}function hl(e,t,n,o,r=12,s,i){if(!n)return;let l=r*1.4,a=n.replace(/\n/g," "),d=s!==void 0?s+". "+a:a;e.font=`${r}px ${Zt}`,e.textBaseline="middle";let c=i!==void 0?Math.min(400,Math.max(60,window.innerWidth-i-16)):400,u=Br(e,d,c),p=e.measureText(u).width;e.fillStyle=o,e.fillRect(t.x-4,t.y-4,p+8,l+8),e.fillStyle="#ffffff",e.fillText(u,t.x,t.y+l/2)}var yl=11,bs=4,Tu=`600 ${yl}px system-ui, -apple-system, sans-serif`;function vs(e,t,n){return e.map(o=>({x:o.x-t,y:o.y-n}))}function Mu(e,t,n,o,r,s){let i=String(o);e.font=Tu;let a=e.measureText(i).width+bs*2,d=yl+bs*2,c=t-a/2,u=n+s/2+2;e.fillStyle=r,e.fillRect(c,u,a,d),e.fillStyle="#ffffff",e.textBaseline="middle",e.fillText(i,c+bs,u+d/2)}function Iu(e,t){if(e.points.length<2&&e.type!=="text")return null;switch(e.type){case"rectangle":case"freehand":{let n,o;if(e.type==="freehand")n=Math.min(...e.points.map(r=>r.x)),o=Math.max(...e.points.map(r=>r.y));else{let r=e.points[0],s=e.points[e.points.length-1];n=Math.min(r.x,s.x),o=Math.max(r.y,s.y)}return{x:n,y:o}}case"circle":{let n=e.points[0],o=e.points[e.points.length-1],r=Math.min(n.x,o.x),s=(Math.min(n.y,o.y)+Math.max(n.y,o.y))/2;return{x:r,y:s}}case"line":{let n=e.points[0],o=e.points[e.points.length-1],r=n.y>o.y?n:o;return{x:r.x,y:r.y}}default:return null}}function bl(){let e=ku(null),t=Dr(()=>{let l=e.current;if(!l)return;let a=l.getContext("2d");a&&a.clearRect(0,0,l.width,l.height)},[]),n=Dr((l,a,d)=>{var v;let c=e.current;if(!c)return;let u=c.getContext("2d");if(!u)return;let g=((v=l.status)!=null?v:l.captured?"in_flight":"pending")==="pending"||d?l.color:"#999999";switch(l.type){case"freehand":ms(u,l.points,g,l.strokeWidth);break;case"line":hs(u,l.points,g,l.strokeWidth);break;case"rectangle":ys(u,l.points,g,l.strokeWidth);break;case"circle":gs(u,l.points,g,l.strokeWidth);break;case"text":l.text&&l.points[0]&&hl(u,l.points[0],l.text,g,l.fontSize,a,l.points[0].x);break}},[]),o=Dr((l,a,d,c)=>{let u=e.current;if(!u||l.length<2)return;let p=u.getContext("2d");if(p)switch(a){case"freehand":ms(p,l,d,c);break;case"line":hs(p,l,d,c);break;case"rectangle":ys(p,l,d,c);break;case"circle":gs(p,l,d,c);break}},[]),r=Dr((l,a)=>{let d=e.current;if(!d||l.points.length<2)return;let c=d.getContext("2d");if(c){if(c.fillStyle="#ffffff",c.strokeStyle=l.color,c.lineWidth=1.5,l.type==="line"){let u=l.points[0],p=l.points[l.points.length-1];[u,p].forEach(g=>{c.beginPath(),c.arc(g.x,g.y,a/2,0,Math.PI*2),c.fill(),c.stroke()});return}if(l.type==="circle"){let u=l.points[0],p=l.points[l.points.length-1],g=Math.min(u.x,p.x),v=Math.max(u.x,p.x),x=Math.min(u.y,p.y),w=Math.max(u.y,p.y),I=(g+v)/2,N=(x+w)/2;[{x:I,y:x},{x:I,y:w},{x:g,y:N},{x:v,y:N}].forEach(O=>{c.beginPath(),c.rect(O.x-a/2,O.y-a/2,a,a),c.fill(),c.stroke()});return}if(l.type==="rectangle"||l.type==="freehand"){let u,p,g,v;if(l.type==="freehand")u=Math.min(...l.points.map(w=>w.x)),p=Math.max(...l.points.map(w=>w.x)),g=Math.min(...l.points.map(w=>w.y)),v=Math.max(...l.points.map(w=>w.y));else{let w=l.points[0],I=l.points[l.points.length-1];u=Math.min(w.x,I.x),p=Math.max(w.x,I.x),g=Math.min(w.y,I.y),v=Math.max(w.y,I.y)}[{x:u,y:g},{x:p,y:g},{x:u,y:v},{x:p,y:v}].forEach(w=>{c.beginPath(),c.rect(w.x-a/2,w.y-a/2,a,a),c.fill(),c.stroke()})}}},[]),s=Dr((l,a,d,c,u,p,g,v=0,x=0,w,I)=>{var N;if(t(),l.forEach(H=>{var re;let O=y(f({},H),{points:vs(H.points,v,x)}),L=w==null?void 0:w.get(H.id),Y=(re=I==null?void 0:I.has(H.id))!=null?re:!1;n(O,L,Y)}),a.length>0){let H=vs(a,v,x);o(H,d,c,u)}if(p&&p.length>0&&g){let H=e.current,O=H==null?void 0:H.getContext("2d");for(let L of p){let Y=l.find(re=>re.id===L);if(Y){let re=y(f({},Y),{points:vs(Y.points,v,x)});if(r(re,g),O&&Y.type!=="text"&&w&&!(Y.groupId&&l.some(_=>_.groupId===Y.groupId&&_.type==="text"))){let _=w.get(Y.id);if(_!==void 0){let B=Iu(re,g);if(B){let A=((N=Y.status)!=null?N:Y.captured?"in_flight":"pending")==="pending"?Y.color:"#999999";Mu(O,B.x,B.y,_,A,g)}}}}}}},[t,n,o,r]),i=Dr(()=>{let l=e.current;if(!l)return;let a=window.devicePixelRatio||1;l.width=window.innerWidth*a,l.height=window.innerHeight*a;let d=l.getContext("2d");d&&d.scale(a,a)},[]);return{canvasRef:e,clearCanvas:t,drawAnnotation:n,drawCurrentPath:o,redrawAll:s,resizeCanvas:i}}import{useEffect as Ru,useRef as Lu}from"react";function vl(){let e=Lu({shift:!1,cmd:!1});return Ru(()=>{let t=r=>{r.key==="Shift"&&(e.current.shift=!0),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!0)},n=r=>{r.key==="Shift"&&(e.current.shift=!1),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!1)},o=()=>{e.current={shift:!1,cmd:!1}};return window.addEventListener("keydown",t,!0),window.addEventListener("keyup",n,!0),window.addEventListener("blur",o),()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("keyup",n,!0),window.removeEventListener("blur",o)}},[]),e}import{useEffect as Au}from"react";function xl(e,t,n,o,r){Au(()=>{let s=i=>{if(e){if(e.linkedSelector)return;i.preventDefault(),i.stopPropagation();let a=i.deltaY>0?-2:2;t(d=>d?y(f({},d),{fontSize:Math.max(12,Math.min(72,d.fontSize+a))}):null);return}if(!n)return;i.preventDefault();let l=o.find(a=>a.id===n);if(l&&l.type==="text"&&!l.linkedSelector){let a=l.fontSize||12,d=i.deltaY>0?-2:2;r({type:"UPDATE_TEXT_SIZE",payload:{id:n,fontSize:a+d}})}};return window.addEventListener("wheel",s,{passive:!1}),()=>{window.removeEventListener("wheel",s)}},[n,e,o,r,t])}import{useCallback as Dl,useEffect as Hi,useRef as _l,useState as oi}from"react";function Ti(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return null;let n=e[t],o=[];for(;n;){let r=n.type,s=(r==null?void 0:r.displayName)||(r==null?void 0:r.name);s&&typeof s=="string"&&/^[A-Z]/.test(s)&&!s.startsWith("_")&&s!=="Fragment"&&o.unshift(s),n=n.return}return o.length>0?{name:o[o.length-1],path:o}:null}function xs(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return[];let n=e[t],o=[];for(;n;){let r=n.type,s=typeof r=="function"||typeof r=="object"?(r==null?void 0:r.displayName)||(r==null?void 0:r.name):null;s&&typeof s=="string"&&/^[A-Z]/.test(s)&&!s.startsWith("_")&&s!=="Fragment"&&o.push({name:s,fiber:n}),n=n.return}return o.reverse(),o}function Mi(e){let t=e,n=new Set;for(;t&&!n.has(t);){if(n.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}function Sl(e){if(e.id)return`#${e.id}`;let t=e.tagName.toLowerCase(),n=Array.from(e.classList).slice(0,3).join(".");return n?`${t}.${n}`:t}function Jn(e){if(e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],n=e;for(;n&&n!==document.documentElement;){let o=n.tagName.toLowerCase();if(n.id&&!n.id.startsWith("radix-")&&!n.id.startsWith(":")){t.unshift(`#${CSS.escape(n.id)}`);break}let r=Array.from(n.classList).filter(i=>!i.startsWith("_")&&i.length<30).slice(0,2);r.length>0&&(o+="."+r.map(i=>CSS.escape(i)).join("."));let s=n.parentElement;if(s){let i=Array.from(s.children).filter(l=>l.tagName===n.tagName);if(i.length>1){let l=i.indexOf(n)+1;o+=`:nth-of-type(${l})`}}t.unshift(o),n=s}return t.join(" > ")}function Hn(e){try{return document.querySelector(e)}catch(t){return null}}function Ii(e,t=0){var a;let n=xs(e);if(n.length===0)return null;let o=n.map(d=>d.name),r=n.length-1,s=Math.max(0,Math.min(n.length-1,r-t)),i=n[s],l=(a=Mi(i.fiber))!=null?a:e;return{name:i.name,path:o,depthIndex:s,rootElement:l}}function wl(e,t){var s,i;let n=xs(e),o=t.toLowerCase(),r=-1;for(let l=n.length-1;l>=0;l--){let a=n[l].name;if(a===t){let d=(s=Mi(n[l].fiber))!=null?s:e;return{name:t,path:n.map(c=>c.name),depthIndex:l,rootElement:d}}if(r===-1){let d=a.toLowerCase();(d.length>=4&&o.includes(d)||o.length>=4&&d.includes(o))&&(r=l)}}if(r>=0){let l=(i=Mi(n[r].fiber))!=null?i:e;return{name:t,path:n.map(a=>a.name),depthIndex:r,rootElement:l}}return null}function _r(e){let t=Hr(),n=[],o=new Set,r=t.currentNode;for(;r=t.nextNode();){let s=wl(r,e);s&&!o.has(s.rootElement)&&(o.add(s.rootElement),n.push(s))}return n}function Ss(e){let t=new Map;if(e.size===0)return t;let n=new Set(e),o=Hr(),r=new Set,s=o.currentNode;for(;(s=o.nextNode())&&n.size>0;)for(let i of n){let l=wl(s,i);if(!l||r.has(l.rootElement))continue;r.add(l.rootElement);let a=l.rootElement.getBoundingClientRect();t.set(i,a.top+window.scrollY),n.delete(i);break}for(let i of n)t.set(i,1/0);return t}function Hr(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Nn(e){let t={selector:Sl(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let n=Cl(e);n&&n.length>0&&n.length<200&&(t.textContent=n);let o={};for(let i of e.attributes)i.name.startsWith("data-")&&(o[i.name]=i.value);Object.keys(o).length>0&&(t.dataAttributes=o);let r=Ti(e);r&&(t.reactComponent=r.name);let s=Pu(e);return s&&(t.context=s),t}function Cl(e){let t="";for(let n of e.childNodes)n.nodeType===Node.TEXT_NODE&&(t+=n.textContent||"");return t.trim()}function dr(e,t){let n=document.elementsFromPoint(e,t);for(let o of n)if(o instanceof HTMLElement&&!(o.id==="devtools-canvas"||o.id==="devtools-toolbar"||o.id==="devtools-scrim")&&!o.closest("#devtools-toolbar")&&!(o.dataset.devtools||o.closest("[data-devtools]"))&&!["html","body"].includes(o.tagName.toLowerCase()))return o;return null}function Pu(e){let t=e.parentElement,n=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let o=t.tagName.toLowerCase();if(n.includes(o)&&t.id)return`${o}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${o}#${t.id}`;t=t.parentElement}return null}function El(e){let t=new Set,n=[],o=window.scrollX,r=window.scrollY,s=[{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2},{x:e.minX,y:e.minY},{x:e.maxX,y:e.minY},{x:e.minX,y:e.maxY},{x:e.maxX,y:e.maxY}];for(let i of s){let l=i.x-o,a=i.y-r;if(l<0||a<0||l>window.innerWidth||a>window.innerHeight)continue;let d=dr(l,a);d&&!t.has(d)&&(t.add(d),n.push(Nn(d)))}return n.slice(0,3)}function ws(e){if(e.length===0)return[];let t=e.map(o=>o.x),n=e.map(o=>o.y);return El({minX:Math.min(...t),minY:Math.min(...n),maxX:Math.max(...t),maxY:Math.max(...n)})}function dn(e,t){return e.style.getPropertyValue(t)!==""}function Ou(e,t=30){if(e<=0)return[];let n=[],o=Hr(),r=.5,s=o.currentNode;for(;(s=o.nextNode())&&n.length<t;){let i=s,l=i.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(i);!dn(i,"padding-top")&&Math.abs((parseFloat(a.paddingTop)||0)-e)<r&&n.push({element:i,property:"padding-top"}),!dn(i,"padding-bottom")&&Math.abs((parseFloat(a.paddingBottom)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-bottom"}),!dn(i,"padding-left")&&Math.abs((parseFloat(a.paddingLeft)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-left"}),!dn(i,"padding-right")&&Math.abs((parseFloat(a.paddingRight)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-right"}),!dn(i,"margin-top")&&Math.abs((parseFloat(a.marginTop)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-top"}),!dn(i,"margin-bottom")&&Math.abs((parseFloat(a.marginBottom)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-bottom"}),!dn(i,"margin-left")&&Math.abs((parseFloat(a.marginLeft)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-left"}),!dn(i,"margin-right")&&Math.abs((parseFloat(a.marginRight)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-right"});let d=a.display;if((d.includes("flex")||d.includes("grid"))&&n.length<t){let c=dn(i,"gap"),u=parseFloat(a.gap)||0,p=parseFloat(a.rowGap)||0,g=parseFloat(a.columnGap)||0;!c&&Math.abs(u-e)<r?n.push({element:i,property:"gap"}):!dn(i,"row-gap")&&Math.abs(p-e)<r?n.push({element:i,property:"row-gap"}):!dn(i,"column-gap")&&Math.abs(g-e)<r&&n.push({element:i,property:"column-gap"})}}return n}function Cs(e,t=30){if(e<=0)return[];let n=[],o=Hr(),r=.5,s=o.currentNode;for(;(s=o.nextNode())&&n.length<t;){let i=s,l=i.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(i),d=parseFloat(a.borderTopWidth)||0,c=parseFloat(a.borderRightWidth)||0,u=parseFloat(a.borderBottomWidth)||0,p=parseFloat(a.borderLeftWidth)||0,g=i.clientWidth,v=i.clientHeight,x=parseFloat(a.paddingTop)||0;!dn(i,"padding-top")&&Math.abs(x-e)<r&&n.push({x:l.left+p,y:l.top+d,width:g,height:e,direction:"vertical",property:"padding-top"});let w=parseFloat(a.paddingBottom)||0;!dn(i,"padding-bottom")&&Math.abs(w-e)<r&&n.length<t&&n.push({x:l.left+p,y:l.top+d+v-e,width:g,height:e,direction:"vertical",property:"padding-bottom"});let I=parseFloat(a.paddingLeft)||0;!dn(i,"padding-left")&&Math.abs(I-e)<r&&n.length<t&&n.push({x:l.left+p,y:l.top+d,width:e,height:v,direction:"horizontal",property:"padding-left"});let N=parseFloat(a.paddingRight)||0;!dn(i,"padding-right")&&Math.abs(N-e)<r&&n.length<t&&n.push({x:l.left+p+g-e,y:l.top+d,width:e,height:v,direction:"horizontal",property:"padding-right"});let H=parseFloat(a.marginTop)||0;!dn(i,"margin-top")&&Math.abs(H-e)<r&&n.length<t&&n.push({x:l.left,y:l.top-e,width:l.width,height:e,direction:"vertical",property:"margin-top"});let O=parseFloat(a.marginBottom)||0;!dn(i,"margin-bottom")&&Math.abs(O-e)<r&&n.length<t&&n.push({x:l.left,y:l.bottom,width:l.width,height:e,direction:"vertical",property:"margin-bottom"});let L=parseFloat(a.marginLeft)||0;!dn(i,"margin-left")&&Math.abs(L-e)<r&&n.length<t&&n.push({x:l.left-e,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-left"});let Y=parseFloat(a.marginRight)||0;!dn(i,"margin-right")&&Math.abs(Y-e)<r&&n.length<t&&n.push({x:l.right,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-right"});let re=a.display;if((re.includes("flex")||re.includes("grid"))&&n.length<t&&!dn(i,"gap")){let _=Array.from(i.children).filter(B=>{let h=getComputedStyle(B);return h.display!=="none"&&h.position!=="absolute"&&h.position!=="fixed"});if(_.length>=2)for(let B=0;B<_.length-1&&n.length<t;B++){let h=_[B].getBoundingClientRect(),A=_[B+1].getBoundingClientRect(),k=A.top-h.bottom;Math.abs(k-e)<r&&k>.5&&n.push({x:Math.min(h.left,A.left),y:h.bottom,width:Math.max(h.right,A.right)-Math.min(h.left,A.left),height:k,direction:"vertical",property:"gap"});let be=A.left-h.right;Math.abs(be-e)<r&&be>.5&&n.push({x:h.right,y:Math.min(h.top,A.top),width:be,height:Math.max(h.bottom,A.bottom)-Math.min(h.top,A.top),direction:"horizontal",property:"gap"})}}}return n}function Ri(e){return typeof e=="string"?{value:e}:e}var Tl={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function kl(e,t){let n=Tl[t];return n?n.includes(e):!1}function Bu(e,t){let n=e.split(/\s+/);for(let o of n){if(o===t)return!0;let r=o.lastIndexOf(":");if(r>=0&&o.slice(r+1)===t)return!0}return!1}function Du(e){var l,a;let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,o=n.indexOf("-");if(o<0)return null;let r=n.slice(0,o),s={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},i=n.slice(0,n.indexOf("-",o+1)>0?n.indexOf("-",o+1):o);return(a=(l=s[i])!=null?l:s[r])!=null?a:null}function Es(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let r=[],s=Hr(),i=s.currentNode;for(;(i=s.nextNode())&&r.length<t;){let l=i,a=l.getBoundingClientRect();if(a.bottom<-50||a.top>window.innerHeight+50||a.right<-50||a.left>window.innerWidth+50||a.width<1||a.height<1)continue;let d=l.className;if(typeof d=="string")for(let c of e.bindings){if(!Bu(d,c))continue;let u=Du(c);if(u&&!(e.property&&!kl(u,e.property))){r.push({element:l,property:u});break}}}return r}let o=Ou(n,t*2);return e.property?o.filter(r=>kl(r.property,e.property)).slice(0,t):o.slice(0,t)}function ks(e,t=30){let n=Es(e,t),o=[];for(let r of n){let s=r.element,i=s.getBoundingClientRect(),l=getComputedStyle(s),a=parseFloat(l.borderTopWidth)||0,d=parseFloat(l.borderRightWidth)||0,c=parseFloat(l.borderLeftWidth)||0,u=s.clientWidth,p=s.clientHeight;switch(r.property){case"padding-top":{let g=parseFloat(l.paddingTop)||0;o.push({x:i.left+c,y:i.top+a,width:u,height:g,direction:"vertical",property:r.property});break}case"padding-bottom":{let g=parseFloat(l.paddingBottom)||0;o.push({x:i.left+c,y:i.top+a+p-g,width:u,height:g,direction:"vertical",property:r.property});break}case"padding-left":{let g=parseFloat(l.paddingLeft)||0;o.push({x:i.left+c,y:i.top+a,width:g,height:p,direction:"horizontal",property:r.property});break}case"padding-right":{let g=parseFloat(l.paddingRight)||0;o.push({x:i.left+c+u-g,y:i.top+a,width:g,height:p,direction:"horizontal",property:r.property});break}case"margin-top":{let g=parseFloat(l.marginTop)||0;o.push({x:i.left,y:i.top-g,width:i.width,height:g,direction:"vertical",property:r.property});break}case"margin-bottom":{let g=parseFloat(l.marginBottom)||0;o.push({x:i.left,y:i.bottom,width:i.width,height:g,direction:"vertical",property:r.property});break}case"margin-left":{let g=parseFloat(l.marginLeft)||0;o.push({x:i.left-g,y:i.top,width:g,height:i.height,direction:"horizontal",property:r.property});break}case"margin-right":{let g=parseFloat(l.marginRight)||0;o.push({x:i.right,y:i.top,width:g,height:i.height,direction:"horizontal",property:r.property});break}case"gap":case"row-gap":case"column-gap":{let g=Array.from(s.children).filter(v=>{let x=getComputedStyle(v);return x.display!=="none"&&x.position!=="absolute"&&x.position!=="fixed"});for(let v=0;v<g.length-1&&o.length<t;v++){let x=g[v].getBoundingClientRect(),w=g[v+1].getBoundingClientRect(),I=w.top-x.bottom;I>.5&&o.push({x:Math.min(x.left,w.left),y:x.bottom,width:Math.max(x.right,w.right)-Math.min(x.left,w.left),height:I,direction:"vertical",property:"gap"});let N=w.left-x.right;N>.5&&o.push({x:x.right,y:Math.min(x.top,w.top),width:N,height:Math.max(x.bottom,w.bottom)-Math.min(x.top,w.top),direction:"horizontal",property:"gap"})}break}}}return o}function Ml(e,t){let n=new Set,o=ei(t);for(let r of e){let s=Rl[r.property];if(!s)continue;let i=r.element.className;if(typeof i=="string")for(let l of s){let a=`${l}-${o}`;for(let d of i.split(/\s+/)){let c=d.lastIndexOf(":"),u=c>=0?d.slice(c+1):d;if(u===a){n.add(u);break}}}}return[...n]}function Il(e){let t=new Set;for(let n of e)for(let[o,r]of Object.entries(Tl))if(r.includes(n.property)){t.add(o);break}if(t.size===1)return[...t][0]}function Ts(e,t,n){if(t===n)return e;let o=ei(t),r=ei(n);return e.map(s=>{let i=s.lastIndexOf("-");if(i<0)return s;let l=s.slice(0,i),a=s.slice(i+1);return a===o||a===`[${t}px]`?`${l}-${r}`:s})}var _u={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function ei(e){var t;return(t=_u[e])!=null?t:`[${e}px]`}var Rl={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function Hu(e,t,n,o){let r=Rl[t];if(!r)return null;let s=ei(n);for(let i of r){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+i+"-(?:"+Nu(s)+"|\\["+n+"px\\]))(?:\\s|$)"),a=e.match(l);if(a!=null&&a[1]){let d=ei(o),c=a[1].lastIndexOf(":"),u=c>=0?a[1].slice(0,c+1):"";return{matched:a[1],suggested:`${u}${i}-${d}`}}}return null}function Nu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ll(e,t,n){let o=new Set,r=[];for(let s of e){let i=Jn(s.element),l=`${i}::${s.property}`;if(o.has(l))continue;o.add(l);let a=Ti(s.element),d=s.element.className||"",c=Hu(d,s.property,t,n);r.push({selector:i,reactComponent:a==null?void 0:a.name,className:d,property:s.property,matchedClass:c==null?void 0:c.matched,suggestedClass:c==null?void 0:c.suggested})}return r}function Li(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Ai(e,t){if(e instanceof HTMLElement){let o=e.style.getPropertyValue(t);if(o)return o}let n=t.replace(/-([a-z])/g,(o,r)=>r.toUpperCase());try{for(let o of document.styleSheets)try{let r=o.cssRules||o.rules;for(let s of r)if(s instanceof CSSStyleRule&&e.matches(s.selectorText)){let i=s.style.getPropertyValue(t);if(i)return i;let l=s.style[n];if(l)return l}}catch(r){}}catch(o){}return null}function Pi(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function ur(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function zu(e){let t=[];for(let n of e){let o=t.find(r=>r.axis!==n.axis?!1:n.axis==="row"?Math.abs(r.y-n.y)<2&&Math.abs(r.h-n.h)<2:Math.abs(r.x-n.x)<2&&Math.abs(r.w-n.w)<2);if(o)if(n.axis==="row"){let r=Math.min(o.x,n.x),s=Math.max(o.x+o.w,n.x+n.w);o.x=r,o.w=s-r}else{let r=Math.min(o.y,n.y),s=Math.max(o.y+o.h,n.y+n.h);o.y=r,o.h=s-r}else t.push(f({},n))}return t}function Ho(e){let t=Array.from(e.children).filter(a=>{if(!(a instanceof HTMLElement))return!1;let d=window.getComputedStyle(a);return d.display!=="none"&&d.position!=="absolute"&&d.position!=="fixed"});if(t.length<2)return[];let n=[],o=e.getBoundingClientRect(),s=window.getComputedStyle(e).flexDirection,i=s==="column"||s==="column-reverse",l=6;for(let a=0;a<t.length-1;a++){let d=t[a].getBoundingClientRect(),c=t[a+1].getBoundingClientRect();if(c.left>d.right+.5&&n.push({axis:"column",x:d.right,y:o.top,w:c.left-d.right,h:o.height}),c.top>d.bottom+.5&&n.push({axis:"row",x:o.left,y:d.bottom,w:o.width,h:c.top-d.bottom}),!(c.left>d.right+.5)&&!(c.top>d.bottom+.5))if(i){let u=(d.bottom+c.top)/2;n.push({axis:"row",x:o.left,y:u-l/2,w:o.width,h:l})}else{let u=(d.right+c.left)/2;n.push({axis:"column",x:u-l/2,y:o.top,w:l,h:o.height})}}return zu(n)}function Ms(e,t){let n=window.getComputedStyle(e),o=n.display;if(o!=="flex"&&o!=="inline-flex")return!1;let r=n.justifyContent;if(r!=="space-between"&&r!=="space-around"&&r!=="space-evenly"&&r!=="stretch")return!1;let s=n.flexDirection;return!(t!==(s==="column"||s==="column-reverse"?"row":"column")||parseFloat(t==="row"?n.rowGap:n.columnGap)>0)}function Nr(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function pr(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function Is(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function zr(e){var c,u;let t=document.createRange(),n=!1;for(let p of e.childNodes)p.nodeType===Node.TEXT_NODE&&(p.textContent||"").trim().length>0&&(n||(t.setStart(p,0),n=!0),t.setEnd(p,(u=(c=p.textContent)==null?void 0:c.length)!=null?u:0));if(!n)return null;let o=t.getBoundingClientRect(),r=window.getComputedStyle(e),s=parseFloat(r.fontSize)||16,i=parseFloat(r.lineHeight);isNaN(i)&&(i=s*1.2);let l=Math.max(1,t.getClientRects().length),a=Math.max(o.height,l*i),d=(a-o.height)/2;return new DOMRect(o.x,o.y-d,o.width,a)}function ti(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,o=parseFloat(t.lineHeight);return isNaN(o)&&(o=n*1.2),{fontSize:n,lineHeight:o}}function Xe(e,t,n){e instanceof HTMLElement&&e.style.setProperty(t,n,"important")}function Al(e,t,n){e instanceof HTMLElement&&e.style.removeProperty(t)}function Oi(e){var t;for(let n of e){let o=Hn(n.selector);if(!o&&n.durableSelector&&(o=Hn(n.durableSelector),o)){let r=(t=n.selector.match(/\[data-pm="([^"]+)"\]/))==null?void 0:t[1];r&&o.setAttribute("data-pm",r)}if(o)for(let r of n.changes)Xe(o,r.property,r.modified)}}function Bi(e){for(let t of e){let n=Hn(t.selector);if(n)for(let o of t.changes)Al(n,o.property,o.original)}}function Ol(e,t,n,o){if(e)for(let r of e){if(r instanceof CSSGroupingRule){Ol(r.cssRules,t,n,o);continue}if(r instanceof CSSStyleRule){let s=r.selectorText.toLowerCase();(s===":root"||s==="html"||s==="*"||s.includes(":root"))&&Fu(r.style,t,n,o)}}}function Fu(e,t,n,o){for(let r=0;r<e.length;r++){let s=e[r];if(s!=null&&s.startsWith("--")){if(n.has(s))continue;n.add(s);let i=t.getPropertyValue(s).trim();Bl(i)&&o.push({name:s,value:i,usage:`var(${s})`})}}}var Di=null,$u=5e3;function Rs(){if(Di&&Date.now()-Di.timestamp<$u)return Di.variables;let e=[],t=new Set,n=getComputedStyle(document.documentElement);try{for(let s of document.styleSheets)try{Ol(s.cssRules||s.rules,n,t,e)}catch(i){}}catch(s){}let o=document.documentElement.style;for(let s=0;s<o.length;s++){let i=o[s];if(i!=null&&i.startsWith("--")&&!t.has(i)){t.add(i);let l=n.getPropertyValue(i).trim();Bl(l)&&e.push({name:i,value:l,usage:`var(${i})`})}}let r=e.sort((s,i)=>s.name.localeCompare(i.name));return Di={variables:r,timestamp:Date.now()},r}function Bl(e){if(!e)return!1;let t=e.toLowerCase().trim();return!!(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("oklch")||t.startsWith("oklab")||t.startsWith("lch")||t.startsWith("lab")||["transparent","currentcolor","inherit","white","black","red","green","blue","yellow","orange","purple","pink","gray","grey"].includes(t))}function Fr(e,t){let n=t.match(/var\((--[^,)]+)(?:,\s*([^)]+))?\)/);if(n){let o=n[1],r=n[2];return getComputedStyle(document.documentElement).getPropertyValue(o).trim()||r||t}return t}function ni(e,t){if(!e)return null;let n=Pl(e);if(!n)return null;for(let o of t){let r=Pl(o.value);if(r&&n===r)return o}return null}function Pl(e){if(!e)return null;let t=e.trim().toLowerCase();if(t.startsWith("oklch(")){let n=t.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)/);if(n){let o=n[1].endsWith("%")?parseFloat(n[1])/100:parseFloat(n[1]),r=n[2].endsWith("%")?parseFloat(n[2])/100:parseFloat(n[2]),s=parseFloat(n[3]);o=Math.round(o*100)/100,r=Math.round(r*1e3)/1e3;let i=Math.round(s);return`oklch(${o} ${r} ${i})`}}if(t.startsWith("rgb")){let n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);if(n)return`rgb(${n[1]},${n[2]},${n[3]})`}return t.startsWith("#")?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t.slice(0,7):t}import{Fragment as fr,jsx as mt,jsxs as po}from"react/jsx-runtime";var eo=22,Vo=12,Wu=3,ju=250,_i=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],Gu=3e3;function Yu(i){var l=i,{left:e,top:t,avoidBottom:n,style:o,children:r}=l,s=Dn(l,["left","top","avoidBottom","style","children"]);let a=e+Vo,d=t+Vo,c=n!==void 0?`${n}px`:"100vh";return mt("div",y(f({"data-devtools":"badge-hit-area"},s),{style:f({position:"fixed",left:e,top:t,padding:Vo},o),children:mt("div",{style:{transform:`translate(min(0px, calc(100vw - ${a}px - 100%)), min(0px, calc(${c} - ${d}px - 100%)))`},children:r})}))}function Hl({annotations:e,supersededAnnotations:t,inFlightIds:n,activeIds:o,queuePositions:r,scrollX:s,scrollY:i,annotationGroupMap:l,onViewThread:a,onSelectAnnotation:d,onHoverAnnotation:c,canvasRef:u}){var Z,_,B,h,A,k,be;let[p,g]=oi(0),[v,x]=oi(()=>Math.floor(Math.random()*_i.length)),w=!!(n&&n.size>0);Hi(()=>{if(!w)return;let K=setInterval(()=>{g(F=>(F+1)%Wu)},ju),de=setInterval(()=>{x(F=>(F+1)%_i.length)},Gu);return()=>{clearInterval(K),clearInterval(de)}},[w]);let I=[];for(let K of e){if(K.type!=="text"||!K.text||!K.points[0]||t.has(K))continue;let de=K.groupId?e.filter(ye=>ye.groupId===K.groupId):[K],F=(Z=K.status)!=null?Z:"pending",me=de.reduce((ye,ct)=>{var Ge;return ye+((Ge=ct.replyCount)!=null?Ge:0)},0),R=ye=>ye==="resolved"&&me===0,ie=!!(n&&(n.has(K.id)||de.some(ye=>n.has(ye.id))))||K.status==="in_flight"||de.some(ye=>ye.status==="in_flight")||R(K.status)||de.some(ye=>R(ye.status)),Se=de.some(ye=>{var ct;return ye.status==="resolved"&&((ct=ye.replyCount)!=null?ct:0)>0||ye.status==="needs_review"}),Pe=de.some(ye=>ye.threadId);if(!ie&&F!=="resolved"&&F!=="needs_review"&&!Se&&!Pe)continue;let _e=K.threadId||((_=de.find(ye=>ye.threadId))==null?void 0:_.threadId),Ze=F==="needs_review"||de.some(ye=>ye.status==="needs_review"),Oe=K.points[0],he=K.fontSize||12,Fe=he*1.4,rt=l.get(K.id),ht=K.text.replace(/\n/g," "),Jt=rt!==void 0?rt+". "+ht:ht,Q=(h=(B=u==null?void 0:u.current)==null?void 0:B.getContext("2d"))!=null?h:document.createElement("canvas").getContext("2d");if(!Q)continue;Q.font=`${he}px ${Zt}`;let ne=Oe.x-s,Te=Or(ne),$e=Br(Q,Jt,Te),pt=Q.measureText($e).width,Je=ie&&!!o&&!o.has(K.id)&&!de.some(ye=>o.has(ye.id));I.push({id:K.id,threadId:_e,linkedSelector:K.linkedSelector||((A=de.find(ye=>ye.linkedSelector))==null?void 0:A.linkedSelector),x:Oe.x+pt+4,y:Oe.y-4,size:Fe+8,color:K.color,isInFlight:ie,isQueued:Je,queuePosition:void 0,isNeedsReview:Ze,replyCount:me})}let N=I.filter(K=>K.isQueued);if(N.length>0&&N.forEach((K,de)=>{var F;K.queuePosition=(F=r==null?void 0:r.get(K.id))!=null?F:`(${de+1}/${N.length})`}),I.length===0)return null;let H=2,O=(be=(k=u==null?void 0:u.current)==null?void 0:k.getContext("2d"))!=null?be:document.createElement("canvas").getContext("2d"),L=I.map(K=>{var Se;let de;K.isQueued?de=K.queuePosition?`queued ${K.queuePosition}`:"queued":K.isInFlight?de=(Se=_i[v])!=null?Se:"thinking":K.replyCount>0?de=`${K.replyCount} ${K.replyCount===1?"reply":"replies"}`:de="Cancelled";let F=!K.isQueued,me=F?11:0,R=F?4:0,ie=de.length*7.2;return O&&(O.font=`12px ${Zt}`,ie=O.measureText(de).width),4+me+R+ie+4}),Y=typeof window!="undefined"?window.innerHeight:9999,re=[];for(let K=0;K<I.length;K++){let de=I[K].y-i,F=Math.min(de,Y-eo),me=F+eo,ie=I[K].x-s;for(let Se=0;Se<K;Se++){let Pe=I[Se].y-i,_e=Math.min(Pe,Y-eo),Ze=_e+eo;if(!(F<Ze&&me>_e))continue;let he=re[Se]+L[Se];ie<he+H&&(ie=he+H)}re.push(ie)}return mt(fr,{children:I.map((K,de)=>{let F=!!K.threadId;return mt(Yu,{left:re[de]-Vo,top:K.y-i-Vo,onMouseDown:F?me=>me.stopPropagation():void 0,onClick:F?me=>{if(me.stopPropagation(),d==null||d(K.id),a==null||a(K.threadId),K.linkedSelector)try{let R=document.querySelector(K.linkedSelector);if(R){let ie=R.getBoundingClientRect();(ie.bottom<0||ie.top>window.innerHeight)&&R.scrollIntoView({behavior:"smooth",block:"center"})}}catch(R){}}:void 0,onMouseEnter:c?()=>c(K.id):void 0,onMouseLeave:c?()=>c(null):void 0,style:{pointerEvents:F?"auto":"none",cursor:F?"pointer":void 0,zIndex:9999},children:mt("div",{"data-devtools":"annotation-badge",style:{height:K.size,display:"flex",alignItems:"center",backgroundColor:K.color,fontFamily:Zt,fontSize:12,color:"#ffffff",userSelect:"none",padding:`0 ${4}px`,gap:4,whiteSpace:"nowrap"},children:K.isQueued?po("span",{style:{opacity:.5,color:"inherit"},children:["queued",K.queuePosition?` ${K.queuePosition}`:""]}):K.isInFlight?po(fr,{children:[mt("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:p===1?po(fr,{children:[mt("circle",{cx:"7",cy:"7",r:"2"}),mt("circle",{cx:"17",cy:"7",r:"2"}),mt("circle",{cx:"7",cy:"17",r:"2"}),mt("circle",{cx:"17",cy:"17",r:"2"})]}):po(fr,{children:[mt("circle",{cx:"12",cy:"6",r:"2"}),mt("circle",{cx:"6",cy:"12",r:"2"}),mt("circle",{cx:"18",cy:"12",r:"2"}),mt("circle",{cx:"12",cy:"18",r:"2"})]})}),mt("span",{style:{opacity:.7,color:"inherit"},children:_i[v]})]}):po(fr,{children:[K.isNeedsReview?mt("span",{style:{fontWeight:700,color:"inherit"},children:"?"}):mt("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:mt("polyline",{points:"4 12 10 18 20 6"})}),mt("span",{style:{opacity:.7,color:"inherit"},children:K.replyCount>0?`${K.replyCount} ${K.replyCount===1?"reply":"replies"}`:"Cancelled"})]})})},K.id)})})}function Ls({inFlightSelectorColors:e,animated:t=!0}){let[n,o]=oi([]);return Hi(()=>{if(e.size===0){o([]);return}let r=null,s=()=>{let a=[];for(let[d,c]of e){let u=Hn(d);if(!u)continue;let p=u.getBoundingClientRect();a.push({selector:d,top:p.top,left:p.left,width:p.width,height:p.height,color:c})}o(a)},i=()=>{r&&cancelAnimationFrame(r),r=requestAnimationFrame(s)};s(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i,!0);let l=new MutationObserver(i);return l.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i,!0),l.disconnect(),r&&cancelAnimationFrame(r)}},[e]),n.length===0?null:po(fr,{children:[t&&mt("style",{children:"@keyframes popmelt-march { to { stroke-dashoffset: -6; } }"}),n.map(r=>mt("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:r.top,left:r.left,width:r.width,height:r.height,pointerEvents:"none",zIndex:9995,overflow:"visible"},children:mt("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:mt("rect",{x:"0.5",y:"0.5",width:Math.max(0,r.width-1),height:Math.max(0,r.height-1),fill:"none",stroke:r.color,strokeWidth:"1",strokeDasharray:"2 4",style:t?{animation:"popmelt-march 0.5s steps(2) infinite"}:void 0})})},r.selector))]})}function Nl({annotations:e,supersededAnnotations:t,scrollX:n,scrollY:o,onReply:r,annotationGroupMap:s,canvasRef:i,onHoverAnnotation:l}){let a=e.filter(u=>t.has(u)?!1:u.status==="waiting_input"&&u.question&&u.threadId);if(a.length===0)return null;let d=new Set,c=[];for(let u of a){if(!u.threadId||d.has(u.threadId))continue;d.add(u.threadId);let p=u.type==="text"?u:e.find(g=>g.groupId&&g.groupId===u.groupId&&g.type==="text")||u;if(p.type==="text"&&p.text&&p.points[0]){let g=p.points[0],v=p.fontSize||12,x=v*1.4,w=s.get(p.id),I=p.text.replace(/\n/g," "),N=w!==void 0?w+". "+I:I,O=document.createElement("canvas").getContext("2d");if(!O)continue;O.font=`${v}px ${Zt}`;let L=g.x-n,Y=Or(L),re=Br(O,N,Y),Z=O.measureText(re).width;c.push({annotation:u,x:g.x+Z+4,y:g.y-4,size:x+8})}}return c.length===0?null:mt(fr,{children:c.map(({annotation:u,x:p,y:g,size:v})=>mt(Ju,{annotation:u,x:p-n,y:g-o,size:v,onReply:r,onHoverAnnotation:l},`question-${u.threadId}`))})}function Ju({annotation:e,x:t,y:n,size:o,onReply:r,onHoverAnnotation:s}){let[i,l]=oi(!1),[a,d]=oi(""),c=_l(null),u=_l(null);Hi(()=>{i&&c.current&&c.current.focus()},[i]),Hi(()=>{if(!i)return;let w=N=>{u.current&&!N.composedPath().includes(u.current)&&l(!1)},I=N=>{N.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",I)}},[i]);let p=Dl(()=>{!a.trim()||!e.threadId||(r(e.threadId,a.trim()),d(""),l(!1))},[a,e.threadId,r]),g=Dl(w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),p())},[p]),v=i?t:t-Vo,x=i?n:n-Vo;return po("div",{ref:u,"data-devtools":"question-badge",onMouseEnter:s?()=>s(e.id):void 0,onMouseLeave:s?()=>s(null):void 0,style:{position:"fixed",left:`max(0px, ${v}px)`,top:`max(0px, ${x}px)`,padding:i?0:Vo,transform:`translate(min(0px, calc(100vw - max(0px, ${v}px) - 100%)), min(0px, calc(100vh - max(0px, ${x}px) - 100%)))`,zIndex:i?10002:9999,pointerEvents:"auto",cursor:i?void 0:"pointer"},children:[!i&&po("div",{onClick:()=>l(!0),style:{height:o,display:"flex",alignItems:"center",backgroundColor:e.color,padding:`0 ${4}px`,gap:4,fontFamily:Zt,fontSize:12,color:"#ffffff",whiteSpace:"nowrap"},children:[po("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[mt("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),mt("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),mt("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),mt("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]}),mt("span",{style:{opacity:.7},children:"reply?"})]}),i&&po("div",{style:{minWidth:260,maxWidth:360,backgroundColor:"#eaeaea",fontFamily:Zt,fontSize:12,color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)"},children:[mt("div",{style:{padding:`${6}px ${8}px`,lineHeight:1.4},children:e.question}),po("div",{style:{padding:`0 ${4}px ${4}px`},children:[mt("textarea",{ref:c,value:a,onChange:w=>d(w.target.value),onKeyDown:g,placeholder:"Type your reply...",style:{width:"100%",minHeight:40,padding:4,fontSize:12,fontFamily:Zt,backgroundColor:"rgba(0, 0, 0, 0.04)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),mt("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:mt("button",{onClick:p,disabled:!a.trim(),style:{padding:"4px 12px",fontSize:11,fontFamily:Zt,fontWeight:600,backgroundColor:a.trim()?e.color:"rgba(0,0,0,0.1)",color:a.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:a.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}function Ni(e){var s;let t=new Set,n=new Map;for(let i of e){if(!i.linkedSelector)continue;let l=n.get(i.linkedSelector)||[];l.push(i),n.set(i.linkedSelector,l)}let o=new Set,r=new Set;for(let i of n.values()){if(i.length<=1){(s=i[0])!=null&&s.groupId&&r.add(i[0].groupId);continue}i.sort((a,d)=>d.timestamp-a.timestamp);let l=i[0];l.groupId&&r.add(l.groupId);for(let a=1;a<i.length;a++){let d=i[a];t.add(d),d.groupId&&o.add(d.groupId)}}for(let i of e)i.groupId&&o.has(i.groupId)&&!r.has(i.groupId)&&t.add(i);return t}import{useEffect as zl,useLayoutEffect as Vu,useState as Fl}from"react";import{jsx as As,jsxs as Wl}from"react/jsx-runtime";function Uu(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var $l=["top-left","top-right","bottom-right","bottom-left"];function jl({element:e,radius:t,accentColor:n,hoveredCorner:o,draggingCorner:r,cursorViewport:s}){let[i,l]=Fl(null),[a,d]=Fl(!1);if(zl(()=>{let I=O=>{(O.key==="Meta"||O.key==="Control")&&d(!0)},N=O=>{(O.key==="Meta"||O.key==="Control")&&d(!1)},H=()=>d(!1);return window.addEventListener("keydown",I,!0),window.addEventListener("keyup",N,!0),window.addEventListener("blur",H),()=>{window.removeEventListener("keydown",I,!0),window.removeEventListener("keyup",N,!0),window.removeEventListener("blur",H)}},[]),zl(()=>{if(!e){l(null);return}let I=()=>{l(e.getBoundingClientRect())};return I(),window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I,{passive:!0}),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I)}},[e]),Vu(()=>{e&&l(e.getBoundingClientRect())},[e,t["top-left"],t["top-right"],t["bottom-right"],t["bottom-left"]]),!i)return null;let c=i.width,u=i.height,p=Uu(n,.2),g={"top-left":{x:0,y:t["top-left"]},"top-right":{x:c,y:t["top-right"]},"bottom-right":{x:c,y:u-t["bottom-right"]},"bottom-left":{x:0,y:u-t["bottom-left"]}},v=new Set,x=r!=null?r:o;if(x)if(a)v.add(x);else for(let I of $l)v.add(I);let w={position:"fixed",top:i.top,left:i.left,width:c,height:u,pointerEvents:"none",zIndex:9996,overflow:"visible"};return Wl("div",{"data-devtools":"border-radius-handles",style:w,children:[Wl("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${c} ${u}`,children:[As("rect",{x:"0.5",y:"0.5",width:Math.max(0,c-1),height:Math.max(0,u-1),fill:"none",stroke:p,strokeWidth:"1"}),$l.map(I=>{let N=g[I],H=v.has(I);return As("circle",{cx:N.x,cy:N.y,r:I===(r!=null?r:o)?3:2.5,fill:n,stroke:"#ffffff",strokeWidth:I===(r!=null?r:o)?4:2,paintOrder:"stroke"},I)})]}),s&&x&&(()=>{let I=Math.round(t[x]);return As("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:I})})()]})}import{useEffect as Ku,useState as Xu}from"react";function gr(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o){let r=parseInt(o[1],16),s=parseInt(o[2],16),i=parseInt(o[3],16);return`rgba(${r}, ${s}, ${i}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}import{Fragment as qu,jsx as Ps,jsxs as ri}from"react/jsx-runtime";function Co({element:e,isSelected:t=!1,elementInfo:n,color:o="#3b82f6",annotationNumber:r,changeCount:s,hideTooltip:i=!1}){let[l,a]=Xu(null);if(Ku(()=>{if(!e){a(null);return}let L=()=>{let Y=e.getBoundingClientRect();a(Y)};return L(),window.addEventListener("scroll",L,{passive:!0}),window.addEventListener("resize",L,{passive:!0}),()=>{window.removeEventListener("scroll",L),window.removeEventListener("resize",L)}},[e]),!l||!e)return null;let d={position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9996,backgroundColor:gr(o,.05),overflow:"visible"},c=e.tagName.toLowerCase(),u=e.id?`#${e.id}`:"",p=e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",g=n==null?void 0:n.reactComponent,v=g?`<${g}> ${c}${u}${p}`:`${c}${u}${p}`,x=22,w=l.height>=window.innerHeight,I=w?0:l.top>=x?l.top-x:l.bottom,N=w?{position:"absolute",top:8,left:8,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400}:{position:"fixed",top:I,left:l.left,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400},O=!i&&ri("div",{"data-devtools":"tooltip",style:N,children:[r!==void 0&&ri("span",{children:[r,"."]}),Ps("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:v}),s!==void 0&&s>0&&ri("span",{style:{opacity:.8},children:["(",s," ",s===1?"change":"changes",")"]})]});return ri(qu,{children:[ri("div",{"data-devtools":"highlight",style:d,children:[Ps("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:Ps("rect",f({x:"0.5",y:"0.5",width:Math.max(0,l.width-1),height:Math.max(0,l.height-1),fill:"none",stroke:o,strokeWidth:"1"},!t&&{strokeDasharray:"2 4"}))}),w&&O]}),!w&&O]})}import{useEffect as Gl,useLayoutEffect as Zu,useState as Os}from"react";import{jsx as No,jsxs as Ds}from"react/jsx-runtime";function Bs(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function _s({element:e,gap:t,accentColor:n,hoveredAxis:o,draggingAxis:r,cursorViewport:s,isAutoGap:i=!1,refreshKey:l=0}){let[a,d]=Os(null),[c,u]=Os([]),[p,g]=Os(!1);if(Gl(()=>{let Z=h=>{(h.key==="Meta"||h.key==="Control")&&g(!0)},_=h=>{(h.key==="Meta"||h.key==="Control")&&g(!1)},B=()=>g(!1);return window.addEventListener("keydown",Z,!0),window.addEventListener("keyup",_,!0),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",Z,!0),window.removeEventListener("keyup",_,!0),window.removeEventListener("blur",B)}},[]),Gl(()=>{if(!e){d(null),u([]);return}let Z=()=>{d(e.getBoundingClientRect()),u(Ho(e))};return Z(),window.addEventListener("scroll",Z,{passive:!0}),window.addEventListener("resize",Z,{passive:!0}),()=>{window.removeEventListener("scroll",Z),window.removeEventListener("resize",Z)}},[e]),Zu(()=>{e&&(d(e.getBoundingClientRect()),u(Ho(e)))},[e,t.row,t.column,l]),!a||c.length===0)return null;let v=a.width,x=a.height,w="pm-gap-stripe-pattern",I=Bs(n,.25),N=Bs(n,.1),H=Bs(n,.2),O=8,L=2,Y={position:"fixed",top:a.top,left:a.left,width:v,height:x,pointerEvents:"none",zIndex:9996,overflow:"visible"},re=r!=null?r:o;return Ds("div",{"data-devtools":"gap-handles",style:Y,children:[Ds("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${v} ${x}`,children:[No("defs",{children:No("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:No("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:I,strokeWidth:"1.5"})})}),No("rect",{x:"0.5",y:"0.5",width:Math.max(0,v-1),height:Math.max(0,x-1),fill:"none",stroke:H,strokeWidth:"1"}),c.map((Z,_)=>{let B=Z.x-a.left,h=Z.y-a.top,A=Z.w,k=Z.h,be=p?Z.axis===re:!0;return(Z.axis==="row"?t.row:t.column)===0?null:Ds("g",{opacity:be?1:.6,children:[No("rect",{x:B,y:h,width:A,height:k,fill:N}),No("rect",{x:B,y:h,width:A,height:k,fill:`url(#${w})`})]},_)}),re&&(()=>{let Z=c.filter(Se=>Se.axis===re);if(Z.length===0)return null;let _=Z[0];if(s&&Z.length>1){let Se=1/0;for(let Pe of Z){let _e=Pe.x+Pe.w/2,Ze=Pe.y+Pe.h/2,Oe=Math.abs(s.x-_e)+Math.abs(s.y-Ze);Oe<Se&&(Se=Oe,_=Pe)}}let B=_.x-a.left,h=_.y-a.top,A=_.w,k=_.h,be=B+A/2,K=h+k/2;if(i)return No("circle",{cx:be,cy:K,r:1.5,fill:n,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"});let de=re==="column",F=de?L:O,me=de?O:L,R=be-F/2,ie=K-me/2;return No("rect",{x:R,y:ie,width:F,height:me,fill:n,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"})})()]}),s&&re&&(()=>{let Z=i?"auto":String(Math.round(re==="row"?t.row:t.column));return No("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:Z})})()]})}import{useCallback as op,useEffect as rp,useState as ip}from"react";import{useEffect as Qu,useState as Yl}from"react";var ep=3,tp=250,Hs=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],np=3e3;function Jl(e){let[t,n]=Yl(0),[o,r]=Yl(()=>Math.floor(Math.random()*Hs.length));return Qu(()=>{if(!e)return;let s=setInterval(()=>n(l=>(l+1)%ep),tp),i=setInterval(()=>r(l=>(l+1)%Hs.length),np);return()=>{clearInterval(s),clearInterval(i)}},[e]),{charIndex:t,word:Hs[o]}}import{Fragment as Ns,jsx as Vn,jsxs as $r}from"react/jsx-runtime";function sp(e){let{element:t}=e,n=t.tagName,o=t.id?`#${t.id}`:"",r=t.className?"."+t.className.split(" ").slice(0,2).join("."):"",s=t.reactComponent;return s?`<${s}> ${n}${o}${r}`:`${n}${o}${r}`}var Vl=22,zs=12;function ap(i){var l=i,{left:e,top:t,avoidBottom:n,style:o,children:r}=l,s=Dn(l,["left","top","avoidBottom","style","children"]);let a=n!==void 0?`${n}px`:"100vh";return Vn("div",y(f({"data-devtools":"badge-hit-area"},s),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:zs,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(${a} - max(0px, ${t}px) - 100%)))`},o),children:r}))}function Ul({styleModifications:e,isInspecting:t,accentColor:n,annotationGroupCount:o,dispatch:r,inFlightSelectors:s,toolbarRef:i,onHoverSelector:l}){var N;let[a,d]=ip([]),c=s&&s.size>0,{charIndex:u,word:p}=Jl(!!c);rp(()=>{if(t){d([]);return}let H=null,O=()=>{let re=[];e.forEach((Z,_)=>{let B=Hn(Z.selector);if(!B)return;let h=B.getBoundingClientRect();re.push({selector:Z.selector,modIndex:_,top:h.top>=Vl?h.top-Vl:h.bottom,left:h.left,label:sp(Z),changeCount:Z.changes.length,annotationNumber:o+_+1})}),d(re)},L=()=>{H&&cancelAnimationFrame(H),H=requestAnimationFrame(O)};O(),window.addEventListener("scroll",L,!0),window.addEventListener("resize",L,!0);let Y=new MutationObserver(L);return Y.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),window.addEventListener("load",L),document.fonts.ready.then(L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L,!0),window.removeEventListener("load",L),Y.disconnect(),H&&cancelAnimationFrame(H)}},[e,t,o]);let g=op(H=>{let O=e[H];if(!O)return;let L=Hn(O.selector);L&&(r({type:"SELECT_ANNOTATION",payload:{id:null}}),r({type:"SET_TOOL",payload:"inspector"}),r({type:"SELECT_ELEMENT",payload:{el:L,info:O.element}}))},[e,r]);if(a.length===0)return null;let v=(N=i==null?void 0:i.current)==null?void 0:N.getBoundingClientRect(),x=v?v.top-8:void 0,w={display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,whiteSpace:"nowrap",maxWidth:400},I={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};return Vn(Ns,{children:a.map(H=>{let O=s==null?void 0:s.has(H.selector);return Vn(ap,{left:H.left-zs,top:H.top-zs,avoidBottom:x,onClick:()=>g(H.modIndex),onMouseEnter:l?()=>l(H.selector):void 0,onMouseLeave:l?()=>l(null):void 0,style:{zIndex:1e4,cursor:"pointer",pointerEvents:"auto"},children:$r("div",{"data-devtools":"badge",style:y(f({},w),{backgroundColor:O?"#999999":n}),children:[$r("span",{children:[H.annotationNumber,"."]}),Vn("span",{style:I,children:H.label}),$r("span",{style:{opacity:.8},children:["(",H.changeCount," ",H.changeCount===1?"change":"changes",")"]}),O&&$r("span",{style:{opacity:.8,marginLeft:4,display:"inline-flex",alignItems:"center",gap:4},children:[Vn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:u===1?$r(Ns,{children:[Vn("circle",{cx:"7",cy:"7",r:"2"}),Vn("circle",{cx:"17",cy:"7",r:"2"}),Vn("circle",{cx:"7",cy:"17",r:"2"}),Vn("circle",{cx:"17",cy:"17",r:"2"})]}):$r(Ns,{children:[Vn("circle",{cx:"12",cy:"6",r:"2"}),Vn("circle",{cx:"6",cy:"12",r:"2"}),Vn("circle",{cx:"18",cy:"12",r:"2"}),Vn("circle",{cx:"12",cy:"18",r:"2"})]})}),p]})]})},H.selector)})})}import{useEffect as lp,useState as cp}from"react";import{Fragment as up,jsx as Kl}from"react/jsx-runtime";function dp(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Xl({styleModifications:e,accentColor:t}){let[n,o]=cp([]);if(lp(()=>{let s=null,i=()=>{let d=[];for(let c of e){let u=Hn(c.selector);if(!u)continue;let p=u.getBoundingClientRect();if(p.width===0&&p.height===0)continue;let g=pr(u);d.push({selector:c.selector,top:p.top,left:p.left,width:p.width,height:p.height,borderRadius:`${g["top-left"]}px ${g["top-right"]}px ${g["bottom-right"]}px ${g["bottom-left"]}px`})}o(d)},l=()=>{s&&cancelAnimationFrame(s),s=requestAnimationFrame(i)};i(),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0});let a=new MutationObserver(l);return a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),a.disconnect(),s&&cancelAnimationFrame(s)}},[e]),n.length===0)return null;let r=dp(t,.2);return Kl(up,{children:n.map(s=>{let i={position:"fixed",top:s.top,left:s.left,width:s.width,height:s.height,pointerEvents:"none",zIndex:9995,border:`1px solid ${r}`,borderRadius:s.borderRadius,boxSizing:"border-box"};return Kl("div",{"data-devtools":"mod-border",style:i},s.selector)})})}import{useEffect as ql,useLayoutEffect as pp,useState as Zl}from"react";import{jsx as Uo,jsxs as $s}from"react/jsx-runtime";function Fs(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var fp={top:"bottom",bottom:"top",left:"right",right:"left"};function Ws({element:e,padding:t,accentColor:n,hoveredSide:o,draggingSide:r,cursorViewport:s,refreshKey:i}){let[l,a]=Zl(null),[d,c]=Zl(!1);if(ql(()=>{let A=K=>{(K.key==="Meta"||K.key==="Control")&&c(!0)},k=K=>{(K.key==="Meta"||K.key==="Control")&&c(!1)},be=()=>c(!1);return window.addEventListener("keydown",A,!0),window.addEventListener("keyup",k,!0),window.addEventListener("blur",be),()=>{window.removeEventListener("keydown",A,!0),window.removeEventListener("keyup",k,!0),window.removeEventListener("blur",be)}},[]),ql(()=>{if(!e){a(null);return}let A=()=>{a(e.getBoundingClientRect())};return A(),window.addEventListener("scroll",A,{passive:!0}),window.addEventListener("resize",A,{passive:!0}),()=>{window.removeEventListener("scroll",A),window.removeEventListener("resize",A)}},[e]),pp(()=>{e&&a(e.getBoundingClientRect())},[e,t.top,t.right,t.bottom,t.left,i]),!l)return null;let u=l.width,p=l.height,{top:g,right:v,bottom:x,left:w}=t,I="pm-stripe-pattern",N=Fs(n,.25),H=Fs(n,.1),O=Fs(n,.2),L=8,Y=2,re={position:"fixed",top:l.top,left:l.left,width:u,height:p,pointerEvents:"none",zIndex:9996,overflow:"visible"},Z=["top","right","bottom","left"],_={top:`0,0 ${u},0 ${u-v},${g} ${w},${g}`,right:`${u},0 ${u},${p} ${u-v},${p-x} ${u-v},${g}`,bottom:`0,${p} ${w},${p-x} ${u-v},${p-x} ${u},${p}`,left:`0,0 ${w},${g} ${w},${p-x} 0,${p}`},B={top:{x:u/2-L/2,y:g/2-Y/2,w:L,h:Y},bottom:{x:u/2-L/2,y:p-x/2-Y/2,w:L,h:Y},left:{x:w/2-Y/2,y:p/2-L/2,w:Y,h:L},right:{x:u-v/2-Y/2,y:p/2-L/2,w:Y,h:L}},h=new Set;return r?h.add(r):o&&(h.add(o),d||h.add(fp[o])),$s("div",{"data-devtools":"padding-handles",style:re,children:[$s("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${u} ${p}`,children:[Uo("defs",{children:Uo("pattern",{id:I,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:Uo("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:N,strokeWidth:"1.5"})})}),Uo("rect",{x:"0.5",y:"0.5",width:Math.max(0,u-1),height:Math.max(0,p-1),fill:"none",stroke:O,strokeWidth:"1"}),Z.map(A=>{if(t[A]<=0)return null;let be=h.has(A);return $s("g",{opacity:be?1:.6,children:[Uo("polygon",{points:_[A],fill:H}),Uo("polygon",{points:_[A],fill:`url(#${I})`})]},A)}),Z.map(A=>{let k=B[A],be=h.has(A);return Uo("rect",{x:k.x,y:k.y,width:k.w,height:k.h,fill:n,stroke:"#ffffff",strokeWidth:be?4:2,paintOrder:"stroke"},`handle-${A}`)})]}),s&&(o||r)&&(()=>{let A=r!=null?r:o,k=Math.round(t[A]);return Uo("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:k})})()]})}import{useCallback as Eo,useEffect as no,useMemo as Ji,useRef as jn,useState as Cn}from"react";import{Check as Yi,ChevronDown as Xs,MoveHorizontal as dc,Shrink as Np}from"lucide-react";var gp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMicgaGVpZ2h0PScxMic+PGRlZnM+PHBhdHRlcm4gaWQ9J2QnIHdpZHRoPSc0JyBoZWlnaHQ9JzQnIHBhdHRlcm5Vbml0cz0ndXNlclNwYWNlT25Vc2UnPjxwYXRoIGQ9J00tMSwxIGwyLC0yIE0wLDQgbDQsLTQgTTMsNSBsMiwtMicgc3Ryb2tlPSdibGFjaycgc3Ryb2tlLXdpZHRoPScuNScvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9JzEyJyBoZWlnaHQ9JzEyJyBmaWxsPSd1cmwoI2QpJy8+PC9zdmc+",Ko={borderWidth:3,borderStyle:"solid",borderImage:`url("${gp}") 4 / 1.9 / 0 round`};function zi({color:e="rgb(0,0,0)",animated:t=!1}={}){let n=`<svg xmlns='http://www.w3.org/2000/svg' width='5' height='5'><path d='M-1,1 l2,-2 M0,5 l5,-5 M4,6 l2,-2' stroke='${e}' stroke-width='.75'/></svg>`;return f({position:"absolute",inset:-3,padding:5,backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(n)}")`,backgroundSize:"5px 5px",WebkitMask:"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0) border-box",WebkitMaskComposite:"xor",mask:"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0) border-box",maskComposite:"exclude",pointerEvents:"none"},t?{animation:"popmelt-border-march 0.8s linear infinite"}:{})}var Fi={"font-size":["rem","px","em"],"line-height":["","rem","px","em"],"letter-spacing":["rem","px","em"],gap:["rem","px","em"],"column-gap":["rem","px","em"],"row-gap":["rem","px","em"],padding:["rem","px","em","%"],margin:["rem","px","em","%"],width:["rem","px","%","em"],height:["rem","px","%","em"],"min-width":["rem","px","%","em"],"max-width":["rem","px","%","em"],"min-height":["rem","px","%","em"],"max-height":["rem","px","%","em"],"border-width":["px","rem","em"],"border-radius":["rem","px","%","em"]};function Wr(e){var t,n;return(n=(t=Fi[e])==null?void 0:t[0])!=null?n:"px"}function Xo(e){let t=e.match(/^([\d.-]+)(.*)$/);return t?{num:parseFloat(t[1]),unit:t[2]||""}:{num:0,unit:""}}function $i(e,t,n,o){let r=e.trim();if(!r)return"";let s=r.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i);if(s)return`${parseFloat(s[1])}${s[2].toLowerCase()}`;let i=parseFloat(r);if(!isNaN(i)){if(o){let{unit:l}=Xo(n);return`${i}${l||Wr(t)}`}return`${i}${Wr(t)}`}return r}function js(e,t){if(!t||t==="px")return e;if(t==="rem"){let n=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Math.round(e/n*1e3)/1e3}return e}import{useCallback as mp,useEffect as hp,useRef as Ql,useState as yp}from"react";import{Plus as ec,X as bp}from"lucide-react";import{jsx as Wn,jsxs as mr}from"react/jsx-runtime";var Wi=[{name:"blur",label:"Blur",unit:"px",defaultValue:10,min:0,max:100,step:1},{name:"brightness",label:"Brightness",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"contrast",label:"Contrast",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"saturate",label:"Saturate",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"grayscale",label:"Grayscale",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"sepia",label:"Sepia",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"invert",label:"Invert",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"hue-rotate",label:"Hue Rotate",unit:"deg",defaultValue:0,min:0,max:360,step:1},{name:"opacity",label:"Opacity",unit:"",defaultValue:1,min:0,max:1,step:.05}];function vp(e){if(!e||e==="none")return[];let t=[],n=/([\w-]+)\(([^)]+)\)/g,o;for(;(o=n.exec(e))!==null;){let r=o[1],s=o[2],i=parseFloat(s);isNaN(i)||t.push({name:r,value:i})}return t}function Gs(e){return e.length===0?"none":e.map(t=>{var r;let n=Wi.find(s=>s.name===t.name),o=(r=n==null?void 0:n.unit)!=null?r:"";return`${t.name}(${t.value}${o})`}).join(" ")}function tc({value:e,onChange:t,accentColor:n,modified:o,panelContentRef:r}){let s=vp(e),[i,l]=yp(!1),a=Ql(null),d=Ql(null);hp(()=>{if(!i)return;let H=O=>{a.current&&!O.composedPath().includes(a.current)&&l(!1)};return document.addEventListener("mousedown",H,!0),()=>document.removeEventListener("mousedown",H,!0)},[i]);let c=Wi.filter(H=>!s.some(O=>O.name===H.name)),u=H=>{let O=[...s,{name:H.name,value:H.defaultValue}];t(Gs(O)),l(!1)},p=H=>{let O=s.filter((L,Y)=>Y!==H);t(Gs(O))},g=(H,O)=>{let L=s.map((Y,re)=>re===H?y(f({},Y),{value:O}):Y);t(Gs(L))},v={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"},x=mp(H=>{var _;if(!d.current)return{position:"fixed",top:0,left:0};let O=d.current.getBoundingClientRect(),L=(_=r==null?void 0:r.current)==null?void 0:_.getBoundingClientRect(),Y=H*24+8,Z=window.innerHeight-O.bottom<Y;return y(f({position:"fixed"},Z?{bottom:window.innerHeight-O.top+2}:{top:O.bottom+2}),{left:L?L.left+4:O.left,width:L?L.width-8:140,zIndex:10001})},[r]),w={backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:4,padding:"4px 0",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},I={display:"block",width:"100%",padding:"4px 10px",border:"none",backgroundColor:"transparent",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#334155",cursor:"pointer",textAlign:"left"},N=H=>Wn("div",{ref:a,style:f(f({},x(H.length)),w),children:H.map(O=>Wn("button",{type:"button",onClick:()=>u(O),style:I,onMouseEnter:L=>{L.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor="transparent"},children:O.label},O.name))});return s.length===0?mr("div",{children:[mr("div",{style:{display:"flex",alignItems:"center",gap:4},children:[Wn(zo,{modified:!1,children:Wn("input",{type:"text",value:"",placeholder:"\u2014",readOnly:!0,style:y(f({},v),{color:"#999",cursor:"default"})})}),Wn("button",{ref:d,type:"button",onClick:()=>l(!i),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:Wn(ec,{size:12})})]}),i&&N(Wi)]}):mr("div",{style:{display:"flex",flexDirection:"column",gap:4,position:"relative"},children:[s.map((H,O)=>{let L=Wi.find(Y=>Y.name===H.name);return L?mr("div",{style:{display:"flex",alignItems:"center",gap:4},children:[Wn("span",{style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o?n:"#94a3b8",fontWeight:o?600:400,width:56,flexShrink:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:L.label}),Wn(zo,{modified:o,children:mr("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 4px"},children:[Wn("input",{type:"range",min:L.min,max:L.max,step:L.step,value:H.value,onChange:Y=>g(O,parseFloat(Y.target.value)),style:{flex:1,height:2,appearance:"none",WebkitAppearance:"none",background:`linear-gradient(to right, ${n} ${(H.value-L.min)/(L.max-L.min)*100}%, rgba(0,0,0,0.1) ${(H.value-L.min)/(L.max-L.min)*100}%)`,borderRadius:1,outline:"none",cursor:"pointer"}}),Wn("input",{type:"number",min:L.min,max:L.max,step:L.step,value:L.unit==="px"||L.unit==="deg"?Math.round(H.value):Math.round(H.value*100)/100,onChange:Y=>g(O,parseFloat(Y.target.value)||0),style:y(f({},v),{width:44,padding:"2px 4px",textAlign:"right",flexShrink:0})}),L.unit&&Wn("span",{style:{fontSize:9,color:"#94a3b8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',flexShrink:0,width:16},children:L.unit})]})}),Wn("button",{type:"button",onClick:()=>p(O),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:Wn(bp,{size:10})})]},H.name):null}),c.length>0&&mr("div",{children:[mr("button",{ref:d,type:"button",onClick:()=>l(!i),style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",border:"none",borderRadius:2,backgroundColor:"transparent",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#94a3b8",cursor:"pointer"},children:[Wn(ec,{size:10}),"Add filter"]}),i&&N(c)]})]})}import{useCallback as go,useEffect as Cp,useRef as ji,useState as nc}from"react";import{AlignHorizontalSpaceAround as Ep,AlignVerticalSpaceAround as kp,Columns3 as Tp,Grid2x2 as Mp,RectangleHorizontal as Ip,Rows3 as Rp,UnfoldHorizontal as oc,UnfoldVertical as rc}from"lucide-react";import{useCallback as xp,useEffect as Sp,useRef as ii}from"react";import{jsx as wp}from"react/jsx-runtime";var Ys=[0,1,2,4,8,12,16,20,24,28,32];function jr({value:e,onChange:t,onPreview:n,onScrubEnd:o,onReset:r,isModified:s,accentColor:i,defaultUnit:l="rem",snapSteps:a,color:d,style:c,children:u}){let p=ii(null),g=ii(null),v=ii(r),x=ii(s),w=ii(!1);v.current=r,x.current=s,Sp(()=>{let N=O=>{let L=g.current;if(!L)return;L.hasMoved=!0,w.current=O.shiftKey;let Y=L.unit==="rem"||L.unit==="em"?.1:1;L.accum+=O.movementX*Y;let re=Math.max(0,Math.round((L.startValue+L.accum)*10)/10);if(O.shiftKey&&a){let Z=L.unit==="rem"||L.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,_=L.unit==="rem"||L.unit==="em"?re*Z:re,B=a[a.length-1];for(let h=0;h<a.length-1;h++){let A=a[h],k=a[h+1];if(_<=(A+k)/2){B=A;break}if(_<k){B=k;break}}_>a[a.length-1]&&(B=Math.round(_/8)*8),re=L.unit==="rem"||L.unit==="em"?Math.round(B/Z*1e3)/1e3:B}n==null||n(`${re}${L.unit}`)},H=()=>{let O=g.current;if(!O)return;let L=Math.max(0,Math.round((O.startValue+O.accum)*10)/10);if(w.current&&a){let re=O.unit==="rem"||O.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,Z=O.unit==="rem"||O.unit==="em"?L*re:L,_=a[a.length-1];for(let B=0;B<a.length-1;B++){let h=a[B],A=a[B+1];if(Z<=(h+A)/2){_=h;break}if(Z<A){_=A;break}}Z>a[a.length-1]&&(_=Math.round(Z/8)*8),L=O.unit==="rem"||O.unit==="em"?Math.round(_/re*1e3)/1e3:_}let Y=O.hasMoved&&L!==O.startValue;g.current=null,document.exitPointerLock(),Y?t(`${L}${O.unit}`):O.hasMoved?n==null||n(`${O.startValue}${O.unit}`):x.current&&v.current&&v.current(),o==null||o()};return document.addEventListener("mousemove",N),document.addEventListener("mouseup",H),()=>{document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",H)}},[t,n,o]);let I=xp(N=>{var L;if(N.button!==0)return;N.preventDefault();let H=Xo(e),O=H.unit&&H.unit!=="px"?H.unit:l;g.current={startValue:H.num,unit:O,accum:0,hasMoved:!1},(L=p.current)==null||L.requestPointerLock()},[e,l]);return wp("span",{ref:p,onMouseDown:I,title:s?"Click to reset \xB7 Drag to scrub":"Drag to scrub",style:f({color:s?i||"#3b82f6":d||"#999",padding:"0 4px",display:"flex",alignItems:"center",cursor:"ew-resize"},c),children:u})}import{Fragment as Js,jsx as De,jsxs as gn}from"react/jsx-runtime";function Lp({gridCols:e,gridRows:t,gridModified:n,accentColor:o,onColsChange:r,onRowsChange:s}){return De(Un,{style:{width:100},children:gn("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 4px"},children:[De("input",{type:"number",min:1,max:12,value:e,onChange:i=>r(parseInt(i.target.value)||1),style:y(f({},wn),{width:32,textAlign:"center",padding:2})}),De("span",{style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:n?o:"#999",fontWeight:n?600:400,fontSize:11,margin:"0 4px"},children:"\xD7"}),De("input",{type:"number",min:1,max:12,value:t,onChange:i=>s(parseInt(i.target.value)||1),style:y(f({},wn),{width:32,textAlign:"center",padding:2})})]})})}function ic({element:e,getValue:t,getOriginalValue:n,handleChange:o,isModified:r,onResetProperty:s,isCollapsed:i,onToggle:l,sectionHeaderStyle:a,activeDropdown:d,onDropdownChange:c,panelContentRef:u,accentColor:p,onFieldHover:g,preferredUnit:v,onUnitCycle:x}){let w=c,I=t("display"),N=t("flex-direction"),H=sc(I,N),O=I==="flex"||I==="inline-flex",L=I==="grid",Y=O||L,re=N==="column"||N==="column-reverse",Z=t("width"),_=t("height"),B=r("width")?Z:Ai(e,"width"),h=r("height")?_:Ai(e,"height"),A=Vs(Z,B),k=Vs(_,h),be=t("min-width"),K=t("max-width"),de=t("min-height"),F=t("max-height"),me=Gr(t("padding")),R=t("gap"),ie=t("row-gap"),Se=t("column-gap"),Pe=t("grid-template-columns"),_e=t("grid-template-rows"),Ze=t("overflow"),Oe=Pe.split(/\s+/).filter(W=>W&&W!=="none").length||1,he=_e.split(/\s+/).filter(W=>W&&W!=="none").length||1,[Fe,rt]=nc(!1),ht=d!==null,Jt=ht||Fe,Q=ht?.3:Fe?.65:1,ne=({mode:W,icon:fe,active:Le})=>De("button",{type:"button",onClick:()=>ac(W,o),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:Le?gr(p,.15):"transparent",color:Le?p:"#64748b",cursor:"pointer",fontSize:14},children:fe}),Te=(W,fe,Le)=>{Le==="fixed"?o(W,fe):o(W,Gi(Le,fe))},$e=W=>{let fe=Gr(t("padding")),Le=W||"0";o("padding",`${fe.top} ${Le} ${fe.bottom} ${Le}`)},pt=W=>{let fe=Gr(t("padding")),Le=W||"0";o("padding",`${Le} ${fe.right} ${Le} ${fe.left}`)},[Je,ye]=nc({}),ct=go((W,fe)=>Le=>{fe(Le),ye(Gt=>y(f({},Gt),{[W]:Le}))},[]),Ge=go(W=>{ye(fe=>{let Le=f({},fe);return delete Le[W],Le})},[]),_t=go(W=>{let fe=Gr(t("padding"));Xe(e,"padding",`${fe.top} ${W} ${fe.bottom} ${W}`)},[e,t]),dt=go(W=>{let fe=Gr(t("padding"));Xe(e,"padding",`${W} ${fe.right} ${W} ${fe.left}`)},[e,t]),pe=go(W=>fe=>{Xe(e,W,fe)},[e]),se=re?"row":"column",Ce=se==="row"?"row-gap":"column-gap",Re=Ce==="row-gap"?ie||R:Se||R,it=r(Ce)||r("gap"),Me=go(()=>{let fe=Ho(e).find(Gt=>Gt.axis===se);if(fe)return se==="row"?fe.h:fe.w;let Le=ur(e);return se==="row"?Le.row:Le.column},[e,se]),en=go(()=>{let W=t("justify-content");return W==="space-between"?"between":W==="space-around"||W==="space-evenly"?"around":"fixed"},[t])(),pn=go((W,fe)=>{if(W==="fixed"){let Le=Math.max(0,Math.round(Me()*1e3)/1e3),Gt=fe||(Le>0?`${Le}px`:"8px");o("justify-content","normal"),o(Ce,Gt);return}o("justify-content",W==="between"?"space-between":"space-around"),o(Ce,"0px")},[Ce,Me,o]),zn=go(W=>{if(en!=="fixed"){pn("fixed",W);return}o(Ce,W)},[pn,en,Ce,o]),jt=go(W=>{Xe(e,"justify-content","normal"),Xe(e,Ce,W)},[e,Ce]),Ot=W=>W==="center"?1:W==="flex-end"||W==="end"?2:0,hn=Ot(t("justify-content")),vt=Ot(t("align-items")),Vt=re?vt:hn,Qe=re?hn:vt,xo=ji(null),Ke=ji({x:0,y:0}),Tt=ji({col:Vt,row:Qe});Tt.current={col:Vt,row:Qe};let Gn=go((W,fe)=>{let Le=["flex-start","center","flex-end"];re?(o("justify-content",Le[fe]),o("align-items",Le[W])):(o("justify-content",Le[W]),o("align-items",Le[fe]))},[re,o]),So=ji(Gn);So.current=Gn,Cp(()=>{let fe=Le=>{let Gt=xo.current;if(!Gt||!Le.composedPath().includes(Gt))return;Le.preventDefault(),Le.stopPropagation(),Ke.current.x+=Le.deltaX,Ke.current.y+=Le.deltaY;let{col:St,row:yn}=Tt.current,bn=!1;Math.abs(Ke.current.x)>=30&&(St=Math.max(0,Math.min(2,St+(Ke.current.x>0?1:-1))),Ke.current.x=0,Ke.current.y=0,bn=!0),!bn&&Math.abs(Ke.current.y)>=30&&(yn=Math.max(0,Math.min(2,yn+(Ke.current.y>0?1:-1))),Ke.current.x=0,Ke.current.y=0,bn=!0),bn&&(St!==Tt.current.col||yn!==Tt.current.row)&&So.current(St,yn)};return document.addEventListener("wheel",fe,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",fe,{capture:!0})},[]);let Fn=()=>De("div",{ref:xo,onMouseEnter:()=>{rt(!0),u.current&&(u.current.style.overflowY="hidden")},onMouseLeave:()=>{rt(!1),u.current&&(u.current.style.overflowY="auto")},style:{width:56,height:56,backgroundColor:to,borderRadius:2,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gridTemplateRows:"repeat(3, 1fr)",padding:6,gap:2,touchAction:"none"},children:[0,1,2].map(W=>[0,1,2].map(fe=>De("button",{type:"button",onClick:()=>Gn(fe,W),style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",backgroundColor:"transparent",cursor:"pointer",padding:0},children:fe===Vt&&W===Qe?De("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:fe===0?gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):fe===1?gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"2.5",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1.5",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"4",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"2",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]})}):De("div",{style:{width:5,height:5,borderRadius:"50%",backgroundColor:"#aaa"}})},`${W}-${fe}`)))}),rn=r("grid-template-columns")||r("grid-template-rows");return gn("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[De("div",{style:a,children:De("span",{children:Y?"Auto layout":"Layout"})}),gn("div",{style:{padding:"8px 12px"},children:[gn("div",{style:{display:"flex",gap:2,marginBottom:8,backgroundColor:to,borderRadius:2,padding:2,opacity:Q,transition:"opacity 150ms ease"},children:[De(ne,{mode:"block",icon:De(Ip,{size:16}),active:H==="block"}),De(ne,{mode:"flex-col",icon:De(Rp,{size:16}),active:H==="flex-col"}),De(ne,{mode:"flex-row",icon:De(Tp,{size:16}),active:H==="flex-row"}),De(ne,{mode:"grid",icon:De(Mp,{size:16}),active:H==="grid"})]}),gn("div",{style:{display:"flex",gap:4,marginBottom:8},children:[De(Us,{label:"W",property:"width",cssValue:A==="fixed"?Z:`${Math.round(e.getBoundingClientRect().width)}px`,mode:A,onValueChange:W=>o("width",W),onModeChange:W=>{if(W==="fixed"){let fe=e.getBoundingClientRect();o("width",`${Math.round(fe.width)}px`)}else o("width",Gi(W,Z))},modified:r("width"),dimmed:ht&&d!=="width",dropdownOpen:d==="width",onDropdownChange:W=>w(W?"width":null),panelContentRef:u,accentColor:p,onReset:()=>s("width"),minValue:be!=="none"&&be!=="0px"&&be!=="auto"?be:"",maxValue:K!=="none"&&K!=="auto"?K:"",onMinChange:W=>o("min-width",W||"0"),onMaxChange:W=>o("max-width",W||"none"),onMinReset:()=>s("min-width"),onMaxReset:()=>s("max-width"),minModified:r("min-width"),maxModified:r("max-width")}),De(Us,{label:"H",property:"height",cssValue:k==="fixed"?_:`${Math.round(e.getBoundingClientRect().height)}px`,mode:k,onValueChange:W=>o("height",W),onModeChange:W=>{if(W==="fixed"){let fe=e.getBoundingClientRect();o("height",`${Math.round(fe.height)}px`)}else o("height",Gi(W,_))},modified:r("height"),dimmed:ht&&d!=="height",dropdownOpen:d==="height",onDropdownChange:W=>w(W?"height":null),panelContentRef:u,minValue:de!=="none"&&de!=="0px"&&de!=="auto"?de:"",maxValue:F!=="none"&&F!=="auto"?F:"",onMinChange:W=>o("min-height",W||"0"),onMaxChange:W=>o("max-height",W||"none"),onMinReset:()=>s("min-height"),onMaxReset:()=>s("max-height"),minModified:r("min-height"),maxModified:r("max-height"),accentColor:p,onReset:()=>s("height")})]}),O&&gn("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8},children:[De("div",{style:{opacity:ht?.3:1,transition:"opacity 150ms ease"},children:Fn()}),gn("div",{style:{flex:1,opacity:Q,transition:"opacity 150ms ease"},children:[De("div",{onClick:it?()=>{s(Ce),s("gap")}:void 0,title:it?"Click to reset":void 0,style:{fontSize:9,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:it?p:"#999",fontWeight:it?600:400,marginBottom:2,cursor:it?"pointer":"default"},children:"Gap"}),De("div",{style:{display:"flex",gap:2,marginBottom:4,backgroundColor:to,borderRadius:2,padding:2},children:["fixed","between","around"].map(W=>{let fe=en===W;return De("button",{type:"button",onClick:()=>pn(W),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",border:"none",borderRadius:2,backgroundColor:fe?gr(p,.15):"transparent",color:fe?p:"#64748b",cursor:"pointer",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:fe?600:400,textTransform:"capitalize"},children:W},W)})}),De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:Re,onChange:W=>{Ge("gap"),zn(W)},onPreview:ct("gap",jt),onScrubEnd:()=>Ge("gap"),onReset:()=>{s(Ce),s("gap")},isModified:it,accentColor:p,defaultUnit:v,children:N==="column"||N==="column-reverse"?De(rc,{size:12,strokeWidth:it?2.5:1.5}):De(oc,{size:12,strokeWidth:it?2.5:1.5})}),De(mo,{property:Ce,value:Je.gap||(en==="fixed"?Re:`${Math.max(0,Math.round(Me()*1e3)/1e3)}px`),onChange:W=>zn(W),isModified:it||"gap"in Je,style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]})]}),L&&gn("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8,opacity:Q,transition:"opacity 150ms ease"},children:[De(Lp,{gridCols:Oe,gridRows:he,gridModified:rn,accentColor:p,onColsChange:W=>o("grid-template-columns",`repeat(${W}, 1fr)`),onRowsChange:W=>o("grid-template-rows",`repeat(${W}, 1fr)`)}),gn("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:Se||R,onChange:W=>{Ge("column-gap"),o("column-gap",W)},onPreview:ct("column-gap",pe("column-gap")),onScrubEnd:()=>Ge("column-gap"),onReset:()=>s("column-gap"),isModified:r("column-gap"),accentColor:p,defaultUnit:v,children:De(oc,{size:12,strokeWidth:r("column-gap")?2.5:1.5})}),De(mo,{property:"column-gap",value:Je["column-gap"]||Se||R,onChange:W=>o("column-gap",W),isModified:r("column-gap")||"column-gap"in Je,placeholder:"col",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})}),De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:ie||R,onChange:W=>{Ge("row-gap"),o("row-gap",W)},onPreview:ct("row-gap",pe("row-gap")),onScrubEnd:()=>Ge("row-gap"),onReset:()=>s("row-gap"),isModified:r("row-gap"),accentColor:p,defaultUnit:v,children:De(rc,{size:12,strokeWidth:r("row-gap")?2.5:1.5})}),De(mo,{property:"row-gap",value:Je["row-gap"]||ie||R,onChange:W=>o("row-gap",W),isModified:r("row-gap")||"row-gap"in Je,placeholder:"row",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]})]}),Y&&gn("div",{onMouseEnter:()=>g==null?void 0:g("padding"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:4,marginBottom:8,opacity:Q,transition:"opacity 150ms ease"},children:[De(Un,{style:{flex:1},dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:me.left,onChange:W=>{Ge("padding-h"),$e(W)},onPreview:ct("padding-h",_t),onScrubEnd:()=>Ge("padding-h"),onReset:()=>s("padding"),isModified:r("padding"),accentColor:p,defaultUnit:v,snapSteps:Ys,children:De(Ep,{size:12,strokeWidth:r("padding")?2.5:1.5})}),De(mo,{property:"padding",value:Je["padding-h"]||me.left,onChange:W=>$e(W),isModified:r("padding")||"padding-h"in Je,placeholder:"H pad",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})}),De(Un,{style:{flex:1},dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:me.top,onChange:W=>{Ge("padding-v"),pt(W)},onPreview:ct("padding-v",dt),onScrubEnd:()=>Ge("padding-v"),onReset:()=>s("padding"),isModified:r("padding"),accentColor:p,defaultUnit:v,snapSteps:Ys,children:De(kp,{size:12,strokeWidth:r("padding")?2.5:1.5})}),De(mo,{property:"padding",value:Je["padding-v"]||me.top,onChange:W=>pt(W),isModified:r("padding")||"padding-v"in Je,placeholder:"V pad",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]}),gn("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",opacity:Q,transition:"opacity 150ms ease"},children:[De("input",{type:"checkbox",checked:Ze==="hidden",onChange:W=>o("overflow",W.target.checked?"hidden":"visible"),style:{margin:0,accentColor:p}}),"Clip content"]})]})]})}import{AlignCenter as Ap,AlignJustify as Pp,AlignLeft as Op,AlignRight as Bp,Baseline as Dp,ChevronDown as _p,WholeWord as Hp}from"lucide-react";import{jsx as kt,jsxs as Fo}from"react/jsx-runtime";var lc={100:"Thin",200:"Extra Light",300:"Light",400:"Regular",500:"Medium",600:"Semi Bold",700:"Bold",800:"Extra Bold",900:"Black"};function cc({element:e,getValue:t,handleChange:n,isModified:o,onResetProperty:r,isCollapsed:s,onToggle:i,sectionHeaderStyle:l,accentColor:a,colorVariables:d,activeColorDropdown:c,onColorDropdownChange:u,panelContentRef:p,preferredUnit:g,onUnitCycle:v}){var A;let x=t("font-family"),w=t("font-size"),I=t("font-weight"),N=t("line-height"),H=t("letter-spacing"),O=t("text-align"),L=t("color"),Y=String(I),re=lc[Y]||Y,Z=Fr(e,L),_=L.includes("var(")?null:ni(Z,d),B=({align:k,icon:be})=>{let K=O===k;return kt("button",{type:"button",onClick:()=>n("text-align",k),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:K?gr(a,.15):"transparent",color:K?a:"#64748b",cursor:"pointer"},children:be})},h=((A=x.split(",")[0])==null?void 0:A.trim().replace(/^["']|["']$/g,""))||"System";return Fo("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[kt("div",{style:l,children:kt("span",{children:"Typography"})}),Fo("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[kt(Un,{children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px"},children:[kt("input",{type:"text",value:x,onChange:k=>n("font-family",k.target.value),style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("font-family")?600:400,color:o("font-family")?a:"inherit"}),title:x}),kt(_p,{size:12,style:{color:"#999",flexShrink:0,marginLeft:4}})]})}),Fo("div",{style:{display:"flex",gap:4},children:[kt(Un,{style:{flex:1},children:kt("select",{value:Y,onChange:k=>n("font-weight",k.target.value),style:y(f({},wn),{padding:"6px 8px",paddingLeft:4,paddingRight:20,cursor:"pointer",fontWeight:o("font-weight")?600:400,color:o("font-weight")?a:"inherit"}),children:Object.entries(lc).map(([k,be])=>kt("option",{value:k,children:be},k))})}),kt(Un,{style:{flex:1},children:kt("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:kt(mo,{property:"font-size",value:w,onChange:k=>n("font-size",k),isModified:o("font-size"),min:1,max:999,style:y(f({},wn),{padding:"6px 8px",paddingRight:24,fontWeight:o("font-size")?600:400,color:o("font-size")?a:"inherit"}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:g,onUnitCycle:v})})})]}),Fo("div",{style:{display:"flex",gap:4},children:[kt(Un,{style:{flex:1},children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[kt(Dp,{size:12,style:{color:o("line-height")?a:"#999",flexShrink:0}}),kt(mo,{property:"line-height",value:N,onChange:k=>n("line-height",k),isModified:o("line-height"),step:.1,min:0,placeholder:"Auto",style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("line-height")?600:400,color:o("line-height")?a:"inherit"}),showUnit:!1})]})}),kt(Un,{style:{flex:1},children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[kt(Hp,{size:12,style:{color:o("letter-spacing")?a:"#999",flexShrink:0}}),kt(mo,{property:"letter-spacing",value:H,onChange:k=>n("letter-spacing",k),isModified:o("letter-spacing"),step:.1,placeholder:"\u2014",style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("letter-spacing")?600:400,color:o("letter-spacing")?a:"inherit"}),showUnit:!1})]})})]}),Fo("div",{style:{display:"flex",gap:2,backgroundColor:to,borderRadius:2,padding:2},children:[kt(B,{align:"left",icon:kt(Op,{size:14})}),kt(B,{align:"center",icon:kt(Ap,{size:14})}),kt(B,{align:"right",icon:kt(Bp,{size:14})}),kt(B,{align:"justify",icon:kt(Pp,{size:14})})]}),Fo("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[kt("span",{onClick:o("color")?()=>r("color"):void 0,title:o("color")?"Click to reset":void 0,style:{fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o("color")?a:"#64748b",fontWeight:o("color")?600:400,cursor:o("color")?"pointer":"default",width:40,flexShrink:0},children:"Color"}),kt("div",{style:{flex:1,minWidth:0},children:kt(Ks,{value:L,resolvedValue:Z,colorVariables:d,matchingVariable:_,onChange:k=>n("color",k),accentColor:a,modified:o("color"),panelContentRef:p,isDropdownOpen:c==="color",onDropdownChange:k=>u(k?"color":null)})})]})]})]})}import{Fragment as Fp,jsx as Ee,jsxs as Yt}from"react/jsx-runtime";var uc=[{name:"Background",properties:[{property:"background-color",label:"Color",type:"color"},{property:"opacity",label:"Opacity",type:"number",step:.1,min:0,max:1}]},{name:"Borders",properties:[{property:"border-width",label:"Width",type:"number",min:0,max:20},{property:"border-color",label:"Color",type:"color"},{property:"border-radius",label:"Radius",type:"number",min:0,max:100},{property:"border-style",label:"Style",type:"select",options:["none","solid","dashed","dotted","double"]}]},{name:"Effects",properties:[{property:"box-shadow",label:"Box Shadow",type:"text"},{property:"backdrop-filter",label:"Backdrop Filter",type:"backdrop-filter"},{property:"transform",label:"Transform",type:"text"}]}];function zp(e,t){let n=t.trim().toLowerCase();switch(e){case"opacity":return n==="1";case"border-width":return n==="0px"||n==="0"||n==="medium";case"border-radius":return n==="0px"||n==="0";case"border-style":return n==="none";case"box-shadow":return n==="none";case"backdrop-filter":return n==="none"||n==="";case"letter-spacing":return n==="normal"||n==="0px"||n==="0";case"background-color":return n==="rgba(0, 0, 0, 0)"||n==="transparent";default:return!1}}function Vs(e,t){return!t||e==="auto"||e==="fit-content"||e==="max-content"||e==="min-content"?"hug":e==="100%"||t==="100%"?"fill":"fixed"}function Gi(e,t){switch(e){case"hug":return"fit-content";case"fill":return"100%";case"fixed":{let n=Xo(t);if(typeof n.num=="number"&&!isNaN(n.num)){let o=n.unit==="%"?"px":n.unit||"px";return`${n.num}${o}`}return"auto"}}}function Gr(e){let t=e.split(/\s+/).filter(Boolean);return t.length===1?{top:t[0],right:t[0],bottom:t[0],left:t[0]}:t.length===2?{top:t[0],right:t[1],bottom:t[0],left:t[1]}:t.length===3?{top:t[0],right:t[1],bottom:t[2],left:t[1]}:t.length>=4?{top:t[0],right:t[1],bottom:t[2],left:t[3]}:{top:"0px",right:"0px",bottom:"0px",left:"0px"}}function sc(e,t){return e==="grid"?"grid":e==="flex"||e==="inline-flex"?t==="column"||t==="column-reverse"?"flex-col":"flex-row":"block"}function ac(e,t){switch(e){case"block":t("display","block");break;case"flex-row":t("display","flex"),t("flex-direction","row");break;case"flex-col":t("display","flex"),t("flex-direction","column");break;case"grid":t("display","grid");break}}var to="rgba(0, 0, 0, 0.04)",wn={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};function Us({label:e,property:t,cssValue:n,mode:o,onValueChange:r,onModeChange:s,modified:i,dimmed:l,dropdownOpen:a,onDropdownChange:d,panelContentRef:c,accentColor:u="#3b82f6",onReset:p,minValue:g,maxValue:v,onMinChange:x,onMaxChange:w,onMinReset:I,onMaxReset:N,minModified:H,maxModified:O}){let L=Xo(n),Y=i?L.unit||Wr(t):Wr(t),re=!i&&L.unit&&L.unit!==Y?js(L.num,Y):L.num,[Z,_]=Cn(!1),[B,h]=Cn(String(re)),[A,k]=Cn(!1),be=jn(null),K=jn(null),de=jn(null),F=jn(!1);no(()=>{Z||h(String(re))},[re,Z]),no(()=>{if(!a)return;let Oe=Fe=>{K.current&&!Fe.composedPath().includes(K.current)&&de.current&&!Fe.composedPath().includes(de.current)&&(d==null||d(!1))},he=Fe=>{Fe.key==="Escape"&&(d==null||d(!1))};return document.addEventListener("mousedown",Oe),document.addEventListener("keydown",he),()=>{document.removeEventListener("mousedown",Oe),document.removeEventListener("keydown",he)}},[a,d]),no(()=>{Z&&be.current&&(be.current.focus(),be.current.select())},[Z]);let me=()=>{let Oe=$i(B,t,n,i);r(Oe||`${Math.max(0,parseFloat(B)||0)}${Y}`),_(!1)},R=()=>{if(F.current){F.current=!1;return}me()},ie=Oe=>{if(Oe.key==="Enter"){me();return}if(Oe.key==="Escape"){F.current=!0,h(String(re)),_(!1);return}if(Oe.key==="ArrowUp"||Oe.key==="ArrowDown"){Oe.preventDefault();let he=Oe.key==="ArrowUp"?1:-1,Fe=Oe.shiftKey?8:Oe.altKey?.1:1,rt=parseFloat(B)||0,ht=Math.round(Math.max(0,rt+he*Fe)*1e3)/1e3;h(String(ht)),r(`${ht}${Y}`)}},Se={fixed:"Fixed",hug:"Hug",fill:"Fill"},Pe={fixed:Ee(dc,{size:12}),hug:Ee(Np,{size:12}),fill:Ee(dc,{size:12})},_e=()=>{d==null||d(!a)},Ze=()=>{if(!de.current||!(c!=null&&c.current))return{position:"absolute",top:"100%",left:-4,right:-4,width:"calc(100% + 8px)",marginTop:4};let Oe=de.current.getBoundingClientRect(),he=c.current.getBoundingClientRect();return{position:"fixed",top:Oe.bottom+4,left:he.left+4,width:he.width-8}};return Yt("div",{ref:de,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),style:{flex:1,display:"flex",alignItems:"center",position:"relative",borderRadius:2,border:"1px solid",borderColor:Z?u:A?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease, opacity 150ms ease",opacity:l?.3:1},children:[Ee("span",{onClick:i&&p?p:void 0,title:i?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:i?u:"#999",fontWeight:i?600:400,padding:"0 8px",flexShrink:0,cursor:i?"pointer":"default"},children:e}),o==="fixed"?Z?Ee("input",{ref:be,type:"text",inputMode:"numeric",value:B,onChange:Oe=>h(Oe.target.value),onKeyDown:ie,onBlur:R,style:y(f({},wn),{flex:1,minWidth:0,padding:"4px 2px"})}):Ee("span",{onClick:()=>_(!0),style:{flex:1,padding:"4px 2px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text"},children:re}):Ee("span",{style:{flex:1}}),Yt("button",{type:"button",onClick:_e,style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",border:"none",outline:"none",backgroundColor:"transparent",color:"#999",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"pointer",flexShrink:0},children:[Se[o],Ee(Xs,{size:12})]}),a&&Yt("div",{ref:K,style:y(f({},Ze()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,overflow:"hidden",fontSize:12,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:[Yt("button",{type:"button",onClick:()=>{s("fixed"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="fixed"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="fixed"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.fixed,Yt("span",{children:["Fixed ",t," (",n,")"]}),o==="fixed"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Yt("button",{type:"button",onClick:()=>{s("hug"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="hug"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="hug"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.hug,Ee("span",{children:"Hug contents"}),o==="hug"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Yt("button",{type:"button",onClick:()=>{s("fill"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="fill"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="fill"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.fill,Ee("span",{children:"Fill container"}),o==="fill"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Ee("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",margin:"4px 0"}}),Yt("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[Yt("div",{style:{display:"flex",alignItems:"center",backgroundColor:to,borderRadius:2,padding:"4px 8px"},children:[Ee("span",{onClick:H?Oe=>{Oe.stopPropagation(),I==null||I()}:void 0,title:H?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:H?u:"#999",fontWeight:H?600:400,marginRight:8,flexShrink:0,cursor:H?"pointer":"default"},children:"Min"}),Ee("input",{type:"text",value:g||"",placeholder:"\u2014",onChange:Oe=>x==null?void 0:x(Oe.target.value),onClick:Oe=>Oe.stopPropagation(),style:y(f({},wn),{flex:1,minWidth:0,padding:0,textAlign:"right",color:H?u:"inherit",fontWeight:H?600:400})})]}),Yt("div",{style:{display:"flex",alignItems:"center",backgroundColor:to,borderRadius:2,padding:"4px 8px"},children:[Ee("span",{onClick:O?Oe=>{Oe.stopPropagation(),N==null||N()}:void 0,title:O?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:O?u:"#999",fontWeight:O?600:400,marginRight:8,flexShrink:0,cursor:O?"pointer":"default"},children:"Max"}),Ee("input",{type:"text",value:v||"",placeholder:"\u2014",onChange:Oe=>w==null?void 0:w(Oe.target.value),onClick:Oe=>Oe.stopPropagation(),style:y(f({},wn),{flex:1,minWidth:0,padding:0,textAlign:"right",color:O?u:"inherit",fontWeight:O?600:400})})]})]})]})]})}function Un({children:e,style:t,dimmed:n}){let[o,r]=Cn(!1);return Ee("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:f({position:"relative",borderRadius:2,border:"1px solid",borderColor:o?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease, opacity 150ms ease",opacity:n?.3:1},t),children:e})}function zo({children:e}){let[t,n]=Cn(!1);return Ee("div",{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:t?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease"},children:e})}function mo({property:e,value:t,onChange:n,isModified:o=!1,step:r=1,min:s,max:i,style:l,placeholder:a,showUnit:d=!0,unitStyle:c,preferredUnit:u,onUnitCycle:p}){let g=Xo(t),v=Wr(e),x=Fi[e],I=u&&x&&x.includes(u)?u:v,N=o&&g.unit||I,H=!o&&g.unit&&g.unit!==N?js(g.num,N):g.num,[O,L]=Cn(!1),[Y,re]=Cn(""),Z=R=>{L(!0),re(String(H||"")),requestAnimationFrame(()=>R.target.select())},_=()=>{if(L(!1),Y.trim()){let R=$i(Y,e,t,o);R&&n(R)}},B=R=>{let ie=R.target.value;re(ie);let Se=ie.trim(),Pe=Se.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i),_e=Se.match(/^(-?[\d.]+)$/);if(Pe){let Ze=parseFloat(Pe[1]);isNaN(Ze)||n(`${Ze}${Pe[2].toLowerCase()}`)}else if(_e){let Ze=parseFloat(_e[1]);isNaN(Ze)||n(`${Ze}${N}`)}},h=R=>{if(R.key==="Enter"){if(Y.trim()){let ie=$i(Y,e,t,o);ie&&n(ie)}R.target.blur();return}if(R.key==="ArrowUp"||R.key==="ArrowDown"){R.preventDefault();let ie=R.shiftKey?10:R.altKey?.1:1,Se=(R.key==="ArrowUp"?1:-1)*r*ie,Pe=parseFloat(Y)||H||0,_e=Math.round((Pe+Se)*1e3)/1e3;s!==void 0&&(_e=Math.max(s,_e)),i!==void 0&&(_e=Math.min(i,_e)),re(String(_e)),n(`${_e}${N}`)}},A=/^-?[\d.]/.test(t.trim()),k=O?Y:A?String(H):"",K=O&&/\s*(rem|em|px|%)\s*$/i.test(Y)?"":N,de=p&&(K==="rem"||K==="px"),F={fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",pointerEvents:"none"},me=y(f({},c!=null?c:F),{pointerEvents:"auto",cursor:"pointer"});return Yt(Fp,{children:[Ee("input",{type:"text",inputMode:"decimal",value:k,onFocus:Z,onBlur:_,onChange:B,onKeyDown:h,placeholder:a,style:l}),d&&K&&Ee("span",{style:de?me:c!=null?c:F,onClick:de?p:void 0,title:de?"Click to switch units":void 0,children:K})]})}function Ks({value:e,resolvedValue:t,colorVariables:n,matchingVariable:o,onChange:r,accentColor:s="#3b82f6",modified:i,panelContentRef:l,isDropdownOpen:a,onDropdownChange:d}){let[c,u]=Cn(!1),p=e,[g,v]=Cn(p),[x,w]=Cn(!1),[I,N]=Cn(!1),[H,O]=Cn(!1),L=jn(null),Y=jn(null),re=jn(null),Z=a!==void 0?a:x,_=d||w,B=Eo(()=>{if(!re.current)return{position:"fixed",top:0,left:0,width:200};let R=re.current.getBoundingClientRect();if(l!=null&&l.current){let ie=l.current.getBoundingClientRect();return{position:"fixed",top:R.bottom+4,left:ie.left+4,width:ie.width-8}}return{position:"fixed",top:R.bottom+4,left:R.left,width:R.width}},[l]);no(()=>{c||v(e)},[e,c]),no(()=>{if(!Z&&!I)return;let R=Se=>{re.current&&!Se.composedPath().includes(re.current)&&(_(!1),N(!1))},ie=Se=>{Se.key==="Escape"&&(_(!1),N(!1))};return document.addEventListener("mousedown",R),document.addEventListener("keydown",ie),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",ie)}},[Z,I]),no(()=>{c&&L.current&&(L.current.focus(),L.current.select())},[c]);let h=Ji(()=>{if(!g||g.startsWith("#")||g.startsWith("rgb")||g.startsWith("hsl")||g.startsWith("oklch"))return[];let R=g.toLowerCase();return n.filter(ie=>ie.name.toLowerCase().includes(R)||ie.usage.toLowerCase().includes(R)).slice(0,8)},[g,n]),A=()=>{r(g),u(!1),N(!1)},k=R=>{v(R),R.includes("var")||R.includes("--")||R.length>0&&!R.startsWith("#")?N(!0):N(!1)},be=R=>{v(R.value),r(R.value),_(!1),N(!1),u(!1)},K=()=>{setTimeout(()=>{!Z&&!I&&A()},150)},de=R=>{R.key==="Enter"?A():R.key==="Escape"&&(v(e),u(!1),N(!1))},F=Ji(()=>{let R=t.trim().toLowerCase();if(R.startsWith("#"))return R.length===4?`#${R[1]}${R[1]}${R[2]}${R[2]}${R[3]}${R[3]}`:R.slice(0,7);let ie=R.match(/rgba?\((\d+),?\s*(\d+),?\s*(\d+)/);if(ie){let Pe=parseInt(ie[1],10).toString(16).padStart(2,"0"),_e=parseInt(ie[2],10).toString(16).padStart(2,"0"),Ze=parseInt(ie[3],10).toString(16).padStart(2,"0");return`#${Pe}${_e}${Ze}`}let Se=R.match(/oklch\(\s*([\d.]+)/);if(Se){let Pe=Math.max(0,Math.min(1,parseFloat(Se[1]))),_e=Math.round(Pe*255).toString(16).padStart(2,"0");return`#${_e}${_e}${_e}`}return"#000000"},[t]);return Yt("div",{ref:re,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:c?s:H?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease",overflow:"hidden"},children:[Yt("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[Yt("div",{style:{position:"relative",marginLeft:8,flexShrink:0},children:[Ee("input",{type:"color",value:F,onChange:R=>{let ie=R.target.value;v(ie),r(ie)},style:{width:12,height:12,padding:0,border:"none",cursor:"pointer",opacity:0,position:"absolute",top:0,left:0}}),Ee("div",{style:{width:12,height:12,borderRadius:2,backgroundColor:t,border:"1px solid rgba(0,0,0,0.1)",pointerEvents:"none"}})]}),c?Ee("input",{ref:L,type:"text",value:g,onChange:R=>k(R.target.value),onKeyDown:de,onBlur:K,style:y(f({},wn),{flex:1,minWidth:0})}):Ee("span",{onClick:()=>u(!0),style:{flex:1,minWidth:0,padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:i?s:"inherit"},title:p,children:p}),n.length>0&&Ee("button",{type:"button",onClick:()=>_(!Z),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:24,border:"none",background:"none",cursor:"pointer",color:"#999",flexShrink:0},children:Ee(Xs,{size:12})})]}),I&&h.length>0&&Ee("div",{style:y(f({},B()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:200,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:h.map(R=>Yt("button",{type:"button",onClick:()=>be(R),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:"transparent",color:"#1e293b",cursor:"pointer",textAlign:"left",fontSize:12},children:[Ee("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:R.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),Ee("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:R.name})]},R.name))}),Z&&Ee("div",{ref:Y,style:y(f({},B()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:280,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:n.map(R=>Yt("button",{type:"button",onClick:()=>be(R),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:(o==null?void 0:o.usage)===R.usage||e===R.value?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:(o==null?void 0:o.usage)===R.usage||e===R.value?600:400,cursor:"pointer",textAlign:"left",fontSize:12},children:[Ee("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:R.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),Ee("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:R.name}),((o==null?void 0:o.usage)===R.usage||e===R.value)&&Ee(Yi,{size:14,style:{marginLeft:"auto",flexShrink:0}})]},R.name))})]})}function pc({element:e,elementInfo:t,selector:n,styleModifications:o,dispatch:r,onClose:s,onHover:i,accentColor:l="#3b82f6",toolbarRef:a}){let d=jn(null),c=jn(null),[u,p]=Cn(()=>{try{return!!localStorage.getItem("devtools-panel-position")}catch(Q){return!1}});no(()=>{if(u)return;let Q=setTimeout(()=>p(!0),50);return()=>clearTimeout(Q)},[u]);let[g,v]=Cn(null),[x,w]=Cn(null),I=g!==null||x!==null,[N,H]=Cn("rem"),O=Eo(()=>{H(Q=>Q==="rem"?"px":"rem")},[]),L=jn(new Map),[Y,re]=Cn(""),Z=Ji(()=>Rs(),[]);no(()=>{let Q=ne=>{var $e;if(ne.key!=="Escape")return;let Te=document.activeElement;Te&&(($e=d.current)!=null&&$e.contains(Te))||s()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[s]);let _=jn({top:0,left:0,maxHeight:400}),[,B]=Cn(0),h="devtools-panel-position",A=jn({x:0,y:0}),k=jn(null),be=jn(!1);no(()=>{try{let Q=localStorage.getItem(h);if(Q){let ne=JSON.parse(Q);typeof ne.top=="number"&&typeof ne.left=="number"&&(be.current=!0,_.current=y(f({},_.current),{top:ne.top,left:ne.left}))}}catch(Q){}},[]),no(()=>{let Q=Te=>{var Me;let $e=k.current;if(!$e)return;let pt=$e.startOffsetX+(Te.clientX-$e.startX),Je=$e.startOffsetY+(Te.clientY-$e.startY),ye=280,ct=16,Ge=Math.max(ct,Math.min(window.innerWidth-ye-ct,_.current.left+pt)),_t=Math.max(ct,_.current.top+Je);A.current={x:Ge-_.current.left,y:_t-_.current.top};let dt=d.current,pe=dt==null?void 0:dt.parentElement;if(!pe)return;pe.style.top=`${_t}px`,pe.style.left=`${Ge}px`;let se=(Me=a==null?void 0:a.current)==null?void 0:Me.getBoundingClientRect(),Ce=window.innerHeight-16;se&&Ge+ye>se.left&&(Ce=se.top-8);let Re=Math.max(0,_t),it=Math.max(200,Ce-Re);dt&&(dt.style.maxHeight=`${it}px`)},ne=()=>{if(!k.current)return;let Te=_.current.top+A.current.y,$e=_.current.left+A.current.x;_.current=y(f({},_.current),{top:Te,left:$e}),A.current={x:0,y:0},be.current=!0;try{localStorage.setItem(h,JSON.stringify({top:Te,left:$e}))}catch(pt){}k.current=null};return window.addEventListener("mousemove",Q),window.addEventListener("mouseup",ne),()=>{window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",ne)}},[]);let K=Eo(Q=>{Q.button!==0||Q.target.closest("button")||(Q.preventDefault(),k.current={startX:Q.clientX,startY:Q.clientY,startOffsetX:A.current.x,startOffsetY:A.current.y})},[]);no(()=>{A.current={x:0,y:0};let Q=($e=!1)=>{var Ce;let pt=d.current,Je=280,ye=8,ct,Ge;if(be.current)ct=_.current.top,Ge=_.current.left;else{let Re=e.getBoundingClientRect();Ge=Re.right+ye,ct=Re.top,Ge+Je>window.innerWidth-ye&&(Ge=Re.left-Je-ye),Ge<ye&&(Ge=Math.max(ye,(window.innerWidth-Je)/2))}let _t=(Ce=a==null?void 0:a.current)==null?void 0:Ce.getBoundingClientRect(),dt=window.innerHeight-16;_t&&Ge+Je>_t.left&&(dt=_t.top-ye);let pe=Math.max(0,ct),se=Math.max(200,dt-pe);if(_.current={top:ct,left:Ge,maxHeight:se},$e&&pt){let Re=pt.parentElement;Re&&!be.current&&(Re.style.top=`${ct+A.current.y}px`,Re.style.left=`${Ge+A.current.x}px`),pt.style.maxHeight=`${se}px`}else B(Re=>Re+1)};Q(!1);let ne=()=>Q(!0),Te=()=>Q(!1);return window.addEventListener("scroll",ne,{passive:!0}),window.addEventListener("resize",Te,{passive:!0}),()=>{window.removeEventListener("scroll",ne),window.removeEventListener("resize",Te)}},[e]),no(()=>{let Q=d.current;if(!Q)return;let ne=Te=>{let $e=c.current;if(!$e){Te.preventDefault();return}let{scrollTop:pt,scrollHeight:Je,clientHeight:ye}=$e,ct=pt<=0&&Te.deltaY<0,Ge=pt+ye>=Je&&Te.deltaY>0;(ct||Ge)&&Te.preventDefault()};return Q.addEventListener("wheel",ne,{passive:!1}),()=>Q.removeEventListener("wheel",ne)},[]);let de=Ji(()=>o.find(Q=>Q.selector===n),[o,n]),F=Eo(Q=>{let ne=de==null?void 0:de.changes.find(Te=>Te.property===Q);return ne?ne.modified:Li(e,Q)},[e,de]),me=Eo((Q,ne)=>{if(!Q.includes("color"))return ne;let Te=ne.trim(),$e=Z.find(Je=>Je.usage===Te||Je.name===Te),pt=($e==null?void 0:$e.value)||Te;return Fr(e,pt)},[Z,e]),R=Eo(Q=>{if(L.current.has(Q))return L.current.get(Q);let ne=de==null?void 0:de.changes.find($e=>$e.property===Q);if(ne)return ne.original;let Te=Li(e,Q);return L.current.set(Q,Te),Te},[e,de]),ie=Eo((Q,ne)=>{let Te=R(Q),$e=me(Q,ne);Xe(e,Q,$e),Q==="backdrop-filter"&&Xe(e,"-webkit-backdrop-filter",$e),r({type:"MODIFY_STYLE",payload:{selector:n,element:t,property:Q,original:Te,modified:$e}})},[e,n,t,r,me,R]),Se=Eo(Q=>{let ne=o.find($e=>$e.selector===n);ne!=null&&ne.changes.find($e=>$e.property===Q)&&e instanceof HTMLElement&&(e.style.removeProperty(Q),r({type:"CLEAR_STYLE",payload:{selector:n,property:Q}}),L.current.delete(Q))},[e,n,o,r]),Pe=Eo(()=>{let Q=Y.split(";").map(ne=>ne.trim()).filter(ne=>ne);for(let ne of Q){let Te=ne.indexOf(":");if(Te>0){let $e=ne.slice(0,Te).trim(),pt=ne.slice(Te+1).trim();$e&&pt&&ie($e,pt)}}re("")},[Y,ie]),_e=Eo(Q=>{var ne;return(ne=de==null?void 0:de.changes.some(Te=>Te.property===Q))!=null?ne:!1},[de]),Ze=Q=>{var Je;let ne=F(Q.property),Te=_e(Q.property),$e=!Te&&zp(Q.property,ne),pt={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};if($e&&Q.type!=="backdrop-filter")return Ee(zo,{modified:!1,children:Ee("input",{type:"text",value:"",placeholder:"\u2014",onFocus:()=>{},onChange:ye=>ie(Q.property,ye.target.value),style:y(f({},pt),{color:"#999"})})});switch(Q.type){case"color":{let ye=Fr(e,ne),ct=ne.includes("var(")?null:ni(ye,Z);return Ee(Ks,{value:ne,resolvedValue:ye,colorVariables:Z,matchingVariable:ct,onChange:Ge=>ie(Q.property,Ge),accentColor:l,modified:Te,panelContentRef:c,isDropdownOpen:x===Q.property,onDropdownChange:Ge=>w(Ge?Q.property:null)})}case"number":{if(!!Fi[Q.property])return Ee(zo,{modified:Te,children:Ee(mo,{property:Q.property,value:ne,onChange:Ge=>ie(Q.property,Ge),isModified:Te,min:Q.min,max:Q.max,step:Q.step||1,style:y(f({},pt),{paddingRight:32}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:N,onUnitCycle:O})});let{num:ct}=Xo(ne);return Ee(zo,{modified:Te,children:Ee("input",{type:"number",value:ct,min:Q.min,max:Q.max,step:Q.step||1,onChange:Ge=>ie(Q.property,Ge.target.value),style:pt})})}case"select":return Ee(zo,{modified:Te,children:Yt("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[Ee("select",{value:ne,onChange:ye=>ie(Q.property,ye.target.value),style:y(f({},pt),{cursor:"pointer",paddingLeft:4,paddingRight:24,appearance:"none",WebkitAppearance:"none"}),children:(Je=Q.options)==null?void 0:Je.map(ye=>Ee("option",{value:ye,children:ye},ye))}),Ee("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:"#999",display:"flex",alignItems:"center"},children:Ee(Xs,{size:12})})]})});case"spacing":return Ee(zo,{modified:Te,children:Ee("input",{type:"text",value:ne,onChange:ye=>ie(Q.property,ye.target.value),placeholder:"e.g., 10px or 10px 20px",style:pt})});case"backdrop-filter":return Ee(tc,{value:ne,onChange:ye=>ie(Q.property,ye),accentColor:l,modified:Te,panelContentRef:c});default:return Ee(zo,{modified:Te,children:Ee("input",{type:"text",value:ne,onChange:ye=>ie(Q.property,ye.target.value),style:pt})})}},Oe=t.reactComponent||t.tagName,he={position:"fixed",top:_.current.top,left:_.current.left,width:280,maxHeight:_.current.maxHeight,backgroundColor:"#eaeaea",borderWidth:3,borderStyle:"solid",borderColor:"transparent",boxSizing:"content-box",zIndex:10002,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontSize:12,overflow:"visible",display:"flex",flexDirection:"column",opacity:u?1:0,transition:"opacity 150ms ease"},Fe={display:"flex",alignItems:"center",justifyContent:"space-between",margin:4,padding:"4px 5px 4px 10px",backgroundColor:l,color:"#ffffff",cursor:k.current?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},rt={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 12px 6px",userSelect:"none",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:600,color:"#475569"},ht={display:"flex",alignItems:"center",padding:"4px 12px",gap:8},Jt={width:80,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",flexShrink:0};return Ee("div",{"data-devtools":"panel-wrapper",style:{position:"fixed",top:_.current.top+A.current.y,left:_.current.left+A.current.x,zIndex:10002,pointerEvents:"none"},children:Yt("div",{ref:d,"data-devtools":"panel",style:y(f({},he),{position:"relative",top:0,left:0,zIndex:0,pointerEvents:"auto"}),onMouseEnter:()=>i==null?void 0:i("element"),onMouseLeave:()=>i==null?void 0:i(null),children:[Ee("div",{"aria-hidden":"true",style:zi()}),Yt("div",{style:Fe,onMouseDown:K,children:[Ee("div",{style:{display:"flex",alignItems:"center",gap:3,overflow:"hidden",minWidth:0},children:Ee("span",{style:{fontWeight:600,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:Oe})}),Ee("button",{type:"button",onClick:s,title:"Close",style:{background:"none",border:"none",cursor:"pointer",fontSize:16,color:"#ffffff",padding:"0 4px",lineHeight:1,flexShrink:0},children:"\xD7"})]}),Yt("div",{ref:c,style:{flex:1,overflowY:"auto",margin:"0 3px 3px"},children:[Ee("div",{style:{opacity:x?.3:1,transition:"opacity 150ms ease"},children:Ee(ic,{element:e,getValue:F,getOriginalValue:R,handleChange:ie,isModified:_e,onResetProperty:Se,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:rt,activeDropdown:g,onDropdownChange:v,panelContentRef:c,accentColor:l,onFieldHover:i,preferredUnit:N,onUnitCycle:O})}),Ee("div",{style:{opacity:g?.3:1,transition:"opacity 150ms ease"},children:Ee(cc,{element:e,getValue:F,handleChange:ie,isModified:_e,onResetProperty:Se,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:rt,accentColor:l,colorVariables:Z,activeColorDropdown:x,onColorDropdownChange:w,panelContentRef:c,preferredUnit:N,onUnitCycle:O})}),uc.map((Q,ne)=>{let Te=ne===uc.length-1,$e=x&&Q.properties.some(Je=>Je.property===x);return Yt("div",{style:{borderBottom:Te?"none":"1px solid rgba(0,0,0,0.08)",opacity:I&&!$e?.3:1,transition:"opacity 150ms ease"},children:[Ee("div",{style:rt,children:Ee("span",{children:Q.name})}),Ee("div",{style:{padding:"4px 0"},children:Q.properties.map(Je=>{let ye=_e(Je.property),ct=$e&&Je.property!==x;return Yt("div",{style:y(f({},ht),{opacity:ct?.3:1,transition:"opacity 150ms ease"}),children:[Ee("span",{onClick:ye?()=>Se(Je.property):void 0,title:ye?"Click to reset":void 0,style:y(f({},Jt),{color:ye?l:"#64748b",fontWeight:ye?600:400,cursor:ye?"pointer":"default"}),children:Je.label}),Ee("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:Ze(Je)})]},Je.property)})})]},Q.name)}),Yt("div",{style:{opacity:I?.3:1,transition:"opacity 150ms ease"},children:[Ee("div",{style:rt,children:Ee("span",{children:"Raw CSS"})}),Yt("div",{style:{padding:"8px 12px"},children:[Ee("textarea",{value:Y,onChange:Q=>re(Q.target.value),placeholder:"property: value; ...",style:{width:"100%",height:60,padding:8,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"1px solid rgba(0,0,0,0.1)",borderRadius:2,resize:"vertical",outline:"none"}}),Y.trim()&&Ee("button",{type:"button",onClick:Pe,style:{marginTop:4,padding:"4px 8px",width:"100%",fontSize:11,border:"none",borderRadius:2,backgroundColor:l,color:"#fff",cursor:"pointer",opacity:Y.trim()?1:.5},children:"Apply"})]})]})]})]})})}import{useEffect as $p,useLayoutEffect as Wp,useState as jp}from"react";import{Fragment as Vp,jsx as hr,jsxs as Jp}from"react/jsx-runtime";var qs=["flex-start","center","flex-end"],Zs=["flex-start","center","flex-end"];function Gp(e){return e==="normal"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Yp(e){return e==="normal"||e==="stretch"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function fc(e){let t=Array.from(e.children);if(t.length===0)return null;let n=1/0,o=1/0,r=-1/0,s=-1/0;for(let i of t){let l=i.getBoundingClientRect();l.width===0&&l.height===0||(l.top<n&&(n=l.top),l.left<o&&(o=l.left),l.bottom>r&&(r=l.bottom),l.right>s&&(s=l.right))}return n===1/0?null:new DOMRect(o,n,s-o,r-n)}function gc({element:e,modifier:t,accentColor:n,refreshKey:o=0}){let[r,s]=jp(null);if($p(()=>{if(!e){s(null);return}let x=()=>s(fc(e));return x(),window.addEventListener("scroll",x,{passive:!0}),window.addEventListener("resize",x,{passive:!0}),()=>{window.removeEventListener("scroll",x),window.removeEventListener("resize",x)}},[e]),Wp(()=>{e&&s(fc(e))},[e,o]),!r)return null;let i=r,l=window.getComputedStyle(e),a=l.display;if(a!=="flex"&&a!=="inline-flex")return null;let d=l.flexDirection,c=d==="column"||d==="column-reverse"?"vertical":"horizontal",u=c==="horizontal"?"vertical":"horizontal",p=[];if(t==="shift"){let x=Gp(l.justifyContent);if(x){let w=qs.indexOf(x);c==="horizontal"?(w>0&&p.push("left"),w<qs.length-1&&p.push("right")):(w>0&&p.push("up"),w<qs.length-1&&p.push("down"))}}else{let x=Yp(l.alignItems);if(x){let w=Zs.indexOf(x);u==="horizontal"?(w>0&&p.push("left"),w<Zs.length-1&&p.push("right")):(w>0&&p.push("up"),w<Zs.length-1&&p.push("down"))}}if(p.length===0)return null;let g=14,v=7;return hr(Vp,{children:p.map(x=>{let w,I;switch(x){case"right":w=i.right+g,I=i.top+i.height/2;break;case"left":w=i.left-g,I=i.top+i.height/2;break;case"down":w=i.left+i.width/2,I=i.bottom+g;break;case"up":w=i.left+i.width/2,I=i.top-g;break}let N=x==="right"?0:x==="left"?180:x==="down"?90:-90,H={position:"fixed",left:w-v,top:I-v,width:v*2,height:v*2,pointerEvents:"none",zIndex:9997};return hr("div",{"data-devtools":"swipe-hint",style:H,children:hr("svg",{width:v*2,height:v*2,viewBox:"-7 -7 14 14",style:{overflow:"visible"},children:Jp("g",{transform:`rotate(${N})`,children:[hr("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round"}),hr("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),hr("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:n,strokeWidth:"1.5",strokeLinecap:"round"}),hr("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:n,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})},x)})})}import{useEffect as Up,useLayoutEffect as Kp,useState as Xp}from"react";import{jsx as Qs,jsxs as ea}from"react/jsx-runtime";function qp(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function mc({element:e,fontSize:t,lineHeight:n,accentColor:o,hoveredProperty:r,draggingProperty:s,cursorViewport:i}){let[l,a]=Xp(null);if(Up(()=>{if(!e){a(null);return}let I=()=>{a(zr(e))};return I(),window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I,{passive:!0}),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I)}},[e]),Kp(()=>{e&&a(zr(e))},[e,t,n]),!l)return null;let d=l.width,c=l.height,u=qp(o,.2),p=s!=null?s:r,g=8,v=2,x={position:"fixed",top:l.top,left:l.left,width:d,height:c,pointerEvents:"none",zIndex:9996,overflow:"visible"},w=I=>I==="font-size"?`${Math.round(t)}`:(t>0?n/t:1.2).toFixed(2).replace(/\.?0+$/,"");return ea("div",{"data-devtools":"text-handles",style:x,children:[ea("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${d} ${c}`,children:[Qs("rect",{x:"0.5",y:"0.5",width:Math.max(0,d-1),height:Math.max(0,c-1),fill:"none",stroke:u,strokeWidth:"1"}),(p==="font-size"||!p)&&Qs("rect",{x:d-v/2,y:c/2-g/2,width:v,height:g,fill:o,stroke:"#ffffff",strokeWidth:p==="font-size"?4:2,paintOrder:"stroke"}),(p==="line-height"||!p)&&Qs("rect",{x:d/2-g/2,y:c-v/2,width:g,height:v,fill:o,stroke:"#ffffff",strokeWidth:p==="line-height"?4:2,paintOrder:"stroke"})]}),i&&p&&(()=>{let I=p==="font-size"?"Aa":"Lh",N=w(p);return ea("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:[I," ",N]})})()]})}import{Fragment as Jr,jsx as ft,jsxs as Yr}from"react/jsx-runtime";var hc=8,ta=[0,1,2,4,8,12,16,20,24,28,32],na="devtools-active-text";function yc(e,t,n=0,o,r){let s=e.left+window.scrollX+4,i=t==="top-left"?e.top+window.scrollY-eo-n*eo+4:e.bottom+window.scrollY+4-1+n*eo,l=window.scrollY+4,a=window.scrollY+window.innerHeight-eo-4,d=90,c=!1;if(o&&r!==void 0){let u=o.getBoundingClientRect();if(e.left+4+r+4+d>u.left){let g=window.scrollY+u.top-eo-4;g<a&&(a=g,c=!0)}}return i<l?i=e.top+window.scrollY+4:i>a&&(i=c?a:Math.max(e.top+window.scrollY+4,a)),{x:s,y:i}}function bc({state:e,dispatch:t,onScreenshot:n,inFlightAnnotationIds:o,activeAnnotationIds:r,queuePositionMap:s,inFlightStyleSelectors:i,inFlightSelectorColors:l,onAttachImages:a,onReply:d,onViewThread:c,onCloseThread:u,onModelComponentsAdd:p,onModelComponentFocus:g,onModelComponentHover:v,modelComponentNames:x,modelPanelHoveredComponent:w,modelSpacingTokenHover:I,highlightedAnnotationIds:N,focusedThreadAnnotationId:H,externalCanvasRef:O,toolbarRef:L}){var et,Ue,Rt,Ct,gt,zt,xt,ln,lo;let{canvasRef:Y,redrawAll:re,resizeCanvas:Z}=bl(),_=un(m=>{Y.current=m,O&&(O.current=m)},[O,Y]),B=Qt(!1);kn(()=>{let m=Y.current;if(!m)return;let b=()=>{B.current&&(B.current=!1,m.style.pointerEvents="")},G=M=>{M.button===0&&B.current&&b()};return window.addEventListener("mousedown",G),()=>window.removeEventListener("mousedown",G)},[Y]);let[h,A]=bt(!1),[k,be]=bt(()=>{if(typeof window=="undefined")return null;try{let m=localStorage.getItem(na);return m?JSON.parse(m):null}catch(m){return null}}),[K,de]=bt(null),[F,me]=bt(null),[R,ie]=bt(null),Se=Qt(null),Pe=Qt(null),_e=Qt({x:0,y:0}),Ze=Qt([]),Oe=Qt(0),[he,Fe]=bt(null),[rt,ht]=bt(new Map),Jt=Qt(0),Q=Qt(null),[ne,Te]=bt(null),[$e,pt]=bt(null),[Je,ye]=bt(null),[ct,Ge]=bt(null),_t=Qt({isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null}),[dt,pe]=bt(null),[se,Ce]=bt(null),[Re,it]=bt(null),[Me,Wt]=bt(null),en=Qt({x:0,y:0}),[pn,zn]=bt({x:0,y:0}),jt=Qt({isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0}),[Ot,hn]=bt(null),[vt,Vt]=bt(null),[Qe,xo]=bt(null),[Ke,Tt]=bt(!1),[Gn,So]=bt(0),[Fn,rn]=bt(null),Tn=Qt({isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null}),[W,fe]=bt(null),[Le,Gt]=bt(null),[St,yn]=bt(null),bn=Qt({isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null}),[Ut,Pn]=bt(null),[vn,Io]=bt(null),[yt,Ro]=bt(null),io=vl(),jo=Qt(l);jo.current=l;let qn=un(m=>{let b=jo.current;if(!b||b.size===0)return!1;for(let G of b.keys())try{if(m.matches(G))return!0}catch(M){}return!1},[]),Mn=Qt(e);Mn.current=e;let Lo=Qt(k);Lo.current=k;let Zn=Qt([]),Kt=Qt(n);Kt.current=n;let[Bt,Xt]=bt(null),sn=e.selectedAnnotationIds;Zn.current=sn;let $n=un((m,b=!1)=>{t({type:"SELECT_ANNOTATION",payload:{id:m,addToSelection:b}})},[t]),wo=un(()=>{t({type:"SELECT_ANNOTATION",payload:{id:null}})},[t]),[In,Ao]=bt(null),[an,Go]=bt({x:window.scrollX,y:window.scrollY});kn(()=>(Z(),window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)),[Z]),kn(()=>{let m=()=>{Go({x:window.scrollX,y:window.scrollY})};return window.addEventListener("scroll",m,{passive:!0}),()=>window.removeEventListener("scroll",m)},[]),kn(()=>{k?localStorage.setItem(na,JSON.stringify(k)):localStorage.removeItem(na)},[k]),xl(k,be,K,e.annotations,t);let Po=Qt(he);Po.current=he,kn(()=>{if(e.activeTool!=="model"||!e.isAnnotating)return;let m=b=>{if(!b.altKey||!Po.current)return;b.preventDefault();let G=b.deltaY>0?-1:1;Jt.current=Math.max(0,Jt.current+G);let M=Q.current;if(M){let C=Ii(M,Jt.current);Fe(C)}};return window.addEventListener("wheel",m,{passive:!1}),()=>window.removeEventListener("wheel",m)},[e.activeTool,e.isAnnotating]),kn(()=>{e.activeTool!=="model"&&(Fe(null),ht(new Map),Jt.current=0,Q.current=null)},[e.activeTool]),kn(()=>{var G;let m=(G=he==null?void 0:he.name)!=null?G:null,b=m&&(x!=null&&x.has(m))?m:null;v==null||v(b)},[he,x,v]);let[so,Er]=bt(null);kn(()=>{var G;if(!w){Er(null);return}let m=_r(w.name),b=w.instanceIndex;Er((G=m[b%m.length])!=null?G:null)},[w]);let[ao,Qo]=bt([]);kn(()=>{var m,b;if(!I){Qo([]);return}(b=(m=I.token)==null?void 0:m.bindings)!=null&&b.length?Qo(ks(I.token)):Qo(Cs(I.px))},[I]);let Yo=Qt(null),On=Qt(null);Yo.current=Ot,On.current=vt,kn(()=>{let m=["flex-start","center","flex-end"],b=["flex-start","center","flex-end"],M=null,C=!1,$=null,oe=null,j=(xe,ze)=>{let at=dr(xe,ze);for(;at&&at!==document.documentElement;){let wt=window.getComputedStyle(at).display;if(wt==="flex"||wt==="inline-flex")return at;at=at.parentElement}return null},te=xe=>{let ze=window.getComputedStyle(xe).flexDirection;return ze==="column"||ze==="column-reverse"?"vertical":"horizontal"},E=xe=>{let ze=xe.getAttribute("data-pm");return ze||(ze=Math.random().toString(36).substring(2,8),xe.setAttribute("data-pm",ze)),{selector:`[data-pm="${ze}"]`,durableSelector:Jn(xe)}},T=()=>{C=!0,M&&clearTimeout(M),M=setTimeout(()=>{C=!1,M=null},300)},X=(xe,ze,ut)=>{let at=te(xe);if(ze===at){let qe=window.getComputedStyle(xe).justifyContent,Ht=qe==="normal"||qe==="flex-start"||qe==="start"?"flex-start":qe==="flex-end"||qe==="end"?"flex-end":qe==="center"?"center":null;if(!Ht)return;let fn=m.indexOf(Ht)+ut;if(fn<0||fn>=m.length)return;let Do=m[fn],{selector:tr,durableSelector:as}=E(xe);Xe(xe,"justify-content",Do),t({type:"MODIFY_STYLES_BATCH",payload:{selector:tr,durableSelector:as,element:Nn(xe),changes:[{property:"justify-content",original:qe,modified:Do}]}})}else{let qe=window.getComputedStyle(xe).flexDirection,Ht=at==="horizontal"?"column":"row",{selector:co,durableSelector:fn}=E(xe);Xe(xe,"flex-direction",Ht),t({type:"MODIFY_STYLES_BATCH",payload:{selector:co,durableSelector:fn,element:Nn(xe),changes:[{property:"flex-direction",original:qe,modified:Ht}]}})}So(wt=>wt+1)},z=(xe,ze,ut)=>{let wt=te(xe)==="horizontal"?"vertical":"horizontal";if(ze!==wt)return;let Ht=window.getComputedStyle(xe).alignItems,co=Ht==="normal"||Ht==="stretch"||Ht==="flex-start"||Ht==="start"?"flex-start":Ht==="flex-end"||Ht==="end"?"flex-end":Ht==="center"?"center":null;if(!co)return;let Do=b.indexOf(co)+ut;if(Do<0||Do>=b.length)return;let tr=b[Do],{selector:as,durableSelector:fd}=E(xe);Xe(xe,"align-items",tr),t({type:"MODIFY_STYLES_BATCH",payload:{selector:as,durableSelector:fd,element:Nn(xe),changes:[{property:"align-items",original:Ht,modified:tr}]}}),So(gd=>gd+1)},J=20,U=null,q=null,we=0,We=(xe,ze,ut)=>{let at=j(ze,ut);rn(at?{modifier:xe,target:at}:null)},tt=xe=>{if(!(e.activeTool!=="hand"||!e.isAnnotating)){if(xe.key==="Shift"&&!xe.altKey){let ze=en.current;We("shift",ze.x,ze.y)}else if(xe.key==="Alt"&&!xe.shiftKey){let ze=en.current;We("alt",ze.x,ze.y)}}},ot=xe=>{if(e.activeTool!=="hand"||!e.isAnnotating)return;let ze=xe.shiftKey&&!xe.altKey,ut=xe.altKey&&!xe.shiftKey;if(!ze&&!ut||xe.buttons!==0){U=null,q=null,we=0,$=null,oe=null,rn(null);return}if($===null&&($=xe.clientX,oe=xe.clientY,We(ze?"shift":"alt",xe.clientX,xe.clientY)),C)return;U===null&&(U=xe.clientX,q=xe.clientY,we=0);let at=xe.clientX-U,wt=xe.clientY-q,qe=Math.abs(at)>=Math.abs(wt)?at:wt;if(Math.abs(qe)>3){let tr=qe>0?1:-1;if(we!==0&&tr!==we){U=xe.clientX,q=xe.clientY,we=0;return}we=tr}if(Math.abs(at)<J&&Math.abs(wt)<J)return;let Ht=j($,oe);if(!Ht)return;let co=Math.abs(at)>=Math.abs(wt)?"horizontal":"vertical",Do=(co==="horizontal"?at:wt)>0?1:-1;U=null,q=null,we=0,ze?X(Ht,co,Do):z(Ht,co,Do),T()},Ft=xe=>{(xe.key==="Shift"||xe.key==="Alt")&&($=null,oe=null,U=null,q=null,we=0,rn(null))},st=()=>{rn(null),U=null,q=null,we=0};return window.addEventListener("keydown",tt),window.addEventListener("mousemove",ot),window.addEventListener("mousedown",st),window.addEventListener("keyup",Ft),()=>{window.removeEventListener("keydown",tt),window.removeEventListener("mousemove",ot),window.removeEventListener("mousedown",st),window.removeEventListener("keyup",Ft),M&&clearTimeout(M)}},[e.activeTool,e.isAnnotating,t]),kn(()=>{let m=b=>{var $,oe,j,te;if(b.key==="Escape"){if(Lo.current)return;if(e.activeTool==="model"&&rt.size>0){b.preventDefault(),ht(new Map);return}if(Zn.current.length>0){b.preventDefault(),wo();return}}if(b.key==="Enter"&&e.activeTool==="model"&&rt.size>0&&p){b.preventDefault();let E=[...rt.keys()].filter(T=>!(x!=null&&x.has(T)));E.length>0&&p(E),ht(new Map);return}if((b.metaKey||b.ctrlKey)&&b.key==="v"&&Ze.current.length>0&&!Lo.current){b.preventDefault(),Oe.current++;let E=Oe.current*20,X=(($=Ze.current[0])==null?void 0:$.groupId)?Math.random().toString(36).substring(2,9):void 0,z=Ze.current.map(U=>y(f({},U),{id:Math.random().toString(36).substring(2,9),groupId:U.groupId?X:void 0,timestamp:Date.now(),points:U.points.map(q=>({x:q.x+E,y:q.y+E}))}));t({type:"PASTE_ANNOTATIONS",payload:{annotations:z}});let J=z.find(U=>U.type!=="text")||z[0];J&&$n(J.id);return}let G=Zn.current;if(G.length===0||Lo.current)return;let M=(j=(oe=b.composedPath)==null?void 0:oe.call(b)[0])!=null?j:b.target,C=M==null?void 0:M.tagName;if(!(C==="INPUT"||C==="TEXTAREA"||M!=null&&M.isContentEditable)&&(b.key==="Delete"||b.key==="Backspace")){if(b.preventDefault(),u){let E=Mn.current.annotations;for(let T of G){let X=E.find(J=>J.id===T);if(!X)continue;let z=X.threadId||X.groupId&&((te=E.find(J=>J.groupId===X.groupId&&J.threadId))==null?void 0:te.threadId);z&&u(z)}}for(let E of G)t({type:"DELETE_ANNOTATION",payload:{id:E}});wo()}};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,wo,$n,e.activeTool,rt,x,p,u]);let D=Ar(),V=Vi(()=>e.annotations.filter(m=>!m.pathname||m.pathname===D),[e.annotations,D]),ee=Vi(()=>Ni(e.annotations),[e.annotations]),ge=Vi(()=>{let m=new Map,b=new Set,G=1,M=[...e.annotations].sort((C,$)=>C.timestamp-$.timestamp);for(let C of M)if(!ee.has(C))if(C.groupId){if(!b.has(C.groupId)){b.add(C.groupId);let $=e.annotations.filter(oe=>oe.groupId===C.groupId);for(let oe of $)m.set(oe.id,G);G++}}else m.set(C.id,G),G++;return m},[e.annotations,ee]),ae=Vi(()=>{if(sn.length===0)return null;let m=new Map;for(let b of sn){let G=e.annotations.find(C=>C.id===b);if(!G)continue;let M=G.groupId?e.annotations.filter(C=>C.groupId===G.groupId):[G];for(let C of M)if(C.linkedSelector&&!(l!=null&&l.has(C.linkedSelector))){let $=C.color||e.activeColor;m.set(C.linkedSelector,$)}}return m.size>0?m:null},[sn,e.annotations,e.activeColor,l]);kn(()=>{let m=V.filter(b=>!(ee.has(b)||k&&!k.isNew&&b.id===k.id));re(m,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,sn,hc,an.x,an.y,ge,N)},[V,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,re,k,sn,an,ge,ee,N]),kn(()=>{if(F){let m=Math.random().toString(36).substring(2,9);be({id:m,point:F.point,text:"",fontSize:12,isNew:!0,groupId:F.groupId}),me(null)}},[F]),kn(()=>{R&&(be({id:Math.random().toString(36).substring(2,9),point:R.point,text:"",fontSize:12,isNew:!0,linkedSelector:R.linkedSelector,linkedAnchor:R.linkedAnchor,elements:R.elements}),ie(null))},[R]);let Ie=Qt(null),ke=(et=k==null?void 0:k.id)!=null?et:null;kn(()=>{ke&&Se.current?requestAnimationFrame(()=>{var G;let m=Se.current;if(!m||(m.focus(),Pe.current===ke))return;Pe.current=ke;let b=Lo.current;if(b){if(Ie.current!==null){let M=Math.min(Ie.current,m.value.length);m.setSelectionRange(M,M);return}if(!b.isNew&&b.clickPoint){let M=Y.current;if(!M)return;let C=M.getContext("2d");if(!C)return;C.font=`${b.fontSize}px ${Zt}`;let $=b.fontSize*1.4,oe=b.text.split(`
3
+ `),u=a*1.2,p=4,g=0;for(let v of c)g=Math.max(g,e.measureText(v).width);e.fillRect(l.x-p,l.y-p,g+p*2,c.length*u+p*2),e.fillStyle="#ffffff",c.forEach((v,x)=>{e.fillText(v,l.x,l.y+a+x*u)});break}}}e.restore()}async function Pr(e,t,n=[],o){var r;try{let s=(r=o==null?void 0:o.dpr)!=null?r:window.devicePixelRatio||1,i=window.innerWidth,l=window.innerHeight,a=n.filter(p=>{var g;return((g=p.status)!=null?g:"pending")==="pending"});console.log("[Screenshot] Starting capture with",a.length,"active annotations (filtered",n.length-a.length,"captured)");let d=wu(a),c=Su(a,l);if(c.length===0){let p=await fl(e,[],window.scrollY,i,l,s,d);return p?[p]:[]}let u=[];for(let p=0;p<c.length;p++){let g=c[p],v=await fl(e,g.annotations,g.top,i,l,s,d);v?u.push(v):console.warn(`[Screenshot] Region ${p+1} failed to capture`)}return console.log("[Screenshot] Capture complete"),u}catch(s){return console.error("[Screenshot] Capture failed:",s),[]}}async function fl(e,t,n,o,r,s,i){try{let l=getComputedStyle(document.documentElement).backgroundColor,d=await vu(e,{filter:p=>!(p instanceof HTMLElement&&(p.id==="devtools-canvas"||p.id==="devtools-toolbar"||p.id==="devtools-scrim"||p.dataset.devtools!==void 0)),scale:s,backgroundColor:l&&l!=="rgba(0, 0, 0, 0)"&&l!=="transparent"?l:"#ffffff",width:o,height:r,style:{transform:`translate(${-window.scrollX}px, ${-n}px)`}}),c=document.createElement("canvas");c.width=o*s,c.height=r*s;let u=c.getContext("2d");return u?(u.drawImage(d,0,0,o*s,r*s,0,0,o*s,r*s),Cu(u,t,n,s,i),new Promise(p=>{c.toBlob(g=>p(g),"image/webp",.8)})):null}catch(l){return console.error("Region capture failed:",l),null}}async function Qr(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=await Promise.all(e.map(l=>new Promise((a,d)=>{let c=new Image;c.onload=()=>a(c),c.onerror=d,c.src=URL.createObjectURL(l)}))),n=t[0].width,o=t.reduce((l,a)=>l+a.height,0),r=document.createElement("canvas");r.width=n,r.height=o;let s=r.getContext("2d");if(!s)return null;let i=0;for(let l of t)s.drawImage(l,0,i),i+=l.height,URL.revokeObjectURL(l.src);return new Promise(l=>{r.toBlob(a=>l(a),"image/webp",.8)})}async function gl(e,t,n){try{let o=Array.isArray(e)?e:[e];if(o.length===0)return!1;let r=await Qr(o);if(!r)return!1;let s=r;if(r.type!=="image/png"){let d=new Image,c=URL.createObjectURL(r);await new Promise(p=>{d.onload=()=>p(),d.src=c}),URL.revokeObjectURL(c);let u=document.createElement("canvas");u.width=d.naturalWidth,u.height=d.naturalHeight,u.getContext("2d").drawImage(d,0,0),s=await new Promise(p=>u.toBlob(g=>p(g),"image/png"))}let i={"image/png":s},l=t&&t.length>0,a=n&&n.length>0;if(l||a){let d=t?t.filter(c=>{var u;return((u=c.status)!=null?u:"pending")==="pending"}):[];if(d.length>0||a){let c=fs(d,n||[]),u=new Blob([JSON.stringify(c,null,2)],{type:"text/plain"});i["text/plain"]=u}}return await navigator.clipboard.write([new ClipboardItem(i)]),!0}catch(o){return console.warn("Clipboard write failed:",o),!1}}var ki="0.7.2";import{useCallback as un,useEffect as kn,useMemo as Vi,useRef as Qt,useState as bt}from"react";import{useCallback as Dr,useRef as ku}from"react";function gs(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!r||!s)return;let i=(r.x+s.x)/2,l=(r.y+s.y)/2,a=Math.abs(s.x-r.x)/2,d=Math.abs(s.y-r.y)/2;e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.ellipse(i,l,a,d,0,0,Math.PI*2),e.stroke()}function ms(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!(!r||!s)){e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.moveTo(r.x,r.y);for(let i=1;i<t.length-1;i++){let l=t[i],a=t[i+1];if(!l||!a)continue;let d=(l.x+a.x)/2,c=(l.y+a.y)/2;e.quadraticCurveTo(l.x,l.y,d,c)}e.lineTo(s.x,s.y),e.stroke()}}function hs(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];!r||!s||(e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.moveTo(r.x,r.y),e.lineTo(s.x,s.y),e.stroke())}function ys(e,t,n,o){if(t.length<2)return;let r=t[0],s=t[t.length-1];if(!r||!s)return;let i=Math.min(r.x,s.x),l=Math.min(r.y,s.y),a=Math.abs(s.x-r.x),d=Math.abs(s.y-r.y);e.beginPath(),e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.strokeRect(i,l,a,d)}var Zt='"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';function Eu(e,t,n){if(!t||e.measureText(t).width<=n)return[t];let o=t.split(/\s+/),r=[],s="";for(let i of o){let l=s?s+" "+i:i;s&&e.measureText(l).width>n?(r.push(s),s=i):s=l}return s&&r.push(s),r.length>0?r:[t]}function Or(e){let t=window.innerWidth-e-16;return Math.max(60,Math.min(400,t))}function ml(e,t,n){let o=[];for(let r of t)o.push(...Eu(e,r,n));return o}function Br(e,t,n){if(e.measureText(t).width<=n)return t;let o="\u2026";for(let r=t.length-1;r>0;r--){let s=t.slice(0,r)+o;if(e.measureText(s).width<=n)return s}return o}function hl(e,t,n,o,r=12,s,i){if(!n)return;let l=r*1.4,a=n.replace(/\n/g," "),d=s!==void 0?s+". "+a:a;e.font=`${r}px ${Zt}`,e.textBaseline="middle";let c=i!==void 0?Math.min(400,Math.max(60,window.innerWidth-i-16)):400,u=Br(e,d,c),p=e.measureText(u).width;e.fillStyle=o,e.fillRect(t.x-4,t.y-4,p+8,l+8),e.fillStyle="#ffffff",e.fillText(u,t.x,t.y+l/2)}var yl=11,bs=4,Tu=`600 ${yl}px system-ui, -apple-system, sans-serif`;function vs(e,t,n){return e.map(o=>({x:o.x-t,y:o.y-n}))}function Mu(e,t,n,o,r,s){let i=String(o);e.font=Tu;let a=e.measureText(i).width+bs*2,d=yl+bs*2,c=t-a/2,u=n+s/2+2;e.fillStyle=r,e.fillRect(c,u,a,d),e.fillStyle="#ffffff",e.textBaseline="middle",e.fillText(i,c+bs,u+d/2)}function Iu(e,t){if(e.points.length<2&&e.type!=="text")return null;switch(e.type){case"rectangle":case"freehand":{let n,o;if(e.type==="freehand")n=Math.min(...e.points.map(r=>r.x)),o=Math.max(...e.points.map(r=>r.y));else{let r=e.points[0],s=e.points[e.points.length-1];n=Math.min(r.x,s.x),o=Math.max(r.y,s.y)}return{x:n,y:o}}case"circle":{let n=e.points[0],o=e.points[e.points.length-1],r=Math.min(n.x,o.x),s=(Math.min(n.y,o.y)+Math.max(n.y,o.y))/2;return{x:r,y:s}}case"line":{let n=e.points[0],o=e.points[e.points.length-1],r=n.y>o.y?n:o;return{x:r.x,y:r.y}}default:return null}}function bl(){let e=ku(null),t=Dr(()=>{let l=e.current;if(!l)return;let a=l.getContext("2d");a&&a.clearRect(0,0,l.width,l.height)},[]),n=Dr((l,a,d)=>{var v;let c=e.current;if(!c)return;let u=c.getContext("2d");if(!u)return;let g=((v=l.status)!=null?v:l.captured?"in_flight":"pending")==="pending"||d?l.color:"#999999";switch(l.type){case"freehand":ms(u,l.points,g,l.strokeWidth);break;case"line":hs(u,l.points,g,l.strokeWidth);break;case"rectangle":ys(u,l.points,g,l.strokeWidth);break;case"circle":gs(u,l.points,g,l.strokeWidth);break;case"text":l.text&&l.points[0]&&hl(u,l.points[0],l.text,g,l.fontSize,a,l.points[0].x);break}},[]),o=Dr((l,a,d,c)=>{let u=e.current;if(!u||l.length<2)return;let p=u.getContext("2d");if(p)switch(a){case"freehand":ms(p,l,d,c);break;case"line":hs(p,l,d,c);break;case"rectangle":ys(p,l,d,c);break;case"circle":gs(p,l,d,c);break}},[]),r=Dr((l,a)=>{let d=e.current;if(!d||l.points.length<2)return;let c=d.getContext("2d");if(c){if(c.fillStyle="#ffffff",c.strokeStyle=l.color,c.lineWidth=1.5,l.type==="line"){let u=l.points[0],p=l.points[l.points.length-1];[u,p].forEach(g=>{c.beginPath(),c.arc(g.x,g.y,a/2,0,Math.PI*2),c.fill(),c.stroke()});return}if(l.type==="circle"){let u=l.points[0],p=l.points[l.points.length-1],g=Math.min(u.x,p.x),v=Math.max(u.x,p.x),x=Math.min(u.y,p.y),w=Math.max(u.y,p.y),I=(g+v)/2,N=(x+w)/2;[{x:I,y:x},{x:I,y:w},{x:g,y:N},{x:v,y:N}].forEach(O=>{c.beginPath(),c.rect(O.x-a/2,O.y-a/2,a,a),c.fill(),c.stroke()});return}if(l.type==="rectangle"||l.type==="freehand"){let u,p,g,v;if(l.type==="freehand")u=Math.min(...l.points.map(w=>w.x)),p=Math.max(...l.points.map(w=>w.x)),g=Math.min(...l.points.map(w=>w.y)),v=Math.max(...l.points.map(w=>w.y));else{let w=l.points[0],I=l.points[l.points.length-1];u=Math.min(w.x,I.x),p=Math.max(w.x,I.x),g=Math.min(w.y,I.y),v=Math.max(w.y,I.y)}[{x:u,y:g},{x:p,y:g},{x:u,y:v},{x:p,y:v}].forEach(w=>{c.beginPath(),c.rect(w.x-a/2,w.y-a/2,a,a),c.fill(),c.stroke()})}}},[]),s=Dr((l,a,d,c,u,p,g,v=0,x=0,w,I)=>{var N;if(t(),l.forEach(H=>{var re;let O=y(f({},H),{points:vs(H.points,v,x)}),L=w==null?void 0:w.get(H.id),Y=(re=I==null?void 0:I.has(H.id))!=null?re:!1;n(O,L,Y)}),a.length>0){let H=vs(a,v,x);o(H,d,c,u)}if(p&&p.length>0&&g){let H=e.current,O=H==null?void 0:H.getContext("2d");for(let L of p){let Y=l.find(re=>re.id===L);if(Y){let re=y(f({},Y),{points:vs(Y.points,v,x)});if(r(re,g),O&&Y.type!=="text"&&w&&!(Y.groupId&&l.some(_=>_.groupId===Y.groupId&&_.type==="text"))){let _=w.get(Y.id);if(_!==void 0){let B=Iu(re,g);if(B){let A=((N=Y.status)!=null?N:Y.captured?"in_flight":"pending")==="pending"?Y.color:"#999999";Mu(O,B.x,B.y,_,A,g)}}}}}}},[t,n,o,r]),i=Dr(()=>{let l=e.current;if(!l)return;let a=window.devicePixelRatio||1;l.width=window.innerWidth*a,l.height=window.innerHeight*a;let d=l.getContext("2d");d&&d.scale(a,a)},[]);return{canvasRef:e,clearCanvas:t,drawAnnotation:n,drawCurrentPath:o,redrawAll:s,resizeCanvas:i}}import{useEffect as Ru,useRef as Lu}from"react";function vl(){let e=Lu({shift:!1,cmd:!1});return Ru(()=>{let t=r=>{r.key==="Shift"&&(e.current.shift=!0),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!0)},n=r=>{r.key==="Shift"&&(e.current.shift=!1),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!1)},o=()=>{e.current={shift:!1,cmd:!1}};return window.addEventListener("keydown",t,!0),window.addEventListener("keyup",n,!0),window.addEventListener("blur",o),()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("keyup",n,!0),window.removeEventListener("blur",o)}},[]),e}import{useEffect as Au}from"react";function xl(e,t,n,o,r){Au(()=>{let s=i=>{if(e){if(e.linkedSelector)return;i.preventDefault(),i.stopPropagation();let a=i.deltaY>0?-2:2;t(d=>d?y(f({},d),{fontSize:Math.max(12,Math.min(72,d.fontSize+a))}):null);return}if(!n)return;i.preventDefault();let l=o.find(a=>a.id===n);if(l&&l.type==="text"&&!l.linkedSelector){let a=l.fontSize||12,d=i.deltaY>0?-2:2;r({type:"UPDATE_TEXT_SIZE",payload:{id:n,fontSize:a+d}})}};return window.addEventListener("wheel",s,{passive:!1}),()=>{window.removeEventListener("wheel",s)}},[n,e,o,r,t])}import{useCallback as Dl,useEffect as Hi,useRef as _l,useState as oi}from"react";function Ti(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return null;let n=e[t],o=[];for(;n;){let r=n.type,s=(r==null?void 0:r.displayName)||(r==null?void 0:r.name);s&&typeof s=="string"&&/^[A-Z]/.test(s)&&!s.startsWith("_")&&s!=="Fragment"&&o.unshift(s),n=n.return}return o.length>0?{name:o[o.length-1],path:o}:null}function xs(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return[];let n=e[t],o=[];for(;n;){let r=n.type,s=typeof r=="function"||typeof r=="object"?(r==null?void 0:r.displayName)||(r==null?void 0:r.name):null;s&&typeof s=="string"&&/^[A-Z]/.test(s)&&!s.startsWith("_")&&s!=="Fragment"&&o.push({name:s,fiber:n}),n=n.return}return o.reverse(),o}function Mi(e){let t=e,n=new Set;for(;t&&!n.has(t);){if(n.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}function Sl(e){if(e.id)return`#${e.id}`;let t=e.tagName.toLowerCase(),n=Array.from(e.classList).slice(0,3).join(".");return n?`${t}.${n}`:t}function Jn(e){if(e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],n=e;for(;n&&n!==document.documentElement;){let o=n.tagName.toLowerCase();if(n.id&&!n.id.startsWith("radix-")&&!n.id.startsWith(":")){t.unshift(`#${CSS.escape(n.id)}`);break}let r=Array.from(n.classList).filter(i=>!i.startsWith("_")&&i.length<30).slice(0,2);r.length>0&&(o+="."+r.map(i=>CSS.escape(i)).join("."));let s=n.parentElement;if(s){let i=Array.from(s.children).filter(l=>l.tagName===n.tagName);if(i.length>1){let l=i.indexOf(n)+1;o+=`:nth-of-type(${l})`}}t.unshift(o),n=s}return t.join(" > ")}function Hn(e){try{return document.querySelector(e)}catch(t){return null}}function Ii(e,t=0){var a;let n=xs(e);if(n.length===0)return null;let o=n.map(d=>d.name),r=n.length-1,s=Math.max(0,Math.min(n.length-1,r-t)),i=n[s],l=(a=Mi(i.fiber))!=null?a:e;return{name:i.name,path:o,depthIndex:s,rootElement:l}}function wl(e,t){var s,i;let n=xs(e),o=t.toLowerCase(),r=-1;for(let l=n.length-1;l>=0;l--){let a=n[l].name;if(a===t){let d=(s=Mi(n[l].fiber))!=null?s:e;return{name:t,path:n.map(c=>c.name),depthIndex:l,rootElement:d}}if(r===-1){let d=a.toLowerCase();(d.length>=4&&o.includes(d)||o.length>=4&&d.includes(o))&&(r=l)}}if(r>=0){let l=(i=Mi(n[r].fiber))!=null?i:e;return{name:t,path:n.map(a=>a.name),depthIndex:r,rootElement:l}}return null}function _r(e){let t=Hr(),n=[],o=new Set,r=t.currentNode;for(;r=t.nextNode();){let s=wl(r,e);s&&!o.has(s.rootElement)&&(o.add(s.rootElement),n.push(s))}return n}function Ss(e){let t=new Map;if(e.size===0)return t;let n=new Set(e),o=Hr(),r=new Set,s=o.currentNode;for(;(s=o.nextNode())&&n.size>0;)for(let i of n){let l=wl(s,i);if(!l||r.has(l.rootElement))continue;r.add(l.rootElement);let a=l.rootElement.getBoundingClientRect();t.set(i,a.top+window.scrollY),n.delete(i);break}for(let i of n)t.set(i,1/0);return t}function Hr(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Nn(e){let t={selector:Sl(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let n=Cl(e);n&&n.length>0&&n.length<200&&(t.textContent=n);let o={};for(let i of e.attributes)i.name.startsWith("data-")&&(o[i.name]=i.value);Object.keys(o).length>0&&(t.dataAttributes=o);let r=Ti(e);r&&(t.reactComponent=r.name);let s=Pu(e);return s&&(t.context=s),t}function Cl(e){let t="";for(let n of e.childNodes)n.nodeType===Node.TEXT_NODE&&(t+=n.textContent||"");return t.trim()}function dr(e,t){let n=document.elementsFromPoint(e,t);for(let o of n)if(o instanceof HTMLElement&&!(o.id==="devtools-canvas"||o.id==="devtools-toolbar"||o.id==="devtools-scrim")&&!o.closest("#devtools-toolbar")&&!(o.dataset.devtools||o.closest("[data-devtools]"))&&!["html","body"].includes(o.tagName.toLowerCase()))return o;return null}function Pu(e){let t=e.parentElement,n=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let o=t.tagName.toLowerCase();if(n.includes(o)&&t.id)return`${o}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${o}#${t.id}`;t=t.parentElement}return null}function El(e){let t=new Set,n=[],o=window.scrollX,r=window.scrollY,s=[{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2},{x:e.minX,y:e.minY},{x:e.maxX,y:e.minY},{x:e.minX,y:e.maxY},{x:e.maxX,y:e.maxY}];for(let i of s){let l=i.x-o,a=i.y-r;if(l<0||a<0||l>window.innerWidth||a>window.innerHeight)continue;let d=dr(l,a);d&&!t.has(d)&&(t.add(d),n.push(Nn(d)))}return n.slice(0,3)}function ws(e){if(e.length===0)return[];let t=e.map(o=>o.x),n=e.map(o=>o.y);return El({minX:Math.min(...t),minY:Math.min(...n),maxX:Math.max(...t),maxY:Math.max(...n)})}function dn(e,t){return e.style.getPropertyValue(t)!==""}function Ou(e,t=30){if(e<=0)return[];let n=[],o=Hr(),r=.5,s=o.currentNode;for(;(s=o.nextNode())&&n.length<t;){let i=s,l=i.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(i);!dn(i,"padding-top")&&Math.abs((parseFloat(a.paddingTop)||0)-e)<r&&n.push({element:i,property:"padding-top"}),!dn(i,"padding-bottom")&&Math.abs((parseFloat(a.paddingBottom)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-bottom"}),!dn(i,"padding-left")&&Math.abs((parseFloat(a.paddingLeft)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-left"}),!dn(i,"padding-right")&&Math.abs((parseFloat(a.paddingRight)||0)-e)<r&&n.length<t&&n.push({element:i,property:"padding-right"}),!dn(i,"margin-top")&&Math.abs((parseFloat(a.marginTop)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-top"}),!dn(i,"margin-bottom")&&Math.abs((parseFloat(a.marginBottom)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-bottom"}),!dn(i,"margin-left")&&Math.abs((parseFloat(a.marginLeft)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-left"}),!dn(i,"margin-right")&&Math.abs((parseFloat(a.marginRight)||0)-e)<r&&n.length<t&&n.push({element:i,property:"margin-right"});let d=a.display;if((d.includes("flex")||d.includes("grid"))&&n.length<t){let c=dn(i,"gap"),u=parseFloat(a.gap)||0,p=parseFloat(a.rowGap)||0,g=parseFloat(a.columnGap)||0;!c&&Math.abs(u-e)<r?n.push({element:i,property:"gap"}):!dn(i,"row-gap")&&Math.abs(p-e)<r?n.push({element:i,property:"row-gap"}):!dn(i,"column-gap")&&Math.abs(g-e)<r&&n.push({element:i,property:"column-gap"})}}return n}function Cs(e,t=30){if(e<=0)return[];let n=[],o=Hr(),r=.5,s=o.currentNode;for(;(s=o.nextNode())&&n.length<t;){let i=s,l=i.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(i),d=parseFloat(a.borderTopWidth)||0,c=parseFloat(a.borderRightWidth)||0,u=parseFloat(a.borderBottomWidth)||0,p=parseFloat(a.borderLeftWidth)||0,g=i.clientWidth,v=i.clientHeight,x=parseFloat(a.paddingTop)||0;!dn(i,"padding-top")&&Math.abs(x-e)<r&&n.push({x:l.left+p,y:l.top+d,width:g,height:e,direction:"vertical",property:"padding-top"});let w=parseFloat(a.paddingBottom)||0;!dn(i,"padding-bottom")&&Math.abs(w-e)<r&&n.length<t&&n.push({x:l.left+p,y:l.top+d+v-e,width:g,height:e,direction:"vertical",property:"padding-bottom"});let I=parseFloat(a.paddingLeft)||0;!dn(i,"padding-left")&&Math.abs(I-e)<r&&n.length<t&&n.push({x:l.left+p,y:l.top+d,width:e,height:v,direction:"horizontal",property:"padding-left"});let N=parseFloat(a.paddingRight)||0;!dn(i,"padding-right")&&Math.abs(N-e)<r&&n.length<t&&n.push({x:l.left+p+g-e,y:l.top+d,width:e,height:v,direction:"horizontal",property:"padding-right"});let H=parseFloat(a.marginTop)||0;!dn(i,"margin-top")&&Math.abs(H-e)<r&&n.length<t&&n.push({x:l.left,y:l.top-e,width:l.width,height:e,direction:"vertical",property:"margin-top"});let O=parseFloat(a.marginBottom)||0;!dn(i,"margin-bottom")&&Math.abs(O-e)<r&&n.length<t&&n.push({x:l.left,y:l.bottom,width:l.width,height:e,direction:"vertical",property:"margin-bottom"});let L=parseFloat(a.marginLeft)||0;!dn(i,"margin-left")&&Math.abs(L-e)<r&&n.length<t&&n.push({x:l.left-e,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-left"});let Y=parseFloat(a.marginRight)||0;!dn(i,"margin-right")&&Math.abs(Y-e)<r&&n.length<t&&n.push({x:l.right,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-right"});let re=a.display;if((re.includes("flex")||re.includes("grid"))&&n.length<t&&!dn(i,"gap")){let _=Array.from(i.children).filter(B=>{let h=getComputedStyle(B);return h.display!=="none"&&h.position!=="absolute"&&h.position!=="fixed"});if(_.length>=2)for(let B=0;B<_.length-1&&n.length<t;B++){let h=_[B].getBoundingClientRect(),A=_[B+1].getBoundingClientRect(),k=A.top-h.bottom;Math.abs(k-e)<r&&k>.5&&n.push({x:Math.min(h.left,A.left),y:h.bottom,width:Math.max(h.right,A.right)-Math.min(h.left,A.left),height:k,direction:"vertical",property:"gap"});let be=A.left-h.right;Math.abs(be-e)<r&&be>.5&&n.push({x:h.right,y:Math.min(h.top,A.top),width:be,height:Math.max(h.bottom,A.bottom)-Math.min(h.top,A.top),direction:"horizontal",property:"gap"})}}}return n}function Ri(e){return typeof e=="string"?{value:e}:e}var Tl={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function kl(e,t){let n=Tl[t];return n?n.includes(e):!1}function Bu(e,t){let n=e.split(/\s+/);for(let o of n){if(o===t)return!0;let r=o.lastIndexOf(":");if(r>=0&&o.slice(r+1)===t)return!0}return!1}function Du(e){var l,a;let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,o=n.indexOf("-");if(o<0)return null;let r=n.slice(0,o),s={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},i=n.slice(0,n.indexOf("-",o+1)>0?n.indexOf("-",o+1):o);return(a=(l=s[i])!=null?l:s[r])!=null?a:null}function Es(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let r=[],s=Hr(),i=s.currentNode;for(;(i=s.nextNode())&&r.length<t;){let l=i,a=l.getBoundingClientRect();if(a.bottom<-50||a.top>window.innerHeight+50||a.right<-50||a.left>window.innerWidth+50||a.width<1||a.height<1)continue;let d=l.className;if(typeof d=="string")for(let c of e.bindings){if(!Bu(d,c))continue;let u=Du(c);if(u&&!(e.property&&!kl(u,e.property))){r.push({element:l,property:u});break}}}return r}let o=Ou(n,t*2);return e.property?o.filter(r=>kl(r.property,e.property)).slice(0,t):o.slice(0,t)}function ks(e,t=30){let n=Es(e,t),o=[];for(let r of n){let s=r.element,i=s.getBoundingClientRect(),l=getComputedStyle(s),a=parseFloat(l.borderTopWidth)||0,d=parseFloat(l.borderRightWidth)||0,c=parseFloat(l.borderLeftWidth)||0,u=s.clientWidth,p=s.clientHeight;switch(r.property){case"padding-top":{let g=parseFloat(l.paddingTop)||0;o.push({x:i.left+c,y:i.top+a,width:u,height:g,direction:"vertical",property:r.property});break}case"padding-bottom":{let g=parseFloat(l.paddingBottom)||0;o.push({x:i.left+c,y:i.top+a+p-g,width:u,height:g,direction:"vertical",property:r.property});break}case"padding-left":{let g=parseFloat(l.paddingLeft)||0;o.push({x:i.left+c,y:i.top+a,width:g,height:p,direction:"horizontal",property:r.property});break}case"padding-right":{let g=parseFloat(l.paddingRight)||0;o.push({x:i.left+c+u-g,y:i.top+a,width:g,height:p,direction:"horizontal",property:r.property});break}case"margin-top":{let g=parseFloat(l.marginTop)||0;o.push({x:i.left,y:i.top-g,width:i.width,height:g,direction:"vertical",property:r.property});break}case"margin-bottom":{let g=parseFloat(l.marginBottom)||0;o.push({x:i.left,y:i.bottom,width:i.width,height:g,direction:"vertical",property:r.property});break}case"margin-left":{let g=parseFloat(l.marginLeft)||0;o.push({x:i.left-g,y:i.top,width:g,height:i.height,direction:"horizontal",property:r.property});break}case"margin-right":{let g=parseFloat(l.marginRight)||0;o.push({x:i.right,y:i.top,width:g,height:i.height,direction:"horizontal",property:r.property});break}case"gap":case"row-gap":case"column-gap":{let g=Array.from(s.children).filter(v=>{let x=getComputedStyle(v);return x.display!=="none"&&x.position!=="absolute"&&x.position!=="fixed"});for(let v=0;v<g.length-1&&o.length<t;v++){let x=g[v].getBoundingClientRect(),w=g[v+1].getBoundingClientRect(),I=w.top-x.bottom;I>.5&&o.push({x:Math.min(x.left,w.left),y:x.bottom,width:Math.max(x.right,w.right)-Math.min(x.left,w.left),height:I,direction:"vertical",property:"gap"});let N=w.left-x.right;N>.5&&o.push({x:x.right,y:Math.min(x.top,w.top),width:N,height:Math.max(x.bottom,w.bottom)-Math.min(x.top,w.top),direction:"horizontal",property:"gap"})}break}}}return o}function Ml(e,t){let n=new Set,o=ei(t);for(let r of e){let s=Rl[r.property];if(!s)continue;let i=r.element.className;if(typeof i=="string")for(let l of s){let a=`${l}-${o}`;for(let d of i.split(/\s+/)){let c=d.lastIndexOf(":"),u=c>=0?d.slice(c+1):d;if(u===a){n.add(u);break}}}}return[...n]}function Il(e){let t=new Set;for(let n of e)for(let[o,r]of Object.entries(Tl))if(r.includes(n.property)){t.add(o);break}if(t.size===1)return[...t][0]}function Ts(e,t,n){if(t===n)return e;let o=ei(t),r=ei(n);return e.map(s=>{let i=s.lastIndexOf("-");if(i<0)return s;let l=s.slice(0,i),a=s.slice(i+1);return a===o||a===`[${t}px]`?`${l}-${r}`:s})}var _u={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function ei(e){var t;return(t=_u[e])!=null?t:`[${e}px]`}var Rl={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function Hu(e,t,n,o){let r=Rl[t];if(!r)return null;let s=ei(n);for(let i of r){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+i+"-(?:"+Nu(s)+"|\\["+n+"px\\]))(?:\\s|$)"),a=e.match(l);if(a!=null&&a[1]){let d=ei(o),c=a[1].lastIndexOf(":"),u=c>=0?a[1].slice(0,c+1):"";return{matched:a[1],suggested:`${u}${i}-${d}`}}}return null}function Nu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ll(e,t,n){let o=new Set,r=[];for(let s of e){let i=Jn(s.element),l=`${i}::${s.property}`;if(o.has(l))continue;o.add(l);let a=Ti(s.element),d=s.element.className||"",c=Hu(d,s.property,t,n);r.push({selector:i,reactComponent:a==null?void 0:a.name,className:d,property:s.property,matchedClass:c==null?void 0:c.matched,suggestedClass:c==null?void 0:c.suggested})}return r}function Li(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Ai(e,t){if(e instanceof HTMLElement){let o=e.style.getPropertyValue(t);if(o)return o}let n=t.replace(/-([a-z])/g,(o,r)=>r.toUpperCase());try{for(let o of document.styleSheets)try{let r=o.cssRules||o.rules;for(let s of r)if(s instanceof CSSStyleRule&&e.matches(s.selectorText)){let i=s.style.getPropertyValue(t);if(i)return i;let l=s.style[n];if(l)return l}}catch(r){}}catch(o){}return null}function Pi(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function ur(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function zu(e){let t=[];for(let n of e){let o=t.find(r=>r.axis!==n.axis?!1:n.axis==="row"?Math.abs(r.y-n.y)<2&&Math.abs(r.h-n.h)<2:Math.abs(r.x-n.x)<2&&Math.abs(r.w-n.w)<2);if(o)if(n.axis==="row"){let r=Math.min(o.x,n.x),s=Math.max(o.x+o.w,n.x+n.w);o.x=r,o.w=s-r}else{let r=Math.min(o.y,n.y),s=Math.max(o.y+o.h,n.y+n.h);o.y=r,o.h=s-r}else t.push(f({},n))}return t}function Ho(e){let t=Array.from(e.children).filter(a=>{if(!(a instanceof HTMLElement))return!1;let d=window.getComputedStyle(a);return d.display!=="none"&&d.position!=="absolute"&&d.position!=="fixed"});if(t.length<2)return[];let n=[],o=e.getBoundingClientRect(),s=window.getComputedStyle(e).flexDirection,i=s==="column"||s==="column-reverse",l=6;for(let a=0;a<t.length-1;a++){let d=t[a].getBoundingClientRect(),c=t[a+1].getBoundingClientRect();if(c.left>d.right+.5&&n.push({axis:"column",x:d.right,y:o.top,w:c.left-d.right,h:o.height}),c.top>d.bottom+.5&&n.push({axis:"row",x:o.left,y:d.bottom,w:o.width,h:c.top-d.bottom}),!(c.left>d.right+.5)&&!(c.top>d.bottom+.5))if(i){let u=(d.bottom+c.top)/2;n.push({axis:"row",x:o.left,y:u-l/2,w:o.width,h:l})}else{let u=(d.right+c.left)/2;n.push({axis:"column",x:u-l/2,y:o.top,w:l,h:o.height})}}return zu(n)}function Ms(e,t){let n=window.getComputedStyle(e),o=n.display;if(o!=="flex"&&o!=="inline-flex")return!1;let r=n.justifyContent;if(r!=="space-between"&&r!=="space-around"&&r!=="space-evenly"&&r!=="stretch")return!1;let s=n.flexDirection;return!(t!==(s==="column"||s==="column-reverse"?"row":"column")||parseFloat(t==="row"?n.rowGap:n.columnGap)>0)}function Nr(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function pr(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function Is(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function zr(e){var c,u;let t=document.createRange(),n=!1;for(let p of e.childNodes)p.nodeType===Node.TEXT_NODE&&(p.textContent||"").trim().length>0&&(n||(t.setStart(p,0),n=!0),t.setEnd(p,(u=(c=p.textContent)==null?void 0:c.length)!=null?u:0));if(!n)return null;let o=t.getBoundingClientRect(),r=window.getComputedStyle(e),s=parseFloat(r.fontSize)||16,i=parseFloat(r.lineHeight);isNaN(i)&&(i=s*1.2);let l=Math.max(1,t.getClientRects().length),a=Math.max(o.height,l*i),d=(a-o.height)/2;return new DOMRect(o.x,o.y-d,o.width,a)}function ti(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,o=parseFloat(t.lineHeight);return isNaN(o)&&(o=n*1.2),{fontSize:n,lineHeight:o}}function Xe(e,t,n){e instanceof HTMLElement&&e.style.setProperty(t,n,"important")}function Al(e,t,n){e instanceof HTMLElement&&e.style.removeProperty(t)}function Oi(e){var t;for(let n of e){let o=Hn(n.selector);if(!o&&n.durableSelector&&(o=Hn(n.durableSelector),o)){let r=(t=n.selector.match(/\[data-pm="([^"]+)"\]/))==null?void 0:t[1];r&&o.setAttribute("data-pm",r)}if(o)for(let r of n.changes)Xe(o,r.property,r.modified)}}function Bi(e){for(let t of e){let n=Hn(t.selector);if(n)for(let o of t.changes)Al(n,o.property,o.original)}}function Ol(e,t,n,o){if(e)for(let r of e){if(r instanceof CSSGroupingRule){Ol(r.cssRules,t,n,o);continue}if(r instanceof CSSStyleRule){let s=r.selectorText.toLowerCase();(s===":root"||s==="html"||s==="*"||s.includes(":root"))&&Fu(r.style,t,n,o)}}}function Fu(e,t,n,o){for(let r=0;r<e.length;r++){let s=e[r];if(s!=null&&s.startsWith("--")){if(n.has(s))continue;n.add(s);let i=t.getPropertyValue(s).trim();Bl(i)&&o.push({name:s,value:i,usage:`var(${s})`})}}}var Di=null,$u=5e3;function Rs(){if(Di&&Date.now()-Di.timestamp<$u)return Di.variables;let e=[],t=new Set,n=getComputedStyle(document.documentElement);try{for(let s of document.styleSheets)try{Ol(s.cssRules||s.rules,n,t,e)}catch(i){}}catch(s){}let o=document.documentElement.style;for(let s=0;s<o.length;s++){let i=o[s];if(i!=null&&i.startsWith("--")&&!t.has(i)){t.add(i);let l=n.getPropertyValue(i).trim();Bl(l)&&e.push({name:i,value:l,usage:`var(${i})`})}}let r=e.sort((s,i)=>s.name.localeCompare(i.name));return Di={variables:r,timestamp:Date.now()},r}function Bl(e){if(!e)return!1;let t=e.toLowerCase().trim();return!!(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("oklch")||t.startsWith("oklab")||t.startsWith("lch")||t.startsWith("lab")||["transparent","currentcolor","inherit","white","black","red","green","blue","yellow","orange","purple","pink","gray","grey"].includes(t))}function Fr(e,t){let n=t.match(/var\((--[^,)]+)(?:,\s*([^)]+))?\)/);if(n){let o=n[1],r=n[2];return getComputedStyle(document.documentElement).getPropertyValue(o).trim()||r||t}return t}function ni(e,t){if(!e)return null;let n=Pl(e);if(!n)return null;for(let o of t){let r=Pl(o.value);if(r&&n===r)return o}return null}function Pl(e){if(!e)return null;let t=e.trim().toLowerCase();if(t.startsWith("oklch(")){let n=t.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)/);if(n){let o=n[1].endsWith("%")?parseFloat(n[1])/100:parseFloat(n[1]),r=n[2].endsWith("%")?parseFloat(n[2])/100:parseFloat(n[2]),s=parseFloat(n[3]);o=Math.round(o*100)/100,r=Math.round(r*1e3)/1e3;let i=Math.round(s);return`oklch(${o} ${r} ${i})`}}if(t.startsWith("rgb")){let n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);if(n)return`rgb(${n[1]},${n[2]},${n[3]})`}return t.startsWith("#")?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t.slice(0,7):t}import{Fragment as fr,jsx as mt,jsxs as po}from"react/jsx-runtime";var eo=22,Vo=12,Wu=3,ju=250,_i=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],Gu=3e3;function Yu(i){var l=i,{left:e,top:t,avoidBottom:n,style:o,children:r}=l,s=Dn(l,["left","top","avoidBottom","style","children"]);let a=e+Vo,d=t+Vo,c=n!==void 0?`${n}px`:"100vh";return mt("div",y(f({"data-devtools":"badge-hit-area"},s),{style:f({position:"fixed",left:e,top:t,padding:Vo},o),children:mt("div",{style:{transform:`translate(min(0px, calc(100vw - ${a}px - 100%)), min(0px, calc(${c} - ${d}px - 100%)))`},children:r})}))}function Hl({annotations:e,supersededAnnotations:t,inFlightIds:n,activeIds:o,queuePositions:r,scrollX:s,scrollY:i,annotationGroupMap:l,onViewThread:a,onSelectAnnotation:d,onHoverAnnotation:c,canvasRef:u}){var Z,_,B,h,A,k,be;let[p,g]=oi(0),[v,x]=oi(()=>Math.floor(Math.random()*_i.length)),w=!!(n&&n.size>0);Hi(()=>{if(!w)return;let K=setInterval(()=>{g(F=>(F+1)%Wu)},ju),de=setInterval(()=>{x(F=>(F+1)%_i.length)},Gu);return()=>{clearInterval(K),clearInterval(de)}},[w]);let I=[];for(let K of e){if(K.type!=="text"||!K.text||!K.points[0]||t.has(K))continue;let de=K.groupId?e.filter(ye=>ye.groupId===K.groupId):[K],F=(Z=K.status)!=null?Z:"pending",me=de.reduce((ye,ct)=>{var Ge;return ye+((Ge=ct.replyCount)!=null?Ge:0)},0),R=ye=>ye==="resolved"&&me===0,ie=!!(n&&(n.has(K.id)||de.some(ye=>n.has(ye.id))))||K.status==="in_flight"||de.some(ye=>ye.status==="in_flight")||R(K.status)||de.some(ye=>R(ye.status)),Se=de.some(ye=>{var ct;return ye.status==="resolved"&&((ct=ye.replyCount)!=null?ct:0)>0||ye.status==="needs_review"}),Pe=de.some(ye=>ye.threadId);if(!ie&&F!=="resolved"&&F!=="needs_review"&&!Se&&!Pe)continue;let _e=K.threadId||((_=de.find(ye=>ye.threadId))==null?void 0:_.threadId),Ze=F==="needs_review"||de.some(ye=>ye.status==="needs_review"),Oe=K.points[0],he=K.fontSize||12,Fe=he*1.4,rt=l.get(K.id),ht=K.text.replace(/\n/g," "),Jt=rt!==void 0?rt+". "+ht:ht,Q=(h=(B=u==null?void 0:u.current)==null?void 0:B.getContext("2d"))!=null?h:document.createElement("canvas").getContext("2d");if(!Q)continue;Q.font=`${he}px ${Zt}`;let ne=Oe.x-s,Te=Or(ne),$e=Br(Q,Jt,Te),pt=Q.measureText($e).width,Je=ie&&!!o&&!o.has(K.id)&&!de.some(ye=>o.has(ye.id));I.push({id:K.id,threadId:_e,linkedSelector:K.linkedSelector||((A=de.find(ye=>ye.linkedSelector))==null?void 0:A.linkedSelector),x:Oe.x+pt+4,y:Oe.y-4,size:Fe+8,color:K.color,isInFlight:ie,isQueued:Je,queuePosition:void 0,isNeedsReview:Ze,replyCount:me})}let N=I.filter(K=>K.isQueued);if(N.length>0&&N.forEach((K,de)=>{var F;K.queuePosition=(F=r==null?void 0:r.get(K.id))!=null?F:`(${de+1}/${N.length})`}),I.length===0)return null;let H=2,O=(be=(k=u==null?void 0:u.current)==null?void 0:k.getContext("2d"))!=null?be:document.createElement("canvas").getContext("2d"),L=I.map(K=>{var Se;let de;K.isQueued?de=K.queuePosition?`queued ${K.queuePosition}`:"queued":K.isInFlight?de=(Se=_i[v])!=null?Se:"thinking":K.replyCount>0?de=`${K.replyCount} ${K.replyCount===1?"reply":"replies"}`:de="Cancelled";let F=!K.isQueued,me=F?11:0,R=F?4:0,ie=de.length*7.2;return O&&(O.font=`12px ${Zt}`,ie=O.measureText(de).width),4+me+R+ie+4}),Y=typeof window!="undefined"?window.innerHeight:9999,re=[];for(let K=0;K<I.length;K++){let de=I[K].y-i,F=Math.min(de,Y-eo),me=F+eo,ie=I[K].x-s;for(let Se=0;Se<K;Se++){let Pe=I[Se].y-i,_e=Math.min(Pe,Y-eo),Ze=_e+eo;if(!(F<Ze&&me>_e))continue;let he=re[Se]+L[Se];ie<he+H&&(ie=he+H)}re.push(ie)}return mt(fr,{children:I.map((K,de)=>{let F=!!K.threadId;return mt(Yu,{left:re[de]-Vo,top:K.y-i-Vo,onMouseDown:F?me=>me.stopPropagation():void 0,onClick:F?me=>{if(me.stopPropagation(),d==null||d(K.id),a==null||a(K.threadId),K.linkedSelector)try{let R=document.querySelector(K.linkedSelector);if(R){let ie=R.getBoundingClientRect();(ie.bottom<0||ie.top>window.innerHeight)&&R.scrollIntoView({behavior:"smooth",block:"center"})}}catch(R){}}:void 0,onMouseEnter:c?()=>c(K.id):void 0,onMouseLeave:c?()=>c(null):void 0,style:{pointerEvents:F?"auto":"none",cursor:F?"pointer":void 0,zIndex:9999},children:mt("div",{"data-devtools":"annotation-badge",style:{height:K.size,display:"flex",alignItems:"center",backgroundColor:K.color,fontFamily:Zt,fontSize:12,color:"#ffffff",userSelect:"none",padding:`0 ${4}px`,gap:4,whiteSpace:"nowrap"},children:K.isQueued?po("span",{style:{opacity:.5,color:"inherit"},children:["queued",K.queuePosition?` ${K.queuePosition}`:""]}):K.isInFlight?po(fr,{children:[mt("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:p===1?po(fr,{children:[mt("circle",{cx:"7",cy:"7",r:"2"}),mt("circle",{cx:"17",cy:"7",r:"2"}),mt("circle",{cx:"7",cy:"17",r:"2"}),mt("circle",{cx:"17",cy:"17",r:"2"})]}):po(fr,{children:[mt("circle",{cx:"12",cy:"6",r:"2"}),mt("circle",{cx:"6",cy:"12",r:"2"}),mt("circle",{cx:"18",cy:"12",r:"2"}),mt("circle",{cx:"12",cy:"18",r:"2"})]})}),mt("span",{style:{opacity:.7,color:"inherit"},children:_i[v]})]}):po(fr,{children:[K.isNeedsReview?mt("span",{style:{fontWeight:700,color:"inherit"},children:"?"}):mt("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:mt("polyline",{points:"4 12 10 18 20 6"})}),mt("span",{style:{opacity:.7,color:"inherit"},children:K.replyCount>0?`${K.replyCount} ${K.replyCount===1?"reply":"replies"}`:"Cancelled"})]})})},K.id)})})}function Ls({inFlightSelectorColors:e,animated:t=!0}){let[n,o]=oi([]);return Hi(()=>{if(e.size===0){o([]);return}let r=null,s=()=>{let a=[];for(let[d,c]of e){let u=Hn(d);if(!u)continue;let p=u.getBoundingClientRect();a.push({selector:d,top:p.top,left:p.left,width:p.width,height:p.height,color:c})}o(a)},i=()=>{r&&cancelAnimationFrame(r),r=requestAnimationFrame(s)};s(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i,!0);let l=new MutationObserver(i);return l.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i,!0),l.disconnect(),r&&cancelAnimationFrame(r)}},[e]),n.length===0?null:po(fr,{children:[t&&mt("style",{children:"@keyframes popmelt-march { to { stroke-dashoffset: -6; } }"}),n.map(r=>mt("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:r.top,left:r.left,width:r.width,height:r.height,pointerEvents:"none",zIndex:9995,overflow:"visible"},children:mt("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:mt("rect",{x:"0.5",y:"0.5",width:Math.max(0,r.width-1),height:Math.max(0,r.height-1),fill:"none",stroke:r.color,strokeWidth:"1",strokeDasharray:"2 4",style:t?{animation:"popmelt-march 0.5s steps(2) infinite"}:void 0})})},r.selector))]})}function Nl({annotations:e,supersededAnnotations:t,scrollX:n,scrollY:o,onReply:r,annotationGroupMap:s,canvasRef:i,onHoverAnnotation:l}){let a=e.filter(u=>t.has(u)?!1:u.status==="waiting_input"&&u.question&&u.threadId);if(a.length===0)return null;let d=new Set,c=[];for(let u of a){if(!u.threadId||d.has(u.threadId))continue;d.add(u.threadId);let p=u.type==="text"?u:e.find(g=>g.groupId&&g.groupId===u.groupId&&g.type==="text")||u;if(p.type==="text"&&p.text&&p.points[0]){let g=p.points[0],v=p.fontSize||12,x=v*1.4,w=s.get(p.id),I=p.text.replace(/\n/g," "),N=w!==void 0?w+". "+I:I,O=document.createElement("canvas").getContext("2d");if(!O)continue;O.font=`${v}px ${Zt}`;let L=g.x-n,Y=Or(L),re=Br(O,N,Y),Z=O.measureText(re).width;c.push({annotation:u,x:g.x+Z+4,y:g.y-4,size:x+8})}}return c.length===0?null:mt(fr,{children:c.map(({annotation:u,x:p,y:g,size:v})=>mt(Ju,{annotation:u,x:p-n,y:g-o,size:v,onReply:r,onHoverAnnotation:l},`question-${u.threadId}`))})}function Ju({annotation:e,x:t,y:n,size:o,onReply:r,onHoverAnnotation:s}){let[i,l]=oi(!1),[a,d]=oi(""),c=_l(null),u=_l(null);Hi(()=>{i&&c.current&&c.current.focus()},[i]),Hi(()=>{if(!i)return;let w=N=>{u.current&&!N.composedPath().includes(u.current)&&l(!1)},I=N=>{N.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",I)}},[i]);let p=Dl(()=>{!a.trim()||!e.threadId||(r(e.threadId,a.trim()),d(""),l(!1))},[a,e.threadId,r]),g=Dl(w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),p())},[p]),v=i?t:t-Vo,x=i?n:n-Vo;return po("div",{ref:u,"data-devtools":"question-badge",onMouseEnter:s?()=>s(e.id):void 0,onMouseLeave:s?()=>s(null):void 0,style:{position:"fixed",left:`max(0px, ${v}px)`,top:`max(0px, ${x}px)`,padding:i?0:Vo,transform:`translate(min(0px, calc(100vw - max(0px, ${v}px) - 100%)), min(0px, calc(100vh - max(0px, ${x}px) - 100%)))`,zIndex:i?10002:9999,pointerEvents:"auto",cursor:i?void 0:"pointer"},children:[!i&&po("div",{onClick:()=>l(!0),style:{height:o,display:"flex",alignItems:"center",backgroundColor:e.color,padding:`0 ${4}px`,gap:4,fontFamily:Zt,fontSize:12,color:"#ffffff",whiteSpace:"nowrap"},children:[po("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[mt("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),mt("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),mt("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),mt("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]}),mt("span",{style:{opacity:.7},children:"reply?"})]}),i&&po("div",{style:{minWidth:260,maxWidth:360,backgroundColor:"#eaeaea",fontFamily:Zt,fontSize:12,color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)"},children:[mt("div",{style:{padding:`${6}px ${8}px`,lineHeight:1.4},children:e.question}),po("div",{style:{padding:`0 ${4}px ${4}px`},children:[mt("textarea",{ref:c,value:a,onChange:w=>d(w.target.value),onKeyDown:g,placeholder:"Type your reply...",style:{width:"100%",minHeight:40,padding:4,fontSize:12,fontFamily:Zt,backgroundColor:"rgba(0, 0, 0, 0.04)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),mt("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:mt("button",{onClick:p,disabled:!a.trim(),style:{padding:"4px 12px",fontSize:11,fontFamily:Zt,fontWeight:600,backgroundColor:a.trim()?e.color:"rgba(0,0,0,0.1)",color:a.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:a.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}function Ni(e){var s;let t=new Set,n=new Map;for(let i of e){if(!i.linkedSelector)continue;let l=n.get(i.linkedSelector)||[];l.push(i),n.set(i.linkedSelector,l)}let o=new Set,r=new Set;for(let i of n.values()){if(i.length<=1){(s=i[0])!=null&&s.groupId&&r.add(i[0].groupId);continue}i.sort((a,d)=>d.timestamp-a.timestamp);let l=i[0];l.groupId&&r.add(l.groupId);for(let a=1;a<i.length;a++){let d=i[a];t.add(d),d.groupId&&o.add(d.groupId)}}for(let i of e)i.groupId&&o.has(i.groupId)&&!r.has(i.groupId)&&t.add(i);return t}import{useEffect as zl,useLayoutEffect as Vu,useState as Fl}from"react";import{jsx as As,jsxs as Wl}from"react/jsx-runtime";function Uu(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var $l=["top-left","top-right","bottom-right","bottom-left"];function jl({element:e,radius:t,accentColor:n,hoveredCorner:o,draggingCorner:r,cursorViewport:s}){let[i,l]=Fl(null),[a,d]=Fl(!1);if(zl(()=>{let I=O=>{(O.key==="Meta"||O.key==="Control")&&d(!0)},N=O=>{(O.key==="Meta"||O.key==="Control")&&d(!1)},H=()=>d(!1);return window.addEventListener("keydown",I,!0),window.addEventListener("keyup",N,!0),window.addEventListener("blur",H),()=>{window.removeEventListener("keydown",I,!0),window.removeEventListener("keyup",N,!0),window.removeEventListener("blur",H)}},[]),zl(()=>{if(!e){l(null);return}let I=()=>{l(e.getBoundingClientRect())};return I(),window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I,{passive:!0}),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I)}},[e]),Vu(()=>{e&&l(e.getBoundingClientRect())},[e,t["top-left"],t["top-right"],t["bottom-right"],t["bottom-left"]]),!i)return null;let c=i.width,u=i.height,p=Uu(n,.2),g={"top-left":{x:0,y:t["top-left"]},"top-right":{x:c,y:t["top-right"]},"bottom-right":{x:c,y:u-t["bottom-right"]},"bottom-left":{x:0,y:u-t["bottom-left"]}},v=new Set,x=r!=null?r:o;if(x)if(a)v.add(x);else for(let I of $l)v.add(I);let w={position:"fixed",top:i.top,left:i.left,width:c,height:u,pointerEvents:"none",zIndex:9996,overflow:"visible"};return Wl("div",{"data-devtools":"border-radius-handles",style:w,children:[Wl("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${c} ${u}`,children:[As("rect",{x:"0.5",y:"0.5",width:Math.max(0,c-1),height:Math.max(0,u-1),fill:"none",stroke:p,strokeWidth:"1"}),$l.map(I=>{let N=g[I],H=v.has(I);return As("circle",{cx:N.x,cy:N.y,r:I===(r!=null?r:o)?3:2.5,fill:n,stroke:"#ffffff",strokeWidth:I===(r!=null?r:o)?4:2,paintOrder:"stroke"},I)})]}),s&&x&&(()=>{let I=Math.round(t[x]);return As("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:I})})()]})}import{useEffect as Ku,useState as Xu}from"react";function gr(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o){let r=parseInt(o[1],16),s=parseInt(o[2],16),i=parseInt(o[3],16);return`rgba(${r}, ${s}, ${i}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}import{Fragment as qu,jsx as Ps,jsxs as ri}from"react/jsx-runtime";function Co({element:e,isSelected:t=!1,elementInfo:n,color:o="#3b82f6",annotationNumber:r,changeCount:s,hideTooltip:i=!1}){let[l,a]=Xu(null);if(Ku(()=>{if(!e){a(null);return}let L=()=>{let Y=e.getBoundingClientRect();a(Y)};return L(),window.addEventListener("scroll",L,{passive:!0}),window.addEventListener("resize",L,{passive:!0}),()=>{window.removeEventListener("scroll",L),window.removeEventListener("resize",L)}},[e]),!l||!e)return null;let d={position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9996,backgroundColor:gr(o,.05),overflow:"visible"},c=e.tagName.toLowerCase(),u=e.id?`#${e.id}`:"",p=e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",g=n==null?void 0:n.reactComponent,v=g?`<${g}> ${c}${u}${p}`:`${c}${u}${p}`,x=22,w=l.height>=window.innerHeight,I=w?0:l.top>=x?l.top-x:l.bottom,N=w?{position:"absolute",top:8,left:8,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400}:{position:"fixed",top:I,left:l.left,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400},O=!i&&ri("div",{"data-devtools":"tooltip",style:N,children:[r!==void 0&&ri("span",{children:[r,"."]}),Ps("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:v}),s!==void 0&&s>0&&ri("span",{style:{opacity:.8},children:["(",s," ",s===1?"change":"changes",")"]})]});return ri(qu,{children:[ri("div",{"data-devtools":"highlight",style:d,children:[Ps("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:Ps("rect",f({x:"0.5",y:"0.5",width:Math.max(0,l.width-1),height:Math.max(0,l.height-1),fill:"none",stroke:o,strokeWidth:"1"},!t&&{strokeDasharray:"2 4"}))}),w&&O]}),!w&&O]})}import{useEffect as Gl,useLayoutEffect as Zu,useState as Os}from"react";import{jsx as No,jsxs as Ds}from"react/jsx-runtime";function Bs(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function _s({element:e,gap:t,accentColor:n,hoveredAxis:o,draggingAxis:r,cursorViewport:s,isAutoGap:i=!1,refreshKey:l=0}){let[a,d]=Os(null),[c,u]=Os([]),[p,g]=Os(!1);if(Gl(()=>{let Z=h=>{(h.key==="Meta"||h.key==="Control")&&g(!0)},_=h=>{(h.key==="Meta"||h.key==="Control")&&g(!1)},B=()=>g(!1);return window.addEventListener("keydown",Z,!0),window.addEventListener("keyup",_,!0),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",Z,!0),window.removeEventListener("keyup",_,!0),window.removeEventListener("blur",B)}},[]),Gl(()=>{if(!e){d(null),u([]);return}let Z=()=>{d(e.getBoundingClientRect()),u(Ho(e))};return Z(),window.addEventListener("scroll",Z,{passive:!0}),window.addEventListener("resize",Z,{passive:!0}),()=>{window.removeEventListener("scroll",Z),window.removeEventListener("resize",Z)}},[e]),Zu(()=>{e&&(d(e.getBoundingClientRect()),u(Ho(e)))},[e,t.row,t.column,l]),!a||c.length===0)return null;let v=a.width,x=a.height,w="pm-gap-stripe-pattern",I=Bs(n,.25),N=Bs(n,.1),H=Bs(n,.2),O=8,L=2,Y={position:"fixed",top:a.top,left:a.left,width:v,height:x,pointerEvents:"none",zIndex:9996,overflow:"visible"},re=r!=null?r:o;return Ds("div",{"data-devtools":"gap-handles",style:Y,children:[Ds("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${v} ${x}`,children:[No("defs",{children:No("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:No("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:I,strokeWidth:"1.5"})})}),No("rect",{x:"0.5",y:"0.5",width:Math.max(0,v-1),height:Math.max(0,x-1),fill:"none",stroke:H,strokeWidth:"1"}),c.map((Z,_)=>{let B=Z.x-a.left,h=Z.y-a.top,A=Z.w,k=Z.h,be=p?Z.axis===re:!0;return(Z.axis==="row"?t.row:t.column)===0?null:Ds("g",{opacity:be?1:.6,children:[No("rect",{x:B,y:h,width:A,height:k,fill:N}),No("rect",{x:B,y:h,width:A,height:k,fill:`url(#${w})`})]},_)}),re&&(()=>{let Z=c.filter(Se=>Se.axis===re);if(Z.length===0)return null;let _=Z[0];if(s&&Z.length>1){let Se=1/0;for(let Pe of Z){let _e=Pe.x+Pe.w/2,Ze=Pe.y+Pe.h/2,Oe=Math.abs(s.x-_e)+Math.abs(s.y-Ze);Oe<Se&&(Se=Oe,_=Pe)}}let B=_.x-a.left,h=_.y-a.top,A=_.w,k=_.h,be=B+A/2,K=h+k/2;if(i)return No("circle",{cx:be,cy:K,r:1.5,fill:n,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"});let de=re==="column",F=de?L:O,me=de?O:L,R=be-F/2,ie=K-me/2;return No("rect",{x:R,y:ie,width:F,height:me,fill:n,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"})})()]}),s&&re&&(()=>{let Z=i?"auto":String(Math.round(re==="row"?t.row:t.column));return No("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:Z})})()]})}import{useCallback as op,useEffect as rp,useState as ip}from"react";import{useEffect as Qu,useState as Yl}from"react";var ep=3,tp=250,Hs=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],np=3e3;function Jl(e){let[t,n]=Yl(0),[o,r]=Yl(()=>Math.floor(Math.random()*Hs.length));return Qu(()=>{if(!e)return;let s=setInterval(()=>n(l=>(l+1)%ep),tp),i=setInterval(()=>r(l=>(l+1)%Hs.length),np);return()=>{clearInterval(s),clearInterval(i)}},[e]),{charIndex:t,word:Hs[o]}}import{Fragment as Ns,jsx as Vn,jsxs as $r}from"react/jsx-runtime";function sp(e){let{element:t}=e,n=t.tagName,o=t.id?`#${t.id}`:"",r=t.className?"."+t.className.split(" ").slice(0,2).join("."):"",s=t.reactComponent;return s?`<${s}> ${n}${o}${r}`:`${n}${o}${r}`}var Vl=22,zs=12;function ap(i){var l=i,{left:e,top:t,avoidBottom:n,style:o,children:r}=l,s=Dn(l,["left","top","avoidBottom","style","children"]);let a=n!==void 0?`${n}px`:"100vh";return Vn("div",y(f({"data-devtools":"badge-hit-area"},s),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:zs,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(${a} - max(0px, ${t}px) - 100%)))`},o),children:r}))}function Ul({styleModifications:e,isInspecting:t,accentColor:n,annotationGroupCount:o,dispatch:r,inFlightSelectors:s,toolbarRef:i,onHoverSelector:l}){var N;let[a,d]=ip([]),c=s&&s.size>0,{charIndex:u,word:p}=Jl(!!c);rp(()=>{if(t){d([]);return}let H=null,O=()=>{let re=[];e.forEach((Z,_)=>{let B=Hn(Z.selector);if(!B)return;let h=B.getBoundingClientRect();re.push({selector:Z.selector,modIndex:_,top:h.top>=Vl?h.top-Vl:h.bottom,left:h.left,label:sp(Z),changeCount:Z.changes.length,annotationNumber:o+_+1})}),d(re)},L=()=>{H&&cancelAnimationFrame(H),H=requestAnimationFrame(O)};O(),window.addEventListener("scroll",L,!0),window.addEventListener("resize",L,!0);let Y=new MutationObserver(L);return Y.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),window.addEventListener("load",L),document.fonts.ready.then(L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L,!0),window.removeEventListener("load",L),Y.disconnect(),H&&cancelAnimationFrame(H)}},[e,t,o]);let g=op(H=>{let O=e[H];if(!O)return;let L=Hn(O.selector);L&&(r({type:"SELECT_ANNOTATION",payload:{id:null}}),r({type:"SET_TOOL",payload:"inspector"}),r({type:"SELECT_ELEMENT",payload:{el:L,info:O.element}}))},[e,r]);if(a.length===0)return null;let v=(N=i==null?void 0:i.current)==null?void 0:N.getBoundingClientRect(),x=v?v.top-8:void 0,w={display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,whiteSpace:"nowrap",maxWidth:400},I={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};return Vn(Ns,{children:a.map(H=>{let O=s==null?void 0:s.has(H.selector);return Vn(ap,{left:H.left-zs,top:H.top-zs,avoidBottom:x,onClick:()=>g(H.modIndex),onMouseEnter:l?()=>l(H.selector):void 0,onMouseLeave:l?()=>l(null):void 0,style:{zIndex:1e4,cursor:"pointer",pointerEvents:"auto"},children:$r("div",{"data-devtools":"badge",style:y(f({},w),{backgroundColor:O?"#999999":n}),children:[$r("span",{children:[H.annotationNumber,"."]}),Vn("span",{style:I,children:H.label}),$r("span",{style:{opacity:.8},children:["(",H.changeCount," ",H.changeCount===1?"change":"changes",")"]}),O&&$r("span",{style:{opacity:.8,marginLeft:4,display:"inline-flex",alignItems:"center",gap:4},children:[Vn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:u===1?$r(Ns,{children:[Vn("circle",{cx:"7",cy:"7",r:"2"}),Vn("circle",{cx:"17",cy:"7",r:"2"}),Vn("circle",{cx:"7",cy:"17",r:"2"}),Vn("circle",{cx:"17",cy:"17",r:"2"})]}):$r(Ns,{children:[Vn("circle",{cx:"12",cy:"6",r:"2"}),Vn("circle",{cx:"6",cy:"12",r:"2"}),Vn("circle",{cx:"18",cy:"12",r:"2"}),Vn("circle",{cx:"12",cy:"18",r:"2"})]})}),p]})]})},H.selector)})})}import{useEffect as lp,useState as cp}from"react";import{Fragment as up,jsx as Kl}from"react/jsx-runtime";function dp(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Xl({styleModifications:e,accentColor:t}){let[n,o]=cp([]);if(lp(()=>{let s=null,i=()=>{let d=[];for(let c of e){let u=Hn(c.selector);if(!u)continue;let p=u.getBoundingClientRect();if(p.width===0&&p.height===0)continue;let g=pr(u);d.push({selector:c.selector,top:p.top,left:p.left,width:p.width,height:p.height,borderRadius:`${g["top-left"]}px ${g["top-right"]}px ${g["bottom-right"]}px ${g["bottom-left"]}px`})}o(d)},l=()=>{s&&cancelAnimationFrame(s),s=requestAnimationFrame(i)};i(),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0});let a=new MutationObserver(l);return a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),a.disconnect(),s&&cancelAnimationFrame(s)}},[e]),n.length===0)return null;let r=dp(t,.2);return Kl(up,{children:n.map(s=>{let i={position:"fixed",top:s.top,left:s.left,width:s.width,height:s.height,pointerEvents:"none",zIndex:9995,border:`1px solid ${r}`,borderRadius:s.borderRadius,boxSizing:"border-box"};return Kl("div",{"data-devtools":"mod-border",style:i},s.selector)})})}import{useEffect as ql,useLayoutEffect as pp,useState as Zl}from"react";import{jsx as Uo,jsxs as $s}from"react/jsx-runtime";function Fs(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var fp={top:"bottom",bottom:"top",left:"right",right:"left"};function Ws({element:e,padding:t,accentColor:n,hoveredSide:o,draggingSide:r,cursorViewport:s,refreshKey:i}){let[l,a]=Zl(null),[d,c]=Zl(!1);if(ql(()=>{let A=K=>{(K.key==="Meta"||K.key==="Control")&&c(!0)},k=K=>{(K.key==="Meta"||K.key==="Control")&&c(!1)},be=()=>c(!1);return window.addEventListener("keydown",A,!0),window.addEventListener("keyup",k,!0),window.addEventListener("blur",be),()=>{window.removeEventListener("keydown",A,!0),window.removeEventListener("keyup",k,!0),window.removeEventListener("blur",be)}},[]),ql(()=>{if(!e){a(null);return}let A=()=>{a(e.getBoundingClientRect())};return A(),window.addEventListener("scroll",A,{passive:!0}),window.addEventListener("resize",A,{passive:!0}),()=>{window.removeEventListener("scroll",A),window.removeEventListener("resize",A)}},[e]),pp(()=>{e&&a(e.getBoundingClientRect())},[e,t.top,t.right,t.bottom,t.left,i]),!l)return null;let u=l.width,p=l.height,{top:g,right:v,bottom:x,left:w}=t,I="pm-stripe-pattern",N=Fs(n,.25),H=Fs(n,.1),O=Fs(n,.2),L=8,Y=2,re={position:"fixed",top:l.top,left:l.left,width:u,height:p,pointerEvents:"none",zIndex:9996,overflow:"visible"},Z=["top","right","bottom","left"],_={top:`0,0 ${u},0 ${u-v},${g} ${w},${g}`,right:`${u},0 ${u},${p} ${u-v},${p-x} ${u-v},${g}`,bottom:`0,${p} ${w},${p-x} ${u-v},${p-x} ${u},${p}`,left:`0,0 ${w},${g} ${w},${p-x} 0,${p}`},B={top:{x:u/2-L/2,y:g/2-Y/2,w:L,h:Y},bottom:{x:u/2-L/2,y:p-x/2-Y/2,w:L,h:Y},left:{x:w/2-Y/2,y:p/2-L/2,w:Y,h:L},right:{x:u-v/2-Y/2,y:p/2-L/2,w:Y,h:L}},h=new Set;return r?h.add(r):o&&(h.add(o),d||h.add(fp[o])),$s("div",{"data-devtools":"padding-handles",style:re,children:[$s("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${u} ${p}`,children:[Uo("defs",{children:Uo("pattern",{id:I,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:Uo("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:N,strokeWidth:"1.5"})})}),Uo("rect",{x:"0.5",y:"0.5",width:Math.max(0,u-1),height:Math.max(0,p-1),fill:"none",stroke:O,strokeWidth:"1"}),Z.map(A=>{if(t[A]<=0)return null;let be=h.has(A);return $s("g",{opacity:be?1:.6,children:[Uo("polygon",{points:_[A],fill:H}),Uo("polygon",{points:_[A],fill:`url(#${I})`})]},A)}),Z.map(A=>{let k=B[A],be=h.has(A);return Uo("rect",{x:k.x,y:k.y,width:k.w,height:k.h,fill:n,stroke:"#ffffff",strokeWidth:be?4:2,paintOrder:"stroke"},`handle-${A}`)})]}),s&&(o||r)&&(()=>{let A=r!=null?r:o,k=Math.round(t[A]);return Uo("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:k})})()]})}import{useCallback as Eo,useEffect as no,useMemo as Ji,useRef as jn,useState as Cn}from"react";import{Check as Yi,ChevronDown as Xs,MoveHorizontal as dc,Shrink as Np}from"lucide-react";var gp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMicgaGVpZ2h0PScxMic+PGRlZnM+PHBhdHRlcm4gaWQ9J2QnIHdpZHRoPSc0JyBoZWlnaHQ9JzQnIHBhdHRlcm5Vbml0cz0ndXNlclNwYWNlT25Vc2UnPjxwYXRoIGQ9J00tMSwxIGwyLC0yIE0wLDQgbDQsLTQgTTMsNSBsMiwtMicgc3Ryb2tlPSdibGFjaycgc3Ryb2tlLXdpZHRoPScuNScvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9JzEyJyBoZWlnaHQ9JzEyJyBmaWxsPSd1cmwoI2QpJy8+PC9zdmc+",Ko={borderWidth:3,borderStyle:"solid",borderImage:`url("${gp}") 4 / 1.9 / 0 round`};function zi({color:e="rgb(0,0,0)",animated:t=!1}={}){let n=`<svg xmlns='http://www.w3.org/2000/svg' width='5' height='5'><path d='M-1,1 l2,-2 M0,5 l5,-5 M4,6 l2,-2' stroke='${e}' stroke-width='.75'/></svg>`;return f({position:"absolute",inset:-3,padding:5,backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(n)}")`,backgroundSize:"5px 5px",WebkitMask:"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0) border-box",WebkitMaskComposite:"xor",mask:"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0) border-box",maskComposite:"exclude",pointerEvents:"none"},t?{animation:"popmelt-border-march 0.8s linear infinite"}:{})}var Fi={"font-size":["rem","px","em"],"line-height":["","rem","px","em"],"letter-spacing":["rem","px","em"],gap:["rem","px","em"],"column-gap":["rem","px","em"],"row-gap":["rem","px","em"],padding:["rem","px","em","%"],margin:["rem","px","em","%"],width:["rem","px","%","em"],height:["rem","px","%","em"],"min-width":["rem","px","%","em"],"max-width":["rem","px","%","em"],"min-height":["rem","px","%","em"],"max-height":["rem","px","%","em"],"border-width":["px","rem","em"],"border-radius":["rem","px","%","em"]};function Wr(e){var t,n;return(n=(t=Fi[e])==null?void 0:t[0])!=null?n:"px"}function Xo(e){let t=e.match(/^([\d.-]+)(.*)$/);return t?{num:parseFloat(t[1]),unit:t[2]||""}:{num:0,unit:""}}function $i(e,t,n,o){let r=e.trim();if(!r)return"";let s=r.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i);if(s)return`${parseFloat(s[1])}${s[2].toLowerCase()}`;let i=parseFloat(r);if(!isNaN(i)){if(o){let{unit:l}=Xo(n);return`${i}${l||Wr(t)}`}return`${i}${Wr(t)}`}return r}function js(e,t){if(!t||t==="px")return e;if(t==="rem"){let n=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Math.round(e/n*1e3)/1e3}return e}import{useCallback as mp,useEffect as hp,useRef as Ql,useState as yp}from"react";import{Plus as ec,X as bp}from"lucide-react";import{jsx as Wn,jsxs as mr}from"react/jsx-runtime";var Wi=[{name:"blur",label:"Blur",unit:"px",defaultValue:10,min:0,max:100,step:1},{name:"brightness",label:"Brightness",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"contrast",label:"Contrast",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"saturate",label:"Saturate",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"grayscale",label:"Grayscale",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"sepia",label:"Sepia",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"invert",label:"Invert",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"hue-rotate",label:"Hue Rotate",unit:"deg",defaultValue:0,min:0,max:360,step:1},{name:"opacity",label:"Opacity",unit:"",defaultValue:1,min:0,max:1,step:.05}];function vp(e){if(!e||e==="none")return[];let t=[],n=/([\w-]+)\(([^)]+)\)/g,o;for(;(o=n.exec(e))!==null;){let r=o[1],s=o[2],i=parseFloat(s);isNaN(i)||t.push({name:r,value:i})}return t}function Gs(e){return e.length===0?"none":e.map(t=>{var r;let n=Wi.find(s=>s.name===t.name),o=(r=n==null?void 0:n.unit)!=null?r:"";return`${t.name}(${t.value}${o})`}).join(" ")}function tc({value:e,onChange:t,accentColor:n,modified:o,panelContentRef:r}){let s=vp(e),[i,l]=yp(!1),a=Ql(null),d=Ql(null);hp(()=>{if(!i)return;let H=O=>{a.current&&!O.composedPath().includes(a.current)&&l(!1)};return document.addEventListener("mousedown",H,!0),()=>document.removeEventListener("mousedown",H,!0)},[i]);let c=Wi.filter(H=>!s.some(O=>O.name===H.name)),u=H=>{let O=[...s,{name:H.name,value:H.defaultValue}];t(Gs(O)),l(!1)},p=H=>{let O=s.filter((L,Y)=>Y!==H);t(Gs(O))},g=(H,O)=>{let L=s.map((Y,re)=>re===H?y(f({},Y),{value:O}):Y);t(Gs(L))},v={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"},x=mp(H=>{var _;if(!d.current)return{position:"fixed",top:0,left:0};let O=d.current.getBoundingClientRect(),L=(_=r==null?void 0:r.current)==null?void 0:_.getBoundingClientRect(),Y=H*24+8,Z=window.innerHeight-O.bottom<Y;return y(f({position:"fixed"},Z?{bottom:window.innerHeight-O.top+2}:{top:O.bottom+2}),{left:L?L.left+4:O.left,width:L?L.width-8:140,zIndex:10001})},[r]),w={backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:4,padding:"4px 0",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},I={display:"block",width:"100%",padding:"4px 10px",border:"none",backgroundColor:"transparent",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#334155",cursor:"pointer",textAlign:"left"},N=H=>Wn("div",{ref:a,style:f(f({},x(H.length)),w),children:H.map(O=>Wn("button",{type:"button",onClick:()=>u(O),style:I,onMouseEnter:L=>{L.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor="transparent"},children:O.label},O.name))});return s.length===0?mr("div",{children:[mr("div",{style:{display:"flex",alignItems:"center",gap:4},children:[Wn(zo,{modified:!1,children:Wn("input",{type:"text",value:"",placeholder:"\u2014",readOnly:!0,style:y(f({},v),{color:"#999",cursor:"default"})})}),Wn("button",{ref:d,type:"button",onClick:()=>l(!i),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:Wn(ec,{size:12})})]}),i&&N(Wi)]}):mr("div",{style:{display:"flex",flexDirection:"column",gap:4,position:"relative"},children:[s.map((H,O)=>{let L=Wi.find(Y=>Y.name===H.name);return L?mr("div",{style:{display:"flex",alignItems:"center",gap:4},children:[Wn("span",{style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o?n:"#94a3b8",fontWeight:o?600:400,width:56,flexShrink:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:L.label}),Wn(zo,{modified:o,children:mr("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 4px"},children:[Wn("input",{type:"range",min:L.min,max:L.max,step:L.step,value:H.value,onChange:Y=>g(O,parseFloat(Y.target.value)),style:{flex:1,height:2,appearance:"none",WebkitAppearance:"none",background:`linear-gradient(to right, ${n} ${(H.value-L.min)/(L.max-L.min)*100}%, rgba(0,0,0,0.1) ${(H.value-L.min)/(L.max-L.min)*100}%)`,borderRadius:1,outline:"none",cursor:"pointer"}}),Wn("input",{type:"number",min:L.min,max:L.max,step:L.step,value:L.unit==="px"||L.unit==="deg"?Math.round(H.value):Math.round(H.value*100)/100,onChange:Y=>g(O,parseFloat(Y.target.value)||0),style:y(f({},v),{width:44,padding:"2px 4px",textAlign:"right",flexShrink:0})}),L.unit&&Wn("span",{style:{fontSize:9,color:"#94a3b8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',flexShrink:0,width:16},children:L.unit})]})}),Wn("button",{type:"button",onClick:()=>p(O),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:Wn(bp,{size:10})})]},H.name):null}),c.length>0&&mr("div",{children:[mr("button",{ref:d,type:"button",onClick:()=>l(!i),style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",border:"none",borderRadius:2,backgroundColor:"transparent",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#94a3b8",cursor:"pointer"},children:[Wn(ec,{size:10}),"Add filter"]}),i&&N(c)]})]})}import{useCallback as go,useEffect as Cp,useRef as ji,useState as nc}from"react";import{AlignHorizontalSpaceAround as Ep,AlignVerticalSpaceAround as kp,Columns3 as Tp,Grid2x2 as Mp,RectangleHorizontal as Ip,Rows3 as Rp,UnfoldHorizontal as oc,UnfoldVertical as rc}from"lucide-react";import{useCallback as xp,useEffect as Sp,useRef as ii}from"react";import{jsx as wp}from"react/jsx-runtime";var Ys=[0,1,2,4,8,12,16,20,24,28,32];function jr({value:e,onChange:t,onPreview:n,onScrubEnd:o,onReset:r,isModified:s,accentColor:i,defaultUnit:l="rem",snapSteps:a,color:d,style:c,children:u}){let p=ii(null),g=ii(null),v=ii(r),x=ii(s),w=ii(!1);v.current=r,x.current=s,Sp(()=>{let N=O=>{let L=g.current;if(!L)return;L.hasMoved=!0,w.current=O.shiftKey;let Y=L.unit==="rem"||L.unit==="em"?.1:1;L.accum+=O.movementX*Y;let re=Math.max(0,Math.round((L.startValue+L.accum)*10)/10);if(O.shiftKey&&a){let Z=L.unit==="rem"||L.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,_=L.unit==="rem"||L.unit==="em"?re*Z:re,B=a[a.length-1];for(let h=0;h<a.length-1;h++){let A=a[h],k=a[h+1];if(_<=(A+k)/2){B=A;break}if(_<k){B=k;break}}_>a[a.length-1]&&(B=Math.round(_/8)*8),re=L.unit==="rem"||L.unit==="em"?Math.round(B/Z*1e3)/1e3:B}n==null||n(`${re}${L.unit}`)},H=()=>{let O=g.current;if(!O)return;let L=Math.max(0,Math.round((O.startValue+O.accum)*10)/10);if(w.current&&a){let re=O.unit==="rem"||O.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,Z=O.unit==="rem"||O.unit==="em"?L*re:L,_=a[a.length-1];for(let B=0;B<a.length-1;B++){let h=a[B],A=a[B+1];if(Z<=(h+A)/2){_=h;break}if(Z<A){_=A;break}}Z>a[a.length-1]&&(_=Math.round(Z/8)*8),L=O.unit==="rem"||O.unit==="em"?Math.round(_/re*1e3)/1e3:_}let Y=O.hasMoved&&L!==O.startValue;g.current=null,document.exitPointerLock(),Y?t(`${L}${O.unit}`):O.hasMoved?n==null||n(`${O.startValue}${O.unit}`):x.current&&v.current&&v.current(),o==null||o()};return document.addEventListener("mousemove",N),document.addEventListener("mouseup",H),()=>{document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",H)}},[t,n,o]);let I=xp(N=>{var L;if(N.button!==0)return;N.preventDefault();let H=Xo(e),O=H.unit&&H.unit!=="px"?H.unit:l;g.current={startValue:H.num,unit:O,accum:0,hasMoved:!1},(L=p.current)==null||L.requestPointerLock()},[e,l]);return wp("span",{ref:p,onMouseDown:I,title:s?"Click to reset \xB7 Drag to scrub":"Drag to scrub",style:f({color:s?i||"#3b82f6":d||"#999",padding:"0 4px",display:"flex",alignItems:"center",cursor:"ew-resize"},c),children:u})}import{Fragment as Js,jsx as De,jsxs as gn}from"react/jsx-runtime";function Lp({gridCols:e,gridRows:t,gridModified:n,accentColor:o,onColsChange:r,onRowsChange:s}){return De(Un,{style:{width:100},children:gn("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 4px"},children:[De("input",{type:"number",min:1,max:12,value:e,onChange:i=>r(parseInt(i.target.value)||1),style:y(f({},wn),{width:32,textAlign:"center",padding:2})}),De("span",{style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:n?o:"#999",fontWeight:n?600:400,fontSize:11,margin:"0 4px"},children:"\xD7"}),De("input",{type:"number",min:1,max:12,value:t,onChange:i=>s(parseInt(i.target.value)||1),style:y(f({},wn),{width:32,textAlign:"center",padding:2})})]})})}function ic({element:e,getValue:t,getOriginalValue:n,handleChange:o,isModified:r,onResetProperty:s,isCollapsed:i,onToggle:l,sectionHeaderStyle:a,activeDropdown:d,onDropdownChange:c,panelContentRef:u,accentColor:p,onFieldHover:g,preferredUnit:v,onUnitCycle:x}){let w=c,I=t("display"),N=t("flex-direction"),H=sc(I,N),O=I==="flex"||I==="inline-flex",L=I==="grid",Y=O||L,re=N==="column"||N==="column-reverse",Z=t("width"),_=t("height"),B=r("width")?Z:Ai(e,"width"),h=r("height")?_:Ai(e,"height"),A=Vs(Z,B),k=Vs(_,h),be=t("min-width"),K=t("max-width"),de=t("min-height"),F=t("max-height"),me=Gr(t("padding")),R=t("gap"),ie=t("row-gap"),Se=t("column-gap"),Pe=t("grid-template-columns"),_e=t("grid-template-rows"),Ze=t("overflow"),Oe=Pe.split(/\s+/).filter(W=>W&&W!=="none").length||1,he=_e.split(/\s+/).filter(W=>W&&W!=="none").length||1,[Fe,rt]=nc(!1),ht=d!==null,Jt=ht||Fe,Q=ht?.3:Fe?.65:1,ne=({mode:W,icon:fe,active:Le})=>De("button",{type:"button",onClick:()=>ac(W,o),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:Le?gr(p,.15):"transparent",color:Le?p:"#64748b",cursor:"pointer",fontSize:14},children:fe}),Te=(W,fe,Le)=>{Le==="fixed"?o(W,fe):o(W,Gi(Le,fe))},$e=W=>{let fe=Gr(t("padding")),Le=W||"0";o("padding",`${fe.top} ${Le} ${fe.bottom} ${Le}`)},pt=W=>{let fe=Gr(t("padding")),Le=W||"0";o("padding",`${Le} ${fe.right} ${Le} ${fe.left}`)},[Je,ye]=nc({}),ct=go((W,fe)=>Le=>{fe(Le),ye(Gt=>y(f({},Gt),{[W]:Le}))},[]),Ge=go(W=>{ye(fe=>{let Le=f({},fe);return delete Le[W],Le})},[]),_t=go(W=>{let fe=Gr(t("padding"));Xe(e,"padding",`${fe.top} ${W} ${fe.bottom} ${W}`)},[e,t]),dt=go(W=>{let fe=Gr(t("padding"));Xe(e,"padding",`${W} ${fe.right} ${W} ${fe.left}`)},[e,t]),pe=go(W=>fe=>{Xe(e,W,fe)},[e]),se=re?"row":"column",Ce=se==="row"?"row-gap":"column-gap",Re=Ce==="row-gap"?ie||R:Se||R,it=r(Ce)||r("gap"),Me=go(()=>{let fe=Ho(e).find(Gt=>Gt.axis===se);if(fe)return se==="row"?fe.h:fe.w;let Le=ur(e);return se==="row"?Le.row:Le.column},[e,se]),en=go(()=>{let W=t("justify-content");return W==="space-between"?"between":W==="space-around"||W==="space-evenly"?"around":"fixed"},[t])(),pn=go((W,fe)=>{if(W==="fixed"){let Le=Math.max(0,Math.round(Me()*1e3)/1e3),Gt=fe||(Le>0?`${Le}px`:"8px");o("justify-content","normal"),o(Ce,Gt);return}o("justify-content",W==="between"?"space-between":"space-around"),o(Ce,"0px")},[Ce,Me,o]),zn=go(W=>{if(en!=="fixed"){pn("fixed",W);return}o(Ce,W)},[pn,en,Ce,o]),jt=go(W=>{Xe(e,"justify-content","normal"),Xe(e,Ce,W)},[e,Ce]),Ot=W=>W==="center"?1:W==="flex-end"||W==="end"?2:0,hn=Ot(t("justify-content")),vt=Ot(t("align-items")),Vt=re?vt:hn,Qe=re?hn:vt,xo=ji(null),Ke=ji({x:0,y:0}),Tt=ji({col:Vt,row:Qe});Tt.current={col:Vt,row:Qe};let Gn=go((W,fe)=>{let Le=["flex-start","center","flex-end"];re?(o("justify-content",Le[fe]),o("align-items",Le[W])):(o("justify-content",Le[W]),o("align-items",Le[fe]))},[re,o]),So=ji(Gn);So.current=Gn,Cp(()=>{let fe=Le=>{let Gt=xo.current;if(!Gt||!Le.composedPath().includes(Gt))return;Le.preventDefault(),Le.stopPropagation(),Ke.current.x+=Le.deltaX,Ke.current.y+=Le.deltaY;let{col:St,row:yn}=Tt.current,bn=!1;Math.abs(Ke.current.x)>=30&&(St=Math.max(0,Math.min(2,St+(Ke.current.x>0?1:-1))),Ke.current.x=0,Ke.current.y=0,bn=!0),!bn&&Math.abs(Ke.current.y)>=30&&(yn=Math.max(0,Math.min(2,yn+(Ke.current.y>0?1:-1))),Ke.current.x=0,Ke.current.y=0,bn=!0),bn&&(St!==Tt.current.col||yn!==Tt.current.row)&&So.current(St,yn)};return document.addEventListener("wheel",fe,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",fe,{capture:!0})},[]);let Fn=()=>De("div",{ref:xo,onMouseEnter:()=>{rt(!0),u.current&&(u.current.style.overflowY="hidden")},onMouseLeave:()=>{rt(!1),u.current&&(u.current.style.overflowY="auto")},style:{width:56,height:56,backgroundColor:to,borderRadius:2,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gridTemplateRows:"repeat(3, 1fr)",padding:6,gap:2,touchAction:"none"},children:[0,1,2].map(W=>[0,1,2].map(fe=>De("button",{type:"button",onClick:()=>Gn(fe,W),style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",backgroundColor:"transparent",cursor:"pointer",padding:0},children:fe===Vt&&W===Qe?De("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:fe===0?gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):fe===1?gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"2.5",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"1.5",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):gn(Js,{children:[De("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"4",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),De("rect",{x:"2",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]})}):De("div",{style:{width:5,height:5,borderRadius:"50%",backgroundColor:"#aaa"}})},`${W}-${fe}`)))}),rn=r("grid-template-columns")||r("grid-template-rows");return gn("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[De("div",{style:a,children:De("span",{children:Y?"Auto layout":"Layout"})}),gn("div",{style:{padding:"8px 12px"},children:[gn("div",{style:{display:"flex",gap:2,marginBottom:8,backgroundColor:to,borderRadius:2,padding:2,opacity:Q,transition:"opacity 150ms ease"},children:[De(ne,{mode:"block",icon:De(Ip,{size:16}),active:H==="block"}),De(ne,{mode:"flex-col",icon:De(Rp,{size:16}),active:H==="flex-col"}),De(ne,{mode:"flex-row",icon:De(Tp,{size:16}),active:H==="flex-row"}),De(ne,{mode:"grid",icon:De(Mp,{size:16}),active:H==="grid"})]}),gn("div",{style:{display:"flex",gap:4,marginBottom:8},children:[De(Us,{label:"W",property:"width",cssValue:A==="fixed"?Z:`${Math.round(e.getBoundingClientRect().width)}px`,mode:A,onValueChange:W=>o("width",W),onModeChange:W=>{if(W==="fixed"){let fe=e.getBoundingClientRect();o("width",`${Math.round(fe.width)}px`)}else o("width",Gi(W,Z))},modified:r("width"),dimmed:ht&&d!=="width",dropdownOpen:d==="width",onDropdownChange:W=>w(W?"width":null),panelContentRef:u,accentColor:p,onReset:()=>s("width"),minValue:be!=="none"&&be!=="0px"&&be!=="auto"?be:"",maxValue:K!=="none"&&K!=="auto"?K:"",onMinChange:W=>o("min-width",W||"0"),onMaxChange:W=>o("max-width",W||"none"),onMinReset:()=>s("min-width"),onMaxReset:()=>s("max-width"),minModified:r("min-width"),maxModified:r("max-width")}),De(Us,{label:"H",property:"height",cssValue:k==="fixed"?_:`${Math.round(e.getBoundingClientRect().height)}px`,mode:k,onValueChange:W=>o("height",W),onModeChange:W=>{if(W==="fixed"){let fe=e.getBoundingClientRect();o("height",`${Math.round(fe.height)}px`)}else o("height",Gi(W,_))},modified:r("height"),dimmed:ht&&d!=="height",dropdownOpen:d==="height",onDropdownChange:W=>w(W?"height":null),panelContentRef:u,minValue:de!=="none"&&de!=="0px"&&de!=="auto"?de:"",maxValue:F!=="none"&&F!=="auto"?F:"",onMinChange:W=>o("min-height",W||"0"),onMaxChange:W=>o("max-height",W||"none"),onMinReset:()=>s("min-height"),onMaxReset:()=>s("max-height"),minModified:r("min-height"),maxModified:r("max-height"),accentColor:p,onReset:()=>s("height")})]}),O&&gn("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8},children:[De("div",{style:{opacity:ht?.3:1,transition:"opacity 150ms ease"},children:Fn()}),gn("div",{style:{flex:1,opacity:Q,transition:"opacity 150ms ease"},children:[De("div",{onClick:it?()=>{s(Ce),s("gap")}:void 0,title:it?"Click to reset":void 0,style:{fontSize:9,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:it?p:"#999",fontWeight:it?600:400,marginBottom:2,cursor:it?"pointer":"default"},children:"Gap"}),De("div",{style:{display:"flex",gap:2,marginBottom:4,backgroundColor:to,borderRadius:2,padding:2},children:["fixed","between","around"].map(W=>{let fe=en===W;return De("button",{type:"button",onClick:()=>pn(W),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",border:"none",borderRadius:2,backgroundColor:fe?gr(p,.15):"transparent",color:fe?p:"#64748b",cursor:"pointer",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:fe?600:400,textTransform:"capitalize"},children:W},W)})}),De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:Re,onChange:W=>{Ge("gap"),zn(W)},onPreview:ct("gap",jt),onScrubEnd:()=>Ge("gap"),onReset:()=>{s(Ce),s("gap")},isModified:it,accentColor:p,defaultUnit:v,children:N==="column"||N==="column-reverse"?De(rc,{size:12,strokeWidth:it?2.5:1.5}):De(oc,{size:12,strokeWidth:it?2.5:1.5})}),De(mo,{property:Ce,value:Je.gap||(en==="fixed"?Re:`${Math.max(0,Math.round(Me()*1e3)/1e3)}px`),onChange:W=>zn(W),isModified:it||"gap"in Je,style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]})]}),L&&gn("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8,opacity:Q,transition:"opacity 150ms ease"},children:[De(Lp,{gridCols:Oe,gridRows:he,gridModified:rn,accentColor:p,onColsChange:W=>o("grid-template-columns",`repeat(${W}, 1fr)`),onRowsChange:W=>o("grid-template-rows",`repeat(${W}, 1fr)`)}),gn("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:Se||R,onChange:W=>{Ge("column-gap"),o("column-gap",W)},onPreview:ct("column-gap",pe("column-gap")),onScrubEnd:()=>Ge("column-gap"),onReset:()=>s("column-gap"),isModified:r("column-gap"),accentColor:p,defaultUnit:v,children:De(oc,{size:12,strokeWidth:r("column-gap")?2.5:1.5})}),De(mo,{property:"column-gap",value:Je["column-gap"]||Se||R,onChange:W=>o("column-gap",W),isModified:r("column-gap")||"column-gap"in Je,placeholder:"col",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})}),De(Un,{dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:ie||R,onChange:W=>{Ge("row-gap"),o("row-gap",W)},onPreview:ct("row-gap",pe("row-gap")),onScrubEnd:()=>Ge("row-gap"),onReset:()=>s("row-gap"),isModified:r("row-gap"),accentColor:p,defaultUnit:v,children:De(rc,{size:12,strokeWidth:r("row-gap")?2.5:1.5})}),De(mo,{property:"row-gap",value:Je["row-gap"]||ie||R,onChange:W=>o("row-gap",W),isModified:r("row-gap")||"row-gap"in Je,placeholder:"row",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]})]}),Y&&gn("div",{onMouseEnter:()=>g==null?void 0:g("padding"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:4,marginBottom:8,opacity:Q,transition:"opacity 150ms ease"},children:[De(Un,{style:{flex:1},dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:me.left,onChange:W=>{Ge("padding-h"),$e(W)},onPreview:ct("padding-h",_t),onScrubEnd:()=>Ge("padding-h"),onReset:()=>s("padding"),isModified:r("padding"),accentColor:p,defaultUnit:v,snapSteps:Ys,children:De(Ep,{size:12,strokeWidth:r("padding")?2.5:1.5})}),De(mo,{property:"padding",value:Je["padding-h"]||me.left,onChange:W=>$e(W),isModified:r("padding")||"padding-h"in Je,placeholder:"H pad",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})}),De(Un,{style:{flex:1},dimmed:ht,children:gn("div",{style:{display:"flex",alignItems:"center"},children:[De(jr,{value:me.top,onChange:W=>{Ge("padding-v"),pt(W)},onPreview:ct("padding-v",dt),onScrubEnd:()=>Ge("padding-v"),onReset:()=>s("padding"),isModified:r("padding"),accentColor:p,defaultUnit:v,snapSteps:Ys,children:De(kp,{size:12,strokeWidth:r("padding")?2.5:1.5})}),De(mo,{property:"padding",value:Je["padding-v"]||me.top,onChange:W=>pt(W),isModified:r("padding")||"padding-v"in Je,placeholder:"V pad",style:y(f({},wn),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:v,onUnitCycle:x})]})})]}),gn("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",opacity:Q,transition:"opacity 150ms ease"},children:[De("input",{type:"checkbox",checked:Ze==="hidden",onChange:W=>o("overflow",W.target.checked?"hidden":"visible"),style:{margin:0,accentColor:p}}),"Clip content"]})]})]})}import{AlignCenter as Ap,AlignJustify as Pp,AlignLeft as Op,AlignRight as Bp,Baseline as Dp,ChevronDown as _p,WholeWord as Hp}from"lucide-react";import{jsx as kt,jsxs as Fo}from"react/jsx-runtime";var lc={100:"Thin",200:"Extra Light",300:"Light",400:"Regular",500:"Medium",600:"Semi Bold",700:"Bold",800:"Extra Bold",900:"Black"};function cc({element:e,getValue:t,handleChange:n,isModified:o,onResetProperty:r,isCollapsed:s,onToggle:i,sectionHeaderStyle:l,accentColor:a,colorVariables:d,activeColorDropdown:c,onColorDropdownChange:u,panelContentRef:p,preferredUnit:g,onUnitCycle:v}){var A;let x=t("font-family"),w=t("font-size"),I=t("font-weight"),N=t("line-height"),H=t("letter-spacing"),O=t("text-align"),L=t("color"),Y=String(I),re=lc[Y]||Y,Z=Fr(e,L),_=L.includes("var(")?null:ni(Z,d),B=({align:k,icon:be})=>{let K=O===k;return kt("button",{type:"button",onClick:()=>n("text-align",k),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:K?gr(a,.15):"transparent",color:K?a:"#64748b",cursor:"pointer"},children:be})},h=((A=x.split(",")[0])==null?void 0:A.trim().replace(/^["']|["']$/g,""))||"System";return Fo("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[kt("div",{style:l,children:kt("span",{children:"Typography"})}),Fo("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[kt(Un,{children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px"},children:[kt("input",{type:"text",value:x,onChange:k=>n("font-family",k.target.value),style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("font-family")?600:400,color:o("font-family")?a:"inherit"}),title:x}),kt(_p,{size:12,style:{color:"#999",flexShrink:0,marginLeft:4}})]})}),Fo("div",{style:{display:"flex",gap:4},children:[kt(Un,{style:{flex:1},children:kt("select",{value:Y,onChange:k=>n("font-weight",k.target.value),style:y(f({},wn),{padding:"6px 8px",paddingLeft:4,paddingRight:20,cursor:"pointer",fontWeight:o("font-weight")?600:400,color:o("font-weight")?a:"inherit"}),children:Object.entries(lc).map(([k,be])=>kt("option",{value:k,children:be},k))})}),kt(Un,{style:{flex:1},children:kt("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:kt(mo,{property:"font-size",value:w,onChange:k=>n("font-size",k),isModified:o("font-size"),min:1,max:999,style:y(f({},wn),{padding:"6px 8px",paddingRight:24,fontWeight:o("font-size")?600:400,color:o("font-size")?a:"inherit"}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:g,onUnitCycle:v})})})]}),Fo("div",{style:{display:"flex",gap:4},children:[kt(Un,{style:{flex:1},children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[kt(Dp,{size:12,style:{color:o("line-height")?a:"#999",flexShrink:0}}),kt(mo,{property:"line-height",value:N,onChange:k=>n("line-height",k),isModified:o("line-height"),step:.1,min:0,placeholder:"Auto",style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("line-height")?600:400,color:o("line-height")?a:"inherit"}),showUnit:!1})]})}),kt(Un,{style:{flex:1},children:Fo("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[kt(Hp,{size:12,style:{color:o("letter-spacing")?a:"#999",flexShrink:0}}),kt(mo,{property:"letter-spacing",value:H,onChange:k=>n("letter-spacing",k),isModified:o("letter-spacing"),step:.1,placeholder:"\u2014",style:y(f({},wn),{flex:1,minWidth:0,padding:0,fontWeight:o("letter-spacing")?600:400,color:o("letter-spacing")?a:"inherit"}),showUnit:!1})]})})]}),Fo("div",{style:{display:"flex",gap:2,backgroundColor:to,borderRadius:2,padding:2},children:[kt(B,{align:"left",icon:kt(Op,{size:14})}),kt(B,{align:"center",icon:kt(Ap,{size:14})}),kt(B,{align:"right",icon:kt(Bp,{size:14})}),kt(B,{align:"justify",icon:kt(Pp,{size:14})})]}),Fo("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[kt("span",{onClick:o("color")?()=>r("color"):void 0,title:o("color")?"Click to reset":void 0,style:{fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o("color")?a:"#64748b",fontWeight:o("color")?600:400,cursor:o("color")?"pointer":"default",width:40,flexShrink:0},children:"Color"}),kt("div",{style:{flex:1,minWidth:0},children:kt(Ks,{value:L,resolvedValue:Z,colorVariables:d,matchingVariable:_,onChange:k=>n("color",k),accentColor:a,modified:o("color"),panelContentRef:p,isDropdownOpen:c==="color",onDropdownChange:k=>u(k?"color":null)})})]})]})]})}import{Fragment as Fp,jsx as Ee,jsxs as Yt}from"react/jsx-runtime";var uc=[{name:"Background",properties:[{property:"background-color",label:"Color",type:"color"},{property:"opacity",label:"Opacity",type:"number",step:.1,min:0,max:1}]},{name:"Borders",properties:[{property:"border-width",label:"Width",type:"number",min:0,max:20},{property:"border-color",label:"Color",type:"color"},{property:"border-radius",label:"Radius",type:"number",min:0,max:100},{property:"border-style",label:"Style",type:"select",options:["none","solid","dashed","dotted","double"]}]},{name:"Effects",properties:[{property:"box-shadow",label:"Box Shadow",type:"text"},{property:"backdrop-filter",label:"Backdrop Filter",type:"backdrop-filter"},{property:"transform",label:"Transform",type:"text"}]}];function zp(e,t){let n=t.trim().toLowerCase();switch(e){case"opacity":return n==="1";case"border-width":return n==="0px"||n==="0"||n==="medium";case"border-radius":return n==="0px"||n==="0";case"border-style":return n==="none";case"box-shadow":return n==="none";case"backdrop-filter":return n==="none"||n==="";case"letter-spacing":return n==="normal"||n==="0px"||n==="0";case"background-color":return n==="rgba(0, 0, 0, 0)"||n==="transparent";default:return!1}}function Vs(e,t){return!t||e==="auto"||e==="fit-content"||e==="max-content"||e==="min-content"?"hug":e==="100%"||t==="100%"?"fill":"fixed"}function Gi(e,t){switch(e){case"hug":return"fit-content";case"fill":return"100%";case"fixed":{let n=Xo(t);if(typeof n.num=="number"&&!isNaN(n.num)){let o=n.unit==="%"?"px":n.unit||"px";return`${n.num}${o}`}return"auto"}}}function Gr(e){let t=e.split(/\s+/).filter(Boolean);return t.length===1?{top:t[0],right:t[0],bottom:t[0],left:t[0]}:t.length===2?{top:t[0],right:t[1],bottom:t[0],left:t[1]}:t.length===3?{top:t[0],right:t[1],bottom:t[2],left:t[1]}:t.length>=4?{top:t[0],right:t[1],bottom:t[2],left:t[3]}:{top:"0px",right:"0px",bottom:"0px",left:"0px"}}function sc(e,t){return e==="grid"?"grid":e==="flex"||e==="inline-flex"?t==="column"||t==="column-reverse"?"flex-col":"flex-row":"block"}function ac(e,t){switch(e){case"block":t("display","block");break;case"flex-row":t("display","flex"),t("flex-direction","row");break;case"flex-col":t("display","flex"),t("flex-direction","column");break;case"grid":t("display","grid");break}}var to="rgba(0, 0, 0, 0.04)",wn={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};function Us({label:e,property:t,cssValue:n,mode:o,onValueChange:r,onModeChange:s,modified:i,dimmed:l,dropdownOpen:a,onDropdownChange:d,panelContentRef:c,accentColor:u="#3b82f6",onReset:p,minValue:g,maxValue:v,onMinChange:x,onMaxChange:w,onMinReset:I,onMaxReset:N,minModified:H,maxModified:O}){let L=Xo(n),Y=i?L.unit||Wr(t):Wr(t),re=!i&&L.unit&&L.unit!==Y?js(L.num,Y):L.num,[Z,_]=Cn(!1),[B,h]=Cn(String(re)),[A,k]=Cn(!1),be=jn(null),K=jn(null),de=jn(null),F=jn(!1);no(()=>{Z||h(String(re))},[re,Z]),no(()=>{if(!a)return;let Oe=Fe=>{K.current&&!Fe.composedPath().includes(K.current)&&de.current&&!Fe.composedPath().includes(de.current)&&(d==null||d(!1))},he=Fe=>{Fe.key==="Escape"&&(d==null||d(!1))};return document.addEventListener("mousedown",Oe),document.addEventListener("keydown",he),()=>{document.removeEventListener("mousedown",Oe),document.removeEventListener("keydown",he)}},[a,d]),no(()=>{Z&&be.current&&(be.current.focus(),be.current.select())},[Z]);let me=()=>{let Oe=$i(B,t,n,i);r(Oe||`${Math.max(0,parseFloat(B)||0)}${Y}`),_(!1)},R=()=>{if(F.current){F.current=!1;return}me()},ie=Oe=>{if(Oe.key==="Enter"){me();return}if(Oe.key==="Escape"){F.current=!0,h(String(re)),_(!1);return}if(Oe.key==="ArrowUp"||Oe.key==="ArrowDown"){Oe.preventDefault();let he=Oe.key==="ArrowUp"?1:-1,Fe=Oe.shiftKey?8:Oe.altKey?.1:1,rt=parseFloat(B)||0,ht=Math.round(Math.max(0,rt+he*Fe)*1e3)/1e3;h(String(ht)),r(`${ht}${Y}`)}},Se={fixed:"Fixed",hug:"Hug",fill:"Fill"},Pe={fixed:Ee(dc,{size:12}),hug:Ee(Np,{size:12}),fill:Ee(dc,{size:12})},_e=()=>{d==null||d(!a)},Ze=()=>{if(!de.current||!(c!=null&&c.current))return{position:"absolute",top:"100%",left:-4,right:-4,width:"calc(100% + 8px)",marginTop:4};let Oe=de.current.getBoundingClientRect(),he=c.current.getBoundingClientRect();return{position:"fixed",top:Oe.bottom+4,left:he.left+4,width:he.width-8}};return Yt("div",{ref:de,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),style:{flex:1,display:"flex",alignItems:"center",position:"relative",borderRadius:2,border:"1px solid",borderColor:Z?u:A?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease, opacity 150ms ease",opacity:l?.3:1},children:[Ee("span",{onClick:i&&p?p:void 0,title:i?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:i?u:"#999",fontWeight:i?600:400,padding:"0 8px",flexShrink:0,cursor:i?"pointer":"default"},children:e}),o==="fixed"?Z?Ee("input",{ref:be,type:"text",inputMode:"numeric",value:B,onChange:Oe=>h(Oe.target.value),onKeyDown:ie,onBlur:R,style:y(f({},wn),{flex:1,minWidth:0,padding:"4px 2px"})}):Ee("span",{onClick:()=>_(!0),style:{flex:1,padding:"4px 2px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text"},children:re}):Ee("span",{style:{flex:1}}),Yt("button",{type:"button",onClick:_e,style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",border:"none",outline:"none",backgroundColor:"transparent",color:"#999",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"pointer",flexShrink:0},children:[Se[o],Ee(Xs,{size:12})]}),a&&Yt("div",{ref:K,style:y(f({},Ze()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,overflow:"hidden",fontSize:12,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:[Yt("button",{type:"button",onClick:()=>{s("fixed"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="fixed"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="fixed"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.fixed,Yt("span",{children:["Fixed ",t," (",n,")"]}),o==="fixed"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Yt("button",{type:"button",onClick:()=>{s("hug"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="hug"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="hug"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.hug,Ee("span",{children:"Hug contents"}),o==="hug"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Yt("button",{type:"button",onClick:()=>{s("fill"),d==null||d(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:o==="fill"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:o==="fill"?600:400,cursor:"pointer",textAlign:"left"},children:[Pe.fill,Ee("span",{children:"Fill container"}),o==="fill"&&Ee(Yi,{size:14,style:{marginLeft:"auto"}})]}),Ee("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",margin:"4px 0"}}),Yt("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[Yt("div",{style:{display:"flex",alignItems:"center",backgroundColor:to,borderRadius:2,padding:"4px 8px"},children:[Ee("span",{onClick:H?Oe=>{Oe.stopPropagation(),I==null||I()}:void 0,title:H?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:H?u:"#999",fontWeight:H?600:400,marginRight:8,flexShrink:0,cursor:H?"pointer":"default"},children:"Min"}),Ee("input",{type:"text",value:g||"",placeholder:"\u2014",onChange:Oe=>x==null?void 0:x(Oe.target.value),onClick:Oe=>Oe.stopPropagation(),style:y(f({},wn),{flex:1,minWidth:0,padding:0,textAlign:"right",color:H?u:"inherit",fontWeight:H?600:400})})]}),Yt("div",{style:{display:"flex",alignItems:"center",backgroundColor:to,borderRadius:2,padding:"4px 8px"},children:[Ee("span",{onClick:O?Oe=>{Oe.stopPropagation(),N==null||N()}:void 0,title:O?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:O?u:"#999",fontWeight:O?600:400,marginRight:8,flexShrink:0,cursor:O?"pointer":"default"},children:"Max"}),Ee("input",{type:"text",value:v||"",placeholder:"\u2014",onChange:Oe=>w==null?void 0:w(Oe.target.value),onClick:Oe=>Oe.stopPropagation(),style:y(f({},wn),{flex:1,minWidth:0,padding:0,textAlign:"right",color:O?u:"inherit",fontWeight:O?600:400})})]})]})]})]})}function Un({children:e,style:t,dimmed:n}){let[o,r]=Cn(!1);return Ee("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:f({position:"relative",borderRadius:2,border:"1px solid",borderColor:o?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease, opacity 150ms ease",opacity:n?.3:1},t),children:e})}function zo({children:e}){let[t,n]=Cn(!1);return Ee("div",{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:t?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease"},children:e})}function mo({property:e,value:t,onChange:n,isModified:o=!1,step:r=1,min:s,max:i,style:l,placeholder:a,showUnit:d=!0,unitStyle:c,preferredUnit:u,onUnitCycle:p}){let g=Xo(t),v=Wr(e),x=Fi[e],I=u&&x&&x.includes(u)?u:v,N=o&&g.unit||I,H=!o&&g.unit&&g.unit!==N?js(g.num,N):g.num,[O,L]=Cn(!1),[Y,re]=Cn(""),Z=R=>{L(!0),re(String(H||"")),requestAnimationFrame(()=>R.target.select())},_=()=>{if(L(!1),Y.trim()){let R=$i(Y,e,t,o);R&&n(R)}},B=R=>{let ie=R.target.value;re(ie);let Se=ie.trim(),Pe=Se.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i),_e=Se.match(/^(-?[\d.]+)$/);if(Pe){let Ze=parseFloat(Pe[1]);isNaN(Ze)||n(`${Ze}${Pe[2].toLowerCase()}`)}else if(_e){let Ze=parseFloat(_e[1]);isNaN(Ze)||n(`${Ze}${N}`)}},h=R=>{if(R.key==="Enter"){if(Y.trim()){let ie=$i(Y,e,t,o);ie&&n(ie)}R.target.blur();return}if(R.key==="ArrowUp"||R.key==="ArrowDown"){R.preventDefault();let ie=R.shiftKey?10:R.altKey?.1:1,Se=(R.key==="ArrowUp"?1:-1)*r*ie,Pe=parseFloat(Y)||H||0,_e=Math.round((Pe+Se)*1e3)/1e3;s!==void 0&&(_e=Math.max(s,_e)),i!==void 0&&(_e=Math.min(i,_e)),re(String(_e)),n(`${_e}${N}`)}},A=/^-?[\d.]/.test(t.trim()),k=O?Y:A?String(H):"",K=O&&/\s*(rem|em|px|%)\s*$/i.test(Y)?"":N,de=p&&(K==="rem"||K==="px"),F={fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",pointerEvents:"none"},me=y(f({},c!=null?c:F),{pointerEvents:"auto",cursor:"pointer"});return Yt(Fp,{children:[Ee("input",{type:"text",inputMode:"decimal",value:k,onFocus:Z,onBlur:_,onChange:B,onKeyDown:h,placeholder:a,style:l}),d&&K&&Ee("span",{style:de?me:c!=null?c:F,onClick:de?p:void 0,title:de?"Click to switch units":void 0,children:K})]})}function Ks({value:e,resolvedValue:t,colorVariables:n,matchingVariable:o,onChange:r,accentColor:s="#3b82f6",modified:i,panelContentRef:l,isDropdownOpen:a,onDropdownChange:d}){let[c,u]=Cn(!1),p=e,[g,v]=Cn(p),[x,w]=Cn(!1),[I,N]=Cn(!1),[H,O]=Cn(!1),L=jn(null),Y=jn(null),re=jn(null),Z=a!==void 0?a:x,_=d||w,B=Eo(()=>{if(!re.current)return{position:"fixed",top:0,left:0,width:200};let R=re.current.getBoundingClientRect();if(l!=null&&l.current){let ie=l.current.getBoundingClientRect();return{position:"fixed",top:R.bottom+4,left:ie.left+4,width:ie.width-8}}return{position:"fixed",top:R.bottom+4,left:R.left,width:R.width}},[l]);no(()=>{c||v(e)},[e,c]),no(()=>{if(!Z&&!I)return;let R=Se=>{re.current&&!Se.composedPath().includes(re.current)&&(_(!1),N(!1))},ie=Se=>{Se.key==="Escape"&&(_(!1),N(!1))};return document.addEventListener("mousedown",R),document.addEventListener("keydown",ie),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",ie)}},[Z,I]),no(()=>{c&&L.current&&(L.current.focus(),L.current.select())},[c]);let h=Ji(()=>{if(!g||g.startsWith("#")||g.startsWith("rgb")||g.startsWith("hsl")||g.startsWith("oklch"))return[];let R=g.toLowerCase();return n.filter(ie=>ie.name.toLowerCase().includes(R)||ie.usage.toLowerCase().includes(R)).slice(0,8)},[g,n]),A=()=>{r(g),u(!1),N(!1)},k=R=>{v(R),R.includes("var")||R.includes("--")||R.length>0&&!R.startsWith("#")?N(!0):N(!1)},be=R=>{v(R.value),r(R.value),_(!1),N(!1),u(!1)},K=()=>{setTimeout(()=>{!Z&&!I&&A()},150)},de=R=>{R.key==="Enter"?A():R.key==="Escape"&&(v(e),u(!1),N(!1))},F=Ji(()=>{let R=t.trim().toLowerCase();if(R.startsWith("#"))return R.length===4?`#${R[1]}${R[1]}${R[2]}${R[2]}${R[3]}${R[3]}`:R.slice(0,7);let ie=R.match(/rgba?\((\d+),?\s*(\d+),?\s*(\d+)/);if(ie){let Pe=parseInt(ie[1],10).toString(16).padStart(2,"0"),_e=parseInt(ie[2],10).toString(16).padStart(2,"0"),Ze=parseInt(ie[3],10).toString(16).padStart(2,"0");return`#${Pe}${_e}${Ze}`}let Se=R.match(/oklch\(\s*([\d.]+)/);if(Se){let Pe=Math.max(0,Math.min(1,parseFloat(Se[1]))),_e=Math.round(Pe*255).toString(16).padStart(2,"0");return`#${_e}${_e}${_e}`}return"#000000"},[t]);return Yt("div",{ref:re,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:c?s:H?"rgba(0,0,0,0.15)":"transparent",backgroundColor:to,transition:"border-color 100ms ease",overflow:"hidden"},children:[Yt("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[Yt("div",{style:{position:"relative",marginLeft:8,flexShrink:0},children:[Ee("input",{type:"color",value:F,onChange:R=>{let ie=R.target.value;v(ie),r(ie)},style:{width:12,height:12,padding:0,border:"none",cursor:"pointer",opacity:0,position:"absolute",top:0,left:0}}),Ee("div",{style:{width:12,height:12,borderRadius:2,backgroundColor:t,border:"1px solid rgba(0,0,0,0.1)",pointerEvents:"none"}})]}),c?Ee("input",{ref:L,type:"text",value:g,onChange:R=>k(R.target.value),onKeyDown:de,onBlur:K,style:y(f({},wn),{flex:1,minWidth:0})}):Ee("span",{onClick:()=>u(!0),style:{flex:1,minWidth:0,padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:i?s:"inherit"},title:p,children:p}),n.length>0&&Ee("button",{type:"button",onClick:()=>_(!Z),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:24,border:"none",background:"none",cursor:"pointer",color:"#999",flexShrink:0},children:Ee(Xs,{size:12})})]}),I&&h.length>0&&Ee("div",{style:y(f({},B()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:200,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:h.map(R=>Yt("button",{type:"button",onClick:()=>be(R),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:"transparent",color:"#1e293b",cursor:"pointer",textAlign:"left",fontSize:12},children:[Ee("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:R.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),Ee("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:R.name})]},R.name))}),Z&&Ee("div",{ref:Y,style:y(f({},B()),{backgroundColor:"#eaeaea",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:280,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:n.map(R=>Yt("button",{type:"button",onClick:()=>be(R),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:(o==null?void 0:o.usage)===R.usage||e===R.value?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:(o==null?void 0:o.usage)===R.usage||e===R.value?600:400,cursor:"pointer",textAlign:"left",fontSize:12},children:[Ee("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:R.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),Ee("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:R.name}),((o==null?void 0:o.usage)===R.usage||e===R.value)&&Ee(Yi,{size:14,style:{marginLeft:"auto",flexShrink:0}})]},R.name))})]})}function pc({element:e,elementInfo:t,selector:n,styleModifications:o,dispatch:r,onClose:s,onHover:i,accentColor:l="#3b82f6",toolbarRef:a}){let d=jn(null),c=jn(null),[u,p]=Cn(()=>{try{return!!localStorage.getItem("devtools-panel-position")}catch(Q){return!1}});no(()=>{if(u)return;let Q=setTimeout(()=>p(!0),50);return()=>clearTimeout(Q)},[u]);let[g,v]=Cn(null),[x,w]=Cn(null),I=g!==null||x!==null,[N,H]=Cn("rem"),O=Eo(()=>{H(Q=>Q==="rem"?"px":"rem")},[]),L=jn(new Map),[Y,re]=Cn(""),Z=Ji(()=>Rs(),[]);no(()=>{let Q=ne=>{var $e;if(ne.key!=="Escape")return;let Te=document.activeElement;Te&&(($e=d.current)!=null&&$e.contains(Te))||s()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[s]);let _=jn({top:0,left:0,maxHeight:400}),[,B]=Cn(0),h="devtools-panel-position",A=jn({x:0,y:0}),k=jn(null),be=jn(!1);no(()=>{try{let Q=localStorage.getItem(h);if(Q){let ne=JSON.parse(Q);typeof ne.top=="number"&&typeof ne.left=="number"&&(be.current=!0,_.current=y(f({},_.current),{top:ne.top,left:ne.left}))}}catch(Q){}},[]),no(()=>{let Q=Te=>{var Me;let $e=k.current;if(!$e)return;let pt=$e.startOffsetX+(Te.clientX-$e.startX),Je=$e.startOffsetY+(Te.clientY-$e.startY),ye=280,ct=16,Ge=Math.max(ct,Math.min(window.innerWidth-ye-ct,_.current.left+pt)),_t=Math.max(ct,_.current.top+Je);A.current={x:Ge-_.current.left,y:_t-_.current.top};let dt=d.current,pe=dt==null?void 0:dt.parentElement;if(!pe)return;pe.style.top=`${_t}px`,pe.style.left=`${Ge}px`;let se=(Me=a==null?void 0:a.current)==null?void 0:Me.getBoundingClientRect(),Ce=window.innerHeight-16;se&&Ge+ye>se.left&&(Ce=se.top-8);let Re=Math.max(0,_t),it=Math.max(200,Ce-Re);dt&&(dt.style.maxHeight=`${it}px`)},ne=()=>{if(!k.current)return;let Te=_.current.top+A.current.y,$e=_.current.left+A.current.x;_.current=y(f({},_.current),{top:Te,left:$e}),A.current={x:0,y:0},be.current=!0;try{localStorage.setItem(h,JSON.stringify({top:Te,left:$e}))}catch(pt){}k.current=null};return window.addEventListener("mousemove",Q),window.addEventListener("mouseup",ne),()=>{window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",ne)}},[]);let K=Eo(Q=>{Q.button!==0||Q.target.closest("button")||(Q.preventDefault(),k.current={startX:Q.clientX,startY:Q.clientY,startOffsetX:A.current.x,startOffsetY:A.current.y})},[]);no(()=>{A.current={x:0,y:0};let Q=($e=!1)=>{var Ce;let pt=d.current,Je=280,ye=8,ct,Ge;if(be.current)ct=_.current.top,Ge=_.current.left;else{let Re=e.getBoundingClientRect();Ge=Re.right+ye,ct=Re.top,Ge+Je>window.innerWidth-ye&&(Ge=Re.left-Je-ye),Ge<ye&&(Ge=Math.max(ye,(window.innerWidth-Je)/2))}let _t=(Ce=a==null?void 0:a.current)==null?void 0:Ce.getBoundingClientRect(),dt=window.innerHeight-16;_t&&Ge+Je>_t.left&&(dt=_t.top-ye);let pe=Math.max(0,ct),se=Math.max(200,dt-pe);if(_.current={top:ct,left:Ge,maxHeight:se},$e&&pt){let Re=pt.parentElement;Re&&!be.current&&(Re.style.top=`${ct+A.current.y}px`,Re.style.left=`${Ge+A.current.x}px`),pt.style.maxHeight=`${se}px`}else B(Re=>Re+1)};Q(!1);let ne=()=>Q(!0),Te=()=>Q(!1);return window.addEventListener("scroll",ne,{passive:!0}),window.addEventListener("resize",Te,{passive:!0}),()=>{window.removeEventListener("scroll",ne),window.removeEventListener("resize",Te)}},[e]),no(()=>{let Q=d.current;if(!Q)return;let ne=Te=>{let $e=c.current;if(!$e){Te.preventDefault();return}let{scrollTop:pt,scrollHeight:Je,clientHeight:ye}=$e,ct=pt<=0&&Te.deltaY<0,Ge=pt+ye>=Je&&Te.deltaY>0;(ct||Ge)&&Te.preventDefault()};return Q.addEventListener("wheel",ne,{passive:!1}),()=>Q.removeEventListener("wheel",ne)},[]);let de=Ji(()=>o.find(Q=>Q.selector===n),[o,n]),F=Eo(Q=>{let ne=de==null?void 0:de.changes.find(Te=>Te.property===Q);return ne?ne.modified:Li(e,Q)},[e,de]),me=Eo((Q,ne)=>{if(!Q.includes("color"))return ne;let Te=ne.trim(),$e=Z.find(Je=>Je.usage===Te||Je.name===Te),pt=($e==null?void 0:$e.value)||Te;return Fr(e,pt)},[Z,e]),R=Eo(Q=>{if(L.current.has(Q))return L.current.get(Q);let ne=de==null?void 0:de.changes.find($e=>$e.property===Q);if(ne)return ne.original;let Te=Li(e,Q);return L.current.set(Q,Te),Te},[e,de]),ie=Eo((Q,ne)=>{let Te=R(Q),$e=me(Q,ne);Xe(e,Q,$e),Q==="backdrop-filter"&&Xe(e,"-webkit-backdrop-filter",$e),r({type:"MODIFY_STYLE",payload:{selector:n,element:t,property:Q,original:Te,modified:$e}})},[e,n,t,r,me,R]),Se=Eo(Q=>{let ne=o.find($e=>$e.selector===n);ne!=null&&ne.changes.find($e=>$e.property===Q)&&e instanceof HTMLElement&&(e.style.removeProperty(Q),r({type:"CLEAR_STYLE",payload:{selector:n,property:Q}}),L.current.delete(Q))},[e,n,o,r]),Pe=Eo(()=>{let Q=Y.split(";").map(ne=>ne.trim()).filter(ne=>ne);for(let ne of Q){let Te=ne.indexOf(":");if(Te>0){let $e=ne.slice(0,Te).trim(),pt=ne.slice(Te+1).trim();$e&&pt&&ie($e,pt)}}re("")},[Y,ie]),_e=Eo(Q=>{var ne;return(ne=de==null?void 0:de.changes.some(Te=>Te.property===Q))!=null?ne:!1},[de]),Ze=Q=>{var Je;let ne=F(Q.property),Te=_e(Q.property),$e=!Te&&zp(Q.property,ne),pt={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};if($e&&Q.type!=="backdrop-filter")return Ee(zo,{modified:!1,children:Ee("input",{type:"text",value:"",placeholder:"\u2014",onFocus:()=>{},onChange:ye=>ie(Q.property,ye.target.value),style:y(f({},pt),{color:"#999"})})});switch(Q.type){case"color":{let ye=Fr(e,ne),ct=ne.includes("var(")?null:ni(ye,Z);return Ee(Ks,{value:ne,resolvedValue:ye,colorVariables:Z,matchingVariable:ct,onChange:Ge=>ie(Q.property,Ge),accentColor:l,modified:Te,panelContentRef:c,isDropdownOpen:x===Q.property,onDropdownChange:Ge=>w(Ge?Q.property:null)})}case"number":{if(!!Fi[Q.property])return Ee(zo,{modified:Te,children:Ee(mo,{property:Q.property,value:ne,onChange:Ge=>ie(Q.property,Ge),isModified:Te,min:Q.min,max:Q.max,step:Q.step||1,style:y(f({},pt),{paddingRight:32}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:N,onUnitCycle:O})});let{num:ct}=Xo(ne);return Ee(zo,{modified:Te,children:Ee("input",{type:"number",value:ct,min:Q.min,max:Q.max,step:Q.step||1,onChange:Ge=>ie(Q.property,Ge.target.value),style:pt})})}case"select":return Ee(zo,{modified:Te,children:Yt("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[Ee("select",{value:ne,onChange:ye=>ie(Q.property,ye.target.value),style:y(f({},pt),{cursor:"pointer",paddingLeft:4,paddingRight:24,appearance:"none",WebkitAppearance:"none"}),children:(Je=Q.options)==null?void 0:Je.map(ye=>Ee("option",{value:ye,children:ye},ye))}),Ee("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:"#999",display:"flex",alignItems:"center"},children:Ee(Xs,{size:12})})]})});case"spacing":return Ee(zo,{modified:Te,children:Ee("input",{type:"text",value:ne,onChange:ye=>ie(Q.property,ye.target.value),placeholder:"e.g., 10px or 10px 20px",style:pt})});case"backdrop-filter":return Ee(tc,{value:ne,onChange:ye=>ie(Q.property,ye),accentColor:l,modified:Te,panelContentRef:c});default:return Ee(zo,{modified:Te,children:Ee("input",{type:"text",value:ne,onChange:ye=>ie(Q.property,ye.target.value),style:pt})})}},Oe=t.reactComponent||t.tagName,he={position:"fixed",top:_.current.top,left:_.current.left,width:280,maxHeight:_.current.maxHeight,backgroundColor:"#eaeaea",borderWidth:3,borderStyle:"solid",borderColor:"transparent",boxSizing:"content-box",zIndex:10002,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontSize:12,overflow:"visible",display:"flex",flexDirection:"column",opacity:u?1:0,transition:"opacity 150ms ease"},Fe={display:"flex",alignItems:"center",justifyContent:"space-between",margin:4,padding:"4px 5px 4px 10px",backgroundColor:l,color:"#ffffff",cursor:k.current?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},rt={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 12px 6px",userSelect:"none",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:600,color:"#475569"},ht={display:"flex",alignItems:"center",padding:"4px 12px",gap:8},Jt={width:80,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",flexShrink:0};return Ee("div",{"data-devtools":"panel-wrapper",style:{position:"fixed",top:_.current.top+A.current.y,left:_.current.left+A.current.x,zIndex:10002,pointerEvents:"none"},children:Yt("div",{ref:d,"data-devtools":"panel",style:y(f({},he),{position:"relative",top:0,left:0,zIndex:0,pointerEvents:"auto"}),onMouseEnter:()=>i==null?void 0:i("element"),onMouseLeave:()=>i==null?void 0:i(null),children:[Ee("div",{"aria-hidden":"true",style:zi()}),Yt("div",{style:Fe,onMouseDown:K,children:[Ee("div",{style:{display:"flex",alignItems:"center",gap:3,overflow:"hidden",minWidth:0},children:Ee("span",{style:{fontWeight:600,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:Oe})}),Ee("button",{type:"button",onClick:s,title:"Close",style:{background:"none",border:"none",cursor:"pointer",fontSize:16,color:"#ffffff",padding:"0 4px",lineHeight:1,flexShrink:0},children:"\xD7"})]}),Yt("div",{ref:c,style:{flex:1,overflowY:"auto",margin:"0 3px 3px"},children:[Ee("div",{style:{opacity:x?.3:1,transition:"opacity 150ms ease"},children:Ee(ic,{element:e,getValue:F,getOriginalValue:R,handleChange:ie,isModified:_e,onResetProperty:Se,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:rt,activeDropdown:g,onDropdownChange:v,panelContentRef:c,accentColor:l,onFieldHover:i,preferredUnit:N,onUnitCycle:O})}),Ee("div",{style:{opacity:g?.3:1,transition:"opacity 150ms ease"},children:Ee(cc,{element:e,getValue:F,handleChange:ie,isModified:_e,onResetProperty:Se,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:rt,accentColor:l,colorVariables:Z,activeColorDropdown:x,onColorDropdownChange:w,panelContentRef:c,preferredUnit:N,onUnitCycle:O})}),uc.map((Q,ne)=>{let Te=ne===uc.length-1,$e=x&&Q.properties.some(Je=>Je.property===x);return Yt("div",{style:{borderBottom:Te?"none":"1px solid rgba(0,0,0,0.08)",opacity:I&&!$e?.3:1,transition:"opacity 150ms ease"},children:[Ee("div",{style:rt,children:Ee("span",{children:Q.name})}),Ee("div",{style:{padding:"4px 0"},children:Q.properties.map(Je=>{let ye=_e(Je.property),ct=$e&&Je.property!==x;return Yt("div",{style:y(f({},ht),{opacity:ct?.3:1,transition:"opacity 150ms ease"}),children:[Ee("span",{onClick:ye?()=>Se(Je.property):void 0,title:ye?"Click to reset":void 0,style:y(f({},Jt),{color:ye?l:"#64748b",fontWeight:ye?600:400,cursor:ye?"pointer":"default"}),children:Je.label}),Ee("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:Ze(Je)})]},Je.property)})})]},Q.name)}),Yt("div",{style:{opacity:I?.3:1,transition:"opacity 150ms ease"},children:[Ee("div",{style:rt,children:Ee("span",{children:"Raw CSS"})}),Yt("div",{style:{padding:"8px 12px"},children:[Ee("textarea",{value:Y,onChange:Q=>re(Q.target.value),placeholder:"property: value; ...",style:{width:"100%",height:60,padding:8,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"1px solid rgba(0,0,0,0.1)",borderRadius:2,resize:"vertical",outline:"none"}}),Y.trim()&&Ee("button",{type:"button",onClick:Pe,style:{marginTop:4,padding:"4px 8px",width:"100%",fontSize:11,border:"none",borderRadius:2,backgroundColor:l,color:"#fff",cursor:"pointer",opacity:Y.trim()?1:.5},children:"Apply"})]})]})]})]})})}import{useEffect as $p,useLayoutEffect as Wp,useState as jp}from"react";import{Fragment as Vp,jsx as hr,jsxs as Jp}from"react/jsx-runtime";var qs=["flex-start","center","flex-end"],Zs=["flex-start","center","flex-end"];function Gp(e){return e==="normal"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Yp(e){return e==="normal"||e==="stretch"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function fc(e){let t=Array.from(e.children);if(t.length===0)return null;let n=1/0,o=1/0,r=-1/0,s=-1/0;for(let i of t){let l=i.getBoundingClientRect();l.width===0&&l.height===0||(l.top<n&&(n=l.top),l.left<o&&(o=l.left),l.bottom>r&&(r=l.bottom),l.right>s&&(s=l.right))}return n===1/0?null:new DOMRect(o,n,s-o,r-n)}function gc({element:e,modifier:t,accentColor:n,refreshKey:o=0}){let[r,s]=jp(null);if($p(()=>{if(!e){s(null);return}let x=()=>s(fc(e));return x(),window.addEventListener("scroll",x,{passive:!0}),window.addEventListener("resize",x,{passive:!0}),()=>{window.removeEventListener("scroll",x),window.removeEventListener("resize",x)}},[e]),Wp(()=>{e&&s(fc(e))},[e,o]),!r)return null;let i=r,l=window.getComputedStyle(e),a=l.display;if(a!=="flex"&&a!=="inline-flex")return null;let d=l.flexDirection,c=d==="column"||d==="column-reverse"?"vertical":"horizontal",u=c==="horizontal"?"vertical":"horizontal",p=[];if(t==="shift"){let x=Gp(l.justifyContent);if(x){let w=qs.indexOf(x);c==="horizontal"?(w>0&&p.push("left"),w<qs.length-1&&p.push("right")):(w>0&&p.push("up"),w<qs.length-1&&p.push("down"))}}else{let x=Yp(l.alignItems);if(x){let w=Zs.indexOf(x);u==="horizontal"?(w>0&&p.push("left"),w<Zs.length-1&&p.push("right")):(w>0&&p.push("up"),w<Zs.length-1&&p.push("down"))}}if(p.length===0)return null;let g=14,v=7;return hr(Vp,{children:p.map(x=>{let w,I;switch(x){case"right":w=i.right+g,I=i.top+i.height/2;break;case"left":w=i.left-g,I=i.top+i.height/2;break;case"down":w=i.left+i.width/2,I=i.bottom+g;break;case"up":w=i.left+i.width/2,I=i.top-g;break}let N=x==="right"?0:x==="left"?180:x==="down"?90:-90,H={position:"fixed",left:w-v,top:I-v,width:v*2,height:v*2,pointerEvents:"none",zIndex:9997};return hr("div",{"data-devtools":"swipe-hint",style:H,children:hr("svg",{width:v*2,height:v*2,viewBox:"-7 -7 14 14",style:{overflow:"visible"},children:Jp("g",{transform:`rotate(${N})`,children:[hr("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round"}),hr("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),hr("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:n,strokeWidth:"1.5",strokeLinecap:"round"}),hr("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:n,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})},x)})})}import{useEffect as Up,useLayoutEffect as Kp,useState as Xp}from"react";import{jsx as Qs,jsxs as ea}from"react/jsx-runtime";function qp(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);return n?`oklch(${n[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function mc({element:e,fontSize:t,lineHeight:n,accentColor:o,hoveredProperty:r,draggingProperty:s,cursorViewport:i}){let[l,a]=Xp(null);if(Up(()=>{if(!e){a(null);return}let I=()=>{a(zr(e))};return I(),window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I,{passive:!0}),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I)}},[e]),Kp(()=>{e&&a(zr(e))},[e,t,n]),!l)return null;let d=l.width,c=l.height,u=qp(o,.2),p=s!=null?s:r,g=8,v=2,x={position:"fixed",top:l.top,left:l.left,width:d,height:c,pointerEvents:"none",zIndex:9996,overflow:"visible"},w=I=>I==="font-size"?`${Math.round(t)}`:(t>0?n/t:1.2).toFixed(2).replace(/\.?0+$/,"");return ea("div",{"data-devtools":"text-handles",style:x,children:[ea("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${d} ${c}`,children:[Qs("rect",{x:"0.5",y:"0.5",width:Math.max(0,d-1),height:Math.max(0,c-1),fill:"none",stroke:u,strokeWidth:"1"}),(p==="font-size"||!p)&&Qs("rect",{x:d-v/2,y:c/2-g/2,width:v,height:g,fill:o,stroke:"#ffffff",strokeWidth:p==="font-size"?4:2,paintOrder:"stroke"}),(p==="line-height"||!p)&&Qs("rect",{x:d/2-g/2,y:c-v/2,width:g,height:v,fill:o,stroke:"#ffffff",strokeWidth:p==="line-height"?4:2,paintOrder:"stroke"})]}),i&&p&&(()=>{let I=p==="font-size"?"Aa":"Lh",N=w(p);return ea("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:[I," ",N]})})()]})}import{Fragment as Jr,jsx as ft,jsxs as Yr}from"react/jsx-runtime";var hc=8,ta=[0,1,2,4,8,12,16,20,24,28,32],na="devtools-active-text";function yc(e,t,n=0,o,r){let s=e.left+window.scrollX+4,i=t==="top-left"?e.top+window.scrollY-eo-n*eo+4:e.bottom+window.scrollY+4-1+n*eo,l=window.scrollY+4,a=window.scrollY+window.innerHeight-eo-4,d=90,c=!1;if(o&&r!==void 0){let u=o.getBoundingClientRect();if(e.left+4+r+4+d>u.left){let g=window.scrollY+u.top-eo-4;g<a&&(a=g,c=!0)}}return i<l?i=e.top+window.scrollY+4:i>a&&(i=c?a:Math.max(e.top+window.scrollY+4,a)),{x:s,y:i}}function bc({state:e,dispatch:t,onScreenshot:n,inFlightAnnotationIds:o,activeAnnotationIds:r,queuePositionMap:s,inFlightStyleSelectors:i,inFlightSelectorColors:l,onAttachImages:a,onReply:d,onViewThread:c,onCloseThread:u,onModelComponentsAdd:p,onModelComponentFocus:g,onModelComponentHover:v,modelComponentNames:x,modelPanelHoveredComponent:w,modelSpacingTokenHover:I,highlightedAnnotationIds:N,focusedThreadAnnotationId:H,externalCanvasRef:O,toolbarRef:L}){var et,Ue,Rt,Ct,gt,zt,xt,ln,lo;let{canvasRef:Y,redrawAll:re,resizeCanvas:Z}=bl(),_=un(m=>{Y.current=m,O&&(O.current=m)},[O,Y]),B=Qt(!1);kn(()=>{let m=Y.current;if(!m)return;let b=()=>{B.current&&(B.current=!1,m.style.pointerEvents="")},G=M=>{M.button===0&&B.current&&b()};return window.addEventListener("mousedown",G),()=>window.removeEventListener("mousedown",G)},[Y]);let[h,A]=bt(!1),[k,be]=bt(()=>{if(typeof window=="undefined")return null;try{let m=localStorage.getItem(na);return m?JSON.parse(m):null}catch(m){return null}}),[K,de]=bt(null),[F,me]=bt(null),[R,ie]=bt(null),Se=Qt(null),Pe=Qt(null),_e=Qt({x:0,y:0}),Ze=Qt([]),Oe=Qt(0),[he,Fe]=bt(null),[rt,ht]=bt(new Map),Jt=Qt(0),Q=Qt(null),[ne,Te]=bt(null),[$e,pt]=bt(null),[Je,ye]=bt(null),[ct,Ge]=bt(null),_t=Qt({isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null}),[dt,pe]=bt(null),[se,Ce]=bt(null),[Re,it]=bt(null),[Me,Wt]=bt(null),en=Qt({x:0,y:0}),[pn,zn]=bt({x:0,y:0}),jt=Qt({isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0}),[Ot,hn]=bt(null),[vt,Vt]=bt(null),[Qe,xo]=bt(null),[Ke,Tt]=bt(!1),[Gn,So]=bt(0),[Fn,rn]=bt(null),Tn=Qt({isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null}),[W,fe]=bt(null),[Le,Gt]=bt(null),[St,yn]=bt(null),bn=Qt({isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null}),[Ut,Pn]=bt(null),[vn,Io]=bt(null),[yt,Ro]=bt(null),io=vl(),jo=Qt(l);jo.current=l;let qn=un(m=>{let b=jo.current;if(!b||b.size===0)return!1;for(let G of b.keys())try{if(m.matches(G))return!0}catch(M){}return!1},[]),Mn=Qt(e);Mn.current=e;let Lo=Qt(k);Lo.current=k;let Zn=Qt([]),Kt=Qt(n);Kt.current=n;let[Bt,Xt]=bt(null),sn=e.selectedAnnotationIds;Zn.current=sn;let $n=un((m,b=!1)=>{t({type:"SELECT_ANNOTATION",payload:{id:m,addToSelection:b}})},[t]),wo=un(()=>{t({type:"SELECT_ANNOTATION",payload:{id:null}})},[t]),[In,Ao]=bt(null),[an,Go]=bt({x:window.scrollX,y:window.scrollY});kn(()=>(Z(),window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)),[Z]),kn(()=>{let m=()=>{Go({x:window.scrollX,y:window.scrollY})};return window.addEventListener("scroll",m,{passive:!0}),()=>window.removeEventListener("scroll",m)},[]),kn(()=>{k?localStorage.setItem(na,JSON.stringify(k)):localStorage.removeItem(na)},[k]),xl(k,be,K,e.annotations,t);let Po=Qt(he);Po.current=he,kn(()=>{if(e.activeTool!=="model"||!e.isAnnotating)return;let m=b=>{if(!b.altKey||!Po.current)return;b.preventDefault();let G=b.deltaY>0?-1:1;Jt.current=Math.max(0,Jt.current+G);let M=Q.current;if(M){let C=Ii(M,Jt.current);Fe(C)}};return window.addEventListener("wheel",m,{passive:!1}),()=>window.removeEventListener("wheel",m)},[e.activeTool,e.isAnnotating]),kn(()=>{e.activeTool!=="model"&&(Fe(null),ht(new Map),Jt.current=0,Q.current=null)},[e.activeTool]),kn(()=>{var G;let m=(G=he==null?void 0:he.name)!=null?G:null,b=m&&(x!=null&&x.has(m))?m:null;v==null||v(b)},[he,x,v]);let[so,Er]=bt(null);kn(()=>{var G;if(!w){Er(null);return}let m=_r(w.name),b=w.instanceIndex;Er((G=m[b%m.length])!=null?G:null)},[w]);let[ao,Qo]=bt([]);kn(()=>{var m,b;if(!I){Qo([]);return}(b=(m=I.token)==null?void 0:m.bindings)!=null&&b.length?Qo(ks(I.token)):Qo(Cs(I.px))},[I]);let Yo=Qt(null),On=Qt(null);Yo.current=Ot,On.current=vt,kn(()=>{let m=["flex-start","center","flex-end"],b=["flex-start","center","flex-end"],M=null,C=!1,$=null,oe=null,j=(xe,ze)=>{let at=dr(xe,ze);for(;at&&at!==document.documentElement;){let wt=window.getComputedStyle(at).display;if(wt==="flex"||wt==="inline-flex")return at;at=at.parentElement}return null},te=xe=>{let ze=window.getComputedStyle(xe).flexDirection;return ze==="column"||ze==="column-reverse"?"vertical":"horizontal"},E=xe=>{let ze=xe.getAttribute("data-pm");return ze||(ze=Math.random().toString(36).substring(2,8),xe.setAttribute("data-pm",ze)),{selector:`[data-pm="${ze}"]`,durableSelector:Jn(xe)}},T=()=>{C=!0,M&&clearTimeout(M),M=setTimeout(()=>{C=!1,M=null},300)},X=(xe,ze,ut)=>{let at=te(xe);if(ze===at){let qe=window.getComputedStyle(xe).justifyContent,Ht=qe==="normal"||qe==="flex-start"||qe==="start"?"flex-start":qe==="flex-end"||qe==="end"?"flex-end":qe==="center"?"center":null;if(!Ht)return;let fn=m.indexOf(Ht)+ut;if(fn<0||fn>=m.length)return;let Do=m[fn],{selector:tr,durableSelector:as}=E(xe);Xe(xe,"justify-content",Do),t({type:"MODIFY_STYLES_BATCH",payload:{selector:tr,durableSelector:as,element:Nn(xe),changes:[{property:"justify-content",original:qe,modified:Do}]}})}else{let qe=window.getComputedStyle(xe).flexDirection,Ht=at==="horizontal"?"column":"row",{selector:co,durableSelector:fn}=E(xe);Xe(xe,"flex-direction",Ht),t({type:"MODIFY_STYLES_BATCH",payload:{selector:co,durableSelector:fn,element:Nn(xe),changes:[{property:"flex-direction",original:qe,modified:Ht}]}})}So(wt=>wt+1)},z=(xe,ze,ut)=>{let wt=te(xe)==="horizontal"?"vertical":"horizontal";if(ze!==wt)return;let Ht=window.getComputedStyle(xe).alignItems,co=Ht==="normal"||Ht==="stretch"||Ht==="flex-start"||Ht==="start"?"flex-start":Ht==="flex-end"||Ht==="end"?"flex-end":Ht==="center"?"center":null;if(!co)return;let Do=b.indexOf(co)+ut;if(Do<0||Do>=b.length)return;let tr=b[Do],{selector:as,durableSelector:fd}=E(xe);Xe(xe,"align-items",tr),t({type:"MODIFY_STYLES_BATCH",payload:{selector:as,durableSelector:fd,element:Nn(xe),changes:[{property:"align-items",original:Ht,modified:tr}]}}),So(gd=>gd+1)},J=20,U=null,q=null,we=0,We=(xe,ze,ut)=>{let at=j(ze,ut);rn(at?{modifier:xe,target:at}:null)},tt=xe=>{if(!(e.activeTool!=="hand"||!e.isAnnotating)){if(xe.key==="Shift"&&!xe.altKey){let ze=en.current;We("shift",ze.x,ze.y)}else if(xe.key==="Alt"&&!xe.shiftKey){let ze=en.current;We("alt",ze.x,ze.y)}}},ot=xe=>{if(e.activeTool!=="hand"||!e.isAnnotating)return;let ze=xe.shiftKey&&!xe.altKey,ut=xe.altKey&&!xe.shiftKey;if(!ze&&!ut||xe.buttons!==0){U=null,q=null,we=0,$=null,oe=null,rn(null);return}if($===null&&($=xe.clientX,oe=xe.clientY,We(ze?"shift":"alt",xe.clientX,xe.clientY)),C)return;U===null&&(U=xe.clientX,q=xe.clientY,we=0);let at=xe.clientX-U,wt=xe.clientY-q,qe=Math.abs(at)>=Math.abs(wt)?at:wt;if(Math.abs(qe)>3){let tr=qe>0?1:-1;if(we!==0&&tr!==we){U=xe.clientX,q=xe.clientY,we=0;return}we=tr}if(Math.abs(at)<J&&Math.abs(wt)<J)return;let Ht=j($,oe);if(!Ht)return;let co=Math.abs(at)>=Math.abs(wt)?"horizontal":"vertical",Do=(co==="horizontal"?at:wt)>0?1:-1;U=null,q=null,we=0,ze?X(Ht,co,Do):z(Ht,co,Do),T()},Ft=xe=>{(xe.key==="Shift"||xe.key==="Alt")&&($=null,oe=null,U=null,q=null,we=0,rn(null))},st=()=>{rn(null),U=null,q=null,we=0};return window.addEventListener("keydown",tt),window.addEventListener("mousemove",ot),window.addEventListener("mousedown",st),window.addEventListener("keyup",Ft),()=>{window.removeEventListener("keydown",tt),window.removeEventListener("mousemove",ot),window.removeEventListener("mousedown",st),window.removeEventListener("keyup",Ft),M&&clearTimeout(M)}},[e.activeTool,e.isAnnotating,t]),kn(()=>{let m=b=>{var $,oe,j,te;if(b.key==="Escape"){if(Lo.current)return;if(e.activeTool==="model"&&rt.size>0){b.preventDefault(),ht(new Map);return}if(Zn.current.length>0){b.preventDefault(),wo();return}}if(b.key==="Enter"&&e.activeTool==="model"&&rt.size>0&&p){b.preventDefault();let E=[...rt.keys()].filter(T=>!(x!=null&&x.has(T)));E.length>0&&p(E),ht(new Map);return}if((b.metaKey||b.ctrlKey)&&b.key==="v"&&Ze.current.length>0&&!Lo.current){b.preventDefault(),Oe.current++;let E=Oe.current*20,X=(($=Ze.current[0])==null?void 0:$.groupId)?Math.random().toString(36).substring(2,9):void 0,z=Ze.current.map(U=>y(f({},U),{id:Math.random().toString(36).substring(2,9),groupId:U.groupId?X:void 0,timestamp:Date.now(),points:U.points.map(q=>({x:q.x+E,y:q.y+E}))}));t({type:"PASTE_ANNOTATIONS",payload:{annotations:z}});let J=z.find(U=>U.type!=="text")||z[0];J&&$n(J.id);return}let G=Zn.current;if(G.length===0||Lo.current)return;let M=(j=(oe=b.composedPath)==null?void 0:oe.call(b)[0])!=null?j:b.target,C=M==null?void 0:M.tagName;if(!(C==="INPUT"||C==="TEXTAREA"||M!=null&&M.isContentEditable)&&(b.key==="Delete"||b.key==="Backspace")){if(b.preventDefault(),u){let E=Mn.current.annotations;for(let T of G){let X=E.find(J=>J.id===T);if(!X)continue;let z=X.threadId||X.groupId&&((te=E.find(J=>J.groupId===X.groupId&&J.threadId))==null?void 0:te.threadId);z&&u(z)}}for(let E of G)t({type:"DELETE_ANNOTATION",payload:{id:E}});wo()}};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,wo,$n,e.activeTool,rt,x,p,u]);let D=Ar(),V=Vi(()=>e.annotations.filter(m=>!m.pathname||m.pathname===D),[e.annotations,D]),ee=Vi(()=>Ni(e.annotations),[e.annotations]),ge=Vi(()=>{let m=new Map,b=new Set,G=1,M=[...e.annotations].sort((C,$)=>C.timestamp-$.timestamp);for(let C of M)if(!ee.has(C))if(C.groupId){if(!b.has(C.groupId)){b.add(C.groupId);let $=e.annotations.filter(oe=>oe.groupId===C.groupId);for(let oe of $)m.set(oe.id,G);G++}}else m.set(C.id,G),G++;return m},[e.annotations,ee]),ae=Vi(()=>{if(sn.length===0)return null;let m=new Map;for(let b of sn){let G=e.annotations.find(C=>C.id===b);if(!G)continue;let M=G.groupId?e.annotations.filter(C=>C.groupId===G.groupId):[G];for(let C of M)if(C.linkedSelector&&!(l!=null&&l.has(C.linkedSelector))){let $=C.color||e.activeColor;m.set(C.linkedSelector,$)}}return m.size>0?m:null},[sn,e.annotations,e.activeColor,l]);kn(()=>{let m=V.filter(b=>!(ee.has(b)||k&&!k.isNew&&b.id===k.id));re(m,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,sn,hc,an.x,an.y,ge,N)},[V,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,re,k,sn,an,ge,ee,N]),kn(()=>{if(F){let m=Math.random().toString(36).substring(2,9);be({id:m,point:F.point,text:"",fontSize:12,isNew:!0,groupId:F.groupId}),me(null)}},[F]),kn(()=>{R&&(be({id:Math.random().toString(36).substring(2,9),point:R.point,text:"",fontSize:12,isNew:!0,linkedSelector:R.linkedSelector,linkedAnchor:R.linkedAnchor,elements:R.elements}),ie(null))},[R]);let Ie=Qt(null),ke=(et=k==null?void 0:k.id)!=null?et:null;kn(()=>{ke&&Se.current?requestAnimationFrame(()=>{var G;let m=Se.current;if(!m||(m.focus(),Pe.current===ke))return;Pe.current=ke;let b=Lo.current;if(b){if(Ie.current!==null){let M=Math.min(Ie.current,m.value.length);m.setSelectionRange(M,M);return}if(!b.isNew&&b.clickPoint){let M=Y.current;if(!M)return;let C=M.getContext("2d");if(!C)return;C.font=`${b.fontSize}px ${Zt}`;let $=b.fontSize*1.4,oe=b.text.split(`
4
4
  `),j=b.clickPoint.y-b.point.y,te=Math.max(0,Math.min(oe.length-1,Math.floor(j/$))),E=b.clickPoint.x-b.point.x,T=oe[te]||"",X=0;for(let J=0;J<=T.length;J++){let U=C.measureText(T.substring(0,J)).width;if(U>E){let q=J>0?C.measureText(T.substring(0,J-1)).width:0;X=E-q<U-E?J-1:J;break}X=J}let z=X;for(let J=0;J<te;J++)z+=(((G=oe[J])==null?void 0:G.length)||0)+1;m.setSelectionRange(z,z)}}}):(Pe.current=null,Ie.current=null)},[ke,Y]);let He=un(m=>{let b=Y.current;if(!b)return{x:0,y:0};let G=b.getBoundingClientRect(),M,C;if("touches"in m&&m.touches[0])M=m.touches[0].clientX,C=m.touches[0].clientY;else if("clientX"in m)M=m.clientX,C=m.clientY;else return{x:0,y:0};return{x:M-G.left+window.scrollX,y:C-G.top+window.scrollY}},[Y]),Ne=un((m,b,G,M)=>{let C=G.x-b.x,$=G.y-b.y,oe=C*C+$*$;if(oe===0)return Math.sqrt((m.x-b.x)**2+(m.y-b.y)**2)<=M;let j=Math.max(0,Math.min(1,((m.x-b.x)*C+(m.y-b.y)*$)/oe)),te=b.x+j*C,E=b.y+j*$;return Math.sqrt((m.x-te)**2+(m.y-E)**2)<=M},[]),Mt=un(m=>{for(let G=V.length-1;G>=0;G--){let M=V[G];if(!M||ee.has(M))continue;let C=(M.strokeWidth||3)+4;switch(M.type){case"text":{if(!M.points[0]||!M.text)continue;let $=M.points[0],oe=M.fontSize||12,j=Y.current;if(j){let te=j.getContext("2d");if(te){te.font=`${oe}px ${Zt}`;let E=M.text.replace(/\n/g," "),T=$.x-an.x,X=Or(T),z=Br(te,E,X),J=te.measureText(z).width,U=oe*1.4;if(m.x>=$.x-4-4&&m.x<=$.x+J+4+4&&m.y>=$.y-4-4&&m.y<=$.y+U+4+4)return M}}break}case"rectangle":{if(M.points.length<2)continue;let $=M.points[0],oe=M.points[M.points.length-1],j=Math.min($.x,oe.x),te=Math.max($.x,oe.x),E=Math.min($.y,oe.y),T=Math.max($.y,oe.y),X=Ne(m,{x:j,y:E},{x:te,y:E},C),z=Ne(m,{x:j,y:T},{x:te,y:T},C),J=Ne(m,{x:j,y:E},{x:j,y:T},C),U=Ne(m,{x:te,y:E},{x:te,y:T},C);if(X||z||J||U)return M;break}case"circle":{if(M.points.length<2)continue;let $=M.points[0],oe=M.points[M.points.length-1],j=($.x+oe.x)/2,te=($.y+oe.y)/2,E=Math.abs(oe.x-$.x)/2,T=Math.abs(oe.y-$.y)/2,X=m.x-j,z=m.y-te,J=Math.sqrt((X/E)**2+(z/T)**2);if(Math.abs(J-1)*Math.max(E,T)<=C)return M;break}case"line":{if(M.points.length<2)continue;let $=M.points[0],oe=M.points[M.points.length-1];if(Ne(m,$,oe,C))return M;break}case"freehand":{if(M.points.length<2)continue;for(let $=0;$<M.points.length-1;$++){let oe=M.points[$],j=M.points[$+1];if(Ne(m,oe,j,C))return M}break}}}return null},[V,Y,Ne,ee,an.x]),qt=un(m=>{let b=Mt(m);return(b==null?void 0:b.type)==="text"?b:null},[Mt]),xn=un(m=>{if(sn.length===0)return null;let b=hc/2+4;for(let G of sn){let M=e.annotations.find(C=>C.id===G);if(!(!M||M.points.length<2)){if(M.type==="line"){let C=M.points[0],$=M.points[M.points.length-1];if(Math.sqrt((m.x-C.x)**2+(m.y-C.y)**2)<=b)return{handle:"start",annotationId:G};if(Math.sqrt((m.x-$.x)**2+(m.y-$.y)**2)<=b)return{handle:"end",annotationId:G};continue}if(M.type==="circle"){let C=M.points[0],$=M.points[M.points.length-1],oe=Math.min(C.x,$.x),j=Math.max(C.x,$.x),te=Math.min(C.y,$.y),E=Math.max(C.y,$.y),T=(oe+j)/2,X=(te+E)/2,z=[{handle:"top",x:T,y:te},{handle:"bottom",x:T,y:E},{handle:"left",x:oe,y:X},{handle:"right",x:j,y:X}];for(let{handle:J,x:U,y:q}of z)if(Math.sqrt((m.x-U)**2+(m.y-q)**2)<=b)return{handle:J,annotationId:G};continue}if(M.type==="rectangle"||M.type==="freehand"){let C=M.points[0],$=M.points[M.points.length-1],oe,j,te,E;M.type==="freehand"?(oe=Math.min(...M.points.map(X=>X.x)),j=Math.max(...M.points.map(X=>X.x)),te=Math.min(...M.points.map(X=>X.y)),E=Math.max(...M.points.map(X=>X.y))):(oe=Math.min(C.x,$.x),j=Math.max(C.x,$.x),te=Math.min(C.y,$.y),E=Math.max(C.y,$.y));let T=[{corner:"topLeft",x:oe,y:te},{corner:"topRight",x:j,y:te},{corner:"bottomLeft",x:oe,y:E},{corner:"bottomRight",x:j,y:E}];for(let{corner:X,x:z,y:J}of T)if(Math.sqrt((m.x-z)**2+(m.y-J)**2)<=b)return{handle:X,annotationId:G}}}}return null},[sn,e.annotations]);kn(()=>{let m=b=>{if(_e.current={x:b.clientX+window.scrollX,y:b.clientY+window.scrollY},!k){let G=qt(_e.current);de((G==null?void 0:G.id)||null)}};return window.addEventListener("mousemove",m),()=>window.removeEventListener("mousemove",m)},[k,qt]);let It=un(()=>{var b;if(!k)return;let m=((b=k.images)==null?void 0:b.length)||0;if(k.text.trim()||m>0)if(k.isNew){let G=Ci();t({type:"ADD_TEXT",payload:f({point:k.point,text:k.text||(m>0?`[${m} image${m>1?"s":""}]`:""),fontSize:k.fontSize,id:G,groupId:k.groupId,linkedSelector:k.linkedSelector,linkedAnchor:k.linkedAnchor,elements:k.elements},m>0?{imageCount:m}:{})}),m>0&&k.images&&a&&a(G,k.images)}else t({type:"UPDATE_TEXT",payload:f({id:k.id,text:k.text||(m>0?`[${m} image${m>1?"s":""}]`:"")},m>0?{imageCount:m}:{})}),m>0&&k.images&&a&&a(k.id,k.images);else k.isNew||t({type:"DELETE_ANNOTATION",payload:{id:k.id}});be(null)},[k,t,a]),Ve=un(m=>{for(let b=0;b<ta.length-1;b++){let G=ta[b],M=ta[b+1];if(m<=(G+M)/2)return G;if(m<M)return M}return Math.round(m/8)*8},[]),Yn=un((m,b,G,M)=>{let C=G.top+Math.max(M.top,4),$=G.bottom-Math.max(M.bottom,4),oe=G.left+Math.max(M.left,4),j=G.right-Math.max(M.right,4);if(m<G.left||m>G.right||b<G.top||b>G.bottom)return null;let te=b<C,E=b>$,T=m<oe,X=m>j;return te&&T?M.top>=M.left?"top":"left":te&&X?M.top>=M.right?"top":"right":E&&T?M.bottom>=M.left?"bottom":"left":E&&X?M.bottom>=M.right?"bottom":"right":te?"top":E?"bottom":T?"left":X?"right":null},[]),Oo=un(m=>{var $,oe;if(!e.isAnnotating)return;if(e.inspectedElement&&e.activeTool==="hand"&&!("button"in m&&m.button===2)){m.preventDefault(),m.stopPropagation(),t({type:"SELECT_ELEMENT",payload:null});return}let b=He(m),G="shiftKey"in m&&m.shiftKey;if(e.activeTool==="inspector"){if("button"in m&&m.button===2)return;if(ne&&!qn(ne)){let j=e.annotations.find(tt=>{if(!tt.linkedSelector||!tt.threadId)return!1;try{return ne.matches(tt.linkedSelector)}catch(ot){return!1}});if(j!=null&&j.threadId&&c){c(j.threadId),requestAnimationFrame(()=>{var Ft;let tt=document.querySelector("[data-popmelt-shadow-host]"),ot=(Ft=tt==null?void 0:tt.shadowRoot)==null?void 0:Ft.querySelector("[data-popmelt-reply]");ot==null||ot.focus()});return}let te=Nn(ne),E=Jn(ne),T=ne.getBoundingClientRect(),X=ne.getAttribute("data-pm");X||(X=Math.random().toString(36).substring(2,8),ne.setAttribute("data-pm",X));let z=`[data-pm="${X}"]`,J=e.styleModifications.some(tt=>{try{return ne.matches(tt.selector)}catch(ot){return!1}}),U=e.annotations.filter(tt=>{if(!tt.linkedSelector)return!1;try{return ne.matches(tt.linkedSelector)}catch(ot){return!1}}).length,q=(J?1:0)+U,we=T.top>=eo*(1+q)?"top-left":"bottom-left",We=yc(T,we,q,L==null?void 0:L.current);ie({point:We,linkedSelector:z,linkedAnchor:we,elements:[y(f({},te),{selector:E})]})}return}if(e.activeTool==="model"){if("button"in m&&m.button===2)return;if(he){let j=he.name;if(x!=null&&x.has(j)){g==null||g(j);return}"shiftKey"in m&&m.shiftKey?ht(E=>{let T=new Map(E);return T.has(j)?T.delete(j):T.set(j,he),T}):rt.size===1&&rt.has(j)?(p&&p([j]),ht(new Map)):ht(new Map([[j,he]]))}return}if(e.activeTool==="hand"&&Ot&&vt){let j=Ot,te=j.getAttribute("data-pm");te||(te=Math.random().toString(36).substring(2,8),j.setAttribute("data-pm",te));let E=Jn(j),T=`[data-pm="${te}"]`,X=Nn(j),z=ur(j),J=b.x-window.scrollX,U=b.y-window.scrollY,q=Ke,we=window.getComputedStyle(j).justifyContent,We=0;if(q){let ot=Ho(j).find(Ft=>Ft.axis===vt);We=ot?vt==="column"?ot.w:ot.h:0}Xe(j,"transition","none"),jt.current={isDragging:!0,hasMoved:!1,axis:vt,startX:J,startY:U,originalRow:q?We:z.row,originalColumn:q?We:z.column,element:j,elementInfo:y(f({},X),{selector:T}),selector:T,durableSelector:E,isAuto:q,originalJustifyContent:we,visualGap:We},xo({axis:vt,row:q?We:z.row,column:q?We:z.column});return}if(e.activeTool==="hand"&&Ut&&vn){let j=Ut,te=j.getAttribute("data-pm");te||(te=Math.random().toString(36).substring(2,8),j.setAttribute("data-pm",te));let E=`[data-pm="${te}"]`,T=Nn(j),{fontSize:X,lineHeight:z}=ti(j),J=X>0?z/X:1.2,U=b.x-window.scrollX,q=b.y-window.scrollY;Xe(j,"transition","none");let we=Jn(j);bn.current={isDragging:!0,property:vn,startX:U,startY:q,originalFontSize:X,originalLineHeight:z,originalRatio:J,element:j,elementInfo:y(f({},T),{selector:E}),selector:E,durableSelector:we},Ro({property:vn,fontSize:X,lineHeight:z});return}if(e.activeTool==="hand"&&W&&Le){let j=W,te=j.getAttribute("data-pm");te||(te=Math.random().toString(36).substring(2,8),j.setAttribute("data-pm",te));let E=`[data-pm="${te}"]`,T=Jn(j),X=Nn(j),z=pr(j),J=j.getBoundingClientRect(),U=Math.floor(J.height/2),q=b.y-window.scrollY;Xe(j,"transition","none"),Tn.current={isDragging:!0,corner:Le,startY:q,original:z,maxRadius:U,element:j,elementInfo:y(f({},X),{selector:E}),selector:E,durableSelector:T},yn({corner:Le,radius:f({},z)});return}if(e.activeTool==="hand"&&dt&&se){let j=dt,te=j.getAttribute("data-pm");te||(te=Math.random().toString(36).substring(2,8),j.setAttribute("data-pm",te));let E=`[data-pm="${te}"]`,T=Jn(j),X=Nn(j),z=Nr(j),J=b.x-window.scrollX,U=b.y-window.scrollY;Xe(j,"transition","none"),_t.current={isDragging:!0,side:se,startX:J,startY:U,original:z,element:j,elementInfo:y(f({},X),{selector:E}),selector:E,durableSelector:T},Wt({side:se,padding:f({},z)});return}let M=xn(b);if(M){let j=e.annotations.find(te=>te.id===M.annotationId);if(j&&j.type!=="text"&&(($=j.status)!=null?$:"pending")==="pending"){Ao({annotationId:M.annotationId,handle:M.handle,startPoint:b,originalPoints:[...j.points],hasMoved:!1});return}}let C=Mt(b);if(C&&C.points[0]){if(k&&It(),C.type!=="text"?($n(C.id,G),C.color&&t({type:"SET_COLOR",payload:C.color})):G||wo(),c){let j=C.threadId||(C.groupId?(oe=e.annotations.find(te=>te.groupId===C.groupId&&te.threadId))==null?void 0:oe.threadId:void 0);j&&c(j)}Xt({annotation:C,startPoint:b,hasMoved:!1});return}if(G||wo(),e.activeTool==="text"){k&&It();let j=Math.random().toString(36).substring(2,9);be({id:j,point:b,text:"",fontSize:12,isNew:!0});return}A(!0),t({type:"START_PATH",payload:b})},[e.isAnnotating,e.activeTool,e.inspectedElement,e.annotations,k,sn,ne,dt,se,W,Le,Ot,vt,Ke,Ut,vn,he,rt,x,p,g,c,He,Mt,xn,t,$n,wo,It]),Bo=un(m=>{var G,M;let b=He(m);if(e.activeTool==="inspector"&&e.isAnnotating){let C=b.x-window.scrollX,$=b.y-window.scrollY,oe=dr(C,$),j=oe&&qn(oe)?null:oe;j!==ne&&(Te(j),pt(j?Nn(j):null));return}if(e.activeTool==="model"&&e.isAnnotating){let C=b.x-window.scrollX,$=b.y-window.scrollY,oe=dr(C,$);if(oe!==Q.current&&(Q.current=oe,Jt.current=0),oe){let j=Ii(oe,Jt.current);Fe(j)}else Fe(null);return}if(e.activeTool==="hand"&&e.isAnnotating){let C=b.x-window.scrollX,$=b.y-window.scrollY;en.current={x:C,y:$},zn({x:C,y:$});let oe=io.current.cmd,j=io.current.shift;if(jt.current.isDragging){let E=jt.current,T=E.element;if(!T)return;if(!E.hasMoved){let U=Math.abs(C-E.startX),q=Math.abs($-E.startY);if(U<=2&&q<=2)return;E.hasMoved=!0,E.isAuto&&(Xe(T,"justify-content","normal"),Xe(T,"row-gap",`${E.visualGap}px`),Xe(T,"column-gap",`${E.visualGap}px`),Tt(!1))}let X=E.axis,z=E.originalRow,J=E.originalColumn;if(X==="column"){let U=C-E.startX;J=E.originalColumn+U,oe||(z=E.originalRow+U)}else{let U=$-E.startY;z=E.originalRow+U,oe||(J=E.originalColumn+U)}z=Math.max(0,z),J=Math.max(0,J),j&&(z=Ve(z),J=Ve(J)),z=Math.round(z),J=Math.round(J),Xe(T,"row-gap",`${z}px`),Xe(T,"column-gap",`${J}px`),xo({axis:X,row:z,column:J});return}if(Tn.current.isDragging){let E=Tn.current,T=E.element;if(!T)return;let X=$-E.startY,z=E.corner,J=E.original,U=f({},J);if(oe){let q=J[z]+X;q=Math.max(0,Math.min(E.maxRadius,q)),j&&(q=Ve(q)),q=Math.round(q),U[z]=q}else{let q=J[z]+X;q=Math.max(0,Math.min(E.maxRadius,q)),j&&(q=Ve(q)),q=Math.round(q),U={"top-left":q,"top-right":q,"bottom-right":q,"bottom-left":q}}Xe(T,"border-top-left-radius",`${U["top-left"]}px`),Xe(T,"border-top-right-radius",`${U["top-right"]}px`),Xe(T,"border-bottom-right-radius",`${U["bottom-right"]}px`),Xe(T,"border-bottom-left-radius",`${U["bottom-left"]}px`),yn({corner:z,radius:U});return}if(bn.current.isDragging){let E=bn.current,T=E.element;if(!T)return;let X=E.property,z=E.originalFontSize,J=E.originalLineHeight,U=[8,10,11,12,13,14,16,18,20,22,24,28,32,36,40,48,56,64,72,80,96];if(X==="font-size"){let we=C-E.startX;z=E.originalFontSize+we,z=Math.max(1,z)}else{let we=$-E.startY;J=E.originalLineHeight+we,J=Math.max(z,J)}if(j)if(X==="font-size"){let we=U[0],We=Math.abs(z-we);for(let tt of U){let ot=Math.abs(z-tt);ot<We&&(we=tt,We=ot)}z=we}else{let we=z>0?J/z:1.2,We=Math.round(we*2)/2;J=z*Math.max(1,We)}z=Math.round(z),J=Math.round(J*10)/10,Xe(T,"font-size",`${z}px`);let q=z>0?Math.round(J/z*1e3)/1e3:1.2;Xe(T,"line-height",`${q}`),Ro({property:X,fontSize:z,lineHeight:J});return}if(_t.current.isDragging){let E=_t.current,T=E.element;if(!T)return;let X=E.side,z=E.original,J=z.top,U=z.right,q=z.bottom,we=z.left;if(X==="top"){let We=E.startY-$;J=z.top+We,oe||(q=z.bottom+We)}else if(X==="bottom"){let We=$-E.startY;q=z.bottom+We,oe||(J=z.top+We)}else if(X==="left"){let We=E.startX-C;we=z.left+We,oe||(U=z.right+We)}else if(X==="right"){let We=C-E.startX;U=z.right+We,oe||(we=z.left+We)}J=Math.max(0,J),U=Math.max(0,U),q=Math.max(0,q),we=Math.max(0,we),j&&(J=Ve(J),U=Ve(U),q=Ve(q),we=Ve(we)),J=Math.round(J),U=Math.round(U),q=Math.round(q),we=Math.round(we),Xe(T,"padding",`${J}px ${U}px ${q}px ${we}px`),Wt({side:X,padding:{top:J,right:U,bottom:q,left:we}});return}let te=dr(C,$);for(;te&&te.tagName==="A";)te=te.parentElement;{let T=[];te&&T.push(te),W&&W!==te&&T.push(W);let X=null,z=16,J=null;for(let U of T){let q=U.getBoundingClientRect(),we=pr(U),We=[["top-left",q.left,q.top+we["top-left"]],["top-right",q.right,q.top+we["top-right"]],["bottom-right",q.right,q.bottom-we["bottom-right"]],["bottom-left",q.left,q.bottom-we["bottom-left"]]];for(let[tt,ot,Ft]of We){let st=Math.hypot(C-ot,$-Ft);st<z&&(z=st,X=tt,J=U)}}if(X&&J){fe(J),Gt(X),dt&&pe(null),se&&Ce(null),Ot&&hn(null),vt&&Vt(null),Tt(!1),Ut&&Pn(null),vn&&Io(null);return}}W&&fe(null),Le&&Gt(null);{let E=[];te&&Pi(te)&&E.push(te);let T=(G=te==null?void 0:te.parentElement)!=null?G:null;for(;T&&T!==document.body&&E.length<3;)Pi(T)&&E.push(T),T=T.parentElement;for(let X of E){let J=Ho(X).find(U=>C>=U.x&&C<=U.x+U.w&&$>=U.y&&$<=U.y+U.h);if(J){hn(X),Vt(J.axis),Tt(Ms(X,J.axis)),dt&&pe(null),se&&Ce(null),Ut&&Pn(null),vn&&Io(null);return}}}Ot&&hn(null),vt&&Vt(null),Tt(!1);{let T=[];te&&T.push(te),Ut&&Ut!==te&&T.push(Ut);let X=null,z=1/0,J=null;for(let U of T){if(!Is(U))continue;let q=zr(U);if(!q)continue;let we=C>=q.left&&C<=q.right&&$>=q.top&&$<=q.bottom,We=[["font-size",q.right,q.top+q.height/2],["line-height",q.left+q.width/2,q.bottom]];for(let[tt,ot,Ft]of We){let st=Math.hypot(C-ot,$-Ft);(we||st<12)&&st<z&&(z=st,X=tt,J=U)}}X&&J?(Pn(J),Io(X)):(Ut&&Pn(null),vn&&Io(null))}if(te!==dt&&pe(te),te){let E=Nr(te),T=te.getBoundingClientRect(),X=Yn(C,$,T,E);Ce(X)}else Ce(null);return}if(In){let{handle:C,originalPoints:$,hasMoved:oe}=In,j=e.annotations.find(z=>z.id===In.annotationId);if(!j)return;let te="metaKey"in m,E=te&&(m.metaKey||m.ctrlKey),T=te&&m.shiftKey,X;if(j.type==="line"){let z=$[0],J=$[$.length-1];C==="start"?X=[b,J]:X=[z,b]}else if(j.type==="freehand"){let z=Math.min(...$.map(qe=>qe.x)),J=Math.max(...$.map(qe=>qe.x)),U=Math.min(...$.map(qe=>qe.y)),q=Math.max(...$.map(qe=>qe.y)),we=(z+J)/2,We=(U+q)/2,tt=J-z||1,ot=q-U||1,Ft=tt/ot,st=z,xe=J,ze=U,ut=q;switch(C){case"topLeft":st=b.x,ze=b.y;break;case"topRight":xe=b.x,ze=b.y;break;case"bottomLeft":st=b.x,ut=b.y;break;case"bottomRight":xe=b.x,ut=b.y;break}if(E)switch(C){case"topLeft":xe=J+(z-st),ut=q+(U-ze);break;case"topRight":st=z-(xe-J),ut=q+(U-ze);break;case"bottomLeft":xe=J+(z-st),ze=U-(ut-q);break;case"bottomRight":st=z-(xe-J),ze=U-(ut-q);break}if(T){let qe=xe-st,Ht=ut-ze;if(Math.abs(qe/Ht)>Ft){let fn=Math.abs(Ht)*Ft*Math.sign(qe);C==="topLeft"||C==="bottomLeft"?st=xe-fn:xe=st+fn}else{let fn=Math.abs(qe)/Ft*Math.sign(Ht);C==="topLeft"||C==="topRight"?ze=ut-fn:ut=ze+fn}}let at=xe-st||1,wt=ut-ze||1;X=$.map(qe=>({x:st+(qe.x-z)/tt*at,y:ze+(qe.y-U)/ot*wt}))}else if(j.type==="circle"){let z=$[0],J=$[$.length-1],U=Math.min(z.x,J.x),q=Math.max(z.x,J.x),we=Math.min(z.y,J.y),We=Math.max(z.y,J.y),tt=(U+q)/2,ot=(we+We)/2,Ft=q-U,st=We-we,xe=U,ze=q,ut=we,at=We;switch(C){case"top":if(ut=b.y,E&&(at=ot+(ot-b.y)),T){let qe=(at-ut)*(Ft/st)/2;xe=tt-qe,ze=tt+qe}break;case"bottom":if(at=b.y,E&&(ut=ot-(b.y-ot)),T){let qe=(at-ut)*(Ft/st)/2;xe=tt-qe,ze=tt+qe}break;case"left":if(xe=b.x,E&&(ze=tt+(tt-b.x)),T){let qe=(ze-xe)*(st/Ft)/2;ut=ot-qe,at=ot+qe}break;case"right":if(ze=b.x,E&&(xe=tt-(b.x-tt)),T){let qe=(ze-xe)*(st/Ft)/2;ut=ot-qe,at=ot+qe}break}X=[{x:xe,y:ut},{x:ze,y:at}]}else{let z=$[0],J=$[$.length-1],U=Math.min(z.x,J.x),q=Math.max(z.x,J.x),we=Math.min(z.y,J.y),We=Math.max(z.y,J.y),tt=(U+q)/2,ot=(we+We)/2,Ft=q-U||1,st=We-we||1,xe=Ft/st,ze=U,ut=q,at=we,wt=We;switch(C){case"topLeft":ze=b.x,at=b.y;break;case"topRight":ut=b.x,at=b.y;break;case"bottomLeft":ze=b.x,wt=b.y;break;case"bottomRight":ut=b.x,wt=b.y;break}if(E)switch(C){case"topLeft":ut=q+(U-ze),wt=We+(we-at);break;case"topRight":ze=U-(ut-q),wt=We+(we-at);break;case"bottomLeft":ut=q+(U-ze),at=we-(wt-We);break;case"bottomRight":ze=U-(ut-q),at=we-(wt-We);break}if(T){let qe=ut-ze,Ht=wt-at;if(Math.abs(qe/Ht)>xe){let fn=Math.abs(Ht)*xe*Math.sign(qe);C==="topLeft"||C==="bottomLeft"?ze=ut-fn:ut=ze+fn}else{let fn=Math.abs(qe)/xe*Math.sign(Ht);C==="topLeft"||C==="topRight"?at=wt-fn:wt=at+fn}}X=[{x:ze,y:at},{x:ut,y:wt}]}t({type:"RESIZE_ANNOTATION",payload:{id:In.annotationId,points:X,saveUndo:!oe}}),oe||Ao(y(f({},In),{hasMoved:!0}));return}if(Bt&&((M=Bt.annotation.status)!=null?M:"pending")==="pending"){let C=b.x-Bt.startPoint.x,$=b.y-Bt.startPoint.y;if((Math.abs(C)>2||Math.abs($)>2)&&!Bt.hasMoved)Xt(y(f({},Bt),{hasMoved:!0,startPoint:b})),t({type:"MOVE_ANNOTATION",payload:{id:Bt.annotation.id,delta:{x:C,y:$},saveUndo:!0}});else if(Bt.hasMoved){let j=b.x-Bt.startPoint.x,te=b.y-Bt.startPoint.y;Xt(y(f({},Bt),{startPoint:b})),t({type:"MOVE_ANNOTATION",payload:{id:Bt.annotation.id,delta:{x:j,y:te}}})}return}!h||!e.isAnnotating||t({type:"CONTINUE_PATH",payload:b})},[h,e.isAnnotating,e.activeTool,Bt,In,ne,dt,se,W,Le,Ot,vt,Ut,vn,He,t,Ve,Yn]),En=un(m=>{var M,C,$,oe,j,te;if(bn.current.isDragging){let E=bn.current,T=E.element;if(T&&E.selector&&E.elementInfo&&yt){T instanceof HTMLElement&&(T.style.removeProperty("font-size"),T.style.removeProperty("line-height"),T.style.removeProperty("transition"));let X=[];if(E.originalFontSize!==yt.fontSize&&(Xe(T,"font-size",`${yt.fontSize}px`),X.push({property:"font-size",original:`${E.originalFontSize}px`,modified:`${yt.fontSize}px`})),E.originalLineHeight!==yt.lineHeight){let z=E.originalFontSize>0?Math.round(E.originalLineHeight/E.originalFontSize*1e3)/1e3:1.2,J=yt.fontSize>0?Math.round(yt.lineHeight/yt.fontSize*1e3)/1e3:1.2;Xe(T,"line-height",`${J}`),X.push({property:"line-height",original:`${z}`,modified:`${J}`})}X.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:E.selector,durableSelector:(M=E.durableSelector)!=null?M:void 0,element:E.elementInfo,changes:X}})}bn.current={isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null},Ro(null);return}if(jt.current.isDragging){let E=jt.current,T=E.element,X="button"in m&&m.button===2;if(!E.hasMoved&&!X&&T&&E.selector&&E.elementInfo){T instanceof HTMLElement&&T.style.removeProperty("transition");let z=["space-between","space-around","stretch","normal"],J=E.originalJustifyContent||"normal",U=z.indexOf(J),q=z[(U+1)%z.length],we=[];q==="normal"?(Xe(T,"justify-content","normal"),we.push({property:"justify-content",original:E.originalJustifyContent,modified:"normal"})):q==="stretch"?(Xe(T,"justify-content",q),Xe(T,"row-gap","8px"),Xe(T,"column-gap","8px"),we.push({property:"justify-content",original:E.originalJustifyContent||"normal",modified:q}),E.originalRow!==8&&we.push({property:"row-gap",original:`${E.originalRow}px`,modified:"8px"}),E.originalColumn!==8&&we.push({property:"column-gap",original:`${E.originalColumn}px`,modified:"8px"})):(T instanceof HTMLElement&&(T.style.removeProperty("row-gap"),T.style.removeProperty("column-gap")),Xe(T,"justify-content",q),we.push({property:"justify-content",original:E.originalJustifyContent||"normal",modified:q}),E.originalRow>0&&we.push({property:"row-gap",original:`${E.originalRow}px`,modified:"0px"}),E.originalColumn>0&&we.push({property:"column-gap",original:`${E.originalColumn}px`,modified:"0px"})),we.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:E.selector,durableSelector:(C=E.durableSelector)!=null?C:void 0,element:E.elementInfo,changes:we}})}else if(E.hasMoved&&T&&E.selector&&E.elementInfo&&Qe){T instanceof HTMLElement&&(T.style.removeProperty("row-gap"),T.style.removeProperty("column-gap"),T.style.removeProperty("transition"));let z=[];E.isAuto?(T instanceof HTMLElement&&T.style.removeProperty("justify-content"),Xe(T,"justify-content","normal"),Xe(T,"row-gap",`${Qe.row}px`),Xe(T,"column-gap",`${Qe.column}px`),z.push({property:"justify-content",original:E.originalJustifyContent,modified:"normal"}),z.push({property:"row-gap",original:"0px",modified:`${Qe.row}px`}),z.push({property:"column-gap",original:"0px",modified:`${Qe.column}px`})):(E.originalRow!==Qe.row&&(Xe(T,"row-gap",`${Qe.row}px`),z.push({property:"row-gap",original:`${E.originalRow}px`,modified:`${Qe.row}px`})),E.originalColumn!==Qe.column&&(Xe(T,"column-gap",`${Qe.column}px`),z.push({property:"column-gap",original:`${E.originalColumn}px`,modified:`${Qe.column}px`}))),z.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:E.selector,durableSelector:($=E.durableSelector)!=null?$:void 0,element:E.elementInfo,changes:z}})}jt.current={isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0},xo(null);return}if(Tn.current.isDragging){let E=Tn.current,T=E.element;if(T&&E.selector&&E.elementInfo&&St){T instanceof HTMLElement&&(T.style.removeProperty("border-top-left-radius"),T.style.removeProperty("border-top-right-radius"),T.style.removeProperty("border-bottom-right-radius"),T.style.removeProperty("border-bottom-left-radius"),T.style.removeProperty("transition"));let X=["top-left","top-right","bottom-right","bottom-left"],z={"top-left":"border-top-left-radius","top-right":"border-top-right-radius","bottom-right":"border-bottom-right-radius","bottom-left":"border-bottom-left-radius"},J=[];for(let U of X)E.original[U]!==St.radius[U]&&(Xe(T,z[U],`${St.radius[U]}px`),J.push({property:z[U],original:`${E.original[U]}px`,modified:`${St.radius[U]}px`}));J.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:E.selector,durableSelector:(oe=E.durableSelector)!=null?oe:void 0,element:E.elementInfo,changes:J}})}Tn.current={isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null},yn(null);return}if(_t.current.isDragging){let E=_t.current,T=E.element,X=E.selector,z=E.elementInfo;if(T&&X&&z&&Me){let J=E.original,U=Me.padding;T instanceof HTMLElement&&(T.style.removeProperty("padding"),T.style.removeProperty("transition"));let q=[],we=[{prop:"padding-top",origVal:J.top,newVal:U.top},{prop:"padding-right",origVal:J.right,newVal:U.right},{prop:"padding-bottom",origVal:J.bottom,newVal:U.bottom},{prop:"padding-left",origVal:J.left,newVal:U.left}];for(let{prop:We,origVal:tt,newVal:ot}of we)tt!==ot&&(Xe(T,We,`${ot}px`),q.push({property:We,original:`${tt}px`,modified:`${ot}px`}));q.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:X,durableSelector:(j=E.durableSelector)!=null?j:void 0,element:z,changes:q}})}_t.current={isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null},Wt(null);return}if(In){Ao(null);return}if(Bt){if(!Bt.hasMoved&&Bt.annotation.type==="text"&&((te=Bt.annotation.status)!=null?te:"pending")==="pending"){let E=He(m);be({id:Bt.annotation.id,point:Bt.annotation.points[0],text:Bt.annotation.text||"",fontSize:Bt.annotation.fontSize||12,isNew:!1,clickPoint:E,groupId:Bt.annotation.groupId})}Xt(null);return}if(!h)return;let b=5;if(e.currentPath.length>=2){let E=e.currentPath[0],T=e.currentPath[e.currentPath.length-1],X=Math.abs(T.x-E.x),z=Math.abs(T.y-E.y);if((e.activeTool==="line"?Math.sqrt(X*X+z*z)<b:X<b&&z<b)&&["rectangle","circle","line"].includes(e.activeTool)){A(!1),t({type:"CANCEL_PATH"});return}}let G=ws(e.currentPath);if(e.activeTool==="rectangle"&&e.currentPath.length>=2){let E=e.currentPath[0],T=e.currentPath[e.currentPath.length-1],X=Math.min(E.x,T.x),z=Math.max(E.y,T.y),J=e.strokeWidth/2,U=Math.random().toString(36).substring(2,9);me({point:{x:X-J+4,y:z+J+4},groupId:U}),A(!1),t({type:"FINISH_PATH",payload:{groupId:U,elements:G}});return}A(!1),t({type:"FINISH_PATH",payload:{elements:G}})},[h,Bt,In,Me,St,Qe,yt,He,t,e.activeTool,e.currentPath,e.strokeWidth]),Qn=un(m=>{let b=m.target.value;Ie.current=m.target.selectionStart,be(G=>G&&y(f({},G),{text:b}))},[]),Bn=un(m=>{m.key==="Escape"?be(null):m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),It())},[It]),er=un(m=>{if(!k)return;let b=m.clipboardData.items,G=[];for(let M=0;M<b.length;M++){let C=b[M];if(C.type.startsWith("image/")){let $=C.getAsFile();$&&G.push($)}}G.length>0&&(m.preventDefault(),be(M=>M?y(f({},M),{images:[...M.images||[],...G]}):null))},[k]),kr=un(m=>{if(!e.isAnnotating)return;if(e.activeTool==="hand"){m.preventDefault();let G=dt||Ot||W||Ut;if(G&&!qn(G)){let M=Nn(G),C=Jn(G);t({type:"SELECT_ELEMENT",payload:{el:G,info:y(f({},M),{selector:C})}})}return}m.preventDefault();let b=Y.current;b&&(B.current=!0,b.style.pointerEvents="none",setTimeout(()=>{B.current&&(B.current=!1,b.style.pointerEvents="")},4e3))},[e.activeTool,e.isAnnotating,dt,Ot,W,Ut,t,qn,Y]);kn(()=>{let m=V.filter(oe=>oe.linkedSelector);if(m.length===0)return;let b=null,G=document.createElement("canvas").getContext("2d"),M=()=>{var j,te,E;let oe=[];for(let T of m){let X=document.querySelector(T.linkedSelector);if(!X&&((te=(j=T.elements)==null?void 0:j[0])!=null&&te.selector)&&T.linkedSelector.startsWith("[data-pm=")){try{X=document.querySelector(T.elements[0].selector)}catch(st){}if(X){let st=(E=T.linkedSelector.match(/data-pm="([^"]+)"/))==null?void 0:E[1];st&&X.setAttribute("data-pm",st)}}if(!X)continue;let z=X.getBoundingClientRect(),J=e.styleModifications.some(st=>{try{return X.matches(st.selector)}catch(xe){return!1}}),U=m.filter(st=>st.id!==T.id&&st.timestamp<T.timestamp&&st.linkedSelector===T.linkedSelector).length,q=(J?1:0)+U,we;if(T.text&&G){let st=T.fontSize||12;G.font=`${st}px ${Zt}`,we=Math.max(...T.text.split(`
5
5
  `).map(xe=>G.measureText(xe).width))}let We=z.top>=eo*(1+q)?"top-left":"bottom-left",tt=yc(z,We,q,L==null?void 0:L.current,we),ot=T.points[0],Ft=We!==T.linkedAnchor;ot&&(Ft||Math.abs(tt.x-ot.x)>1||Math.abs(tt.y-ot.y)>1)&&oe.push({id:T.id,point:tt,linkedAnchor:Ft?We:void 0})}oe.length>0&&t({type:"UPDATE_LINKED_POSITIONS",payload:{updates:oe}})},C=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(M)};M(),window.addEventListener("scroll",C,!0),window.addEventListener("resize",C,!0),window.addEventListener("load",C),document.fonts.ready.then(C);let $=new MutationObserver(C);return $.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C,!0),window.removeEventListener("load",C),$.disconnect(),b&&cancelAnimationFrame(b)}},[V,t]);let ui=()=>{var m,b,G;if(!e.isAnnotating)return"default";if(In){let{handle:M}=In;return M==="start"||M==="end"?"move":M==="top"||M==="bottom"?"ns-resize":M==="left"||M==="right"?"ew-resize":M==="topLeft"||M==="bottomRight"?"nwse-resize":"nesw-resize"}if(e.activeTool==="text")return"text";if(e.activeTool==="hand"){let M=(m=Qe==null?void 0:Qe.axis)!=null?m:vt;if(M==="row")return"ns-resize";if(M==="column")return"ew-resize";if(St||Le)return"ns-resize";let C=(b=yt==null?void 0:yt.property)!=null?b:vn;if(C==="font-size")return"ew-resize";if(C==="line-height")return"ns-resize";let $=(G=Me==null?void 0:Me.side)!=null?G:se;return $==="top"||$==="bottom"?"ns-resize":$==="left"||$==="right"?"ew-resize":"default"}return"crosshair"},pi={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:9998,pointerEvents:e.isAnnotating?"auto":"none",visibility:e.isAnnotating?"visible":"hidden",cursor:ui()},P=un(()=>{let m=Y.current;if(!m||!k)return{width:100,height:12*1.4,isWrapped:!1};let b=m.getContext("2d");if(!b)return{width:100,height:k.fontSize*1.4,isWrapped:!1};b.font=`${k.fontSize}px ${Zt}`;let M=b.measureText("Type here...").width,C=k.text.split(`
6
6
  `),$=C.length>0?Math.max(M,...C.map(T=>b.measureText(T||" ").width)):M,oe=k.point.x-an.x,j=Or(oe);if($>j){let T=ml(b,C,j),X=Math.min(j,Math.max(M,...T.map(J=>b.measureText(J).width))),z=Math.max(1,T.length)*k.fontSize*1.4;return{width:X,height:z,isWrapped:!0}}let E=Math.max(1,C.length)*k.fontSize*1.4;return{width:$,height:E,isWrapped:!1}},[k,Y,an.x])(),le=k?Math.max(1,k.text.split(`