mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 22:07:10 -04:00
2 lines
4.8 KiB
JavaScript
2 lines
4.8 KiB
JavaScript
![]() |
import{d as w,j as p,D as _,a7 as O,G as T,c as g,E as d,M as D,q as s,m as u,g as S,S as V,k as I,l as v,F as M,U,z as j,L as F,K as q}from"./chunk-449c23a2.js";import{_ as G}from"./chunk-6deddc2e.js";import{i as x,a as k}from"./chunk-1e650f13.js";import{c as $}from"./chunk-81b950ae.js";import{a as K}from"./chunk-a740628f.js";import{_ as N}from"./chunk-92eb22f4.js";import{u as C}from"./chunk-340feaf0.js";import{_ as H}from"./chunk-f82e52c7.js";import{_ as J}from"./chunk-5ef11c84.js";import{I as Q}from"../entries/src_pages_Home.page.16dc467b.js";import"./chunk-9a43cce8.js";import"./chunk-767079b6.js";import"./chunk-a0dc36f0.js";import"./chunk-60fffae6.js";import"./chunk-567e13ca.js";import"./chunk-aff6c081.js";import"./chunk-416dc92c.js";import"./chunk-9519e52e.js";import"./chunk-f94e2689.js";import"./chunk-6e5bd8af.js";import"./chunk-f206ee20.js";import"./chunk-f92ba12f.js";import"./chunk-cf010ec4.js";import"./chunk-ee54c1e8.js";const W={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 24 24"},X=O('<g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="5" cy="18" r="2"></circle><circle cx="19" cy="6" r="2"></circle><path d="M19 8v5a5 5 0 0 1-5 5h-3l3-3m0 6l-3-3"></path><path d="M5 16v-5a5 5 0 0 1 5-5h3l-3-3m0 6l3-3"></path></g>',1),Y=[X],Z=w({name:"Exchange",render:function(e,a){return p(),_("svg",W,Y)}});function E(t){return`${t>>>24}.${t>>16&255}.${t>>8&255}.${t&255}`}function f(t,e){return t==null||e==null?-1:1+Number.parseInt(e,2)-Number.parseInt(t,2)}function ee(t,e){if(t==null||e==null||f(t,e)<1)return null;let l=32;for(let i=0;i<32;i++)if(t[i]!==e[i]){l=i;break}const r=t.substring(0,l)+"0".repeat(32-l),n=e.substring(0,l)+"1".repeat(32-l);return{start:r,end:n,mask:l}}function te({startIp:t,endIp:e}){const a=$({value:x({ip:t}).toString(),fromBase:10,toBase:2}).padStart(32,"0"),l=$({value:x({ip:e}).toString(),fromBase:10,toBase:2}).padStart(32,"0"),r=ee(a,l);if(r!=null){const n={};return n.newEnd=E(Number.parseInt(r.end,2)),n.newStart=E(Number.parseInt(r.start,2)),n.newCidr=`${n.newStart}/${r.mask}`,n.newSize=f(r.start,r.end),n.oldSize=f(a,l),n}}const ae={"font-bold":""},ne=["data-test-id"],oe=["data-test-id"],le=w({__name:"result-row",props:{label:{default:""},oldValue:{default:""},newValue:{default:""}},setup(t){const e=t,{label:a,oldValue:l,newValue:r}=T(e),n=g(()=>K.kebabCase(a.value));return(i,h)=>(p(),_("tr",null,[d("td",ae,D(s(a)),1),d("td",{"data-test-id":`${s(n)}.old`},[u(N,{value:s(l),class:"monospace"},null,8,["value"])],8,ne),d("td",{"data-test-id":`${s(n)}.new`},[u(N,{value:s(r)},null,8,["value"])],8,oe)]))}}),se={"mb-4":"",flex:"","gap-4":""},re=d("thead",null,[d("tr",null,[d("th",{scope:"col"}," "),d("th",{scope:"col"}," old value "),d("th",{scope:"col"}," new value ")])],-1),de=d("div",{"my-3":"","op-70":""}," The end IPv4 address is lower than the start IPv4 address. This is not valid and no result could be calculated. In the most cases the solution to solve this problem is to change start and end address. ",-1),Pe=w({__name:"ipv4-range-expander",setup(t){const e=S("ipv4-range-expander:startAddress","192.168.1.1"),a=S("ipv4-range-expander:endAddress","192.168.6.255"),l=g(()=>te({startIp:e.value,endIp:a.value})),r=[{label:"Start address",getOldValue:()=>e.value,getNewValue:o=>o?.newStart},{label:"End address",getOldValue:()=>a.value,getNewValue:o=>o?.newEnd},{label:"Addresses in range",getOldValue:o=>o?.oldSize?.toLocaleString(),getNewValue:o=>o?.newSize?.toLocaleString()},{label:"CIDR",getOldValue:()=>"",getNewValue:o=>o?.newCidr}],n=C({source:e,rules:[{message:"Invalid ipv4 address",validator:o=>k({ip:o})}]}),i=C({source:a,rules:[{message:"Invalid ipv4 address",validator:o=>k({ip:o})}]}),h=g(()=>i.isValid&&n.isValid&&l.value!==void 0);function B(){const o=e.value;e.value=a.value,a.value=o}return(o,m)=>{const b=G,y=J,z=Q,P=q,A=H;return p(),_("div",null,[d("div",se,[u(b,{value:s(e),"onUpdate:value":m[0]||(m[0]=c=>V(e)?e.value=c:null),label:"Start address",placeholder:"Start IPv4 address...",valid
|