import{_ as N}from"./Ciyi0QpJ.js";import{d as A,a as B,r as J,ao as V,bW as Z,o as k,h as G,f as H}from"./CCqMIw4K.js";function C(){}C.prototype={diff:function(e,o){var r,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},t=u.callback;typeof u=="function"&&(t=u,u={}),this.options=u;var f=this;function i(c){return t?(setTimeout(function(){t(void 0,c)},0),!0):c}e=this.castInput(e),o=this.castInput(o),e=this.removeEmpty(this.tokenize(e)),o=this.removeEmpty(this.tokenize(o));var s=o.length,l=e.length,d=1,p=s+l;u.maxEditLength&&(p=Math.min(p,u.maxEditLength));var m=(r=u.timeout)!==null&&r!==void 0?r:1/0,h=Date.now()+m,a=[{oldPos:-1,lastComponent:void 0}],v=this.extractCommon(a[0],o,e,0);if(a[0].oldPos+1>=l&&v+1>=s)return i([{value:this.join(o),count:o.length}]);var g=-1/0,L=1/0;function $(){for(var c=Math.max(g,-d);c<=Math.min(L,d);c+=2){var y=void 0,x=a[c-1],D=a[c+1];x&&(a[c-1]=void 0);var E=!1;if(D){var M=D.oldPos-c;E=D&&0<=M&&M<s}var O=x&&x.oldPos+1<l;if(!E&&!O){a[c]=void 0;continue}if(!O||E&&x.oldPos+1<D.oldPos?y=f.addToPath(D,!0,void 0,0):y=f.addToPath(x,void 0,!0,1),v=f.extractCommon(y,o,e,c),y.oldPos+1>=l&&v+1>=s)return i(Q(f,y.lastComponent,o,e,f.useLongestToken));a[c]=y,y.oldPos+1>=l&&(L=Math.min(L,c-1)),v+1>=s&&(g=Math.max(g,c+1))}d++}if(t)(function c(){setTimeout(function(){if(d>p||Date.now()>h)return t();$()||c()},0)})();else for(;d<=p&&Date.now()<=h;){var q=$();if(q)return q}},addToPath:function(e,o,r,u){var t=e.lastComponent;return t&&t.added===o&&t.removed===r?{oldPos:e.oldPos+u,lastComponent:{count:t.count+1,added:o,removed:r,previousComponent:t.previousComponent}}:{oldPos:e.oldPos+u,lastComponent:{count:1,added:o,removed:r,previousComponent:t}}},extractCommon:function(e,o,r,u){for(var t=o.length,f=r.length,i=e.oldPos,s=i-u,l=0;s+1<t&&i+1<f&&this.equals(o[s+1],r[i+1]);)s++,i++,l++;return l&&(e.lastComponent={count:l,previousComponent:e.lastComponent}),e.oldPos=i,s},equals:function(e,o){return this.options.comparator?this.options.comparator(e,o):e===o||this.options.ignoreCase&&e.toLowerCase()===o.toLowerCase()},removeEmpty:function(e){for(var o=[],r=0;r<e.length;r++)e[r]&&o.push(e[r]);return o},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function Q(n,e,o,r,u){for(var t=[],f;e;)t.push(e),f=e.previousComponent,delete e.previousComponent,e=f;t.reverse();for(var i=0,s=t.length,l=0,d=0;i<s;i++){var p=t[i];if(p.removed){if(p.value=n.join(r.slice(d,d+p.count)),d+=p.count,i&&t[i-1].added){var h=t[i-1];t[i-1]=t[i],t[i]=h}}else{if(!p.added&&u){var m=o.slice(l,l+p.count);m=m.map(function(v,g){var L=r[d+g];return L.length>v.length?L:v}),p.value=n.join(m)}else p.value=n.join(o.slice(l,l+p.count));l+=p.count,p.added||(d+=p.count)}}var a=t[s-1];return s>1&&typeof a.value=="string"&&(a.added||a.removed)&&n.equals("",a.value)&&(t[s-2].value+=a.value,t.pop()),t}var R=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,W=/\S/,F=new C;F.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!W.test(n)&&!W.test(e)};F.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),o=0;o<e.length-1;o++)!e[o+1]&&e[o+2]&&R.test(e[o])&&R.test(e[o+2])&&(e[o]+=e[o+2],e.splice(o+1,2),o--);return e};var I=new C;I.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
`));var e=[],o=n.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(var r=0;r<o.length;r++){var u=o[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=u:(this.options.ignoreWhitespace&&(u=u.trim()),e.push(u))}return e};function U(n,e,o){return I.diff(n,e,o)}var X=new C;X.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Y=new C;Y.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function w(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?w=function(e){return typeof e}:w=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(n)}var K=Object.prototype.toString,T=new C;T.useLongestToken=!0;T.tokenize=I.tokenize;T.castInput=function(n){var e=this.options,o=e.undefinedReplacement,r=e.stringifyReplacer,u=r===void 0?function(t,f){return typeof f>"u"?o:f}:r;return typeof n=="string"?n:JSON.stringify(z(n,null,null,u),u,"  ")};T.equals=function(n,e){return C.prototype.equals.call(T,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function z(n,e,o,r,u){e=e||[],o=o||[],r&&(n=r(u,n));var t;for(t=0;t<e.length;t+=1)if(e[t]===n)return o[t];var f;if(K.call(n)==="[object Array]"){for(e.push(n),f=new Array(n.length),o.push(f),t=0;t<n.length;t+=1)f[t]=z(n[t],e,o,r,u);return e.pop(),o.pop(),f}if(n&&n.toJSON&&(n=n.toJSON()),w(n)==="object"&&n!==null){e.push(n),f={},o.push(f);var i=[],s;for(s in n)n.hasOwnProperty(s)&&i.push(s);for(i.sort(),t=0;t<i.length;t+=1)s=i[t],f[s]=z(n[s],e,o,r,s);e.pop(),o.pop()}else f=n;return f}var _=new C;_.tokenize=function(n){return n.slice()};_.join=_.removeEmpty=function(n){return n};const b=A({__name:"CodeDiff",props:{from:{},to:{},lang:{}},setup(n){const e=n;function o(i,s){const l=U(i.trim(),s.trim()),d=[],p=[],m=[];for(const h of l){const a=h.value.trimEnd().split(`
`);for(const v of a)h.added?(d.push(m.length),m.push(v)):(h.removed&&p.push(m.length),m.push(v))}return{added:d,removed:p,result:m.join(`
`)}}const r=B(()=>o(e.from,e.to));function u(i){let s=0;return i.replace(/class="shiki/,'class="shiki diff').replace(/class="line"/g,l=>(s++,r.value.added.includes(s-1)?'class="line line-added"':r.value.removed.includes(s-1)?'class="line line-removed"':l))}const t=J();V(f);function f(){const i=Z(t);i&&i.querySelector(".line-added,.line-removed")?.scrollIntoView()}return(i,s)=>{const l=N;return k(),G(l,{ref_key:"elRef",ref:t,code:H(r).result,lang:i.lang,"transform-rendered":u,onLoaded:f},null,8,["code","lang"])}}});export{b as _};
