@pickaxeproject/react 6.1.0-4 → 6.1.0-5

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 (23) hide show
  1. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  2. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  6. package/dist/cjs/components/Pickaxe/index.js +1 -1
  7. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  8. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  9. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  10. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  11. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +1 -4
  12. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  13. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  14. package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
  15. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  16. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  17. package/dist/esm/components/Pickaxe/index.js +1 -1
  18. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  19. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  20. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  21. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  22. package/dist/esm/src/components/Pickaxe/Provider.d.ts +1 -4
  23. package/package.json +1 -1
@@ -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"),a=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),o=require("../../common/PickaxeIcon.js"),l=require("./Document.js"),c=require("../../common/PickaxeMessageActions.js"),d=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),x=require("../../../../common/isoMap.js"),m=require("franc-min"),f=require("../../common/SmitheryConnectView.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(require("remove-markdown"));exports.default=({index:h,message:j,smitheryData:g,resubmitPrompt:b,isLastMessage:w=!1})=>{var y,v;const{pickaxeId:k,pickaxe:O,styles:N,colors:q,misc:S,responsiveBy:C,disableHtml:I,disableJs:A,disableCss:P,isNewChat:R,isRtl:M}=t.usePickaxeContext(),{isGenerating:F}=i.useResponseContext(),{onLoadArtifact:H}=n.useArtifact(),[L,T]=s.useState(!1),[E,J]=s.useState([]),V=a.useStyleFontSize(),z=null!==(y=null==O?void 0:O.chaticon)&&void 0!==y?y:`https://cdn.mail.studio/chaticons/${k}.png`,B=w&&F,D=null==O?void 0:O.enablereadout;s.useEffect((()=>{if(!D||"assistant"!==j.role)return;const e=()=>{const e=window.speechSynthesis.getVoices();e.length>0&&J(e)};return e(),window.speechSynthesis.onvoiceschanged=e,()=>{window.speechSynthesis.onvoiceschanged=null}}),[D,j.role]),s.useEffect((()=>()=>{L&&window.speechSynthesis.cancel()}),[L]);const G=()=>{if(L)return window.speechSynthesis.cancel(),void T(!1);const e=j.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=p.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=m.franc(s),a=x.convertToIso1(t);window.speechSynthesis.cancel();const i=new SpeechSynthesisUtterance(s),n=E.find((e=>e.lang.startsWith(a)&&e.name.includes("Google")))||E.find((e=>e.lang.startsWith(a)));n?(i.voice=n,i.lang=n.lang):i.lang=a||"en",i.onstart=()=>T(!0),i.onend=()=>T(!1),i.onerror=()=>T(!1),window.speechSynthesis.speak(i)},U=!j.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===j.role?e.jsx("div",Object.assign({className:u.default("flex w-full",M?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:u.default("flex flex-col w-full",0===h&&R&&"viewport"===C&&"min-[767px]:max-w-[80%]",0===h&&R&&"container"===C&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:u.default("flex gap-x-3",M&&"flex-row-reverse")},{children:[S.isChatImage&&"NONE"!==z&&e.jsx(o.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:q.text}),e.jsxs("div",Object.assign({className:u.default("flex flex-col flex-grow",M?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:u.default(V.b2,"chat-message pt-3 w-full",M?"text-right":"text-left")},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:N.theme,colors:q},M&&{rtl:!0},I&&{disableHtml:!0},A&&{disableJs:!0},P&&{disableCss:!0},{disableReasoning:null!==(v=null==O?void 0:O.enablereasoningdisplay)&&void 0!==v&&v,onArtifactClick:H},{children:e.jsx(d.default,{parts:j.parts})})),w&&g&&b&&e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(f.default,{serverId:g.serverId,smitheryId:g.smitheryId,name:g.smitheryId,resubmitPrompt:()=>b()})}))]})),e.jsx("div",Object.assign({className:u.default("flex flex-col gap-6 my-4",U&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:u.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:q.secondaryText}},t)))})):e.jsx(c.default,Object.assign({content:j.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:h},"intromessage"===j.area&&{isHideFeedback:!0},{onReadOut:G,isReadOut:D||!1,isReading:L}))}))]}))]}))}))})):"user"===j.role?e.jsx("div",Object.assign({className:u.default("flex w-full",M?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:u.default("flex gap-x-3 max-w-[80%]",M?"pr-9":"pl-9","viewport"===C?M?"min-[767px]:pr-0":"min-[767px]:pl-0":M?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:u.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",M?"text-right":"text-left"),style:{backgroundColor:q.secondary+"80",color:q.secondaryText,borderRadius:N.cornerRadius}},{children:[j.documentIds&&j.documentIds.length>0&&e.jsx("div",Object.assign({className:u.default("flex flex-col gap-y-2",M?"items-start":"items-end")},{children:j.documentIds.map((t=>e.jsx(s.Fragment,{children:e.jsx(l.default,{documentId:t})},t)))})),e.jsx(r.PickaxeMarkdown,Object.assign({theme:N.theme,colors:q},M&&{rtl:!0},I&&{disableHtml:!0},A&&{disableJs:!0},P&&{disableCss:!0},{children:e.jsx(d.default,{parts:j.parts})}))]}))}))})):e.jsx("div",{})};
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"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),o=require("../../common/PickaxeIcon.js"),l=require("./Document.js"),c=require("../../common/PickaxeMessageActions.js"),d=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),x=require("../../../../common/isoMap.js"),m=require("franc-min"),f=require("../../common/SmitheryConnectView.js");exports.default=({index:h,message:p,smitheryData:j,resubmitPrompt:g,isLastMessage:b=!1})=>{var w,y;const{pickaxeId:v,pickaxe:k,styles:O,colors:N,misc:S,responsiveBy:q,disableHtml:C,disableJs:I,disableCss:P,isNewChat:A,isRtl:R}=t.usePickaxeContext(),{isGenerating:M}=i.useResponseContext(),{onLoadArtifact:F}=n.useArtifact(),[H,E]=s.useState(!1),[J,T]=s.useState([]),V=a.useStyleFontSize(),z=null!==(w=null==k?void 0:k.chaticon)&&void 0!==w?w:`https://cdn.mail.studio/chaticons/${v}.png`,B=b&&M,D=null==k?void 0:k.enablereadout;s.useEffect((()=>{if(!D||"assistant"!==p.role)return;const e=()=>{const e=window.speechSynthesis.getVoices();e.length>0&&T(e)};return e(),window.speechSynthesis.onvoiceschanged=e,()=>{window.speechSynthesis.onvoiceschanged=null}}),[D,p.role]),s.useEffect((()=>()=>{H&&window.speechSynthesis.cancel()}),[H]);const G=()=>{if(H)return window.speechSynthesis.cancel(),void E(!1);const e=p.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=m.franc(e),t=x.convertToIso1(s);window.speechSynthesis.cancel();const a=new SpeechSynthesisUtterance(e),i=J.find((e=>e.lang.startsWith(t)&&e.name.includes("Google")))||J.find((e=>e.lang.startsWith(t)));i?(a.voice=i,a.lang=i.lang):a.lang=t||"en",a.onstart=()=>E(!0),a.onend=()=>E(!1),a.onerror=()=>E(!1),window.speechSynthesis.speak(a)},L=!p.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===p.role?e.jsx("div",Object.assign({className:u.default("flex w-full",R?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:u.default("flex flex-col w-full",0===h&&A&&"viewport"===q&&"min-[767px]:max-w-[80%]",0===h&&A&&"container"===q&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:u.default("flex gap-x-3",R&&"flex-row-reverse")},{children:[S.isChatImage&&"NONE"!==z&&e.jsx(o.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:N.text}),e.jsxs("div",Object.assign({className:u.default("flex flex-col flex-grow",R?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:u.default(V.b2,"chat-message pt-3 w-full",R?"text-right":"text-left")},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},R&&{rtl:!0},C&&{disableHtml:!0},I&&{disableJs:!0},P&&{disableCss:!0},{disableReasoning:null!==(y=null==k?void 0:k.enablereasoningdisplay)&&void 0!==y&&y,onArtifactClick:F},{children:e.jsx(d.default,{parts:p.parts})})),b&&j&&g&&e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(f.default,{serverId:j.serverId,smitheryId:j.smitheryId,name:j.smitheryId,resubmitPrompt:()=>g()})}))]})),e.jsx("div",Object.assign({className:u.default("flex flex-col gap-6 my-4",L&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:u.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:N.secondaryText}},t)))})):e.jsx(c.default,Object.assign({content:p.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:h},"intromessage"===p.area&&{isHideFeedback:!0},{onReadOut:G,isReadOut:D||!1,isReading:H}))}))]}))]}))}))})):"user"===p.role?e.jsx("div",Object.assign({className:u.default("flex w-full",R?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:u.default("flex gap-x-3 max-w-[80%]",R?"pr-9":"pl-9","viewport"===q?R?"min-[767px]:pr-0":"min-[767px]:pl-0":R?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:u.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",R?"text-right":"text-left"),style:{backgroundColor:N.secondary+"80",color:N.secondaryText,borderRadius:O.cornerRadius}},{children:[p.documentIds&&p.documentIds.length>0&&e.jsx("div",Object.assign({className:u.default("flex flex-col gap-y-2",R?"items-start":"items-end")},{children:p.documentIds.map((t=>e.jsx(s.Fragment,{children:e.jsx(l.default,{documentId:t})},t)))})),e.jsx(r.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},R&&{rtl:!0},C&&{disableHtml:!0},I&&{disableJs:!0},P&&{disableCss:!0},{children:e.jsx(d.default,{parts:p.parts})}))]}))}))})):e.jsx("div",{})};
@@ -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");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),N=require("../../../common/cn.js"),C=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=_(n);const T=s.forwardRef((({resubmitPrompt:_,onFocus:T,onBlur:A,onInputHeightChange:R,initSmitheryAuthData:q},P)=>{var D,L,U;const{origin:M,pickaxeId:$,sessionId:B,sender:F,senderType:H,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:V,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,onGenerateComplete:ie}=i.usePickaxeContext(),{token:oe,isLoggedOut:re,isSent:ae,isPricingAuth:le}=d.useAuthContext(),{messages:ce,isGenerating:de,setMessages:ue,setStatus:fe,setLimitData:pe,setError:me}=o.useResponseContext(),{documents:ge,isUploading:he,documentError:ve,onFileUpload:be,setDocuments:xe,setDocumentError:ye}=u.useDocument(),{studio:je}=I.useStudio(),{scrollStartSession:we,scrollEndSession:Oe,scrollToBottom:ke}=f.useScroll({auto:!0}),{artifacts:Se,currentPopupType:Ne,setArtifacts:Ce,setCurrentArtifact:Ie}=p.useArtifactContext(),{height:_e}=c.useDimensionContext(),Ee=l.useConversation(),[Te,Ae]=s.useState(""),[Re,qe]=s.useState(!1),[Pe,De]=s.useState(!1),[Le,Ue]=s.useState(null),[Me,$e]=s.useState(null),[Be,Fe]=s.useState(!1),He=s.useRef(null),Xe=s.useRef(""),Ke=s.useRef(null),We=s.useRef(null),Je=s.useRef(null),Ve=s.useRef(null),ze=s.useRef(null),Ge=Math.max(.4*_e,100),{transcript:Qe,listening:Ye,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=n.useSpeechRecognition(),[tt]=g.useMediaQuery("(max-width: 480px)"),st=m.useHover(),{isHover:nt}=st,it=e.__rest(st,["isHover"]),ot=m.useHover(),{isHover:rt}=ot,at=e.__rest(ot,["isHover"]),lt=m.useHover(),{isHover:ct}=lt,dt=e.__rest(lt,["isHover"]),ut=a.useStyleFontSize(),ft=r.useStyleInput(),pt="undefined"!=typeof window?window.location.hostname:"",mt="undefined"!=typeof window?window.location.href:"",gt="undefined"!=typeof window&&window.self!==window.top,ht=pt.includes("pickaxe.co")&&!mt.includes("https://studio.pickaxe.co/_embed")&&!gt,vt=null===(D=null==J?void 0:J.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),bt=et&&(null==J?void 0:J.enablevoicetotext),xt="chat-input"===W&&Y&&!ae,yt="chat-input"===W&&le&&re&&ae,jt=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",wt=Re||Pe,Ot=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==J?void 0:J.studioid},F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ht&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ue(t.studioUser),$e(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,B,H,F,oe,X,K,ht]);s.useEffect((()=>{Ot()}),[Ot]);const kt=(null==te?void 0:te.limit)||0,St=(null==Le?void 0:Le.currentUses)||0,Nt=(null==Le?void 0:Le.extraUses)||0,Ct=!!(null==je?void 0:je.data.usage)&&je.data.usage.isCredits,It=kt>St?kt-St+Nt:Nt,_t=s.useMemo((()=>!!Le&&(!Be&&(!(kt<=0)&&It<=.05*kt))),[Le,Be,It,kt]),Et=s.useMemo((()=>{var e,t,s;return!!Y&&(!!J&&(!Ee.isLoading&&(!((null!==(t=null===(e=Ee.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!xt)))))}),[J,Y,ee,xt,Ee.data,Ee.isLoading]),Tt=s.useMemo((()=>{if(de||he)return!1;const e=ge.length>0&&ge.every((e=>"finished"===e.status));return!(!Te.trim()&&!e)&&ge.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[de,he,Te,ge]);s.useImperativeHandle(P,(()=>({onSubmit:At}))),s.useEffect((()=>{ne(Et)}),[Et]),s.useEffect((()=>{var e;if(_){const t=Array.from(ce),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;At(s,!0)}}),[_]),s.useEffect((()=>{if(!Ve.current||!R)return;const e=new ResizeObserver((e=>{for(const t of e)R(t.contentRect.height)}));return e.observe(Ve.current),()=>{e.disconnect()}}),[R]),s.useEffect((()=>{if(!Ye)return;const e=Xe.current?`${Xe.current} `:"";Ae(`${e}${Qe}`)}),[Qe,Ye]),s.useEffect((()=>{if(!We.current)return;(()=>{if(!We.current)return;let e=We.current.scrollHeight>52;Te.includes("\n")||ge.length?e=!0:Te.trim()||(e=!1),qe(e)})()}),[Te,ge]),s.useEffect((()=>{const e=We.current,t=Je.current;if(!e||!t||Re||Te.includes("\n"))return void De(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Te||jt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;De(o>l)}),[Te,Re,jt]);const At=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(de||he)return;const o=ge.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:Te;if(!c&&!l)return;me(""),ye(""),pe(null),Ae(""),se(!1),fe("fetching"),we(),ke();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ce.slice(0,ce.length-1)):Array.from(ce),...s?[]:[{id:ce.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ce.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ue(u),ke(),d&&xe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:B,senderType:H,value:c},d&&{documentIds:r}),F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},ht&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;fe("streaming"),ze.current=new AbortController;const g=u.length-1,h=[];let b=[...null!=Se?Se:[]],x=0,y=!1,j="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${x}`,{signal:null===(i=ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return me(t),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ue([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:ce.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce([...b]),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ce(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ce(b.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);me(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ie||ie(B)}catch(e){if(e.limitData)pe(e.limitData),me("");else{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."),me(t)}}finally{ke(),fe("idle"),Oe(),Ke.current=null,yield Ot()}}));return yt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!xt&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ve,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===V.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ft),{maxHeight:`${Ge}px`,overflowY:"auto"})},{children:[_t&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:ft.backgroundColor?`${ft.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:V.cornerRadius+"px",borderTopLeftRadius:V.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[It," ",Ct?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Me}${null==te?void 0:te.accessGroupId}`;C.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Fe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!de&&ge.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:de}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ye&&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!==(U=z.accent)&&void 0!==U?U:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:We,className:N.default(ut.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Te.trim()&&!Te.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",wt&&"mb-12",Ye&&"text-transparent"),value:Te,placeholder:jt,onChange:e=>{if(Ae(e),R){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void R(0);if(t>=11)return;let s=0;t>1&&(s=50),R(24*(t-1)+s)}},onKeyDown:e=>{Q||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),he||de||At()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield be(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Je,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",wt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!wt&&ft.backgroundColor&&{backgroundColor:ft.backgroundColor}),{borderTopRightRadius:V.cornerRadius+"px",borderBottomRightRadius:V.cornerRadius+"px"})},{children:de?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:()=>{ze.current&&(ze.current.abort(),ze.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),fe("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Ye?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.default.stopListening,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[vt&&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:rt?z.accent+"10":void 0,color:rt?z.accent:z.accent+"80"},disabled:he||de,onClick:()=>{var e;return null===(e=He.current)||void 0===e?void 0:e.click()}},at,{children:[t.jsx("input",{id:"file-upload",ref:He,type:"file",accept:[...h.allowedFileMimeTypes,...h.allowedImageMimeTypes,...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield be(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),bt&&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:Ye?z.accent:ct?z.accent+"10":void 0,color:Ye?z.accentText:ct?z.accent:z.accent+"80"},disabled:he||de,onClick:()=>{Ye?E.default.stopListening():(Xe.current=Te,Ze(),E.default.startListening({continuous:!0,interimResults:!0,language:G||"en-US"}))}},dt,{children:t.jsx(y.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:nt||Tt?z.accent:z.accent+"10",color:nt||Tt?z.accentText:z.accent+"80"},disabled:!Tt,onClick:()=>At()},it,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),ve&&t.jsx(k.default,{error:ve,className:"mt-3"})]}))}))}));T.displayName="Input",exports.default=T;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),N=require("../../../common/cn.js"),C=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=_(n);const T=s.forwardRef((({resubmitPrompt:_,onFocus:T,onBlur:A,onInputHeightChange:R,initSmitheryAuthData:P},q)=>{var D,L,U;const{origin:M,pickaxeId:$,sessionId:B,sender:F,senderType:H,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:V,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,onGenerateComplete:ie}=i.usePickaxeContext(),{token:oe,isLoggedOut:re,isSent:ae,isPricingAuth:le}=d.useAuthContext(),{messages:ce,isGenerating:de,setMessages:ue,setStatus:fe,setLimitData:pe,setError:me}=o.useResponseContext(),{documents:he,isUploading:ge,documentError:ve,onFileUpload:be,setDocuments:xe,setDocumentError:ye}=u.useDocument(),{studio:je}=I.useStudio(),{scrollStartSession:we,scrollEndSession:Oe,scrollToBottom:ke}=f.useScroll({auto:!0}),{artifacts:Se,currentPopupType:Ne,setArtifacts:Ce,setCurrentArtifact:Ie}=p.useArtifactContext(),{height:_e}=c.useDimensionContext(),Ee=l.useConversation(),[Te,Ae]=s.useState(""),[Re,Pe]=s.useState(!1),[qe,De]=s.useState(!1),[Le,Ue]=s.useState(null),[Me,$e]=s.useState(null),[Be,Fe]=s.useState(!1),He=s.useRef(null),Xe=s.useRef(""),Ke=s.useRef(null),We=s.useRef(null),Je=s.useRef(null),Ve=s.useRef(null),ze=s.useRef(null),Ge=Math.max(.4*_e,100),{transcript:Qe,listening:Ye,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=n.useSpeechRecognition(),[tt]=h.useMediaQuery("(max-width: 480px)"),st=m.useHover(),{isHover:nt}=st,it=e.__rest(st,["isHover"]),ot=m.useHover(),{isHover:rt}=ot,at=e.__rest(ot,["isHover"]),lt=m.useHover(),{isHover:ct}=lt,dt=e.__rest(lt,["isHover"]),ut=a.useStyleFontSize(),ft=r.useStyleInput(),pt="undefined"!=typeof window?window.location.hostname:"",mt="undefined"!=typeof window?window.location.href:"",ht="undefined"!=typeof window&&window.self!==window.top,gt=pt.includes("pickaxe.co")&&!mt.includes("https://studio.pickaxe.co/_embed")&&!ht,vt=null===(D=null==J?void 0:J.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),bt=et&&(null==J?void 0:J.enablevoicetotext),xt="chat-input"===W&&Y&&!ae,yt="chat-input"===W&&le&&re&&ae,jt=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",wt=Re||qe,Ot=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==J?void 0:J.studioid},F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),gt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ue(t.studioUser),$e(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,B,H,F,oe,X,K,gt]);s.useEffect((()=>{Ot()}),[Ot]);const kt=(null==te?void 0:te.limit)||0,St=(null==Le?void 0:Le.currentUses)||0,Nt=(null==Le?void 0:Le.extraUses)||0,Ct=!!(null==je?void 0:je.data.usage)&&je.data.usage.isCredits,It=kt>St?kt-St+Nt:Nt,_t=s.useMemo((()=>!!Le&&(!Be&&(!(kt<=0)&&It<=.05*kt))),[Le,Be,It,kt]),Et=s.useMemo((()=>{var e,t,s;return!!Y&&(!!J&&(!Ee.isLoading&&(!((null!==(t=null===(e=Ee.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!xt)))))}),[J,Y,ee,xt,Ee.data,Ee.isLoading]),Tt=s.useMemo((()=>{if(de||ge)return!1;const e=he.length>0&&he.every((e=>"finished"===e.status));return!(!Te.trim()&&!e)&&he.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[de,ge,Te,he]);s.useImperativeHandle(q,(()=>({onSubmit:At}))),s.useEffect((()=>{ne(Et)}),[Et]),s.useEffect((()=>{var e;if(_){const t=Array.from(ce),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;At(s,!0)}}),[_]),s.useEffect((()=>{if(!Ve.current||!R)return;const e=new ResizeObserver((e=>{for(const t of e)R(t.contentRect.height)}));return e.observe(Ve.current),()=>{e.disconnect()}}),[R]),s.useEffect((()=>{if(!Ye)return;const e=Xe.current?`${Xe.current} `:"";Ae(`${e}${Qe}`)}),[Qe,Ye]),s.useEffect((()=>{if(!We.current)return;(()=>{if(!We.current)return;let e=We.current.scrollHeight>52;Te.includes("\n")||he.length?e=!0:Te.trim()||(e=!1),Pe(e)})()}),[Te,he]),s.useEffect((()=>{const e=We.current,t=Je.current;if(!e||!t||Re||Te.includes("\n"))return void De(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Te||jt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;De(o>l)}),[Te,Re,jt]);const At=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(de||ge)return;const o=he.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:Te;if(!c&&!l)return;me(""),ye(""),pe(null),Ae(""),se(!1),fe("fetching"),we(),ke();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ce.slice(0,ce.length-1)):Array.from(ce),...s?[]:[{id:ce.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ce.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ue(u),ke(),d&&xe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:B,senderType:H,value:c},d&&{documentIds:r}),F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),gt&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;fe("streaming"),ze.current=new AbortController;const h=u.length-1,g=[];let b=[...null!=Se?Se:[]],x=0,y=!1,j="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${x}`,{signal:null===(i=ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return me(t),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&P){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,P({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,P({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ue([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:ce.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce([...b]),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ce(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ce(b.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);me(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ie||ie(B)}catch(e){if(e.limitData)pe(e.limitData),me("");else{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."),me(t)}}finally{ke(),fe("idle"),Oe(),Ke.current=null,yield Ot()}}));return yt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!xt&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ve,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===V.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ft),{maxHeight:`${Ge}px`,overflowY:"auto"})},{children:[_t&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:ft.backgroundColor?`${ft.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:V.cornerRadius+"px",borderTopLeftRadius:V.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[It," ",Ct?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Me}${null==te?void 0:te.accessGroupId}`;C.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Fe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!de&&he.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:de}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ye&&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!==(U=z.accent)&&void 0!==U?U:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:We,className:N.default(ut.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Te.trim()&&!Te.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",wt&&"mb-12",Ye&&"text-transparent"),value:Te,placeholder:jt,onChange:e=>{if(Ae(e),R){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void R(0);if(t>=11)return;let s=0;t>1&&(s=50),R(24*(t-1)+s)}},onKeyDown:e=>{Q||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ge||de||At()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield be(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Je,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",wt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!wt&&ft.backgroundColor&&{backgroundColor:ft.backgroundColor}),{borderTopRightRadius:V.cornerRadius+"px",borderBottomRightRadius:V.cornerRadius+"px"})},{children:de?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:()=>{ze.current&&(ze.current.abort(),ze.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),fe("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Ye?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.default.stopListening,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[vt&&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:rt?z.accent+"10":void 0,color:rt?z.accent:z.accent+"80"},disabled:ge||de,onClick:()=>{var e;return null===(e=He.current)||void 0===e?void 0:e.click()}},at,{children:[t.jsx("input",{id:"file-upload",ref:He,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield be(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),bt&&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:Ye?z.accent:ct?z.accent+"10":void 0,color:Ye?z.accentText:ct?z.accent:z.accent+"80"},disabled:ge||de,onClick:()=>{Ye?E.default.stopListening():(Xe.current=Te,Ze(),E.default.startListening({continuous:!0,interimResults:!0,language:G||"en-US"}))}},dt,{children:t.jsx(y.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:nt||Tt?z.accent:z.accent+"10",color:nt||Tt?z.accentText:z.accent+"80"},disabled:!Tt,onClick:()=>At()},it,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),ve&&t.jsx(k.default,{error:ve,className:"mt-3"})]}))}))}));T.displayName="Input",exports.default=T;
@@ -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"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("../../../Icons/check.svg.js"),a=require("./Dropdown.js"),c=require("../../../../common/cn.js");exports.default=({field:l,update:o})=>{const{colors:u,isRtl:d,translations:p}=t.usePickaxeContext(),{setError:x}=i.useResponseContext(),j=n.useStyleFontSize(),m=s.useRef(null),f=s.useMemo((()=>l.example.split("S3P32X")),[l.example]),b=s.useMemo((()=>l.input?l.input.split("&#44;"):[]),[l.input]),[h,g]=s.useState((()=>{const e=f.includes(l.input);return l.allowOther&&l.input&&!e?l.input:""}));return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3",dir:d?"rtl":"ltr"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:c.default(j.b3,"font-semibold opacity-70")},{children:l.main})),l.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:u.error}},{children:"*"}))]})),e.jsx(a.default,Object.assign({id:l.id.replace(/[^A-Za-z]+/g,""),value:l.input.replace(/&#44;/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:l.maxLength,isDropdown:l.isDropdown},{children:e.jsxs("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[f.map(((s,t)=>e.jsxs("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{x("");const s=b.includes(e),t=l.input?l.input.split("&#44;"):[],i=new Set(t);s&&i.has(e)?i.delete(e):s||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));o(Object.assign(Object.assign({},l),{input:n.join("&#44;")}))})(s)},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:b.includes(s)?u.accent:u.accent+"80"},b.includes(s)&&{backgroundColor:u.accent})},{children:e.jsx(r.default,{className:c.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",b.includes(s)&&"opacity-100"),style:{color:u.accentText}})})),e.jsx("p",Object.assign({className:c.default(j.b2,"select-none")},{children:s}))]}),t))),l.allowOther&&e.jsxs("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{x("");const e=b.includes(h.trim()),s=l.input?l.input.split("&#44;"):[],t=Array.from(new Set(s)).filter((e=>""!==e.trim()&&f.includes(e)));e||t.push(h.trim()),o(Object.assign(Object.assign({},l),{input:t.join("&#44;")})),setTimeout((()=>{var e;return null===(e=m.current)||void 0===e?void 0:e.focus()}),0)}},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:b.includes(h)?u.accent:u.accent+"80"},b.includes(h)&&{backgroundColor:u.accent})},{children:e.jsx(r.default,{className:c.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",b.includes(h)&&"opacity-100"),style:{color:u.accentText}})})),e.jsxs("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e.jsxs("p",Object.assign({className:c.default(j.b2,"select-none opacity-80 min-w-fit")},{children:[(null==p?void 0:p.other)||"Other",":"]})),e.jsx("input",{ref:m,type:"text",className:c.default(j.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:b.includes(h)?u.accent:"rgba(0,0,0,0.2)"},value:h,onChange:e=>(e=>{x(""),g(e);const s=b.includes(e.trim()),t=l.input?l.input.split("&#44;"):[],i=new Set(t.filter((e=>f.includes(e))));s?i.delete(e.trim()):i.add(e.trim());const n=Array.from(i).filter((e=>""!==e.trim()));o(Object.assign(Object.assign({},l),{input:n.join("&#44;")}))})(e.target.value),placeholder:"Type your answer..."})]}))]}))]}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("../../../Icons/check.svg.js"),c=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:o,update:l})=>{const{colors:d,isRtl:u}=t.usePickaxeContext(),{setError:p}=i.useResponseContext(),x=n.useStyleFontSize(),j=s.useMemo((()=>o.input?o.input.split("&#44;"):[]),[o.input]);return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3",dir:u?"rtl":"ltr"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:a.default(x.b3,"font-semibold opacity-70")},{children:o.main})),o.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:d.error}},{children:"*"}))]})),e.jsx(c.default,Object.assign({id:o.id.replace(/[^A-Za-z]+/g,""),value:o.input.replace(/&#44;/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:o.maxLength,isDropdown:o.isDropdown},{children:e.jsx("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:o.example.split("S3P32X").map(((s,t)=>e.jsxs("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{p("");const s=j.includes(e),t=o.input?o.input.split("&#44;"):[],i=new Set(t);s&&i.has(e)?i.delete(e):s||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));l(Object.assign(Object.assign({},o),{input:n.join("&#44;")}))})(s)},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:j.includes(s)?d.accent:d.accent+"80"},j.includes(s)&&{backgroundColor:d.accent})},{children:e.jsx(r.default,{className:a.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",j.includes(s)&&"opacity-100"),style:{color:d.accentText}})})),e.jsx("p",Object.assign({className:a.default(x.b2,"select-none")},{children:s}))]}),t)))}))}))]}))};
@@ -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"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:j,senderType:y,portalId:O,deploymentId:w,pickaxe:C,misc:S,translations:I,isRtl:k,setSessionId:_,setIsNewChat:P,onGenerateComplete:q}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{isGenerating:N,setResponse:E,setMessages:T,setStatus:D,setLimitData:U,setError:L,setIsSwitchedToChat:R}=o.useResponseContext(),{documents:J,websiteLink:B,isUploading:K,onWebsiteUpload:W,setDocuments:X,setDocumentError:V}=r.useDocument(),{scrollStartSession:M,scrollEndSession:$,scrollToTarget:F}=a.useScroll({auto:!(null==C?void 0:C.enablechatresponses)}),{artifacts:G,currentPopupType:z,setArtifacts:Q,setCurrentArtifact:Y}=l.useArtifactContext(),[H,Z]=s.useState(!1),ee=s.useRef(null),te=s.useMemo((()=>f.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||N||H,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(N||K||H)return;L(""),V(""),U(null),E(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=J.filter((e=>"finished"===e.status)),o=J.map((e=>e.name)),r=null!==(t=null===(e=null==C?void 0:C.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(B).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];Z(!0);const t=yield W(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Z(!1)}else if(a&&r&&!i.length)return void V("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),D("fetching"),M(),F();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:y,valueObj:g},m&&{documentIds:p}),j&&{sender:j}),A&&{studioSessionToken:A}),!A&&!j&&{sender:d.initializeEmbedUserId()}),O&&{portalId:O}),w&&{deploymentId:w}))}),v=yield h.json();if(!v.success){const e=new Error(v.error||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}const S=v.submissionId,I=v.sessionId,k={sessionId:I,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};E(k),(null==C?void 0:C.enablechatresponses)&&(_(I),P(!1),R(!0),T([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&X([]),D("streaming"),ee.current=new AbortController;const $=[];let te=[...null!=G?G:[]],se=0,ne=!1,ie="";for(;!ne;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${S}?index=${se}`,{signal:null===(s=ee.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&se++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return L(t),void(ne=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ie="",$.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("text-end"===n.type)ie="";else if("reasoning-start"===n.type)ie="",$.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("reasoning-end"===n.type)ie="";else if(n.type.startsWith("data-")){const e=n;$.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[...$]})});E(i),(null==C?void 0:C.enablechatresponses)&&T([{id:0,role:"assistant",parts:[...$],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");te=te.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Q([...te])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Q(te.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else ne=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}ne||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(ne=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==q||q(I)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),L(t),F()}finally{D("idle"),Z(!1),$()}}))},{children:H?(null==I?void 0:I.processing)||"Processing...":K?(null==I?void 0:I.uploading)||"Uploading...":N?(null==I?void 0:I.loading)||"Loading...":null!==(v=null==C?void 0:C.submittext)&&void 0!==v?v:"Submit"})),te&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||N||H,onClick:h},{children:(null==I?void 0:I["clear-form"])||"Clear form"}))]})),!S.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
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"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:j,senderType:y,portalId:O,deploymentId:w,pickaxe:C,misc:S,translations:k,isRtl:I,setSessionId:_,setIsNewChat:P,onGenerateComplete:A}=n.usePickaxeContext(),{token:N}=i.useAuthContext(),{isGenerating:q,setResponse:E,setMessages:T,setStatus:U,setLimitData:D,setError:L,setIsSwitchedToChat:R}=o.useResponseContext(),{documents:J,websiteLink:B,isUploading:K,onWebsiteUpload:W,setDocuments:X,setDocumentError:V}=r.useDocument(),{scrollStartSession:M,scrollEndSession:$,scrollToTarget:F}=a.useScroll({auto:!(null==C?void 0:C.enablechatresponses)}),{artifacts:G,currentPopupType:z,setArtifacts:Q,setCurrentArtifact:Y}=l.useArtifactContext(),[H,Z]=s.useState(!1),ee=s.useRef(null),te=s.useMemo((()=>f.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:I?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||q||H,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(q||K||H)return;L(""),V(""),D(null),E(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=J.filter((e=>"finished"===e.status)),o=J.map((e=>e.name)),r=null!==(t=null===(e=null==C?void 0:C.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(B).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];Z(!0);const t=yield W(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Z(!1)}else if(a&&r&&!i.length)return void V("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),U("fetching"),M(),F();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:y,valueObj:g},m&&{documentIds:p}),j&&{sender:j}),N&&{studioSessionToken:N}),!N&&!j&&{sender:d.initializeEmbedUserId()}),O&&{portalId:O}),w&&{deploymentId:w}))}),v=yield h.json();if(!v.success){const e=new Error(v.error||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}const S=v.submissionId,k=v.sessionId,I={sessionId:k,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};E(I),(null==C?void 0:C.enablechatresponses)&&(_(k),P(!1),R(!0),T([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&X([]),U("streaming"),ee.current=new AbortController;const $=[];let te=[...null!=G?G:[]],se=0,ne=!1,ie="";for(;!ne;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${S}?index=${se}`,{signal:null===(s=ee.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&se++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return L(t),void(ne=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ie="",$.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("text-end"===n.type)ie="";else if("reasoning-start"===n.type)ie="",$.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("reasoning-end"===n.type)ie="";else if(n.type.startsWith("data-")){const e=n;$.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},I),{question:Object.assign(Object.assign({},I.question),{responseParts:[...$]})});E(i),(null==C?void 0:C.enablechatresponses)&&T([{id:0,role:"assistant",parts:[...$],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");te=te.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Q([...te])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Q(te.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else ne=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}ne||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(ne=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==A||A(k)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),L(t),F()}finally{U("idle"),Z(!1),$()}}))},{children:H?(null==k?void 0:k.processing)||"Processing...":K?(null==k?void 0:k.uploading)||"Uploading...":q?(null==k?void 0:k.loading)||"Loading...":null!==(v=null==C?void 0:C.submittext)&&void 0!==v?v:"Submit"})),te&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||q||H,onClick:h},{children:(null==k?void 0:k["clear-form"])||"Clear form"}))]})),!S.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
@@ -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"),i=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),n=require("./ResponseProvider.js"),r=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:y,portalId:h,deploymentType:m,deploymentDimensions:S,deploymentMisc:b,styles:v,colors:g,limits:x={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:j,artifact:P={popupType:"auto"},responsiveBy:w="viewport",locale:F="en",opacity:k=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:A=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:E=!1,isDropShadow:H=!1,allowGuestUsage:M=!0,preventInitialSessionId:R=!1,onGenerateComplete:_,onSessionIdChange:G})=>{const[L,B]=s.useState(""),[N,U]=s.useState(""),[W,z]=s.useState(""),[J,V]=s.useState(""),[Y,K]=s.useState(p),[Q,X]=s.useState(null),[Z,$]=s.useState(f),[ee,te]=s.useState("loading"),[se,ie]=s.useState(null),[oe,ne]=s.useState(null),[re,ae]=s.useState(null),[le,de]=s.useState(!1),[ce,ue]=s.useState(!0),[pe,fe]=s.useState(!0),[ye,he]=s.useState(!1);return s.useEffect((()=>{de(!1)}),[null==v?void 0:v.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!le&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{de(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),de(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),de(!0)}}))}),[T,le,null==v?void 0:v.font]),s.useEffect((()=>{K(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:L,pickaxeId:N,sessionId:W,lastSessionId:J,sender:Y,senderType:Z,portalId:h,deploymentId:y,deploymentType:m,validationStatus:ee,deploymentDimensions:S,deploymentMisc:b,accessGroup:Q,pickaxe:re,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},g),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},j),artifact:P,responsiveBy:w,locale:F,opacity:k,forceMobile:C,loadFont:T,disableHtml:O,disableJs:A,disableCss:D,isFontLoaded:le,isNewChat:ce,isShowIceBreaker:pe,isShowFeedbackMessage:ye,isRtl:q,isEmbed:E,isDropShadow:H,allowGuestUsage:M,clientSecret:oe,stripeAccountId:se,preventInitialSessionId:R,setClientSecret:ne,setStripeAccountId:ie,setContextId:B,setValidationStatus:te,setPickaxeId:U,setSessionId:e=>{z((t=>{const s="function"==typeof e?e(t):e;return null==G||G(s),s}))},setLastSessionId:V,setSender:K,setSenderType:$,setAccessGroup:X,setPickaxe:ae,setIsFontLoaded:de,setIsNewChat:ue,setIsShowIceBreaker:fe,setIsShowFeedbackMessage:he},_&&{onGenerateComplete:_})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(n.default,Object.assign({limits:x},{children:t.jsx(r.default,{children:t.jsx(i.ArtifactProvider,Object.assign({},P,{children:c}))})}))})})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:S,styles:g,colors:v,limits:x={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:I="en",opacity:k=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:A=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:E=!1,isDropShadow:H=!1,allowGuestUsage:M=!0,onGenerateComplete:R})=>{const[_,G]=s.useState(""),[L,B]=s.useState(""),[N,U]=s.useState(""),[W,z]=s.useState(""),[J,V]=s.useState(p),[Y,K]=s.useState(null),[Q,X]=s.useState(f),[Z,$]=s.useState("loading"),[ee,te]=s.useState(null),[se,ie]=s.useState(null),[oe,re]=s.useState(null),[ne,ae]=s.useState(!1),[le,de]=s.useState(!0),[ce,ue]=s.useState(!0),[pe,fe]=s.useState(!1);return s.useEffect((()=>{ae(!1)}),[null==g?void 0:g.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!ne&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[g.font]},active:()=>{ae(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ae(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ae(!0)}}))}),[T,ne,null==g?void 0:g.font]),s.useEffect((()=>{V(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:_,pickaxeId:L,sessionId:N,lastSessionId:W,sender:J,senderType:Q,portalId:y,deploymentId:h,deploymentType:m,validationStatus:Z,deploymentDimensions:b,deploymentMisc:S,accessGroup:Y,pickaxe:oe,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},P),artifact:w,responsiveBy:F,locale:I,opacity:k,forceMobile:C,loadFont:T,disableHtml:O,disableJs:A,disableCss:D,isFontLoaded:ne,isNewChat:le,isShowIceBreaker:ce,isShowFeedbackMessage:pe,isRtl:q,isEmbed:E,isDropShadow:H,allowGuestUsage:M,clientSecret:se,stripeAccountId:ee,setClientSecret:ie,setStripeAccountId:te,setContextId:G,setValidationStatus:$,setPickaxeId:B,setSessionId:U,setLastSessionId:z,setSender:V,setSenderType:X,setAccessGroup:K,setPickaxe:re,setIsFontLoaded:ae,setIsNewChat:de,setIsShowIceBreaker:ue,setIsShowFeedbackMessage:fe},R&&{onGenerateComplete:R})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:x},{children:t.jsx(n.default,{children:t.jsx(i.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),o=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),v=require("../Icons/lock.svg.js"),b=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),k=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const y=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:w,className:N})=>{const{sessionId:q,styles:_,colors:O,responsiveBy:C,deploymentType:A,isNewChat:S,isEmbed:I,opacity:P,deploymentId:E,sender:L,portalId:R,validationStatus:T,stripeAccountId:D,clientSecret:G,preventInitialSessionId:M,setClientSecret:U,setStripeAccountId:B,setValidationStatus:F,setContextId:$,setPickaxeId:W,setSessionId:z,setPickaxe:H,setAccessGroup:J}=i.usePickaxeContext(),{isSent:K,token:V}=r.useAuthContext(),{setMessages:X,setResponse:Y,setError:Q,setLimitData:Z,setIsSwitchedToChat:ee}=l.useResponseContext(),{setDocumentError:se}=o.useDocumentContext(),{setCurrentArtifact:te}=c.useArtifactContext(),[ae,ie]=a.useState(!1),[re,le]=a.useState([]),[oe,ce]=a.useState(null),ne=t.usePickaxe(),de="chat-input"===A&&S&&!K,ue=a.useMemo((()=>D?k.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:D}):null),[D]);a.useEffect((()=>{W(w)}),[w]);a.useEffect((()=>{if(!E&&!R||!ne.data)return;if("stripe_checkout"===T)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;F("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:E,sender:L||void 0,studioSessionToken:V,portalId:R,studioId:null===(e=ne.data)||void 0===e?void 0:e.studioid}});s.data.success?(F("success"),J(s.data.accessGroup)):"Login required."===s.data.message?(F("login_required"),ie(!0)):"Access denied."===s.data.message?(F("access_denied"),le(s.data.upgradeGroups||[]),ie(!0)):"Upgrade required."===s.data.message?(F("upgrade_required"),le(s.data.upgradeGroups||[]),ce(s.data.upgradeUrl),ie(!0)):F("login_required")}catch(e){console.error("Failed to validate deployment:",e),F("success")}}))}),[E,L,V,R,ne.data]),a.useEffect((()=>{if(!ne.data)return;const e=ne.data.chatflag;M||z(e?n.v4():""),$(n.v4()),e?X([]):Y(null),Q(""),se(""),Z(null),te(null),ee(!1),H(ne.data),ie(!0)}),[ne.data]),a.useEffect((()=>{Q(""),se(""),Z(null),X([]),Y(null),te(null)}),[q]);const xe=a.useMemo((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${s}`}),[O.primary,P]);if(!ne.data)return null;return s.jsx("div",Object.assign({className:f.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===_.theme&&"dark",N),style:Object.assign({backgroundColor:de?"transparent":xe,color:O.text},_.font&&"Real Head Pro"!==_.font&&{fontFamily:_.font})},{children:"stripe_checkout"===T&&G&&ue?s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:O.secondary||"#ffffff",color:O.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{U&&U(null),B&&B(null),F("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:O.text}},{children:[s.jsx(y,{className:"w-5 h-5"}),s.jsx("span",{children:"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(b.EmbeddedCheckoutProvider,Object.assign({stripe:ue,options:{clientSecret:G}},{children:s.jsx(b.EmbeddedCheckout,{})}))}))]})):ne.isLoading||!ae||"loading"===T?s.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===C?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:f.default("w-full min-h-[48px]","viewport"===C?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===T?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:re&&re.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:re.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:oe},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===T&&I?s.jsx(p.default,{}):"login_required"!==T||I?"access_denied"===T?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(g.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(g.AvatarImage,{src:null===(me=ne.data)||void 0===me?void 0:me.coverphoto,alt:`${null===(pe=ne.data)||void 0===pe?void 0:pe.formtitle} Logo`}),s.jsx(g.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(v.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:O.accent,color:O.accentText,borderRadius:_.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=re.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:L||void 0,studioSessionToken:V,studioId:null===(e=ne.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=ne.data)||void 0===s?void 0:s.formid,deploymentId:E,accessGroupIds:t})}});a.data.success?alert("Successfully requested access!"):alert(a.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):q?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var me,pe};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),r=require("../../hooks/pickaxe/usePickaxeContext.js"),i=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),v=require("../Icons/lock.svg.js"),b=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),k=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const y=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:w,className:N})=>{const{sessionId:q,styles:_,colors:O,responsiveBy:C,deploymentType:A,isNewChat:S,isEmbed:I,opacity:P,deploymentId:E,sender:L,portalId:R,validationStatus:T,stripeAccountId:D,clientSecret:G,setClientSecret:M,setStripeAccountId:U,setValidationStatus:B,setContextId:F,setPickaxeId:$,setSessionId:W,setPickaxe:z,setAccessGroup:H}=r.usePickaxeContext(),{isSent:J,token:K}=i.useAuthContext(),{setMessages:V,setResponse:X,setError:Y,setLimitData:Q,setIsSwitchedToChat:Z}=l.useResponseContext(),{setDocumentError:ee}=c.useDocumentContext(),{setCurrentArtifact:se}=o.useArtifactContext(),[te,ae]=a.useState(!1),[re,ie]=a.useState([]),[le,ce]=a.useState(null),oe=t.usePickaxe(),ne="chat-input"===A&&S&&!J,de=a.useMemo((()=>D?k.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:D}):null),[D]);a.useEffect((()=>{$(w)}),[w]);a.useEffect((()=>{if(!E&&!R||!oe.data)return;if("stripe_checkout"===T)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;B("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:E,sender:L||void 0,studioSessionToken:K,portalId:R,studioId:null===(e=oe.data)||void 0===e?void 0:e.studioid}});s.data.success?(B("success"),H(s.data.accessGroup)):"Login required."===s.data.message?(B("login_required"),ae(!0)):"Access denied."===s.data.message?(B("access_denied"),ie(s.data.upgradeGroups||[]),ae(!0)):"Upgrade required."===s.data.message?(B("upgrade_required"),ie(s.data.upgradeGroups||[]),ce(s.data.upgradeUrl),ae(!0)):B("login_required")}catch(e){console.error("Failed to validate deployment:",e),B("success")}}))}),[E,L,K,R,oe.data]),a.useEffect((()=>{if(!oe.data)return;const e=oe.data.chatflag;W(e?n.v4():""),F(n.v4()),e?V([]):X(null),Y(""),ee(""),Q(null),se(null),Z(!1),z(oe.data),ae(!0)}),[oe.data]),a.useEffect((()=>{Y(""),ee(""),Q(null),V([]),X(null),se(null)}),[q]);const ue=a.useMemo((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${s}`}),[O.primary,P]);if(!oe.data)return null;return s.jsx("div",Object.assign({className:f.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===_.theme&&"dark",N),style:Object.assign({backgroundColor:ne?"transparent":ue,color:O.text},_.font&&"Real Head Pro"!==_.font&&{fontFamily:_.font})},{children:"stripe_checkout"===T&&G&&de?s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:O.secondary||"#ffffff",color:O.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{M&&M(null),U&&U(null),B("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:O.text}},{children:[s.jsx(y,{className:"w-5 h-5"}),s.jsx("span",{children:"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(b.EmbeddedCheckoutProvider,Object.assign({stripe:de,options:{clientSecret:G}},{children:s.jsx(b.EmbeddedCheckout,{})}))}))]})):oe.isLoading||!te||"loading"===T?s.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===C?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:f.default("w-full min-h-[48px]","viewport"===C?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===T?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:re&&re.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:re.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:le},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===T&&I?s.jsx(p.default,{}):"login_required"!==T||I?"access_denied"===T?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(g.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(g.AvatarImage,{src:null===(xe=oe.data)||void 0===xe?void 0:xe.coverphoto,alt:`${null===(me=oe.data)||void 0===me?void 0:me.formtitle} Logo`}),s.jsx(g.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(v.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:O.accent,color:O.accentText,borderRadius:_.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=re.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:L||void 0,studioSessionToken:K,studioId:null===(e=oe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=oe.data)||void 0===s?void 0:s.formid,deploymentId:E,accessGroupIds:t})}});a.data.success?alert("Successfully requested access!"):alert(a.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):q?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var xe,me};
@@ -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};