mouaif 0.3.0

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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +140 -0
  3. package/bin/mouaif.js +281 -0
  4. package/frontend/dist/assets/AgentFilePicker-CcKLJorU.js +1 -0
  5. package/frontend/dist/assets/CliModal-Hs5phmNZ.js +7 -0
  6. package/frontend/dist/assets/DictationPage-BI23lp42.js +2 -0
  7. package/frontend/dist/assets/FileEditor-DDl31c6d.js +2 -0
  8. package/frontend/dist/assets/GitModal-3EC_gpJ5.js +2 -0
  9. package/frontend/dist/assets/Inspector-Ba3R1w04.js +73 -0
  10. package/frontend/dist/assets/SettingsAbout-bvZGDEDw.js +1 -0
  11. package/frontend/dist/assets/SettingsActions-Dk6WX9jv.js +1 -0
  12. package/frontend/dist/assets/SettingsAgents-BNV0MgDB.js +1 -0
  13. package/frontend/dist/assets/SettingsDefaults-DbMmQbzc.js +1 -0
  14. package/frontend/dist/assets/SettingsHiddenContent-BZ2sloH1.js +1 -0
  15. package/frontend/dist/assets/SettingsMcp-DOrfbQd1.js +1 -0
  16. package/frontend/dist/assets/SettingsMcpEdit-BGMQ2CWC.js +3 -0
  17. package/frontend/dist/assets/SettingsMcpRegistry-BywXee_A.js +1 -0
  18. package/frontend/dist/assets/SettingsNotifications-B0LEs11a.js +1 -0
  19. package/frontend/dist/assets/SettingsPricing-BAg33iVF.js +1 -0
  20. package/frontend/dist/assets/SettingsProject-DNrKhCcZ.js +14 -0
  21. package/frontend/dist/assets/SettingsProjects-IqkBfDcm.js +1 -0
  22. package/frontend/dist/assets/SettingsPrompts-BgeiASuk.js +1 -0
  23. package/frontend/dist/assets/SettingsProviders-k0xJN0IK.js +1 -0
  24. package/frontend/dist/assets/SettingsTags-B5kjFdQi.js +1 -0
  25. package/frontend/dist/assets/agentNavigation-BiiCpFz5.js +1 -0
  26. package/frontend/dist/assets/codemirror-Bp6CUUFk.js +30 -0
  27. package/frontend/dist/assets/index-BGvI4n0T.js +61 -0
  28. package/frontend/dist/assets/index-Bgg1gnDf.css +1 -0
  29. package/frontend/dist/assets/index-C1sQFIC-.css +1 -0
  30. package/frontend/dist/assets/index-CANPYzQg.css +1 -0
  31. package/frontend/dist/assets/index-Crn1LdzK.css +1 -0
  32. package/frontend/dist/assets/index-FbCWDPiB.css +1 -0
  33. package/frontend/dist/assets/projectQS-D1cSZ7Gr.js +1 -0
  34. package/frontend/dist/assets/virtual-list-6H9b4K51.js +1 -0
  35. package/frontend/dist/icons/favicon-32.png +0 -0
  36. package/frontend/dist/icons/icon-180-apple.png +0 -0
  37. package/frontend/dist/icons/icon-192.png +0 -0
  38. package/frontend/dist/icons/icon-512.png +0 -0
  39. package/frontend/dist/icons/icon-maskable-512.png +0 -0
  40. package/frontend/dist/index.html +83 -0
  41. package/frontend/dist/manifest.webmanifest +33 -0
  42. package/frontend/dist/sw.js +482 -0
  43. package/package.json +98 -0
  44. package/scripts/patch-zimmerframe.js +58 -0
  45. package/src/access-auth.js +515 -0
  46. package/src/agentFeatures.js +294 -0
  47. package/src/agentFiles.js +164 -0
  48. package/src/agentSkills.js +147 -0
  49. package/src/agents.js +230 -0
  50. package/src/ai-chat.js +21 -0
  51. package/src/ai-endpoints.js +1880 -0
  52. package/src/ai-stream.js +2048 -0
  53. package/src/ai.js +68 -0
  54. package/src/auth.js +391 -0
  55. package/src/chatdb.js +816 -0
  56. package/src/chats.js +275 -0
  57. package/src/custom-actions.js +65 -0
  58. package/src/files.js +431 -0
  59. package/src/hideFileContent.js +327 -0
  60. package/src/http-server.js +535 -0
  61. package/src/index.js +15 -0
  62. package/src/inspector.js +731 -0
  63. package/src/inspectorProfiles.js +503 -0
  64. package/src/live-chat.js +107 -0
  65. package/src/mcp.js +1517 -0
  66. package/src/messages.js +238 -0
  67. package/src/modelList.js +137 -0
  68. package/src/notifications.js +52 -0
  69. package/src/oauth-anthropic.js +280 -0
  70. package/src/oauth-github-copilot.js +417 -0
  71. package/src/oauth-mcp.js +216 -0
  72. package/src/oauth-openrouter.js +285 -0
  73. package/src/package-version.js +20 -0
  74. package/src/projects.js +285 -0
  75. package/src/promptProfiles.js +256 -0
  76. package/src/prompts.js +384 -0
  77. package/src/providerShapes.js +44 -0
  78. package/src/providers/base.js +41 -0
  79. package/src/providers/index.js +25 -0
  80. package/src/push.js +315 -0
  81. package/src/qr.js +192 -0
  82. package/src/restart.js +47 -0
  83. package/src/server-handlers-access.js +306 -0
  84. package/src/server-handlers-actions.js +100 -0
  85. package/src/server-handlers-ai.js +248 -0
  86. package/src/server-handlers-auth.js +273 -0
  87. package/src/server-handlers-chats.js +1436 -0
  88. package/src/server-handlers-git.js +467 -0
  89. package/src/server-handlers-mcp-oauth.js +56 -0
  90. package/src/server-handlers-misc.js +783 -0
  91. package/src/server-handlers-projects.js +289 -0
  92. package/src/server-handlers-prompts.js +259 -0
  93. package/src/server-handlers-push.js +102 -0
  94. package/src/server-handlers-settings.js +406 -0
  95. package/src/server-handlers-tools.js +654 -0
  96. package/src/server-handlers-transcribe.js +399 -0
  97. package/src/server-shared.js +780 -0
  98. package/src/server-web-static.js +191 -0
  99. package/src/settings.js +898 -0
  100. package/src/statusBar.js +541 -0
  101. package/src/tags.js +414 -0
  102. package/src/toolFeedback.js +225 -0
  103. package/src/tools/ask.js +154 -0
  104. package/src/tools/authorization.js +932 -0
  105. package/src/tools/files.js +1150 -0
  106. package/src/tools/progress.js +71 -0
  107. package/src/tools/restart.js +32 -0
  108. package/src/tools/searchEngine.js +957 -0
  109. package/src/tools/shell.js +341 -0
  110. package/src/tools/subagent.js +47 -0
  111. package/src/tools/task.js +234 -0
  112. package/src/tools/webpreview.js +448 -0
  113. package/src/trace.js +103 -0
  114. package/src/transcribe.js +683 -0
  115. package/src/usage.js +389 -0
  116. package/src/util.js +151 -0
