PageSourceSearch

https://tools.fthux.com/_nuxt/mZFS2fRO.js

js fthux.com collected 2026-09-24 14:13:44 UTC 14,453 bytes, 9 lines download raw bytes

1import{d as U,r as f,D as R,f as V,g as r,F as J,A as X,o as n,y as b,i as s,t as i,z as k,k as B,G as K,u as Q,b as W,c as Y,e as Z,I as D,B as ee,C as te,h as se,q as oe,s as le,M as ne}from"./DzfUrCz9.js";const re={class:"font-mono text-sm leading-6 w-full"},ae={key:0,class:"select-none text-slate-500 w-10 text-right pr-3 border-r border-slate-700/50 mr-2 flex-shrink-0"},ie={key:0,class:"text-red-700 font-bold"},ue=["onClick"],ce={class:"text-slate-400 font-bold"},de={key:0,class:"text-slate-500 mx-1"},pe={key:1,class:"text-slate-400"},fe={key:0},ve={class:"text-slate-400 ml-4"},me={key:0},he={key:0},ge=U({__name:"JsonTree",props:{data:{},expandAll:{type:Boolean},defaultCollapsed:{type:Boolean},isEscaped:{type:Boolean},showLineNumbers:{type:Boolean}},setup(E){const v=E,C=f([]),a=f(new Set);f(new Map);let m=0,h=0;const $=(l,u=0,o="root")=>{const c=[];if(l===null||typeof l!="object")return m++,h++,c.push({id:h,lineNumber:m,depth:u,content:"",type:"primitive",hasChildren:!1,path:o,canCollapse:!1,value:l}),c;const y=Array.isArray(l),O=Object.keys(l),L=O.length===0;m++,h++;const S={id:h,lineNumber:m,depth:u,content:"",type:"open",hasChildren:!L,path:o,canCollapse:!L,value:y?"[":"{"};if(c.push(S),L||O.forEach((_,F)=>{const I=F===O.length-1,H=`${o}.${_}`,N=$(l[_],u+1,H);N.length===1&&N[0].type,N[0].key=y?void 0:_,c.push(...N);const P=c[c.length-1];P.needsComma=!I}),L)S.value=y?"[]":"{}",S.canCollapse=!1;else{m++,h++;const _={id:h,lineNumber:m,depth:u,content:"",type:"close",hasChildren:!1,path:`${o}-close`,canCollapse:!1,value:y?"]":"}"};S.pairId=_.id,c.push(_)}return c};R(()=>v.data,()=>{if(m=0,h=0,C.value=$(v.data),v.defaultCollapsed){const l=C.value.filter(u=>u.canCollapse).map(u=>u.path);a.value=new Set(l)}else a.value.clear()},{immediate:!0});const T=l=>{a.value.has(l)?a.value.delete(l):a.value.add(l)};R(()=>v.defaultCollapsed,l=>{if(l){const u=C.value.filter(o=>o.canCollapse).map(o=>o.path);a.value=new Set(u)}else a.value.clear()});const A=l=>{if(l.depth===0)return!0;const u=l.path.split(".");let o=u[0];if(a.value.has(o))return!1;for(let c=1;c<u.length&&!(c===u.length-1&&l.type!=="close");c++)if(o+="."+u[c],a.value.has(o))return!1;if(l.type==="close"){const c=l.path.replace("-close","");if(a.value.has(c))return!1}return!0},j=V(()=>C.value.filter(l=>A(l))),w=l=>({paddingLeft:v.showLineNumbers?`${l*1.5}rem`:`${l*1.5+1}rem`}),M=l=>typeof l=="string"?v.isEscaped?JSON.stringify(l):`"${l}"`:String(l),x=l=>typeof l=="string"?"text-green-600 whitespace-pre-wrap break-all":typeof l=="number"?"text-purple-600":typeof l=="boolean"?"text-blue-600":l===null?"text-slate-500":"text-slate-700";return(l,u)=>(n(),r("div",re,[(n(!0),r(J,null,X(j.value,o=>(n(),r("div",{key:o.id,class:"flex items-start hover:bg-slate-800/20"},[E.showLineNumbers?(n(),r("div",ae,i(o.lineNumber),1)):b("",!0),s("div",{class:"flex-grow pb-0.5",style:K(w(o.depth))},[o.key?(n(),r("span",ie,'"'+i(o.key)+'": ',1)):b("",!0),o.type==="open"?(n(),r("span",{key:1,onClick:c=>T(o.path),class:"cursor-pointer inline-flex items-center select-none"},[s("span",{class:k(["mr-1 text-slate-500 w-3 inline-block text-center transition-transform",{"-rotate-90":a.value.has(o.path)}])}," ▼ ",2),s("span",ce,i(o.value),1),a.value.has(o.path)?(n(),r("span",de,i(o.value==="["?"Array(...)":"Object{...}"),1)):b("",!0),a.value.has(o.path)?(n(),r("span",pe,[B(i(o.value==="["?"]":"}"),1),o.needsComma?(n(),r("span",fe,",")):b("",!0)])):b("",!0)],8,ue)):o.type==="close"?(n(),r(J,{key:2},[s("span",ve,i(o.value),1),o.needsComma?(n(),r("span",me,",")):b("",!0)],64)):(n(),r(J,{key:3},[s("span",{class:k(x(o.value))},i(M(o.value)),3),o.needsComma?(n(),r("span",he,",")):b("",!0)],64))],4)]))),128))]))}}),be=Object.assign(ge,{__name:"JsonTree"}),xe={key:0,class:"text-center mb-8"},ke={class:"text-3xl md:text-4xl font-black text-slate-900 mb-4"},ye={class:"text-slate-500 max-w-2xl mx-auto"},we={class:"flex flex-wrap gap-2 mb-4 p-2 bg-slate-50 rounded-xl border border-slate-100 items-center justify-between"},_e={class:"flex flex-wrap gap-2 items-center"},Ce={key:0,class:"flex items-center"},$e={key:1,class:"flex items-center"},je=["title"],Me={key:0,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Le={key:1,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Se={class:"grid grid-cols-1 lg:grid-cols-2 gap-4 flex-grow min-h-0"},Be={class:"flex flex-col h-full min-h-[400px]"},Ae=["placeholder"],Ne={class:"flex flex-col h-full min-h-[400px]"},Oe={class:"flex-1 min-h-0 bg-slate-900 rounded-xl border border-slate-800 relative overflow-hidden flex flex-col"},Te={key:0,class:"absolute inset-0 z-10 bg-slate-900/90 backdrop-blur-sm flex items-center justify-center p-8"},Ve={class:"bg-rose-500/10 border border-rose-500/20 text-rose-400 p-6 rounded-xl max-w-lg w-full"},Je={class:"font-mono text-sm mb-4 break-words"},Ee={key:0,class:"text-xs bg-rose-500/20 inline-block px-2 py-1 rounded text-rose-200 font-mono"},Fe={class:"flex-1 min-h-0 overflow-auto custom-scrollbar p-0"},Ie={key:1,class:"font-mono text-sm leading-6 min-h-full flex flex-col"}
1,He={key:0,class:"select-none text-slate-500 w-10 text-right pr-3 border-r border-slate-700/50 mr-2 flex-shrink-0"},Pe={key:2,class:"h-full flex items-center justify-center text-slate-700 font-medium"},Re=U({__name:"json-formatter",setup(E){const{t:v}=Q(),C=W();Y({title:()=>v("json_formatter.title"),ogTitle:()=>v("json_formatter.title"),description:()=>v("json_formatter.desc"),ogDescription:()=>v("json_formatter.desc"),ogImage:C.site.ogImage,twitterCard:"summary_large_image"}),Z({script:[{type:"application/ld+json",innerHTML:JSON.stringify({"@context":C.site.schema.context,"@type":"SoftwareApplication",name:v("json_formatter.title"),description:v("json_formatter.desc"),applicationCategory:"DeveloperApplication",operatingSystem:"Any"})}]});const a=f(""),m=f(""),h=f(""),$=f(!0),T=f(!1),A=f(!1),j=f(!1),w=f(!0),M=f(!0),x=f(!1),l=f(0),u=f(!1),o=V(()=>{if(!a.value.trim())return null;try{const t=JSON.parse(a.value);let e=t;return j.value&&(e=S(t)),j.value?A.value?e.replace(/>\s+</g,"><"):F(e):A.value?JSON.stringify(e):e}catch{return null}}),c=V(()=>!$.value||!o.value?"empty":typeof o.value=="object"?"tree":"text"),y=V(()=>
1{let t=o.value;if(typeof t=="object"&&t!==null&&(t=JSON.stringify(t,null,4)),typeof t=="string"&&!w.value)try{return t.replace(/\\n/g,`
2`).replace(/\\t/g,"	").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return t}return t||""});let O;R(a,()=>{clearTimeout(O),O=setTimeout(L,300)});const L=()=>{if(!a.value.trim()){$.value=!0,m.value="",h.value="";return}try{JSON.parse(a.value),$.value=!0,m.value="",h.value=""}catch(t){$.value=!1,m.value=t.message;const e=t.message.match(/position (\d+)/);if(e&&e[1]){const p=parseInt(e[1]),d=a.value.substring(0,p).split(`
3`),g=d[d.length-1];h.value=`Line ${d.length}, Column ${(g?.length||0)+1}`}}};V(()=>a.value?a.value.split(`
4`).length:1);const S=(t,e="root")=>{let p="";if(typeof t!="object"||t===null)return`<${e}>${t}</${e}>`;if(Array.isArray(t))return t.forEach(d=>p+=S(d,"item")),_(p)>1?`<${e}>${p}</${e}>`:p;for(const d in t)p+=S(t[d],d);return e==="root"?`<root>${p}</root>`:`<${e}>${p}</${e}>`},_=t=>(t.match(/<item>/g)||[]).length,F=t=>{let e="",p=0;return t.split(/>\s*</).forEach(d=>{d.match(/^\/\w/)&&(p=-1),e+=new Array(Math.max(0,p)).fill("  ").join("")+"<"+d+`>\r
5`,p+=d.match(/^[\w]/)&&!d.match(/<\//)?1:0}),e.substring(1,e.length-3)},I=()=>{a.value="",L()},H=()=>{a.value=JSON.stringify({website:C.site.domain,description:`A cool tool website with <b>HTML</b> support.
6New lines are escaped.`,tools:[{name:"JSON Formatter",status:"active"},{name:"QR Code",status:"active"}],meta:{created:2024,secure:!0,path:"C:\\Windows\\System32"},unicode:"❤"},null,4),L()},N=()=>{let t=y.value||"";typeof o.value=="object"&&(t=JSON.stringify(o.value,null,4),w.value||(t=t.replace(/\\n
6/g,`
7`).replace(/\\t/g,"	").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))),t&&navigator.clipboard.writeText(t).then(()=>{T.value=!0,setTimeout(()=>T.value=!1,2e3)})},P=()=>{let t=y.value||"";if(typeof o.value=="object"&&(t=JSON.stringify(o.value,null,4),w.value||(t=t.replace(/\\n/g,`
8`).replace(/\\t/g,"	").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))),!t)return;const e=j.value?"xml":"json",p=new Blob([t],{type:"text/plain"}),d=URL.createObjectURL(p),g=document.createElement("a");g.href=d,g.download=`data.${e}`,g.click(),URL.revokeObjectURL(d)},q=()=>x.value=!x.value,G=()=>{u.value=!u.value,l.value++};return(t,e)=>{const p=oe,d=le;return n(),r("div",{class:k(["min-h-screen bg-[#F8F9FA] flex flex-col transition-all duration-300",{"fixed inset-0 z-50 bg-white":x.value}])},[x.value?b("",!0):(n(),D(p,{key:0})),s("div",{class:k(["flex-grow container mx-auto px-4 py-8",{"!p-0 !max-w-none h-screen":x.value}])},[s("div",{class:k(["bg-white rounded-2xl shadow-sm border border-slate-200 p-6 md:p-8 flex flex-col h-[calc(100vh-180px)] min-h-[500px]",{"!rounded-none !border-0 !shadow-none !p-4 !min-h-0 !h-full":x.value}])},[x.value?b("",!0):(n(),r("div",xe,[s("h1",ke,i(t.$t("json_formatter.title")),1),s("p",ye,i(t.$t("json_formatter.subtitle")),1)])),s("div",we,[s("div",_e,[s("button",{onClick:e[0]||(e[0]=g=>A.value=!A.value),class:k(["btn-toggle",A.value?"btn-active":"btn-inactive"])},[e[5]||(e[5]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})],-1)),B(" "+i(t.$t("json_formatter.actions.compress")),1)],2),s("button",{onClick:e[1]||(e[1]=g=>j.value=!j.value),class:k(["btn-toggle",j.value?"btn-active":"btn-inactive"])},[e[6]||(e[6]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})],-1)),B(" "+i(t.$t("json_formatter.actions.xml")),1)],2),s("button",{onClick:e[2]||(e[2]=g=>w.value=!w.value),class:k(["btn-toggle",w.value?"btn-active":"btn-inactive"])},[e[7]||(e[7]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})],-1)),B(" "+i(t.$t("json_formatter.actions.preserve_escape")),1)],2),s("button",{onClick:e[3]||(e[3]=g=>M.value=!M.value),class:k(["btn-toggle",M.value?"btn-active":"btn-inactive"])},[e[8]||(e[8]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h16M4 18h16"})],-1)),B(" "+i(t.$t("json_formatter.options.line_numbers")),1)],2),e[11]||(e[11]=s("div",{class:"w-px h-6 bg-slate-300 mx-1"},null,-1)),s("button",{onClick:G,class:"btn-action"},[u.value?(n(),r("span",$e,[e[10]||(e[10]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 15l7-7 7 7"})],-1)),B(" "+i(t.$t("json_formatter.actions.expand_all")),1)])):(n(),r("span",Ce,[e[9]||(e[9]=s("svg",{class:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})],-1)),B(" "+i(t.$t("json_formatter.actions.collapse_all")),1)]))]),e[12]||(e[12]=s("div",{class:"w-px h-6 bg-slate-300 mx-1"},null,-1)),s("button",{onClick:H,class:"btn-action"},i(t.$t("json_formatter.actions.example")),1),s("button",{onClick:N,class:"btn-action"},i(T.value?t.$t("json_formatter.status.copied"):t.$t("json_formatter.actions.copy")),1),s("button",{onClick:P,class:"btn-action"},i(t.$t("json_formatter.actions.save")),1),s("button",{onClick:I,class:"btn-action text-rose-600 hover:bg-rose-50"},i(t.$t("json_formatter.actions.clear")),1)]),s("button",{onClick:q,class:"p-2 text-slate-500 hover:text-red-600 transition-colors",title:t.$t("json_formatter.actions.fullscreen")},[x.value?(n(),r("svg",Le,[...e[14]||(e[14]=[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 6V10H6M10 10L4 4M14 6V10h4M14 10l6-6M10 18v-4H6M10 14l-6 6M14 18v-4h4M14 14l6 6"},null,-1)])])):(n(),r("svg",Me,[...e[13]||(e[13]=[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"},null,-1)])]))],8,je)]),s("div",Se,[s("div",Be,[s("div",{class:k(["flex-grow relative border-2 rounded-xl overflow-hidden transition-colors flex",$.value?"border-slate-200 focus-within:border-red-500":"border-red-300 focus-within:border-red-500"])},[ee(s("textarea",{"onUpdate:modelValue":e[4]||(e[4]=g=>a.value=g),placeholder:t.$t("json_formatter.placeholder"),class:"flex-grow h-full p-4 font-mono text-sm bg-slate-50 border-0 resize-none focus:outline-none focus:ring-0 leading-6 custom-scrollbar w-full overflow-y-auto",spellcheck:"false"},null,8,Ae),[[te,a.value]])],2)]),s("div",Ne,[s("div",Oe,[m.value?(n(),r("div",Te,[s("div",Ve,[e[15]||(e[15]=s("h3",{class:"font-bold text-lg mb-2 flex items-center"},[s("svg",{class:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),B(" Parse Error ")],-1)),s("p",Je,i(m.value),1),h.value?(n(),r("div",Ee,i(h.value),1)):b("",!0)])])):b("",!0),s("div",Fe,[c.value==="tree"?(n(),r("div",{key:"tree-"+l.value,class:"min-h-full"},[se(be,{data:o.value,"default-collapsed":u.value,"is-escaped":w.value,"show-line-numbers":M.value},null,8,["data","default-collapsed","is-escaped","show-line-numbers"])])):y.value?(n(),r("div",Ie,[(n(!0),r(J,null,X(y.value.split(`
9`),(g,z)=>(n(),r("div",{key:z,class:"flex items-start hover:bg-slate-800/20"},[M.value?(n(),r("div",He,i(Number(z)+1),1)):b("",!0),s("div",{class:k(["flex-grow whitespace-pre-wrap break-all text-slate-300 pr-4",{"pl-4":!M.value}])},i(g),3)]))),128))])):(n(),r("div",Pe,i(t.$t("json_formatter.status.waiting_for_input")),1))])])])])],2)],2),x.value?b("",!0):(n(),D(d,{key:1}))],2)}}}),De=ne(Re,[["__scopeId","data-v-3af7624d"]]);export{De as default};

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.