1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8893],{8893:(e,t,n)=>{n.r(t),n.d(t,{default:()=>F});var s=n(95155),a=n(12115),r=n(27784),o=n(67001),i=n(90235),l=n(97003),d=n(33534),c=n(69869),u=n(12513),m=n(25016),h=n(81322),p=n(52863);let x=e=>e.toLocaleString("en-US"),f=[{name:"child",what:"The default. child::title is the same as writing title"},{name:"descendant",what:"Every node underneath, at any depth"},{name:"descendant-or-self",what:"The same, plus the node itself. // is short for /descendant-or-self::node()/"},{name:"parent",what:"One step up. The abbreviation is .."},{name:"ancestor",what:"Every node above, up to the document. CSS cannot do this"},{name:"ancestor-or-self",what:"The same, plus the node itself"},{name:"following-sibling",what:"Later siblings sharing the same parent"},{name:"preceding-sibling",what:"Earlier siblings sharing the same parent"},{name:"following",what:"Everything that starts after this node closes"},{name:"preceding",what:"Everything that closed before this node started"},{name:"attribute",what:"The attributes of an element. The abbreviation is @"},{name:"self",what:"The node itself. The abbreviation is ."},{name:"namespace",what:"The namespace nodes in scope. Rarely used and dropped in later versions"}],g=[{group:"Node set",name:"last",sig:"last()",what:"How many nodes are in the current step"},{group:"Node set",name:"position",sig:"position()",what:"Where this node sits in the current step"},{group:"Node set",name:"count",sig:"count(node-set)",what:"How many nodes matched"},{group:"Node set",name:"id",sig:"id(object)",what:"Nodes by their declared ID attribute"},{group:"Node set",name:"local-name",sig:"local-name(node-set?)",what:"The name with any prefix stripped off"},{group:"Node set",name:"namespace-uri",sig:"namespace-uri(node-set?)",what:"The namespace a node belongs to"},{group:"Node set",name:"name",sig:"name(node-set?)",what:"The full name including the prefix"},{group:"String",name:"string",sig:"string(object?)",what:"Turns anything into its string value"},{group:"String",name:"concat",sig:"concat(s, s, ...)",what:"Joins a fixed list of strings"},{group:"String",name:"starts-with",sig:"starts-with(s, t)",what:"True when s begins with t"},{group:"String",name:"contains",sig:"contains(s, t)",what:"True when t appears anywhere in s"},{group:"String",name:"substring-before",sig:"substring-before(s, t)",what:"Everything before the first t"},{group:"String",name:"substring-after",sig:"substring-after(s, t)",what:"Everything after the first t"},{group:"String",name:"substring",sig:"substring(s, start, len?)",what:"A slice, counting from 1 and not 0"},{group:"String",name:"string-length",sig:"string-length(s?)",what:"How many characters"},{group:"String",name:"normalize-space",sig:"normalize-space(s?)",what:"Trims the ends and collapses runs of whitespace"},{group:"String",name:"translate",sig:"translate(s, from, to)",what:"Swaps characters one for one. This is how you fake lower-case()"},{group:"Boolean",name:"boolean",sig:"boolean(object)",what:"Truth value. A node set is true when it is not empty"},{group:"Boolean",name:"not",sig:"not(boolean)",what:"Flips it"},{group:"Boolean",name:"true",sig:"true()",what:"The constant true"},{group:"Boolean",name:"false",sig:"false()",what:"The constant false"},{group:"Boolean",name:"lang",sig:"lang(string)",what:"True when the node is in that language"},{group:"Number",name:"number",sig:"number(object?)",what:"Turns anything into a
1number"},{group:"Number",name:"sum",sig:"sum(node-set)",what:"Adds up every node in the set"},{group:"Number",name:"floor",sig:"floor(n)",what:"Rounds down"},{group:"Number",name:"ceiling",sig:"ceiling(n)",what:"Rounds up"},{group:"Number",name:"round",sig:"round(n)",what:"Rounds to the nearest whole number"}],b={"ends-with":{fix:!0,alt:"substring() measured back from the end of the string"},"lower-case":{fix:!0,alt:"translate() with the alphabet spelled out both ways"},"upper-case":{fix:!0,alt:"translate() with the alphabet spelled out both ways"},matches:{fix:!1,alt:"contains() or starts-with() for plain substrings. XPath 1.0 has no regular expressions at all"},replace:{fix:!1,alt:"translate() when you are swapping single characters, otherwise do it after the query"},tokenize:{fix:!1,alt:"substring-before() and substring-after() to pull one piece at a time"},"string-join":{fix:!1,alt:"concat(), which takes a fixed list of arguments rather than a node set"},"distinct-values":{fix:!1,alt:"nothing in 1.0. Select everything and dedupe in your own code"},min:{fix:!1,alt:"no 1.0 equivalent. Sort or compare after the query"},max:{fix:!1,alt:"no 1.0 equivalent. Sort or compare after the query"},avg:{fix:!1,alt:"sum(node-set) div count(node-set)"},abs:{fix:!1,alt:"no 1.0 equivalent. Compare against 0 and negate in a predicate"},exists:{fix:!1,alt:"a plain predicate, since an empty node set is already false"},empty:{fix:!1,alt:"not() around a plain predicate"},"index-of":{fix:!1,alt:"position() inside a predicate"},reverse:{fix:!1,alt:"no 1.0 equivalent. Reverse the list after the query"},subsequence:{fix:!1,alt:"a positional predicate such as [position() > 2]"},"deep-equal":{fix:!1,alt:"no 1.0 equivalent"},data:{fix:!1,alt:"string(), which is what 1.0 does implicitly anyway"},"node-name":{fix:!1,alt:"name() or local-name()"},compare:{fix:!1,alt:"the plain = and != operators"},"current-date":{fix:!1,alt:"no 1.0 equivalent. XPath 1.0 has no date type"},"current-dateTime":{fix:!1,alt:"no 1.0 equivalent. XPath 1.0 has no date type"}},y={eq:"the value comparison eq. Use = instead",ne:"the value comparison ne. Use != instead",lt:"the value comparison lt. Use < instead",le:"the value comparison le. Use <= instead",gt:"the value comparison gt. Use > instead",ge:"the value comparison ge. Use >= instead",is:"the node identity operator is",intersect:"the intersect operator",except:"the except operator",idiv:"the integer division operator idiv. Use div and floor()",to:"the range operator to",instance:"instance of",castable:"castable as",treat:"treat as",satisfies:"a quantified some or every expression"},w=`<catalog> 2 <book isbn="978-0131103627" format="pdf"> 3 <title>The C Programming Language</title> 4 <author>Brian Kernighan</author> 5 <price currency="USD">42.50</price> 6 </book> 7 <book isbn="978-0201616224" format="epub"> 8 <title>The Pragmatic Programmer</title> 9 <author>Andrew Hunt</author> 10 <price currency="USD">39.99</price> 11 </book> 12 <book isbn="978-1449355739" format="pdf"> 13 <title>Learning Python</title> 14 <author>Mark Lutz</author> 15 <price currency="USD">54.00</price> 16 </book> 17</catalog>`,v=`<div class="product-grid"> 18 <section class="row"> 19 <article class="card" data-testid="card-1"> 20 <h3 class="name">Mechanical keyboard</h3> 21 <span class="price">$89.50</span> 22 <button class="btn add" data-action="add"> 23 Add to cart 24 </button> 25 </article> 26 <article class="card" data-testid="card-2"> 27 <h3 class="name">USB-C cable</h3> 28 <span class="price">$12.00</span> 29 <button class="btn add" disabled> 30 Out of stock 31 </button> 32 </article> 33 </section> 34 <section class="row"> 35 <article class="card" data-testid="card-3"> 36 <h3 class="name">Desk mat</h3> 37 <span class="price">$24.99</span> 38 <button class="btn add" data-action="add"> 39 Add to cart 40 </button> 41 </article> 42 </section> 43</div>`,k="xpath-tester-mode",N=["m","q","d"],j=[{name:"Sitemap, the namespace trap",mode:"xml",doc:`<?xml version="1.0" encoding="UTF-8"?> 44<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 45 <url> 46 <loc>https://example.com/</loc> 47 <lastmod>2024-03-01</lastmod> 48 <priority>1.0</priority> 49 </url> 50 <url> 51 <loc>https://example.com/pricing</loc> 52 <lastmod>2024-02-14</lastmod> 53 <priority>0.8</priority> 54 </url> 55 <url> 56 <loc>https://example.com/docs/install</loc> 57 <lastmod>2024-01-09</lastmod> 58 <priority>0.6</priority> 59 </url> 60</urlset>`,expr:"//url"},{name:"SOAP, prefixes at two depths",mode:"xml",doc:`<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 61 <soap:Header> 62 <auth:Token xmlns:auth="urn:northwind:auth">a1b2c3</auth:Token> 63 </soap:Header> 64 <soap:Body> 65 <ord:GetOrderResponse xmlns:ord="urn:northwind:orders"> 66 <ord:Order id="SO-4192"> 67 <ord:Status>partially_refunded</ord:Status>
68 <ord:Line sku="TB-KEY-01" qty="1"/> 69 <ord:Line sku="TB-CAB-06" qty="3"/> 70 </ord:Order> 71 </ord:GetOrderResponse> 72 </soap:Body> 73</soap:Envelope>`,expr:"//ord:Line/@sku"},{name:"count(), not a node set",mode:"xml",doc:w,expr:"count(//book)"},{name:"ends-with, an XPath 2.0 trap",mode:"xml",doc:w,expr:"//book[ends-with(@isbn, '3627')]/title"},{name:"The [1] surprise",mode:"html",doc:v,expr:"//article[1]"},{name:"Text with whitespace round it",mode:"html",doc:v,expr:"//button[text()='Add to cart']"}],T=/[A-Za-z_]/,$=/[A-Za-z0-9_.-]/;function S(e){let t=[],n=0;for(;n<e.length;){let s=e[n];if(/\s/.test(s)){n++;continue}if('"'===s||"'"===s){let a=e.indexOf(s,n+1),r=a<0?e.length:a+1;t.push({type:"str",text:e.slice(n,r),start:n,end:r}),n=r;continue}if(/[0-9]/.test(s)||"."===s&&/[0-9]/.test(e[n+1]??"")){let s=n;for(;s<e.length&&/[0-9.]/.test(e[s]);)s++;t.push({type:"num",text:e.slice(n,s),start:n,end:s}),n=s;continue}if("$"===s){let s=n+1;for(;s<e.length&&($.test(e[s])||":"===e[s]);)s++;t.push({type:"var",text:e.slice(n,s),start:n,end:s}),n=s;continue}if(T.test(s)){let s=n;for(;s<e.length&&$.test(e[s]);)s++;if(":"===e[s]&&":"!==e[s+1]){let t=s+1;if("*"===e[t])t++;else for(;t<e.length&&$.test(e[t]);)t++;s=t}t.push({type:"name",text:e.slice(n,s),start:n,end:s}),n=s;continue}let a=e.slice(n,n+2);if("::"===a||"//"===a||"!="===a||"<="===a||">="===a||".."===a){t.push({type:"op",text:a,start:n,end:n+2}),n+=2;continue}t.push({type:"op",text:s,start:n,end:n+1}),n++}return t}let C=new Set(["/","//","|","+","-","=","!=","<","<=",">",">=","*","::","(","[",",","@"]);function P(e){let t=[];for(let n=0;n<e.length;n++){if("name"!==e[n].type){t.push("other");continue}let s=n>0?e[n-1]:null,a=n+1<e.length?e[n+1]:null;if(!(!s||"op"===s.type&&C.has(s.text)||"name"===s.type&&"operator"===t[n-1])){t.push("operator");continue}if(a&&"op"===a.type&&"("===a.text){t.push("function");continue}if(a&&"op"===a.type&&"::"===a.text){t.push("axis");continue}if(s&&"op"===s.type&&"@"===s.text||s&&"op"===s.type&&"::"===s.text&&n>=2&&"attribute"===e[n-2].text){t.push("attr-name");continue}t.push("name-test")}return t}function E(e,t){let n=S(e),s=P(n),a="",r=0;for(let o=0;o<n.length;o++){if("name-test"!==s[o])continue;let i=n[o];if(i.text.includes(":"))continue;let l=t(i.text);null!==l&&(a+=e.slice(r,i.start)+l,r=i.end)}return a+e.slice(r)}function R(e){let t=S(e),n=P(t),s=[];for(let e=0;e<t.length;e++){let a=t[e];"name-test"!==n[e]||a.text.includes(":")||s.push(a.text)}return s}function M(e,t,n){let s=n+1,a=t[s];if(!a||"("!==a.text)return null;let r=[],o=a.end,i=1;for(s++;s<t.length;s++){let n=t[s];if("op"===n.type)if("("===n.text||"["===n.text)i++;else if(")"===n.text||"]"===n.text){if(0==--i)return r.push(e.slice(o,n.start).trim()),{args:r,end:n.end}}else","===n.text&&1===i&&(r.push(e.slice(o,n.start).trim()),o=n.end)}return null}let z="ABCDEFGHIJKLMNOPQRSTUVWXYZ",A="abcdefghijklmnopqrstuvwxyz",X="http://www.w3.org/1999/xhtml";function L(e){for(let t=1;t<100;t++){let n=1===t?"ns":`ns${t}`;if(!e.some(e=>e.prefix===n))return n}return"ns99"}function q(e,t,n){try{return e.evaluate(t,e,n,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength}catch{return null}}
73let U={1:"element",2:"attribute",3:"text",4:"cdata",7:"processing instruction",8:"comment",9:"document"};function O(e,t){let n="";if(t)switch(e.nodeType){case 1:n="string"==typeof e.outerHTML?e.outerHTML:new XMLSerializer().serializeToString(e);break;case 2:n=`${e.name}="${e.value}"`;break;case 3:case 4:n=(e.nodeValue??"").trim();break;case 7:n=`<?${e.target} ${e.data}?>`;break;case 8:n=`<!--${e.nodeValue??""}-->`;break;case 9:n=new XMLSerializer().serializeToString(e);break;default:n=e.nodeValue??e.nodeName}else n=(n=2===e.nodeType?e.value:e.textContent??"").trim();return n.length<=1200?{text:n,omitted:0}:{text:n.slice(0,1200),omitted:n.length-1200}}function _(e,t){return e.localName===t.localName&&e.namespaceURI===t.namespaceURI}function D(e,t,n){if(n)return e.localName;if(!e.namespaceURI)return e.nodeName;if(e.prefix)return`${e.prefix}:${e.localName}`;let s=t.find(t=>t.uri===e.namespaceURI);return s?`${s.prefix}:${e.localName}`:`*[local-name()='${e.localName}']`}function H(e,t,n){if(2===e.nodeType){let s=e.ownerElement;return s?`${H(s,t,n)}/@${e.name}`:`/@${e.name}`}let s=[],a=e;for(;a&&9!==a.nodeType;){if(1===a.nodeType){let e=a,r=1,o=e.previousElementSibling;for(;o;)_(o,e)&&r++,o=o.previousElementSibling;let i=r,l=e.nextElementSibling;for(;l;)_(l,e)&&i++,l=l.nextElementSibling;
73let d=D(e,t,n);s.unshift(i>1?`${d}[${r}]`:d)}else if(3===a.nodeType||4===a.nodeType||8===a.nodeType){let e=8===a.nodeType?"comment()":"text()",t=1,n=a.previousSibling;for(;n;)n.nodeType===a.nodeType&&t++,n=n.previousSibling;s.unshift(`${e}[${t}]`)}a=a.parentNode}return`/${s.join("/")}`}let B=["id","data-testid","data-test","data-qa","name"],I="text-sky-700 dark:text-sky-400",Y="bg-yellow-200 text-yellow-900 dark:bg-yellow-500/30 dark:text-yellow-100";function F(){let[e,t]=(0,a.useState)(null),[n,w]=(0,a.useState)("xml"),[v,T]=(0,a.useState)(""),[$,C]=(0,a.useState)(""),[_,F]=(0,a.useState)([]),[V,Z]=(0,a.useState)(!0),[J,W]=(0,a.useState)(!1),[G,K]=(0,a.useState)(!1),[Q,ee]=(0,a.useState)(!1),[et,en]=(0,a.useState)(!0),[es,ea]=(0,a.useState)(!1),[er,eo]=(0,a.useState)(""),[ei,el]=(0,a.useState)(null),[ed,ec]=(0,a.useState)(!1),[eu,em]=(0,a.useState)(""),[eh,ep]=(0,a.useState)(!1),[ex,ef]=(0,a.useState)(null),[eg,eb]=(0,a.useState)(!1),ey=(0,a.useRef)(null),ew=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=(0,c.qA)(window.location.search,window.location.hash);if((0,c.Yc)(e,N)){let t=e.get("d"),n=e.get("q"),s=e.get("m");t&&T(t),n&&C(n),w("html"===s||"xml"===s?s:"xml"),ep(!0);return}let t=(0,u.y5)(k);if(t.found)w(t.oneOf("mode",["xml","html"],"xml"));else try{let e=window.localStorage.getItem(k);("html"===e||"xml"===e)&&w(e)}catch{}ep(!0)},[]),(0,r.Vd)(k,()=>JSON.stringify({mode:n}),[n]);let ev=Math.max(0,v.length-2e6),ek=v.trim().length>0&&v.length>6e3,eN=ev>0?v.slice(0,2e6):v,ej=(0,a.useMemo)(()=>{if("undefined"==typeof DOMParser||!eN.trim())return{kind:"idle"};let e=new DOMParser;if("html"===n)return{kind:"ok",doc:e.parseFromString(eN,"text/html")};let t=e.parseFromString(eN,"application/xml"),s=t.querySelector("parsererror");if(s){let e=(s.textContent??"").replace(/\s+/g," ").trim(),t=/line\s+(?:number\s+)?(\d+)/i.exec(e),n=/column\s+(\d+)/i.exec(e);return{kind:"error",message:e||"The document is not well formed XML.",line:t&&t[1]?Number(t[1]):null,column:n&&n[1]?Number(n[1]):null}}return{kind:"ok",doc:t}},[eN,n]),eT=(0,a.useMemo)(()=>"ok"!==ej.kind?{rows:[],total:0,defaultUri:null}:function(e,t){let n=[],s=0,a=null;t&&(n.push({prefix:"xhtml",uri:X,auto:!0,from:"HTML parsing"}),s=1,a=X);let r=new Set,o=e=>{for(let t of Array.from(e.attributes)){if("xmlns"!==t.name&&!t.name.startsWith("xmlns:"))continue;s++;let o="xmlns"===t.name;o&&null===a&&(a=t.value);let i=o?"":t.name.slice(6),l=`${i}|${t.value}`;!r.has(l)&&(r.add(l),n.length>=40||n.push({prefix:o?L(n):i,uri:t.value,auto:o,from:e.nodeName}))}for(let t of Array.from(e.children))o(t)};if(!t&&e.documentElement&&o(e.documentElement),!t&&null===a){let t=e.documentElement;t&&t.namespaceURI&&!t.prefix&&(a=t.namespaceURI,!n.some(e=>e.uri===t.namespaceURI)&&(n.push({prefix:L(n),uri:t.namespaceURI,auto:!0,from:t.nodeName}),s++))}return{rows:n,total:s,defaultUri:a}}(ej.doc,"html"===n),[ej,n]),e$=eT.rows.map(e=>`${e.prefix}=${e.uri}`).join("|"),eS=(0,a.useRef)("");(0,a.useEffect)(()=>{eS.current!==e$&&(eS.current=e$,F(eT.rows))},[e$,eT.rows]);let eC=(0,a.useMemo)(()=>({lookupNamespaceURI(e){if(!e)return null;let t=_.find(t=>t.prefix===e);return t?t.uri:null}}),[_]),eP=es?er:$,eE=(0,a.useMemo)(()=>{if("ok"!==ej.kind)return{state:"idle"};let e=eP.trim();return e?function(e,t,n){let s="undefined"!=typeof performance?performance.now():0,a=()=>"undefined"!=typeof performance?performance.now()-s:0;try{let s=e.evaluate(t,e,n,XPathResult.ANY_TYPE,null);if(s.resultType===XPathResult.NUMBER_TYPE)return{state:"ok",result:{kind:"number",value:s.numberValue},ms:a()};if(s.resultType===XPathResult.STRING_TYPE)return{state:"ok",result:{kind:"string",value:s.stringValue},ms:a()};if(s.resultType===XPathResult.BOOLEAN_TYPE)return{state:"ok",result:{kind:"boolean",value:s.booleanValue},ms:a()};let r=e.evaluate(t,e,n,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),o=r.snapshotLength,i=[],l=Math.min(o,5e3);for(let e=0;e<l;e++){let t=r.snapshotItem(e);t&&i.push(t)}return{state:"ok",result:{kind:"nodes",nodes:i,total:o},ms:a()}}catch(e){return{state:"error",message:e instanceof Error?e.message:"The browser could not read that expression.",ms:a()}}}(ej.doc,e,eC):{state:"idle"}},[ej,eP,eC]);(0,a.useEffect)(()=>{!es&&"idle"!==eE.state&&eE.ms>1200&&(eo(eP),ea(!0))},[eE,es,eP]);let eR=(0,a.useMemo)(()=>"ok"!==eE.state||"nodes"!==eE.result.kind?new Set:new Set(eE.result.nodes),[eE]),eM=(0,a.useMemo)(()=>"ok"===ej.kind?function(e){let t=0,n=[e];for(;n.length&&t<5e5;){let e=n.pop();if(!e)break;t++;let s=e.childNodes;for(let e=0;e<s.length;e++){let t=s[e];t&&n.push(t)}}return t}(ej.doc):0,[ej]),ez=(0,a.useMemo)(()=>"ok"!==ej.kind?null:"html"===n&&ej.doc.body?ej.doc.body:ej.doc.documentElement??null,[ej,n]),eA=null!==ez&&eM>0&&eM<=2e4,eX=(0,a.useCallback)(e=>{if("ok"!==ej.kind)return;let t=H(e,_,"html"===n),s=(1===e.nodeType?function(e,t,n,s,a){let r=D(e,n,s);for(let n of B){let s=e.getAttribute(n);if(!s)continue;let o=`//${r}[@${n}=${function(e){if(!e.includes("'"))return`'${e}'`;if(!e.includes('"'))return`"${e}"`;let t=e.split("'").map(e=>`'${e}'`);return`concat(${t.join(', "\'", ')})`}(s)}]`;if(1===q(t,o,a))return o}return null}(e,ej.doc,_,"html"===n,eC):null)??t;C(s),ef(s===t?null:t),ea(!1),el(null)},[ej,_,n,eC]),eL=(0,a.useMemo)(()=>({matched:eR,onPick:eX}),[eR,eX]),eq=(0,a.useMemo)(()=>"ok"===ej.kind?function(e){let t=new Set,n=e.getElementsByTagName("*"),s=Math.min(n.length,5e3);for(let e=0;e<s;e++){let s=n[e];s&&t.add(s.localName)}return Array.from(t)}(ej.doc):[],[ej]),eU=(0,a.useMemo)(()=>
73{if("ok"!==ej.kind)return[];let e=eP.trim();if(!e)return[];let t=[],s="ok"===eE.state&&"nodes"===eE.result.kind?eE.result.total:null,{funcs:a,ops:r}=function(e){let t=S(e),n=P(t),s=[],a=[];for(let e=0;e<t.length;e++){let r=t[e];"function"===n[e]?s.push(r.text):"operator"===n[e]&&a.push(r.text)}return{funcs:s,ops:a}}(e),o=a.find(e=>b[e]),i=r.find(e=>y[e]);if(o){let n=b[o],a=null;"ends-with"===o?a=function(e){let t=e,n=!1;for(let e=0;e<5;e++){let e=S(t),s=P(e),a=-1;for(let t=0;t<e.length;t++)if("function"===s[t]&&"ends-with"===e[t].text){a=t;break}if(a<0)break;let r=M(t,e,a);if(!r||2!==r.args.length)break;let o=r.args[0],i=r.args[1],l=`substring(${o}, string-length(${o}) - string-length(${i}) + 1) = ${i}`;t=t.slice(0,e[a].start)+l+t.slice(r.end),n=!0}return n?t:null}(e):("lower-case"===o||"upper-case"===o)&&(a=function(e,t){let n="lower-case"===t?z:A,s="lower-case"===t?A:z,a=e,r=!1;for(let e=0;e<5;e++){let e=S(a),o=P(e),i=-1;for(let n=0;n<e.length;n++)if("function"===o[n]&&e[n].text===t){i=n;break}if(i<0)break;let l=M(a,e,i);if(!l||1!==l.args.length)break;let d=`translate(${l.args[0]}, '${n}', '${s}')`;a=a.slice(0,e[i].start)+d+a.slice(l.end),r=!0}return r?a:null}(e,o)),t.push({key:"version",headline:`${o}() is XPath 2.0, and the browser only implements 1.0.`,detail:n.fix?"ends-with"===o?"There is an exact 1.0 equivalent, so the tool has written it out for you.":"There is a 1.0 equivalent using translate(), which swaps single characters, so the rewrite covers A to Z and nothing else.":`XPath 1.0 has no equivalent. The nearest approach is ${n.alt}.`,fix:a?{expr:a,count:q(ej.doc,a,eC),wasCount:s}:void 0})}else i&&t.push({key:"version-op",headline:`That expression uses ${y[i]}, which arrived in XPath 2.0.`,detail:"The browser engine is XPath 1.0, so it cannot parse it at all."});if(0===s&&eT.defaultUri){let n=R(e),s=_.find(e=>e.uri===eT.defaultUri);if(n.length>0&&s){let a,r=(a=s.prefix,E(e,e=>`${a}:${e}`)),o=q(ej.doc,r,eC);null!==o&&o>0&&t.push({key:"namespace",headline:`This document declares a default namespace (${eT.defaultUri}).`,detail:`XPath 1.0 has no default namespace, so ${n[0]} on its own can never match it. The prefix ${s.prefix} is bound for you below.`,fix:{expr:r,count:o,wasCount:0}})}}if(0===s&&"xml"===n&&0===t.length)for(let n of R(e)){let s=eq.find(e=>e.toLowerCase()===n.toLowerCase()&&e!==n);if(!s)continue;let a=E(e,e=>e===n?s:null),r=q(ej.doc,a,eC);if(null!==r&&r>0){t.push({key:"case",headline:`The document spells that element ${s}, not ${n}.`,detail:"XML name tests are case sensitive, so a single letter out means zero nodes and no error.",fix:{expr:a,count:r,wasCount:0}});break}}if(0===s&&0===t.length){let n=function(e){if(!/text\(\)\s*!?=/.test(e))return null;let t=e.replace(/text\(\)(\s*!?=)/g,"normalize-space(text())$1");return t===e?null:t}(e);if(n){let e=q(ej.doc,n,eC);null!==e&&e>0&&t.push({key:"whitespace",headline:"The text is there, with whitespace round it.",detail:"text() hands back the raw characters, including the newline and indent the source file uses. normalize-space() trims the ends and collapses the middle.",fix:{expr:n,count:e,wasCount:0}})}}if(null!==s&&s>1){let n=function(e){let t=e.trim();if(!t.endsWith("]"))return null;let n=0,s=-1;for(let e=t.length-1;e>=0;e--){let a=t[e];if("]"===a)n++;else if("["===a&&0==--n){s=e;break}}if(s<=0)return null;let a=t.slice(s+1,t.length-1).trim();if(!/^\d+$/.test(a))return null;let r=t.slice(0,s).trim();return!r.includes("//")||r.startsWith("(")?null:{base:r,n:a}}(e);if(n){let a=`(${n.base})[${n.n}]`,r=q(ej.doc,a,eC);null!==r&&r!==s&&t.push({key:"precedence",headline:`${e} means every match that is the ${"1"===n.n?"first":`number ${n.n}`}
73 of its own parent.`,detail:"The predicate binds to the step, not to the whole expression, so each parent contributes one. Parentheses around the path apply the number to the finished list instead.",fix:{expr:a,count:r,wasCount:s}})}}if(null!==s&&e.includes("!=")&&t.length<2){let n=function(e){let t=S(e),n=P(t),s=-1;for(let e=0;e<t.length;e++){let n=t[e];"op"===n.type&&"!="===n.text&&(s=e)}if(s<0)return null;let a=e=>{let s=t[e];return"name"===s.type&&"operator"===n[e]&&("and"===s.text||"or"===s.text)},r=0,o=-1;for(let e=s-1;e>=0;e--){let n=t[e];if("op"===n.type){if("]"===n.text||")"===n.text)r++;else if("["===n.text||"("===n.text){if(0===r){o=e;break}r--}else if(","===n.text&&0===r){o=e;break}continue}if(0===r&&a(e)){o=e;break}}r=0;let i=-1;for(let e=s+1;e<t.length;e++){let n=t[e];if("op"===n.type){if("["===n.text||"("===n.text)r++;else if("]"===n.text||")"===n.text){if(0===r){i=e;break}r--}else if(","===n.text&&0===r){i=e;break}continue}if(0===r&&a(e)){i=e;break}}let l=o>=0?t[o].end:0,d=i>=0?t[i].start:e.length,c=e.slice(l,t[s].start).trim(),u=e.slice(t[s].end,d).trim();if(!c||!u)return null;let m=e.slice(0,l),h=e.slice(d),p=/[A-Za-z0-9_)\]]$/.test(m)?" ":"",x=/^[A-Za-z0-9_([]/.test(h)?" ":"";return`${m}${p}not(${c} = ${u})${x}${h}`}(e);if(n){let e=q(ej.doc,n,eC);null!==e&&e!==s&&t.push({key:"notequal",headline:"In XPath 1.0, a != b is true when any node in the set differs.",detail:'That is not the same as "none of them equal it". An element carrying two matching values still passes. not(a = b) is the form people usually mean.',fix:{expr:n,count:e,wasCount:s}})}}return t.slice(0,2)},[ej,eP,eE,eT,_,eC,n,eq]);function eO(e){let t=ew.current;if(!t)return void C(t=>t+e);let n=t.selectionStart??$.length,s=t.selectionEnd??n;C($.slice(0,n)+e+$.slice(s)),ea(!1),window.requestAnimationFrame(()=>{t.focus();let s=n+e.length;t.setSelectionRange(s,s)})}async function e_(e,n){if(!e)return;let{ok:s,note:a}=await (0,p.copyText)(e);s&&(el(n),setTimeout(()=>el(e=>e===n?null:e),1500)),t(a)}async function eD(e){if(e)try{let t=await (0,h.G)(e);T(t.text),em(t.note)}catch(e){em(e instanceof Error&&e.message.includes("UTF-32")?e.message:"")}}function eH(e){C(e),eo(e),ef(null),el(null)}let eB=(0,a.useCallback)(()=>(0,c.CZ)([{key:"m",value:n},{key:"q",value:$.trim()||null,personal:"the expression you wrote"},{key:"d",value:eg&&v&&v.length<=6e3?v:null,personal:"the document you loaded"}]),[$,v,n,eg]),eI="ok"===eE.state?eE.result:null,eY=(0,a.useMemo)(()=>eI&&"nodes"===eI.kind?eI.nodes.slice(0,200):[],[eI]),eF=eI&&"nodes"===eI.kind?Math.max(0,eI.total-eY.length):0,eV=(0,a.useMemo)(()=>{if(0===eY.length)return"";let e=eY.map(e=>O(e,V).text);return J?JSON.stringify(e,null,2):e.join("\n")},[eY,V,J]),eZ=e=>e.includes("'")?`"${e.replace(/"/g,'\\"')}"`:`'${e}'`,eJ=_.filter(e=>e.prefix).map(e=>`'${e.prefix}': '${e.uri}'`).join(", "),eW=_.filter(e=>e.prefix).map(e=>`${/^[A-Za-z_$][\w$]*$/.test(e.prefix)?e.prefix:`'${e.prefix}'`}: '${e.uri}'`).join(", "),eG=$.trim()||"//your/path",eK=[{label:"Selenium, Python",code:`driver.find_elements(By.XPATH, ${eZ(eG)})`},{label:"Selenium, Java",code:`driver.findElements(By.xpath("${eG.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"))`},{label:"Playwright",code:`page.locator(${eZ(`xpath=${eG}`)})`},{label:"lxml",code:eJ?`tree.xpath(${eZ(eG)}, namespaces={${eJ}})`:`tree.xpath(${eZ(eG)})`},{label:"The browser, with the resolver this tool built",code:`const ns = {${eW}}; 74const r = document.evaluate( 75 ${eZ(eG)}, 76 document, 77 { lookupNamespaceURI: (p) => ns[p] || null }, 78 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, 79 null, 80); 81for (let i = 0; i < r.snapshotLength; i++) console.log(r.snapshotItem(i));`}],eQ="error"===ej.kind&&null!==ej.line?eN.split("\n")[ej.line-1]:void 0;return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:"Parse as"}),["xml","html"].map(e=>(0,s.jsx)(l.$,{type:"button",size:"sm",variant:n===e?"default":"outline",onClick:()=>w(e),children:"xml"===e?"XML":"HTML"},e)),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"xml"===n?"Strict. A missing tag is reported with the line it happened on.":"Forgiving. Broken markup is repaired and wrapped in a full page, exactly as a browser would, so the tree can differ from what you pasted."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(i.J,{htmlFor:"xp-doc",children:"Your document"}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("button",{type:"button",onClick:()=>ey.current?.click(),className:"text-xs font-medium text-primary underline-offset-2 hover:underline",children:"Load a file"}),(0,s.jsx)("input",{ref:ey,type:"file",accept:".xml,.html,.htm,.xhtml,.svg,.rss,.atom,.txt,text/*,application/xml",className:"hidden",onChange:e=>{eD(e.target.files?.[0]),e.target.value=""}})]})]}),(0,s.jsx)(o.T,{id:"xp-doc","aria-label":"XML or HTML document to query",placeholder:"Paste your XML or HTML here, or drag a file onto this box.",value:v,onCh
81ange:e=>T(e.target.value),onDrop:function(e){e.preventDefault(),ec(!1),eD(e.dataTransfer.files?.[0])},onDragOver:e=>{e.preventDefault(),ec(!0)},onDragLeave:()=>ec(!1),className:(0,m.cn)("min-h-[170px] font-mono transition-colors",ed&&"border-primary ring-2 ring-ring"),spellCheck:!1}),""!==eu&&(0,s.jsx)("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-400",role:"status",children:eu}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click to browse, drag a file in, or just paste. Your document stays in this tab and is never uploaded."}),ev>0&&(0,s.jsxs)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-200",children:["The last ",x(ev)," characters were not parsed. The document is capped at ",x(2e6)," ","characters."]})]}),"error"===ej.kind&&(0,s.jsxs)("div",{role:"alert",className:"space-y-1 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"font-medium",children:"This is not well formed XML."})," ",null!==ej.line?`The browser reports line ${ej.line}${null!==ej.column?`, column ${ej.column}`:""}.`:"The browser did not report a position for it."]}),void 0!==eQ&&(0,s.jsx)("pre",{className:"overflow-x-auto rounded bg-background/60 px-2 py-1 font-mono text-xs",children:eQ}),(0,s.jsx)("p",{className:"text-xs opacity-90",children:ej.message}),(0,s.jsx)("p",{className:"text-xs opacity-90",children:"Positions come from the browser and are not standardized, so treat them as a starting point. Switch to HTML mode if this is markup rather than XML."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(i.J,{htmlFor:"xp-expr",children:"XPath expression"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{id:"xp-expr",ref:ew,type:"text",spellCheck:!1,autoComplete:"off",className:"flex h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"//book[@format='pdf']/title",value:$,onChange:e=>{C(e.target.value),ef(null),el(null)},onKeyDown:e=>{"Enter"===e.key&&es&&eo($)}}),es&&(0,s.jsx)(l.$,{type:"button",size:"sm",onClick:()=>eo($),children:"Run"}),(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",disabled:!$.trim(),onClick:()=>e_($.trim(),"expr"),children:"expr"===ei?"Copied!":"Copy"})]}),ex&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["That element also has an attribute worth anchoring to, so you got the stable form. The positional path is"," ",(0,s.jsx)("button",{type:"button",onClick:()=>{C(ex),ef(null)},className:"font-mono text-primary underline-offset-2 hover:underline",children:ex}),", which is what Copy full XPath gives you in browser dev tools and breaks the moment anything is reordered."]}),es&&(0,s.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["The last expression took longer than ",1200," milliseconds, so live typing is off to keep the tab responsive. Press Run or Enter to evaluate."," ",(0,s.jsx)("button",{type:"button",onClick:()=>ea(!1),className:"text-primary underline-offset-2 hover:underline",children:"Turn live typing back on"})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Try one:"}),j.map(e=>(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{w(e.mode),T(e.doc),C(e.expr),eo(e.expr),ea(!1),ef(null),el(null)},children:e.name},e.name)),(0,s.jsx)(l.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":G,onClick:()=>K(e=>!e),children:G?"Hide reference":"Axes and functions"}),(0,s.jsx)(l.$,{type:"button",variant:"ghost",size:"sm",onClick:function(){T(""),C(""),eo(""),ea(!1),ef(null),el(null)},disabled:!v&&!$,children:"Clear"})]}),"ok"===ej.kind&&_.length>0&&(0,s.jsxs)("div",{className:"rounded-md border bg-muted/40 p-3 text-sm",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("p",{className:"font-medium",children:["Namespaces (",_.length," bound",eT.total>_.length?`, ${x(eT.total-_.length)} not listed`:"",")"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",disabled:!$.trim(),onClick:()=>eH(E($.trim(),e=>`*[local-name()='${e}']`)),title:"Rewrite every name test as *[local-name()='...']",children:"Ignore namespaces"}),(0,s.jsx)(l.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>en(e=>!e),children:et?"Hide":"Show"})]})]}),et&&(0,s.jsxs)("div",{className:"mt-2 space-y-1",children:[_.map((e,t)=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("input",{"aria-label":`Prefix for ${e.uri}`,value:e.prefix,onChange:e=>{let n=e.target.value.replace(/[^A-Za-z0-9_.-]/g,"");F(e=>e.map((e,s)=>s===t?{...e,prefix:n}:e))},className:"h-7 w-24 rounded border border-input bg-background px-2 font-mono text-xs"}),(0,s.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:e.uri}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.auto?"auto bound, the declaration had no prefix":`declared on ${e.from}`})]},`${e.uri}-${t}`)),(0,s.jsx)("p",{className:"pt-1 text-xs text-muted-foreground",children:"Edit a prefix and every expression using it re-evaluates. Ignore namespaces rewrites your name tests with local-name(), which also matches an element of that name in a different namespace, so on a mixed document it can pick up more than you wanted."})]})]}),G&&(0,s.jsxs)("div",{className:"space-y-3 rounded-md border bg-muted/40 p-3 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"font-medium",children:["The ",f.length," axes"]}),(0,s.jsx)("p",{className:"mb-1 text-xs text-muted-foreground",children:"Click one to drop it into your expression."}),(0,s.jsx)("div",{className:"space-y-0.5",children:f.map(e=>(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 sm:flex-row sm:gap-3",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>eO(`${e.name}::`),className:"shrink-0 text-left font-mono text-xs text-primary underline-offset-2 hover:underline sm:w-44",children:[e.name,"::"]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.what})]},e.name))})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"font-medium",children:["The ",g.length," core functions"]}),(0,s.jsx)("p",{className:"mb-1 text-xs text-muted-foreground",children:"ends-with() is not among them, even though starts-with() and contains() are. That one gap causes more broken expressions than anything else on this page."}),(0,s.jsx)("div",{className:"space-y-0.5",children:g.map(e=>(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 sm:flex-row sm:gap-3",children:[(0,s.jsx)("button",{type:"button",onClick:()=>eO(`${e.name}(`),className:"shrink-0 text-left font-mono text-xs text-primary underline-offset-2 hover:underline sm:w-56",children:e.sig}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,s.jsxs)("span",{className:"opacity-70",children:[e.group,". "]}),e.what]})]},e.name))})]})]}),eU.map(e=>(0,s.jsxs)("div",{className:"space-y-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-950 dar
81k:text-amber-100",children:[(0,s.jsx)("p",{className:"font-medium",children:e.headline}),(0,s.jsx)("p",{className:"opacity-90",children:e.detail}),e.fix&&null!==e.fix.count&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("span",{className:"font-mono text-xs",children:[eP.trim(),": ",null===e.fix.wasCount?"no result":`${x(e.fix.wasCount)} nodes`]}),(0,s.jsx)("span",{className:"opacity-60",children:"vs"}),(0,s.jsxs)("span",{className:"font-mono text-xs",children:[e.fix.expr,": ",x(e.fix.count)," nodes"]}),(0,s.jsx)(l.$,{type:"button",size:"sm",onClick:()=>eH(e.fix?.expr??""),children:"Use it"})]})]},e.key)),"error"===eE.state&&(0,s.jsxs)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,s.jsx)("span",{className:"font-medium",children:"The browser rejected that expression:"})," ",eE.message]}),eI&&(0,s.jsxs)("div",{"aria-live":"polite",className:"rounded-md border bg-muted px-4 py-3 text-sm",children:["nodes"===eI.kind?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"font-medium",children:["Node set. ",1===eI.total?"1 node":`${x(eI.total)} nodes`]}),0===eI.total&&0===eU.length&&(0,s.jsx)("p",{className:"mt-1 text-muted-foreground",children:"Cut the expression back one step at a time. The step where the count drops to zero is the one that is wrong."}),eF>0&&(0,s.jsxs)("p",{className:"mt-1 text-muted-foreground",children:[x(eF)," were not shown below."]})]}):"number"===eI.kind?(0,s.jsxs)("p",{className:"font-medium",children:["Number. ",(0,s.jsx)("span",{className:"font-mono",children:Number.isNaN(eI.value)?"NaN":eI.value})]}):"boolean"===eI.kind?(0,s.jsxs)("p",{className:"font-medium",children:["Boolean. ",(0,s.jsx)("span",{className:"font-mono",children:String(eI.value)})]}):(0,s.jsxs)("p",{className:"font-medium",children:["String. ",(0,s.jsx)("span",{className:"font-mono break-words",children:eI.value||"(empty)"})]}),"nodes"!==eI.kind&&(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["XPath 1.0 has four types. This one came back as a ",eI.kind,", which is why there is nothing to highlight in the tree."]})]}),eY.length>0&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Matches"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",onClick:()=>Z(e=>!e),children:V?"Whole node":"Text only"}),(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",onClick:()=>W(e=>!e),children:J?"JSON":"One per line"}),(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",onClick:()=>e_(eV,"values"),children:"values"===ei?"Copied!":"Copy results"}),(0,s.jsx)(l.$,{type:"button",variant:"outline",size:"sm",onClick:()=>e_(eY.map(e=>H(e,_,"html"===n)).join("\n"),"paths"),children:"paths"===ei?"Copied!":"Copy paths"})]})]}),(0,s.jsx)("ul",{className:"max-h-[380px] space-y-2 overflow-auto rounded-md border bg-muted px-4 py-3 text-sm",children:eY.map((e,t)=>{let n=O(e,V);return(0,s.jsxs)("li",{className:"break-words",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"rounded bg-background px-1.5 py-0.5",children:U[e.nodeType]??"node"}),(0,s.jsx)("span",{className:"font-mono",children:function(e){let t=[],n=2===e.nodeType?e.ownerElement:e;for(;n&&1===n.nodeType;)t.unshift(n.nodeName),n=n.parentNode;return 2===e.nodeType&&t.push(`@${e.name}`),t.join(" > ")}(e)}),(0,s.jsx)("button",{type:"button",onClick:()=>eX(e),className:"text-primary underline-offset-2 hover:underline",children:"narrow to this one"})]}),(0,s.jsx)("pre",{className:"mt-0.5 overflow-x-auto font-mono text-xs",children:n.text}),n.omitted>0&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[x(n.omitted)," characters of this node were not shown."]})]},t)})})]}),"ok"===ej.kind&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("p",{className:"text-sm font-medium",children:["Document",eR.size>0?" with matches highlighted":""]}),eA&&ez?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"max-h-[420px] overflow-auto rounded-md border bg-muted px-4 py-3 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:function e(t,n,a,r){let o=" ".repeat(n);if(3===t.nodeType||4===t.nodeType){let e=(t.nodeValue??"").trim();return e?(0,s.jsxs)("span",{children:[o,(0,s.jsx)("span",{onClick:e=>{e.stopPropagation(),a.onPick(t)},className:(0,m.cn)("cursor-pointer rounded-sm",a.matched.has(t)&&Y),children:e.length>200?`${e.slice(0,200)}...`:e}),"\n"]},r):null}if(8===t.nodeType)return(0,s.jsxs)("span",{children:[o,(0,s.jsx)("span",{onClick:e=>{e.stopPropagation(),a.onPick(t)},className:(0,m.cn)("cursor-pointer rounded-sm text-muted-foreground",a.matched.has(t)&&Y),children:`<!--${(t.nodeValue??"").slice(0,120)}-->`}),"\n"]},r);if(1!==t.nodeType)return null;let i=Array.from(t.attributes),l=Array.from(t.childNodes).filter(e=>
811===e.nodeType||8===e.nodeType||(3===e.nodeType||4===e.nodeType)&&(e.nodeValue??"").trim()),d=1===l.length&&l[0]&&(3===l[0].nodeType||4===l[0].nodeType),c=(0,s.jsxs)("span",{onClick:e=>{e.stopPropagation(),a.onPick(t)},className:(0,m.cn)("cursor-pointer rounded-sm",a.matched.has(t)&&Y),title:"Click for the XPath that selects this element",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"<"}),(0,s.jsx)("span",{className:I,children:t.nodeName})]}),u=i.map(e=>(0,s.jsxs)("span",{onClick:t=>{t.stopPropagation(),a.onPick(e)},className:(0,m.cn)("cursor-pointer rounded-sm",a.matched.has(e)&&Y),title:"Click for the XPath that selects this attribute",children:[" ",(0,s.jsx)("span",{className:"text-purple-700 dark:text-purple-400",children:e.name}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"="}),(0,s.jsx)("span",{className:"text-emerald-700 dark:text-emerald-400",children:`"${e.value.length>90?`${e.value.slice(0,90)}...`:e.value}"`})]},e.name));if(0===l.length)return(0,s.jsxs)("span",{children:[o,c,u,(0,s.jsx)("span",{className:"text-muted-foreground",children:"/>"}),"\n"]},r);if(d){let e=l[0],n=(e.nodeValue??"").trim();return(0,s.jsxs)("span",{children:[o,c,u,(0,s.jsx)("span",{className:"text-muted-foreground",children:">"}),(0,s.jsx)("span",{onClick:t=>{t.stopPropagation(),a.onPick(e)},className:(0,m.cn)("cursor-pointer rounded-sm",a.matched.has(e)&&Y),children:n.length>200?`${n.slice(0,200)}...`:n}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"</"}),(0,s.jsx)("span",{className:I,children:t.nodeName}),(0,s.jsx)("span",{className:"text-muted-foreground",children:">"}),"\n"]},r)}return(0,s.jsxs)("span",{children:[o,c,u,(0,s.jsx)("span",{className:"text-muted-foreground",children:">"}),"\n",l.map((t,s)=>e(t,n+1,a,`${r}-${s}`)),o,(0,s.jsx)("span",{className:"text-muted-foreground",children:"</"}),(0,s.jsx)("span",{className:I,children:t.nodeName}),(0,s.jsx)("span",{className:"text-muted-foreground",children:">"}),"\n"]},r)}(ez,0,eL,"root")}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click any element, attribute, or text node and the XPath that selects it lands in the box above."})]}):(0,s.jsxs)("p",{className:"rounded-md border bg-muted px-4 py-3 text-xs text-muted-foreground",children:["The clickable tree was not built. This document has ",x(eM)," nodes and the limit is"," ",x(2e4),". The match list above is unaffected."]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(l.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":Q,onClick:()=>ee(e=>!e),children:Q?"Hide code":"Use this expression in code"}),Q&&(0,s.jsx)("div",{className:"mt-2 space-y-2 rounded-md border bg-muted/40 p-3",children:eK.map(e=>(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium",children:e.label}),(0,s.jsx)("button",{type:"button",onClick:()=>e_(e.code,e.label),className:"text-xs text-primary underline-offset-2 hover:underline",children:ei===e.label?"Copied!":"Copy"})]}),(0,s.jsx)("pre",{className:"overflow-x-auto rounded bg-background px-2 py-1 font-mono text-xs",children:e.code})]},e.label))})]}),"idle"===ej.kind&&(0,s.jsx)("p",{"aria-live":"polite",className:"rounded-md border bg-muted px-4 py-3 text-sm text-muted-foreground",children:"Paste a document to get started, or load one of the examples above. Each one demonstrates a different reason an expression comes back empty."}),eh&&eg&&ek&&(0,s.jsxs)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-200",children:["This document is ",x(v.length)," characters, which is too long to fit in a link. The limit is ",x(6e3),", so a share or embed link carries your expression but not the document. Send the file separately."]}),eh&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 rounded border-input accent-primary",checked:eg,onChange:e=>eb(e.target.checked)}),(0,s.jsx)("span",{children:"Put the document in the Share link too. Off by default, so Share copies your expression and the mode and n
81one of the file you loaded."})]}),(0,s.jsx)(d.ToolActions,{share:eB,title:"XPath Tester",embedCarriesPersonal:!1})]}),e&&(0,s.jsx)("p",{role:"status","aria-live":"polite",className:"text-xs text-destructive",children:e})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.