@@ -0,0 +1,73 @@
1
+ import{A,h as ne,k as o,d as T,u as yo,$ as bn,S as nt,_ as vo,T as Er,D as wo,a as _o,f as $e,b as ko,c as yn}from"./index-BGvI4n0T.js";import{c as Mr}from"./virtual-list-6H9b4K51.js";import{E as So,a as xo,o as Co,b as en,l as Po,h as Ro,c as To,d as No,i as Eo,e as Mo,f as Ao,s as Io,g as Lo,k as Fo,j as Mn,m as zo,n as Oo,p as Do,q as Bo,r as jo,t as Ho,u as Vo,v as Uo,w as Wo}from"./codemirror-Bp6CUUFk.js";function vn(e){if(!e)return"";const t=new Date(e);if(isNaN(t.getTime()))return"";const n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return n+":"+r+":"+i}function wn(e){return e==="pending"?"···":e==="failed"?"FAIL":String(e)}function qo(e){if(e==="pending")return"pending";if(e==="failed")return"failed";const t=Number(e);return!isNaN(t)&&t>=400?"error":!isNaN(t)&&t>=300?"redirect":!isNaN(t)&&t>=200?"ok":"other"}function _t(e){return typeof e!="number"||isNaN(e)||e<0?"":e<1024?e+" B":e<1024*1024?(e/1024).toFixed(e<10240?1:0)+" KB":(e/(1024*1024)).toFixed(2)+" MB"}function _n(e){return typeof e!="number"||isNaN(e)||e<0?"":e<1e3?e+" ms":(e/1e3).toFixed(2)+" s"}function Zo(e,t){if(!t)return;const n=document.createElement("span");if(n.className="inspector__arg inspector__arg--"+(t.type||"unknown"),t.type==="object"&&t.preview&&Array.isArray(t.preview.properties)){const r=t.preview.properties,i=r.slice(0,5).map(l=>l.name+": "+(l.value!==void 0?l.value:l.type||"")).join(", ");n.textContent=(t.className==="Array"?"[":"{")+i+(r.length>5?", …":"")+(t.className==="Array"?"]":"}"),n.title=t.description||""}else t.type==="string"?n.textContent=String(t.value!==void 0?t.value:t.description||""):typeof t.value<"u"?n.textContent=String(t.value):typeof t.description<"u"?n.textContent=t.description:t.type==="function"?n.textContent="ƒ "+(t.description||""):n.textContent=t.type||"";e.appendChild(n)}function Ko(e){return e?typeof e.value<"u"?String(e.value):typeof e.description<"u"?e.description:e.type==="function"?"ƒ "+(e.description||""):e.type||"":""}const Go=[["window","global object","variable"],["document","the DOM document","variable"],["location","current URL","variable"],["history","session history","variable"],["navigator","browser/device info","variable"],["screen","screen metrics","variable"],["localStorage","persistent storage","variable"],["sessionStorage","session storage","variable"],["fetch","fetch network requests","function"],["alert","show an alert dialog","function"],["confirm","show a confirm dialog","function"],["prompt","show a prompt dialog","function"],["setTimeout","schedule after a delay","function"],["setInterval","schedule repeatedly","function"],["requestAnimationFrame","schedule before next paint","function"],["getComputedStyle","computed style of an element","function"],["matchMedia","media query match","function"],["getSelection","current text selection","function"],["structuredClone","deep clone a value","function"],["URL","URL constructor","class"],["URLSearchParams","query-string parsing","class"],["Date","date constructor","class"],["JSON","JSON helpers","variable"],["Math","math helpers","variable"],["Object","Object constructor","class"],["Array","Array constructor","class"],["Map","Map constructor","class"],["Set","Set constructor","class"],["Promise","Promise constructor","class"],["RegExp","regex constructor","class"],["Error","Error constructor","class"],["console","console API","variable"]].map(([e,t,n])=>({label:e,detail:t,type:n})),$o=[["$","last evaluated result","variable"],["$$","querySelectorAll shorthand","function"],["$x","XPath query shorthand","function"],["$0","currently selected element","variable"],["$1","previously selected element","variable"],["$_","most recent evaluated value","variable"],["inspect","open a value in DevTools","function"],["clear","clear the console","function"],["copy","copy a value to the clipboard","function"],["keys","object keys","function"],["values","object values","function"],["debug","set a breakpoint on a function","function"],["monitor","log calls to a function","function"]].map(([e,t,n])=>({label:e,detail:t,type:n}));[["async function","async function expression","keyword"],["arrow function","arrow function expression","keyword"],["class","class expression","keyword"],["for loop","for loop","keyword"],["function","function expression","keyword"],["if","if statement","keyword"],["try/catch","try/catch statement","keyword"],["while","while loop","keyword"]].map(([e,t,n])=>({label:e,detail:t,type:n}));const Xo=`(() => {
2
+ const out = [];
3
+ const ids = new Set();
4
+ const push = (id) => { if (id && !ids.has(id)) { ids.add(id); out.push(id); } };
5
+ for (const el of document.querySelectorAll('[id]')) push(el.id);
6
+ for (const n of ['documentElement', 'head', 'body', 'title', 'activeElement']) {
7
+ try { const el = document[n]; if (el && el.id) push(el.id); } catch {}
8
+ }
9
+ return out.slice(0, 300);
10
+ })()`;function Jo(e){let t=null,n=null,r=null,i=0;async function l(){const c=Date.now();if(r&&c-i<2e3)return r;try{const u=await e("__mouaif_console_refs__",{expression:Xo,returnByValue:!0,objectGroup:"mouaif-console-refs"}),d=u&&u.result&&u.result.value;r=Array.isArray(d)?d:[]}catch{r=[]}return i=Date.now(),r}function s(){return t||(t=(async()=>{try{const c=await e("__mouaif_console_globals__",{expression:'(typeof globalThis !== "undefined" ? Object.getOwnPropertyNames(globalThis) : [])',returnByValue:!0,objectGroup:"mouaif-console-globals"}),u=c&&c.result&&c.result.value;Array.isArray(u)&&(n=u.filter(d=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(d)).sort().map(d=>({label:d,type:"variable"})))}catch{}return n||(n=[]),n})(),t)}async function a(c){let u;try{u=await e("__mouaif_console_props__",{expression:"(() => { try { const o = ("+c+'); return { ok: true, desc: String(o), props: (o == null ? [] : Object.getOwnPropertyNames(Object(o))) }; } catch (e) { return { ok: false, desc: "", props: [] }; } })()',returnByValue:!0,objectGroup:"mouaif-console-props"})}catch{return[]}const d=u&&u.result&&u.result.value;if(!d||d.ok!==!0||!Array.isArray(d.props))return[];const y=typeof d.desc=="string"?d.desc.slice(0,40):"";return d.props.filter(_=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(_)).slice(0,250).map(_=>({label:_,type:"property",detail:y||void 0}))}return async function(u){const d=u.matchBefore(/[\w$]+$/);if(!d){if(u.explicit){const Z=await s();return{from:u.pos,options:Z.slice(0,200),validFor:/^[\w$]*$/}}return null}if(u.state.sliceDoc(Math.max(0,d.from-1),d.from)==="."){const Z=u.state.doc.lineAt(u.pos).from,X=u.state.sliceDoc(Z,d.from).replace(/\.$/,"").trim().match(/[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/);if(X){const B=await a(X[0]);return B.length?{from:d.from,options:B,validFor:/^[\w$]*$/}:null}}const _=d.text,R=Go.concat($o).filter(Z=>Z.label.toLowerCase().startsWith(_.toLowerCase())).slice(0,80),K=(await s()).filter(Z=>Z.label.toLowerCase().startsWith(_.toLowerCase())&&Z.label!==_).slice(0,120),p=(await l()).filter(Z=>Z.toLowerCase().startsWith(_.toLowerCase())).slice(0,60).map(Z=>({label:Z,type:"variable",detail:"#"+Z})),E=[],q=new Set;for(const Z of R.concat(K,p))q.has(Z.label)||(q.add(Z.label),E.push(Z));return E.length?{from:d.from,options:E.slice(0,300),validFor:/^[\w$]*$/}:null}}function Yo(e){const t=A(null),n=A(null),r=A(e.onEvaluate);r.current=e.onEvaluate;const i=A(e.getEval);i.current=e.getEval;const l=A(null);return ne(()=>{if(!t.current)return;const s=Jo((y,_)=>{const R=i.current;return R?R(y,_):Promise.reject(new Error("no CDP connection"))}),a=y=>{const _=y.state.doc.toString();if(!_||!_.trim())return!0;const R=r.current;if(R)try{R(_)}catch{}return y.dispatch({changes:{from:0,to:y.state.doc.length},selection:{anchor:0}}),!0};l.current=()=>{const y=n.current;if(!y)return;const{from:_,to:R}=y.state.selection.main,j=y.state.doc.lineAt(_),K=`
11
+ `+/^[ \t]*/.exec(j.text)[0];y.dispatch(y.state.changeByRange(N=>({changes:{from:N.from,to:N.to,insert:K},range:So.cursor(N.from+K.length)}))),y.focus()};const c=[{key:"Mod-Enter",run:y=>a(y)},{key:"Enter",run:Mn},{key:"Shift-Enter",run:Mn},zo,...Oo,...Do,...Bo,...jo],u=xo.create({doc:"",extensions:[Po(),Ro(),To(),No(),Eo(),Mo(),Ao(),Io(Lo),Fo.of(c),Ho({override:[s],activateOnTyping:!0,defaultKeymap:!0,maxRenderedOptions:40,tooltipClass:()=>"mouaif-console-autocomplete"}),Vo(),Uo(),Co,en.lineWrapping,Wo("Evaluate JavaScript in the page…"),en.theme({"&":{height:"auto",fontSize:"13px"},".cm-content":{padding:"8px 0",caretColor:"#528bff"},".cm-gutters":{backgroundColor:"#282c34",borderRight:"1px solid #21252b"},".cm-line":{padding:"0 8px"}})]}),d=new en({state:u,parent:t.current});return n.current=d,()=>{d.destroy(),n.current=null,l.current=null}},[]),o("div",{class:"inspector__jsconsole"},o("div",{class:"inspector__jsconsole-bar"},o("span",{class:"inspector__jsconsole-hint"},"Enter for newline · Ctrl+Enter to run · Ctrl+Space to autocomplete"),o("button",{type:"button",class:"inspector__jsconsole-btn","aria-label":"New line with indent",title:"New line with indent",onClick:()=>{l.current&&l.current()}},"↵")),o("div",{ref:t,class:"inspector__jsconsole-editor","aria-label":"JavaScript console"}))}function Qo(e){const t=A(null);return ne(()=>{if(!t.current)return;const n=Mr({scroller:t.current,itemHeight:64,overscan:6,key:r=>r.id,render:(r,i)=>{const l=r.id+"|"+(r.rev||0);if(i.__sig===l)return;i.__sig=l,i.className="inspector__row inspector__row--console inspector__row--"+(r.level||"log");const s=document.createElement("span");s.className="inspector__row-time",s.textContent=vn(r.ts);const a=document.createElement("span");a.className="inspector__row-level",a.textContent=(r.level||"log").toUpperCase();const c=document.createElement("span");c.className="inspector__row-body";const u=document.createElement("span");if(u.className="inspector__row-text",Array.isArray(r.args)&&r.args.length)for(let _=0;_<r.args.length;_++)_&&u.appendChild(document.createTextNode(" ")),Zo(u,r.args[_]);else u.textContent=r.text||"";c.appendChild(u);const d=document.createElement("span");d.className="inspector__row-meta";const y=[];r.url&&y.push(r.url.replace(/^.*\//,"")+(r.line?":"+r.line:"")),r.stack&&y.push("stack"),d.textContent=y.join(" · "),d.textContent&&c.appendChild(d),r.stack&&(i.classList.add("inspector__row--expandable"),i.title="tap for stack trace"),i.replaceChildren(s,a,c)},data:[]});return e.onReady&&e.onReady(n),()=>{try{n.destroy()}catch{}}},[]),o("div",{class:"inspector__console-wrap"},o("div",{ref:t,class:"inspector__scroller inspector__scroller--console","aria-label":"Console output",onClick:e.onRowTap}),o(Yo,{onEvaluate:e.onEvaluate,getEval:e.getEval}))}function ei(e){const t=A(null);return ne(()=>{if(!t.current)return;const n=Mr({scroller:t.current,itemHeight:52,overscan:6,key:r=>r.id,render:(r,i)=>{const l=r.id+"|"+(r.rev||0)+"|"+String(r.status)+"|"+String(r.size)+"|"+String(r.duration);if(i.__sig===l)return;i.__sig=l,i.className="inspector__row inspector__row--network inspector__row--expandable";const s=document.createElement("div");s.className="inspector__net-top";const a=document.createElement("span");a.className="inspector__row-method",a.textContent=r.method||"";const c=document.createElement("span");c.className="inspector__row-status inspector__row-status--"+qo(r.status),c.textContent=wn(r.status);const u=document.createElement("span");u.className="inspector__row-text",u.textContent=r.url||"",s.appendChild(a),s.appendChild(c),s.appendChild(u);const d=document.createElement("div");d.className="inspector__net-meta";const y=[];r.type&&y.push(r.type),r.mimeType&&y.push(r.mimeType.split(";")[0]),r.size!=null&&y.push(_t(r.size)),r.duration!=null&&y.push(_n(r.duration)),r.ip&&y.push(r.ip),d.textContent=y.join(" · "),i.replaceChildren(s,d)},data:[]});return e.onReady&&e.onReady(n),()=>{try{n.destroy()}catch{}}},[]),o("div",{ref:t,class:"inspector__scroller inspector__scroller--network","aria-label":"Network log",onClick:e.onRowTap})}function ti(e,t,n){return e&&typeof e.then=="function"?e.then(r=>{r&&t&&t()},()=>{}):(e&&t&&t(),null)}function an(){return"Pick: tap an element in the page"}const ni="mouaif:inspector:previewZoom",cn="mouaif:inspector:previewZoom2";function ri(e){const t=A(null),n=A(null),r=A(null),[i,l]=T(""),[s,a]=T(!1),c=A(null);e.typeBarRef&&(e.typeBarRef.current={open:()=>{c.current&&c.current.scrollIntoView({block:"nearest"}),r.current&&r.current.focus()}});async function u(M,Q){if(s)return;const ee=M??i;if(!(!ee&&!Q)){a(!0);try{Q?e.onEnter&&await e.onEnter():(e.onInsert&&await e.onInsert(ee),l("")),e.refreshRef&&e.refreshRef.current&&e.refreshRef.current()}finally{a(!1)}}}function d(M){M.preventDefault(),u(i,!1)}const y=A(null),_=A(null),[R,j]=T(!1);e.fullscreenOpenRef&&(e.fullscreenOpenRef.current.open=R);const K=yo({onClose:()=>j(!1),active:R}),[N,p]=T(""),[E,q]=T("capturing…"),Z=(()=>{if(typeof localStorage>"u")return"fit";try{if(localStorage.getItem(cn)==="size")return"size";localStorage.removeItem(ni)}catch{}return"fit"})(),[D,X]=T(Z),[B,ge]=T({w:0,h:0}),$=A({w:0,h:0}),ue=A(!1),de=A(si());function ie(){de.current=!0,ue.current=!0,X(M=>{const Q=M==="fit"?"size":"fit";try{localStorage.setItem(cn,Q)}catch{}return Q})}function be(M,Q){if(ue.current||(ue.current=!0,!M||!Q))return;const ee=Q.clientWidth||Q.offsetWidth,te=An(qe.current.presets,qe.current.id);ii({decided:!1,chosen:de.current,naturalWidth:M.naturalWidth,frameWidth:ee,deviceScaleFactor:te})&&X("size")}const[H,se]=T(""),[Te,we]=T(""),ce=A(""),ye=A(null);ye.current=e.evaluate||null;const[Se,ae]=T(!1);async function pe(M){const Q=ye.current;if(!(!Q||M===void 0))try{const ee=await Q('document.title || ""');if(!ee)return;const te=ee&&ee.result&&typeof ee.result.value=="string"?ee.result.value:"";te&&we(te)}catch{}}const xe=A({w:0,h:0}),v=A(!1),U=A({x:0,y:0}),le=10;function De(M){if(M.button!=null&&M.button!==0){v.current=!1;return}v.current=!0,U.current={x:M.clientX,y:M.clientY}}function z(M){if(!v.current)return;const Q=M.clientX-U.current.x,ee=M.clientY-U.current.y;(Math.abs(Q)>le||Math.abs(ee)>le)&&(v.current=!1)}function oe(){v.current=!1}function Ne(){v.current=!1}const fe=A(null),Xe=A(""),qe=A({presets:e.sizePresets,id:e.sizeId});qe.current={presets:e.sizePresets,id:e.sizeId},ne(()=>{if(!e.capture)return;let M=!1,Q=!1,ee=null,te=null,Ie=0,J=0,Le=0,Ee=null,Ke=0;const Ze=250;let m=null;function g(){ee&&clearTimeout(ee);const P=Date.now()-Ie,x=P>=3e3?500:3e3-P;ee=setTimeout(()=>{if(ee=null,!M){if(Q){g();return}S("poll"),g()}},x)}async function S(P,x){if(M)return;if(Q){(x||P!=="poll")&&(x||!m||!m.force)&&(m={reason:P,force:!!x});return}Q=!0,Ie=Date.now();const V=++Le;try{const G=await e.capture();if(M)return;if(g(),!G||!G.data){q(n.current&&n.current.src?"live":"capturing…");return}if(G.data===Xe.current){q("live");return}Xe.current=G.data;const he="data:image/png;base64,"+G.data;fe.current={dataUrl:he,width:0,height:0};const Fe=n.current,Be=t.current;if(Fe&&Be){const Me=Be.scrollTop||0,ze=Be.scrollLeft||0,rt=Fe.onload;Fe.onload=()=>{t.current&&(t.current.scrollTop!==Me&&(t.current.scrollTop=Me),t.current.scrollLeft!==ze&&(t.current.scrollLeft=ze));const je=n.current;if(je){xe.current.w=je.naturalWidth||xe.current.w,xe.current.h=je.naturalHeight||xe.current.h,fe.current&&(fe.current.width=je.naturalWidth||0,fe.current.height=je.naturalHeight||0);const Ae=je.naturalWidth||0,et=je.naturalHeight||0;Ae&&et&&(Ae!==$.current.w||et!==$.current.h)&&($.current={w:Ae,h:et},ge($.current)),be(je,t.current),je.onload=rt||null}},Fe.src=he,p(he),q("live")}else p(he),q("live")}catch(G){const he=G&&G.message||String(G);q(he==="not connected"||he==="disconnected"?"capturing…":"screenshot failed: "+he)}finally{if(Q=!1,J=Date.now(),Ee!=null&&e.ackFrame&&V>=Ke){const G=Ee;Ee=null,Ke=0,te&&(clearTimeout(te),te=null),e.ackFrame(G).catch(()=>{})}if(m&&!M){const G=m;m=null,S(G.reason,G.force);return}}}const C=[];return e.subscribe&&(C.push(e.subscribe("Page.frameNavigated",P=>{if(M)return;const x=P&&P.frame,V=x&&!x.parentId&&typeof x.url=="string"?x.url:"";V&&V!==ce.current&&(ce.current=V,se(V),pe(V)),S("navigate"),g()})),C.push(e.subscribe("Page.frameStoppedLoading",()=>{M||(S("load"),pe(ce.current),g())})),C.push(e.subscribe("Page.navigatedWithinDocument",P=>{if(M)return;const x=P&&typeof P.url=="string"?P.url:"";x&&x!==ce.current&&(ce.current=x,se(x)),S("load"),g()})),C.push(e.subscribe("Page.screencastFrame",P=>{if(M||!P||P.sessionId==null||!e.ackFrame||(Ee=P.sessionId,Ke=Le+1,te))return;const x=Math.max(0,Ze-(Date.now()-J));te=setTimeout(()=>{te=null,M||S("stream")},x)}))),S("init"),g(),pe(ce.current),e.refreshRef&&(e.refreshRef.current=()=>{M||(q("capturing…"),S("manual",!0))}),e.fullscreenRef&&(e.fullscreenRef.current=()=>{M||j(P=>!P)}),e.draftCraftRef&&(e.draftCraftRef.current=()=>{!M&&fe.current&&e.onDraftCraft&&e.onDraftCraft(fe.current)}),()=>{M=!0,e.refreshRef&&(e.refreshRef.current=null),e.fullscreenRef&&(e.fullscreenRef.current=null),e.draftCraftRef&&(e.draftCraftRef.current=null),ee&&clearTimeout(ee),te&&clearTimeout(te);for(const P of C)try{P()}catch{}}},[e.capture,e.subscribe,e.ackFrame]);const Ce=A(!1);ne(()=>{if(Ce.current||!e.pageUrl&&!e.pageTitle)return;Ce.current=!0;const M=typeof e.pageUrl=="string"?e.pageUrl:"",Q=typeof e.pageTitle=="string"?e.pageTitle:"";M&&M!==ce.current&&(ce.current=M,se(M)),Q&&we(Q)},[e.pageUrl,e.pageTitle]);function Pe(M,Q){const ee=Q||n.current;if(!ee||!e.clickAt||!v.current)return;const te=ee.getBoundingClientRect();if(te.width<=0||te.height<=0)return;let Ie=ee.naturalWidth,J=ee.naturalHeight;(!Ie||!J)&&(Ie=xe.current.w||Ie,J=xe.current.h||J),(!Ie||!J)&&(Ie=te.width,J=te.height);const Le=Math.round((M.clientX-te.left)*(Ie/te.width)),Ee=Math.round((M.clientY-te.top)*(J/te.height));e.clickAt(Le,Ee)}const _e=D==="size"&&B.w?{width:ai(B.w,An(e.sizePresets,e.sizeId))+"px"}:null;return o(nt,null,o("div",{class:"inspector__preview"+(e.pickMode?" is-picking":"")},e.pickMode?o("div",{class:"inspector__pickban",role:"status","aria-live":"polite"},o("span",{class:"inspector__pickban-dot","aria-hidden":"true"}),o("span",{class:"inspector__pickban-text"},e.pickHint||an()),e.onPickCancel?o("button",{class:"btn inspector__pickban-cancel",type:"button","aria-label":"Cancel picking an element",title:"Cancel picking",onClick:M=>{M.stopPropagation(),e.onPickCancel()}},"Cancel"):null):null,o("div",{ref:t,class:"inspector__preview-frame",role:"group","aria-label":"Live page preview, scrollable",onPointerDown:De,onPointerMove:z,onPointerUp:z,onPointerCancel:Ne,onScroll:oe,onClick:M=>Pe(M)},o("img",{ref:n,src:N,class:"inspector__preview-img"+(D==="size"?" inspector__preview-img--size":""),style:_e,alt:"Live page preview",draggable:"false"})),e.onInsert||e.onEnter?o("form",{ref:c,class:"inspector__typebar",onSubmit:d},o("input",{ref:r,class:"input inspector__typebar-input",type:"text",placeholder:"Type into page…",value:i,disabled:s,onInput:M=>l(M.currentTarget.value),"aria-label":"Type text into the inspected page"}),o("button",{class:"btn inspector__typebar-send",type:"submit",disabled:s||!i,"aria-label":"Send typed text",title:"Send typed text"},"Send"),e.onEnter?o("button",{class:"btn inspector__typebar-enter",type:"button",disabled:s,"aria-label":"Press Enter in the inspected page",title:"Press Enter in the inspected page",onClick:()=>u("",!0)},"↵"):null):o("div",{ref:c}),o("div",{class:"inspector__preview-foot"},o("div",{class:"status inspector__status","aria-live":"polite"},E),o("button",{class:"inspector__zoom"+(D==="size"?" is-on":""),type:"button","aria-pressed":String(D==="size"),"aria-label":D==="size"?"Show preview fit to width":"Show preview at natural size and pan",title:D==="size"?"Fit width":"Natural size (pan)",onClick:ie},o("svg",{viewBox:"0 0 24 24",width:14,height:14,"aria-hidden":"true"},o("path",{d:"M4 4h6v2H6v4H4V4Zm10 0h6v6h-2V6h-4V4ZM4 14h2v4h4v2H4v-6Zm14 0h2v6h-6v-2h4v-4Z",fill:"currentColor"})),o("span",null,D==="size"?"Fit":"100%")))),R?bn(o("div",{class:"inspector__preview-fs",role:"dialog","aria-modal":"true","aria-label":Te||H||"Live page preview, full screen",ref:K},o("div",{class:"inspector__preview-fs-head"},o("div",{class:"inspector__preview-fs-text"},o("div",{class:"inspector__preview-fs-title",title:Te||H||"Preview"},Te||H||"Preview"),o("div",{class:"inspector__preview-fs-host"},oi(H))),o("div",{class:"inspector__preview-fs-actions"},o("button",{class:"inspector__preview-fs-zoom"+(D==="size"?" is-on":""),type:"button","aria-pressed":String(D==="size"),"aria-label":D==="size"?"Show preview fit to width":"Show preview at natural size and pan",title:D==="size"?"Fit width":"Natural size (pan)",onClick:ie},o("svg",{viewBox:"0 0 24 24",width:14,height:14,"aria-hidden":"true"},o("path",{d:"M4 4h6v2H6v4H4V4Zm10 0h6v6h-2V6h-4V4ZM4 14h2v4h4v2H4v-6Zm14 0h2v6h-6v-2h4v-4Z",fill:"currentColor"}))),o("button",{class:"btn inspector__preview-fs-refresh",type:"button",disabled:Se,onClick:()=>{Se||(ae(!0),e.refreshRef&&e.refreshRef.current&&e.refreshRef.current(),setTimeout(()=>ae(!1),350))},"aria-label":"Refresh preview",title:"Refresh preview"},o("svg",{viewBox:"0 0 24 24",width:14,height:14,"aria-hidden":"true"},o("path",{d:"M4 12a8 8 0 0 1 13.66-5.66L20 4 M20 4v5h-5 M20 12a8 8 0 0 1-13.66 5.66L4 20 M4 20v-5h5",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"})),o("span",null,"Refresh")),Array.isArray(e.sizePresets)&&e.sizePresets.length>0?o("select",{class:"inspector__preview-fs-size",value:e.sizeId||"auto",disabled:!!e.sizeDisabled,"aria-label":"Capture size",title:"Capture size",onChange:M=>e.onSizeChange&&e.onSizeChange(M.currentTarget.value)},e.sizePresets.map(M=>o("option",{key:M.id,value:M.id},M.width?M.label+" · "+M.width+"×"+M.height:M.label))):null,o("button",{class:"icon-btn inspector__preview-fs-close",type:"button","aria-label":"Close full-screen preview",title:"Close full-screen preview",onClick:()=>j(!1)},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M6 6 18 18 M18 6 6 18",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round"}))))),e.onInsert||e.onEnter?o("form",{class:"inspector__typebar inspector__typebar--fs",onSubmit:d},o("input",{class:"input inspector__typebar-input",type:"text",placeholder:"Type into page…",value:i,disabled:s,onInput:M=>l(M.currentTarget.value),"aria-label":"Type text into the inspected page"}),o("button",{class:"btn inspector__typebar-send",type:"submit",disabled:s||!i,"aria-label":"Send typed text",title:"Send typed text"},"Send"),e.onEnter?o("button",{class:"btn inspector__typebar-enter",type:"button",disabled:s,"aria-label":"Press Enter in the inspected page",title:"Press Enter in the inspected page",onClick:()=>u("",!0)},"↵"):null):null,o("div",{ref:y,class:"inspector__preview-fs-frame"+(e.pickMode?" is-picking":""),role:"group","aria-label":"Live page preview, scrollable",onPointerDown:De,onPointerMove:z,onPointerUp:z,onPointerCancel:Ne,onScroll:oe,onClick:M=>Pe(M,_.current)},e.pickMode?o("div",{class:"inspector__pickban inspector__pickban--fs",role:"status"},o("span",{class:"inspector__pickban-dot","aria-hidden":"true"}),o("span",{class:"inspector__pickban-text"},e.pickHint||an()),e.onPickCancel?o("button",{class:"btn inspector__pickban-cancel",type:"button","aria-label":"Cancel picking an element",onClick:M=>{M.stopPropagation(),e.onPickCancel()}},"Cancel"):null):null,o("img",{ref:_,src:N,class:"inspector__preview-fs-img"+(D==="size"?" inspector__preview-img--size":""),style:_e,alt:"Live page preview",draggable:"false"}))),document.body):null)}function oi(e){if(!e||!/^https?:\/\//i.test(e))return"";try{return new URL(e).host}catch{return""}}function ii({decided:e,chosen:t,naturalWidth:n,frameWidth:r,deviceScaleFactor:i}){return t?!1:li(n,r,i)==="size"}function si(){if(typeof localStorage>"u")return!1;try{const e=localStorage.getItem(cn);return e==="size"||e==="fit"}catch{return!1}}function An(e,t){const n=Array.isArray(e)?e.find(r=>r.id===t):null;return n&&n.deviceScaleFactor||1}function li(e,t,n){if(!e||!t)return"fit";const r=e/n;return r&&t/r<.6?"size":"fit"}function ai(e,t){return e?Math.round(e/t):0}function ci(e){const[t,n]=T(null),r=A(e.metrics);r.current=e.metrics,ne(()=>{let l=!1,s=null;async function a(){if(!l){try{const c=r.current,u=c?await c():null;if(l)return;n(u)}catch{}l||(s=setTimeout(a,2500))}}return a(),()=>{l=!0,s&&clearTimeout(s)}},[]);const i=t?[["Documents",t.documents],["Frames",t.frames],["Nodes",t.nodes],["Listeners",t.listeners],["JS heap",_t(t.jsHeap)],["Layout",t.layoutCount],["Recalc style",t.recalcCount],["Requests (session)",t.netCount]]:[];return o("div",{class:"inspector__metrics","aria-label":"Page metrics"},i.map(([l,s])=>o("div",{class:"inspector__metric",key:l},o("div",{class:"inspector__metric-value"},s==null||s===""?"—":String(s)),o("div",{class:"inspector__metric-key"},l))))}function ui(e,t){const n=String(t||"").trim();if(!n)return e;const r=e.filter(i=>i!==n);return r.unshift(n),r}function In(e,t){const n=String(t||"").trim();return!n||!e.includes(n)?e:e.filter(r=>r!==n)}function Ln(e,t){const n=e.indexOf(t);return n===-1?1/0:n}function Fn(e,t,n){const r=Array.isArray(e)?e.slice():[];if(!Array.isArray(t)||t.length===0)return r;const i=l=>l&&l.prop;return r.sort((l,s)=>Ln(t,i(l))-Ln(t,i(s)))}function Et(e,t){return Array.isArray(e)&&e.includes(t)}const tn="--insp-pin-h";function di(e){if(!e||typeof e.getBoundingClientRect!="function")return"";const t=e.getBoundingClientRect(),n=t&&t.height;return typeof n!="number"||!isFinite(n)||n<=0?"":Math.round(n)+"px"}function pi(e,t){if(!e||!e.style||typeof e.style.setProperty!="function")return"";const n=di(t);return n?(e.style.getPropertyValue&&e.style.getPropertyValue(tn)===n||e.style.setProperty(tn,n),n):(typeof e.style.removeProperty=="function"&&e.style.removeProperty(tn),"")}function fi(e,t,n){const r={},i=r.ResizeObserver!==void 0?r.ResizeObserver:typeof ResizeObserver=="function"?ResizeObserver:null;if(typeof t=="function"&&t(),!e||!i)return()=>{};const l=new i(()=>{typeof t=="function"&&t()});return l.observe(e),()=>{try{l.disconnect()}catch{}}}const Ar=[{id:"all",label:"All",hint:"every property the browser resolves for this element"},{id:"set",label:"Declared",hint:"only the properties this element declares in its own inline style"},{id:"changed",label:"Changed",hint:"only the properties you changed in this session"}],Ir=Ar.map(e=>e.id),hi=60,zn=new Set;function mi(e,t){const n=String(t??"").trim().toLowerCase();return n?e?String(e.prop||"").toLowerCase().indexOf(n)!==-1?!0:String(e.value==null?"":e.value).toLowerCase().indexOf(n)!==-1:!1:!0}function gi(e,t){const n=t||{},r=Ir.indexOf(n.filter)===-1?"all":n.filter,i=n.setNames||zn,l=n.changedNames||zn,s=n.query,a=[];for(const c of e||[])c&&(r==="set"&&!i.has(c.prop)||r==="changed"&&!l.has(c.prop)||mi(c,s)&&a.push(c));return a}function bi(e,t){if(!Number.isFinite(e)||e<=0)return 0;const n=Math.max(0,Math.floor(Number(t)||0));return Math.min(e,hi*(n+1))}const yi=24;function On(e){const t=String(e??"").trim().toLowerCase();if(!t)return"";const n=t.indexOf("-");return n>0?t.slice(0,n):t}function Lr(e,t){const n=Array.isArray(e)?e:[],r=bi(n.length,t);if(r<=0||r>=n.length)return r;const i=On(n[r-1]&&n[r-1].prop);if(!i)return r;const l=Math.min(n.length,r+yi);let s=r;for(;s<l&&On(n[s]&&n[s].prop)===i;)s++;return s}function vi(e,t){const n=Array.isArray(e)?e:[];return Math.max(0,n.length-Lr(n,t))}function wi(e){const t=e||{},n=String(t.query==null?"":t.query).trim();return n?"No property matches “"+n+"”.":t.filter==="changed"?"Nothing changed yet — edited properties appear here.":t.filter==="set"?"Nothing set on this element yet — tap a declared row or a chip to add one.":"No computed styles for this element."}function _i(e){const t=e||{},n=Ir.indexOf(t.filter)===-1?"all":t.filter,r=Math.max(0,Number(t.shown)||0),i=Math.max(0,Number(t.total)||0),l=String(t.query==null?"":t.query).trim(),s=n==="changed"?"you changed here":n==="set"?"declared here":"all resolved";return l?r+" of "+i+" match “"+l+"” · "+s:"Showing "+r+" of "+i+" · "+s}const ki=["inherit","initial","unset","revert"],Lt={display:["block","flex","grid","inline","inline-block","inline-flex","none","contents"],position:["static","relative","absolute","fixed","sticky"],overflow:["visible","hidden","scroll","auto","clip"],"overflow-x":["visible","hidden","scroll","auto","clip"],"overflow-y":["visible","hidden","scroll","auto","clip"],"text-align":["left","right","center","justify","start","end"],"flex-direction":["row","row-reverse","column","column-reverse"],"flex-wrap":["nowrap","wrap","wrap-reverse"],"align-items":["stretch","flex-start","flex-end","center","baseline"],"align-self":["auto","stretch","flex-start","flex-end","center","baseline"],"justify-content":["flex-start","flex-end","center","space-between","space-around","space-evenly"],"justify-items":["start","end","center","stretch"],"white-space":["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],"box-sizing":["content-box","border-box"],"font-style":["normal","italic","oblique"],"font-weight":["normal","bold","lighter","bolder"],"text-decoration":["none","underline","line-through","overline"],"border-style":["none","solid","dashed","dotted","double","groove","ridge","inset","outset"],"list-style-type":["none","disc","circle","square","decimal"],"pointer-events":["auto","none"],visibility:["visible","hidden","collapse"],"object-fit":["fill","contain","cover","none","scale-down"],"background-repeat":["repeat","no-repeat","repeat-x","repeat-y","space","round"],"background-size":["auto","cover","contain"],cursor:["auto","default","pointer","text","move","grab","not-allowed","wait","help"],"mix-blend-mode":["normal","multiply","screen","overlay","darken","lighten"],opacity:["initial","inherit","unset"],"line-height":["normal","inherit","initial","unset"],width:["auto","fit-content","max-content","min-content","inherit"],height:["auto","fit-content","max-content","min-content","inherit"],"max-width":["none","fit-content","max-content","min-content","inherit"],"max-height":["none","fit-content","max-content","min-content","inherit"],"min-width":["auto","fit-content","max-content","min-content","inherit"],"min-height":["auto","fit-content","max-content","min-content","inherit"],"z-index":["auto","inherit","initial","unset"],flex:["none","auto","initial"],transform:["none"],transition:["none"],"transition-timing-function":["ease","linear","ease-in","ease-out","ease-in-out","step-start","step-end"],"animation-timing-function":["ease","linear","ease-in","ease-out","ease-in-out","step-start","step-end"],"transition-duration":["inherit","initial","unset"],"animation-duration":["inherit","initial","unset"],"border-radius":["inherit","initial","unset"],padding:["inherit","initial","unset"],margin:["auto","inherit","initial","unset"]},Si={px:"length-abs",pt:"length-abs",pc:"length-abs",cm:"length-abs",mm:"length-abs",in:"length-abs",q:"length-abs",rem:"length-rel",em:"length-rel","%":"percent",vh:"view",vw:"view",vmin:"view",vmax:"view",ch:"length-rel",ex:"length-rel",ms:"time",s:"time",deg:"angle",rad:"angle",turn:"angle",grad:"angle"},un=new Set(["opacity","fill-opacity","stroke-opacity"]),xi=new Set(["width","height","min-width","min-height","max-width","max-height","top","right","bottom","left","padding","margin","gap","row-gap","column-gap","font-size","letter-spacing","word-spacing","text-indent","vertical-align","border-radius","border-width","outline-width","outline-offset","inset","block-size","inline-size","flex-basis"]),Ci=new Set(["opacity","z-index","line-height","flex-grow","flex-shrink","order","font-weight","widows","orphans","tab-size","scale","aspect-ratio"]),Pi=new Set(["font-size","line-height","opacity","width","height","max-width","max-height","min-width","min-height","padding","margin","top","right","bottom","left","flex-basis","letter-spacing","text-indent"]),Dn={length:"Length",number:"Number",percent:"Percent",keyword:"Keyword",color:"Colour",time:"Time",angle:"Angle",custom:"Custom",expression:"Expression",unknown:"Text"},Ri=/^([-+]?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i,Ti=/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|color\(|color-mix\(|currentcolor$|transparent$|(?:[a-z]+)$)/i,Bn=new Set(["black","silver","gray","grey","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","pink","brown","gold","cyan","magenta","violet","indigo","transparent","currentcolor"]),Ni=["top-left","top-right","bottom-right","bottom-left","block-start","block-end","inline-start","inline-end","top","right","bottom","left","block","inline","start","end","x","y","row","column"];function Ei(e){for(const t of Ni){if(e===t)continue;if(e.endsWith("-"+t))return e.slice(0,-(t.length+1));const n="-"+t+"-",r=e.indexOf(n);if(r>0)return e.slice(0,r)+"-"+e.slice(r+n.length)}return""}function Dt(e){const t=String(e||"").trim().toLowerCase();if(!t)return"unknown";if(t==="color"||t.endsWith("-color")||t==="background")return"color";if(t.endsWith("-duration")||t.endsWith("-delay")||t==="transition-duration"||t==="animation-duration")return"time";if(t.startsWith("rotate")||t.endsWith("-angle")||t.startsWith("hue-rotate")||t==="rotate"||t==="transform")return"angle-or-transform";if(t.startsWith("--"))return"custom";if(Ci.has(t))return"number";if(xi.has(t)||t.endsWith("-width")||t.endsWith("-size")||t.endsWith("-radius"))return"length";if(Lt[t])return"keyword-only";const n=Ei(t);if(n){const r=Dt(n);if(r!=="unknown")return r}return"unknown"}function ve(e,t){const n=String(e||"").trim().toLowerCase(),r=n.startsWith("--"),i=String(t??"").trim();if(!i)return{kind:"unknown",raw:i,customProperty:r};const l=i.toLowerCase();if(/^var\(/i.test(l))return{kind:"custom",raw:i,customProperty:r,keyword:i};if(/^(calc|min|max|clamp)\(/i.test(l))return{kind:"expression",raw:i,customProperty:r};if(l.startsWith("url(")||l.startsWith("linear-gradient(")||l.startsWith("radial-gradient("))return{kind:"unknown",raw:i,customProperty:r};const s=Dt(n);if(s==="color"&&(Ti.test(l)||Bn.has(l)))return{kind:"color",raw:i,customProperty:r,keyword:Bn.has(l)?l:void 0};if(/^#[0-9a-f]{3,8}$/i.test(l))return{kind:"color",raw:i,customProperty:r};if(/^(rgba?|hsla?)\(/i.test(l))return{kind:"color",raw:i,customProperty:r};const a=Ri.exec(i);if(a){const c=Number(a[1]),u=(a[2]||"").toLowerCase();if(!u){const y=c===0;return{kind:s==="length"&&y?"length":"number",raw:i,number:c,customProperty:r,unit:y&&s==="length"?"px":""}}const d=Si[u];return d==="percent"?{kind:"percent",raw:i,number:c,unit:"%",customProperty:r}:d==="time"?{kind:"time",raw:i,number:c,unit:u,customProperty:r}:d==="angle"?{kind:"angle",raw:i,number:c,unit:u,customProperty:r}:d==="length-abs"||d==="length-rel"||d==="view"?{kind:"length",raw:i,number:c,unit:u,customProperty:r,relative:d==="length-rel"}:{kind:"unknown",raw:i,number:c,unit:u,customProperty:r}}return/^[a-z-]+(\s+[a-z-]+)*$/i.test(l)?{kind:"keyword",raw:i,keyword:l,customProperty:r}:{kind:"unknown",raw:i,customProperty:r}}function jn(e,t){const n=String(e||"").trim().toLowerCase();if(n.startsWith("--")){const s=ve(n,t);return!t||s.kind==="custom"||s.kind==="unknown"||s.kind==="expression"?["custom"]:[s.kind,"keyword"]}const r=Dt(n),i=[],l=s=>{i.includes(s)||i.push(s)};return r==="color"?(l("color"),l("keyword"),i):r==="time"?(l("time"),l("keyword"),i):r==="custom"?["custom"]:r==="length"?(l("length"),Pi.has(n)&&l("percent"),l("number"),l("keyword"),i):r==="number"?(l("number"),un.has(n)&&l("percent"),l("keyword"),i):r==="angle-or-transform"?(l("angle"),l("length"),l("keyword"),i):(l("keyword"),i)}function Hn(e){const t=String(e||"").trim();if(!t)return"";const n=Dt(t);return n==="length"?"0px":n==="number"?"0":n==="time"?"0ms":n==="angle-or-transform"?"0deg":""}function dn(e,t,n){const r=n||{};return t==="px"?e:t==="pt"?e*(96/72):t==="pc"?e*16:t==="in"?e*96:t==="cm"?e*(96/2.54):t==="mm"?e*(96/25.4):t==="q"?e*(96/101.6):t==="rem"?r.rootFontSize?e*r.rootFontSize:null:t==="em"?r.parentFontSize||r.fontSize?e*(r.parentFontSize||r.fontSize):null:(t==="ch"||t==="ex")&&r.fontSize?e*r.fontSize*.5:null}function L(e){if(!Number.isFinite(e))return"";const t=Math.round(e*1e4)/1e4;return String(t)}function Vn(e,t){const n=String(e||"").trim().toLowerCase(),r=t||{};if(n==="font-size"||n==="line-height"){const i=r.parentFontSize||r.fontSize;return i||null}return null}const Mi={length:["px","rem","em"],time:["ms","s"],angle:["deg","turn","rad"]};function kn(e,t,n){const r=ve(e,t),i=Mi[r.kind];if(!i||r.number==null)return[];const l=n||{};return i.map(s=>{if(s===r.unit)return{unit:s,value:r.raw,current:!0,ok:!0,lossless:!0};if(r.kind==="length"){const a=dn(r.number,r.unit,l);if(a==null)return{unit:s,ok:!1,value:"",reason:"needs a base font size the inspector has not read"};if(s==="px")return{unit:s,ok:!0,value:L(a)+"px",lossless:!0};const c=s==="rem"?l.rootFontSize:l.parentFontSize||l.fontSize;return c?{unit:s,ok:!0,value:L(a/c)+s,lossless:!0,note:"of "+L(c)+"px"}:{unit:s,ok:!1,value:"",reason:"needs the "+s+" base font size"}}if(r.kind==="time")return s==="s"?{unit:s,ok:!0,value:L(r.number/1e3)+"s",lossless:!0}:{unit:s,ok:!0,value:L(r.number*1e3)+"ms",lossless:!0};if(r.kind==="angle"){const a=r.unit==="turn"?r.number*360:r.unit==="rad"?r.number*(180/Math.PI):r.number;return s==="deg"?{unit:s,ok:!0,value:L(a)+"deg",lossless:!0}:s==="turn"?{unit:s,ok:!0,value:L(a/360)+"turn",lossless:!0}:{unit:s,ok:!0,value:L(a*(Math.PI/180))+"rad",lossless:!0}}return{unit:s,ok:!1,value:"",reason:"unsupported unit change"}})}function Ai(e,t,n,r){const i=String(e||"").trim().toLowerCase(),l=ve(i,t),s=String(n||"");if(!s)return{ok:!1,reason:"no target type"};if(l.kind===s)return{ok:!0,value:l.raw,lossless:!0,same:!0,toKind:s};if(s==="keyword")return{ok:!0,value:Lt[i]?Lt[i][0]:"inherit",lossless:!1,toKind:"keyword",discarded:l.raw,note:"discards "+l.raw+" — the old value stays undoable"};if(s==="length"&&(l.kind==="number"||l.kind==="percent")){if(l.kind==="number")return l.number===0?{ok:!0,value:"0px",lossless:!0,toKind:"length",note:"0 needs no unit"}:{ok:!0,value:l.raw+"px",lossless:!1,toKind:"length",discarded:l.raw,note:l.raw+" becomes "+l.raw+"px — the same digits, a different meaning; still undoable"};const a=Vn(i,r);if(a==null)return{ok:!1,reason:"a percentage of "+i+" needs a base size the inspector does not read"};const c=l.number/100*a;return{ok:!0,value:L(c)+"px",lossless:!0,toKind:"length",note:"of "+L(a)+"px"}}if(s==="percent"&&(l.kind==="length"||l.kind==="number")){if(l.kind==="number")return un.has(i)?{ok:!0,value:L(l.number*100)+"%",lossless:!0,toKind:"percent",note:"the same value for "+i}:{ok:!1,reason:"a bare number and a percentage mean different things for "+i};const a=Vn(i,r);if(a==null)return{ok:!1,reason:"a percentage of "+i+" needs a base size the inspector does not read"};const c=dn(l.number,l.unit,r);return c==null?{ok:!1,reason:"cannot resolve "+l.raw+" to pixels (no base font size)"}:{ok:!0,value:L(c/a*100)+"%",lossless:!0,toKind:"percent",note:"of "+L(a)+"px"}}if(s==="number"&&l.kind==="percent")return un.has(i)?{ok:!0,value:L(l.number/100),lossless:!0,toKind:"number",note:"the same value for "+i}:{ok:!1,reason:"a percentage and a bare number mean different things for "+i};if(s==="number"&&l.kind==="length")return l.number===0?{ok:!0,value:"0",lossless:!0,toKind:"number",note:"0 needs no unit"}:{ok:!0,value:L(l.number),lossless:!1,toKind:"number",discarded:l.raw,note:l.raw+" becomes "+L(l.number)+" — the unit is dropped; still undoable"};if(s==="length"&&l.kind==="length"){const a=dn(l.number,l.unit,r);if(a==null)return{ok:!1,reason:"cannot resolve "+l.raw+" without a base font size"};const c=r||{};return c.rootFontSize?{ok:!0,value:L(a/c.rootFontSize)+"rem",lossless:!0,toKind:"length",note:"of "+L(c.rootFontSize)+"px root"}:{ok:!0,value:L(a)+"px",lossless:!0,toKind:"length"}}if(s==="time"){if(l.kind!=="time"&&l.kind!=="number")return{ok:!1,reason:"not a time value"};const a=l.unit==="s"?l.number*1e3:l.number;return{ok:!0,value:l.unit==="s"?L(a/1e3)+"s":L(a)+"ms",lossless:!0,toKind:"time"}}if(s==="angle"){if(l.kind!=="angle"&&l.kind!=="number")return{ok:!1,reason:"not an angle value"};const a=l.unit==="turn"?l.number*360:l.unit==="rad"?l.number*(180/Math.PI):l.unit==="grad"?l.number*.9:l.number;return{ok:!0,value:L(a)+"deg",lossless:!0,toKind:"angle"}}return s==="color"?l.kind!=="color"?{ok:!1,reason:"not a colour value"}:{ok:!0,value:l.raw,lossless:!0,toKind:"color"}:s==="custom"?l.kind==="custom"?{ok:!0,value:l.raw,lossless:!0,same:!0,toKind:"custom"}:{ok:!1,reason:"a custom property form needs a variable to point at"}:{ok:!1,reason:"no conversion from "+l.kind+" to "+s}}function Ii(e,t,n){const r=String(e||"").trim(),i=ve(r,t);return(r.startsWith("--")?jn(r,t):jn(r)).map(s=>{if(s===i.kind)return{kind:s,label:Dn[s]||s,value:i.raw,isCurrent:!0,ok:!0,lossless:!0};const a=Ai(r,t,s,n);return{kind:s,label:Dn[s]||s,isCurrent:!1,ok:a.ok,value:a.ok?a.value:"",lossless:!!(a.ok&&a.lossless),discarded:a.discarded||"",note:a.note||"",reason:a.ok?"":a.reason}})}function Sn(e){const t=String(e||"").trim().toLowerCase(),r=(Lt[t]||[]).slice();for(const i of ki)r.includes(i)||r.push(i);return r}const Fr=12,Li=8;function dt(e){return String(e??"").trim().replace(/\s+/g," ").toLowerCase()}function Fi(e){const t=/^([-+]?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i.exec(String(e??"").trim());if(!t)return null;const n=Number(t[1]);if(!Number.isFinite(n))return null;const r=(t[2]||"").toLowerCase(),i=(t[1].split(".")[1]||"").length;return{n,unit:r,decimals:i}}function zi(e,t){let n=Math.abs(e),r=Math.abs(t);for(;r;){const i=n%r;n=r,r=i}return n}function Oi(e){const t=new Map;for(const a of e||[]){const c=Fi(a&&a.value);if(!c||!Number.isFinite(c.n))continue;t.has(c.unit)||t.set(c.unit,{numbers:new Set,decimals:0,count:0});const u=t.get(c.unit);u.numbers.add(c.n),u.decimals=Math.max(u.decimals,c.decimals),u.count+=a.count||1}if(!t.size)return null;let n=null;for(const[a,c]of t){const u=c.count+c.numbers.size/100;(!n||u>n.score)&&(n={unit:a,bucket:c,score:u})}const r=Array.from(n.bucket.numbers).sort((a,c)=>a-c);if(r.length<2)return{unit:n.unit,values:r,step:null,decimals:n.bucket.decimals};const i=Math.pow(10,n.bucket.decimals),l=r.map(a=>Math.round(a*i));let s=l[0];for(let a=1;a<l.length;a++)s=zi(s,l[a]);return{unit:n.unit,values:r,step:s>0?s/i:null,decimals:n.bucket.decimals}}function Di(e,t,n){const r=dt(t);if(!r)return;e.uses++;let i=e.values.find(l=>l.key===r);i||(i={key:r,value:String(t).trim().replace(/\s+/g," "),count:0,selector:"",origin:"regular",inherited:""},e.values.push(i)),i.count++,!i.selector&&n&&(i.selector=n.selector||"",i.origin=n.origin||"regular",i.inherited=n.inherited||"")}function Bi(e){const t=e||{},n={},r=[];for(const i of t.rules||[])if(i)for(const l of i.props||[]){const s=String(l&&l.name||"").trim().toLowerCase();if(s){if(s.startsWith("--")){const a=r.find(c=>c.name===s);a?a.count++:r.push({name:s,value:String(l.value||"").trim(),selector:i.selector||"",count:1});continue}n[s]||(n[s]={values:[],uses:0,computed:""}),Di(n[s],l.value,i)}}for(const i of t.computed||[]){const l=String(i&&i.prop||"").trim().toLowerCase();if(l){if(l.startsWith("--")){const s=r.find(a=>a.name===l);s?s.resolved=String(i.value||"").trim():r.push({name:l,value:String(i.value||"").trim(),selector:"computed",count:0,resolved:String(i.value||"").trim()});continue}n[l]||(n[l]={values:[],uses:0,computed:""}),n[l].computed=String(i.value||"").trim()}}return{props:n,tokens:r}}function kt(e,t,n){const r=String(t||"").trim().toLowerCase(),i=e&&e.props&&e.props[r];if(!i)return[];const l=dt(i.computed),s=i.values.map(c=>({value:c.value,count:c.count,selector:c.selector,origin:c.origin,inherited:c.inherited,isCurrent:l!==""&&c.key===l}));s.sort((c,u)=>u.count-c.count||(c.value<u.value?-1:c.value>u.value?1:0));const a=n||Fr;return s.slice(0,a)}const ji={space:["space","spacing","gap","pad","padding","margin","inset","gutter"],radius:["radius","corner","rounded","round"],color:["color","colour","brand","bg","background","fg","foreground","accent","surface"],font:["font","type","text","leading","weight"],motion:["duration","delay","ease","easing","transition","animation","motion","speed"]},Hi={padding:"space",margin:"space",gap:"space","row-gap":"space","column-gap":"space",inset:"space",top:"space",right:"space",bottom:"space",left:"space",width:"space",height:"space","min-width":"space","min-height":"space","max-width":"space","max-height":"space","border-radius":"radius",color:"color","background-color":"color","border-color":"color","font-size":"font","line-height":"font","font-family":"font","letter-spacing":"font","font-weight":"font","transition-duration":"motion","transition-delay":"motion","transition-timing-function":"motion","animation-duration":"motion","animation-delay":"motion"};function Vi(e){const t=String(e||"").toLowerCase().replace(/^--/,"").split(/[-_]/).filter(Boolean);for(const[n,r]of Object.entries(ji))if(t.some(i=>r.includes(i)))return n;return""}function Ui(e,t){const n=Hi[String(e||"").trim().toLowerCase()],r=Vi(t);return!n||!r?!0:r===n}function zr(e,t,n){const r=String(t||"").trim().toLowerCase();if(!r)return[];const i=e&&e.props&&e.props[r],l=i&&i.values.length?ve(r,i.values[0].value).kind:i&&i.computed?ve(r,i.computed).kind:null;if(!l)return[];const s=[];for(const a of e&&e.tokens||[]){const c=a.resolved||a.value;c&&(/^var\(/i.test(c)||Ui(r,a.name)&&ve(r,c).kind===l&&s.push({name:a.name,value:c,declared:a.value,selector:a.selector,count:a.count||0}))}return s.sort((a,c)=>c.count-a.count||(a.name<c.name?-1:a.name>c.name?1:0)),s.slice(0,n||Li)}function Ft(e,t){const n=kt(e,t,Fr);return n.length<2?null:Oi(n)}function Or(e){if(!e||!e.values||e.values.length<2)return"";const t=e.unit||"",n=e.step?String(e.step)+t:"no common step";return e.values.length+" values on this page · steps of "+n}function Wi(e,t){const n=String(t||"").trim().toLowerCase(),r=e&&e.props&&e.props[n];return!r||!r.values?{values:0,uses:0}:{values:r.values.length,uses:r.uses||0}}function qi(e,t){const n=String(t||"").trim().toLowerCase(),r=[];for(const i of e||[]){if(!i||i.prop!==n||!i.value)continue;const l=dt(i.value);let s=r.find(a=>a.key===l);s||(s={key:l,value:String(i.value).trim(),count:0,labels:[]},r.push(s)),s.count++,i.label&&!s.labels.includes(i.label)&&s.labels.push(i.label)}return r.sort((i,l)=>l.count-i.count||(i.value<l.value?-1:i.value>l.value?1:0)),r.map(i=>({value:i.value,count:i.count,labels:i.labels}))}const Zi=.5;function Ki(e){const t=e&&Number.isFinite(e.decimals)?e.decimals:0;return Math.min(Math.max(t,0),4)}function xn(e,t){if(!Number.isFinite(e))return e;const n=Math.pow(10,t||0);return Math.round(e*n)/n}function Bt(e){return!!(e&&Number.isFinite(e.step)&&e.step>=Zi&&Array.isArray(e.values)&&e.values.length>1)}function Dr(e){const t=[];for(const n of e&&e.values||[]){const r=typeof n=="number"?n:Number(n);Number.isFinite(r)&&t.push(r)}return t.sort((n,r)=>n-r),t}function Gi(e,t){const n=ve("x",e);if(!n||n.number==null)return null;const r=t||"",i=n.unit||r;return r&&i!==r?null:{n:n.number,unit:i,raw:n.raw,kind:n.kind}}function $i(e,t){if(!Bt(t))return null;const n=Gi(e,t.unit);if(!n)return null;const r=Dr(t);let i=null;for(const l of r){const s=Math.abs(n.n-l),a=l-n.n;(!i||s<i.distance||s===i.distance&&a<0&&i.signed>0)&&(i={number:l,distance:xn(s,4),signed:a})}return i?{number:i.number,value:L(i.number)+(t.unit||""),distance:i.distance,distanceText:L(i.distance)+(t.unit||"")}:null}function Un(e,t){return Bt(e)?e.step:null}function Xi(e,t,n){const r=ve("x",e);if(!r||r.number==null)return null;const i=Number.isFinite(n)&&n>0?n:1,l=r.number+(t<0?-i:i);if(!Number.isFinite(l))return null;const s=l<0?0:l;return L(xn(s,4))+(r.unit||"")}function Br(e,t,n,r){const i={},l=String(t??"").trim(),s={value:l,from:l,to:l,snapped:!1,onScale:!1,offScale:!1,nearest:null,distance:0,unit:n&&n.unit||"",step:null,reason:""};if(!l)return s.reason="nothing to snap",s;const a=ve(e,l);if(!a||a.number==null)return s.reason="not a number",s;if(!Bt(n))return s.reason="this page has no numeric scale for "+String(e||"this property"),s;const c=n.unit||"",u=a.unit||c;if(c&&u!==c)return s.reason="the page's scale is in "+c+", this value is in "+(a.unit||"a bare number"),s;s.step=n.step,s.unit=c;const d=Ki(n),y=a.number;if(Dr(n).some(j=>j===xn(y,d)))return s.onScale=!0,s.snapped=!1,s.nearest={number:y,value:L(y)+c,distance:0,distanceText:"0"+c},s;const R=$i(l,n);return s.offScale=!0,s.nearest=R,s.distance=R?R.distance:0,i.snapTo&&R?(s.snapped=!0,s.value=R.value,s.to=R.value,s.reason="snapped to the nearest page value",s):(s.reason=R?"off the page scale: "+R.value+" is "+R.distanceText+" away":"off the page scale",s)}function Ji(e){const t=e||{};return t.snapped?"snapped · "+L(t.step)+" "+(t.unit||"")+" step":t.onScale?"on scale · "+L(t.step)+" "+(t.unit||"")+" step":t.offScale&&t.nearest?"nearest "+t.nearest.value+" · "+t.nearest.distanceText+" away":t.reason||""}const jr=/^--/,Yi=/^-[a-z]+-[a-z][a-z0-9]*(-[a-z0-9]+)*$|^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Qi(e){const t=String(e??"").trim();return t?jr.test(t)?t:t.toLowerCase():""}function Wn(e,t,n){const r=Qi(e),i=String(t??"").trim();if(!r)return{ok:!1,prop:"",value:i,error:"Enter a CSS property name."};if(jr.test(r))return i?{ok:!0,prop:r,value:i}:{ok:!1,prop:r,value:"",error:"A custom property needs a value — use Remove to drop it."};if(!Yi.test(r))return{ok:!1,prop:r,value:i,error:"“"+r+"” is not a CSS property name. Names are lowercase and hyphenated, like background-color."};if(!i)return{ok:!1,prop:r,value:"",error:"Enter a value — use Remove to drop the property."};if(typeof n=="function"){let l;try{l=n(r,i)}catch{l=!1}if(!l)return{ok:!1,prop:r,value:i,error:"“"+i+"” is not a valid value for "+r+"."}}return{ok:!0,prop:r,value:i}}function Cn(e){return!e||typeof document>"u"||!document.body?e:bn(e,document.body)}function pn(e){if(!e.open)return null;const t=e.title||"Confirm",n=e.message||"",r=e.confirmLabel||"Confirm",i=e.cancelLabel||"Cancel",l=!!e.busy;return Cn(o("div",{class:"inspector__overlay",onClick:l?void 0:e.onCancel,role:"presentation"},o("div",{class:"inspector__sheet inspector__sheet--confirm",role:"alertdialog","aria-modal":"true","aria-label":t,onClick:s=>s.stopPropagation()},o("div",{class:"inspector__sheet-head"},o("strong",{class:"inspector__sheet-title"},t)),o("div",{class:"inspector__sheet-body inspector__sheet-body--confirm"},o("p",{class:"inspector__confirm-msg"},n),o("div",{class:"inspector__confirm-actions"},o("button",{class:"btn inspector__confirm-cancel",type:"button",disabled:l,onClick:e.onCancel},i),o("button",{class:"btn inspector__confirm-go",type:"button","data-danger":"1",disabled:l,onClick:e.onConfirm},l?"Working…":r))))))}const qn={black:"#000000",white:"#ffffff",silver:"#c0c0c0",gray:"#808080",grey:"#808080",maroon:"#800000",red:"#ff0000",purple:"#800080",fuchsia:"#ff00ff",magenta:"#ff00ff",green:"#008000",lime:"#00ff00",olive:"#808000",yellow:"#ffff00",navy:"#000080",blue:"#0000ff",teal:"#008080",aqua:"#00ffff",cyan:"#00ffff",orange:"#ffa500",pink:"#ffc0cb",brown:"#a52a2a",gold:"#ffd700",violet:"#ee82ee",indigo:"#4b0082",crimson:"#dc143c",salmon:"#fa8072",tomato:"#ff6347",khaki:"#f0e68c",slategray:"#708090",slategrey:"#708090",dimgray:"#696969",dimgrey:"#696969",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",whitesmoke:"#f5f5f5",gainsboro:"#dcdcdc",lavender:"#e6e6fa",beige:"#f5f5dc",ivory:"#fffff0",snow:"#fffafa",mintcream:"#f5fffa",azure:"#f0ffff",midnightblue:"#191970",steelblue:"#4682b4",royalblue:"#4169e1",dodgerblue:"#1e90ff",skyblue:"#87ceeb",lightblue:"#add8e6",deepskyblue:"#00bfff",cornflowerblue:"#6495ed",darkblue:"#00008b",darkgreen:"#006400",forestgreen:"#228b22",seagreen:"#2e8b57",mediumseagreen:"#3cb371",springgreen:"#00ff7f",yellowgreen:"#9acd32",darkred:"#8b0000",firebrick:"#b22222",indianred:"#cd5c5c",rosybrown:"#bc8f8f",darkorange:"#ff8c00",coral:"#ff7f50",sandybrown:"#f4a460",peru:"#cd853f",chocolate:"#d2691e",saddlebrown:"#8b4513",sienna:"#a0522d",darkmagenta:"#8b008b",darkviolet:"#9400d3",blueviolet:"#8a2be2",mediumpurple:"#9370db",plum:"#dda0dd",orchid:"#da70d6",hotpink:"#ff69b4",deeppink:"#ff1493",lightpink:"#ffb6c1",lightyellow:"#ffffe0",lemonchiffon:"#fffacd",wheat:"#f5deb3",lightsteelblue:"#b0c4de",powderblue:"#b0e0e6",paleturquoise:"#afeeee",darkcyan:"#008b8b",lightseagreen:"#20b2aa",cadetblue:"#5f9ea0",darkolivegreen:"#556b2f",olivedrab:"#6b8e23",darkslateblue:"#483d8b",slateblue:"#6a5acd",mediumslateblue:"#7b68ee",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",lightslategray:"#778899",lightslategrey:"#778899"};function Ge(e){return Number.isFinite(e)?Math.max(0,Math.min(255,Math.round(e))):0}function nn(e){const t=String(e??"").trim();if(!t)return null;if(/%$/.test(t)){const r=parseFloat(t);return Number.isFinite(r)?r/100*255:null}const n=parseFloat(t);return Number.isFinite(n)?n:null}function Zn(e){if(e==null||e==="")return 1;const t=String(e).trim();if(/%$/.test(t)){const r=parseFloat(t);return Number.isFinite(r)?Math.max(0,Math.min(1,r/100)):1}const n=parseFloat(t);return Number.isFinite(n)?Math.max(0,Math.min(1,n)):1}function jt(e,t,n){const r=(e%360+360)%360,i=Math.max(0,Math.min(1,t)),l=Math.max(0,Math.min(1,n)),s=(1-Math.abs(2*l-1))*i,a=s*(1-Math.abs(r/60%2-1)),c=l-s/2,u=Math.floor(r/60)%6,d=[[s,a,0],[a,s,0],[0,s,a],[0,a,s],[a,0,s],[s,0,a]][u]||[0,0,0];return{r:Ge((d[0]+c)*255),g:Ge((d[1]+c)*255),b:Ge((d[2]+c)*255),a:1}}function es(e){const t=e||{r:0,g:0,b:0},n=Ge(t.r)/255,r=Ge(t.g)/255,i=Ge(t.b)/255,l=Math.max(n,r,i),s=Math.min(n,r,i),a=(l+s)/2,c=l-s;if(!c)return{h:0,s:0,l:a,a:t.a==null?1:t.a};const u=a>.5?c/(2-l-s):c/(l+s);let d;return l===n?d=(r-i)/c%6:l===r?d=(i-n)/c+2:d=(n-r)/c+4,d*=60,d<0&&(d+=360),{h:d,s:u,l:a,a:t.a==null?1:t.a}}function St(e,t){const n=t||{},r=String(e??"").trim().toLowerCase();if(!r)return null;if(r==="currentcolor")return n.color?St(n.color,n):null;if(r==="transparent")return{r:0,g:0,b:0,a:0};const i=/^#([0-9a-f]{3,8})$/.exec(r);if(i){const s=i[1],a=c=>parseInt(c.length===1?c+c:c,16);return s.length===3||s.length===4?{r:a(s[0]),g:a(s[1]),b:a(s[2]),a:s.length===4?a(s[3])/255:1}:s.length===6||s.length===8?{r:a(s.slice(0,2)),g:a(s.slice(2,4)),b:a(s.slice(4,6)),a:s.length===8?a(s.slice(6,8))/255:1}:null}const l=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(r);if(l){const a=l[2].replace(/\//g," ").replace(/,/g," ").trim().split(/\s+/).filter(_=>_!=="");if(a.length<3)return null;if(l[1].startsWith("rgb")){const _=nn(a[0]),R=nn(a[1]),j=nn(a[2]);return _==null||R==null||j==null?null:{r:Ge(_),g:Ge(R),b:Ge(j),a:Zn(a[3])}}const c=parseFloat(a[0]),u=parseFloat(a[1]),d=parseFloat(a[2]);if(!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d))return null;const y=jt(c,/%$/.test(a[1])?u/100:u,/%$/.test(a[2])?d/100:d);return y.a=Zn(a[3]),y}return r in qn?St(qn[r],n):null}function rn(e){const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Kn(e){const t=e||{r:0,g:0,b:0};return .2126*rn(Ge(t.r))+.7152*rn(Ge(t.g))+.0722*rn(Ge(t.b))}function Gn(e,t){const n=e&&e.a!=null?e.a:1,r=t||{r:0,g:0,b:0};if(n>=1)return{r:e.r,g:e.g,b:e.b,a:1};const i=(l,s)=>Ge(l*n+(s||0)*(1-n));return{r:i(e.r,r.r),g:i(e.g,r.g),b:i(e.b,r.b),a:1}}function ts(e,t){const n=Kn(e),r=Kn(t),i=Math.max(n,r),l=Math.min(n,r);return(i+.05)/(l+.05)}const Mt=4.5,$n=7;function Xn(e){const t=Number(e);return!Number.isFinite(t)||t<=0?{level:"fail",min:Mt}:t>=$n?{level:"AAA",min:$n}:t>=Mt?{level:"AA",min:Mt}:{level:"fail",min:Mt}}function ns(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return{ratio:0,level:"fail",text:"no ratio",ok:!1};const n=Xn(t).level,r=Math.round(t*10)/10,i=Xn(r).level===n?r:Math.round(t*100)/100;return{ratio:i,level:n,text:n+" "+L(i)+":1",ok:n!=="fail"}}function zt(e,t,n){const r=n||{},i=St(e??r.bg,r),l=St(t??r.color,r);if(!i||!l)return{ok:!1,ratio:null,reason:"a colour could not be read"};if(i.a===0)return{ok:!1,ratio:null,reason:"the background is transparent"};const s=Gn(i,{r:255,g:255,b:255}),a=Gn(l,s),c=ts(s,a),u=ns(c);return{ok:!0,ratio:u.ratio,level:u.level,text:u.text,okLevel:u.ok,fg:a,bg:s,source:{background:String(e||"").trim(),foreground:String(t||"").trim()}}}function rs(e,t,n){return(t||[]).map(r=>{const i=r&&typeof r=="object"?r:{value:r},l=zt(e,i.value,n);return Object.assign({},i,{ratio:l.ratio,text:l.text||"",level:l.level||"",readable:!!l.okLevel,reason:l.reason||""})})}function os(e,t){if(!St(e,t))return[];const r=zt(e,"#ffffff",t),i=zt(e,"#000000",t),l=(r.ratio||0)>=(i.ratio||0)?{value:"#ffffff",label:"white text",result:r}:{value:"#000000",label:"black text",result:i};return[{value:l.value,label:l.label,ratio:l.result.ratio,text:l.result.text,level:l.result.level,readable:!!l.result.okLevel,reason:""}]}const is=6,ss=4,ls=5,as=3,cs=6;function us(e,t){if(!t.length)return!1;const n=t[0]&&t[0].value?t[0].value:"";return/^#|^(rgb|hsl)a?\(/i.test(n)||/^(color|background-color|border-color|outline-color|fill|stroke|caret-color|text-decoration-color|column-rule-color)$/.test(e)}function Jn(e){return{background:String(e||"")}}function Yn(e){return"inspector__suggest-aa"+(e?"":" is-bad")}function ds(e){const t=e.result;if(!t||!t.value)return null;const n=Ji(t);return n?t.snapped?o("p",{class:"inspector__suggest-snap is-on",role:"status"},n):t.onScale?o("p",{class:"inspector__suggest-snap is-on",role:"status"},n):t.offScale&&t.nearest?o("p",{class:"inspector__suggest-snap is-off",role:"status"},o("span",{class:"inspector__suggest-snap-ghost","aria-hidden":"true"},t.value),o("span",null,n),o("button",{class:"inspector__suggest-snap-btn",type:"button",title:"Rewrite the value as "+t.nearest.value+" — still one property, one undo","aria-label":"Snap "+t.value+" to "+t.nearest.value,onClick:()=>e.onSnap(t.nearest.value)},"Snap to "+t.nearest.value)):o("p",{class:"inspector__suggest-snap is-none"},n):null}function ps(e){const t=e.index,n=e.prop||"",r=e.value||"";if(!t||!n)return null;const i=Bt(Ft(t,n))?Ft(t,n):null,l=kt(t,n,is),s=Wi(t,n),a=Math.max(s.values,l.length),c=a>l.length?" · "+a+" values seen":" · "+a+(a===1?" value":" values"),u=zr(t,n,ss),d=qi(e.siblings||[],n).filter(p=>dt(p.value)!==dt(r)).slice(0,as),y=e.shape==="text"?Sn(n).filter(p=>dt(p)!==dt(r)).slice(0,cs):[],_=i?Br(n,r,i):null,R=!e.ownColour&&us(n,l),j=e.contrastCtx||{},K=R?rs(j.bg||e.bg||"",l.map(p=>({value:p.value,count:p.count,selector:p.selector,isCurrent:p.isCurrent})),j).slice(0,ls):[],N=R&&K.length<3?os(j.bg||e.bg||"",j):[];return!l.length&&!u.length&&!_&&!d.length&&!y.length?null:o("div",{class:"inspector__suggest"},l.length?o("div",{class:"grp"},o("div",{class:"gh"},R?"This page's palette":"On this page",o("span",null,c+(i&&i.step?" · steps of "+i.step+(i.unit||""):"")+(R?" · contrast vs this element":""))),o("div",{class:"opts"},R?K.map(p=>o("button",{class:"opt inspector__suggest-colour"+(p.isCurrent?" is-current":"")+(p.readable?"":" is-unreadable"),type:"button",key:"v-"+p.value,title:p.value+" — used "+p.count+(p.count===1?" time":" times")+(p.selector?" ("+p.selector+")":"")+(p.text?" · "+p.text+" contrast":p.reason?" · "+p.reason:"")+(p.isCurrent?" · the value in force":""),"aria-label":"Use "+p.value+", used "+p.count+(p.count===1?" time":" times")+(p.text?", contrast "+p.text:""),onClick:()=>e.onPick(p.value)},o("span",{class:"inspector__suggest-sw",style:Jn(p.value),"aria-hidden":"true"}),o("span",{class:"inspector__suggest-value"},p.value),p.text?o("span",{class:Yn(p.readable)},p.text):o("span",{class:"inspector__suggest-ev"},p.count+"×"))):l.map(p=>o("button",{class:"opt"+(p.isCurrent?" is-current":""),type:"button",key:"v-"+p.value,title:p.value+" — used "+p.count+(p.count===1?" time":" times")+(p.selector?" ("+p.selector+")":"")+(p.inherited?", inherited from "+p.inherited:"")+(p.isCurrent?" · the value in force":""),"aria-label":"Use "+p.value+", used "+p.count+(p.count===1?" time":" times")+" on this page",onClick:()=>e.onPick(p.value)},o("span",{class:"inspector__suggest-value"},p.value),o("span",{class:"inspector__suggest-ev"},p.count+"×"))))):null,N.length?o("div",{class:"grp"},o("div",{class:"gh"},"Readable on this element",o("span",null," · the default pair")),o("div",{class:"opts"},N.map(p=>o("button",{class:"opt inspector__suggest-colour"+(p.readable?"":" is-unreadable"),type:"button",key:"d-"+p.value,title:p.label+" — "+p.text+" contrast on "+(j.bg||"this element"),"aria-label":"Use "+p.label+", contrast "+p.text,onClick:()=>e.onPick(p.value)},o("span",{class:"inspector__suggest-sw",style:Jn(p.value),"aria-hidden":"true"}),o("span",{class:"inspector__suggest-value"},p.label),o("span",{class:Yn(p.readable)},p.text))))):null,d.length?o("div",{class:"grp"},o("div",{class:"gh"},"Match a sibling",o("span",null," · what the peers use")),o("div",{class:"opts"},d.map(p=>o("button",{class:"opt inspector__suggest-sibling",type:"button",key:"s-"+p.value,title:p.value+" — "+(p.labels[0]||"a sibling element")+" uses "+p.value+(p.count>1?" ("+p.count+" peers)":""),"aria-label":"Use "+p.value+", what "+(p.labels[0]||"a sibling element")+" uses",onClick:()=>e.onPick(p.value)},o("span",{class:"inspector__suggest-value"},p.value),o("span",{class:"inspector__suggest-ev"},p.labels[0]||""))))):null,u.length?o("div",{class:"grp"},o("div",{class:"gh"},"Tokens",o("span",null," · from this page")),o("div",{class:"opts"},u.map(p=>o("button",{class:"opt inspector__suggest-token",type:"button",key:"t-"+p.name,title:p.name+" = "+p.value+(p.selector?" ("+p.selector+")":""),"aria-label":"Use "+p.name+", which resolves to "+p.value,onClick:()=>e.onPick(p.name)},o("span",{class:"inspector__suggest-value"},p.name),o("span",{class:"inspector__suggest-ev"},"= "+p.value))))):null,y.length?o("div",{class:"grp"},o("div",{class:"gh"},"Keywords",o("span",null," · valid for any property")),o("div",{class:"opts"},y.map(p=>o("button",{class:"opt inspector__suggest-word",type:"button",key:"w-"+p,title:p+" — the "+(/^(inherit|initial|unset|revert)$/.test(p)?"CSS-wide":"property's own")+" keyword","aria-label":"Use "+p,onClick:()=>e.onPick(p)},o("span",{class:"inspector__suggest-value"},p))))):null,o(ds,{result:_,onSnap:e.onPick}),i&&i.values.length>1?o("p",{class:"inspector__suggest-note"},Or(i)):null)}const fs=100,Qn=40,er=5,hs=64,on={opacity:{min:0,max:1},"line-height":{min:0,max:3},"z-index":{min:-10,max:100},angle:{min:-180,max:180},hue:{min:0,max:360},scale:{min:0,max:3},percent:{min:0,max:200},time:{min:0,max:2e3}};function ms(e,t){const n=String(e||"").trim().toLowerCase(),r=ve(n,t);return n==="opacity"||n==="fill-opacity"||n==="stroke-opacity"?"opacity":n==="line-height"?"line-height":n==="z-index"?"z-index":n==="hue-rotate"||n==="filter"&&/hue-rotate\(/i.test(String(t||""))?"hue":/^rotate/.test(n)||n.endsWith("-angle")||r.kind==="angle"?"angle":r.kind==="time"||/-duration$|-delay$/.test(n)?"time":r.kind==="percent"?"percent":n==="scale"||/^scale/.test(n)?"scale":r.kind==="length"?"length":r.kind==="number"?"number":"length"}function gs(e){const t=e||{};return Number.isFinite(t.size)&&t.size>0?t.size:Number.isFinite(t.fontSize)&&t.fontSize>0?t.fontSize:hs}function bs(e,t,n){const r=n||{},i=String(t||"px").toLowerCase();return i==="px"||i===""?e:i==="rem"&&r.rootFontSize?e/r.rootFontSize:i==="em"&&(r.parentFontSize||r.fontSize)?e/(r.parentFontSize||r.fontSize):i==="pt"?e*(72/96):i==="vh"&&r.viewportHeight?e/r.viewportHeight*100:i==="vw"&&r.viewportWidth?e/r.viewportWidth*100:e}function Ot(e,t,n){const r=n||{},i=ve(e,t),l=ms(e,t),s=i.unit||"";let a,c;if(l==="length"){const d=gs(r);a=0,c=bs(d*4,s,r)}else if(l==="number"){const d=on.scale;a=d.min,c=d.max,Number.isFinite(i.number)&&i.number>c&&(c=Math.ceil(i.number))}else{const d=on[l]||on.scale;a=d.min,c=d.max,l==="time"&&s==="s"&&(a=a/1e3,c=c/1e3),Number.isFinite(i.number)&&(i.number<a&&(a=i.number),i.number>c&&(c=i.number))}c>a||(c=a+1);const u=Number.isFinite(r.step)&&r.step>0?r.step:null;return{min:a,max:c,scale:a>0&&c/a>=fs?"log":"linear",unit:s,family:l,step:u}}function Hr(e){return!!(e&&e.scale==="log"&&e.min>0)}function fn(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}function lt(e,t){if(!t)return 0;const n=Number(e);if(!Number.isFinite(n))return 0;if(Hr(t)){const r=Math.max(n,t.min);return fn(Math.log(r/t.min)/Math.log(t.max/t.min))}return fn((n-t.min)/(t.max-t.min))}function Vr(e,t,n){if(!t)return 0;const r=fn(Number(e));let i;return Hr(t)?i=t.min*Math.pow(t.max/t.min,r):i=t.min+r*(t.max-t.min),pt(i,n,t)}function pt(e,t,n){const r=Number(e);if(!Number.isFinite(r))return n?n.min:0;const i=n?n.min:-1/0,l=n?n.max:1/0;let s=Math.max(i,Math.min(l,r));return Number.isFinite(t)&&t>0&&(s=i+Math.round((s-i)/t)*t,s=Math.max(i,Math.min(l,s))),Math.round(s*1e4)/1e4}const tr={length:[1,4,8],number:[1,5,10],opacity:[.01,.05,.1],"line-height":[.05,.1,.5],"z-index":[1,5,10],time:[10,50,100],angle:[1,15,45],hue:[1,15,30],scale:[.01,.05,.1],percent:[1,5,10]},nr={length:{fine:1,coarse:8,above:32},number:{fine:1,coarse:10,above:50},opacity:{fine:.05,coarse:.05},"line-height":{fine:.05,coarse:.05},"z-index":{fine:1,coarse:1},time:{fine:10,coarse:50,above:200},angle:{fine:1,coarse:15,above:90},hue:{fine:1,coarse:15,above:90},scale:{fine:.01,coarse:.05,above:1},percent:{fine:1,coarse:5,above:50}};function Ur(e){return tr[String(e||"")]||tr.length}function rr(e,t){const n=nr[String(t||"")]||nr.length,r=Math.abs(Number(e));return!Number.isFinite(r)||!Number.isFinite(n.above)||r<=n.above?n.fine:n.coarse}function or(e,t,n,r){const i=Number(e),l=r?r.min:-1/0,s=r?r.max:1/0,a=Number.isFinite(i)?i:r?r.min:0,c=Number.isFinite(n)&&n>0?n:1,u=a+(t<0?-c:c);return pt(Math.max(l,Math.min(s,u)),n,r)}function ys(e,t){if(!e)return[];let n=Number.isFinite(t)&&t>0?t:null;n||(n=(e.max-e.min)/10);const r=e.max-e.min;let i=Math.floor(r/n)+1;if(i>Qn){const s=Math.ceil(i/Qn);n*=s,i=Math.floor(r/n)+1}const l=[];for(let s=0;s<i;s++)l.push(Math.round((e.min+s*n)*1e4)/1e4);return l}function vs(e){if(!e)return[];const t=e.max-e.min;if(!(t>0))return[e.min];const n=[1,2,5,10,20,25,50,100,200,250,500,1e3];let r=n[n.length-1];for(const s of n)if(t/s<=er){r=s;break}const i=[],l=Math.ceil(e.min/r)*r;for(let s=l;s<=e.max+1e-9&&(i.push(Math.round(s*1e4)/1e4),!(i.length>er+1));s+=r);return i.length<=1?[e.min,e.max]:i}function ws(e,t){const n=t||{},r=ys(e,n.step),i=vs(e),l=[];for(const s of n.tokens||[]){const a=ve("x",s&&s.value);if(!a||a.number==null||a.unit&&e.unit&&a.unit!==e.unit)continue;const c=a.number;if(c<e.min||c>e.max)continue;const u=lt(c,e);l.some(d=>Math.abs(d.number-c)<1e-9)||l.push({name:String(s.name||""),value:L(c)+e.unit,number:c,ratio:u})}return{minor:r,major:i,tokens:l}}function _s(e){for(const t of e||[])if(t&&!t.current&&t.ok&&t.value)return String(t.value);return""}const ks=[{fraction:.25,label:"¼"},{fraction:.5,label:"½"},{fraction:1,label:"1"}];function Ss(e,t){const n=t||{};if(!e||e.family!=="length")return[];if(!(Number.isFinite(n.size)&&n.size>0))return[];const r=e.max/4,i=[];for(const l of ks){const s=Math.round(r*l.fraction*1e4)/1e4;s<e.min||s>e.max||i.push({label:l.label,fraction:l.fraction,number:s,ratio:lt(s,e)})}return i}const xs=[100,150,200,300];function Cs(e,t){if(!e||e.family!=="time")return[];const n=String(e.unit||"").toLowerCase()==="s",r=[];for(const i of xs){const l=Math.round((n?i/1e3:i)*1e4)/1e4;l<e.min||l>e.max||r.push({number:l,label:L(l)+(e.unit||"")})}return r}const Ps=.25,Rs=300,Ts=24,Ns=500;function Es(e,t){const n=t||{},r=Ur(n.family),i=Math.abs(Number(e)),l=Number.isFinite(i)&&i<Ps,s=Number.isFinite(n.step)&&n.step>0?n.step:r[0];return{step:l?r[0]:s,fine:l}}function Ms(e,t){if(!e||!t)return!1;const n=Math.abs(Number(t.at)-Number(e.at)),r=Math.abs(Number(t.x)-Number(e.x));return!Number.isFinite(n)||!Number.isFinite(r)?!1:n<=Rs&&r<=Ts}function As(e,t){if(e==null||e==="")return"";const n=Number(e);return Number.isFinite(n)?L(n)+(t&&t.unit||""):String(e)}function Is(e,t){const n=ve(e,t);return!n||n.number==null?{ok:!1,reason:"this value is not a number, so there is nothing to drag"}:n.kind==="keyword"||n.kind==="color"||n.kind==="custom"||n.kind==="expression"||n.kind==="unknown"?{ok:!1,reason:"a "+n.kind+" value has no numeric range"}:{ok:!0,reason:""}}const Ls=4;function st(e){return(Math.max(0,Math.min(1,e))*100).toFixed(2)+"%"}function At(e,t){const n=Math.max(0,Math.min(1,e));return n<=1e-4?{left:st(n)}:n>=.9999?{left:"calc(100% - "+t+"px)"}:{left:"calc("+st(n)+" - "+t/2+"px)"}}function Fs(e,t){return L(e)+(t||"")}function zs(e){const t=e.prop||"",n=e.value||"",r=e.ctx||{},[i,l]=T(null),[s,a]=T(!1),[c,u]=T(null),[d,y]=T(!1),_=A(null),R=A(null),j=A(null),K=A(null),N=Is(t,n),p=N.ok?Ot(t,n,Object.assign({step:r.step},r)):null,E=ve(t,n),q=Ur(p?p.family:""),Z=i??(p&&p.step?p.step:null),D=Z??rr(E.number,p?p.family:""),X=p?ws(p,{step:D,tokens:r.tokens||[]}):{minor:[],major:[],tokens:[]},B=p?Ss(p,r):[],ge=p?Cs(p):[],$=p?lt(E.number,p):0,ue=(()=>{if(!p||r.nearest==null||d)return null;const v=Number(r.nearest);return!Number.isFinite(v)||v<p.min||v>p.max?null:{number:v,ratio:lt(v,p)}})(),de=kn(t,n,r),ie=_s(de);function be(v,U){if(!p)return;const le=Number.isFinite(U)&&U>0?U:null,De=le?pt(v,le,p):pt(v,null,p),z=Fs(Number(De.toFixed(Ls)),p.unit);z!==n&&e.onChange(z)}function H(v){const U=_.current;if(!U)return 0;const le=U.getBoundingClientRect();return le.width>0?Math.max(0,Math.min(1,(v-le.left)/le.width)):0}function se(v,U){p&&be(Vr(H(v),p,U??D),U)}function Te(v){if(!p)return;if(v.currentTarget.setPointerCapture)try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}c&&u(null);const U=ye(v);R.current={id:v.pointerId,moved:!1,x:v.clientX,t:U,speed:null},v.preventDefault(),se(v.clientX,D)}function we(v){const U=R.current;if(!U||U.id!==v.pointerId)return;const le=ye(v),De=Math.max(1,le-U.t),z=Math.abs(v.clientX-U.x)/De;U.speed=U.speed==null?z:U.speed*.6+z*.4,U.x=v.clientX,U.t=le,U.moved=!0,v.preventDefault();const oe=Es(U.speed,{family:p.family,step:D});oe.fine!==s&&a(oe.fine),se(v.clientX,oe.step)}function ce(v){const U=R.current;if(U){if(R.current=null,s&&a(!1),v.currentTarget.releasePointerCapture)try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}if(!U.moved){const le={at:ye(v),x:v.clientX};Ms(K.current,le)?(K.current=null,e.onKeypad&&e.onKeypad()):K.current=le}}}function ye(v){return v&&Number.isFinite(v.timeStamp)&&v.timeStamp>0?v.timeStamp:typeof performance<"u"&&performance.now?performance.now():Date.now()}const Se=()=>{j.current&&(clearTimeout(j.current),j.current=null)};function ae(v,U){return{onPointerDown:()=>{Se(),j.current=setTimeout(()=>{j.current="fired",be(v),u({value:v,label:U})},Ns)},onPointerUp:Se,onPointerCancel:Se,onPointerLeave:Se}}function pe(v){if(!p)return;if(j.current==="fired"){j.current=null;return}c&&u(null);const U=Number(v);Number.isFinite(U)&&be(U)}if(!N.ok)return o("p",{class:"inspector__rail-note"},"No rail: "+N.reason+".");const xe=p?As(E.number,p):"";return o("div",{class:"inspector__rail"},o("div",{class:"inspector__rail-head"},o("span",{class:"inspector__rail-kind"},p.family),e.from!=null&&String(e.from)!==String(n)?o("span",{class:"inspector__rail-was"},String(e.from)):null,o("span",{class:"inspector__rail-now"},xe||n),o("span",{class:"inspector__rail-ev"},c?"locked · "+c.label:s?"fine "+L(rr(0,p.family))+(p.unit||""):D==null?"fine":i!=null?L(i)+(p.unit||"")+" step":p.step?"page step "+L(p.step)+(p.unit||""):"step "+L(D)+(p.unit||""))),o("div",{class:"inspector__rail-wrap",ref:_,role:"slider",tabIndex:0,"aria-label":"Value rail for "+t,"aria-valuemin":String(p.min),"aria-valuemax":String(p.max),"aria-valuenow":E.number!=null?String(E.number):"","aria-valuetext":xe,onPointerDown:Te,onPointerMove:we,onPointerUp:ce,onPointerCancel:ce,onKeyDown:v=>{(v.key==="ArrowRight"||v.key==="ArrowUp")&&(v.preventDefault(),be(or(E.number,1,D,p))),(v.key==="ArrowLeft"||v.key==="ArrowDown")&&(v.preventDefault(),be(or(E.number,-1,D,p)))}},o("div",{class:"inspector__rail-track"}),o("div",{class:"inspector__rail-fill",style:{width:st($)}}),X.minor.map(v=>o("span",{class:"inspector__rail-tick",key:"t"+v,style:At(lt(v,p),2)})),X.major.map(v=>o("button",Object.assign({class:"inspector__rail-major"+(c&&c.value===v?" is-locked":""),type:"button",key:"m"+v,style:At(lt(v,p),2),title:"Set "+t+" to "+L(v)+(p.unit||"")+" — hold to lock","aria-label":"Set to "+L(v)+(p.unit||""),onClick:()=>pe(v)},ae(v,L(v)+(p.unit||""))))),X.tokens.map(v=>o("button",Object.assign({class:"inspector__rail-token"+(c&&c.value===v.number?" is-locked":""),type:"button",key:"k"+v.name,style:At(v.ratio,3),title:v.name+" = "+v.value+" — hold to lock","aria-label":"Set to "+v.name+", which is "+v.value,onClick:()=>pe(v.number)},ae(v.number,v.name)))),ue?o("span",{class:"inspector__rail-ghost",style:{left:st(ue.ratio)},"aria-hidden":"true"}):null,B.map(v=>o("button",Object.assign({class:"inspector__rail-frac"+(c&&c.value===v.number?" is-locked":""),type:"button",key:"f"+v.fraction,style:At(v.ratio,2),title:v.label+" of this element = "+L(v.number)+(p.unit||"")+" — hold to lock","aria-label":"Set to "+v.label+" of this element, "+L(v.number)+(p.unit||""),onClick:()=>pe(v.number)},ae(v.number,v.label+" of this element")))),o("span",{class:"inspector__rail-thumb",style:{left:st($)},"aria-hidden":"true"},E.number!=null?L(E.number):"")),o("div",{class:"inspector__rail-labels"},X.major.map(v=>{const U=lt(v,p),le=U<=1e-4?"0":U>=.9999?"-100%":"-50%";return o("span",{key:"l"+v,style:{left:st(U),transform:"translateX("+le+")"}},L(v))}),X.tokens.map(v=>o("span",{class:"is-token",key:"n"+v.name,style:{left:st(v.ratio)}},v.name),B.map(v=>o("span",{class:"is-fraction",key:"fl"+v.fraction,style:{left:st(v.ratio)}},v.label)))),o("div",{class:"inspector__rail-foot"},o("div",{class:"inspector__rail-seg",role:"group","aria-label":"Snap step"},q.map(v=>o("button",{class:"inspector__rail-segbtn"+(D===v?" is-on":""),type:"button",key:"p"+v,"aria-pressed":String(D===v),title:"Snap to "+L(v)+(p.unit||"")+" steps",onClick:()=>{l(v),p&&be(pt(E.number,v,p))}},L(v)+" "+(p.unit||""))),p&&p.step?o("button",{class:"inspector__rail-segbtn"+(i==null?" is-on":""),type:"button",title:"Use the page's own "+p.step+(p.unit||"")+" step","aria-pressed":String(i==null),onClick:()=>{l(null)}},"page"):null),de.length>1?o("div",{class:"inspector__rail-units",role:"group","aria-label":"Unit"},de.map(v=>o("button",{class:"inspector__rail-unitchip"+(v.current?" is-on":""),type:"button",key:v.unit,disabled:!v.ok,"aria-pressed":String(!!v.current),title:v.current?v.unit+" — the unit in use":v.ok?"Rewrite as "+v.value:"Not available: "+v.reason,onClick:()=>{v.ok&&e.onChange(v.value)}},v.unit))):null,ie?o("span",{class:"inspector__rail-equiv"},"= "+ie):null,ge.length?o("div",{class:"inspector__rail-presets",role:"group","aria-label":"Common durations"},ge.map(v=>o("button",{class:"inspector__rail-presetchip"+(E.number===v.number?" is-on":""),type:"button",key:"d"+v.number,"aria-pressed":String(E.number===v.number),title:"Set "+t+" to "+v.label,onClick:()=>be(v.number)},v.label))):null,r.nearest!=null&&p.step?o("button",{class:"inspector__rail-leave"+(d?" is-on":""),type:"button","aria-pressed":String(d),title:d?"Snap the drag back to the page's "+L(p.step)+(p.unit||"")+" step":"Keep "+n+" — drag in "+L(q[0])+(p.unit||"")+" steps instead of the page's "+L(p.step)+(p.unit||""),onClick:()=>{if(d){y(!1),l(null);return}y(!0),l(q[0])}},d?"use scale":"leave scale"):null,r.scaleNote?o("span",{class:"inspector__rail-mini"},r.scaleNote):null))}const Wr={padding:["top","right","bottom","left"],margin:["top","right","bottom","left"],inset:["top","right","bottom","left"],"border-width":["top","right","bottom","left"],"border-radius":["top-left","top-right","bottom-right","bottom-left"],gap:["row","column"],"background-position":["x","y"]},Os={top:"top",right:"right",bottom:"bottom",left:"left",row:"row",column:"column",x:"x",y:"y","top-left":"↖","top-right":"↗","bottom-right":"↘","bottom-left":"↙"},Ds={padding:e=>"padding-"+e,margin:e=>"margin-"+e,inset:e=>e==="top"?"top":e==="right"?"right":e==="bottom"?"bottom":"left","border-width":e=>"border-"+e+"-width","border-radius":e=>"border-"+e+"-radius",gap:e=>e==="row"?"row-gap":"column-gap","background-position":e=>"background-position-"+e},Bs=new Set(["transform","filter","backdrop-filter","box-shadow","text-shadow","transition","animation"]),js=new Set(["background-image","mask-image","list-style-image","border-image-source"]);function qr(e,t,n){const r=String(e||"").trim().toLowerCase(),i=String(t??"").trim(),l=ve(r,t);if(r.startsWith("--"))return l.number!=null?"rail":l.kind==="color"?"colour":"text";if(l.kind==="expression"||l.kind==="custom")return"text";if(l.kind==="color")return"colour";if(l.kind==="time")return"time";if(l.kind==="angle")return"angle";if(js.has(r))return"image";if(Bs.has(r)&&l.kind!=="keyword"&&l.number==null){if(Gr(i))return"functions";const s=Zr(r,i);if(s&&s.some(a=>a.args.length>1))return"functions"}return Wr[r]&&(i.split(/\s+/).filter(Boolean).length>1&&Kr(r,i).ok||n==="fanout")?"fanout":l.number!=null?"rail":l.kind==="keyword"&&Vs(r).length>=2?"enum":(l.kind==="keyword","text")}const Hs=new Set(["box-shadow","text-shadow","transition","animation"]);function Vs(e){const t=["inherit","initial","unset","revert"];return Sn(e).filter(n=>!t.includes(n))}function Zr(e,t){const n=String(e||"").trim().toLowerCase();if(!Hs.has(n))return null;const r=Pn(String(t??"")).map(i=>i.trim()).filter(Boolean);return r.length?r.map((i,l)=>{const s=Us(i);return{index:l,raw:i,args:s}}):null}function Us(e){const t=String(e??"").trim(),n=[];let r=0,i=0;for(let l=0;l<t.length;l++){const s=t[l];s==="("?r++:s===")"?r--:/\s/.test(s)&&r===0&&(l>i&&n.push(t.slice(i,l)),i=l+1)}return i<t.length&&n.push(t.slice(i)),n.map(l=>({raw:l,value:l}))}function ir(e){return(e||[]).map(t=>(t.args||[]).map(n=>String(n.value==null?n.raw:n.value)).join(" ")).join(", ")}function xt(e){const t=String(e||"").trim().toLowerCase(),n=Wr[t];if(!n)return null;const r=Ds[t];return n.map(i=>({key:i,label:Os[i]||i,longhand:r?r(i):t+"-"+i}))}function Kr(e,t){const n=xt(e);if(!n)return{ok:!1,reason:"not a shorthand property"};const r=String(t??"").trim().split(/\s+/).filter(Boolean);if(!r.length)return{ok:!1,reason:"no value to split"};if(r.every(u=>!/^[-+]?[\d.]/.test(u)))return{ok:!1,reason:"a keyword has no sides"};const i=n.length===4?4:2;let l;i===4?r.length===1?l=[r[0],r[0],r[0],r[0]]:r.length===2?l=[r[0],r[1],r[0],r[1]]:r.length===3?l=[r[0],r[1],r[2],r[1]]:l=r.slice(0,4):r.length===1?l=[r[0],r[0]]:l=r.slice(0,2);const s={},a={};let c="";return n.forEach((u,d)=>{const y=l[d]==null?l[0]:l[d];s[u.key]=y;const _=ve(e,y);_&&_.number!=null&&(a[u.key]=_.number),!c&&_&&_.unit&&(c=_.unit)}),{ok:!0,unit:c,sides:s,numbers:a,uniform:Object.values(s).every(u=>u===Object.values(s)[0]),values:n.map(u=>s[u.key]),reason:""}}function Ws(e,t){const n=xt(e);if(!n||!t)return"";const r=n.map(i=>String(t[i.key]==null?"":t[i.key]).trim());return r.some(i=>!i)?"":n.length===2||r[1]===r[3]&&r[0]===r[2]?r[0]===r[1]?r[0]:r[0]+" "+r[1]:r[1]===r[3]?r[0]+" "+r[1]+" "+r[2]:r.join(" ")}function Gr(e){const t=String(e??"").trim();if(!t||/^(none|inherit|initial|unset|revert)$/i.test(t))return null;const n=[];let r=0;for(;r<t.length;){for(;r<t.length&&/[\s,]/.test(t[r]);)r++;if(r>=t.length)break;const i=/^[-a-z]+\(/i.exec(t.slice(r));if(!i)return null;const l=i[0].slice(0,-1),s=r+i[0].length-1,a=qs(t,s);if(a<0)return null;const c=t.slice(s+1,a);n.push({name:l,args:Pn(c).map(u=>({raw:u.trim(),value:u.trim()})),index:n.length}),r=a+1}return n.length?n:null}function qs(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]==="(")n++;else if(e[r]===")"&&(n--,n===0))return r;return-1}function Pn(e){const t=[];let n=0,r=0;for(let i=0;i<e.length;i++){const l=e[i];l==="("?n++:l===")"?n--:l===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t.filter(i=>i.trim()!=="")}function It(e){return!Array.isArray(e)||!e.length?"none":e.map(t=>String(t.name||"")+"("+(t.args||[]).map(n=>String(n.value==null?n.raw:n.value)).join(", ")+")").join(" ")}const Zs={transform:[{name:"translateX",args:["0px"]},{name:"translateY",args:["-4px"]},{name:"scale",args:["1.05"]},{name:"rotate",args:["45deg"]},{name:"skewX",args:["0deg"]},{name:"skewY",args:["0deg"]}],filter:[{name:"blur",args:["4px"]},{name:"brightness",args:["1.1"]},{name:"contrast",args:["1.1"]},{name:"saturate",args:["1.2"]},{name:"grayscale",args:["0.5"]},{name:"hue-rotate",args:["45deg"]},{name:"opacity",args:["0.5"]}]},Ks=6;function Gs(e,t){const n=String(e||"").trim().toLowerCase(),r=Zs[n];if(!r)return[];const i=new Set((t||[]).map(l=>String(l&&l.name||"").toLowerCase()));return r.filter(l=>!i.has(l.name.toLowerCase())).slice(0,Ks)}function $s(e,t){const n=Array.isArray(e)?e:[];return!t||!t.name?n:n.concat([{name:String(t.name),args:(t.args||[]).map(i=>({raw:String(i),value:String(i)})),index:n.length}]).map((i,l)=>Object.assign({},i,{index:l}))}function Xs(e,t,n){if(!Array.isArray(e))return[];const r=Number(t),i=r+(n<0?-1:1);if(!Number.isFinite(r)||r<0||r>=e.length||i<0||i>=e.length)return e;const l=e.slice(),s=l[r];return l[r]=l[i],l[i]=s,l.map((a,c)=>Object.assign({},a,{index:c}))}const sn="none";function Js(e){const t=/^color-mix\((.*)\)$/is.exec(String(e||"").trim());if(!t)return null;const n=Pn(t[1]);if(n.length!==3||!/^in\s+srgb$/i.test(n[0].trim()))return null;const r=/^\s*(.+?)\s+([\d.]+)%\s*$/.exec(n[1]);if(!r||!/^transparent$/i.test(n[2].trim()))return null;const i=$r(r[1]);if(!i||i.format==="unknown"||i.keyword)return null;const l=parseFloat(r[2]);return Number.isFinite(l)?Object.assign({},i,{a:Math.max(0,Math.min(1,(i.a==null?1:i.a)*(l/100))),format:"mix",raw:String(e).trim()}):null}function Ys(e,t){const n=String(e||"").trim().toLowerCase(),r=Sn(n),i=["inherit","initial","unset","revert"],l=[],s=(a,c)=>{const u=String(a||"").trim().toLowerCase();!u||l.some(d=>d.key===u)||l.push({key:u,value:String(a).trim(),source:c,wide:i.includes(u)})};for(const a of t||[]){const c=a&&a.value?a.value:a;s(c,"page")}for(const a of r)s(a,"spec");return l}function $r(e){const t=String(e??"").trim();if(!t)return null;if(/^color-mix\(/i.test(t))return Js(t)||{keyword:null,format:"unknown",raw:t};const n=t.toLowerCase();let r=null,i=1,l=null;if(n==="transparent")r={r:0,g:0,b:0},i=0;else{if(n==="currentcolor")return{keyword:"currentcolor",format:"keyword",raw:t};if(n in sr)r=sr[n];else{const a=/^#([0-9a-f]{3,8})$/i.exec(n);if(a){const c=a[1],u=d=>parseInt(d.length===1?d+d:d,16);c.length===3||c.length===4?(r={r:u(c[0]),g:u(c[1]),b:u(c[2])},c.length===4&&(i=u(c[3])/255)):(c.length===6||c.length===8)&&(r={r:u(c.slice(0,2)),g:u(c.slice(2,4)),b:u(c.slice(4,6))},c.length===8&&(i=u(c.slice(6,8))/255))}else{const c=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(n);if(c){const u=c[2].replace(/\//g," ").replace(/,/g," ").trim().split(/\s+/).filter(Boolean);if(c[1].startsWith("hsl")){const d=parseFloat(u[0]),y=parseFloat(u[1])/(/%$/.test(u[1])?100:1),_=parseFloat(u[2])/(/%$/.test(u[2])?100:1);if(!Number.isFinite(d)||!Number.isFinite(y)||!Number.isFinite(_))return null;l={h:(d%360+360)%360,s:Math.max(0,Math.min(1,y)),l:Math.max(0,Math.min(1,_))},r=jt(l.h,l.s,l.l)}else{const d=parseFloat(u[0]),y=parseFloat(u[1]),_=parseFloat(u[2]);if(!Number.isFinite(d)||!Number.isFinite(y)||!Number.isFinite(_))return null;r={r:d,g:y,b:_}}if(u[3]!=null){const d=parseFloat(u[3]);i=/%$/.test(u[3])?d/100:d}}}}}if(!r)return{keyword:null,format:"unknown",raw:t};const s=l||es(r);return{h:s.h,s:s.s,l:s.l,a:Number.isFinite(i)?Math.max(0,Math.min(1,i)):1,rgb:{r:Math.round(r.r),g:Math.round(r.g),b:Math.round(r.b)},format:/^#/.test(n)?"hex":/^hsl/.test(n)?"hsl":/^rgb/.test(n)?"rgb":"named",raw:t,keyword:null}}const sr={black:{r:0,g:0,b:0},white:{r:255,g:255,b:255},red:{r:255,g:0,b:0},green:{r:0,g:128,b:0},blue:{r:0,g:0,b:255},grey:{r:128,g:128,b:128},gray:{r:128,g:128,b:128},silver:{r:192,g:192,b:192},yellow:{r:255,g:255,b:0},orange:{r:255,g:165,b:0},purple:{r:128,g:0,b:128},pink:{r:255,g:192,b:203},navy:{r:0,g:0,b:128},teal:{r:0,g:128,b:128},lime:{r:0,g:255,b:0},cyan:{r:0,g:255,b:255},aqua:{r:0,g:255,b:255},magenta:{r:255,g:0,b:255},fuchsia:{r:255,g:0,b:255},maroon:{r:128,g:0,b:0},olive:{r:128,g:128,b:0},rebeccapurple:{r:102,g:51,b:153}};function hn(e,t){const n=e||{};if(n.keyword==="currentcolor")return"currentcolor";const r=n.a==null?1:n.a,i=n.rgb||jt(n.h||0,n.s||0,n.l||0),l=t||n.format||"hex",s=c=>Math.max(0,Math.min(255,Math.round(c))).toString(16).padStart(2,"0");if(l==="rgb")return r<1?"rgba("+Math.round(i.r)+", "+Math.round(i.g)+", "+Math.round(i.b)+", "+L(r)+")":"rgb("+Math.round(i.r)+", "+Math.round(i.g)+", "+Math.round(i.b)+")";if(l==="hsl"){const c=L(Math.round(n.h||0)),u=L(Math.round((n.s||0)*100)),d=L(Math.round((n.l||0)*100));return r<1?"hsla("+c+", "+u+"%, "+d+"%, "+L(r)+")":"hsl("+c+", "+u+"%, "+d+"%)"}if(l==="mix"){const c="#"+s(i.r)+s(i.g)+s(i.b),u=L(Math.round(r*1e4)/100);return"color-mix(in srgb, "+c+" "+u+"%, transparent)"}const a="#"+s(i.r)+s(i.g)+s(i.b);return r<1?a+s(r*255):a}function Qs(e){const t=e||{},n=Number.isFinite(t.h)?t.h:0,r=Number.isFinite(t.s)?t.s:0,i=Number.isFinite(t.l)?t.l:0,l=(a,c,u)=>hn({h:a,s:c,l:u,a:1},"hex"),s=[0,60,120,180,240,300,360].map(a=>l(a,Math.max(r,.5),.5));return[{key:"h",label:"hue",value:Math.round(n),min:0,max:360,suffix:"°",track:"linear-gradient(90deg, "+s.join(", ")+")",end:"rainbow = full gamut",now:l(n,r,i)},{key:"s",label:"saturation",value:Math.round(r*100),min:0,max:100,suffix:"%",track:"linear-gradient(90deg, "+l(n,0,i)+", "+l(n,1,i)+")",end:"0 = grey",now:l(n,r,i)},{key:"l",label:"lightness",value:Math.round(i*100),min:0,max:100,suffix:"%",track:"linear-gradient(90deg, "+l(n,r,0)+", "+l(n,r,.5)+", "+l(n,r,1)+")",end:"50% = true colour",now:l(n,r,i)}]}function lr(e,t,n){const r=Object.assign({},e),i=Number(n);return Number.isFinite(i)&&(t==="h"?r.h=i:t==="s"?r.s=Math.max(0,Math.min(1,i/100)):t==="l"&&(r.l=Math.max(0,Math.min(1,i/100))),r.rgb=jt(r.h||0,r.s||0,r.l||0)),r}function el(e){const t=ve("transition-duration",e);if(!t||t.number==null)return[];const n=t.unit==="s"?t.number*1e3:t.number;return[{unit:"ms",current:t.unit==="ms",value:L(n)+"ms"},{unit:"s",current:t.unit==="s",value:L(n/1e3)+"s"}]}function tl(e){const t=ve("rotate",e);if(!t||t.number==null)return[];const n=t.unit==="turn"?t.number*360:t.unit==="rad"?t.number*(180/Math.PI):t.number;return[{unit:"deg",current:t.unit==="deg",value:L(n)+"deg"},{unit:"turn",current:t.unit==="turn",value:L(n/360)+"turn"},{unit:"rad",current:t.unit==="rad",value:L(n*(Math.PI/180))+"rad"}]}function nl(e,t,n){return zt(t,e,n)}function rl(e){const t=[];for(const n of e||[]){const r=n&&n.value?n.value:n,i=String(r||"").trim();i&&(/^url\(/i.test(i)||/gradient\(/i.test(i))&&(t.some(l=>l.value===i)||t.push({value:i,thumb:/^url\(/i.test(i)}))}return t}const Xr=/(^|\s|^[-a-z]*\()(?:var|env|attr)\(/i,ol=new Set(["border-radius"]);function il(e){const t=String(e??"").trim();if(!t||Xr.test(t))return!1;let n=0;for(const r of t)if(r==="(")n++;else if(r===")")n--;else if(/\s/.test(r)&&n===0)return!1;return n===0}function sl(e,t){const n=(e||[]).map(r=>String(r??"").trim());return n.length!==t||t<2||n.some(r=>!r)?null:t===2?n[0]===n[1]?n[0]:n.join(" "):n[1]===n[3]&&n[0]===n[2]?n[0]===n[1]?n[0]:n[0]+" "+n[1]:n[1]===n[3]?n[0]+" "+n[1]+" "+n[2]:n.join(" ")}function ar(e,t){const n=String(e||"").trim().toLowerCase(),r=xt(n);if(!r)return{ok:!1,form:"",value:"",longhands:{},reason:"not a shorthand property"};const i=t||{},l={},s=[];for(const d of r){const y=String(i[d.key]==null?"":i[d.key]).trim();y||s.push(d.key),l[d.key]=y}if(s.length)return{ok:!1,form:"",value:"",longhands:l,reason:"no value for "+s.join(", ")};const a={};for(const d of r)a[d.longhand]=l[d.key];const c=r.filter(d=>!il(l[d.key]));if(c.length)return{ok:!0,form:"longhands",value:"",longhands:a,reason:"a "+(Xr.test(l[c[0].key])?"custom property":"multi-part value")+" cannot join a shorthand, so the "+r.length+" sides are written as longhands"};const u=sl(r.map(d=>l[d.key]),r.length);return u?ol.has(n)&&r.length===4&&u.split(" ").length===2?{ok:!0,form:"longhands",value:"",longhands:a,reason:"a two-value border-radius is the slash form, so the corners are written literally"}:{ok:!0,form:"shorthand",value:u,longhands:a,reason:""}:{ok:!0,form:"longhands",value:"",longhands:a,reason:"the sides could not be collapsed"}}function ll(e,t){const n=String(e??"").trim().toLowerCase(),r=String(t??"").trim().toLowerCase();if(!n||!r)return!1;if(n===r)return!0;if(n.startsWith("--"))return!1;if(r.startsWith(n+"-"))return!0;const i=xt(n);return i?i.some(l=>l.longhand===r):!1}function al(e,t){const n=String(e??"").trim();if(!n)return[];const r=[n];for(const i of t||[]){const l=String(i??"").trim();l&&l!==n&&ll(n,l)&&!r.includes(l)&&r.push(l)}return r}function mn(e){const t=e.range,n=e.step,r=Number(e.value),i=Number.isFinite(r)?lt(r,t):0,l=(s,a)=>{if(!t||!a)return;const c=a.getBoundingClientRect();if(!(c.width>0))return;const u=Math.max(0,Math.min(1,(s-c.left)/c.width));e.onChange(Vr(u,t,n))};return o("div",{class:"inspector__subrail"},o("span",{class:"inspector__subrail-name"},e.label),o("div",{class:"inspector__subrail-track",role:"slider",tabIndex:0,"aria-label":e.label+" value","aria-valuemin":String(t?t.min:""),"aria-valuemax":String(t?t.max:""),"aria-valuenow":Number.isFinite(r)?String(r):"",onPointerDown:s=>{const a=s.currentTarget;if(a.setPointerCapture)try{a.setPointerCapture(s.pointerId)}catch{}s.preventDefault(),l(s.clientX,a)},onPointerMove:s=>{(!s.currentTarget.hasPointerCapture||s.currentTarget.hasPointerCapture(s.pointerId))&&(s.buttons||s.pointerType==="touch")&&l(s.clientX,s.currentTarget)},onKeyDown:s=>{t&&((s.key==="ArrowRight"||s.key==="ArrowUp")&&(s.preventDefault(),e.onChange(pt(r+n,n,t))),(s.key==="ArrowLeft"||s.key==="ArrowDown")&&(s.preventDefault(),e.onChange(pt(r-n,n,t))))}},o("span",{class:"inspector__subrail-fill",style:{width:(i*100).toFixed(2)+"%"}}),o("span",{class:"inspector__subrail-thumb",style:{left:(i*100).toFixed(2)+"%"}})),o("span",{class:"inspector__subrail-value"},e.text))}function cl(e){const t=$r(e.value);if(!t||t.format==="unknown")return o("p",{class:"inspector__shape-note"},t&&t.keyword==="currentcolor"?"currentcolor follows the element’s text colour — set it from the color row instead.":"No colour view: this value is not a colour the inspector can read, so the typed field is the control.");const n=Qs(t),r=[{key:"hex",label:"hex"},{key:"rgb",label:"rgb"},{key:"hsl",label:"hsl"},{key:"mix",label:"color-mix()"}],l=(e.candidates||[]).slice(0,5).map(s=>Object.assign({},s,{contrast:nl(s.value,e.background,e.contrastCtx)}));return o("div",{class:"inspector__shape inspector__shape--colour"},n.map(s=>{const a=s.key==="h"?s.value/360:s.value/100,c=(u,d)=>{if(!d)return;const y=d.getBoundingClientRect();if(!(y.width>0))return;const _=Math.max(0,Math.min(1,(u-y.left)/y.width)),R=lr(t,s.key,s.key==="h"?_*360:_*100);e.onChange(hn(R,e.format||t.format))};return o("div",{class:"inspector__railcard",key:s.key},o("div",{class:"inspector__railhead"},o("span",{class:"inspector__rail-kind"},s.label),o("span",{class:"inspector__rail-now"},s.value+s.suffix),o("span",{class:"inspector__rail-ev"},s.end)),o("div",{class:"inspector__railwrap inspector__railwrap--short",role:"slider",tabIndex:0,"aria-label":s.label,"aria-valuemin":"0","aria-valuemax":String(s.max),"aria-valuenow":String(s.value),"aria-valuetext":s.value+s.suffix,onPointerDown:u=>{const d=u.currentTarget;if(d.setPointerCapture)try{d.setPointerCapture(u.pointerId)}catch{}u.preventDefault(),c(u.clientX,d)},onPointerMove:u=>{(!u.currentTarget.hasPointerCapture||u.currentTarget.hasPointerCapture(u.pointerId))&&(u.buttons||u.pointerType==="touch")&&c(u.clientX,u.currentTarget)},onKeyDown:u=>{if(u.key!=="ArrowRight"&&u.key!=="ArrowLeft")return;u.preventDefault();const d=u.key==="ArrowRight"?1:-1,y=s.value+d*(s.key==="h",1);e.onChange(hn(lr(t,s.key,y),e.format||t.format))}},o("span",{class:"inspector__rtrack",style:{background:s.track}}),o("span",{class:"inspector__rtrack-fill",style:{width:(a*100).toFixed(2)+"%"}}),o("span",{class:"inspector__rthumb",style:{left:(a*100).toFixed(2)+"%",background:s.now}})))}),o("div",{class:"inspector__shape-row",role:"group","aria-label":"Colour format"},r.map(s=>o("button",{class:"inspector__shape-chip"+((e.format||t.format)===s.key?" is-on":""),type:"button",key:s.key,"aria-pressed":String((e.format||t.format)===s.key),title:s.key==="mix"?"Write this colour as a color-mix() of itself and transparent — the same colour, as a mix":"Write this colour as "+s.label,onClick:()=>e.onFormat(s.key)},s.label))),l.length?o("div",{class:"grp"},o("div",{class:"gh"},"This page's palette",o("span",null," · contrast vs this element")),o("div",{class:"opts"},l.map(s=>o("button",{class:"opt inspector__suggest-colour"+(s.isCurrent?" is-current":"")+(s.contrast&&s.contrast.okLevel?"":" is-unreadable"),type:"button",key:"c-"+s.value,title:s.value+(s.contrast&&s.contrast.text?" · "+s.contrast.text:""),"aria-label":"Use "+s.value+(s.contrast&&s.contrast.text?", contrast "+s.contrast.text:""),onClick:()=>e.onChange(s.value)},o("span",{class:"inspector__suggest-sw",style:{background:s.value},"aria-hidden":"true"}),o("span",{class:"inspector__suggest-value"},s.value),s.contrast&&s.contrast.text?o("span",{class:"inspector__suggest-aa"+(s.contrast.okLevel?"":" is-bad")},s.contrast.text):null)))):null)}function ul(e){const t=xt(e.prop),n=Kr(e.prop,e.value),[r,i]=T(null);if(!t||!n.ok)return o("p",{class:"inspector__shape-note"},"No fan-out view: "+(n&&n.reason||"this property has no sides")+". The typed field is the control.");const l=r??n.uniform,s=n.unit||"px",a=ar(e.prop,n.sides),c=a.ok&&a.form==="shorthand",u=(d,y)=>{if(!c)return;const _=Object.assign({},n.sides);if(l)for(const j of t)_[j.key]=L(y)+s;else _[d]=L(y)+s;const R=ar(e.prop,_);R.ok&&R.form==="shorthand"&&e.onChange(R.value)};return o("div",{class:"inspector__shape inspector__shape--fanout"},o("div",{class:"inspector__linkrow"},o("button",{class:"inspector__linktog"+(l?" is-on":""),type:"button",role:"switch","aria-checked":String(l),"aria-label":"Link all sides",onClick:()=>i(!l)},o("span",{class:"inspector__linktog-knob","aria-hidden":"true"})),o("span",null,"Link all sides — drag one, all move")),o("div",{class:"inspector__railcard"},t.map(d=>{const y=n.numbers[d.key],_=Ot(e.prop,(y??0)+s,e.ctx||{});return o("div",{key:d.key,class:"inspector__subrail-row"},o(mn,{label:d.label,value:y??0,range:_,step:e.step||1,text:n.sides[d.key],onChange:R=>u(d.key,R)}))})),o("p",{class:"inspector__shape-line"},e.prop+": "+Ws(e.prop,n.sides)),o("p",{class:"inspector__shape-note"},c?"Written back as the shortest valid shorthand; every side is one declaration and one undo.":"Not rewritten from here: "+(a.reason||"the sides cannot be collapsed")+". The typed field is the control."))}function dl(e){const t=Ys(e.prop,e.used||[]),n=String(e.value||"").trim().toLowerCase();return o("div",{class:"inspector__shape inspector__shape--enum"},o("div",{class:"inspector__opts",role:"group","aria-label":e.prop+" keyword"},t.map(r=>o("button",{class:"inspector__shape-chip"+(r.key===n?" is-on":"")+(r.source==="page"?" is-page":"")+(r.wide?" is-wide":""),type:"button",key:r.key,"aria-pressed":String(r.key===n),title:r.source==="page"?r.value+" — used on this page":r.value+(r.wide?" — a CSS-wide keyword":""),onClick:()=>e.onChange(r.value)},r.value))),o("p",{class:"inspector__shape-note"},e.used&&e.used.length?"The page's own values come first; the CSS-wide keywords are last.":"The property's own keywords; the CSS-wide keywords are last."))}function pl(e){const t=Gr(e.value);if(t){const r=(a,c,u)=>{const d=t.map(y=>({name:y.name,args:y.args.map(_=>({raw:_.raw,value:_.value}))}));d[a].args[c].value=u,e.onChange(It(d))},i=a=>{const c=t.filter((u,d)=>d!==a);e.onChange(c.length?It(c):sn)},l=(a,c)=>{const u=Xs(t,a,c);u!==t&&e.onChange(It(u))},s=Gs(e.prop,t);return o("div",{class:"inspector__shape inspector__shape--functions"},t.map(a=>o("div",{class:"inspector__railcard",key:a.name+a.index},o("div",{class:"inspector__railhead"},o("span",{class:"inspector__rail-kind"},a.name),o("span",{class:"inspector__rail-ev"},a.args.length+(a.args.length===1?" argument":" arguments")),o("button",{class:"inspector__fn-move",type:"button",disabled:a.index===0,"aria-label":"Move "+a.name+" earlier",title:"Move "+a.name+" earlier",onClick:()=>l(a.index,-1)},"▲"),o("button",{class:"inspector__fn-move",type:"button",disabled:a.index===t.length-1,"aria-label":"Move "+a.name+" later",title:"Move "+a.name+" later",onClick:()=>l(a.index,1)},"▼"),o("button",{class:"inspector__fn-remove",type:"button","aria-label":"Remove "+a.name,onClick:()=>i(a.index)},"✕")),a.args.map((c,u)=>o("div",{key:"a"+u,class:"inspector__subrail-row"},o(mn,{label:"arg "+(u+1),value:Number(String(c.value).replace(/[^\d.+-]/g,"")),range:Ot(e.prop,c.value,e.ctx||{}),step:ur(c.value,e.step),text:c.value,onChange:d=>r(a.index,u,L(d)+cr(c.value))}))))),o("div",{class:"inspector__fn-addrow",role:"group","aria-label":"Add a function"},o("span",{class:"inspector__fn-addlabel"},"Add"),s.map(a=>o("button",{class:"inspector__shape-chip",type:"button",key:"add-"+a.name,title:"Add "+a.name+"("+a.args.join(", ")+")",onClick:()=>e.onChange(It($s(t,a)))},a.name)),o("button",{class:"inspector__shape-chip"+(t.length?"":" is-on"),type:"button","aria-label":"Set "+e.prop+" to none",title:"Set "+e.prop+" to none",onClick:()=>e.onChange(sn)},sn)))}const n=Zr(e.prop,e.value);if(n){const r=(l,s,a)=>{const c=n.map(u=>({index:u.index,raw:u.raw,args:u.args.map(d=>({raw:d.raw,value:d.value}))}));c[l].args[s].value=a,e.onChange(ir(c))},i=(l,s)=>{const a=l+(s<0?-1:1);if(a<0||a>=n.length)return;const c=n.slice(),u=c[l];c[l]=c[a],c[a]=u,e.onChange(ir(c.map((d,y)=>Object.assign({},d,{index:y}))))};return o("div",{class:"inspector__shape inspector__shape--list"},n.map((l,s)=>o("div",{class:"inspector__railcard",key:"i"+s},o("div",{class:"inspector__railhead"},o("span",{class:"inspector__rail-kind"},e.prop+" #"+(s+1)),o("span",{class:"inspector__rail-ev"},l.args.length+" values"),o("button",{class:"inspector__fn-move",type:"button",disabled:s===0,"aria-label":"Move item "+(s+1)+" earlier",onClick:()=>i(s,-1)},"▲"),o("button",{class:"inspector__fn-move",type:"button",disabled:s===n.length-1,"aria-label":"Move item "+(s+1)+" later",onClick:()=>i(s,1)},"▼")),l.args.map((a,c)=>o("div",{key:"a"+c,class:"inspector__subrail-row"},o(mn,{label:String(a.value).slice(0,8),value:Number(String(a.value).replace(/[^\d.+-]/g,"")),range:Ot(e.prop,a.value,e.ctx||{}),step:ur(a.value,e.step),text:a.value,onChange:u=>r(s,c,L(u)+cr(a.value))}))))))}return o("p",{class:"inspector__shape-note"},"No per-argument view: this value is not a list the inspector can take apart, so the typed field is the control.")}function cr(e){const t=/([a-z%]+)$/i.exec(String(e||"").trim());return t?t[1]:""}function ur(e,t){return t||1}function dr(e){const t=e.options||[];return t.length<2?null:o("div",{class:"inspector__shape-row",role:"group","aria-label":e.label},t.map(n=>o("button",{class:"inspector__shape-chip"+(n.current?" is-on":""),type:"button",key:n.unit,"aria-pressed":String(!!n.current),onClick:()=>e.onChange(n.value)},n.unit)))}function fl(e){const t=rl(e.candidates||[]);return t.length?o("div",{class:"inspector__shape inspector__shape--image"},o("div",{class:"grp"},o("div",{class:"gh"},"On this page",o("span",null," · images and gradients")),o("div",{class:"opts"},t.map(n=>o("button",{class:"opt"+(n.value===String(e.value||"").trim()?" is-current":""),type:"button",key:n.value,title:n.value,"aria-label":"Use "+n.value,onClick:()=>e.onChange(n.value)},n.thumb?o("span",{class:"inspector__shape-thumb",style:{backgroundImage:n.value},"aria-hidden":"true"}):null,o("span",{class:"inspector__suggest-value"},n.value))))),o("p",{class:"inspector__shape-note"},"No rail — an image is not a number. The page's own candidates are offered instead.")):o("p",{class:"inspector__shape-note"},"No rail for an image: the page declares no other images or gradients for this property, so the typed field is the control.")}function hl(e){const t=qr(e.prop,e.value,e.sticky);return t==="rail"?null:t==="text"?o("p",{class:"inspector__shape-note"},"No shape view for this value — the typed field is the control."):t==="colour"?o(cl,e):t==="fanout"?o(ul,e):t==="enum"?o(dl,e):t==="functions"?o(pl,e):t==="image"?o(fl,e):t==="time"?o("div",{class:"inspector__shape"},o(dr,{label:"Time unit",options:el(e.value),onChange:e.onChange})):t==="angle"?o("div",{class:"inspector__shape"},o(dr,{label:"Angle unit",options:tl(e.value),onChange:e.onChange})):null}const ml=[{id:"layout",label:"Layout"},{id:"spacing",label:"Spacing"},{id:"size",label:"Size"},{id:"text",label:"Text"},{id:"colour",label:"Colour"},{id:"effects",label:"Effects"}],gl=["top","right","bottom","left"],Jr={top:"Top",right:"Right",bottom:"Bottom",left:"Left"},bl=[{id:"margin",label:"Margin",note:"outside the element"},{id:"padding",label:"Padding",note:"inside the element"}],pr={gap:{min:0,max:64,step:4,units:["px","rem"]},"row-gap":{min:0,max:64,step:4,units:["px","rem"]},"column-gap":{min:0,max:64,step:4,units:["px","rem"]},padding:{min:0,max:64,step:4,units:["px","rem","%"]},margin:{min:0,max:64,step:4,units:["px","rem","%"]},width:{min:0,max:600,step:8,units:["px","%","rem"]},height:{min:0,max:600,step:8,units:["px","%","rem"]},"border-radius":{min:0,max:96,step:4,units:["px","%","rem"]},"border-width":{min:0,max:16,step:1,units:["px"]},"font-size":{min:8,max:72,step:2,units:["px","rem","em"]},"line-height":{min:.8,max:3,step:.1,units:[]},"letter-spacing":{min:-2,max:12,step:.5,units:["px","rem"]},opacity:{min:0,max:1,step:.1,units:[]}},Ht={min:0,max:96,step:4,units:["px","rem","%"]},fr=/-(top|right|bottom|left)$/;function Yr(e){const t=String(e||"").trim().toLowerCase();return fr.test(t)?t.replace(fr,""):t}function Qr(e){const t=String(e||"").trim().toLowerCase();return pr[t]||pr[Yr(t)]||Ht}const yl={"line-height":{min:8,max:96,step:1,units:["px"]}};function eo(e,t){const n=Qr(e),r=yl[Yr(e)];if(!r)return n;const i=yt(t);return i&&i.unit&&(n.units||[]).indexOf(i.unit)<0&&(r.units||[]).indexOf(i.unit)>=0?r:n}function vl(e){const t=e&&e.step||1,n=t>=4?t/4:t/2;return{coarse:t,fine:n}}function Vt(e,t){const n=String(e||"").trim().toLowerCase();if(!n)return"";const r=t&&t.declared||[],i=t&&t.computed||[];for(const l of r)if(l&&String(l.prop||"").toLowerCase()===n)return String(l.value==null?"":l.value);for(const l of i)if(l&&String(l.prop||"").toLowerCase()===n)return String(l.value==null?"":l.value);return""}const wl={padding:["top","right","bottom","left"],margin:["top","right","bottom","left"],"border-width":["top","right","bottom","left"],"border-color":["top","right","bottom","left"],"border-style":["top","right","bottom","left"],inset:["top","right","bottom","left"]};function _l(e){const[t,n,r,i]=e;return t===n&&n===r&&r===i?t:t===r&&n===i?t+" "+n:n===i?t+" "+n+" "+r:e.join(" ")}function hr(e,t){const n=String(e||"").trim().toLowerCase();if(!n)return null;for(const r of t&&t.declared||[])if(r&&String(r.prop||"").toLowerCase()===n)return String(r.value==null?"":r.value);return null}function to(e,t){const n=String(e||"").trim().toLowerCase(),r=hr(n,t);if(r!=null)return r;const i=wl[n];if(!i)return null;const l=i.map(s=>hr(n+"-"+s,t));return l.every(s=>s!=null)?_l(l):null}function bt(e,t){return to(e,t)!=null}const kl=/^([-+]?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i;function yt(e){const t=kl.exec(String(e??"").trim());if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?{number:n,unit:(t[2]||"").toLowerCase()}:null}function no(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;const n=yt(e);if(!n)return null;const r={};return n.unit==="rem"?r.rootFontSize?n.number*r.rootFontSize:n.number:n.unit==="em"&&(r.parentFontSize||r.fontSize)?n.number*(r.parentFontSize||r.fontSize):n.number}function ro(e,t,n,r){const i=r||{},l=(n==null?"px":String(n)).toLowerCase(),s=Number(e);if(!Number.isFinite(s))return"";if(l===""||l==="number")return L(s);if(l==="px")return L(s)+"px";if(l==="rem"&&i.rootFontSize)return L(s/i.rootFontSize)+"rem";if(l==="em"&&(i.parentFontSize||i.fontSize))return L(s/(i.parentFontSize||i.fontSize))+"em";if(l==="%"){const a=String(t||"").toLowerCase();if(a==="font-size"||a==="line-height"){const c=i.parentFontSize||i.fontSize;if(c)return L(s/c*100)+"%"}}return L(s)+"px"}function Sl(e,t,n){const r=yt(t);return r?!r.unit&&(n.units||[]).length===0?"":r.unit||"px":(n.units||["px"])[0]}function xl(e,t){const n=no(e),r=t||Ht;if(n==null)return 0;const i=r.max-r.min;return i>0?Math.min(1,Math.max(0,(n-r.min)/i)):0}function oo(e,t){const n=Number(t);if(!(n>0))return e;const r=Math.round(e/n)*n,i=String(n);if(i.indexOf("e")>=0)return Math.round(r*1e6)/1e6;const l=(i.split(".")[1]||"").length;return Number(r.toFixed(l))}function Cl(e,t,n){const r=t||Ht,i=Math.min(1,Math.max(0,Number(e)||0)),l=r.min+i*(r.max-r.min),s=oo(l,n||r.step);return Math.min(r.max,Math.max(r.min,s))}function mr(e,t,n,r){const i=n||Ht,l=yt(e);if(!l)return null;const s=no(e);if(s==null)return null;const a=oo(s+(Number(t)<0?-1:1)*(r||i.step),r||i.step),c=Math.min(i.max,Math.max(i.min,a)),u=l.unit||(i.units||["px"])[0];return{px:c,css:ro(c,"",u)}}function Pl(e,t,n){const r=yt(t);if(!r)return[];const i=kn(e,t,n||{}),l=Qr(e).units||[],s=i.filter(a=>a.unit===""||l.indexOf(a.unit)>=0||a.current);return!r.unit&&l.length===0?[]:s.map(a=>({unit:a.unit,value:a.value,current:!!a.current,ok:a.ok!==!1,reason:a.reason||"",title:a.current?a.unit+" — the unit in use":a.ok!==!1?"Rewrite as "+a.value:"Not available: "+(a.reason||"")}))}function Rl(e,t){const n=String(t??"").trim().toLowerCase(),i=(e&&e.options||[]).map(l=>({value:l.value,label:l.label,glyph:l.glyph||"",isOn:l.value===n,title:l.value===n?l.value+" — the value in force":"Set "+e.prop+" to "+l.value}));return n&&!i.some(l=>l.isOn)&&i.unshift({value:n,label:n,glyph:"·",isOn:!0,unknown:!0,title:n+" — set elsewhere, not one of this control's options"}),i}function io(e){return Vt("display",e).trim().toLowerCase()}function vt(e){const t=io(e);return t==="flex"||t==="inline-flex"}function so(e){const t=io(e);return t==="grid"||t==="inline-grid"}const Tl=[{id:"none",label:"None",value:"none",hint:"No background image"},{id:"down",label:"Down",value:"linear-gradient(rgb(255, 255, 255) 0%, rgb(220, 220, 220) 100%)",hint:"Fade downward"},{id:"accent",label:"Accent",value:"linear-gradient(135deg, rgb(79, 140, 255) 0%, rgb(139, 92, 246) 100%)",hint:"A two-hue accent wash"},{id:"warm",label:"Warm",value:"linear-gradient(135deg, rgb(255, 179, 71) 0%, rgb(255, 94, 98) 100%)",hint:"Orange to red"},{id:"cool",label:"Cool",value:"linear-gradient(135deg, rgb(54, 209, 220) 0%, rgb(91, 134, 229) 100%)",hint:"Teal to blue"},{id:"fade",label:"Fade out",value:"linear-gradient(rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 100%)",hint:"A scrim for text over a photo"}];function Nl(e){const t=gr(e);return Tl.map(n=>({value:n.value,label:n.label,hint:n.hint,isOn:gr(n.value)===t,title:n.isOn?n.label+" — the value in force":"Set background-image to "+n.hint.toLowerCase()}))}function gr(e){return String(e??"").trim().replace(/\s+/g," ").toLowerCase()}const El=[{id:"display",group:"layout",prop:"display",label:"Display",kind:"segments",hint:"How the box takes part in the layout",options:[{value:"block",label:"Block",glyph:"▤"},{value:"flex",label:"Flex",glyph:"⇤"},{value:"grid",label:"Grid",glyph:"▦"},{value:"inline-flex",label:"Inline",glyph:"↔"},{value:"none",label:"None",glyph:"⃠"}]},{id:"flex-direction",group:"layout",prop:"flex-direction",label:"Direction",kind:"segments",when:vt,hint:"Which way the children flow",options:[{value:"row",label:"Row",glyph:"→"},{value:"row-reverse",label:"Row ↺",glyph:"←"},{value:"column",label:"Column",glyph:"↓"},{value:"column-reverse",label:"Col ↺",glyph:"↑"}]},{id:"align-items",group:"layout",prop:"align-items",label:"Align items",kind:"segments",when:vt,hint:"Across the flow",options:[{value:"flex-start",label:"Start",glyph:"⤒"},{value:"center",label:"Centre",glyph:"↕"},{value:"flex-end",label:"End",glyph:"⤓"},{value:"stretch",label:"Stretch",glyph:"⇕"},{value:"baseline",label:"Base",glyph:"⌐"}]},{id:"justify-content",group:"layout",prop:"justify-content",label:"Justify",kind:"segments",when:vt,hint:"Along the flow",options:[{value:"flex-start",label:"Start",glyph:"⊢"},{value:"center",label:"Centre",glyph:"↔"},{value:"flex-end",label:"End",glyph:"⊣"},{value:"space-between",label:"Between",glyph:"[ ]"},{value:"space-around",label:"Around",glyph:"( )"}]},{id:"gap",group:"layout",prop:"gap",label:"Gap",kind:"range",when:e=>vt(e)||so(e),hint:"Space between the children"},{id:"position",group:"layout",prop:"position",label:"Position",kind:"segments",hint:"How the box is placed",options:[{value:"static",label:"Static",glyph:"▤"},{value:"relative",label:"Relative",glyph:"⇱"},{value:"absolute",label:"Absolute",glyph:"⌖"},{value:"fixed",label:"Fixed",glyph:"⊞"},{value:"sticky",label:"Sticky",glyph:"⇧"}]},{id:"box",group:"spacing",prop:"padding",label:"Box model",kind:"box",hint:"Tap an edge, then drag the value"},{id:"width",group:"size",prop:"width",label:"Width",kind:"range",keywords:[{value:"auto",label:"Auto"},{value:"100%",label:"100%"}],hint:"The element's own width"},{id:"height",group:"size",prop:"height",label:"Height",kind:"range",keywords:[{value:"auto",label:"Auto"}],hint:"The element's own height"},{id:"border-radius",group:"size",prop:"border-radius",label:"Corners",kind:"range",hint:"Rounds the corners"},{id:"font-size",group:"text",prop:"font-size",label:"Size",kind:"range",hint:"The type size"},{id:"font-weight",group:"text",prop:"font-weight",label:"Weight",kind:"segments",hint:"How heavy the type is",options:[{value:"300",label:"300",glyph:"Aa"},{value:"400",label:"400",glyph:"Aa"},{value:"500",label:"500",glyph:"Aa"},{value:"600",label:"600",glyph:"Aa"},{value:"700",label:"700",glyph:"Aa"},{value:"800",label:"800",glyph:"Aa"}]},{id:"line-height",group:"text",prop:"line-height",label:"Line height",kind:"range",hint:"Space between the lines"},{id:"letter-spacing",group:"text",prop:"letter-spacing",label:"Tracking",kind:"range",hint:"Space between the letters"},{id:"text-align",group:"text",prop:"text-align",label:"Align",kind:"segments",hint:"Where the text sits",options:[{value:"left",label:"Left",glyph:"⇤"},{value:"center",label:"Centre",glyph:"↔"},{value:"right",label:"Right",glyph:"⇥"},{value:"justify",label:"Justify",glyph:"☰"}]},{id:"color",group:"text",prop:"color",label:"Text colour",kind:"colour",hint:"The type colour"},{id:"background-color",group:"colour",prop:"background-color",label:"Background",kind:"colour",hint:"Behind the content"},{id:"background-image",group:"colour",prop:"background-image",label:"Background image",kind:"image",hint:"A gradient or an image, painted over the background colour"},{id:"border-color",group:"colour",prop:"border-color",label:"Border colour",kind:"colour",hint:"The border line"},{id:"opacity",group:"effects",prop:"opacity",label:"Opacity",kind:"range",hint:"How see-through it is"},{id:"box-shadow",group:"effects",prop:"box-shadow",label:"Shadow",kind:"segments",hint:"Depth around the box",options:[{value:"none",label:"None",glyph:"·"},{value:"0 1px 2px rgba(0, 0, 0, 0.18)",label:"Soft",glyph:"▁"},{value:"0 4px 12px rgba(0, 0, 0, 0.22)",label:"Lifted",glyph:"▂"},{value:"0 12px 32px rgba(0, 0, 0, 0.28)",label:"Floating",glyph:"▃"}]},{id:"border-style",group:"effects",prop:"border-style",label:"Border style",kind:"segments",hint:"The kind of border line",options:[{value:"none",label:"None",glyph:"·"},{value:"solid",label:"Solid",glyph:"▬"},{value:"dashed",label:"Dashed",glyph:"▨"},{value:"dotted",label:"Dotted",glyph:"⋯"}]},{id:"border-width",group:"effects",prop:"border-width",label:"Border width",kind:"range",hint:"How thick the border is"}];function br(e,t){return El.filter(n=>n.group===e&&(!n.when||n.when(t||{})))}function Ml(e){return vt(e)||so(e)?"layout":"spacing"}function Al(e){const t=[];for(const n of bl)for(const r of gl){const i=n.id+"-"+r;t.push({box:n.id,side:r,prop:i,label:n.label+" "+Jr[r].toLowerCase(),value:Vt(i,e),isSet:bt(i,e)})}return t}const Il=[{id:"all",label:"All"},{id:"layout",label:"Layout"},{id:"spacing",label:"Spacing"},{id:"size",label:"Size"},{id:"text",label:"Type"},{id:"colour",label:"Colour"},{id:"effects",label:"Effects"}],Ll=[{prop:"display",group:"layout",label:"Display",blurb:"How the box is laid out",preview:"flex"},{prop:"position",group:"layout",label:"Position",blurb:"Static, relative, absolute…",preview:"position"},{prop:"flex-direction",group:"layout",label:"Flex direction",blurb:"Which way the children flow",preview:"flex"},{prop:"align-items",group:"layout",label:"Align items",blurb:"Line the children up across",preview:"flex"},{prop:"justify-content",group:"layout",label:"Justify content",blurb:"Spread the children along",preview:"flex"},{prop:"gap",group:"layout",label:"Gap",blurb:"Space between the children",preview:"gap"},{prop:"flex-wrap",group:"layout",label:"Flex wrap",blurb:"Let the children wrap",preview:"flex"},{prop:"padding",group:"spacing",label:"Padding",blurb:"Space inside the element",preview:"padding"},{prop:"margin",group:"spacing",label:"Margin",blurb:"Space outside the element",preview:"margin"},{prop:"margin-top",group:"spacing",label:"Row gap",blurb:"Space between rows",preview:"gap"},{prop:"width",group:"size",label:"Width",blurb:"The element's own width",preview:"size"},{prop:"height",group:"size",label:"Height",blurb:"The element's own height",preview:"size"},{prop:"min-height",group:"size",label:"Min height",blurb:"Never shorter than this",preview:"size"},{prop:"max-width",group:"size",label:"Max width",blurb:"Never wider than this",preview:"size"},{prop:"border-radius",group:"size",label:"Border radius",blurb:"Rounds the corners",preview:"radius"},{prop:"font-size",group:"text",label:"Font size",blurb:"The type size",preview:"text"},{prop:"font-weight",group:"text",label:"Font weight",blurb:"How heavy the type is",preview:"weight"},{prop:"line-height",group:"text",label:"Line height",blurb:"Space between the lines",preview:"text"},{prop:"letter-spacing",group:"text",label:"Letter spacing",blurb:"Space between the letters",preview:"text"},{prop:"text-align",group:"text",label:"Text align",blurb:"Where the text sits",preview:"text"},{prop:"font-family",group:"text",label:"Font family",blurb:"The face the type is set in",preview:"weight"},{prop:"color",group:"colour",label:"Colour",blurb:"The type colour",preview:"colour"},{prop:"background-color",group:"colour",label:"Background",blurb:"Behind the content",preview:"colour"},{prop:"background-image",group:"colour",label:"Background image",blurb:"A gradient or an image",preview:"gradient"},{prop:"border-color",group:"colour",label:"Border colour",blurb:"The border line",preview:"border"},{prop:"opacity",group:"effects",label:"Opacity",blurb:"How see-through it is",preview:"opacity"},{prop:"box-shadow",group:"effects",label:"Box shadow",blurb:"Depth around the element",preview:"shadow"},{prop:"border",group:"effects",label:"Border",blurb:"A line around the element",preview:"border"},{prop:"border-style",group:"effects",label:"Border style",blurb:"Solid, dashed, dotted…",preview:"border"},{prop:"overflow",group:"effects",label:"Overflow",blurb:"What happens past the edge",preview:"overflow"},{prop:"transition",group:"effects",label:"Transition",blurb:"How changes animate",preview:"none"},{prop:"cursor",group:"effects",label:"Cursor",blurb:"Pointer shape on hover",preview:"none"}];function Fl(e,t,n){const r=String(e||"").trim().toLowerCase();return(n||Ll).filter(l=>t&&t!=="all"&&l.group!==t?!1:r?(l.prop+" "+l.label+" "+l.blurb).toLowerCase().indexOf(r)>=0:!0)}function zl(e,t){const n=to(e.prop,t),r=n??Vt(e.prop,t),i=n!=null;return{prop:e.prop,group:e.group,label:e.label,blurb:e.blurb,preview:e.preview||"none",value:r,isSet:i,action:i?"Edit":"Choose",title:i?"Edit "+e.label+" ("+e.prop+") — now "+r:"Add "+e.label+" ("+e.prop+")"}}function Ol(e,t){return ve(e,t)}function Dl(e){const[t,n]=T(null);return ne(()=>{n(null)},[e]),[t??e,n]}function Ut(e){return o("div",{class:"inspector__touch-head"},o("span",{class:"inspector__touch-label"},o("span",{class:"inspector__touch-name"},e.label),o("code",{class:"inspector__touch-prop"},e.prop),e.isSet?o("span",{class:"inspector__touch-set",title:"Declared on this element"},"set"):null),o("button",{class:"inspector__touch-value"+(e.isSet?" is-set":""),type:"button",disabled:e.disabled,title:e.value?"Type an exact value for "+e.prop+" (now "+e.value+")":"Type a value for "+e.prop,"aria-label":"Edit "+e.prop+(e.value?", now "+e.value:"")+" in the value editor",onClick:()=>e.onEdit(e.prop,e.value)},e.value||"—"))}function yr(e){const t=e.dir<0?e.down:e.up,n=e.dir<0?"Decrease ":"Increase ";return o("button",{class:"inspector__touch-step",type:"button",disabled:e.disabled||!t,title:t?n+e.prop+" to "+t.css:"Not a number — use the value editor","aria-label":n+e.prop,onClick:()=>e.onStep(t)},e.dir<0?"−":"+")}function lo(e){const{prop:t,label:n,value:r,ctx:i,unitCtx:l,spec:s,onApply:a,onEdit:c,disabled:u,note:d,keywords:y}=e,[_,R]=T(!1),[j,K]=Dl(r),N=s||eo(t,r),p=vl(N),E=_?p.fine:p.coarse,q=yt(r),Z=Sl(t,r,N),D=q?xl(r,N):0,X=j??r,B=mr(r,-1,N,E),ge=mr(r,1,N,E),$=Pl(t,r,l),ue=!!q,de=Math.max(.1,E/(N.max-N.min)*100);function ie(H){return ro(Cl(H,N,E),t,Z,l)}function be(H){const se=ie(H);String(se)!==String(r)&&a(t,se)}return o("div",{class:"inspector__touch-row"},o(Ut,{label:n,prop:t,value:r,isSet:bt(t,i),disabled:u,onEdit:c}),d?o("p",{class:"inspector__touch-note"},d):null,o("div",{class:"inspector__touch-range"},o(yr,{dir:-1,prop:t,down:B,up:ge,disabled:u||!ue,onStep:H=>{H&&a(t,H.css)}}),o("input",{class:"inspector__touch-slider",type:"range",min:0,max:100,step:de,value:String(Math.round(D*1e3)/10),disabled:u||!ue,"aria-label":n+" ("+t+")","aria-valuetext":X,onInput:H=>K(ie(Number(H.currentTarget.value)/100)),onChange:H=>{K(null),be(Number(H.currentTarget.value)/100)}}),o(yr,{dir:1,prop:t,down:B,up:ge,disabled:u||!ue,onStep:H=>{H&&a(t,H.css)}}),o("span",{class:"inspector__touch-readout","aria-hidden":"true"},X||"—")),ue?o("div",{class:"inspector__touch-foot"},$.length>1?o("div",{class:"inspector__touch-chips",role:"group","aria-label":"Unit for "+t},$.map(H=>o("button",{class:"inspector__touch-chip"+(H.current?" is-on":""),type:"button",key:H.unit,disabled:!H.ok||H.current||u,"aria-pressed":String(!!H.current),title:H.title,onClick:()=>a(t,H.value)},H.unit))):null,o("div",{class:"inspector__touch-chips",role:"group","aria-label":"Step size for "+t},o("button",{class:"inspector__touch-chip"+(_?"":" is-on"),type:"button","aria-pressed":String(!_),title:"Step by "+p.coarse+" — the design scale",onClick:()=>R(!1)},"Coarse"),o("button",{class:"inspector__touch-chip"+(_?" is-on":""),type:"button","aria-pressed":String(_),title:"Step by "+p.fine+" — a fraction of the coarse step",onClick:()=>R(!0)},"Fine"))):o("p",{class:"inspector__touch-note"},"Not a number ("+(r||"unset")+") — the value editor can rewrite it."),y&&y.length?o("div",{class:"inspector__touch-chips",role:"group","aria-label":"Common values for "+t},y.map(H=>o("button",{class:"inspector__touch-chip"+(String(r).toLowerCase()===H.value?" is-on":""),type:"button",key:H.value,"aria-pressed":String(String(r).toLowerCase()===H.value),disabled:u,title:"Set "+t+" to "+H.value,onClick:()=>a(t,H.value)},H.label))):null)}function Bl(e){const{control:t,value:n,ctx:r,onApply:i,onEdit:l,disabled:s}=e,a=Rl(t,n);return o("div",{class:"inspector__touch-row"},o(Ut,{label:t.label,prop:t.prop,value:n,isSet:bt(t.prop,r),disabled:s,onEdit:l}),o("div",{class:"inspector__touch-seg",role:"group","aria-label":t.label+" ("+t.prop+")"},a.map(c=>o("button",{class:"inspector__touch-segbtn"+(c.isOn?" is-on":"")+(c.unknown?" is-unknown":""),type:"button",key:c.value,"aria-pressed":String(!!c.isOn),disabled:s||!!c.isOn||!!c.unknown,title:c.title,onClick:()=>i(t.prop,c.value)},o("span",{class:"inspector__touch-segglyph","aria-hidden":"true"},c.glyph),o("span",{class:"inspector__touch-seglabel"},c.label)))),t.hint?o("p",{class:"inspector__touch-note"},t.hint):null)}function jl(e){const{control:t,value:n,ctx:r,onApply:i,onEdit:l,disabled:s,swatches:a}=e,c=(a||[]).filter(u=>u&&String(u).toLowerCase()!==String(n||"").toLowerCase());return o("div",{class:"inspector__touch-row"},o(Ut,{label:t.label,prop:t.prop,value:n,isSet:bt(t.prop,r),disabled:s,onEdit:l}),o("div",{class:"inspector__touch-colour"},o("button",{class:"inspector__touch-stroke",type:"button",style:{backgroundColor:n||"transparent"},disabled:s,title:n?"Edit "+t.prop+" ("+n+")":"Pick a colour for "+t.prop,"aria-label":"Edit "+t.prop+(n?", now "+n:""),onClick:()=>l(t.prop,n)}),c.length?o("div",{class:"inspector__touch-chips",role:"group","aria-label":"Colours this page uses for "+t.prop},c.map(u=>o("button",{class:"inspector__touch-swatch",type:"button",key:u,style:{backgroundColor:u},disabled:s,title:"Set "+t.prop+" to "+u,"aria-label":"Set "+t.prop+" to "+u,onClick:()=>i(t.prop,u)}))):null),t.hint?o("p",{class:"inspector__touch-note"},t.hint):null)}function Hl(e){const{control:t,value:n,ctx:r,onApply:i,onEdit:l,disabled:s}=e,a=Nl(n);return o("div",{class:"inspector__touch-row"},o(Ut,{label:t.label,prop:t.prop,value:n,isSet:bt(t.prop,r),disabled:s,onEdit:l}),o("div",{class:"inspector__touch-chips",role:"group","aria-label":"Background image presets"},a.map(c=>o("button",{class:"inspector__touch-chip"+(c.isOn?" is-on":""),type:"button",key:c.value,"aria-pressed":String(!!c.isOn),disabled:s||c.isOn,title:c.title,onClick:()=>i(t.prop,c.value)},c.label))),t.hint?o("p",{class:"inspector__touch-note"},t.hint):null)}function vr(e){const{box:t,edges:n,selected:r,onSelect:i,style:l,children:s}=e;return o("div",{class:"inspector__touch-box inspector__touch-box--"+t,style:l},n.filter(a=>a.box===t).map(a=>o("button",{class:"inspector__touch-edge"+(r.box===a.box&&r.side===a.side?" is-on":"")+(a.isSet?" is-set":""),type:"button",key:a.prop,style:{gridArea:a.side},"aria-pressed":String(r.box===a.box&&r.side===a.side),title:a.value?a.prop+" is "+a.value+" — tap to edit it in the row below":a.prop+" is not set — tap to edit it in the row below","aria-label":a.prop+(a.value?", "+a.value:", not set"),onClick:()=>i(a)},a.value||"—")),o("div",{class:"inspector__touch-boxmid",style:{gridArea:"mid"}},s||o("span",{class:"inspector__touch-boxname","aria-hidden":"true"},t)))}function Vl(e){const{edges:t,selected:n,onSelect:r,label:i,ctx:l,unitCtx:s,onApply:a,onEdit:c,disabled:u}=e,d=t.find(y=>y.box===n.box&&y.side===n.side)||t[0];return o("div",{class:"inspector__touch-row"},o("div",{class:"inspector__touch-head"},o("span",{class:"inspector__touch-label"},o("span",{class:"inspector__touch-name"},"Box model"),o("code",{class:"inspector__touch-prop"},"margin · padding"))),o("div",{class:"inspector__touch-boxes"},o(vr,{box:"margin",edges:t,selected:n,onSelect:r},o(vr,{box:"padding",edges:t,selected:n,onSelect:r},o("span",{class:"inspector__touch-boxtag"},i||"content")))),o("p",{class:"inspector__touch-note"},"Editing "+d.prop+(d.isSet?" — declared on this element":" — currently from a rule, so an edit copies it onto the element")),o(lo,{prop:d.prop,label:Jr[d.side]+" "+d.box,value:d.value,ctx:l,unitCtx:s,onApply:a,onEdit:c,disabled:u}))}function ao(e,t){if(!e||!t)return;const n=e.getBoundingClientRect();if(!n.height)return;const r=[".inspector__styles-pin",".inspector__touch-tabs"].map(c=>{const u=e.querySelector(c);if(!u)return 0;const d=u.getBoundingClientRect();return d.height&&d.top<=n.top+1?d.bottom:0}).reduce((c,u)=>Math.max(c,u),n.top),i=Math.max(n.top,r);if(i>=n.bottom)return;const l=6,s=8,a=t.getBoundingClientRect();a.top>=i+s&&a.bottom<=n.bottom-s||(e.scrollTop+=a.top-i-l)}function Ul(e){const{ctx:t,unitCtx:n,onApply:r,onEdit:i,onAddProperty:l,disabled:s,swatchesFor:a,label:c}=e,[u,d]=T(()=>Ml(t)),[y,_]=T({box:"padding",side:"top"});e.revealRef&&(e.revealRef.current=()=>ao(document.querySelector(".inspector__styles"),e.tabsRef&&e.tabsRef.current));const R=Al(t),j=br(u,t);function K(N){return br(N,t).some(p=>p.kind==="box"?R.some(E=>E.isSet):bt(p.prop,t))}return o("div",{class:"inspector__touch"},o("div",{class:"inspector__touch-tabs",ref:e.tabsRef,role:"group","aria-label":"Style groups"},ml.map(N=>o("button",{class:"inspector__touch-tab"+(u===N.id?" is-on":"")+(K(N.id)?" is-set":""),type:"button",key:N.id,"aria-pressed":String(u===N.id),title:N.label+" styles"+(K(N.id)?" — something here is set on this element":""),onClick:()=>{N.id!==u&&(d(N.id),e.onGroupChange&&e.onGroupChange(N.id))}},N.label))),j.length?j.map(N=>{const p=Vt(N.prop,t);return N.kind==="box"?o(Vl,{key:N.id,edges:R,selected:y,onSelect:E=>_({box:E.box,side:E.side}),label:c,ctx:t,unitCtx:n,onApply:r,onEdit:i,disabled:s}):N.kind==="segments"?o(Bl,{key:N.id,control:N,value:p,ctx:t,onApply:r,onEdit:i,disabled:s}):N.kind==="colour"?o(jl,{key:N.id,control:N,value:p,ctx:t,swatches:a?a(N.prop):[],onApply:r,onEdit:i,disabled:s}):N.kind==="image"?o(Hl,{key:N.id,control:N,value:p,ctx:t,onApply:r,onEdit:i,disabled:s}):o(lo,{key:N.id,prop:N.prop,label:N.label,spec:eo(N.prop,p),keywords:N.keywords,note:N.hint,kind:Ol(N.prop,p).kind,value:p,ctx:t,unitCtx:n,onApply:r,onEdit:i,disabled:s})}):o("p",{class:"inspector__touch-none"},"No controls in this group for this element."),o("button",{class:"inspector__touch-add"+(e.addOpen?" is-open":""),type:"button",disabled:s,"aria-expanded":String(!!e.addOpen),"aria-controls":"inspector-addprop",title:e.addOpen?"Hide the property list":"Browse CSS properties and add one to this element",onClick:l},o("span",{class:"inspector__touch-addglyph","aria-hidden":"true"},"+"),o("span",null,"Add property")),o("p",{class:"inspector__touch-footnote"},"Every control writes the element's own inline style — one property per tap, and the receipt below can undo it."))}function Wl(e){return o("span",{class:"inspector__propcard inspector__propcard--"+(e.kind||"none"),"aria-hidden":"true"},o("span",{class:"inspector__propcard-box"}),o("span",{class:"inspector__propcard-mark"}),o("span",{class:"inspector__propcard-glyph"},e.glyph||"Aa"))}function ql(e){const[t,n]=T(""),[r,i]=T("all"),l=A(null);function s(){const u=l.current;u&&ao(u.closest(".inspector__styles"),u)}if(ne(()=>{e.open&&(n(""),i("all"),s())},[e.open]),ne(()=>{e.open&&s()},[r,t]),!e.open)return null;const a=Fl(t,r).map(u=>zl(u,e.ctx||{})),c=(e.suggestions||[]).map(([u,d,y])=>({prop:u,desc:d,short:y}));return o("div",{class:"inspector__addprop",id:"inspector-addprop",ref:l,role:"region","aria-label":"Add a property"},o("div",{class:"inspector__addprop-head"},o("h3",{class:"inspector__styles-h"},"Add a property"),o("button",{class:"btn inspector__addprop-close",type:"button",title:"Close the property list",onClick:e.onClose},"Close")),o("label",{class:"label",for:"inspector-addprop-search"},"Search every property"),o("input",{class:"input inspector__addprop-search",id:"inspector-addprop-search",type:"search",value:t,placeholder:"padding, colour, shadow…",autocapitalize:"off",autocorrect:"off",spellcheck:!1,enterkeyhint:"search",onInput:u=>n(u.currentTarget.value)}),c.length&&!t&&r==="all"?o("div",{class:"inspector__addprop-suggest",role:"group","aria-label":"Suggested properties"},o("p",{class:"inspector__addprop-h"},"Suggested"),o("div",{class:"inspector__touch-chips"},c.map(u=>{const d=(e.ctx&&e.ctx.declared||[]).find(y=>y.prop===u.prop);return o("button",{class:"inspector__touch-chip"+(d?" is-on":""),type:"button",key:u.prop,title:d?u.prop+" — set to "+d.value:u.desc+" ("+u.prop+")",onClick:()=>e.onPick({prop:u.prop,value:d?d.value:"",isSet:!!d})},u.short||u.prop)}))):null,o("div",{class:"inspector__addprop-tabs",role:"group","aria-label":"Property groups"},Il.map(u=>o("button",{class:"inspector__touch-tab"+(r===u.id?" is-on":""),type:"button",key:u.id,"aria-pressed":String(r===u.id),onClick:()=>i(u.id)},u.label))),a.length?o("ul",{class:"inspector__addprop-list"},a.map(u=>o("li",{key:u.prop},o("button",{class:"inspector__addprop-card"+(u.isSet?" is-set":""),type:"button",title:u.title,"aria-label":u.title,onClick:()=>e.onPick(u)},o(Wl,{kind:u.preview,glyph:u.label.slice(0,2)}),o("span",{class:"inspector__addprop-text"},o("span",{class:"inspector__addprop-name"},u.label),o("code",{class:"inspector__addprop-prop"},u.prop),o("span",{class:"inspector__addprop-blurb"},u.blurb)),o("span",{class:"inspector__addprop-action"},u.isSet?o("span",{class:"inspector__addprop-value"},u.value||"set"):null,o("span",{class:"inspector__addprop-badge"},u.action)))))):o("p",{class:"inspector__styles-none",role:"status"},"No property matches “"+t+"”. Try another word, or type the name in the editor's property field."),o("p",{class:"inspector__addprop-note"},"Any property can be set — pick a card for the guided value editor, or type a name in the editor's own property field."))}const Zl=800;function Kl(e){const t=e||{},n=Math.max(200,Number(t.intervalMs)||Zl),r=t.setTimer||((y,_)=>setTimeout(y,_)),i=t.clearTimer||(y=>clearTimeout(y)),l=t.isHidden||(()=>!1),s=t.busy||(()=>!1);let a=!0,c=null,u=!1;async function d(){if(c=null,!a){if(!u&&!l()&&!s()){u=!0;try{await t.capture()}catch{}finally{u=!1}}a||(c=r(d,n))}}return{start(){a&&(a=!1,c=r(d,n))},stop(){a=!0,c&&(i(c),c=null)}}}function Gl(e){const t=e||{},n=(t.declared||[]).filter(s=>s&&(s.prop||s.name)),r=String(t.edited||"").trim(),i=r.toLowerCase(),l=n.some(s=>String(s.prop||s.name||"").toLowerCase()===i);return{changed:r?1:0,added:r&&!l?1:0,kept:Math.max(0,n.length-(r&&l?1:0)),rulesEdited:0,elements:r?1:0}}function $l(e){const t=e||{},n=String(t.prop||""),r=at(t.from),i=at(t.to);return{prop:n,from:r,to:i,wasSet:r!=="",isRemoval:i==="",text:n+" "+(r===""?"—":r)+" → "+(i===""?"(removed)":i)}}function at(e){return e==null?"":String(e).trim()}function Xl(e,t){const n=Array.isArray(e)?e.slice():[],r=String(t&&t.prop||"").trim();if(!r)return n;const i=t&&t.fromPriority==="important"?"important":"",l=t&&t.toPriority==="important"?"important":"",s=r.toLowerCase(),a=n.findIndex(d=>String(d.prop||"").toLowerCase()===s);if(a<0){const d={prop:r,from:at(t.from),to:at(t.to),fromPriority:i,toPriority:l};return d.from===d.to&&d.fromPriority===d.toPriority?n:(n.push(d),n.slice(-20))}const c=n[a],u={prop:c.prop,from:c.from,to:at(t.to),fromPriority:c.fromPriority||"",toPriority:l};return u.from===u.to&&(u.fromPriority||"")===u.toPriority?(n.splice(a,1),n):(n[a]=u,n)}function Jl(e){const t=e||{},n=String(t.prop||""),r=at(t.from),i=t.fromPriority==="important"?"important":"";return n?r===""?{kind:"remove",prop:n,value:""}:{kind:"set",prop:n,value:r,priority:i}:null}function co(e){return(Array.isArray(e)?e.slice():[]).reverse()}function Yl(e){const t=Array.isArray(e)?e:[];let n=0,r=0;for(const i of t)at(i&&i.from)===""&&n++,at(i&&i.to)===""&&r++;return{count:t.length,added:n,removed:r,hasChanges:t.length>0}}function Ql(e){return co(e).map((t,n)=>{const r=$l(t);return{key:(r.prop||"row")+"-"+n,prop:r.prop,from:r.from,to:r.to,text:r.text,wasSet:r.wasSet,isRemoval:r.isRemoval}})}const ea={"user-agent":"browser"},ta={regular:"author",injected:"author",inspector:"author",inline:"author","user-agent":"user-agent"},na=40,ra=24;function oa(e){const n=(e&&e.selectorList&&e.selectorList.selectors||[]).map(i=>i&&i.text?String(i.text).trim():"").filter(Boolean);if(n.length)return n.join(", ");const r=e&&e.selectorList&&e.selectorList.text||"";return String(r).trim()}function ia(e){return(e&&e.media||[]).map(r=>r&&r.text?String(r.text).trim():"").filter(Boolean).join(" and ")}function sa(e){const t=e&&e.cssProperties||[],n=[];for(const r of t)!r||!r.name||r.implicit||n.push({name:String(r.name),value:String(r.value==null?"":r.value),important:!!r.important,disabled:!!r.disabled});return n}function gn(e,t){const n=sa(e&&e.style);if(!n.length)return null;const r=n.slice(0,ra),i=t.origin||"regular";return{id:t.id,selector:t.selector,origin:i,group:ta[i]||"author",media:ia(e),inherited:t.inherited||"",props:r,more:Math.max(0,n.length-r.length)}}function wr(e,t){const n=(e||[]).map(i=>i&&i.rule||i).filter(Boolean),r=[];for(let i=n.length-1;i>=0;i--){const l=gn(n[i],{id:t.prefix+"-m"+i,selector:oa(n[i])||"(unknown)",origin:n[i].origin||"regular",inherited:t.inherited});l&&r.push(l)}return r}function la(e,t){const n=e||{},r=t&&t.ancestors||[],i=[],l=gn({style:n.inlineStyle},{id:"inline",selector:"element.style",origin:"inline"});l&&i.push(l),i.push(...wr(n.matchedCSSRules,{prefix:"own"}));const s=n.inherited||[];for(let u=0;u<s.length;u++){const d=r[u]&&r[u].label?r[u].label:"ancestor",y=s[u]||{},_=gn({style:y.inlineStyle},{id:"inh"+u+"-inline",selector:"element.style",origin:"inline",inherited:d});_&&i.push(_),i.push(...wr(y.matchedCSSRules,{prefix:"inh"+u,inherited:d}))}const a={total:i.length,author:0,userAgent:0};for(const u of i)u.group==="user-agent"?a.userAgent++:a.author++;const c=i.slice(0,na);return{rules:c,counts:a,truncated:Math.max(0,i.length-c.length)}}function aa(e){const t=String(e??"").trim();return!t||/^[—\-\s×x]+$/i.test(t)?"":t}function ca(e,t){const n=r=>r&&typeof r=="object"&&String(r.label||"").trim()!=="";return n(e)?e:n(t)?t:null}function _r(e,t){const n=String(t??"").trim();if(!n)return null;const r=ve(e,n);return!r||r.kind!=="color"?null:o("span",{class:"inspector__styles-swatch",style:{background:n},"aria-hidden":"true"})}function ua(e){const t=e.receipt||[],n=Yl(t);if(!n.hasChanges)return null;const r=Ql(t);return o("div",{class:"inspector__receipt",role:"group","aria-label":"Changes made in this session"},o("div",{class:"inspector__receipt-head"},o("strong",{class:"inspector__receipt-title"},String(n.count)+(n.count===1?" change":" changes")),o("span",{class:"inspector__receipt-meta"},[n.added?n.added+" added":null,n.removed?n.removed+" removed":null].filter(Boolean).join(" · ")),o("button",{class:"btn inspector__receipt-undoall",type:"button",title:"Reverse every change in this list","aria-label":"Undo all "+n.count+" changes",onClick:e.onUndoAll},"↺ Undo all")),r.map(i=>o("div",{class:"inspector__receipt-row",key:i.key},e.onEditRow&&!i.isRemoval?o("button",{class:"inspector__receipt-main",type:"button",title:"Edit "+i.prop,"aria-label":"Edit "+i.prop+", now "+i.to,onClick:()=>e.onEditRow(i)},o("span",{class:"inspector__receipt-prop"},i.prop),i.wasSet?o("span",{class:"inspector__receipt-was",title:"was "+i.from},i.from):o("span",{class:"inspector__receipt-was inspector__receipt-was--unset",title:"was not set on this element"},"—"),o("span",{class:"inspector__receipt-arrow","aria-hidden":"true"},"→"),o("span",{class:"inspector__receipt-now"},i.to)):o("span",{class:"inspector__receipt-main"},o("span",{class:"inspector__receipt-prop"},i.prop),i.wasSet?o("span",{class:"inspector__receipt-was",title:"was "+i.from},i.from):o("span",{class:"inspector__receipt-was inspector__receipt-was--unset",title:"was not set on this element"},"—"),o("span",{class:"inspector__receipt-arrow","aria-hidden":"true"},"→"),o("span",{class:"inspector__receipt-now is-removed"},"(removed)")),o("button",{class:"inspector__receipt-revert",type:"button",title:"Reverse this change: "+i.text,"aria-label":"Undo "+i.text,onClick:()=>e.onUndo(i)},"↺"))))}function da(e){const t=e.prop||"",n=e.value||"",r=e.ctx||{};if(!t||!n)return null;const i=Ii(t,n,r),l=kn(t,n,r);if(i.length<2&&l.length<2)return null;const s=i.find(a=>a.isCurrent);return o("div",{class:"inspector__valueswitch"},o("label",{class:"label"},"Value type",o("span",{class:"inspector__valueswitch-kind"},s?" — "+s.label:"")),o("div",{class:"inspector__kindseg",role:"group","aria-label":"Value type"},i.map(a=>o("button",{class:"inspector__kindseg-btn"+(a.isCurrent?" is-on":"")+(a.ok?"":" is-blocked"),type:"button",key:a.kind,"aria-pressed":String(!!a.isCurrent),disabled:!a.ok||a.isCurrent,title:a.isCurrent?a.label+" — the form this value is in now":a.ok?"Rewrite as "+a.label+": "+a.value+(a.lossless?" (same value)":" ("+a.note+")"):"Not available: "+a.reason,"aria-label":a.isCurrent?a.label+", current":a.ok?"Use "+a.label+", "+a.value+(a.lossless?"":", "+a.note):a.label+" unavailable, "+a.reason,onClick:()=>e.onChange(a.value)},o("span",{class:"inspector__kindseg-name"},a.label),o("span",{class:"inspector__kindseg-val"},a.isCurrent?n:a.ok?a.value:"—")))),l.length>1?o("div",{class:"inspector__unitrow",role:"group","aria-label":"Unit"},o("span",{class:"inspector__unitrow-label"},"Unit"),l.map(a=>o("button",{class:"inspector__unitchip"+(a.current?" is-on":""),type:"button",key:a.unit,disabled:!a.ok,"aria-pressed":String(!!a.current),title:a.current?a.unit+" — the unit in use":a.ok?"Rewrite as "+a.value+(a.note?" ("+a.note+")":""):"Not available: "+a.reason,onClick:()=>e.onChange(a.value)},a.unit))):null,(()=>{const a=i.filter(u=>!u.isCurrent&&u.ok&&!u.lossless),c=i.filter(u=>!u.isCurrent&&!u.ok);return!a.length&&!c.length?null:o("p",{class:"inspector__valueswitch-note"},a.length?o("span",{class:"inspector__valueswitch-warn"},"! ",a.map(u=>u.label+" "+u.note).join(" · ")):null,a.length&&c.length?" ":null,c.length?o("span",{class:"inspector__valueswitch-blocked"},c.map(u=>u.label+": "+u.reason).join(" · ")):null)})())}function kr(e){if(!e)return"(no element)";const t=(e.nodeName||"").toLowerCase(),n=Array.isArray(e.attributes)?e.attributes:[];let r="",i=[];for(const s of n)s&&s.name==="id"?r=s.value||"":s&&s.name==="class"&&(i=String(s.value||"").split(/\s+/).filter(Boolean));let l=t;return r&&(l+="#"+r),i.length&&(l+=i.slice(0,3).map(s=>"."+s).join(""),i.length>3&&(l+="…")),l}function Sr(e){if(!e)return"";const t=n=>{const r=parseFloat(n);return Number.isFinite(r)?Math.round(r)+"px":n};return(e.width?t(e.width):"—")+" × "+(e.height?t(e.height):"—")}const pa=[["color","text color","color"],["background-color","background","bg"],["font-size","font size","size"],["margin","margin","margin"],["padding","padding","padding"],["border","border","border"]],fa=/^(-?\d+(?:\.\d+)?)(px|em|rem|%|vh|vw|pt|ch|ex)?$/;function xr(e,t,n){return fa.test(String(e??"").trim())?Xi(e,t,n):null}function ha(e){const[t,n]=T(e.prop||""),[r,i]=T(e.value||Hn(e.prop)),[l,s]=T(!1),[a,c]=T(""),[u,d]=T(!1),[y,_]=T(null),[R,j]=T(e.priority==="important"?"important":""),[K,N]=T([]),p=A(!0);ne(()=>()=>{p.current=!1},[]),ne(()=>{n(e.prop||""),i(e.value||Hn(e.prop)),c(""),d(!1),_(null)},[e.prop,e.value]),ne(()=>{j(e.priority==="important"?"important":"")},[e.prop,e.value,e.priority]);const E=(t||"").trim(),q=Er(()=>Wn(t,r,typeof CSS<"u"&&CSS.supports?(z,oe)=>CSS.supports(z,oe):null),[t,r]),[Z,D]=T(!1),X=Z&&!q.ok,B=A(e.readSiblings);B.current=e.readSiblings,ne(()=>{let z=!0;N([]);const oe=B.current;return!oe||!E?()=>{z=!1}:(oe(E).then(Ne=>{z&&N(Array.isArray(Ne)?Ne:[])}).catch(()=>{z&&N([])}),()=>{z=!1})},[E]);const[ge,$]=T(!1);function ue(){if(!l){if(Z&&!u&&q.ok){$(!0);return}e.onCancel()}}const de=e.valueIndex&&E?Ft(e.valueIndex,E):null,ie=Un(de),be=xr(r,-1,ie),H=xr(r,1,ie),se=de?Br(E,r,de):null,Te=(()=>{if(!e.valueIndex||!E)return{};const z=Ft(e.valueIndex,E),oe=zr(e.valueIndex,E).map(_e=>({name:_e.name,value:_e.value})),Ne=/^(width|height|min-width|max-width|min-height|max-height|top|right|bottom|left|inset|inset-block|inset-inline|block-size|inline-size|flex-basis|outline-offset|text-indent)$/,fe=e.box&&e.box.width!=null?e.box:{},Xe=e.unitCtx||{},Ce=ve(E,r).kind==="length"?Ne.test(E)?Number(fe.height)||Number(fe.width):Xe.fontSize:null,Pe=e.unitCtx||{};return{step:Un(z),tokens:oe,scaleNote:z&&z.step?Or(z):"",size:Number.isFinite(Ce)&&Ce>0?Ce:null,fontSize:Pe.fontSize,parentFontSize:Pe.parentFontSize,rootFontSize:Pe.rootFontSize,nearest:se&&se.offScale&&se.nearest?se.nearest.number:null}})(),we=A(null),ce=qr(E,r);we.current==null?we.current={shape:ce}:(we.current.shape!=="fanout"||ce==="fanout")&&(we.current.shape=ce);const ye=we.current.shape,Se=ye==="rail"||ye==="time"||ye==="angle",ae=z=>{i(z),d(!1),c("")},pe=A(null),xe=[Se?o(zs,{key:"rail",prop:E,value:r,ctx:Te,from:e.from,onKeypad:()=>{const z=pe.current;if(z)try{z.focus(),z.select&&z.select()}catch{}},onChange:ae}):null,o(hl,{key:"shape",prop:E,value:r,sticky:ye,format:y,onFormat:_,ctx:Te,step:Te.step,used:e.valueIndex?kt(e.valueIndex,E,12):[],candidates:e.colourCandidates,background:e.contrastCtx&&e.contrastCtx.bg,contrastCtx:e.contrastCtx,onChange:ae})];async function v(z,oe){if(!(l||!e.onApply)){s(!0),c("");try{if(await e.onApply(z,oe,R),!p.current)return;d(!0),e.onRefreshShot&&e.onRefreshShot()}catch(Ne){if(!p.current)return;c(Ne&&Ne.message||"Could not set "+z)}finally{p.current&&s(!1)}}}async function U(){const z=Wn(t,r,typeof CSS<"u"&&CSS.supports?(oe,Ne)=>CSS.supports(oe,Ne):null);if(!z.ok){c(z.error);return}await v(z.prop,z.value)}async function le(z){!E||z==null||(i(z),await v(E,z))}async function De(){if(!E){c("Property is required.");return}if(!(l||!e.onRemove)){s(!0),c("");try{await e.onRemove(E),p.current&&e.onDone()}catch(z){if(!p.current)return;c(z&&z.message||"Could not remove "+E),s(!1)}}}return Cn(o("div",{class:"inspector__overlay",onClick:l?void 0:ue},o("div",{class:"inspector__sheet inspector__sheet--style",role:"dialog","aria-modal":"true","aria-label":"Edit "+(E||"style"),onClick:z=>z.stopPropagation()},o("div",{class:"inspector__sheet-head"},o("strong",{class:"inspector__sheet-title"},E?"Edit "+E:"Add style"),o("button",{class:"btn inspector__sheet-close",type:"button",onClick:ue},u?"Done":"Cancel")),o("div",{class:"inspector__sheet-body inspector__sheet-body--style"},e.shot?o("button",{class:"inspector__styles-shot inspector__styles-shot--sheet",type:"button",title:"Tap to refresh the element preview","aria-label":"Refresh the element preview",disabled:!!e.shotBusy,onClick:e.onRefreshShot},o("img",{class:"inspector__styles-shot-img",src:e.shot,alt:"Preview of the edited element",draggable:"false"})):null,o("label",{class:"label"},"Property"),o("input",{class:"input inspector__style-input",type:"text",value:t,placeholder:"e.g. background-color",autocapitalize:"off",autocorrect:"off",spellcheck:!1,onInput:z=>{n(z.currentTarget.value),d(!1),D(!0)}}),o("label",{class:"label"},"Value"),o(da,{prop:E,value:r,ctx:e.unitCtx,onChange:z=>{i(z),d(!1),c("")}}),o(ps,{index:e.valueIndex,prop:E,value:r,contrastCtx:e.contrastCtx,ownColour:ye==="colour",shape:ye,siblings:K,onPick:z=>{i(z),d(!1),c("")}}),...xe,o("div",{class:"inspector__style-valuerow"},o("button",{class:"inspector__style-step",type:"button",disabled:l||be==null,"aria-label":"Decrease "+(E||"value"),title:be==null?"Not a number":"Decrease to "+be+(ie?" — the page's "+ie+(de.unit||"")+" step":""),onClick:()=>le(be)},"−"),o("input",{class:"input inspector__style-input inspector__style-input--value",type:"text",ref:pe,value:r,placeholder:"e.g. #ffcc00",autocapitalize:"off",autocorrect:"off",spellcheck:!1,onInput:z=>{i(z.currentTarget.value),d(!1),D(!0)}}),o("button",{class:"inspector__style-step",type:"button",disabled:l||H==null,"aria-label":"Increase "+(E||"value"),title:H==null?"Not a number":"Increase to "+H+(ie?" — the page's "+ie+(de.unit||"")+" step":""),onClick:()=>le(H)},"+")),ie&&se?o("p",{class:"inspector__style-step-note"},"Stepping by "+ie+(de.unit||"")+" — this page's own scale",se.offScale&&se.nearest?" · nearest "+se.nearest.value:""):null,o("div",{class:"inspector__style-priorityrow"},o("span",{class:"inspector__style-prioritylabel"},"Priority"),o("button",{class:"inspector__style-priority"+(R==="important"?" is-on":""),type:"button","aria-pressed":String(R==="important"),"aria-label":R==="important"?"Priority important — tap to use a normal declaration":"Priority normal — tap to mark this declaration important",title:R==="important"?"Written as !important — it beats other declarations on this element":"Normal declaration — a stylesheet rule marked !important will still win",onClick:()=>j(R==="important"?"":"important")},R==="important"?"!important":"normal"),o("span",{class:"inspector__style-priorityhint"},R==="important"?"Beats other declarations on this element":"A stylesheet !important rule still wins — tap to override it")),(()=>{const z=Gl({declared:e.declared||[],edited:E});return e.isInline?o("div",{class:"inspector__scope"},o("div",{class:"inspector__scope-head"},"Only one thing changes"),o("div",{class:"inspector__scope-grid"},o("span",null,"Properties changed ",o("b",null,String(z.changed))),o("span",null,"Declarations kept ",o("b",null,String(z.kept))),o("span",null,"Rules edited ",o("b",null,String(z.rulesEdited))),o("span",null,"Other elements ",o("b",{class:"inspector__scope-zero"},"0"))),z.added?o("p",{class:"inspector__scope-note"},"Adds "+E+" to this element — it had no declaration of its own before."):null,o("p",{class:"inspector__scope-note inspector__scope-kept"},"Every other declaration on this element is kept as it is.")):null})(),u?o("p",{class:"inspector__style-applied",role:"status"},"Applied — keep editing or tap Done"):null,X&&!a?o("p",{class:"inspector__style-error",role:"status"},q.error):null,a?o("p",{class:"inspector__style-error",role:"alert"},a):null,o("div",{class:"inspector__sheet-actions"},o("button",{class:"btn inspector__style-apply",type:"button",disabled:l||!q.ok,title:q.ok?"Apply this declaration to the element":q.error,onClick:U},l?"Applying…":"Apply"),e.isRemove?o("button",{class:"btn btn--danger inspector__style-remove",type:"button",disabled:l,onClick:De},"Remove"):null)),ge?o(pn,{open:!0,title:"Discard this change?",message:"Your edit to "+(E||"this property")+" has not been applied. Leaving now keeps the value the element has.",confirmLabel:"Discard",cancelLabel:"Keep editing",onCancel:()=>$(!1),onConfirm:()=>{$(!1),e.onCancel()}}):null)))}function ma(e){const t=e.rules||[],n=e.counts||{userAgent:0},r=t.filter(d=>e.showUa||d.group!=="user-agent"),i=r.length?r[0].id:null,[l,s]=T(()=>i?{[i]:!0}:{});ne(()=>{s(i?{[i]:!0}:{})},[e.selectionKey,i]);function a(d){s(y=>{const _={...y};return _[d]?delete _[d]:_[d]=!0,_})}let c=null;const u=n.userAgent?o("button",{class:"inspector__rules-ua"+(e.showUa?" is-on":""),type:"button",key:"ua","aria-pressed":String(!!e.showUa),onClick:e.onToggleUa},(e.showUa?"Hide ":"Show ")+n.userAgent+" browser default rule"+(n.userAgent===1?"":"s")):null;return e.open&&(t.length?c=[r.length?o("ul",{class:"inspector__rules",key:"list"},r.map(d=>{const y=!!l[d.id];return o("li",{class:"inspector__rule"+(d.group==="user-agent"?" is-ua":"")+(d.inherited?" is-inherited":""),key:d.id},o("button",{class:"inspector__rule-head",type:"button","aria-expanded":String(y),"aria-label":(y?"Hide":"Show")+" the "+d.props.length+" declaration"+(d.props.length===1?"":"s")+" of "+d.selector+(d.inherited?", inherited from "+d.inherited:""),title:y?"Hide declarations":"Show declarations",onClick:()=>a(d.id)},o("span",{class:"inspector__rule-caret","aria-hidden":"true"},y?"▾":"▸"),o("span",{class:"inspector__rule-sel"},d.selector),d.group==="user-agent"?o("span",{class:"inspector__rule-tag"},ea["user-agent"]):null,d.media?o("span",{class:"inspector__rule-tag inspector__rule-tag--media",title:"@media "+d.media},"@media "+d.media):null,d.inherited?o("span",{class:"inspector__rule-tag inspector__rule-tag--inh"},"from "+d.inherited):null,o("span",{class:"inspector__rule-n","aria-hidden":"true"},String(d.props.length)+(d.more?"+"+d.more:""))),y?o("ul",{class:"inspector__rule-props"},d.props.map(_=>o("li",{key:d.id+":"+_.name},o("button",{class:"inspector__rule-prop"+(_.disabled?" is-off":""),type:"button",title:"Set "+_.name+" on this element","aria-label":"Set "+_.name+", "+_.value+(_.important?" important":"")+", on this element as an inline style",onClick:()=>e.onEdit(_.name,_.value)},o("span",{class:"inspector__rule-pname"},_.name),o("span",{class:"inspector__rule-pval"},_.value+(_.important?" !important":""))))),d.more?o("li",{class:"inspector__rule-more"},"+"+d.more+" more"):null):null)})):o("p",{class:"inspector__styles-none",key:"only-ua",role:"status"},"Only browser default rules matched this element."),e.truncated?o("p",{class:"inspector__rules-truncated",key:"cut"},"+"+e.truncated+" more rules not shown"):null,u]:c=o("p",{class:"inspector__styles-none",role:"status"},e.busy?"Reading the cascade…":"No stylesheet rules matched this element.")),o("div",{class:"inspector__styles-section"},o("div",{class:"inspector__rules-bar"},o("h3",{class:"inspector__styles-h"},"Matched rules"),o("span",{class:"inspector__rules-count"},e.busy&&!t.length?"…":String(r.length)),o("button",{class:"inspector__rules-toggle",type:"button","aria-expanded":String(!!e.open),"aria-label":(e.open?"Hide":"Show")+" the rules that match this element"+(r.length?" ("+r.length+")":""),onClick:e.onToggle},e.open?"Hide rules":"Show rules")),c)}function ga(e){const[t,n]=T(null),[r,i]=T(!1),[l,s]=T(""),[a,c]=T(null),[u,d]=T(!1),[y,_]=T(""),[R,j]=T(null),[K,N]=T(!1),[p,E]=T([]),q=e.receipt||[];ne(()=>{e.receiptNonce&&(Je(),Ze())},[e.receiptNonce]);const Z=A("");ne(()=>{const f=e.restoreObjectId||"";!f||Z.current===f||B.current||e.refreshNodeModel&&(Z.current=f,G(()=>e.refreshNodeModel(f)))});const[D,X]=T(null),B=A(null),ge=A(0),$=A(null),ue=t&&t.objectId||"",[de,ie]=T(!1);ne(()=>{const f=$.current;f&&(f.scrollLeft=f.scrollWidth,ie(f.scrollLeft>1))},[ue,D]);function be(f){const k=f.currentTarget.scrollLeft>1;ie(O=>O===k?O:k)}const H=A(null),se=A(null),Te=A(null),we=A(null),[ce,ye]=T("");ne(()=>{if(!ce)return;const f=we.current;f&&f()},[ce]);const Se=A("");ne(()=>{const f=t&&t.objectId||"";if(!f){Se.current="";return}if(Se.current===f)return;Se.current=f;const k=H.current;k&&(k.scrollTop=0)},[ue]);const[ae,pe]=T(null),[xe,v]=T(!1),[U,le]=T(!1),[De,z]=T(!1),[oe,Ne]=T(!1),fe=A(0),[Xe,qe]=T({query:"",filter:"all",steps:0}),Ce=Xe.query,Pe=Xe.filter,_e=Xe.steps,M=A(0);function Q(f){qe(k=>({...k,query:String(f||""),steps:0}))}function ee(f){qe(k=>({...k,filter:f,steps:0}))}function te(f){qe(k=>({...k,steps:Math.max(0,f)}))}function Ie(){const f=H.current;!f||M.current<=0||f.scrollHeight-f.scrollTop-f.clientHeight>72||qe(O=>({...O,steps:O.steps+1}))}vo(()=>{const f=H.current;if(!f)return;const k=()=>pi(f,se.current);return fi(se.current,k)},[ue,l]);const J=A(0),Le=A(""),Ee=A(!1),Ke=A(!1);async function Ze(f){const k=f||B.current,O=k&&k.objectId;if(!O||!e.captureElementShot)return;const Y=++J.current;Ee.current=!0,N(!0);try{const re=await e.captureElementShot(O);if(Y!==J.current)return;re&&re.data&&(Le.current=re.data,m({src:"data:image/png;base64,"+re.data,width:re.width,height:re.height}))}catch{}finally{Ee.current=!1,Y===J.current&&N(!1)}}function m(f){j(k=>({...k,...f}))}async function g(){const f=B.current&&B.current.objectId;if(!(!f||!e.captureElementShot)&&!Ee.current&&!Ke.current){Ke.current=!0;try{const k=await e.captureElementShot(f,{scroll:!1});if(!k||!k.data||Ee.current||k.data===Le.current)return;const O=B.current;if(!O||O.objectId!==f)return;Le.current=k.data,m({src:"data:image/png;base64,"+k.data,width:k.width,height:k.height})}catch{}finally{Ke.current=!1}}}ne(()=>{if(!(t&&t.objectId)||!e.captureElementShot)return;const k=Kl({capture:g,isHidden:()=>typeof document<"u"&&document.visibilityState==="hidden"});return k.start(),()=>k.stop()},[t&&t.objectId,e.captureElementShot]);function S(f){const k=f&&f.objectId;if(!k||!e.readElementTree){ge.current++,X(null);return}const O=++ge.current;Promise.resolve(e.readElementTree(k)).then(Y=>{O===ge.current&&X(Y)}).catch(()=>{O===ge.current&&X(null)})}function C(f){const k=B.current&&B.current.objectId;!k||!e.selectAncestorNode||G(()=>e.selectAncestorNode(k,f).then(O=>{if(!O)throw new Error("Nothing above this element.");return O}))}function P(f){const k=B.current&&B.current.objectId;!k||!e.selectChildNode||G(()=>e.selectChildNode(k,f).then(O=>{if(!O)throw new Error("That child is no longer on the page.");return O}))}function x(f){const k=B.current&&B.current.objectId;!!(f&&f.objectId===k)||(E([]),e.onSelectionReset&&e.onSelectionReset()),Me(f),N(!1),Ze(f),S(f),V(f)}async function V(f){const k=f&&f.objectId;if(!k||!e.readMatchedRules){fe.current++,pe(null);return}const O=++fe.current;v(!0);try{const Y=await e.readMatchedRules(k);O===fe.current&&pe(Y)}catch{O===fe.current&&pe(null)}finally{O===fe.current&&v(!1)}}async function G(f){i(!0),s("");try{const k=await f();k&&x(k)}catch(k){s(k&&k.message||"Could not inspect element")}finally{i(!1)}}async function he(f,k){if(!e.pickNodeAt)return!1;s("");try{const O=await e.pickNodeAt(f,k);return O?(x(O),!0):(s("Nothing selectable at that point."),!1)}catch(O){return s(O&&O.message||"Inspect failed"),!1}}async function Fe(){if(!(!e.selectBySelector||!(y||"").trim())){i(!0),s("");try{const f=await e.selectBySelector(y);f?x(f):s("No element matches “"+y.trim()+"”.")}catch(f){s(f&&f.message||"Selector failed")}finally{i(!1)}}}ne(()=>(e.pickHandlerRef&&(e.pickHandlerRef.current=he),()=>{e.pickHandlerRef&&(e.pickHandlerRef.current=null)})),ne(()=>{if(e.onSelectionChange)return e.onSelectionChange({label:t?kr(t.node):"",size:Sr(t&&t.box),objectId:t&&t.objectId||"",declared:t&&t.inlineProps||[],rules:ae||null,tree:D||null,changed:p||[],receipt:q||[],editing:a?a.prop:"",busy:!!r}),()=>{e.onSelectionChange&&e.onSelectionChange(null)}},[t,ae,D,p,q,a,r]),ne(()=>{if(e.panelHandlesRef)return e.panelHandlesRef.current={selectAncestor:f=>{if(!f)return Promise.resolve(!1);const O=(D&&D.ancestors||[]).find(re=>re&&re.label===f.label),Y=f.levels!=null?f.levels:O&&O.levels;return Y==null?Promise.resolve(!1):C(Y)},clear:()=>ct(),refresh:()=>qt(),togglePick:()=>Be()},()=>{e.panelHandlesRef&&(e.panelHandlesRef.current=null)}});function Be(){if(!e.onPickModeChange)return;const f=!e.pickMode;e.onPickModeChange(f),f?(B.current=null,n(null),j(null),X(null),pe(null),ge.current++,fe.current++,s("")):e.hideNodeHighlight&&e.hideNodeHighlight().catch(()=>{})}function Me(f){B.current=f,n(f)}function ze(f,k,O){const Y=B.current;if(!Y)return;let re=!1;const Ue=(Y.inlineProps||[]).map(We=>We.prop===f?(re=!0,{prop:f,value:k,priority:O||""}):We);re||Ue.push({prop:f,value:k,priority:O||""}),Me({...Y,inlineProps:Ue,rev:(Y.rev||0)+1})}function rt(f){const k=B.current&&B.current.inlineProps||[];return al(f,k.map(O=>O&&O.prop))}function je(f){const k=rt(f);E(O=>{let Y=O;for(const re of k.slice().reverse())Y=ui(Y,re);return Y})}function Ae(f){if(!f||!f.inline)return;const k=f.inline||{},O=f.priorities||{},Y=f.computed||{},re=f.bases||null,Ue=B.current;if(!Ue)return;const We=Object.keys(k).map(F=>({prop:F,value:String(k[F]||""),priority:O[F]==="important"?"important":""})),Oe=(Ue.computed||[]).map(F=>Object.prototype.hasOwnProperty.call(Y,F.prop)?{...F,value:String(Y[F.prop]||"")}:F);Me({...Ue,inlineProps:We,computed:Oe,bases:re||Ue.bases||null,rev:(Ue.rev||0)+1})}async function et(){const f=B.current&&B.current.objectId;if(!(!f||!e.readElementStyles))try{Ae(await e.readElementStyles(f))}catch{}}async function Je(){await et();const f=B.current&&B.current.objectId;f&&await V({objectId:f})}async function ke(f,k,O){if(!e.setInlineStyleProperty)throw new Error("not connected");const Y=B.current&&B.current.objectId;if(!Y)throw new Error("element not resolved");const re=(B.current&&B.current.inlineProps||[]).filter(Tt=>Tt.prop===f)[0],Ue=re&&re.value||"",We=re&&re.priority||"",Oe=await e.setInlineStyleProperty(Y,f,k,O),F=Oe&&Oe.priority||"";e.onRecordChange&&e.onRecordChange({prop:f,from:Ue,to:k,fromPriority:We,toPriority:F}),ze(f,k,F),await Je(),je(f),Ze()}async function Re(f,k){try{await ke(f,k)}catch(O){s(O&&O.message||"Could not set "+f)}}async function it(f){if(!e.removeInlineStyleProperty)throw new Error("not connected");const k=B.current&&B.current.objectId;if(!k)throw new Error("element not resolved");const O=(B.current&&B.current.inlineProps||[]).filter(We=>We.prop===f)[0],Y=O&&O.value||"",re=O&&O.priority||"",Ue=rt(f);await e.removeInlineStyleProperty(k,f),e.onRecordChange&&e.onRecordChange({prop:f,from:Y,to:"",fromPriority:re,toPriority:""}),B.current&&Me({...B.current,inlineProps:B.current.inlineProps.filter(We=>We.prop!==f),rev:(B.current.rev||0)+1}),E(We=>Ue.reduce((Oe,F)=>In(Oe,F),We)),await Je(),Ze()}function Wt(f){const k=rt(f);E(O=>k.reduce((Y,re)=>In(Y,re),O))}function qt(){const f=B.current&&B.current.objectId;f&&G(()=>e.refreshNodeModel(f))}function ct(){Z.current=e.restoreObjectId||Z.current,B.current=null,J.current++,ge.current++,fe.current++,n(null),j(null),N(!1),X(null),pe(null),c(null),d(!1),s(""),e.onSelectionReset&&e.onSelectionReset(),e.onCleared&&e.onCleared(),E([]),e.hideNodeHighlight&&e.hideNodeHighlight().catch(()=>{})}if(!t){const f=e.previewVisible===!1;return o("div",{class:"inspector__styles",role:"group","aria-label":"Element styles"},o("div",{class:"inspector__styles-empty",role:"status"},o("p",{class:"inspector__styles-intro"},"Select an element to edit its inline CSS and read the result here."),e.pickMode?o("p",{class:"inspector__styles-or"},f?"The Preview panel is hidden — use a selector below.":"Now tap the element in the live preview."):null,o("button",{class:"inspector__styles-tap"+(e.pickMode?" is-on":""),type:"button","aria-pressed":String(!!e.pickMode),disabled:f&&!e.pickMode,title:f&&!e.pickMode?"Turn the Preview panel on to pick elements from the page":e.pickMode?"Pick mode on — tap the preview to select":"Pick mode off — tap the preview to select",onClick:Be},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M5 3l14 7-6.5 1.5L10 19 5 3Z",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linejoin":"round"})),o("span",null,e.pickMode?"Selecting…":"Tap element")),o("p",{class:"inspector__styles-or"},"or type a selector"),o("div",{class:"inspector__styles-select"},o("input",{class:"input inspector__styles-sel",type:"text",value:y,placeholder:"#hero, .card, button",autocapitalize:"off",autocorrect:"off",spellcheck:!1,enterkeyhint:"go",onInput:k=>_(k.currentTarget.value),onKeydown:k=>{k.key==="Enter"&&Fe()}}),o("button",{class:"btn inspector__styles-sel-go",type:"button",disabled:r||!(y||"").trim(),onClick:Fe},r?"…":"Select")),l?o("p",{class:"inspector__style-error",role:"alert"},l):null))}const He=kr(t.node),ut=aa(Sr(t.box)),Zt=t.bases?{rootFontSize:t.bases.root,parentFontSize:t.bases.parent,fontSize:t.bases.self}:{},ot=t.inlineProps||[],Ve=t.computed||[],ft=Er(()=>Bi({rules:ae&&ae.rules||[],computed:Ve}),[ae,Ve]),Kt=Fn(ot,p),Gt=Fn(Ve,p),Ct=new Set(ot.map(f=>f.prop)),Pt=new Set(p),tt=gi(Gt,{query:Ce,filter:Pe,setNames:Ct,changedNames:Pt}),Rt=Lr(tt,_e),$t=tt.slice(0,Rt),ht=vi(tt,_e);return M.current=ht,o("div",{class:"inspector__styles",ref:H,role:"group","aria-label":"Element styles",onScroll:Ie},o("div",{class:"inspector__styles-pin",ref:se},o("button",{class:"inspector__styles-elem",type:"button",title:"Copy the selector "+He+(ut?" · "+ut:""),"aria-label":"Copy selector "+He,onClick:()=>{e.onCopyElement&&e.onCopyElement(He)}},o("span",{class:"inspector__styles-elem-name"},He),ut?o("span",{class:"inspector__styles-elem-size"},ut):null),l?o("p",{class:"inspector__style-error",role:"alert"},l):null),R?o("div",{class:"inspector__styles-shotwrap"},o("button",{class:"inspector__styles-shot",type:"button",title:"Tap to refresh the element preview","aria-label":"Refresh the element preview for "+He,disabled:K,onClick:Ze},o("img",{class:"inspector__styles-shot-img",src:R.src,alt:"Preview of "+He,draggable:"false"})),o("p",{class:"inspector__styles-shot-note",role:"status"},o("span",null,K?"Updating…":"Live element preview — tap to refresh"),o("span",{class:"inspector__styles-shot-dims"},R.width&&R.height?R.width+"×"+R.height:""))):null,o(ua,{receipt:q,busy:!1,onUndo:f=>{Wt(f.prop),e.onUndo&&e.onUndo(f)},onUndoAll:()=>{E([]),e.onUndoAll&&e.onUndoAll()},onEditRow:f=>c({prop:f.prop,value:f.to})}),D&&(D.ancestors&&D.ancestors.length||D.children&&D.children.length)?o("div",{class:"inspector__styles-section"},o("h3",{class:"inspector__styles-h"},"Element tree"),o("p",{class:"inspector__styles-tree-hint"},"Tap a chip to select that element — the highlighted chip is this one."),D.ancestors&&D.ancestors.length?o("div",{class:"inspector__styles-tree-row inspector__styles-tree-row--parents"},o("span",{class:"inspector__styles-tree-label"},o("span",{class:"inspector__styles-tree-arrow","aria-hidden":"true"},"↑"),"Parents"),o("div",{class:"inspector__styles-crumbs-wrap"},de?o("span",{class:"inspector__styles-crumbs-more","aria-hidden":"true"},"‹"):null,o("div",{class:"inspector__styles-crumbs",ref:$,onScroll:be,role:"group","aria-label":"Parent elements, root first"},D.ancestors.slice().reverse().reduce((f,k)=>f.concat([o("button",{class:"inspector__styles-crumb",type:"button",key:"anc-"+k.levels,title:"Select "+k.label,"aria-label":"Select parent element "+k.label,onClick:()=>C(k.levels)},o("span",{class:"inspector__styles-crumb-label"},k.label)),o("span",{class:"inspector__styles-crumb-sep","aria-hidden":"true",key:"sep-"+k.levels},"›")]),[]).concat([o("span",{class:"inspector__styles-crumb is-here",key:"here","aria-current":"true",title:"This element: "+He},o("span",{class:"inspector__styles-crumb-label"},He))])))):null,D.children&&D.children.length?o("div",{class:"inspector__styles-tree-row"},o("button",{class:"inspector__styles-kids-toggle",type:"button","aria-expanded":String(oe),"aria-label":(oe?"Hide":"Show")+" the "+D.childCount+" child element"+(D.childCount===1?"":"s")+" of "+He,title:oe?"Hide the children":"Show the children",onClick:()=>Ne(!oe)},o("span",{class:"inspector__styles-kids-caret","aria-hidden":"true"},oe?"▾":"▸"),o("span",{class:"inspector__styles-tree-arrow","aria-hidden":"true"},"↓"),o("span",{class:"inspector__styles-kids-label"},D.childCount===1?"1 child":D.childCount+" children")),oe?o("div",{class:"inspector__styles-kids",role:"group","aria-label":"Child elements"},D.children.map((f,k)=>o("button",{class:"inspector__styles-kid",type:"button",key:"kid-"+k,title:"Select "+f.label,"aria-label":"Select child element "+f.label,onClick:()=>P(k)},o("span",{class:"inspector__styles-kid-label"},f.label))),D.childCount>D.children.length?o("span",{class:"inspector__styles-kids-more"},"+"+(D.childCount-D.children.length)+" more"):null):null):null):null,o("div",{class:"inspector__styles-section"},o("h3",{class:"inspector__styles-h"},"Style controls"),o(Ul,{key:"touch-"+(t&&t.objectId||"none"),ctx:{declared:ot,computed:Ve},unitCtx:Zt,label:He,swatchesFor:f=>kt(ft,f,6).map(k=>k.value),onApply:Re,onEdit:(f,k)=>c({prop:f,value:k}),onAddProperty:()=>d(f=>!f),addOpen:u,disabled:r,tabsRef:Te,revealRef:we,onGroupChange:ye})),o(ql,{open:u,ctx:{declared:ot,computed:Ve},suggestions:pa,onClose:()=>d(!1),onPick:f=>{d(!1),c({prop:f.prop,value:f.isSet?f.value:""})}}),o("div",{class:"inspector__styles-section"},o("h3",{class:"inspector__styles-h"},"Declared styles"),ot.length?o("ul",{class:"inspector__styles-list"},Kt.map(f=>o("li",{class:"inspector__styles-row inspector__styles-row--declared"+(Et(p,f.prop)?" inspector__styles-row--changed":""),key:(t.rev||0)+":"+f.prop},o("button",{class:"inspector__styles-row-main",type:"button","aria-label":(Et(p,f.prop)?"Changed. ":"")+(f.value?"Edit "+f.prop+", value "+f.value:"Edit "+f.prop),title:"Edit "+f.prop,onClick:()=>c({prop:f.prop,value:f.value,priority:f.priority||""})},o("span",{class:"inspector__styles-prop"},f.prop),Et(p,f.prop)?o("span",{class:"inspector__styles-changed","aria-hidden":"true"},"changed"):null,f.priority==="important"?o("span",{class:"inspector__styles-important",title:"Stored as !important on this element"},"!important"):null,_r(f.prop,f.value),o("span",{class:"inspector__styles-val"},f.value||""))))):o("p",{class:"inspector__styles-none"},"No inline styles yet.",o("br"),"Tap Add property above to set one.")),o("div",{class:"inspector__styles-section"},o(ma,{rules:ae?ae.rules:null,counts:ae?ae.counts:null,truncated:ae?ae.truncated:0,busy:xe,open:U,showUa:De,selectionKey:t.objectId,onToggle:()=>le(!U),onToggleUa:()=>z(!De),onEdit:(f,k)=>c({prop:f,value:k})})),o("div",{class:"inspector__styles-section"},o("div",{class:"inspector__computed-bar"},o("h3",{class:"inspector__styles-h"},"Computed"),o("span",{class:"inspector__computed-count"},tt.length+"/"+Ve.length),o("div",{class:"inspector__computed-showgroup"},o("span",{class:"inspector__computed-show","aria-hidden":"true"},"Show"),o("div",{class:"inspector__computed-filters",role:"group","aria-label":"Filter computed properties"},Ar.map(f=>o("button",{class:"inspector__computed-filter"+(Pe===f.id?" is-on":""),type:"button",key:f.id,"aria-pressed":String(Pe===f.id),title:"Show "+f.hint,"aria-label":"Show "+f.hint,onClick:()=>ee(f.id)},f.label))))),o("div",{class:"inspector__computed-searchrow"},o("input",{class:"input inspector__computed-search",type:"search",value:Ce,placeholder:"Filter property or value…","aria-label":"Filter computed properties by name or value",autocapitalize:"off",autocorrect:"off",spellcheck:!1,onInput:f=>Q(f.currentTarget.value)}),Ce?o("button",{class:"inspector__computed-clear",type:"button","aria-label":"Clear the computed filter",title:"Clear the computed filter",onClick:()=>Q("")},"✕"):null),o("p",{class:"inspector__computed-status",role:"status"},_i({filter:Pe,shown:tt.length,total:Ve.length,query:Ce})),tt.length?[o("ul",{class:"inspector__styles-list inspector__styles-list--computed",key:"list"},$t.map(f=>{const k=Et(p,f.prop),O=[o("span",{class:"inspector__styles-prop"},f.prop),k?o("span",{class:"inspector__styles-changed","aria-hidden":"true"},"changed"):null,_r(f.prop,f.value),o("span",{class:"inspector__styles-val"},f.value||"")];return o("li",{class:"inspector__styles-row inspector__styles-row--computed"+(k?" inspector__styles-row--changed":""),key:f.prop},k?o("button",{class:"inspector__styles-row-main",type:"button","aria-label":"Changed. Edit "+f.prop+", value "+(f.value||""),title:"Edit "+f.prop,onClick:()=>c({prop:f.prop,value:f.value})},O):O)})),ht>0?o("button",{class:"inspector__computed-more",type:"button",key:"more",onClick:()=>te(_e+1)},"Show "+ht+" more of "+tt.length):_e>0?o("button",{class:"inspector__computed-more",type:"button",key:"less",onClick:()=>te(0)},"Collapse to the first "+Rt):null]:o("p",{class:"inspector__styles-none",role:"status"},wi({query:Ce,filter:Pe}))),a?o(ha,{key:"sheet-"+a.prop,prop:a.prop,value:a.value,priority:a.priority||"",isInline:!0,isRemove:ot.some(f=>f.prop===a.prop),box:t.box,declared:ot,valueIndex:ft,colourCandidates:kt(ft,a.prop,8),from:(()=>{const f=(e.receipt||[]).find(k=>k.prop===a.prop);return f?f.from:null})(),shot:R&&R.src,shotBusy:K,unitCtx:t.bases?{rootFontSize:t.bases.root,parentFontSize:t.bases.parent,fontSize:t.bases.self}:void 0,contrastCtx:(()=>{const f=O=>{const Y=Ve.find(re=>re.prop===O);return Y?Y.value:""},k=f("background-color");return{bg:k,color:f("color"),fallbackBg:/rgba?\(0,\s*0,\s*0,\s*0\)|transparent/i.test(k)?f("background-color"):""}})(),onRefreshShot:Ze,readSiblings:e.readSiblingValues&&t.objectId?f=>e.readSiblingValues(t.objectId,f):null,onApply:ke,onRemove:it,onDone:()=>c(null),onCancel:()=>c(null)}):null)}function ba(e){const t=e.item;if(!t)return null;const n=t.kind==="request",r=typeof e.onAddToChat=="function",i=!r||!!e.addToChatDisabled,l=e.addToChatLabel||"Add to chat";function s(c){return o("dl",{class:"inspector__kv"},c.map(([u,d])=>o(nt,{key:u},o("dt",null,u),o("dd",null,d==null||d===""?"—":String(d)))))}function a(c,u){return!u||!Object.keys(u).length?null:o(nt,null,o("h3",{class:"inspector__sheet-h"},c),o("pre",{class:"inspector__headers"},Object.keys(u).map(d=>d+": "+u[d]).join(`
12
+ `)))}return Cn(o("div",{class:"inspector__overlay",onClick:e.onClose},o("div",{class:"inspector__sheet",role:"dialog","aria-label":"Details",onClick:c=>c.stopPropagation()},o("div",{class:"inspector__sheet-head"},o("strong",{class:"inspector__sheet-title"},n?t.method+" "+wn(t.status):(t.level||"log").toUpperCase()),o("div",{class:"inspector__sheet-head-actions"},o("button",{class:"btn btn--primary inspector__sheet-add-chat",type:"button",disabled:i,title:r?"Add this entry to a chat draft":"Chats are unavailable",onClick:c=>{c.stopPropagation(),r&&e.onAddToChat()}},l),o("button",{class:"btn inspector__sheet-close",type:"button",onClick:e.onClose},"Close"))),o("div",{class:"inspector__sheet-body"},n?o(nt,null,s([["URL",t.url],["Type",t.type],["MIME",t.mimeType],["Size",_t(t.size)],["Encoded",_t(t.encodedSize)],["Duration",_n(t.duration)],["Remote",t.ip?t.ip+(t.port?":"+t.port:""):""],["Protocol",t.protocol],["From cache",t.fromCache?"yes":"no"],["Error",t.statusText]]),a("Request headers",t.requestHeaders),a("Response headers",t.responseHeaders),o("h3",{class:"inspector__sheet-h"},"Response body"),o("pre",{class:"inspector__body"},t.bodyLoading?"loading…":t.body!==void 0&&t.body!==null&&t.body!==""?t.body:"(no body captured)"),o("button",{class:"btn",type:"button",onClick:e.onLoadBody},"Fetch body")):o(nt,null,s([["Time",vn(t.ts)],["Level",t.level],["Source",t.url?t.url+(t.line?":"+t.line:""):""]]),o("h3",{class:"inspector__sheet-h"},"Message"),o("pre",{class:"inspector__body"},t.text||""),t.stack?o(nt,null,o("h3",{class:"inspector__sheet-h"},"Stack trace"),o("pre",{class:"inspector__body"},t.stack)):null)))))}function ya(){const e={current:null},t={current:null},n={current:1},r=new Map,i=new Map;function l(d,y,_){const R=e.current;if(!R||R.readyState!==1)return Promise.reject(new Error("not connected"));const j=n.current++,K=JSON.stringify({id:j,method:d,params:y||{}});return new Promise((N,p)=>{const E={resolve:N,reject:p,timer:null};Number.isFinite(_)&&_>0&&(E.timer=setTimeout(()=>{if(!r.delete(j))return;const q=new Error(d+" timed out");q.code="ETIMEDOUT",p(q)},_)),r.set(j,E);try{R.send(K)}catch(q){r.delete(j),E.timer&&clearTimeout(E.timer),p(q)}})}function s(d,y){let _=i.get(d);return _||(_=new Set,i.set(d,_)),_.add(y),()=>_.delete(y)}function a(d){let y;try{y=JSON.parse(d.data)}catch{return}if(typeof y.id=="number"){const _=r.get(y.id);_&&(r.delete(y.id),_.timer&&clearTimeout(_.timer),y.error?_.reject(Object.assign(new Error(y.error.message||"CDP error"),{code:y.error.code})):_.resolve(y.result||{}));return}if(typeof y.method=="string"){const _=i.get(y.method);if(_)for(const R of _)try{R(y.params||{})}catch{}}}function c(){const d=e.current;if(e.current=null,d)try{d.close(1e3,"client disconnect")}catch{}for(const y of r.values()){y.timer&&clearTimeout(y.timer);try{y.reject(new Error("disconnected"))}catch{}}r.clear(),i.clear()}function u(d,y){e.current&&c();const _=encodeURIComponent(d),R=encodeURIComponent(y),K=(window.location.protocol==="https:"?"wss:":"ws:")+"//"+window.location.host+"/api/inspector/proxy?host="+_+"&targetId="+R;let N;try{N=new WebSocket(K)}catch(p){return{error:"WebSocket open failed: "+(p.message||p)}}return e.current=N,N.addEventListener("message",a),N.addEventListener("error",()=>{}),N.addEventListener("close",p=>{p&&typeof p.reason=="string"&&p.reason&&p.reason!=="client disconnect"&&(e.current=null,t.current=p.reason)}),{ws:N,cdpSend:l,cdpOn:s,disconnect:()=>c()}}return{wsRef:e,cdpSend:l,cdpOn:s,connect:u,disconnect:c,pending:r,listeners:i,cmdId:n,lastProxyError:t}}function va(e){const{consoleEntries:t,networkEntries:n,reqMap:r,consoleVL:i,networkVL:l,cdpSend:s,onNavigate:a}=e,c=e.consoleCountRef||{current:null},u=e.networkCountRef||{current:null};function d(m){m.rev=(m.rev||0)+1}const y=2e3;function _(m,g){const S=m.current.length-y;if(S<=0)return;const C=m.current.splice(0,S);for(const P of C)P&&(P.body=null,P.args=null,g&&P.requestId&&g.current.get(P.requestId)===P&&g.current.delete(P.requestId))}function R(){_(t,null);const m=t.current.slice(-y),g=i.current;if(g)try{g.setData(m),g.scrollToIndex(m.length-1)}catch{i.current=null}c.current&&c.current(m.length)}function j(){_(n,r);const m=n.current.slice(-y),g=l.current;if(g)try{g.setData(m)}catch{l.current=null}u.current&&u.current(m.length)}function K(m){const g=m.args||[],S=g.map(Ko).join(" "),C=Date.now(),P={id:"c"+C+"-"+t.current.length,kind:"console",level:m.type||"log",text:S,args:g.slice(0,8),url:null,line:null,stack:null,ts:C},x=m.stackTrace&&m.stackTrace.callFrames;x&&x.length&&(P.url=x[0].url||null,P.line=x[0].lineNumber!=null?x[0].lineNumber+1:null,P.stack=x.map(V=>" at "+(V.functionName||"(anon)")+" ("+(V.url||"")+":"+((V.lineNumber||0)+1)+":"+((V.columnNumber||0)+1)+")").join(`
13
+ `)),t.current.push(P),R()}async function N(m){const g=Date.now(),S=()=>"c"+g+"-"+t.current.length;if(!s||!m||!String(m).trim())return null;let C;try{const P=await s("Runtime.evaluate",{expression:String(m),includeCommandLineAPI:!0,returnByValue:!0,awaitPromise:!0,objectGroup:"mouaif-console"});C={id:S(),kind:"console",level:"info",text:"",args:[],url:null,line:null,stack:null,ts:g};const x=P&&P.result;if(P&&P.exceptionDetails){const V=P.exceptionDetails;C.level="error",C.text=V.exception&&(V.exception.description||V.exception.value)||V.text||"Uncaught exception",V.exception&&(C.args=[V.exception]);const G=V.stackTrace&&V.stackTrace.callFrames;G&&G.length&&(C.url=G[0].url||null,C.line=G[0].lineNumber!=null?G[0].lineNumber+1:null,C.stack=G.map(he=>" at "+(he.functionName||"(anon)")+" ("+(he.url||"")+":"+((he.lineNumber||0)+1)+":"+((he.columnNumber||0)+1)+")").join(`
14
+ `))}else if(x&&typeof x.value<"u"){let V;try{V=typeof x.value=="string"?x.value:JSON.stringify(x.value)}catch{V=x.description||String(x.value)}C.text=V,typeof x.value=="string"&&(C.args=[{type:"string",value:x.value}])}else x&&(x.description||x.objectId)?(C.text=x.description||"",C.args=[x]):(C.text="undefined",C.args=[{type:"undefined"}])}catch(P){C={id:S(),kind:"console",level:"error",text:"Runtime.evaluate failed: "+(P&&P.message||P),args:[],url:null,line:null,stack:null,ts:g}}return t.current.push(C),R(),C}function p(m){const g=m.exceptionDetails||{},S=g.exception&&(g.exception.description||g.exception.value)||g.text||"exception",C=Date.now(),P={id:"c"+C+"-"+t.current.length,kind:"exception",level:"error",text:S,args:g.exception?[g.exception]:[],url:g.url||null,line:g.lineNumber!=null?g.lineNumber+1:null,stack:null,ts:C},x=g.stackTrace&&g.stackTrace.callFrames;x&&x.length&&(P.stack=x.map(V=>" at "+(V.functionName||"(anon)")+" ("+(V.url||"")+":"+((V.lineNumber||0)+1)+":"+((V.columnNumber||0)+1)+")").join(`
15
+ `)),t.current.push(P),R()}function E(m){const g=m.request||{},S={id:"n"+(m.requestId||"")+"-"+r.current.size,requestId:m.requestId,kind:"request",method:g.method||"GET",url:g.url||"",status:"pending",type:(m.type||"").toLowerCase()||null,initiator:m.initiator&&m.initiator.url||null,requestHeaders:g.headers||null,ts:Date.now(),_start:typeof m.timestamp=="number"?m.timestamp:null,duration:null,size:null,encodedSize:null,mimeType:null,ip:null,port:null,protocol:null,fromCache:!1,body:null,bodyLoading:!1};r.current.set(m.requestId,S),n.current.push(S),j()}function q(m){const g=m.response||{},S=r.current.get(m.requestId);S&&(S.status=g.status||0,S.statusText=g.statusText||"",S.type=(m.type||"").toLowerCase()||S.type,S.mimeType=g.mimeType||null,S.responseHeaders=g.headers||null,S.encodedSize=typeof g.encodedDataLength=="number"?g.encodedDataLength:null,S.ip=g.remoteIPAddress||null,S.port=g.remotePort||null,S.protocol=g.protocol||null,S.fromCache=!!(g.fromDiskCache||g.fromServiceWorker||g.fromPrefetchCache),d(S),j())}function Z(m){const g=r.current.get(m.requestId);g&&(g.duration=typeof m.timestamp=="number"&&g._start!=null?Math.round((m.timestamp-g._start)*1e3):null,typeof m.encodedDataLength=="number"&&(g.encodedSize=m.encodedDataLength,g.size=m.encodedDataLength),d(g),j())}function D(m){const g=r.current.get(m.requestId);g&&(g.status="failed",g.statusText=m.errorText||"failed",d(g),j())}const X={tail:Promise.resolve(),depth:0};function B(m){X.depth++;const g=X.tail.then(m,m);return X.tail=g.then(()=>{X.depth--},()=>{X.depth--}),g}let ge;function $(){if(ge===void 0)return Promise.resolve();const m=ge;return m?s("Emulation.setDeviceMetricsOverride",{width:m.width,height:m.height,deviceScaleFactor:m.deviceScaleFactor||1,mobile:!!m.mobile,screenWidth:m.width,screenHeight:m.height},8e3):s("Emulation.clearDeviceMetricsOverride",{},8e3)}async function ue(m){const g=await B(()=>s("Page.captureScreenshot",m,8e3));if(m.clip)try{await B(()=>$())}catch{}return g}function de(m){const g={format:"png",captureBeyondViewport:e.captureBeyondViewport!==!1};return m&&m.clip&&(g.clip=m.clip),ue(g)}function ie(){return s("Page.startScreencast",{format:"jpeg",quality:20,maxWidth:320,maxHeight:320,everyNthFrame:1})}function be(){return s("Page.stopScreencast")}function H(m){return s("Page.screencastFrameAck",{sessionId:m})}async function se(m){if(ge=m&&m.width?m:null,!m){await s("Emulation.clearDeviceMetricsOverride");return}await s("Emulation.setDeviceMetricsOverride",{width:m.width,height:m.height,deviceScaleFactor:m.deviceScaleFactor||1,mobile:!!m.mobile,screenWidth:m.width,screenHeight:m.height})}async function Te(m,g){let S=0,C=0,P=1;try{const Me=await s("Runtime.evaluate",{expression:"({ sx: window.scrollX || 0, sy: window.scrollY || 0, dpr: window.devicePixelRatio || 1 })",returnByValue:!0}),ze=Me&&Me.result&&Me.result.value;ze&&typeof ze=="object"&&(S=ze.sx||0,C=ze.sy||0,P=ze.dpr||1)}catch{}const x=m/P,V=g/P,G=typeof window<"u"&&window.innerHeight||0;let he=Math.round(x-S),Fe=Math.round(V-C),Be=C;if(G>0&&(Fe<0||Fe>G)&&(Be=Math.max(0,Math.round(V-G/2))),Be!==C)try{await s("Runtime.evaluate",{expression:"window.scrollTo(0, "+Be+")"}),Fe=Math.round(V-Be)}catch{}return{x:he,y:Fe}}async function we(m,g){const S=await Te(m,g);return s("Input.dispatchMouseEvent",{type:"mousePressed",x:S.x,y:S.y,button:"left",clickCount:1}).then(()=>s("Input.dispatchMouseEvent",{type:"mouseReleased",x:S.x,y:S.y,button:"left",clickCount:1})).then(()=>!0).catch(C=>{throw C})}async function ce(m,g){const S=await Te(m,g),C=await s("Runtime.evaluate",{expression:"(function(){ var e = document.elementFromPoint("+Math.round(S.x)+","+Math.round(S.y)+"); return e; })()",objectGroup:"mouaif-pick",returnByValue:!1},8e3),P=C&&C.result&&C.result.objectId;return P?fe(P):null}const ye='function ml(n){ if(!n||!n.nodeName) return ""; var s=String(n.nodeName).toLowerCase(); if(n.id) s+="#"+n.id; var c=(typeof n.className==="string")?n.className.trim().split(/\\s+/).filter(Boolean):[]; if(c.length) s+="."+c.slice(0,2).join("."); if(c.length>2) s+="…"; return s; }',Se=8,ae=6;async function pe(m){if(!m)return 0;try{const g=await s("DOM.requestNode",{objectId:m},8e3);return g&&g.nodeId||0}catch{return 0}}async function xe(m){if(!m)return null;try{const g=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(){ "+ye+" var anc=[],n=this.parentElement,lv=1; while(n && lv<="+Se+"){ anc.push({ label: ml(n), levels: lv }); n=n.parentElement; lv++; } var k=this.children||[],kids=[]; for(var i=0;i<k.length && i<"+ae+";i++){ kids.push({ label: ml(k[i]) }); } return { ancestors: anc, children: kids, childCount: k.length, label: ml(this) }; }",returnByValue:!0},8e3);return g&&g.result&&g.result.value||null}catch{return null}}async function v(m,g){const S=Math.max(1,Math.min(Se,Number(g)||1)),C=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(n){ var e=this; for(var i=0;i<n && e;i++){ e=e.parentElement; } return e || null; }",arguments:[{value:S}],returnByValue:!1},8e3),P=C&&C.result&&C.result.objectId;return P?fe(P):null}async function U(m,g){const S=Math.max(0,Number(g)||0),C=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(i){ var k=this.children||[]; return k[i] || null; }",arguments:[{value:S}],returnByValue:!1},8e3),P=C&&C.result&&C.result.objectId;return P?fe(P):null}const le='function(){function nth(n){ var i=1,s=n; while((s=s.previousElementSibling)) i++; return i; }function esc(v){ return (window.CSS && CSS.escape) ? CSS.escape(v) : v; }function unique(sel){ try { return document.querySelectorAll(sel).length === 1; } catch (e) { return false; } }var el=this, parts=[];while(el && el.nodeType===1){if(el.id && unique("#"+esc(el.id))){ parts.unshift("#"+esc(el.id)); break; }var p=el.nodeName.toLowerCase(), parent=el.parentElement;if(parent){var same=0, k=parent.children;for(var i=0;i<k.length;i++){ if(k[i].nodeName===el.nodeName) same++; }if(same>1) p+=":nth-of-type("+nth(el)+")";}parts.unshift(p);el=parent;if(parts.length>=32) break;}return parts.join(" > ");}';async function De(m){if(!m)return 0;const g=await pe(m);if(g)return g;let S="";try{const C=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:le,returnByValue:!0},8e3);S=C&&C.result&&C.result.value||""}catch{return 0}if(!S)return 0;try{const C=await s("DOM.getDocument",{depth:0},8e3),P=C&&C.root&&C.root.nodeId;if(!P)return 0;const x=await s("DOM.querySelector",{nodeId:P,selector:S},8e3);return x&&x.nodeId||0}catch{return 0}}const z=`function(){
16
+ var el = this;
17
+ var RULE_BUDGET = 20000;
18
+ function decl(cs){
19
+ var out = [], n = (cs && cs.length) || 0;
20
+ for (var i = 0; i < n; i++){
21
+ var p = cs.item(i);
22
+ if (!p) continue;
23
+ out.push({ name: p, value: cs.getPropertyValue(p), important: cs.getPropertyPriority(p) === "important" });
24
+ }
25
+ return out;
26
+ }
27
+ function collect(node, list, cond, sink, seen){
28
+ for (var i = 0; i < list.length; i++){
29
+ var r = list[i];
30
+ if (!r) continue;
31
+ if (r.cssRules){
32
+ cond = r.conditionText ? (cond ? cond + " and " + r.conditionText : r.conditionText) : cond;
33
+ seen = collect(node, r.cssRules, cond, sink, seen);
34
+ continue;
35
+ }
36
+ if (!r.selectorText) continue;
37
+ if (++seen > RULE_BUDGET) return seen;
38
+ var hit = false;
39
+ try { hit = node.matches(r.selectorText); } catch (e) { hit = false; }
40
+ if (!hit) continue;
41
+ var props = decl(r.style);
42
+ if (!props.length) continue;
43
+ sink.push({ rule: {
44
+ selectorList: { selectors: [{ text: r.selectorText }] },
45
+ origin: "regular",
46
+ media: cond ? [{ text: cond }] : [],
47
+ style: { cssProperties: props }
48
+ } });
49
+ }
50
+ return seen;
51
+ }
52
+ var chain = [], up = el.parentElement;
53
+ while (up && chain.length < 8){ chain.push(up); up = up.parentElement; }
54
+ var sheets = document.styleSheets || [];
55
+ var scan = function(node){
56
+ var sink = [], seen = 0;
57
+ for (var s = 0; s < sheets.length; s++){
58
+ var list = null;
59
+ try { list = sheets[s].cssRules; } catch (e) { continue; }
60
+ seen = collect(node, list, "", sink, seen);
61
+ if (seen > RULE_BUDGET) break;
62
+ }
63
+ return sink;
64
+ };
65
+ var inherited = [];
66
+ for (var c = 0; c < chain.length; c++){
67
+ inherited.push({ inlineStyle: { cssProperties: decl(chain[c].style) }, matchedCSSRules: scan(chain[c]) });
68
+ }
69
+ return { inlineStyle: { cssProperties: decl(el.style) }, matchedCSSRules: scan(el), inherited: inherited };
70
+ }`;function oe(m){return m?!!(m.inlineStyle||m.matchedCSSRules&&m.matchedCSSRules.length||m.inherited&&m.inherited.length):!1}async function Ne(m){if(!m)return null;const g=await xe(m),S=g&&g.ancestors||[];let C=null;const P=await De(m);if(P)try{C=await s("CSS.getMatchedStylesForNode",{nodeId:P},8e3)}catch{C=null}if(!oe(C))try{const x=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:z,returnByValue:!0},8e3),V=x&&x.result&&x.result.value;V&&(C=V)}catch{}return la(C,{ancestors:S})}async function fe(m){if(!m)return null;const g={objectId:m,node:null,inlineProps:[],computed:[],box:null};try{const C=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:'function(){ var cs = getComputedStyle(this); var inline=[]; for (var i=0;i<this.style.length;i++){ var p=this.style.item(i); inline.push([p, this.style.getPropertyValue(p), this.style.getPropertyPriority(p)]); } var computed=[]; for (var j=0;j<cs.length;j++){ var q=cs.item(j); computed.push([q, cs.getPropertyValue(q)]); } var r=this.getBoundingClientRect(); var cls=(typeof this.className==="string")?this.className:""; var root=null, parent=null; try { root=parseFloat(getComputedStyle(document.documentElement).fontSize)||null; } catch(e){ root=null; } try { var pe=this.parentElement; parent=pe?parseFloat(getComputedStyle(pe).fontSize)||null:null; } catch(e){ parent=null; } if (parent==null) parent=parseFloat(cs.fontSize)||null; return { tag:this.nodeName, id:this.id||"", className:cls, inline:inline, computed:computed, width:r.width, height:r.height, bases:{ root:root, parent:parent, self:parseFloat(cs.fontSize)||null } }; }',returnByValue:!0}),P=C&&C.result&&C.result.value;P&&(g.node={nodeName:P.tag,attributes:[{name:"id",value:P.id||""},{name:"class",value:P.className||""}]},g.inlineProps=(P.inline||[]).map(x=>({prop:x[0],value:String(x[1]||""),priority:x[2]==="important"?"important":""})),g.computed=(P.computed||[]).map(x=>({prop:x[0],value:String(x[1]||"")})).sort((x,V)=>x.prop<V.prop?-1:x.prop>V.prop?1:0),g.box={width:P.width,height:P.height},g.bases=P.bases||null)}catch{}const S=await De(m);if(S)try{await s("Overlay.highlightNode",{nodeId:S,highlightConfig:{showInfo:!0,showStyles:!1,contentColor:{r:110,g:168,b:254,a:.3},paddingColor:{r:110,g:168,b:254,a:.15},borderColor:{r:110,g:168,b:254,a:.6}}})}catch{}return g}async function Xe(m,g){if(!m)return null;const S=Math.max(0,Math.min(48,g&&g.pad||16)),C=Math.max(64,g&&g.maxWidth||480),P=!g||g.scroll!==!1;if(!P&&e.captureBeyondViewport===!1)return null;let x=null;try{const Je=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(){ if(!this.getBoundingClientRect) return null;"+(P?' try { this.scrollIntoView({ block: "center", inline: "nearest" }); } catch (e) { try { this.scrollIntoView(); } catch (e2) { return null; } }':"")+" var b = this.getBoundingClientRect(); return { x: b.x, y: b.y, width: b.width, height: b.height, sx: window.scrollX || 0, sy: window.scrollY || 0, dpr: window.devicePixelRatio || 1 }; }",returnByValue:!0},8e3);x=Je&&Je.result&&Je.result.value}catch{return null}if(!x||!(x.width>0)||!(x.height>0))return null;const V=e.captureBeyondViewport!==!1,G=V?0:x.sx||0,he=V?0:x.sy||0,Fe=Math.max(120,g&&g.contextWidth||520),Be=Math.max(90,g&&g.contextHeight||360),Me=Math.min(x.width+S*2,Fe),ze=Math.min(x.height+S*2,Be),rt=Math.max(0,x.x+(x.sx||0)-S-G),je=Math.max(0,x.y+(x.sy||0)-S-he);let Ae=Math.min(2,C/Me);(!Number.isFinite(Ae)||Ae<=.05)&&(Ae=.05);let et=null;try{const Je=await ue({format:"png",captureBeyondViewport:V,clip:{x:rt,y:je,width:Me,height:ze,scale:Ae}});et=Je&&Je.data}catch{return null}return et?{data:et,width:Math.max(1,Math.round(Me*Ae)),height:Math.max(1,Math.round(ze*Ae))}:null}async function qe(m){if(!m)return null;const g=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(){ var cs = getComputedStyle(this); var inline = {}; var priorities = {}; var computed = {}; for (var i = 0; i < this.style.length; i++) { var p = this.style.item(i); inline[p] = this.style.getPropertyValue(p); priorities[p] = this.style.getPropertyPriority(p); computed[p] = cs.getPropertyValue(p); } var root = null, parent = null; try { root = parseFloat(getComputedStyle(document.documentElement).fontSize) || null; } catch (e) { root = null; } try { var pe = this.parentElement; if (pe) parent = parseFloat(getComputedStyle(pe).fontSize) || null; } catch (e) { parent = null; } if (parent == null) parent = parseFloat(cs.fontSize) || null; return { inline: inline, priorities: priorities, computed: computed, bases: { root: root, parent: parent, self: parseFloat(cs.fontSize) || null } }; }",returnByValue:!0},8e3);return g&&g.result&&g.result.value||null}const Ce=12;async function Pe(m,g){if(!m||!g)return[];try{const S=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(prop){ var out = []; var parent = this.parentElement; if (!parent) return out; var kids = parent.children; for (var i = 0; i < kids.length && out.length < "+Ce+'; i++) { var k = kids[i]; if (k === this) continue; var v = ""; try { v = getComputedStyle(k).getPropertyValue(prop); } catch (e) { continue; } v = String(v || "").trim(); if (!v) continue; var nth = 1; var s = k; while ((s = s.previousElementSibling)) nth++; var suffix = nth === 1 ? "st" : nth === 2 ? "nd" : nth === 3 ? "rd" : "th"; var cls = (typeof k.className === "string") ? k.className.trim() : ""; var names = cls ? cls.split(/\\s+/).slice(0, 2).join(".") : ""; out.push({ prop: prop, value: v, label: nth + suffix + " " + k.nodeName.toLowerCase() + (names ? "." + names : "") }); } return out;}',arguments:[{value:String(g)}],returnByValue:!0},8e3),C=S&&S.result&&S.result.value;return Array.isArray(C)?C:[]}catch{return[]}}async function _e(){try{await s("Overlay.hideHighlight")}catch{}}async function M(m){return m?fe(m):null}async function Q(m){const g=String(m||"").trim();if(!g)return null;const S=await s("Runtime.evaluate",{expression:"(function(){ var e = document.querySelector("+JSON.stringify(g)+"); return e; })()",objectGroup:"mouaif-pick",returnByValue:!1},8e3),C=S&&S.result&&S.result.objectId;return C?fe(C):null}async function ee(m,g,S,C){if(!m)throw new Error("element not resolved");const P=await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:'function(p, v, pr){ var s = this.style; try { var before = s.cssText; s.setProperty(p, v, pr || ""); var read = s.getPropertyValue(p); var applied = read !== "" || s.cssText !== before; return { ok: true, applied: applied, read: String(read), priority: s.getPropertyPriority(p) }; } catch (e) { return { ok: false, error: String(e) }; }}',arguments:[{value:String(g)},{value:String(S)},{value:C==="important"?"important":""}],returnByValue:!0}),x=P&&P.result&&P.result.value;if(x&&!x.ok)throw new Error(x.error||"setProperty failed");if(x&&x.applied===!1)throw new Error("“"+String(S)+"” is not a valid value for "+String(g)+" — the browser rejected it, so nothing was changed.");return{priority:(x&&x.priority)==="important"?"important":""}}async function te(m,g){if(!m)throw new Error("element not resolved");return await s("Runtime.callFunctionOn",{objectId:m,functionDeclaration:"function(p){ this.style.removeProperty(p); return { ok:true }; }",arguments:[{value:String(g)}],returnByValue:!0}),!0}async function Ie(m){if(m==null)return null;const g=String(m);return g?s("Input.insertText",{text:g}):null}async function J(){const m={key:"Enter",code:"Enter",windowsVirtualKeyCode:13,nativeVirtualKeyCode:13};await s("Input.dispatchKeyEvent",{type:"keyDown",...m,text:"\r",unmodifiedText:"\r"}),await s("Input.dispatchKeyEvent",{type:"keyUp",...m})}async function Le(){const m={netCount:n.current.length};try{const g=await s("Performance.getMetrics"),S=g&&g.metrics||[],C={};for(const P of S)C[P.name]=P.value;m.documents=C.Documents,m.frames=C.Frames,m.nodes=C.Nodes,m.listeners=C.JSEventListeners,m.jsHeap=C.JSHeapUsedSize,m.layoutCount=C.LayoutCount,m.recalcCount=C.RecalcStyleCount}catch{}return m}async function Ee(m){if(!(!m||!m.requestId||m.bodyLoading)){m.bodyLoading=!0,d(m),e.rerender&&e.rerender();try{const g=await s("Network.getResponseBody",{requestId:m.requestId});let S=g&&typeof g.body=="string"?g.body:"";if(g&&g.base64Encoded)try{S=decodeURIComponent(escape(atob(S)))}catch{S=atob(S)}m.body=S.length>2e5?S.slice(0,2e5)+`
71
+ … (truncated)`:S}catch(g){m.body="(failed to fetch body: "+(g&&g.message||g)+")"}finally{m.bodyLoading=!1,d(m),e.rerender&&e.rerender()}}}function Ke(m){const g=m&&m.frame;g&&!g.parentId&&typeof a=="function"&&a(g.url||"",g.name||"")}function Ze(m){m&&m.url&&typeof a=="function"&&a(m.url,"")}return{onConsoleEvent:K,onExceptionEvent:p,onRequestWillBeSent:E,onResponseReceived:q,onLoadingFinished:Z,onLoadingFailed:D,onFrameNavigated:Ke,onNavigatedWithinDocument:Ze,pushConsole:R,pushNetwork:j,captureScreenshot:de,clickAt:we,fetchMetrics:Le,startPreviewStream:ie,stopPreviewStream:be,ackPreviewFrame:H,loadResponseBody:Ee,evaluateExpression:N,setViewportSize:se,insertText:Ie,pressEnter:J,pickNodeAt:ce,hideNodeHighlight:_e,setInlineStyleProperty:ee,removeInlineStyleProperty:te,refreshNodeModel:M,selectBySelector:Q,captureElementShot:Xe,readElementStyles:qe,readSiblingValues:Pe,readElementTree:xe,selectAncestorNode:v,selectChildNode:U,readMatchedRules:Ne}}function uo(e){const t=e&&typeof e.pageTitle=="string"?e.pageTitle.trim():"";if(t)return t;const n=e&&typeof e.pageUrl=="string"?e.pageUrl.trim():"";return n||"the inspected page"}function wa(e){return e.url?"Source: "+e.url+(e.line?":"+e.line:""):""}function _a(e,t){const n=e.level||"log",l=["Inspector "+(e.kind==="exception"?"exception":"console "+n)+" — "+uo(t)],s=[vn(e.ts),String(n).toUpperCase()].filter(Boolean).join(" ");l.push((s?s+" ":"")+(e.text||""));const a=wa(e);return a&&l.push(a),e.stack&&l.push("Stack:",e.stack),l.join(`
72
+ `)}function ka(e,t){const n=wn(e.status),i=["Inspector request "+(e.method||"GET")+" "+n+" — "+uo(t),e.url||""],l=[e.type||"",e.mimeType?String(e.mimeType).split(";")[0]:"",_t(e.size),_n(e.duration)].filter(Boolean);return l.length&&i.push(l.join(" · ")),e.status==="failed"&&e.statusText&&i.push("Error: "+e.statusText),i.join(`
73
+ `)}function Sa(e,t){return!e||typeof e!="object"?"":(e.kind==="request"?ka(e,t):_a(e,t)).trim()}async function xa(e){try{return await navigator.clipboard.writeText(e||""),!0}catch{try{const n=document.createElement("textarea");n.value=e||"",n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}}const Cr={page:{label:"TAB",short:"tab",tone:"accent"},iframe:{label:"FRAME",short:"frame",tone:"accent"},webview:{label:"VIEW",short:"view",tone:"accent"},service_worker:{label:"SW",short:"sw",tone:"warning"},background_page:{label:"BG",short:"bg",tone:"muted"},worker:{label:"WORKER",short:"wrk",tone:"warning"},shared_worker:{label:"SHARED",short:"shr",tone:"warning"},other:{label:"OTHER",short:"?",tone:"muted"}};function po(e){const t=e&&e.type||"other";return Cr[t]||Cr.other}function Ca(e,t){if(!e||e.type!=="page"||!e.id||!Array.isArray(t))return!1;const n=t.find(r=>r&&r.type==="webview"&&r.parentId===e.id&&/^chrome-extension:\/\/mhjfbmdgcfjbbpaeojofohoefgiehjai\//.test(r.url||""));return!n||!n.id?!1:t.some(r=>r&&r.type==="iframe"&&r.parentId===n.id)}function Pr(e){return e?"Close “"+(e.title||(e.url?fo(e):"")||e.id||"this tab")+"”?":"Close this tab?"}function fo(e){const t=e&&e.url||"";if(!t||!/^https?:\/\//i.test(t))return"";try{return new URL(t).host}catch{return""}}const Qe=[{id:"preview",label:"Preview"},{id:"styles",label:"Styles"},{id:"console",label:"Console"},{id:"network",label:"Network"},{id:"overview",label:"Info"}],ho="mouaif:inspector:panels",wt=[{id:"auto",label:"Auto",width:null,height:null},{id:"phone",label:"Phone",width:375,height:667,mobile:!0,deviceScaleFactor:2},{id:"phone+",label:"Phone+",width:414,height:896,mobile:!0,deviceScaleFactor:2},{id:"tablet",label:"Tablet",width:768,height:1024},{id:"laptop",label:"Laptop",width:1280,height:800}],Rr="mouaif:inspector:viewport";function Pa(){try{const e=localStorage.getItem(ho);if(!e)return new Set(Qe.map(i=>i.id));const t=JSON.parse(e);if(!Array.isArray(t))return new Set(Qe.map(i=>i.id));const n=new Set(Qe.map(i=>i.id)),r=new Set(t.filter(i=>n.has(i)));return r.size?r:new Set(Qe.map(i=>i.id))}catch{return new Set(Qe.map(e=>e.id))}}function Tr(e){try{localStorage.setItem(ho,JSON.stringify(Array.from(e)))}catch{}}const Ra="mouaif:inspector:intent";function Ta(){try{return localStorage.getItem(Ra)==="1"}catch{return!1}}function Na(e){const[t,n]=T(!1),r=A(null);yn(r,()=>n(!1),t);const i=e.target,l=po(i),s=i&&i.id&&i.type==="page";return o("div",{ref:r,class:"inspector__row-menu"},o("button",{class:"icon-btn inspector__row-menu-btn",type:"button","aria-haspopup":"true","aria-expanded":String(t),"aria-label":"Target options",onClick:a=>{a.stopPropagation(),n(!t)}},"⋯"),o("div",{class:"inspector__row-menu-pop",hidden:!t,role:"menu",onClick:a=>a.stopPropagation()},o("button",{type:"button",role:"menuitem",onClick:()=>{n(!1),e.onConnect(i)}},"Connect"),s?o("button",{type:"button",role:"menuitem",onClick:()=>{n(!1),e.onReload(i)}},"Reload"):null,s?o("button",{type:"button",role:"menuitem","data-danger":"1",onClick:()=>{n(!1),e.onClose(i)}},"Close tab"):null,o("div",{class:"inspector__row-menu-meta"},o("span",null,l.label),o("span",null,i&&i.id?i.id:""))))}function Ea(e){const t=e.target,n=po(t),r=t&&(t.title||t.url||t.id)||"",i=fo(t)||t&&(t.url||t.webSocketDebuggerUrl||t.id)||"";return o("li",{class:"inspector__row-target inspector__row-target--"+n.tone,key:t&&t.id},o("button",{class:"inspector__row-target-main",type:"button","aria-label":"Connect to "+r,onClick:()=>e.onConnect(t)},o("span",{class:"inspector__row-target-chip"},n.label),o("span",{class:"inspector__row-target-body"},o("span",{class:"inspector__row-target-title"},r),i&&i!==r?o("span",{class:"inspector__row-target-sub"},i):null)),o(Na,{target:t,onConnect:e.onConnect,onReload:e.onReload,onClose:e.onClose}))}function Ma(e){const[t,n]=T(!1),r=A(null);yn(r,()=>n(!1),t);const i=wt.find(l=>l.id===e.sizeId)||wt[0];return o("div",{ref:r,class:"inspector__size"},o("button",{class:"inspector__size-btn",type:"button","aria-haspopup":"listbox","aria-expanded":String(t),"aria-label":"Preview size: "+i.label,title:"Preview size",onClick:l=>{l.stopPropagation(),n(!t)}},o("span",{class:"inspector__size-btn-label"},i.label),o("svg",{viewBox:"0 0 24 24",width:14,height:14,"aria-hidden":"true"},o("path",{d:"M7 10l5 5 5-5z",fill:"currentColor"}))),o("div",{class:"inspector__size-pop",hidden:!t,role:"listbox",onClick:l=>l.stopPropagation()},wt.map(l=>o("button",{class:"inspector__size-opt"+(e.sizeId===l.id?" is-on":""),type:"button",role:"option","aria-selected":String(e.sizeId===l.id),onClick:()=>{n(!1),e.onChange(l.id)}},o("span",{class:"inspector__size-opt-label"},l.label),o("span",{class:"inspector__size-opt-dims"},l.width?l.width+"×"+l.height:"native")))))}function Nr(e){const t=e.isVisible,n=t?"Hide "+e.label+" panel":"Show "+e.label+" panel",r=o("button",{class:"icon-btn inspector__panel-fs"+(e.focused?" is-on":""),type:"button","aria-label":e.focused?"Exit full screen for "+e.label:"Open "+e.label+" full screen",title:e.focused?"Exit full screen":"Open "+e.label+" full screen",disabled:!t,onClick:i=>{i.stopPropagation(),e.onFullscreen()}},e.focused?o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true",fill:"currentColor"},o("path",{d:"M9 4v5H4V7h3V4h2Zm6 0h2v3h3v2h-5V4ZM4 15h5v5H7v-3H4v-2Zm11 0h5v2h-3v3h-2v-5Z"})):o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true",fill:"currentColor"},o("path",{d:"M4 9V4h5v2H6v3H4Zm11-5h5v5h-2V6h-3V4ZM6 15v3h3v2H4v-5h2Zm12 0h2v5h-5v-2h3v-3Z"})));return o("div",{class:"inspector__panel"+(e.grow?" inspector__panel--grow":"")+(e.span?" inspector__panel--span":"")+(e.solo?" inspector__panel--solo":"")+(e.focused?" inspector__panel--fullscreen":""),"data-panel":e.id},o("div",{class:"inspector__panel-head"},o("div",{class:"inspector__panel-head-left"},r,e.onSizeChange?o(Ma,{sizeId:e.sizeId,onChange:e.onSizeChange}):null),o("div",{class:"inspector__panel-head-actions"},e.stylesActions?o(nt,null,o("button",{class:"icon-btn inspector__styles-clear",type:"button","aria-label":"Clear selection",title:"Clear selection",disabled:!e.stylesActions.hasElement,onClick:i=>{i.stopPropagation(),e.stylesActions.onClear()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M6 6 18 18 M18 6 6 18",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round"}))),o("button",{class:"icon-btn inspector__styles-refresh",type:"button","aria-label":"Refresh styles",title:"Refresh styles",disabled:!e.stylesActions.hasElement||e.stylesActions.busy,onClick:i=>{i.stopPropagation(),e.stylesActions.onRefresh()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M12 4V1L7 6l5 5V7c3.3 0 6 2.7 6 6s-2.7 6-6 6-6-2.7-6-6H4c0 4.4 3.6 8 8 8s8-3.6 8-8-3.6-8-8-8Z",fill:"currentColor"}))),o("button",{class:"icon-btn inspector__styles-pick"+(e.stylesActions.pickMode?" is-on":""),type:"button","aria-pressed":String(!!e.stylesActions.pickMode),"aria-label":e.stylesActions.pickLabel,title:e.stylesActions.pickLabel,disabled:!!e.stylesActions.pickDisabled,onClick:i=>{i.stopPropagation(),e.stylesActions.onPick()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M5 3l14 7-6.5 1.5L10 19 5 3Z",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linejoin":"round"})))):null,e.onDraftCraft?o("button",{class:"icon-btn inspector__panel-draft-craft",type:"button",title:"Draft Craft","aria-label":"Open Draft Craft for this preview",disabled:!e.isVisible,onClick:i=>{i.stopPropagation(),e.onDraftCraft()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},o("rect",{x:3,y:4,width:18,height:16,rx:2}),o("path",{d:"m8 15 2.5-3 2 2 3.5-4 2 3"}),o("path",{d:"m16.5 3 .5-1 .5 1 1 .5-1 .5-.5 1-.5-1-1-.5 1-.5Z"}))):null,e.onRefresh?o("button",{class:"icon-btn inspector__panel-refresh",type:"button",title:"Refresh preview","aria-label":"Refresh preview",disabled:!e.isVisible,onClick:i=>{i.stopPropagation(),e.onRefresh()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M12 4V1L7 6l5 5V7c3.3 0 6 2.7 6 6s-2.7 6-6 6-6-2.7-6-6H4c0 4.4 3.6 8 8 8s8-3.6 8-8-3.6-8-8-8Z",fill:"currentColor"}))):null,e.onTypeBar?o("button",{class:"icon-btn inspector__panel-typebar",type:"button",title:"Type into page","aria-label":"Type into page",disabled:!e.isVisible,onClick:i=>{i.stopPropagation(),e.onTypeBar()}},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},o("rect",{x:3,y:6,width:18,height:12,rx:2}),o("path",{d:"M6 10h4M6 14h2M12 14h6"}))):null,o("button",{class:"inspector__panel-eye"+(t?" is-visible":""),type:"button","aria-label":n,"aria-pressed":String(t),title:n,onClick:()=>e.onToggle(e.id)},t?o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M12 5C5 5 1 12 1 12s4 7 11 7 11-7 11-7-4-7-11-7Zm0 11a4 4 0 1 1 0-8 4 4 0 0 1 0 8Z",fill:"currentColor"}),o("circle",{cx:12,cy:12,r:2.2,fill:"currentColor"})):o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M2 5l2-2 18 18-2 2-3.4-3.4A12.8 12.8 0 0 1 12 19c-7 0-11-7-11-7a18.6 18.6 0 0 1 4.1-4.5L2 5Zm10 4a3 3 0 0 1 3 3l-3-3Zm0-4c7 0 11 7 11 7a18.4 18.4 0 0 1-3.3 3.9l-2.5-2.5A4 4 0 0 0 12 8a4 4 0 0 0-.6 0L9.3 5.9A11.5 11.5 0 0 1 12 5Z",fill:"currentColor"}))))),o("div",{class:"inspector__panel-body"},t?e.children:null))}function Aa(e){const t=A(e.onExit);return t.current=e.onExit,ne(()=>{function n(r){r.key!=="Escape"||r.defaultPrevented||t.current&&t.current()}return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[]),null}function Ia(e){return e.render(e.id)}function La(e){if(!e)return"idle";const t=String(e).toLowerCase();return/fail|error|disconnected|reject|abort|invalid|missing|denied|unknown/.test(t)?"danger":/warn/.test(t)?"warn":/reloading|navigating|opening|closing|fetching|saving|connecting|switching|going /.test(t)?"busy":/connected|now using|saved|closed|opened|reloaded|navigat|targets|applied|copied/.test(t)?"ok":"info"}function ln(e){const t=La(e.text);return o("span",{class:"inspector__statuspill inspector__statuspill--"+t,role:"status","aria-live":"polite"},o("span",{class:"inspector__statuspill-dot","aria-hidden":"true"}),o("span",{class:"inspector__statuspill-text"},e.text||""))}function Fa(e){const[t,n]=T(!1),r=A(null);return yn(r,()=>n(!1),t),o("div",{ref:r,class:"inspector__actions"},o("button",{class:"icon-btn inspector__actions-btn",type:"button","aria-haspopup":"true","aria-expanded":String(t),"aria-label":"Tab actions",title:"Tab actions",onClick:i=>{i.stopPropagation(),n(!t)}},"…"),o("div",{class:"inspector__actions-pop",hidden:!t,role:"menu",onClick:i=>i.stopPropagation()},o("button",{type:"button",role:"menuitem",onClick:()=>{n(!1),e.onReload()}},"Reload"),o("button",{type:"button",role:"menuitem",onClick:()=>{n(!1),e.onOpenInNewTab()}},"Open in new tab"),o("button",{type:"button",role:"menuitem",onClick:()=>{n(!1),e.onShowAll()}},"Show all panels"),o("div",{class:"inspector__actions-pop-sep"}),o("button",{type:"button",role:"menuitem","data-danger":"1",onClick:()=>{n(!1),e.onClose()}},"Close tab")))}const za={preview:o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm2 0v14h14V5H5Zm2 10h10v-2H7v2Zm0-4h10V9H7v2Zm0-4h6V5H7v2Z",fill:"currentColor"})),styles:o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M4 4h16v3H4V4Zm0 5h14v2H4V9Zm0 4h12v3H4v-3Zm0 5h10v2H4v-2Z",fill:"currentColor"})),console:o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M3 4h18v3H3V4Zm0 5h12v2H3V9Zm0 4h18v2H3v-2Zm0 4h12v3H3v-3Z",fill:"currentColor"})),network:o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M12 3a9 9 0 0 0-9 9h2a7 7 0 0 1 14 0h2a9 9 0 0 0-9-9Zm0 4a5 5 0 0 0-5 5h2a3 3 0 0 1 6 0h2a5 5 0 0 0-5-5Zm0 4a1 1 0 1 0 0 2 1 1 0 0 0 0-2Zm-9 6h18v2H3v-2Z",fill:"currentColor"})),overview:o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M3 4h7v7H3V4Zm0 9h7v7H3v-7Zm9-9h9v4h-9V4Zm0 6h9v10h-9V10Z",fill:"currentColor"}))};function ja(){const e=A(null),t=A(null),n=A(null),r=A(null),[i,l]=T("");function s(h){l(h==null?"":String(h))}const[a,c]=T(0),[u,d]=T(0),y=A(h=>c(h|0)),_=A(h=>d(h|0));y.current=h=>c(h|0),_.current=h=>d(h|0);const[R,j]=T(""),[K,N]=T([]),[p,E]=T(null),[q,Z]=T(!1),[D,X]=T(null),B=A(!1),ge=A(null);ge.current=p;const[$,ue]=T(()=>Pa()),[de,ie]=T(null),[be,H]=T(null),[se,Te]=T(null),[we,ce]=T(null),[ye,Se]=T(()=>{try{return localStorage.getItem(Rr)||"auto"}catch{return"auto"}}),[ae,pe]=T("setup"),[,xe]=T(0),[v,U]=T(!1),[le,De]=T(null),[z,oe]=T(!1),[Ne,fe]=T(""),[Xe,qe]=T(null),Ce=A([]),Pe=A([]),_e=A(null),M=A(null),Q=A(new Map),ee=A(null),te=A(null),Ie=A({open:!1}),[J,Le]=T("");ne(()=>{J&&!$.has(J)&&Le("")},[J,$]),ne(()=>{Ie.current.open&&J&&Le("")});const Ee=A(null),Ke=A(null),Ze=A(null),[m,g]=T(!1),[S,C]=T(null),P=A(""),[x,V]=T(null);ne(()=>{S&&String(S.label||"").trim()&&V(S)},[S]);const[G,he]=T([]),[Fe,Be]=T(0);function Me(h){he(b=>Xl(b,h))}async function ze(h){const b=Jl(h),w=x&&x.objectId;if(!(!b||!w||!F)){try{if(b.kind==="remove"?F.removeInlineStyleProperty&&await F.removeInlineStyleProperty(w,b.prop):F.setInlineStyleProperty&&await F.setInlineStyleProperty(w,b.prop,b.value,b.priority),he(I=>I.filter(W=>String(W.prop).toLowerCase()!==String(b.prop).toLowerCase())),F.refreshNodeModel){const I=await F.refreshNodeModel(w);if(I){const W=(I.inlineProps||[]).map(me=>({prop:me.prop,value:String(me.value||"")}));V(me=>me&&me.objectId===w?{...me,declared:W}:me)}}}catch(I){s(I&&I.message||"could not undo "+b.prop);return}Be(I=>I+1),ke()}}async function rt(){const h=co(G);for(const b of h)await ze(b);he([]),ke()}async function je(h){const b=String(h||"");if(!b)return;const w=await xa(b);s(w?"copied selector "+b:"could not copy the selector")}const Ae=A(null),[et,Je]=T(()=>Ta());ne(()=>{if(!$.has("console")&&_e.current){try{_e.current.setData([])}catch{}_e.current=null}},[$]),ne(()=>{if(!$.has("network")&&M.current){try{M.current.setData([])}catch{}M.current=null}},[$]),ne(()=>{const h=it.current;if(!(!q||!$.has("preview")||!h))return h.startPreviewStream().catch(()=>{}),()=>h.stopPreviewStream().catch(()=>{})},[q,$]);function ke(){xe(h=>h+1)}const Re=A(null),it=A(null);function Wt(h,b){He(ye),h&&(E(w=>w&&{...w,url:h,title:b||h}),n.current&&(n.current.value=h),f(h),Re.current&&Re.current.cdpSend&&Re.current.cdpSend("Runtime.evaluate",{expression:"document.title",returnByValue:!0}).then(w=>{const I=w&&w.result&&w.result.value;I&&typeof I=="string"&&E(W=>W&&{...W,title:I})}).catch(()=>{}),ke())}function qt(h){Re.current=ya();const b={consoleEntries:Ce,networkEntries:Pe,reqMap:Q,consoleVL:_e,networkVL:M,captureBeyondViewport:!h||h.captureBeyondViewport!==!1,cdpSend:Re.current.cdpSend,onNavigate:Wt,rerender:ke,consoleCountRef:y,networkCountRef:_};return it.current=va(b),Re.current}function ct(){if(Re.current&&Re.current.disconnect(),Re.current=null,it.current=null,Z(!1),J&&go(),Q.current.clear(),E(null),X(null),B.current=!1,Ce.current=[],Pe.current=[],ie(null),_e.current)try{_e.current.setData([])}catch{}if(M.current)try{M.current.setData([])}catch{}s("")}function He(h){const b=h||"auto";Se(b);try{localStorage.setItem(Rr,b)}catch{}const w=it.current,I=wt.find(W=>W.id===b);w&&w.setViewportSize&&w.setViewportSize(I&&I.width?I:null).catch(()=>{})}function ut(h){Re.current&&ct();const b=Ca(h,K),w=qt({captureBeyondViewport:!b}),I=it.current;E(h),pe("inspect"),Ce.current=[],Pe.current=[],s("connecting…");const W=w.connect(R,h.id);if(W.error){s(W.error);return}W.ws.addEventListener("open",()=>{s("connected to "+(h.title||h.url||h.id)),w.cdpSend("Runtime.enable").catch(me=>{s("Runtime.enable failed: "+me.message)}),w.cdpSend("Network.enable").catch(me=>{s("Network.enable failed: "+me.message)}),w.cdpSend("DOM.enable").catch(()=>{}),w.cdpSend("CSS.enable").catch(()=>{}),w.cdpSend("Page.enable").then(()=>Z(!0)).catch(()=>{}),f(null),He(ye),w.cdpSend("Emulation.setEmulatedMedia",{features:[{name:"prefers-color-scheme",value:"light"}]}).catch(()=>{}),w.cdpSend("Performance.enable").catch(()=>{}),w.cdpOn("Runtime.consoleAPICalled",I.onConsoleEvent),w.cdpOn("Runtime.exceptionThrown",I.onExceptionEvent),w.cdpOn("Network.requestWillBeSent",I.onRequestWillBeSent),w.cdpOn("Network.responseReceived",I.onResponseReceived),w.cdpOn("Network.loadingFinished",I.onLoadingFinished),w.cdpOn("Network.loadingFailed",I.onLoadingFailed),w.cdpOn("Page.frameNavigated",I.onFrameNavigated),w.cdpOn("Page.navigatedWithinDocument",I.onNavigatedWithinDocument)}),W.ws.addEventListener("close",me=>{Z(!1);const Ye=me&&typeof me.code=="number"?me.code:0;s("disconnected (code "+Ye+")")}),W.ws.addEventListener("error",()=>{const me=w.lastProxyError&&w.lastProxyError.current;s(me||"WebSocket error")}),ke()}async function Zt(){let h;try{if(h=await $e("/api/inspector/config"),h.status!==200){s("HTTP "+h.status);return}j(h.body.url||""),e.current&&(e.current.value=h.body.url||""),qe(h.body.activeProfile||null),s(h.body.url?"current: "+h.body.url:"using default: "+h.body.defaultUrl),ke(),h.body.url&&setTimeout(Ve,0)}catch(b){s("inspector: "+(b&&b.message||String(b)))}}async function ot(){if(!e.current)return;const h=(e.current.value||"").trim();if(!h){s("url is required");return}r.current.disabled=!0,s("saving…");let b;try{b=await $e("/api/inspector/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:h})})}catch{s("network error"),r.current&&(r.current.disabled=!1);return}if(r.current&&(r.current.disabled=!1),b.status!==200){s("HTTP "+b.status);return}j(b.body.url||h),qe(b.body&&b.body.activeProfile||null),s("saved.")}async function Ve(){s("fetching targets…");let h;try{h=await $e("/api/inspector/targets")}catch{s("network error");return}if(h.status!==200){const b=h.body&&h.body.error?h.body.error:"HTTP "+h.status;s(b);return}N(h.body.targets||[]),pe("targets"),s((h.body.targets||[]).length+" targets"),ke()}async function ft(h,b){if(!h||!h.id)return;if(b==="close"){Ct("row",h);return}s("reloading "+(h.title||h.url||"tab")+"…");let w;try{w=await $e("/api/inspector/reload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:h.id})})}catch{s("network error");return}if(w.status!==200||!w.body||!w.body.ok){const I=w.body&&w.body.error?w.body.error:"HTTP "+w.status;s("reload failed: "+I);return}s("reloaded")}async function Kt(){const h=p;if(!h||!h.url)return;const b=h.url;s("opening "+b+" in a new tab…");let w;try{w=await $e("/api/inspector/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:b})})}catch{s("network error opening new tab");return}if(w.status!==200||!w.body||!w.body.target){const I=w.body&&w.body.error?w.body.error:"HTTP "+w.status;s("new tab failed: "+I);return}s("opened "+b+" in a new tab")}function Gt(){const h=p;if(!h||!h.id){s("nothing to close");return}Ct("attached",h)}function Ct(h,b){!b||!b.id||ce({action:h,target:b})}function Pt(){ce(null)}async function tt(){const h=we;if(!h||!h.target||!h.target.id){ce(null);return}const b=h.target;ce(null),h.action==="row"?await Rt(b):await $t(b)}async function Rt(h){s("closing "+(h.title||h.url||"tab")+"…");let b;try{b=await $e("/api/inspector/close",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:h.id})})}catch{s("network error");return}if(b.status!==200||!b.body||!b.body.ok){const w=b.body&&b.body.error?b.body.error:"HTTP "+b.status;s("close failed: "+w);return}s("closed"),Ve()}async function $t(h){s("closing tab…");let b;try{b=await $e("/api/inspector/close",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:h.id})})}catch{s("network error closing tab");return}if(b.status!==200||!b.body||!b.body.ok){const w=b.body&&b.body.error?b.body.error:"HTTP "+b.status;s("close failed: "+w);return}ct(),pe("targets"),ke(),Ve()}async function ht(){const h=p;if(!h||!h.id)return;s("reloading…");let b;try{b=await $e("/api/inspector/reload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:h.id})})}catch{s("network error reloading");return}if(b.status!==200||!b.body||!b.body.ok){const w=b.body&&b.body.error?b.body.error:"HTTP "+b.status;s("reload failed: "+w);return}s("reloaded")}async function f(h){const b=p;if(!(!b||!b.id||B.current||!q)){B.current=!0;try{const w=await $e("/api/inspector/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:b.id})});if(!w||w.status!==200||!w.body||typeof w.body.canGoBack!="boolean"){X(null);return}if(h&&k(h))return;X(w.body)}catch{X(null)}finally{B.current=!1}}}function k(h){const b=ge.current;return!!(b&&b.url&&String(b.url)!==String(h))}async function O(h){const b=p;if(!b||!b.id)return;const w=h==="back",I=w?"/api/inspector/back":"/api/inspector/forward";s(w?"going back…":"going forward…");let W;try{W=await $e(I,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:b.id})})}catch{s(w?"network error going back":"network error going forward");return}if(W.status!==200||!W.body){const Ye=W.body&&W.body.error?W.body.error:"HTTP "+W.status;s((w?"back":"forward")+" failed: "+Ye);return}const me=w?W.body.wentBack:W.body.wentForward;s(me?w?"went back":"went forward":w?"no page to go back to":"no page to go forward to"),me&&f(null)}async function Y(){return O("back")}async function re(){return O("forward")}async function Ue(){const h=p,b=n.current;if(!h||!h.id||!b)return;let w=(b.value||"").trim();if(!w){s("enter a url first");return}/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(w)||(w="http://"+w),s("navigating to "+w+"…");let I;try{I=await $e("/api/inspector/navigate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:h.id,url:w})})}catch{s("network error navigating");return}if(I.status!==200||!I.body||typeof I.body.frameId!="string"&&!I.body.errorText){const W=I.body&&(I.body.error||I.body.errorText)?I.body.error||I.body.errorText:"HTTP "+I.status;s("navigate failed: "+W);return}s("navigating to "+w+"…")}async function We(){const h=t.current;if(!h)return;let b=(h.value||"").trim();if(!b){s("enter a page url first");return}/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(b)||(b="http://"+b),s("opening "+b+"…");let w;try{w=await $e("/api/inspector/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:b})})}catch{s("network error");return}if(w.status!==200||!w.body||!w.body.target){const I=w.body&&w.body.error?w.body.error:"HTTP "+w.status;s(I);return}ut(w.body.target)}if(ne(()=>(Zt(),()=>{ct()}),[]),ae==="setup")return o(nt,null,o("section",null,o("p",{class:"hint"},"Start Chrome with ",o("code",null,"--remote-debugging-port=9222")," and paste its debugger URL below."),o("div",{class:"row"},o("label",{class:"label",for:"inspectorUrl"},"Chrome debugger URL"),o("input",{ref:e,class:"input",id:"inspectorUrl",type:"text",placeholder:"http://127.0.0.1:9222"})),null,o("div",{class:"row row--actions"},o(ln,{text:i}),o("button",{ref:r,class:"btn btn--primary",type:"button",onClick:()=>{ot().then(Ve)}},"Save & discover"),o("button",{class:"btn",type:"button",onClick:Ve},"Discover"))),o("p",{class:"hint hint--compact"},"Phone tip: ",o("code",null,"adb reverse tcp:9222 tcp:9222")," then ",o("code",null,"http://127.0.0.1:9222"),"."),null);if(ae==="targets")return o(nt,null,o("div",{class:"view-head"},o("a",{href:"#/inspector",class:"view-back","aria-label":"Back to inspector setup",onClick:h=>{h.preventDefault(),ct(),pe("setup"),ke()}},"←"),o("h2",{class:"view-title"},"Pick a target")),o("section",null,o("p",{class:"hint"},"Type a page URL and Chrome opens it in a new tab with the inspector attached. Or tap a target below. Connection is over ",o("code",null,"ws://")," via mouaif (port "+String(window.location.port||5732)+"); data flows both ways in real time."),o("div",{class:"row"},o("label",{class:"label",for:"inspectorPageUrl"},"Page URL"),o("input",{ref:t,class:"input",id:"inspectorPageUrl",type:"url",placeholder:"http://localhost:3000",onKeydown:h=>{h.key==="Enter"&&We()}})),o("div",{class:"row row--actions"},o("button",{class:"btn btn--primary",type:"button",onClick:We},"Open & inspect"),o("button",{class:"btn",type:"button",onClick:Ve},"Refresh targets")),o(ln,{text:i}),K.length?o("ul",{class:"inspector__row-targets","aria-label":"Discoverable targets"},K.map(h=>o(Ea,{target:h,key:h&&h.id,onConnect:ut,onReload:b=>ft(b,"reload"),onClose:b=>ft(b,"close")}))):o("div",{class:"inspector__row-targets-empty",role:"status"},o("p",null,"No targets found."),o("p",{class:"inspector__row-targets-empty-hint"},"Open a tab in Chrome and tap ",o("strong",null,"Refresh targets")," to discover it.")),we?o(pn,{open:!0,title:"Close tab?",message:Pr(we.target),confirmLabel:"Close tab",onCancel:Pt,onConfirm:tt}):null));const Oe=p,F=it.current;function Tt(h,b){const w=h==="console"?_e.current:M.current;if(!w)return;let I=b.target;for(;I&&I!==b.currentTarget&&!I.__sig;)I=I.parentNode;if(!I||!I.__sig)return;const W=I.__sig.split("|")[0],Ye=w.getData().find(mt=>mt.id===W);Ye&&(ie(Ye),ke())}function mo(){if(!de)return;const h=Sa(de,{pageTitle:p&&p.title,pageUrl:p&&p.url});h&&H({projectDir:ko(),text:h,textLabel:"inspector entry",description:"Add this Inspector entry to any chat draft."})}function Xt(h,b){requestAnimationFrame(()=>{const w=document.querySelector(".app__main"),I=document.querySelector('.inspector__panel[data-panel="'+h+'"]');if(!w||!I)return;const W=w.getBoundingClientRect();if(!W.height)return;const me=document.querySelector(".inspector__panelbar"),Ye=me?me.getBoundingClientRect():null,mt=Ye&&Ye.height?Math.max(W.top,Ye.bottom):W.top;if(mt>=W.bottom)return;const gt=I.getBoundingClientRect(),Nt=6;if(b==="bottom"){if(gt.bottom<=W.bottom-Nt&&gt.top>=mt)return;w.scrollTop+=gt.bottom-(W.bottom-Nt);return}gt.top>=mt-Nt&&gt.bottom<=W.bottom||(w.scrollTop+=gt.top-mt-Nt)})}function Jt(h){const b=$;let w=!1,I;if(b.has(h)){if(b.size===1)return;J===h&&Le(""),I=new Set(b),I.delete(h)}else I=new Set(b),I.add(h),w=!0;Tr(I),ue(I),ke(),w&&Xt(h,"top")}function Rn(){const h=new Set(Qe.map(b=>b.id));Tr(h),ue(h),ke()}function Yt(h){Le(b=>b===h?"":h),ke()}function go(){Le(""),ke()}const Qt=Qe.map(h=>h.id).filter(h=>$.has(h)),bo=Qt.length===0,Tn=h=>h==="preview"?o(ri,{capture:F&&F.captureScreenshot,clickAt:(b,w)=>{if(m&&Ze.current){ti(Ze.current(b,w),()=>g(!1));return}F&&F.clickAt(b,w).catch(()=>{})},pickMode:m,pickHint:an(),onPickCancel:()=>{g(!1),ke()},subscribe:Re.current&&Re.current.cdpOn,ackFrame:F&&F.ackPreviewFrame,refreshRef:ee,fullscreenRef:te,fullscreenOpenRef:Ie,typeBarRef:Ee,draftCraftRef:Ke,onInsert:F?F.insertText:null,onEnter:F?F.pressEnter:null,onDraftCraft:b=>b&&Te(b),evaluate:b=>Re.current?Re.current.cdpSend("Runtime.evaluate",{expression:b,returnByValue:!0,awaitPromise:!1}):Promise.reject(new Error("not connected")),pageUrl:p&&p.url,pageTitle:p&&p.title,sizePresets:wt,sizeId:ye,sizeDisabled:!q,onSizeChange:He}):h==="styles"?o(ga,{pickNodeAt:F?F.pickNodeAt:null,selectBySelector:F?F.selectBySelector:null,refreshNodeModel:F?F.refreshNodeModel:null,hideNodeHighlight:F?F.hideNodeHighlight:null,setInlineStyleProperty:F?F.setInlineStyleProperty:null,removeInlineStyleProperty:F?F.removeInlineStyleProperty:null,captureElementShot:F?F.captureElementShot:null,readElementStyles:F?F.readElementStyles:null,readSiblingValues:F?F.readSiblingValues:null,readElementTree:F?F.readElementTree:null,selectAncestorNode:F?F.selectAncestorNode:null,selectChildNode:F?F.selectChildNode:null,readMatchedRules:F?F.readMatchedRules:null,previewVisible:$.has("preview"),pickHandlerRef:Ze,panelHandlesRef:Ae,onCopyElement:je,restoreObjectId:x&&x.objectId||"",receipt:G,onRecordChange:Me,onUndo:b=>ze(b),onUndoAll:()=>rt(),receiptNonce:Fe,onSelectionReset:()=>{he([])},onCleared:()=>{C(null),V(null)},onSelectionChange:b=>{C(b);const w=b&&b.objectId||"";w&&w!==P.current&&(P.current=w,Xt("styles","top")),w||(P.current="")},pickMode:m,onPickModeChange:b=>{g(b),b&&Xt("preview","bottom")}}):h==="console"?o(Qo,{onRowTap:b=>Tt("console",b),onReady:b=>{_e.current=b,F&&F.pushConsole()},onEvaluate:b=>{F&&F.evaluateExpression(b)},getEval:(b,w)=>Re.current?Re.current.cdpSend("Runtime.evaluate",w):Promise.reject(new Error("not connected"))}):h==="network"?o(ei,{onRowTap:b=>Tt("network",b),onReady:b=>{M.current=b,F&&F.pushNetwork()}}):o(ci,{metrics:()=>F?F.fetchMetrics():Promise.resolve({})}),Nn=ca(S,x),En={hasElement:!!(Nn&&String(Nn.label||"").trim()),busy:!!(S&&S.busy),pickMode:m,pickLabel:m?"Stop picking — tap the preview to select":"Pick an element from the preview",pickDisabled:!$.has("preview")&&!m,onClear:()=>{const h=Ae.current;h&&h.clear&&h.clear()},onRefresh:()=>{const h=Ae.current;h&&h.refresh&&h.refresh()},onPick:()=>{const h=Ae.current;h&&h.togglePick&&h.togglePick()}};return o(nt,null,o("div",{class:"view-head inspector__viewhead"},o("a",{href:"#/inspector",class:"view-back","aria-label":"Back to targets",onClick:h=>{h.preventDefault(),ct(),pe("targets"),ke()}},"←"),o("h2",{class:"view-title inspector__title"},Oe&&(Oe.title||Oe.url||"target")),o(Fa,{onReload:ht,onOpenInNewTab:Kt,onShowAll:Rn,onClose:Gt})),o("section",null,o("div",{class:"inspector__nav"},o("button",{class:"icon-btn inspector__nav-back",type:"button",disabled:!!(D&&!D.canGoBack),title:"Go back in this tab's history","aria-label":"Go back in this tab's history",onClick:Y},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2Z",fill:"currentColor"}))),o("button",{class:"icon-btn inspector__nav-forward",type:"button",disabled:!!(D&&!D.canGoForward),title:"Go forward in this tab's history","aria-label":"Go forward in this tab's history",onClick:re},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M4 11h12.17l-5.59-5.59L12 4l8 8-8 8-1.41-1.41L16.17 13H4v-2Z",fill:"currentColor"}))),o("button",{class:"icon-btn inspector__nav-reload",type:"button",title:"Reload this tab","aria-label":"Reload this tab",onClick:ht},o("svg",{viewBox:"0 0 24 24",width:18,height:18,"aria-hidden":"true"},o("path",{d:"M12 4V1L7 6l5 5V7c3.3 0 6 2.7 6 6s-2.7 6-6 6-6-2.7-6-6H4c0 4.4 3.6 8 8 8s8-3.6 8-8-3.6-8-8-8Z",fill:"currentColor"}))),o("input",{ref:n,class:"input inspector__nav-input",type:"url",placeholder:"http://localhost:3000",enterkeyhint:"go",value:Oe&&Oe.url||"",onKeydown:h=>{h.key==="Enter"&&Ue()}}),o("button",{class:"btn btn--primary inspector__nav-go",type:"button",title:"Go to this URL in the inspected tab","aria-label":"Go to this URL in the inspected tab",onClick:Ue},"Go")),o("div",{class:"inspector__panelbar",role:"group","aria-label":"Optional panels"},Qe.map(h=>{const b=$.has(h.id),w=h.id==="console"?a:h.id==="network"?u:0,I=w>999?"999+":String(w),W=b&&w>0;return o("button",{class:"inspector__panelchip"+(b?" is-on":"")+(W?" has-badge":""),type:"button","aria-label":(b?"Hide ":"Show ")+h.label+(W?" ("+I+" entries)":""),"aria-pressed":String(b),title:(b?"Hide ":"Show ")+h.label,"data-panel-id":h.id,onClick:()=>Jt(h.id)},o("span",{class:"inspector__panelchip-icon","aria-hidden":"true"},za[h.id]),o("span",{class:"inspector__panelchip-label"},h.label),W?o("span",{class:"inspector__panelchip-badge","aria-hidden":"true"},I):null)}),null),o(ln,{text:i}),null,bo?o("div",{class:"inspector__panels-empty",role:"status"},o("p",null,"No panels visible."),o("p",{class:"inspector__panels-empty-hint"},"Tap a panel name above to show it."),o("button",{class:"btn",type:"button",onClick:Rn},"Show all panels")):o("div",{class:"inspector__panels"},Qt.map((h,b)=>o(Nr,{id:h,label:Qe.find(w=>w.id===h).label,grow:b===0,solo:Qt.length===1,isVisible:$.has(h),focused:J===h,onToggle:Jt,stylesActions:h==="styles"?En:null,sizeId:ye,onSizeChange:h==="preview"?He:null,onRefresh:h==="preview"?()=>ee.current&&ee.current():null,onFullscreen:h==="preview"?()=>{te.current&&te.current()}:()=>Yt(h),onTypeBar:h==="preview"?()=>Ee.current&&Ee.current.open():null,onDraftCraft:h==="preview"?()=>Ke.current&&Ke.current():null,key:h},Tn(h))))),J?bn(o("div",{class:"inspector__fs",role:"dialog","aria-modal":"true","aria-label":(Qe.find(h=>h.id===J)||{}).label+" panel, full screen"},o(Nr,{id:J,label:(Qe.find(h=>h.id===J)||{}).label,grow:!0,solo:!0,focused:!0,isVisible:!0,onToggle:Jt,stylesActions:J==="styles"?En:null,sizeId:ye,onSizeChange:null,onRefresh:null,onFullscreen:()=>Yt(J),key:"fs-"+J},o(Ia,{id:J,render:Tn})),o(Aa,{onExit:()=>Yt(J)})),document.body):null,se?o(_o,{image:se,pageTitle:Oe&&Oe.title,pageUrl:Oe&&Oe.url,onClose:()=>Te(null)}):null,o(ba,{item:de,onClose:()=>{ie(null),ke()},onLoadBody:()=>F&&F.loadResponseBody(de),onAddToChat:mo}),be?o(wo,{open:!0,payload:be,placement:"bottom",onClose:()=>H(null),onAdded:()=>{H(null),ie(null),ke()}}):null,we?o(pn,{open:!0,title:"Close tab?",message:Pr(we.target),confirmLabel:"Close tab",onCancel:Pt,onConfirm:tt}):null)}export{ja as InspectorView,La as classifyStatus};