@pickaxeproject/react 3.21.0 → 3.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/common/documents.js +1 -1
  2. package/dist/cjs/common/utils.js +1 -1
  3. package/dist/cjs/components/Core/Textarea.js +1 -1
  4. package/dist/cjs/components/Icons/chevron-up.svg.js +1 -0
  5. package/dist/cjs/components/Pickaxe/Addons/Document/List.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  8. package/dist/cjs/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  9. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Others/Think.js +1 -0
  10. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  11. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  12. package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  13. package/dist/cjs/hooks/pickaxe/useThumbSelection.js +1 -1
  14. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  15. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  16. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  17. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  18. package/dist/cjs/src/common/utils.d.ts +2 -0
  19. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/Others/Think.d.ts +2 -0
  20. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +0 -2
  21. package/dist/cjs/src/hooks/pickaxe/useThumbSelection.d.ts +2 -3
  22. package/dist/cjs/src/types/pickaxe.d.ts +1 -1
  23. package/dist/esm/common/documents.js +1 -1
  24. package/dist/esm/common/utils.js +1 -1
  25. package/dist/esm/components/Core/Textarea.js +1 -1
  26. package/dist/esm/components/Icons/chevron-up.svg.js +1 -0
  27. package/dist/esm/components/Pickaxe/Addons/Document/List.js +1 -1
  28. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  29. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  30. package/dist/esm/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  31. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Others/Think.js +1 -0
  32. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  33. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  34. package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  35. package/dist/esm/hooks/pickaxe/useThumbSelection.js +1 -1
  36. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  37. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  38. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  39. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  40. package/dist/esm/src/common/utils.d.ts +2 -0
  41. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/Others/Think.d.ts +2 -0
  42. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +0 -2
  43. package/dist/esm/src/hooks/pickaxe/useThumbSelection.d.ts +2 -3
  44. package/dist/esm/src/types/pickaxe.d.ts +1 -1
  45. package/package.json +3 -3
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".md"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","application/xml","text/xml","audio/mpeg","video/mp4"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".md"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","application/xml","text/xml","audio/mpeg","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{try{const t=document.cookie.split("; ");for(const o of t){const[t,r]=o.split("=");if(t===e)return r}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const o=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},exports.generateId=(e,t="",o="")=>{let r="";for(let t=0;t<e;t++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+r+o},exports.getAuthToken=t=>{try{if("undefined"==typeof window)return null;let o=null;return o=new URLSearchParams(window.location.search).get("pxtoken"),o||(o=localStorage.getItem(`PXE-token-${t}`)),o||(o=e(`PXE-token-${t}`)),o?decodeURIComponent(o):null}catch(e){return null}},exports.getCookie=e,exports.randomStr=(e,t=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(o=o.replace(/[0-9]/g,""));let r="";for(let t=0;t<e;t++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{try{const t=document.cookie.split("; ");for(const o of t){const[t,r]=o.split("=");if(t===e)return r}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const o=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},exports.generateId=(e,t="",o="")=>{let r="";for(let t=0;t<e;t++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+r+o},exports.getAuthToken=t=>{try{if("undefined"==typeof window)return null;let o=null;return o=new URLSearchParams(window.location.search).get("pxtoken"),o||(o=localStorage.getItem(`PXE-token-${t}`)),o||(o=e(`PXE-token-${t}`)),o?decodeURIComponent(o):null}catch(e){return null}},exports.getCookie=e,exports.mergeRefs=function(...e){return t=>{for(const o of e)o&&("function"==typeof o?o(t):o.current=t)}},exports.randomStr=(e,t=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(o=o.replace(/[0-9]/g,""));let r="";for(let t=0;t<e;t++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),a=require("react"),l=require("react-textarea-autosize"),o=require("../../common/cn.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=t(l);const n=a.forwardRef(((a,l)=>{var{name:t,value:n="",rows:u=1,maxRows:c,placeholder:i,className:d,hideScrollbar:b,onChange:m}=a,h=e.__rest(a,["name","value","rows","maxRows","placeholder","className","hideScrollbar","onChange"]);return r.jsx(s.default,Object.assign({},t&&{name:t},{ref:l,value:n,onChange:e=>null==m?void 0:m(e.target.value),minRows:u},c&&{maxRows:c},{className:o.default("w-full resize-none bg-transparent outline-none ring-0 placeholder:text-inherit placeholder:opacity-50",d,b?"no-scrollbar":"scrollbar scrollbar-thumb-black/50 scrollbar-thumb-rounded-full scrollbar-w-[4px] scrollbar-h-[4px]"),placeholder:i},h))}));n.displayName="Textarea",exports.default=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),a=require("react"),l=require("../../common/cn.js"),t=require("../../common/utils.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(require("react-textarea-autosize"));const n=a.forwardRef(((o,n)=>{var{name:u,value:c="",rows:i=1,maxRows:d,placeholder:m,className:f,hideScrollbar:b,onChange:p}=o,h=e.__rest(o,["name","value","rows","maxRows","placeholder","className","hideScrollbar","onChange"]);const w=a.useRef(null),v=t.mergeRefs(n,w);return a.useEffect((()=>{w.current&&setTimeout((()=>{"undefined"!=typeof window&&window.dispatchEvent(new Event("resize"))}),100)}),[]),r.jsx(s.default,Object.assign({},u&&{name:u},{ref:v,value:c,onChange:e=>null==p?void 0:p(e.target.value),minRows:i},d&&{maxRows:d},{className:l.default("w-full resize-none bg-transparent outline-none ring-0 placeholder:text-inherit placeholder:opacity-50",f,b?"no-scrollbar":"scrollbar scrollbar-thumb-black/50 scrollbar-thumb-rounded-full scrollbar-w-[4px] scrollbar-h-[4px]"),placeholder:m},h))}));n.displayName="Textarea",exports.default=n;
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var o=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=t.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m18 15-6-6-6 6"})));exports.default=o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("./hooks/useDocument.js"),l=require("../../../../common/utils.js"),i=require("../../../Icons/spinner-lines.svg.js"),o=require("../../../Icons/file.svg.js"),c=require("../../../Icons/x.svg.js"),n=require("../../../Icons/circle-info.svg.js"),u=require("../../../../common/cn.js");exports.default=({className:d,isDisabled:f})=>{const{styles:m,colors:x,translations:h,isRtl:j}=t.usePickaxeContext(),{documents:b,isUploading:g,removeDocument:p}=a.useDocument(),v=r.useStyleFontSize();return e.jsx("div",Object.assign({className:u.default("flex flex-row gap-3 flex-wrap",d)},{children:b.map(((t,r)=>{var a,d,b,k,y;return e.jsx(s.Fragment,{children:"document"===t.type?e.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:m.cornerRadius,borderColor:x.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:m.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===t.status&&{backgroundColor:x.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(o.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:u.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:u.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(a=t.error)||void 0===a?void 0:a.includes("You have reached the file limit"))?null!==(d=null==h?void 0:h["file-limit-reached"])&&void 0!==d?d:"You have reached the file limit.":t.error:l.formatBytes(t.size)}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):"image"===t.type?e.jsxs("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:m.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===t.status&&{backgroundColor:x.error,color:"white"})},{children:["finished"===t.status?e.jsx("img",{className:"object-cover w-full h-full",style:{borderRadius:m.cornerRadius},src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(b=t.documentId)||void 0===b?void 0:b.split("-")[2]}/${null===(k=t.documentId)||void 0===k?void 0:k.split("-")[1]}.${null===(y=t.documentId)||void 0===y?void 0:y.split("-")[2]}`,alt:""}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):null},r)}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("./hooks/useDocument.js"),r=require("../../../../common/utils.js"),i=require("../../../Icons/spinner-lines.svg.js"),c=require("../../../Icons/file.svg.js"),o=require("../../../Icons/x.svg.js"),n=require("../../../Icons/circle-info.svg.js"),d=require("../../../../common/cn.js");exports.default=({className:u,isDisabled:f})=>{const{styles:h,colors:m,translations:x,isRtl:j}=t.usePickaxeContext(),{documents:b,isUploading:g,removeDocument:p}=l.useDocument(),v=a.useStyleFontSize();return e.jsx("div",Object.assign({className:d.default("flex flex-row gap-3 flex-wrap",u)},{children:b.map(((t,a)=>{var l,u,b,k,y,w,N;return e.jsx(s.Fragment,{children:"document"===t.type?e.jsxs("div",Object.assign({className:d.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:m.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(c.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:d.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:d.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:d.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(l=t.error)||void 0===l?void 0:l.includes("You have reached the file limit"))?null!==(u=null==x?void 0:x["file-limit-reached"])&&void 0!==u?u:"You have reached the file limit.":t.error:r.formatBytes(t.size)}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:d.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(o.default,{className:"w-4 h-4 shrink-0"})}))]})):"image"===t.type?e.jsxs("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:["finished"===t.status?e.jsx("img",{className:"object-cover w-full h-full",style:{borderRadius:h.cornerRadius},src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(b=t.documentId)||void 0===b?void 0:b.split("-")[2]}/${null===(k=t.documentId)||void 0===k?void 0:k.split("-")[1]}.${null===(y=t.documentId)||void 0===y?void 0:y.split("-")[2]}`,alt:""}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}),!g&&e.jsx("button",Object.assign({type:"button",className:d.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(o.default,{className:"w-4 h-4 shrink-0"})}))]})):"website"===t.type?e.jsxs("div",Object.assign({className:d.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:m.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(c.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:d.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:d.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:d.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(w=t.error)||void 0===w?void 0:w.includes("You have reached the file limit"))?null!==(N=null==x?void 0:x["file-limit-reached"])&&void 0!==N?N:"You have reached the file limit.":t.error:"Website "}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:d.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(o.default,{className:"w-4 h-4 shrink-0"})}))]})):null},a)}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),r=require("../../../../../common/documents.js"),a=require("uuid"),u=require("../../../../../common/error.js");const d=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","gpt-5","gpt-5-mini","gpt-5-nano","gpt-5-chat-latest","o1","o4-mini","o3","gemini-2.0-flash","gemini-2.0-flash-lite","gemini-2.5-pro-preview-05-06","gemini-2.5-flash-preview-05-20","claude-3-7-sonnet-20250219","claude-sonnet-4-20250514","claude-opus-4-20250514","claude-opus-4-1-20250805","claude-sonnet-4-5-20250929","grok-4-latest","grok-4-fast-non-reasoning-latest","grok-4-fast-reasoning-latest","sonar","sonar-pro","sonar-reasoning","sonar-reasoning-pro"];exports.useDocument=({onQuestionChange:l}={})=>{const{formId:c,chatId:p,sessionId:m,pickaxe:g,studioUserId:f}=s.usePickaxeContext(),{token:w}=o.useAuthContext(),h=n.useDocumentContext(),I=i.useSubmitDocument(),b=t.useMemo((()=>{var e;return d.includes(null!==(e=null==g?void 0:g.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[g]),v=e=>{const t=[...r.allowedFileMimeTypes,...b?r.allowedImageMimeTypes:[]];if(e.some((e=>{var s;if(console.log(e.type),t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&r.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}))){const e=new Error(b?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, or XML files. Please try again."),t=u.default(e);return h.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},h),{isImageUploadAllowed:b,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(v(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const o=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:o,error:i}=yield I.document(Object.assign(Object.assign(Object.assign({formId:c,responseId:p,file:t,sessionId:m},(null==g?void 0:g.workspaceid)&&{workspaceId:g.workspaceid}),f&&{studioUserId:f}),w&&{studioSessionToken:w}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:o});const n=o.startsWith("IMAGE-");return h.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:o}),{name:t.name,documentId:o}}catch(e){const o=u.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:o}),{error:o}}}))));yield Promise.allSettled(o),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield I.website(Object.assign(Object.assign(Object.assign({formId:c,responseId:p,website:e},(null==g?void 0:g.workspaceid)&&{workspaceId:g.workspaceid}),f&&{studioUserId:f}),w&&{studioSessionToken:w})),{success:s,documentId:o}=t;if(!s)throw new Error("Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:o}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:o}}catch(t){const s=u.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),r=require("../../../../../common/documents.js"),a=require("uuid"),u=require("../../../../../common/error.js");const d=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","gpt-5","gpt-5-mini","gpt-5-nano","gpt-5-chat-latest","o1","o4-mini","o3","gemini-2.0-flash","gemini-2.0-flash-lite","gemini-2.5-pro-preview-05-06","gemini-2.5-flash-preview-05-20","claude-3-7-sonnet-20250219","claude-sonnet-4-20250514","claude-opus-4-20250514","claude-opus-4-1-20250805","claude-sonnet-4-5-20250929","claude-haiku-4-5-20251001","grok-4-latest","grok-4-fast-non-reasoning-latest","grok-4-fast-reasoning-latest","sonar","sonar-pro","sonar-reasoning","sonar-reasoning-pro"];exports.useDocument=({onQuestionChange:l}={})=>{const{formId:c,chatId:p,sessionId:m,pickaxe:g,studioUserId:f}=s.usePickaxeContext(),{token:w}=o.useAuthContext(),h=n.useDocumentContext(),I=i.useSubmitDocument(),b=t.useMemo((()=>{var e;return d.includes(null!==(e=null==g?void 0:g.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[g]),v=e=>{const t=[...r.allowedFileMimeTypes,...b?r.allowedImageMimeTypes:[]];if(e.some((e=>{var s;if(console.log(e.type),t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&r.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}))){const e=new Error(b?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, or XML files. Please try again."),t=u.default(e);return h.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},h),{isImageUploadAllowed:b,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(v(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const o=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:o,error:i}=yield I.document(Object.assign(Object.assign(Object.assign({formId:c,responseId:p,file:t,sessionId:m},(null==g?void 0:g.workspaceid)&&{workspaceId:g.workspaceid}),f&&{studioUserId:f}),w&&{studioSessionToken:w}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:o});const n=o.startsWith("IMAGE-");return h.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:o}),{name:t.name,documentId:o}}catch(e){const o=u.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:o}),{error:o}}}))));yield Promise.allSettled(o),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield I.website(Object.assign(Object.assign(Object.assign({formId:c,responseId:p,website:e},(null==g?void 0:g.workspaceid)&&{workspaceId:g.workspaceid}),f&&{studioUserId:f}),w&&{studioSessionToken:w})),{success:s,documentId:o}=t;if(!s)throw new Error("Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:o}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:o}}catch(t){const s=u.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../../../hooks/pickaxe/useSubmit.js"),u=require("../Addons/Document/hooks/useDocument.js"),d=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../Addons/Artifact/hooks/useArtifactContext.js"),g=require("../../../hooks/pickaxe/useSpeechRecognition.js"),p=require("../../../hooks/core/useHover.js"),v=require("../../../hooks/core/useMediaQuery.js"),m=require("../../../common/documents.js"),h=require("eventsource-parser"),x=require("../../Icons/attach-vertical.svg.js"),j=require("../../Icons/arrow-right.svg.js"),b=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),k=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),I=require("../../../common/cn.js");const C=({colors:e})=>{var s,r;const{translations:i}=n.usePickaxeContext();return t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(s=e.accent)&&void 0!==s?s:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm",style:{color:e.text+"90"}},{children:null!==(r=null==i?void 0:i.listening)&&void 0!==r?r:"Listening..."}))]}))},N=s.forwardRef((({onFocus:N,onBlur:q,onInputHeightChange:A},_)=>{var E,D,H;const{formId:T,chatId:L,userId:M,studioUserId:P,embedUserId:R,deploymentId:F,deploymentType:W,pickaxe:U,styles:B,colors:J,studioLang:$,forceMobile:G,isNewChat:z,isRtl:K,isEmailLogin:Q,isShowFeedbackMessage:V,setIsNewChat:X,setIsShowIceBreaker:Y,onGenerateComplete:Z}=n.usePickaxeContext(),{token:ee,isLoggedOut:te,isSent:se}=l.useAuthContext(),{messages:ne,status:re,limits:ie,isGenerating:oe,setMessages:ae,setStatus:le,setLimitData:ce,setError:ue}=r.useResponseContext(),{documents:de,isUploading:fe,isImageUploadAllowed:ge,documentError:pe,onFileUpload:ve,setDocuments:me,setDocumentError:he}=u.useDocument(),{scrollStartSession:xe,scrollEndSession:je,scrollToBottom:be}=d.useScroll({auto:!0}),{artifacts:ye,currentPopupType:ke,setArtifacts:we,setCurrentArtifact:Oe}=f.useArtifactContext(),Se=a.useConversation(),Ie=c.useSubmit(),[Ce,Ne]=s.useState(""),qe=s.useRef(null),Ae=s.useRef(""),_e=s.useRef(null),{isSupported:Ee,isListening:De,finalTranscript:He,interimTranscript:Te,startListening:Le,stopListening:Me}=g.useSpeechRecognition({lang:$||"en"}),[Pe]=v.useMediaQuery("(max-width: 899px)"),Re=p.useHover(),{isHover:Fe}=Re,We=e.__rest(Re,["isHover"]),Ue=p.useHover(),{isHover:Be}=Ue,Je=e.__rest(Ue,["isHover"]),$e=p.useHover(),{isHover:Ge}=$e,ze=e.__rest($e,["isHover"]),Ke=p.useHover(),{isHover:Qe}=Ke,Ve=e.__rest(Ke,["isHover"]),[Xe,Ye]=s.useState(!1),Ze=o.useStyleFontSize(),et=i.useStyleInput(),tt="chat-input"===W&&z&&!se,st="chat-input"===W&&Q&&te&&se,nt=s.useMemo((()=>{var e,t,s;return!!z&&(!!U&&(!Se.isLoading&&(!((null!==(t=null===(e=Se.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=U.icebreakers)||void 0===s?void 0:s.length)&&(!V&&!tt)))))}),[U,z,V,tt,Se.data,Se.isLoading]),rt=s.useMemo((()=>{if(oe||fe)return!1;const e=de.length>0&&de.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Ce.trim()&&!e)&&de.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[oe,fe,Ce,de]);s.useEffect((()=>{Y(nt)}),[nt]),s.useEffect((()=>{if(!De)return;const e=`${Ae.current} ${He} ${Te}`.trim();Ne(e)}),[He,Te,De]),s.useEffect((()=>{!De&&Ae.current&&(Ne(`${Ae.current} ${He}`.trim()),Ae.current="")}),[De,He]);const it=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if("idle"!==re||fe)return;const n=de.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),i=null!=t?t:Ce;if(!i&&!r)return;ue(""),he(""),ce(null),Ne(""),X(!1),le("fetching"),xe(),be();const o=null!==(s=null===(e=null==U?void 0:U.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,a=[...Array.from(ne),Object.assign({id:ne.length+1,role:"user",content:i},o&&{documentIds:n})];ae(a),be(),o&&me([]);const l=(yield Ie.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:T,responseId:L,value:i},o&&{documentIds:n}),M&&{userId:M}),P&&{studioUserId:P}),R&&{embedUserId:R}),ee&&{studioSessionToken:ee}),F&&{deploymentId:F}))).body;if(!l)throw new Error("Streaming error");const c=a.length,u=new TextDecoder;_e.current=l.getReader();let d="",f=!0,g=!1,p=[...null!=ye?ye:[]];const v=h.createParser({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,ae([...a.slice(0,c),{id:ne.length+1,role:"assistant",content:d}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(p),ke.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),we(p),ke.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(p),ke.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");p=p.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),we(p)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);we(p.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);ue(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(f=!1)}});for(;f&&_e.current;){const{value:e,done:t}=yield _e.current.read();if(t){f=!1;break}const s=u.decode(e);s&&(g||(le("streaming"),g=!0),v.feed(s))}null==Z||Z(L)}catch(e){if("AbortError"===e.name)return void console.log("Stream stopped by user.");let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(ie).find((([e])=>t.includes(e)));s?ce(s[1]):ue(t)}finally{be(),le("idle"),je(),_e.current=null}}));return s.useImperativeHandle(_,(()=>({onSubmit:it}))),st?null:t.jsx("div",Object.assign({className:I.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!tt&&"px-4 pb-4"),dir:K?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"relative flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({className:I.default("flex flex-col gap-y-3 px-4 py-3","block"===B.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},et),Xe&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Ye(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),Ye(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),Ye(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Ye(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(X(!1),yield ve(e))}))},{children:[De&&t.jsx(C,{colors:J}),"idle"===re&&de.length>0&&t.jsx(k.default,{isDisabled:"idle"!==re}),t.jsxs("div",Object.assign({className:I.default("flex items-end gap-x-2",K&&"flex-row-reverse")},{children:[t.jsx(w.default,Object.assign({className:I.default(Ze.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!Ce.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",K?"text-right":"text-left",De&&"text-transparent"),value:Ce,placeholder:null!==(E=null==U?void 0:U.placeholdertext)&&void 0!==E?E:K?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Ne(e),A){const t=(e.match(/\n/g)||[]).length+1;if(t>=11)return;A(24*(t-1))}},onKeyDown:e=>{G||Pe||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),fe||"idle"!==re||it()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),X(!1),yield ve(e))}))},N&&{onFocus:N},q&&{onBlur:q},{dir:K?"rtl":"ltr"})),t.jsx("div",Object.assign({className:"flex items-center gap-x-2"},{children:oe?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{_e.current&&(_e.current.cancel(),_e.current=null),le("idle")},style:{backgroundColor:Qe?J.accent:J.accent+"10",color:Qe?J.accentText:J.accent}},Ve,{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):De?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Me,style:{backgroundColor:Qe?J.accent:J.accent+"10",color:Qe?J.accentText:J.accent}},Ve,{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[null!==(H=null===(D=null==U?void 0:U.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"))&&void 0!==H&&H&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Be?J.accent+"10":void 0,color:Be?J.accent:J.accent+"80"},disabled:fe||"idle"!==re,onClick:()=>{var e;return null===(e=qe.current)||void 0===e?void 0:e.click()}},Je,{children:[t.jsx("input",{id:"file-upload",ref:qe,type:"file",accept:[...m.allowedFileMimeTypes,...ge?m.allowedImageMimeTypes:[],...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){X(!1),yield ve(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(x.default,{className:"h-6 w-6 shrink-0"})]})),Ee&&(null==U?void 0:U.enablevoicetotext)&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:De?J.accent:Ge?J.accent+"10":void 0,color:De?J.accentText:Ge?J.accent:J.accent+"80"},disabled:fe||"idle"!==re,onClick:()=>{De?Me():(Ae.current=Ce,Le())}},ze,{children:t.jsx(b.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Fe||rt?J.accent:J.accent+"10",color:Fe||rt?J.accentText:J.accent+"80"},disabled:!rt,onClick:()=>it()},We,{children:t.jsx(j.default,{className:I.default("h-6 w-6 shrink-0",K&&"scale-x-[-1] transform")})}))]})}))]}))]})),pe&&t.jsx(O.default,{error:pe,className:"mt-3"})]}))}))}));N.displayName="Input",exports.default=N;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../../../hooks/pickaxe/useSubmit.js"),u=require("../Addons/Document/hooks/useDocument.js"),d=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../Addons/Artifact/hooks/useArtifactContext.js"),p=require("../../../hooks/pickaxe/useSpeechRecognition.js"),g=require("../../../hooks/core/useHover.js"),m=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),j=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),k=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),C=require("../../../common/cn.js");const I=s.forwardRef((({onFocus:I,onBlur:N,onInputHeightChange:q},A)=>{var E,_,D;const{formId:R,chatId:T,userId:H,studioUserId:F,embedUserId:L,deploymentId:W,deploymentType:M,pickaxe:P,styles:$,colors:B,studioLang:U,forceMobile:J,isNewChat:z,isRtl:G,isEmailLogin:K,isShowFeedbackMessage:Q,setIsNewChat:V,setIsShowIceBreaker:X,onGenerateComplete:Y}=n.usePickaxeContext(),{token:Z,isLoggedOut:ee,isSent:te}=l.useAuthContext(),{messages:se,status:ne,limits:re,isGenerating:ie,setMessages:oe,setStatus:ae,setLimitData:le,setError:ce}=r.useResponseContext(),{documents:ue,isUploading:de,isImageUploadAllowed:fe,documentError:pe,onFileUpload:ge,setDocuments:me,setDocumentError:he}=u.useDocument(),{scrollStartSession:ve,scrollEndSession:be,scrollToBottom:je}=d.useScroll({auto:!0}),{artifacts:xe,currentPopupType:ye,setArtifacts:ke,setCurrentArtifact:we}=f.useArtifactContext(),Oe=a.useConversation(),Se=c.useSubmit(),[Ce,Ie]=s.useState(""),[Ne,qe]=s.useState(!1),[Ae,Ee]=s.useState(!1),_e=s.useRef(null),De=s.useRef(""),Re=s.useRef(null),Te=s.useRef(null),He=s.useRef(null),{isSupported:Fe,isListening:Le,finalTranscript:We,interimTranscript:Me,startListening:Pe,stopListening:$e}=p.useSpeechRecognition({lang:U||"en"}),[Be]=m.useMediaQuery("(max-width: 899px)"),Ue=g.useHover(),{isHover:Je}=Ue,ze=e.__rest(Ue,["isHover"]),Ge=g.useHover(),{isHover:Ke}=Ge,Qe=e.__rest(Ge,["isHover"]),Ve=g.useHover(),{isHover:Xe}=Ve,Ye=e.__rest(Ve,["isHover"]),[Ze,et]=s.useState(!1),tt=o.useStyleFontSize(),st=i.useStyleInput(),nt=null===(E=null==P?void 0:P.documentuploadtype)||void 0===E?void 0:E.startsWith("enduserupload"),rt=Fe&&(null==P?void 0:P.enablevoicetotext),it="chat-input"===M&&z&&!te,ot="chat-input"===M&&K&&ee&&te,at=Ne||Ae,lt=s.useMemo((()=>{var e,t,s;return!!z&&(!!P&&(!Oe.isLoading&&(!((null!==(t=null===(e=Oe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=P.icebreakers)||void 0===s?void 0:s.length)&&(!Q&&!it)))))}),[P,z,Q,it,Oe.data,Oe.isLoading]),ct=s.useMemo((()=>{if(ie||de)return!1;const e=ue.length>0&&ue.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Ce.trim()&&!e)&&ue.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ie,de,Ce,ue]);s.useImperativeHandle(A,(()=>({onSubmit:ut}))),s.useEffect((()=>{X(lt)}),[lt]),s.useEffect((()=>{if(!Le)return;const e=`${De.current} ${We} ${Me}`.trim();Ie(e)}),[We,Me,Le]),s.useEffect((()=>{!Le&&De.current&&(Ie(`${De.current} ${We}`.trim()),De.current="")}),[Le,We]),s.useEffect((()=>{if(!Te.current)return;(()=>{if(!Te.current)return;let e=Te.current.scrollHeight>52;Ce.includes("\n")||ue.length?e=!0:Ce.trim()||(e=!1),qe(e)})()}),[Ce,ue]),s.useEffect((()=>{const e=Te.current,t=He.current;if(!e||!t||Ne||Ce.includes("\n"))return void Ee(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,r=document.createElement("span");Object.assign(r.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),r.textContent=Ce,document.body.appendChild(r);const i=r.offsetWidth;r.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ee(i>l)}),[Ce,Ne]);const ut=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if("idle"!==ne||de)return;const n=ue.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),i=null!=t?t:Ce;if(!i&&!r)return;ce(""),he(""),le(null),Ie(""),V(!1),ae("fetching"),ve(),je();const o=null!==(s=null===(e=null==P?void 0:P.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,a=[...Array.from(se),Object.assign({id:se.length+1,role:"user",content:i},o&&{documentIds:n})];oe(a),je(),o&&me([]);const l=(yield Se.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:R,responseId:T,value:i},o&&{documentIds:n}),H&&{userId:H}),F&&{studioUserId:F}),L&&{embedUserId:L}),Z&&{studioSessionToken:Z}),W&&{deploymentId:W}))).body;if(!l)throw new Error("Streaming error");const c=a.length,u=new TextDecoder;Re.current=l.getReader();let d="",f=!0,p=!1,g=[...null!=xe?xe:[]];const m=v.createParser({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,oe([...a.slice(0,c),{id:se.length+1,role:"assistant",content:d}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ke(g),ye.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ke(g),ye.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ke(g),ye.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");g=g.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ke(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ke(g.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);ce(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(f=!1)}});for(;f&&Re.current;){const{value:e,done:t}=yield Re.current.read();if(t){f=!1;break}const s=u.decode(e);s&&(p||(ae("streaming"),p=!0),m.feed(s))}null==Y||Y(T)}catch(e){if("AbortError"===e.name)return void console.log("Stream stopped by user.");let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(re).find((([e])=>t.includes(e)));s?le(s[1]):ce(t)}finally{je(),ae("idle"),be(),Re.current=null}}));return ot?null:t.jsx("div",Object.assign({className:C.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!it&&"px-4 pb-4"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===$.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},st),Ze&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),et(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),et(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),et(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),et(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(V(!1),yield ge(e))}))},{children:[Le&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(_=B.accent)&&void 0!==_?_:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:B.text+"90"}},{children:"Listening..."}))]})),"idle"===ne&&ue.length>0&&t.jsx(k.default,{className:"p-4 pb-0",isDisabled:"idle"!==ne}),t.jsx(w.default,Object.assign({ref:Te,className:C.default(tt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ce.trim()&&!Ce.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",G?"text-right":"text-left",at&&"mb-12",Le&&"text-transparent"),value:Ce,placeholder:null!==(D=null==P?void 0:P.placeholdertext)&&void 0!==D?D:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Ie(e),q){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void q(0);if(t>=11)return;let s=0;t>1&&(s=50),q(24*(t-1)+s)}},onKeyDown:e=>{J||Be||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),de||"idle"!==ne||ut()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),V(!1),yield ge(e))}))},I&&{onFocus:I},N&&{onBlur:N},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:He,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",at?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!at&&st.backgroundColor&&{backgroundColor:st.backgroundColor}),{borderTopRightRadius:$.cornerRadius+"px",borderBottomRightRadius:$.cornerRadius+"px"})},{children:ie?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Re.current&&(Re.current.cancel(),Re.current=null),ae("idle")},style:{backgroundColor:B.accent,color:B.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):Le?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:$e,style:{backgroundColor:B.accent,color:B.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[nt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ke?B.accent+"10":void 0,color:Ke?B.accent:B.accent+"80"},disabled:de||"idle"!==ne,onClick:()=>{var e;return null===(e=_e.current)||void 0===e?void 0:e.click()}},Qe,{children:[t.jsx("input",{id:"file-upload",ref:_e,type:"file",accept:[...h.allowedFileMimeTypes,...fe?h.allowedImageMimeTypes:[],...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){V(!1),yield ge(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),rt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Le?B.accent:Xe?B.accent+"10":void 0,color:Le?B.accentText:Xe?B.accent:B.accent+"80"},disabled:de||"idle"!==ne,onClick:()=>{Le?$e():(De.current=Ce,Pe())}},Ye,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Je||ct?B.accent:B.accent+"10",color:Je||ct?B.accentText:B.accent+"80"},disabled:!ct,onClick:()=>ut()},ze,{children:t.jsx(j.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),pe&&t.jsx(O.default,{error:pe,className:"mt-3"})]}))}))}));I.displayName="Input",exports.default=I;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),r=require("copy-to-clipboard"),a=require("../../Icons/copy.svg.js"),o=require("../../Icons/copied.svg.js"),c=require("./PickaxeSimpleButton.js"),n=require("../../../common/cn.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(r);exports.default=({color:r,text:s="",className:u,iconClassName:d})=>{const[f,p]=i.useState(s),[m,h]=i.useState(!1),[j,x]=i.useState(!1);i.useEffect((()=>{p(s)}),[s]);return t.jsx(c.default,Object.assign({color:r},u&&{className:u},{isForceColor:j,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{if(m)return;h(!0);const t=null!==(e=[...Array.from(s.matchAll(/https:\/\/streaming\.pickaxeproject\.com\/api\/function_call_results\?.*?&name=[^&]+/g)),...Array.from(s.matchAll(/https:\/\/utils\.pickaxe\.co\/api\/fn\/result\?.*?&name=[^&]+/g))].map((e=>e[0])))&&void 0!==e?e:[],i=[];if(t.length){for(const e of t)try{const t=yield fetch(e),r=yield t.json(),a=r.text||r.url||"";i.push(a)}catch(e){console.error(e)}i.length&&p(i.join("\n"))}let r=i.length>0?i.join("\n"):f;(r.includes("<action-caption")||r.includes("<action-finished"))&&(r=r.replace(/<action-caption data-index="[^"]">(.*?)<\/action-caption>/g,"$1"),r=r.replace(/<action-finished data-index="[^"]">.*?<\/action-finished>/g,"")),l.default(r),h(!1),x(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){console.error(e)}finally{h(!1),x(!1)}}))},{children:m||j?t.jsx(o.default,{className:n.default("w-4 h-4 shrink-0",d)}):t.jsx(a.default,{className:n.default("w-4 h-4 shrink-0",d)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),o=require("copy-to-clipboard"),i=require("../../Icons/copy.svg.js"),a=require("../../Icons/copied.svg.js"),s=require("./PickaxeSimpleButton.js"),c=require("../../../common/cn.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(o);exports.default=({color:o,text:n="",className:u,iconClassName:f})=>{const[d,p]=r.useState(n),[m,h]=r.useState(!1),[j,g]=r.useState(!1);r.useEffect((()=>{p(n)}),[n]);return t.jsx(s.default,Object.assign({color:o},u&&{className:u},{isForceColor:j,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{if(m)return;h(!0);const t=null!==(e=[...Array.from(n.matchAll(/https:\/\/streaming\.pickaxeproject\.com\/api\/function_call_results\?.*?&name=[^&]+/g)),...Array.from(n.matchAll(/https:\/\/utils\.pickaxe\.co\/api\/fn\/result\?.*?&name=[^&]+/g))].map((e=>e[0])))&&void 0!==e?e:[],r=[];if(t.length){for(const e of t)try{const t=yield fetch(e),o=yield t.json(),i=o.text||o.url||"";r.push(i)}catch(e){console.error(e)}r.length&&p(r.join("\n"))}let o=r.length>0?r.join("\n"):d;/<action-(caption|finished|error)/.test(o)&&(o=o.replace(/<action-caption\b[^>]*>([\s\S]*?)<\/action-caption>/g,"$1"),o=o.replace(/<action-finished\b[^>]*>[\s\S]*?<\/action-finished>/g,""),o=o.replace(/<action-error\b[^>]*>[\s\S]*?<\/action-error>/g,"")),l.default(o),h(!1),g(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){console.error(e)}finally{h(!1),g(!1)}}))},{children:m||j?t.jsx(a.default,{className:c.default("w-4 h-4 shrink-0",f)}):t.jsx(i.default,{className:c.default("w-4 h-4 shrink-0",f)})}))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../hooks/usePickaxeMarkdownContext.js"),r=require("framer-motion"),n=require("../../../../../Icons/chevron-down.svg.js"),o=require("../../../../../Icons/chevron-up.svg.js");const i={collapsed:{height:0,opacity:0,marginTop:0,marginBottom:0},expanded:{height:"auto",opacity:1,marginTop:"1rem",marginBottom:0}},a=e=>{try{return["string","number"].includes(typeof e)?e:e instanceof Array?e.map(a).join(""):"object"==typeof e&&e?a(e.props.children):""}catch(e){return""}};exports.Think=({node:c,children:l})=>{const{colors:d}=t.usePickaxeMarkdownContext(),[u,x]=s.useState(!1);return e.jsxs("div",Object.assign({className:"flex flex-col mb-4"},{children:[e.jsxs("div",Object.assign({className:"flex flex-row gap-2 items-center"},{children:[e.jsx("div",Object.assign({className:"text-sm",style:{color:d.text+50}},{children:"Thoughts"})),e.jsx("button",Object.assign({className:"rounded-full cursor-pointer outline-none text-c-secondary transition-colors duration-300",onClick:()=>x(!u)},{children:u?e.jsx(o.default,{className:"w-3 h-3 shrink-0"}):e.jsx(n.default,{className:"w-3 h-3 shrink-0"})}))]})),e.jsx(r.AnimatePresence,Object.assign({initial:!1},{children:u&&e.jsx(r.motion.div,Object.assign({className:"flex flex-col pl-3 text-sm border-l whitespace-pre-wrap",style:{borderColor:d.text+40,color:d.text+50},initial:"collapsed",animate:"expanded",exit:"collapsed",variants:i,transition:{duration:.2,ease:"easeInOut"}},{children:a(l).replace(/^\s+|\s+$/g,"")}),"reasoning")}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),t=require("react"),n=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),s=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),f=require("./Components/Headings/index.js"),x=require("./Components/List/index.js"),g=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),j=require("./Components/Action/index.js"),C=require("./Components/Artifact/index.js"),q=require("../../../../common/cn.js");function k(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var w=k(s),A=k(a),y=k(o),v=k(l),O=k(c);exports.PickaxeMarkdownRenderer=({className:s,style:a,children:o,value:l,maxLines:c,maxChars:k,multiLineBreaks:P,recursion:H,onExpandClick:S})=>{const{colors:M,rtl:$,disableHtml:E,disableJs:T,disableCss:_}=n.usePickaxeMarkdownContext(),[I,L]=t.useState({width:0,height:0}),[B,N]=t.useState(null),R=t.useRef(null),z=t.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),P&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,P]);t.useEffect((()=>{if(k)return void N(z.length>k?z.slice(0,k)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void N(null);if(!R.current||!z||B)return;const e=R.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),t=c*r;if(!(I.height>t))return;const n=Math.floor(I.width/8),i=Math.floor(n*c);N(z.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[z,c,k,I,B]);const F={h1:f.H1,h2:f.H2,h3:f.H3,h4:f.H4,h5:f.H5,p:d.P,a:u.A,img:p.Img,iframe:h.Iframe,code:m.Code,ol:x.Ol,ul:x.Ul,li:x.Li,table:g.Table,th:g.Th,tr:g.Tr,td:g.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:t=>{var{children:n}=t,i=e.__rest(t,["children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:M.accent,marginLeft:".25rem",userSelect:"none"},S&&{cursor:"pointer"})},S&&{onClick:S},{children:n})):r.jsx("span",Object.assign({},i,{children:n}))},ActionCaption:j.ActionCaption,ActionFinished:j.ActionFinished,ActionError:j.ActionError,Artifact:C.Artifact,ArtifactError:C.ArtifactError};t.useEffect((()=>{if(!R.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:t}=r.contentRect;L({width:e,height:t})}}));return e.observe(R.current),()=>{e.disconnect()}}),[]);const J=B||z;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:R,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},a)},$&&{dir:"rtl"},{children:[r.jsx(w.default,Object.assign({className:q.default(!H&&"pxe-prose",s),components:F,remarkPlugins:[A.default,[y.default,{singleDollarTextMath:!1}]],rehypePlugins:[i.rehypeCode,v.default,...E?[]:[O.default],[i.rehypeSanitize,{disableJs:T,disableCss:_}],i.rehypePickaxeAction,i.rehypePickaxeArtifacts]},{children:J})),o]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),s=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),f=require("./Components/Headings/index.js"),x=require("./Components/List/index.js"),g=require("./Components/Table/index.js"),j=require("./Components/Others/index.js"),b=require("./Components/Action/index.js"),q=require("./Components/Artifact/index.js"),C=require("./Components/Others/Think.js"),k=require("../../../../common/cn.js");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var $=w(s),v=w(a),y=w(o),O=w(l),A=w(c);exports.PickaxeMarkdownRenderer=({className:s,style:a,children:o,value:l,maxLines:c,maxChars:w,multiLineBreaks:H,recursion:T,onExpandClick:M})=>{const{colors:P,rtl:S,disableHtml:_,disableJs:E,disableCss:I}=t.usePickaxeMarkdownContext(),[L,B]=n.useState({width:0,height:0}),[N,R]=n.useState(null),z=n.useRef(null),J=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),H&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,H]);n.useEffect((()=>{if(w)return void R(J.length>w?J.slice(0,w)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void R(null);if(!z.current||!J||N)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=c*r;if(!(L.height>n))return;const t=Math.floor(L.width/8),i=Math.floor(t*c);R(J.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[J,c,w,L,N]);const W={h1:f.H1,h2:f.H2,h3:f.H3,h4:f.H4,h5:f.H5,p:d.P,a:u.A,img:p.Img,iframe:h.Iframe,code:m.Code,ol:x.Ol,ul:x.Ul,li:x.Li,table:g.Table,th:g.Th,tr:g.Tr,td:g.Td,hr:j.Hr,br:j.Br,blockquote:j.Blockquote,span:n=>{var{children:t}=n,i=e.__rest(n,["children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:P.accent,marginLeft:".25rem",userSelect:"none"},M&&{cursor:"pointer"})},M&&{onClick:M},{children:t})):r.jsx("span",Object.assign({},i,{children:t}))},"action-caption":b.ActionCaption,"action-finished":b.ActionFinished,"action-error":b.ActionError,artifact:q.Artifact,"artifact-error":q.ArtifactError,think:C.Think};n.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;B({width:e,height:n})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const D=N||J;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},a)},S&&{dir:"rtl"},{children:[r.jsx($.default,Object.assign({className:k.default(!T&&"pxe-prose",s),components:W,remarkPlugins:[v.default,[y.default,{singleDollarTextMath:!1}]],rehypePlugins:[i.rehypeCode,O.default,..._?[]:[A.default],[i.rehypeSanitize,{disableJs:E,disableCss:I}]]},{children:D})),o]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"],r=["artifact","artifact-error"],n=["Artifact","ArtifactError"];exports.rehypeCode=()=>t=>{e.visit(t,"code",(e=>{var t;e.lang=null!==(t=e.lang)&&void 0!==t?t:"plaintext"}))},exports.rehypePickaxeAction=()=>r=>(e.visit(r,"element",(e=>{const i=e.tagName;if(t.includes(i)){const t=i.split("-");e.tagName=t.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e.visit(r,"element",((t,r,n)=>{if("p"===t.tagName){const o=t.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===o.length){const t=o[0];if("element"===t.type&&i.includes(t.tagName)&&n&&"children"in n&&n.children&&void 0!==r)return n.children.splice(r,1,t),[e.SKIP,r]}}})),r),exports.rehypePickaxeArtifacts=()=>t=>(e.visit(t,"element",(e=>{const t=e.tagName;if(r.includes(t)){const i=t.split("-");e.tagName=i.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e.visit(t,"element",((t,i,r)=>{if("p"===t.tagName){const o=t.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===o.length){const t=o[0];if("element"===t.type&&n.includes(t.tagName)&&r&&"children"in r&&r.children&&void 0!==i)return r.children.splice(i,1,t),[e.SKIP,i]}}})),t),exports.rehypeSanitize=(t={})=>i=>{e.visit(i,"element",((i,r,n)=>{if(t.disableJs){if("script"===i.tagName&&n&&"number"==typeof r)return n.children.splice(r,1),[e.SKIP,r];if(i.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{i.properties[e]&&delete i.properties[e]})),i.properties.href&&"string"==typeof i.properties.href&&i.properties.href.toLowerCase().startsWith("javascript:")&&delete i.properties.href}}if(t.disableCss&&"style"===i.tagName&&n&&"number"==typeof r)return n.children.splice(r,1),[e.SKIP,r]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");exports.rehypeCode=()=>r=>{e.visit(r,"code",(e=>{var r;e.lang=null!==(r=e.lang)&&void 0!==r?r:"plaintext"}))},exports.rehypeSanitize=(r={})=>t=>{e.visit(t,"element",((t,i,o)=>{if(r.disableJs){if("script"===t.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[e.SKIP,i];if(t.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{t.properties[e]&&delete t.properties[e]})),t.properties.href&&"string"==typeof t.properties.href&&t.properties.href.toLowerCase().startsWith("javascript:")&&delete t.properties.href}}if(r.disableCss&&"style"===t.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[e.SKIP,i]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/pickaxe/useSubmitFeedback.js"),a=require("../../../hooks/pickaxe/useThumbSelection.js"),n=require("framer-motion"),l=require("../../Icons/message-square-notes.svg.js"),o=require("../../Icons/thumbs-down.svg.js"),c=require("../../Icons/thumbs-up.svg.js"),r=require("./PickaxeSimpleButton.js"),u=require("./PickaxeCopyButton.js"),d=require("./PickaxeFeedbackThumbsDownReasons.js"),b=require("../../../common/cn.js");exports.default=({content:p,index:m=0,chatCount:x,responseId:h,isForm:j,isHideFeedback:f,onOpenChat:k})=>{var y,g,v,w;const{mutateAsync:O}=t.useSubmitFeedback(),{colors:T,translations:q,pickaxe:N,setIsShowFeedbackMessage:S}=i.usePickaxeContext(),C=s.useStyleFontSize(),{toggleThumb:D,submitThumbsDown:F,submitThumbsUp:P,isThumbsUpSelected:I,isThumbsDownSelected:U,showThumbsDownOptions:z,showThumbsUpOptions:R,showSuccess:A}=a.useThumbSelection({content:p,index:m,responseId:h,successDuration:2e3,thumbsDownPromptRate:.3,onThumbsDownReasonOpen:()=>S(!0),onThumbsDownReasonClose:()=>S(!1),submit:O}),B="function"==typeof k&&!!(null==N?void 0:N.enablechatresponses)&&void 0!==h&&void 0!==x,H=Boolean((null==N?void 0:N.enablechatresponses)&&!k||!(null==N?void 0:N.enablechatresponses)&&j)&&!f;return e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:"flex h-4 items-center gap-3"},{children:[B&&e.jsxs(r.default,Object.assign({color:T.accent,onClick:k},{children:[e.jsx(l.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:b.default(C.b3,"font-semibold")},{children:x}))]})),e.jsx(u.default,{color:T.accent,text:p}),H&&e.jsxs(e.Fragment,{children:[e.jsx(r.default,Object.assign({color:T.accent,onClick:()=>D("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:e.jsx(c.default,{className:"size-4",style:{fill:T.text,fillOpacity:I?.3:0}})})),e.jsx(r.default,Object.assign({color:T.accent,onClick:()=>D("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:e.jsx(o.default,{className:"size-4",style:{fill:T.text,fillOpacity:U?.3:0}})})),e.jsx(n.AnimatePresence,{children:A&&e.jsx(n.motion.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:e.jsx("p",Object.assign({className:b.default(C.b4,T.secondary,"opacity-75")},{children:null!==(y=null==q?void 0:q["feedback-thanks"])&&void 0!==y?y:"Thanks for the feedback!"}))}))})]})]})),e.jsx(n.AnimatePresence,{children:(z||R)&&e.jsxs(n.motion.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:"space-y-0.5"},{children:[e.jsx("p",Object.assign({className:b.default(C.b3,T.text)},{children:R?null!==(g=null==q?void 0:q["feedback-like-title"])&&void 0!==g?g:"What went right?":null!==(v=null==q?void 0:q["feedback-dislike-title"])&&void 0!==v?v:"What went wrong?"})),e.jsx("p",Object.assign({className:b.default(C.b3,T.secondary,"opacity-75")},{children:null!==(w=null==q?void 0:q["feedback-dislike-message"])&&void 0!==w?w:"Help us improve our answers"}))]})),e.jsx(n.motion.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:e.jsx(d.default,{isUp:R,submitThumbsDown:F,submitThumbsUp:P})}))]}))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/pickaxe/useSubmitFeedback.js"),a=require("../../../hooks/pickaxe/useThumbSelection.js"),n=require("framer-motion"),l=require("../../Icons/message-square-notes.svg.js"),o=require("../../Icons/thumbs-down.svg.js"),c=require("../../Icons/thumbs-up.svg.js"),r=require("./PickaxeSimpleButton.js"),u=require("./PickaxeCopyButton.js"),d=require("./PickaxeFeedbackThumbsDownReasons.js"),b=require("../../../common/cn.js");exports.default=({content:p,index:m=0,chatCount:x,responseId:h,isForm:j,isHideFeedback:f,onOpenChat:k})=>{var y,g,v,O;const{mutateAsync:w}=t.useSubmitFeedback(),{colors:T,translations:q,pickaxe:N,setIsShowFeedbackMessage:S}=i.usePickaxeContext(),C=s.useStyleFontSize(),{toggleThumb:F,submitThumbsDown:D,submitThumbsUp:P,isThumbsUpSelected:I,isThumbsDownSelected:U,showThumbsDownOptions:z,showThumbsUpOptions:R,showSuccess:A}=a.useThumbSelection({content:p,index:m,responseId:h,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>S(!0),onThumbsDownReasonClose:()=>S(!1),submit:w}),B="function"==typeof k&&!!(null==N?void 0:N.enablechatresponses)&&void 0!==h&&void 0!==x,H=Boolean((null==N?void 0:N.enablechatresponses)&&!k||!(null==N?void 0:N.enablechatresponses)&&j)&&!f;return e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:"flex h-4 items-center gap-3"},{children:[B&&e.jsxs(r.default,Object.assign({color:T.accent,onClick:k},{children:[e.jsx(l.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:b.default(C.b3,"font-semibold")},{children:x}))]})),e.jsx(u.default,{color:T.accent,text:p}),H&&e.jsxs(e.Fragment,{children:[e.jsx(r.default,Object.assign({color:T.accent,onClick:()=>F("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:e.jsx(c.default,{className:"size-4",style:{fill:T.text,fillOpacity:I?.3:0}})})),e.jsx(r.default,Object.assign({color:T.accent,onClick:()=>F("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:e.jsx(o.default,{className:"size-4",style:{fill:T.text,fillOpacity:U?.3:0}})})),e.jsx(n.AnimatePresence,{children:A&&e.jsx(n.motion.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:e.jsx("p",Object.assign({className:b.default(C.b4,T.secondary,"opacity-75")},{children:null!==(y=null==q?void 0:q["feedback-thanks"])&&void 0!==y?y:"Thanks for the feedback!"}))}))})]})]})),e.jsx(n.AnimatePresence,{children:(z||R)&&e.jsxs(n.motion.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:"space-y-0.5"},{children:[e.jsx("p",Object.assign({className:b.default(C.b3,T.text)},{children:R?null!==(g=null==q?void 0:q["feedback-like-title"])&&void 0!==g?g:"What went right?":null!==(v=null==q?void 0:q["feedback-dislike-title"])&&void 0!==v?v:"What went wrong?"})),e.jsx("p",Object.assign({className:b.default(C.b3,T.secondary,"opacity-75")},{children:null!==(O=null==q?void 0:q["feedback-dislike-message"])&&void 0!==O?O:"Help us improve our answers"}))]})),e.jsx(n.motion.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:e.jsx(d.default,{isUp:R,submitThumbsDown:D,submitThumbsUp:P})}))]}))})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),s=require("./useCreateFeedbackPayload.js");exports.useThumbSelection=({content:t,index:n,responseId:i,submit:o,onThumbsDownReasonOpen:u,onThumbsDownReasonClose:a,onThumbsUpReasonOpen:l,onThumbsUpReasonClose:c,successDuration:b=3e3,thumbsDownPromptRate:d=1,thumbsUpPromptRate:r=1})=>{const m=s.useCreateFeedbackPayload({content:t,index:n,responseId:i}),[k,p]=e.useState(null),[h,T]=e.useState(!1),[O,g]=e.useState(!1),[f,j]=e.useState(!1),w=()=>{j(!0),setTimeout((()=>j(!1)),b)},S=()=>{h&&(T(!1),null==a||a()),O&&(g(!1),null==c||c())};return{selectedThumb:k,showThumbsDownOptions:h,showThumbsUpOptions:O,toggleThumb:e=>{if("like"===e){const e="like"===k&&O,s=!e&&Math.random()<r;return S(),s?(p("like"),g(!0),void(null==l||l())):e?void p(null):(p("like"),o(Object.assign(Object.assign({},m),{feedbackType:"like",content:t})),void w())}if("dislike"===e){const e="dislike"===k&&h,s=!e&&Math.random()<d;if(S(),s)return p("dislike"),T(!0),void(null==u||u());if(e)return void p(null);p("dislike"),o(Object.assign(Object.assign({},m),{feedbackType:"dislike",content:t})),w()}},submitThumbsDown:e=>{o(Object.assign(Object.assign({},m),{feedbackType:"dislike",content:t,feedbackMessage:e})),S(),w()},submitThumbsUp:e=>{o(Object.assign(Object.assign({},m),{feedbackType:"like",content:t,feedbackMessage:e})),S(),w()},isThumbsUpSelected:"like"===k,isThumbsDownSelected:"dislike"===k,showSuccess:f}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),s=require("./useCreateFeedbackPayload.js");exports.useThumbSelection=({content:t,index:n,responseId:i,submit:o,onThumbsDownReasonOpen:u,onThumbsDownReasonClose:a,onThumbsUpReasonOpen:l,onThumbsUpReasonClose:c,successDuration:b=3e3,promptRate:d=1})=>{const r=s.useCreateFeedbackPayload({content:t,index:n,responseId:i}),[k,m]=e.useState(null),[p,h]=e.useState(!1),[T,O]=e.useState(!1),[g,f]=e.useState(!1),j=()=>{f(!0),setTimeout((()=>f(!1)),b)},w=()=>{p&&(h(!1),null==a||a()),T&&(O(!1),null==c||c())};return{selectedThumb:k,showThumbsDownOptions:p,showThumbsUpOptions:T,toggleThumb:e=>{if("like"===e){const e="like"===k&&T,s=!e&&Math.random()<d;return w(),s?(m("like"),O(!0),void(null==l||l())):e?void m(null):(m("like"),o(Object.assign(Object.assign({},r),{feedbackType:"like",content:t})),void j())}if("dislike"===e){const e="dislike"===k&&p,s=!e&&Math.random()<d;if(w(),s)return m("dislike"),h(!0),void(null==u||u());if(e)return void m(null);m("dislike"),o(Object.assign(Object.assign({},r),{feedbackType:"dislike",content:t})),j()}},submitThumbsDown:e=>{o(Object.assign(Object.assign({},r),{feedbackType:"dislike",content:t,feedbackMessage:e})),w(),j()},submitThumbsUp:e=>{o(Object.assign(Object.assign({},r),{feedbackType:"like",content:t,feedbackMessage:e})),w(),j()},isThumbsUpSelected:"like"===k,isThumbsDownSelected:"dislike"===k,showSuccess:g}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base2.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};