@forbespro/lead-agent
Version:
Lead Chat Agent React Component
2 lines (1 loc) • 2.13 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./index160.js"),I=require("./index185.js");function _(c){const u={};let e=-1,p,o,n,s,f,l,g;const r=new I.SpliceBuffer(c);for(;++e<r.length;){for(;e in u;)e=u[e];if(p=r.get(e),e&&p[1].type==="chunkFlow"&&r.get(e-1)[1].type==="listItemPrefix"&&(l=p[1]._tokenizer.events,n=0,n<l.length&&l[n][1].type==="lineEndingBlank"&&(n+=2),n<l.length&&l[n][1].type==="content"))for(;++n<l.length&&l[n][1].type!=="content";)l[n][1].type==="chunkText"&&(l[n][1]._isInFirstContentOfListItem=!0,n++);if(p[0]==="enter")p[1].contentType&&(Object.assign(u,x(r,e)),e=u[e],g=!0);else if(p[1]._container){for(n=e,o=void 0;n--;)if(s=r.get(n),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(r.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=n);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;o&&(p[1].end={...r.get(o)[1].start},f=r.slice(o,e),f.unshift(p),r.splice(o,e-o+1,f))}}return T.splice(c,0,Number.POSITIVE_INFINITY,r.slice(0)),!g}function x(c,u){const e=c.get(u)[1],p=c.get(u)[2];let o=u-1;const n=[];let s=e._tokenizer;s||(s=p.parser[e.contentType](e.start),e._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const f=s.events,l=[],g={};let r,y,i=-1,t=e,d=0,h=0;const a=[h];for(;t;){for(;c.get(++o)[1]!==t;);n.push(o),t._tokenizer||(r=p.sliceStream(t),t.next||r.push(null),y&&s.defineSkip(t.start),t._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(r),t._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),y=t,t=t.next}for(t=e;++i<f.length;)f[i][0]==="exit"&&f[i-1][0]==="enter"&&f[i][1].type===f[i-1][1].type&&f[i][1].start.line!==f[i][1].end.line&&(h=i+1,a.push(h),t._tokenizer=void 0,t.previous=void 0,t=t.next);for(s.events=[],t?(t._tokenizer=void 0,t.previous=void 0):a.pop(),i=a.length;i--;){const m=f.slice(a[i],a[i+1]),k=n.pop();l.push([k,k+m.length-1]),c.splice(k,2,m)}for(l.reverse(),i=-1;++i<l.length;)g[d+l[i][0]]=d+l[i][1],d+=l[i][1]-l[i][0]-1;return g}exports.SpliceBuffer=I.SpliceBuffer;exports.subtokenize=_;