@pickaxeproject/react 6.18.0 → 6.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/chatMessages.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/cjs/hooks/pickaxe/useTextToSpeech.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/src/common/chatMessages.d.ts +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -1
- package/dist/esm/common/chatMessages.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/esm/hooks/pickaxe/useTextToSpeech.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/src/common/chatMessages.d.ts +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(e){return String(t)}},e=e=>{if(!e||"object"!=typeof e)return null;const r=e;return"string"!=typeof r.type?null:{type:r.type,content:t(r.content),isVisible:!1!==r.isVisible}},r=(t,r)=>{let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(e){return String(t)}},e=e=>{if(!e||"object"!=typeof e)return null;const r=e;return"string"!=typeof r.type?null:{type:r.type,content:t(r.content),isVisible:!1!==r.isVisible}},r=(t,r)=>{let n=t;if("string"==typeof n)try{const t=JSON.parse(n);Array.isArray(t)&&(n=t)}catch(t){}if(Array.isArray(n))return n.map(e).filter((t=>null!==t));const s=e(n);if(s)return[s];const i="string"==typeof n?n:r;return"string"==typeof i&&i?[{type:"text",content:i,isVisible:!0}]:[]},n=t=>{var e,n;const s=r(t.parts).filter((t=>!1!==t.isVisible)),i=s.filter((t=>"text"===t.type)).map((t=>{var e;return null!==(e=t.content)&&void 0!==e?e:""})).join(""),o=i.replace(/\s+/g," ").replace(/\s*([.,!?;:])\s*/g,"$1").trim();return o?JSON.stringify({role:t.role,text:o,documentIds:null!==(e=t.documentIds)&&void 0!==e?e:[]}):JSON.stringify({role:t.role,documentIds:null!==(n=t.documentIds)&&void 0!==n?n:[],parts:s.map((t=>{var e;return{type:t.type,content:null!==(e=t.content)&&void 0!==e?e:""}}))})};exports.mergeConversationMessages=(t,e)=>{if(!t.length)return e;if(!e.length)return t;const r=e.map(n),s=t.map(n),i=((t,e)=>{const r=Array.from({length:t.length+1},(()=>Array(e.length+1).fill(0)));for(let n=t.length-1;n>=0;n-=1)for(let s=e.length-1;s>=0;s-=1)r[n][s]=t[n]===e[s]?r[n+1][s+1]+1:Math.max(r[n+1][s],r[n][s+1]);return r})(r,s),o=[];let l=0,a=0;for(;l<e.length&&a<t.length;){const n=i[l][a];if(r[l]===s[a]){if(i[l+1][a]===n){o.push(e[l]),l+=1;continue}if(i[l][a+1]===n){o.push(t[a]),a+=1;continue}o.push(e[l]),l+=1,a+=1}else i[l+1][a]>=i[l][a+1]?(o.push(e[l]),l+=1):(o.push(t[a]),a+=1)}return[...o,...e.slice(l),...t.slice(a)]},exports.normalizeHistoryMessages=t=>Array.isArray(t)?t.flatMap((t=>{var e;if(!t||"object"!=typeof t)return[];const n=t;return"user"!==n.role&&"assistant"!==n.role?[]:[Object.assign(Object.assign({},n),{documentIds:Array.isArray(n.documentIds)?n.documentIds.filter((t=>"string"==typeof t)):[],parts:r(n.parts,null!==(e=n.content)&&void 0!==e?e:n.message)})]})):[],exports.normalizeMessageParts=r;
|
|
@@ -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/studio/useStyleFontSize.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Artifact/hooks/useArtifact.js"),o=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeIcon.js"),n=require("./Document.js"),d=require("../../common/PickaxeMessageActions.js"),c=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),
|
|
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/studio/useStyleFontSize.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Artifact/hooks/useArtifact.js"),o=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeIcon.js"),n=require("./Document.js"),d=require("../../common/PickaxeMessageActions.js"),c=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),m=require("../../../../common/isoMap.js"),x=require("franc-min"),p=require("../../common/ComposioConnectView.js"),f=require("../../common/SmitheryConnectView.js"),j=require("../../../../hooks/pickaxe/useTextToSpeech.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(require("remove-markdown"));exports.default=({index:g,message:b,smitheryData:v,resubmitPrompt:k,isLastMessage:y=!1})=>{var w,O;const{pickaxeId:N,pickaxe:q,styles:C,colors:I,misc:P,responsiveBy:A,disableHtml:S,disableJs:R,disableCss:M,isNewChat:T,isRtl:L}=t.usePickaxeContext(),{isGenerating:F}=a.useResponseContext(),{onLoadArtifact:H}=r.useArtifact(),J=i.useStyleFontSize(),V=null!==(w=null==q?void 0:q.chaticon)&&void 0!==w?w:`https://cdn.mail.studio/chaticons/${N}.png`,z=y&&F,B=null==q?void 0:q.enablereadout,{isLoading:D,isSpeaking:_,speak:E,stop:G}=j.useTextToSpeech(B&&"assistant"===b.role,{provider:null==q?void 0:q.readoutprovider,pickaxeId:N,voiceName:null==q?void 0:q.readoutvoice}),U=()=>{if(D||_)return void G();const e=b.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=h.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=x.franc(s),i=m.convertToIso1(t);E(s,i)},$=!b.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:u.default("flex flex-col w-full",0===g&&T&&"viewport"===A&&"min-[767px]:max-w-[80%]",0===g&&T&&"container"===A&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:u.default("flex gap-x-3",L&&"flex-row-reverse")},{children:[P.isChatImage&&"NONE"!==V&&e.jsx(l.default,{src:V,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:I.text}),e.jsxs("div",Object.assign({className:u.default("flex flex-col flex-grow",L?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:u.default(J.b2,"chat-message pt-3 w-full",L?"text-right":"text-left")},{children:[e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I,isStreaming:z},L&&{rtl:!0},S&&{disableHtml:!0},R&&{disableJs:!0},M&&{disableCss:!0},{disableReasoning:null!==(O=null==q?void 0:q.enablereasoningdisplay)&&void 0!==O&&O,onArtifactClick:H},{children:e.jsx(c.default,{parts:b.parts,isStreaming:z})})),y&&v&&k&&("composio"===v.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(p.default,{serverId:v.serverId,toolkitSlug:v.toolkitSlug||"",name:v.name,resubmitPrompt:()=>k()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(f.default,{serverId:v.serverId,smitheryId:v.smitheryId||"",name:v.name||v.smitheryId,resubmitPrompt:()=>k()})})))]})),e.jsx("div",Object.assign({className:u.default("flex flex-col gap-6 my-4",$&&"mt-2")},{children:z?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:I.secondaryText}},t)))})):e.jsx(d.default,Object.assign({content:b.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:g},"intromessage"===b.area&&{isHideFeedback:!0},{onReadOut:U,isReadOut:B||!1,isReadOutLoading:D,isReading:_}))}))]}))]}))}))})):"user"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:u.default("flex gap-x-3 max-w-[80%]",L?"pr-9":"pl-9","viewport"===A?L?"min-[767px]:pr-0":"min-[767px]:pl-0":L?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:u.default(J.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",L?"text-right":"text-left"),style:{backgroundColor:I.secondary+"80",color:I.secondaryText,borderRadius:C.cornerRadius}},{children:[b.documentIds&&b.documentIds.length>0&&e.jsx("div",Object.assign({className:u.default("flex flex-col gap-y-2",L?"items-start":"items-end")},{children:b.documentIds.map((t=>e.jsx(s.Fragment,{children:e.jsx(n.default,{documentId:t})},t)))})),e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I},L&&{rtl:!0},S&&{disableHtml:!0},R&&{disableJs:!0},M&&{disableCss:!0},{children:e.jsx(c.default,{parts:b.parts})}))]}))}))})):e.jsx("div",{})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),o=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),h=require("../../common/PickaxeEmbedHead.js"),j=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),v=require("../../Addons/Scroll/ScrollLockView.js"),b=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js"),O=require("../../../../common/chatMessages.js"),q=require("../../Addons/Auth/VerificationCodeForm.js");exports.default=({additionalScrollHeight:A,smitheryAuthData:S,isForceHideInfo:P,isInputFocused:I,onSubmit:L,resubmitPrompt:M})=>{var H,R,D,F,B;const{sessionId:E,deploymentType:T,pickaxe:z,translations:W,misc:$,isNewChat:_,isRtl:V,isEmbed:U,isShowIceBreaker:G,setSessionId:J,setLastSessionId:K}=i.usePickaxeContext(),{emailInput:Q,isLoggedOut:X,isSending:Y,isResendDisabled:Z,isSent:ee,isPricingAuth:se}=a.useAuthContext(),{onSend:ie}=t.useAuth(),{scrollContainerRef:ae,isLocked:te}=o.useScrollContext(),{messages:le,limitData:ne,error:oe}=l.useResponseContext(),{height:re,width:ce}=n.useDimensionContext(),{currentArtifact:de,chatPopupType:ue,currentPopupType:xe}=d.useArtifactContext(),me=c.useConversation(),fe=r.useStyleFontSize(),he=s.useMemo((()=>(null==z?void 0:z.icebreakers)?z.icebreakers.slice(0,3):[]),[null==z?void 0:z.icebreakers]),je=s.useMemo((()=>{const e=!!me.data&&me.data.messages.length>1;return!P&&me.isSuccess&&_&&!e}),[P,me.isSuccess,_,me.data]),ge=s.useMemo((()=>!(null==z?void 0:z.chatflag)&&(null==z?void 0:z.enablechatresponses)&&le.length>0),[z,le]),pe=s.useMemo((()=>!!me.data&&me.data.messages.some((e=>"intromessage"===e.area))),[me.data]),ve="chat-input"===T&&se&&X&&ee,be=G&&!I&&!pe&&je&&ce>767,ye=G&&!I&&(pe||ce<=767),ke=s.useMemo((()=>{var e,s;const i=null!==(s=null===(e=me.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return O.mergeConversationMessages(le,i)}),[null===(H=me.data)||void 0===H?void 0:H.messages,le]),we=()=>{K(E),J("")};return s.useLayoutEffect((()=>{if(!te)return;const e=ae.current;e&&(e.scrollTop=e.scrollHeight)}),[A,null===(R=me.data)||void 0===R?void 0:R.messages.length,te,ae,ke.length]),e.jsxs("div",Object.assign({ref:ae,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4 [overflow-anchor:none]"},{children:[e.jsx(u.AnimatePresence,{children:!!de&&"inline"===xe&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",ue),style:{height:`calc(${re-A}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(b.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[je&&U&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===T&&"right-12")},{children:e.jsx(p.default,{tip:(null==W?void 0:W["chat-history"])||"Chat History",onClick:we})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",je&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),U&&!me.isLoading&&e.jsx(h.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!je&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==W?void 0:W["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",U&&!me.isLoading&&!je&&"mt-0")},{children:[be&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===he.length&&"grid-cols-2",1===he.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:he,onSend:L})})),ve?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:Q}))]}))})),e.jsxs(k.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(D=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==D?D:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Z||Y||ie(!0)}},{children:Y?null!==(F=null==W?void 0:W.resending)&&void 0!==F?F:"Resending...":null!==(B=null==W?void 0:W.resend)&&void 0!==B?B:"Resend"}))]})),e.jsx(q.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:me.isLoading&&!(null==z?void 0:z.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):me.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(fe.b2,"text-center font-semibold")},{children:[(null==W?void 0:W["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==W?void 0:W["contact-us"])||"contact us"}))," ",(null==W?void 0:W["for-help"])||"for help."]}))})):me.data||ge?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[ke.map(((s,i)=>e.jsx(y.default,{smitheryData:S,resubmitPrompt:M,index:i,message:s,isLastMessage:i===ke.length-1},`message-${i}`))),ne?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(j.default,{})})):oe?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",V?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:oe})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!$.isWhiteLabel||ye&&"mt-4")},{children:[!$.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",ye&&"mb-2")}),ye&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:he,onSend:L})})),e.jsx(v.default,{})]}))]})):null})]}))]}))]}))};
|
|
@@ -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("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=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"),f=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/message-clock.svg.js"),I=require("../../Icons/stop.svg.js"),j=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),S=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),N=require("../../Core/ErrorAlert.js"),k=require("../../Core/Menu/index.js"),_=require("../../Core/Menu/Button.js"),E=require("../../Core/Menu/List.js"),C=require("../../../common/error.js"),T=require("../../../common/chatMessages.js"),U=require("../../../common/api/pickaxe.js"),A=require("../../../common/validation.js"),D=require("../../../common/cn.js"),P=require("../../../common/utils.js"),L=require("../../../common/pickaxeConfig.js"),q=require("../../../common/agentPrefill.js"),R=require("../../../common/deploymentWebhooks.js"),M=require("../../../hooks/studio/useStudio.js"),F=require("../../../hooks/pickaxe/useSpeechToText.js"),V=require("../common/PickaxeCommon.js");const $=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},B=e=>"string"==typeof e&&e.trim().length>0,X=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,K=e=>e.map((e=>Object.assign({},e))),H=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),W=(e,t)=>{if(e&&"object"==typeof e)return e[t]},z=(e,t)=>{const s=W(e,t);return B(s)?s:null},G=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Y=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(W(e,"uses"))?W(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>B(e)?{type:"deployment",id:e}:B(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},J=s.forwardRef((({resubmitPrompt:W,onFocus:J,onBlur:Q,onInputHeightChange:Z,initSmitheryAuthData:ee},te)=>{var se,ne,ie,re,oe,ae,le,de,ce,ue,pe,me,ge,fe,ve,he,be;const{origin:xe,pickaxeId:ye,sessionId:Ie,sender:je,senderType:we,portalId:Se,deploymentId:Oe,deploymentType:Ne,pickaxe:ke,styles:_e,colors:Ee,translations:Ce,locale:Te,forceMobile:Ue,isNewChat:Ae,isRtl:De,isEmbed:Pe,isShowFeedbackMessage:Le,accessGroup:qe,setIsNewChat:Re,setIsShowIceBreaker:Me,setValidationStatus:Fe,setValidationUpgradeGroups:Ve,setValidationUpgradeUrl:$e,setAccessGroup:Be,onUpgrade:Xe,onGenerateComplete:Ke}=n.usePickaxeContext(),{token:He,isLoggedOut:We,isSent:ze,isPricingAuth:Ge}=d.useAuthContext(),{messages:Ye,isGenerating:Je,setMessages:Qe,setStatus:Ze,setLimitData:et,setError:tt}=i.useResponseContext(),{documents:st,isUploading:nt,documentError:it,onFileUpload:rt,setDocuments:ot,setDocumentError:at}=c.useDocument(),{studio:lt}=M.useStudio(),[dt]=g.useMediaQuery("(max-width: 480px)"),{scrollStartSession:ct,scrollEndSession:ut,scrollToBottom:pt}=u.useScroll({auto:!0,smooth:!(Ue||dt)}),{artifacts:mt,currentPopupType:gt,setArtifacts:ft,setCurrentArtifact:vt}=p.useArtifactContext(),{height:ht}=l.useDimensionContext(),bt=a.useConversation(),[xt,yt]=s.useState((()=>q.readAgentPrefill([Oe,ye]).chatInput)),[It,jt]=s.useState(!1),[wt,St]=s.useState(!1),[Ot,Nt]=s.useState(!1),[kt,_t]=s.useState([]),[Et,Ct]=s.useState(!1),[Tt,Ut]=s.useState(null),[At,Dt]=s.useState(null),[Pt,Lt]=s.useState(null),[qt,Rt]=s.useState(null),[Mt,Ft]=s.useState(!1),[Vt,$t]=s.useState(!1),[Bt,Xt]=s.useState(0),Kt=s.useRef(null),Ht=s.useRef(""),Wt=s.useRef(null),zt=s.useRef(null),Gt=s.useRef(null),Yt=s.useRef([]),Jt=s.useRef(null),Qt=s.useRef(null),Zt=s.useRef(null),es=s.useRef(null),ts=s.useRef(new Set),ss=s.useRef(null),ns=Math.max(.4*ht,100),{speechTranscript:is,isSpeechListening:rs,isSpeechProcessing:os,isSpeechSupported:as,onStartListening:ls,onStopListening:ds}=F.useSpeechToText(),cs=m.useHover(),{isHover:us}=cs,ps=e.__rest(cs,["isHover"]),ms=m.useHover(),{isHover:gs}=ms,fs=e.__rest(ms,["isHover"]),vs=m.useHover(),{isHover:hs}=vs,bs=e.__rest(vs,["isHover"]),xs=o.useStyleFontSize(),ys=r.useStyleInput(),Is="undefined"!=typeof window?window.location.hostname:"",js="undefined"!=typeof window?window.location.href:"",ws="undefined"!=typeof window&&window.self!==window.top,Ss=Is.includes("pickaxe.co")&&!js.includes("https://studio.pickaxe.co/_embed")&&!ws,Os=null!==(ne=null===(se=null==ke?void 0:ke.documentuploadtype)||void 0===se?void 0:se.startsWith("enduserupload"))&&void 0!==ne&&ne,Ns=as&&(null==ke?void 0:ke.enablevoicetotext),ks=rs&&!xt.trim(),_s=B(Oe),Es="chat-input"===Ne&&Ae&&!ze,Cs="chat-input"===Ne&&Ge&&We&&ze,Ts=s.useCallback((e=>{const t=A.getValidationFailure(e);return!!t&&(tt(""),et(null),Fe(t.status),Be(t.accessGroup),Ve(t.upgradeGroups),$e(t.upgradeUrl),!0)}),[tt,et,Fe,Ve,$e,Be]),Us=null!==(ie=null==ke?void 0:ke.placeholdertext)&&void 0!==ie?ie:De?"بماذا تريد أن تتحدث؟":(null==Ce?void 0:Ce["what-do-you-want-to-talk-about"])||"What do you want to talk about?",As=It||wt,Ds=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Ft(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==ke?void 0:ke.studioid},He?{studioSessionToken:He}:je?{sender:je}:{sender:P.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}})),Ss&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Lt(t.studioUser),Rt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Ft(!0)}}))),[Ss,null==ke?void 0:ke.studioid,je,He]);s.useEffect((()=>{Ds()}),[Ds]);const Ps=Number(null!==(re=null==qe?void 0:qe.limit)&&void 0!==re?re:0),Ls="string"==typeof(null==qe?void 0:qe.limitInterval)?qe.limitInterval:null,qs=!!(null==lt?void 0:lt.data.usage)&<.data.usage.isCredits,Rs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=Se?Se:z(Pt,"portalId"))&&void 0!==e?e:z(Pt,"portalid"))&&void 0!==t?t:z(qe,"portalId"))&&void 0!==s?s:z(qe,"portalid"))&&void 0!==n?n:z(ke,"portalId"))&&void 0!==i?i:z(ke,"portalid")}),[qe,Se,ke,Pt]),Ms=s.useMemo((()=>Y({studioUser:Pt,deploymentId:Oe,portalId:Rs})),[Oe,Rs,Pt]);s.useEffect((()=>{_s&&Ae&&Ie&&ts.current.add(Ie)}),[Ae,Ie,_s]);const Fs=s.useCallback((()=>{var e,t,s;return{studioId:null==ke?void 0:ke.studioid,userEmail:z(Pt,"email"),userId:null!==(e=z(Pt,"userId"))&&void 0!==e?e:z(Pt,"userid"),sessionId:Ie,deploymentId:Oe,deploymentType:Ne,portalId:Rs,accessGroupId:null!==(t=null==qe?void 0:qe.accessGroupId)&&void 0!==t?t:null,pickaxeId:ye,sender:je,senderType:we,origin:xe,metadata:null!==(s=L.getPickaxeConfigMetadata(Oe))&&void 0!==s?s:null}}),[null==qe?void 0:qe.accessGroupId,Oe,Ne,xe,null==ke?void 0:ke.studioid,ye,Rs,je,we,Ie,Pt]),Vs=s.useCallback((()=>!!(_s&&Mt&&Ie)&&(!!ts.current.has(Ie)&&(R.fireDeploymentSessionInitializedWebhook(Fs()),ts.current.delete(Ie),!0))),[Fs,Mt,Ie,_s]);s.useEffect((()=>{if(!Mt||!Ie)return;Vs();const e=ss.current;(null==e?void 0:e.sessionId)===Ie&&(R.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Fs()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),ss.current=null)}),[Vs,Fs,Mt,Ie]);const $s={currentUses:G(null==Pt?void 0:Pt.currentUses),extraUses:G(null==Pt?void 0:Pt.extraUses)},Bs=Ms.scope?{currentUses:null!==(ae=G(null===(oe=Ms.record)||void 0===oe?void 0:oe.currentUses))&&void 0!==ae?ae:0,extraUses:null!==(de=G(null===(le=Ms.record)||void 0===le?void 0:le.extraUses))&&void 0!==de?de:0}:{currentUses:0,extraUses:0},Xs=z(Pt,"type"),Ks="guest"===Xs||!Xs&&We?Bs:$s;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(qs&&(null===(e=null==lt?void 0:lt.data)||void 0===e?void 0:e.workspaceId))try{const e=yield U.pickaxeApi2.get(`/cost_per_run?workspaceId=${lt.data.workspaceId}`,{withCredentials:!1});t&&Xt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Xt(0)}else t&&Xt(0)})),()=>{t=!1}}),[qs,null===(ce=null==lt?void 0:lt.data)||void 0===ce?void 0:ce.workspaceId]);const Hs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===V.STUDIO_INFINITY_VALUE||r===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:Ks.currentUses,extraUses:Ks.extraUses,limit:Ps,limitInterval:Ls}),Ws=Hs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(Hs)),zs=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===V.STUDIO_INFINITY_VALUE||n===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:Ks.extraUses,limit:Ps,limitInterval:Ls}),Gs=zs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.ceil(.05*zs),Ys=qs?Math.ceil(5*Bt):5,Js=Gs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(Gs,Ys),Qs=s.useMemo((()=>!!Pt&&(!Vt&&(Ws!==V.STUDIO_INFINITY_VALUE&&Ws<=Js))),[Vt,Js,Ws,Pt]),Zs=Boolean(null==qe?void 0:qe.hideUpgradeOptions),en=Boolean(!Zs&&((null===(ue=null==qe?void 0:qe.upgrade)||void 0===ue?void 0:ue.isBuyMoreUses)||(null===(pe=null==qe?void 0:qe.upgrade)||void 0===pe?void 0:pe.isLinkToCustomURL)||(null===(me=null==qe?void 0:qe.upgrade)||void 0===me?void 0:me.isUpgradeToAnotherGroup)&&(null===(ge=qe.upgrade.accessGroupIds)||void 0===ge?void 0:ge.length))),tn=!Zs&&(null===(fe=null==qe?void 0:qe.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)&&"string"==typeof qe.upgrade.limitLink&&qe.upgrade.limitLink.trim().length>0?qe.upgrade.limitLink.trim():null,sn=tn&&"string"==typeof(null===(ve=null==qe?void 0:qe.upgrade)||void 0===ve?void 0:ve.limitCTA)&&qe.upgrade.limitCTA.trim().length>0?qe.upgrade.limitCTA:(null==Ce?void 0:Ce["pricing.upgrade"])||(null==Ce?void 0:Ce.upgrade)||"Upgrade",nn=s.useMemo((()=>{var e,t,s;return!!Ae&&(!!ke&&(!bt.isLoading&&(!((null!==(t=null===(e=bt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=ke.icebreakers)||void 0===s?void 0:s.length)&&(!Le&&!Es)))))}),[ke,Ae,Le,Es,bt.data,bt.isLoading]),rn=s.useMemo((()=>{if(nt||Ot)return!1;const e=Os&&st.length>0&&st.every((e=>"finished"===e.status));return!(!xt.trim()&&!e)&&st.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Os,nt,Ot,xt,st]);s.useImperativeHandle(te,(()=>({onSubmit:cn}))),s.useEffect((()=>{Me(nn)}),[nn]),s.useEffect((()=>{var e;if(W){const t=Array.from(Ye),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;cn(s,!0)}}),[W]),s.useEffect((()=>{if(!Zt.current||!Z)return;const e=new ResizeObserver((e=>{for(const t of e)Z(t.contentRect.height)}));return e.observe(Zt.current),()=>{e.disconnect()}}),[Z]),s.useEffect((()=>{if(!rs)return;const e=Ht.current?`${Ht.current} `:"";yt(`${e}${is}`)}),[is,rs]),s.useEffect((()=>{if(!Jt.current)return;(()=>{if(!Jt.current)return;let e=Jt.current.scrollHeight>52;xt.includes("\n")||st.length?e=!0:xt.trim()||(e=!1),jt(e)})()}),[xt,st]),s.useEffect((()=>{const e=Jt.current,t=Qt.current;if(!e||!t||It||xt.includes("\n"))return void St(!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=xt||Us,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;St(r>l)}),[xt,It,Us]);const on=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:zt.current))return!1;const e=K(Yt.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!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()}),body:JSON.stringify({outputMessageParts:e})},Ss&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),an=e=>{Gt.current=e,es.current&&(es.current.abort(),es.current=null),Wt.current&&(Wt.current.cancel().catch((()=>{})),Wt.current=null)},ln=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!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}))},Ss&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),dn=()=>{const e=zt.current;e&&!Ot&&!nt&&xt.trim()&&(_t((t=>{var s,n;return[...t,{id:X(),message:xt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),yt(""))},cn=(t,s=!1,n=!1,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,r,o,a,l,d;let c=null;try{if(Je&&!n||nt)return;const u=st.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),p=u.map((e=>e.documentId)).filter(Boolean),m=u.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:xt,f=null!==(r=null===(e=null==ke?void 0:ke.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==r&&r&&p.length>0;if(!g&&!f)return;tt(""),at(""),et(null),yt(""),Re(!1),Ze("fetching"),ct(),pt();const h=null!==(a=null===(o=bt.data)||void 0===o?void 0:o.messages)&&void 0!==a?a:[],b=T.getUnpersistedMemoryMessages(Ye,h),x=s?b.slice(0,b.length-1):b,y=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(x),I=y+(s?0:1),j={id:I,role:"assistant",parts:[],documentIds:[]},w=[...x,...s?[]:[{id:y,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:f?p:[]}],j];Qe(w),pt(),f&&ot([]);const S=L.getPickaxeConfigMetadata(Oe),O=null!=i?i:X();c=O,zt.current=O,Gt.current=null,Yt.current=[];const N=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:xe,pickaxeId:ye,sessionId:Ie,submissionId:O,senderType:we,value:g},f&&{documentIds:p}),je&&{sender:je}),He&&{studioSessionToken:He}),!He&&!je&&{sender:P.initializeEmbedUserId()}),Rs&&{portalId:Rs}),Oe&&{deploymentId:Oe}),S&&{metadata:S}),f&&m.length>0?{uploadedModelImages:m}:{})),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()})},Ss&&{credentials:"include"})),k=yield N.json();if(!k.success){if(k.limitData){const e=new Error(k.error||k.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=k.limitData,e}if(Ts(k))return;throw new Error(k.error||k.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation")}const _=null!==(l=k.submissionId)&&void 0!==l?l:O;c=_,zt.current=_;const E=()=>Gt.current===_;if(E())return;_s&&Ae&&Ie&&ts.current.add(Ie);const C=Object.assign(Object.assign({},Fs()),{message:g,documentIds:f?p:[],uploadedModelImages:f?m:[],hasUploadedDocuments:f,isHidden:s,metadata:null!=S?S:null});Mt?(Vs(),R.fireDeploymentFirstMessageSubmittedWebhook(C)):ss.current=C,Ze("streaming"),es.current=new AbortController;const U=[];let A=[...null!=mt?mt:[]],D=0,q=!1,M="";for(;!q;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${_}?index=${D}`,{signal:null===(d=es.current)||void 0===d?void 0:d.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Wt.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(E())q=!0;else if(e.event&&"ping"!==e.event&&D++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return et(t.limitData),tt(""),void(q=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong"])||"Something went wrong.";return Ts(t)||tt(s),void(q=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&ee){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){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 q=!0,ee({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\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 q=!0,ee({provider:"composio",toolkitSlug: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 q=!0,ee({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw q=!0,ee({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)M="",U.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)M+=n.delta,U[U.length-1].content=M;else if("text-end"===n.type)M="";else if("reasoning-start"===n.type)M="",U.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)M+=n.delta,U[U.length-1].content=M;else if("reasoning-end"===n.type)M="";else if(n.type.startsWith("data-")){const e=n;U.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Yt.current=K(U);const i=K(U);Qe((e=>{const t=e.findIndex((e=>e.id===I)),s=Object.assign(Object.assign({},j),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft([...A]),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ft(A),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft(A),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");A=A.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ft(A)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ft(A.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);if(t.limitData)return et(t.limitData),tt(""),void(q=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Ts(t))return void(q=!0);tt(s)}else"stop"===e.event&&(q=!0)}else q=!0}});for(;;){if(E()){q=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(E()){q=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}q||E()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||H(e)||E())return void(q=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Ke||Ke(Ie)}catch(e){if(H(e))return;if(e.limitData)et(e.limitData),tt("");else{let t=C.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==Ce?void 0:Ce["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Ts(t)||tt(t)}}finally{const e=!c||zt.current===c;pt(),e&&(Ze("idle"),ut(),Wt.current=null),c&&e&&(zt.current=null,Yt.current=[]),yield Ds()}}));return s.useEffect((()=>{if(Je||Ot||Et||0===kt.length)return;const t=kt[0];Ct(!0),Ut(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield ln(t.predecessorSubmissionId)))return void tt((null==Ce?void 0:Ce["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");_t((e=>e.filter((e=>e.id!==t.id)))),yield cn(t.message,!1,!0,t.id)}finally{Ct(!1),Ut(null)}}))}),[Je,Et,Ot,kt]),Cs?null:t.jsx("div",Object.assign({className:D.default("flex w-full flex-shrink-0 flex-col items-center",!Es&&"px-4 pb-8"),dir:De?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[kt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ee.text+"18",backgroundColor:null!==(he=ys.backgroundColor)&&void 0!==he?he:Ee.text+"08",color:Ee.text,borderTopLeftRadius:Math.max(_e.cornerRadius-4,12),borderTopRightRadius:Math.max(_e.cornerRadius-4,12)}},{children:kt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<kt.length-1?{borderBottom:`1px solid ${Ee.text}12`}:void 0},{children:[t.jsx(y.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),At===s.id||Tt===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),At===s.id?(null==Ce?void 0:Ce.steering)||"Steering...":(null==Ce?void 0:Ce.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:Ot||!Je,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=zt.current;if(!e||Ot)return;const s=kt.findIndex((e=>e.id===t.id));if(-1===s)return;Nt(!0),Dt(t.id),tt(""),an(e);let n=!1;try{if(!(yield on(e)))throw new Error((null==Ce?void 0:Ce["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield ln(e)))throw new Error((null==Ce?void 0:Ce["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");Ze("idle"),_t((e=>e.filter((e=>e.id!==t.id)))),n=!0,Nt(!1),Dt(null),yield cn(t.message,!1,!0,t.id)}catch(e){Ze("idle"),n&&_t((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),tt(C.default(e))}finally{Nt(!1),Dt(null)}}))})(s)},"aria-label":`${(null==Ce?void 0:Ce["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ce?void 0:Ce.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:Ot,onClick:()=>{return e=s.id,void _t((t=>$(t,e)));var e},"aria-label":`${(null==Ce?void 0:Ce["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(j.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(k.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(_.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ot,role:"button",tabIndex:Ot?-1:0,"aria-haspopup":"menu","aria-label":(null==Ce?void 0:Ce["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(E.default,Object.assign({role:"menu",align:De?"bottom-start":"bottom-end",positionStrategy:Pe?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=ys.backgroundColor)&&void 0!==i?i:Ee.primary,color:Ee.text,borderRadius:"12px"},border:`1px solid ${Ee.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{_t((t=>$(t,e.id))),yt(e.message),requestAnimationFrame((()=>{const t=Jt.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(w.default,{className:"h-4 w-4 shrink-0"}),(null==Ce?void 0:Ce["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:Zt,className:D.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===_e.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ys),{maxHeight:`${ns}px`,overflowY:"auto"})},{children:[Qs&&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:ys.backgroundColor?`${ys.backgroundColor}E6`:void 0,borderColor:Ee.text+"20",color:Ee.text,borderTopRightRadius:_e.cornerRadius+"px",borderTopLeftRadius:_e.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Ws.toLocaleString()," ",qs?(null==Ce?void 0:Ce.credits)||"Credits":(null==Ce?void 0:Ce.uses)||"Uses"," ",(null==Ce?void 0:Ce.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[en&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ee.accent,color:Ee.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),tn)return void window.open(tn,"_blank","noopener,noreferrer");if(Xe)return void Xe();const t=P.buildUpgradeUrl({baseUrl:qt,accessGroupId:null==qe?void 0:qe.accessGroupId});t&&P.openAuthenticatedPricingUrl({deploymentId:Oe,pricingUrl:t,studioId:null==ke?void 0:ke.studioid,studioSessionToken:He})}},{children:sn})),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:()=>$t(!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"})}))}))]}))]})),!Je&&st.length>0&&t.jsx(S.default,{className:"p-4 pb-0",isDisabled:Je}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[ks&&t.jsxs("div",Object.assign({className:D.default("pointer-events-none absolute top-1/2 z-10 flex -translate-y-1/2 select-none items-center gap-x-2",De?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(be=Ee.accent)&&void 0!==be?be:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ee.text+"90"}},{children:(null==Ce?void 0:Ce.listening)||"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Jt,className:D.default(xs.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!xt.trim()&&!xt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",De?"text-right":"text-left",As&&"mb-12"),value:xt,placeholder:ks?"":Us,onChange:e=>{yt(e)},onKeyDown:e=>{Ue||dt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),nt||Ot||(Je?dn():cn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Os)return;t.preventDefault(),Re(!1),yield rt(e)}}))},J&&{onFocus:J},Q&&{onBlur:Q},{dir:De?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Qt,className:D.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",As?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!As&&ys.backgroundColor&&{backgroundColor:ys.backgroundColor}),{borderTopRightRadius:_e.cornerRadius+"px",borderBottomRightRadius:_e.cornerRadius+"px"})},{children:Je?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ce?void 0:Ce["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=zt.current;e&&(an(e),on(e)),Ze("idle")},style:{backgroundColor:Ee.accent+"10",color:Ee.accent}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ce?void 0:Ce["queue-message"])||"Queue message",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",disabled:Ot||nt||!xt.trim(),onClick:dn,style:{backgroundColor:xt.trim()?Ee.accent:Ee.accent+"10",color:xt.trim()?Ee.accentText:Ee.accent+"80"}},{children:t.jsx(b.default,{className:D.default("h-6 w-6 shrink-0",De&&"scale-x-[-1] transform")})}))]}):rs?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:ds,style:{backgroundColor:Ee.accent,color:Ee.accentText}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Os&&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:gs?Ee.accent+"10":void 0,color:gs?Ee.accent:Ee.accent+"80"},disabled:nt||Je,onClick:()=>{var e;return null===(e=Kt.current)||void 0===e?void 0:e.click()}},fs,{children:[t.jsx("input",{id:"file-upload",ref:Kt,type:"file",accept:[...f.allowedFileMimeTypes,...f.allowedImageMimeTypes,...f.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Re(!1),yield rt(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Ns&&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:rs?Ee.accent:hs?Ee.accent+"10":void 0,color:rs?Ee.accentText:hs?Ee.accent:Ee.accent+"80"},disabled:nt||Je||os,onClick:()=>{rs?ds():(Ht.current=xt,ls(Te||"en-US"))}},bs,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:us||rn?Ee.accent:Ee.accent+"10",color:us||rn?Ee.accentText:Ee.accent+"80"},disabled:!rn,onClick:()=>cn()},ps,{children:t.jsx(b.default,{className:D.default("h-6 w-6 shrink-0",De&&"scale-x-[-1] transform")})}))]})}))]}))]})),it&&t.jsx(N.default,{error:it,className:"mt-3"})]}))}))}));J.displayName="Input",exports.default=J;
|
|
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("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/message-clock.svg.js"),I=require("../../Icons/stop.svg.js"),j=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),S=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),N=require("../../Core/ErrorAlert.js"),k=require("../../Core/Menu/index.js"),_=require("../../Core/Menu/Button.js"),E=require("../../Core/Menu/List.js"),C=require("../../../common/error.js"),T=require("../../../common/api/pickaxe.js"),U=require("../../../common/validation.js"),A=require("../../../common/cn.js"),D=require("../../../common/utils.js"),P=require("../../../common/pickaxeConfig.js"),L=require("../../../common/agentPrefill.js"),R=require("../../../common/deploymentWebhooks.js"),q=require("../../../hooks/studio/useStudio.js"),M=require("../../../hooks/pickaxe/useSpeechToText.js"),F=require("../common/PickaxeCommon.js");const V=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},$=e=>"string"==typeof e&&e.trim().length>0,B=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,X=e=>e.map((e=>Object.assign({},e))),K=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),H=(e,t)=>{if(e&&"object"==typeof e)return e[t]},W=(e,t)=>{const s=H(e,t);return $(s)?s:null},z=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},G=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(H(e,"uses"))?H(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>$(e)?{type:"deployment",id:e}:$(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},Y=s.forwardRef((({resubmitPrompt:H,onFocus:Y,onBlur:J,onInputHeightChange:Q,initSmitheryAuthData:Z},ee)=>{var te,se,ne,ie,re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he;const{origin:be,pickaxeId:xe,sessionId:ye,sender:Ie,senderType:je,portalId:we,deploymentId:Se,deploymentType:Oe,pickaxe:Ne,styles:ke,colors:_e,translations:Ee,locale:Ce,forceMobile:Te,isNewChat:Ue,isRtl:Ae,isEmbed:De,isShowFeedbackMessage:Pe,accessGroup:Le,setIsNewChat:Re,setIsShowIceBreaker:qe,setValidationStatus:Me,setValidationUpgradeGroups:Fe,setValidationUpgradeUrl:Ve,setAccessGroup:$e,onUpgrade:Be,onGenerateComplete:Xe}=n.usePickaxeContext(),{token:Ke,isLoggedOut:He,isSent:We,isPricingAuth:ze}=d.useAuthContext(),{messages:Ge,isGenerating:Ye,setMessages:Je,setStatus:Qe,setLimitData:Ze,setError:et}=i.useResponseContext(),{documents:tt,isUploading:st,documentError:nt,onFileUpload:it,setDocuments:rt,setDocumentError:ot}=c.useDocument(),{studio:at}=q.useStudio(),[lt]=f.useMediaQuery("(max-width: 480px)"),{scrollStartSession:dt,scrollEndSession:ct,scrollToBottom:ut}=u.useScroll({auto:!0,smooth:!(Te||lt)}),{artifacts:pt,currentPopupType:mt,setArtifacts:ft,setCurrentArtifact:gt}=p.useArtifactContext(),{height:vt}=l.useDimensionContext(),ht=a.useConversation(),[bt,xt]=s.useState((()=>L.readAgentPrefill([Se,xe]).chatInput)),[yt,It]=s.useState(!1),[jt,wt]=s.useState(!1),[St,Ot]=s.useState(!1),[Nt,kt]=s.useState([]),[_t,Et]=s.useState(!1),[Ct,Tt]=s.useState(null),[Ut,At]=s.useState(null),[Dt,Pt]=s.useState(null),[Lt,Rt]=s.useState(null),[qt,Mt]=s.useState(!1),[Ft,Vt]=s.useState(!1),[$t,Bt]=s.useState(0),Xt=s.useRef(null),Kt=s.useRef(""),Ht=s.useRef(null),Wt=s.useRef(null),zt=s.useRef(null),Gt=s.useRef([]),Yt=s.useRef(null),Jt=s.useRef(null),Qt=s.useRef(null),Zt=s.useRef(null),es=s.useRef(new Set),ts=s.useRef(null),ss=Math.max(.4*vt,100),{speechTranscript:ns,isSpeechListening:is,isSpeechProcessing:rs,isSpeechSupported:os,onStartListening:as,onStopListening:ls}=M.useSpeechToText(),ds=m.useHover(),{isHover:cs}=ds,us=e.__rest(ds,["isHover"]),ps=m.useHover(),{isHover:ms}=ps,fs=e.__rest(ps,["isHover"]),gs=m.useHover(),{isHover:vs}=gs,hs=e.__rest(gs,["isHover"]),bs=o.useStyleFontSize(),xs=r.useStyleInput(),ys="undefined"!=typeof window?window.location.hostname:"",Is="undefined"!=typeof window?window.location.href:"",js="undefined"!=typeof window&&window.self!==window.top,ws=ys.includes("pickaxe.co")&&!Is.includes("https://studio.pickaxe.co/_embed")&&!js,Ss=null!==(se=null===(te=null==Ne?void 0:Ne.documentuploadtype)||void 0===te?void 0:te.startsWith("enduserupload"))&&void 0!==se&&se,Os=os&&(null==Ne?void 0:Ne.enablevoicetotext),Ns=is&&!bt.trim(),ks=$(Se),_s="chat-input"===Oe&&Ue&&!We,Es="chat-input"===Oe&&ze&&He&&We,Cs=s.useCallback((e=>{const t=U.getValidationFailure(e);return!!t&&(et(""),Ze(null),Me(t.status),$e(t.accessGroup),Fe(t.upgradeGroups),Ve(t.upgradeUrl),!0)}),[et,Ze,Me,Fe,Ve,$e]),Ts=null!==(ne=null==Ne?void 0:Ne.placeholdertext)&&void 0!==ne?ne:Ae?"بماذا تريد أن تتحدث؟":(null==Ee?void 0:Ee["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Us=yt||jt,As=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Mt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==Ne?void 0:Ne.studioid},Ke?{studioSessionToken:Ke}:Ie?{sender:Ie}:{sender:D.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}})),ws&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Pt(t.studioUser),Rt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Mt(!0)}}))),[ws,null==Ne?void 0:Ne.studioid,Ie,Ke]);s.useEffect((()=>{As()}),[As]);const Ds=Number(null!==(ie=null==Le?void 0:Le.limit)&&void 0!==ie?ie:0),Ps="string"==typeof(null==Le?void 0:Le.limitInterval)?Le.limitInterval:null,Ls=!!(null==at?void 0:at.data.usage)&&at.data.usage.isCredits,Rs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=we?we:W(Dt,"portalId"))&&void 0!==e?e:W(Dt,"portalid"))&&void 0!==t?t:W(Le,"portalId"))&&void 0!==s?s:W(Le,"portalid"))&&void 0!==n?n:W(Ne,"portalId"))&&void 0!==i?i:W(Ne,"portalid")}),[Le,we,Ne,Dt]),qs=s.useMemo((()=>G({studioUser:Dt,deploymentId:Se,portalId:Rs})),[Se,Rs,Dt]);s.useEffect((()=>{ks&&Ue&&ye&&es.current.add(ye)}),[Ue,ye,ks]);const Ms=s.useCallback((()=>{var e,t,s;return{studioId:null==Ne?void 0:Ne.studioid,userEmail:W(Dt,"email"),userId:null!==(e=W(Dt,"userId"))&&void 0!==e?e:W(Dt,"userid"),sessionId:ye,deploymentId:Se,deploymentType:Oe,portalId:Rs,accessGroupId:null!==(t=null==Le?void 0:Le.accessGroupId)&&void 0!==t?t:null,pickaxeId:xe,sender:Ie,senderType:je,origin:be,metadata:null!==(s=P.getPickaxeConfigMetadata(Se))&&void 0!==s?s:null}}),[null==Le?void 0:Le.accessGroupId,Se,Oe,be,null==Ne?void 0:Ne.studioid,xe,Rs,Ie,je,ye,Dt]),Fs=s.useCallback((()=>!!(ks&&qt&&ye)&&(!!es.current.has(ye)&&(R.fireDeploymentSessionInitializedWebhook(Ms()),es.current.delete(ye),!0))),[Ms,qt,ye,ks]);s.useEffect((()=>{if(!qt||!ye)return;Fs();const e=ts.current;(null==e?void 0:e.sessionId)===ye&&(R.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ms()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),ts.current=null)}),[Fs,Ms,qt,ye]);const Vs={currentUses:z(null==Dt?void 0:Dt.currentUses),extraUses:z(null==Dt?void 0:Dt.extraUses)},$s=qs.scope?{currentUses:null!==(oe=z(null===(re=qs.record)||void 0===re?void 0:re.currentUses))&&void 0!==oe?oe:0,extraUses:null!==(le=z(null===(ae=qs.record)||void 0===ae?void 0:ae.extraUses))&&void 0!==le?le:0}:{currentUses:0,extraUses:0},Bs=W(Dt,"type"),Xs="guest"===Bs||!Bs&&He?$s:Vs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Ls&&(null===(e=null==at?void 0:at.data)||void 0===e?void 0:e.workspaceId))try{const e=yield T.pickaxeApi2.get(`/cost_per_run?workspaceId=${at.data.workspaceId}`,{withCredentials:!1});t&&Bt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Bt(0)}else t&&Bt(0)})),()=>{t=!1}}),[Ls,null===(de=null==at?void 0:at.data)||void 0===de?void 0:de.workspaceId]);const Ks=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===F.STUDIO_INFINITY_VALUE||r===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:Xs.currentUses,extraUses:Xs.extraUses,limit:Ds,limitInterval:Ps}),Hs=Ks===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(Ks)),Ws=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===F.STUDIO_INFINITY_VALUE||n===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:Xs.extraUses,limit:Ds,limitInterval:Ps}),zs=Ws===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.ceil(.05*Ws),Gs=Ls?Math.ceil(5*$t):5,Ys=zs===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.max(zs,Gs),Js=s.useMemo((()=>!!Dt&&(!Ft&&(Hs!==F.STUDIO_INFINITY_VALUE&&Hs<=Ys))),[Ft,Ys,Hs,Dt]),Qs=Boolean(null==Le?void 0:Le.hideUpgradeOptions),Zs=Boolean(!Qs&&((null===(ce=null==Le?void 0:Le.upgrade)||void 0===ce?void 0:ce.isBuyMoreUses)||(null===(ue=null==Le?void 0:Le.upgrade)||void 0===ue?void 0:ue.isLinkToCustomURL)||(null===(pe=null==Le?void 0:Le.upgrade)||void 0===pe?void 0:pe.isUpgradeToAnotherGroup)&&(null===(me=Le.upgrade.accessGroupIds)||void 0===me?void 0:me.length))),en=!Qs&&(null===(fe=null==Le?void 0:Le.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)&&"string"==typeof Le.upgrade.limitLink&&Le.upgrade.limitLink.trim().length>0?Le.upgrade.limitLink.trim():null,tn=en&&"string"==typeof(null===(ge=null==Le?void 0:Le.upgrade)||void 0===ge?void 0:ge.limitCTA)&&Le.upgrade.limitCTA.trim().length>0?Le.upgrade.limitCTA:(null==Ee?void 0:Ee["pricing.upgrade"])||(null==Ee?void 0:Ee.upgrade)||"Upgrade",sn=s.useMemo((()=>{var e,t,s;return!!Ue&&(!!Ne&&(!ht.isLoading&&(!((null!==(t=null===(e=ht.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Ne.icebreakers)||void 0===s?void 0:s.length)&&(!Pe&&!_s)))))}),[Ne,Ue,Pe,_s,ht.data,ht.isLoading]),nn=s.useMemo((()=>{if(st||St)return!1;const e=Ss&&tt.length>0&&tt.every((e=>"finished"===e.status));return!(!bt.trim()&&!e)&&tt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ss,st,St,bt,tt]);s.useImperativeHandle(ee,(()=>({onSubmit:dn}))),s.useEffect((()=>{qe(sn)}),[sn]),s.useEffect((()=>{var e;if(H){const t=Array.from(Ge),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;dn(s,!0)}}),[H]),s.useEffect((()=>{if(!Qt.current||!Q)return;const e=new ResizeObserver((e=>{for(const t of e)Q(t.contentRect.height)}));return e.observe(Qt.current),()=>{e.disconnect()}}),[Q]),s.useEffect((()=>{if(!is)return;const e=Kt.current?`${Kt.current} `:"";xt(`${e}${ns}`)}),[ns,is]),s.useEffect((()=>{if(!Yt.current)return;(()=>{if(!Yt.current)return;let e=Yt.current.scrollHeight>52;bt.includes("\n")||tt.length?e=!0:bt.trim()||(e=!1),It(e)})()}),[bt,tt]),s.useEffect((()=>{const e=Yt.current,t=Jt.current;if(!e||!t||yt||bt.includes("\n"))return void wt(!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=bt||Ts,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;wt(r>l)}),[bt,yt,Ts]);const rn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:Wt.current))return!1;const e=X(Gt.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!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()}),body:JSON.stringify({outputMessageParts:e})},ws&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),on=e=>{zt.current=e,Zt.current&&(Zt.current.abort(),Zt.current=null),Ht.current&&(Ht.current.cancel().catch((()=>{})),Ht.current=null)},an=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!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}))},ws&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),ln=()=>{const e=Wt.current;e&&!St&&!st&&bt.trim()&&(kt((t=>{var s,n;return[...t,{id:B(),message:bt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),xt(""))},dn=(t,s=!1,n=!1,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,r,o,a;let l=null;try{if(Ye&&!n||st)return;const d=tt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),c=d.map((e=>e.documentId)).filter(Boolean),u=d.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),p=null!=t?t:bt,m=null!==(r=null===(e=null==Ne?void 0:Ne.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==r&&r&&c.length>0;if(!p&&!m)return;et(""),ot(""),Ze(null),xt(""),Re(!1),Qe("fetching"),dt(),ut();const f=s?Ge.slice(0,Ge.length-1):Ge,g=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(f),h=g+(s?0:1),b={id:h,role:"assistant",parts:[],documentIds:[]},x=[...f,...s?[]:[{id:g,role:"user",parts:[{type:"text",content:p,isVisible:!0}],documentIds:m?c:[]}],b];Je(x),ut(),m&&rt([]);const y=P.getPickaxeConfigMetadata(Se),I=null!=i?i:B();l=I,Wt.current=I,zt.current=null,Gt.current=[];const j=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:be,pickaxeId:xe,sessionId:ye,submissionId:I,senderType:je,value:p},m&&{documentIds:c}),Ie&&{sender:Ie}),Ke&&{studioSessionToken:Ke}),!Ke&&!Ie&&{sender:D.initializeEmbedUserId()}),Rs&&{portalId:Rs}),Se&&{deploymentId:Se}),y&&{metadata:y}),m&&u.length>0?{uploadedModelImages:u}:{})),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()})},ws&&{credentials:"include"})),w=yield j.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==Ee?void 0:Ee["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Cs(w))return;throw new Error(w.error||w.message||(null==Ee?void 0:Ee["failed-to-start-generation"])||"Failed to start generation")}const S=null!==(o=w.submissionId)&&void 0!==o?o:I;l=S,Wt.current=S;const O=()=>zt.current===S;if(O())return;ks&&Ue&&ye&&es.current.add(ye);const N=Object.assign(Object.assign({},Ms()),{message:p,documentIds:m?c:[],uploadedModelImages:m?u:[],hasUploadedDocuments:m,isHidden:s,metadata:null!=y?y:null});qt?(Fs(),R.fireDeploymentFirstMessageSubmittedWebhook(N)):ts.current=N,Qe("streaming"),Zt.current=new AbortController;const k=[];let _=[...null!=pt?pt:[]],E=0,C=!1,T="";for(;!C;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${S}?index=${E}`,{signal:null===(a=Zt.current)||void 0===a?void 0:a.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ht.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(O())C=!0;else if(e.event&&"ping"!==e.event&&E++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Ze(t.limitData),et(""),void(C=!0);const s=t.error||t.message||(null==Ee?void 0:Ee["something-went-wrong"])||"Something went wrong.";return Cs(t)||et(s),void(C=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&Z){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){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 C=!0,Z({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\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 C=!0,Z({provider:"composio",toolkitSlug: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 C=!0,Z({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw C=!0,Z({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)T="",k.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)T+=n.delta,k[k.length-1].content=T;else if("text-end"===n.type)T="";else if("reasoning-start"===n.type)T="",k.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)T+=n.delta,k[k.length-1].content=T;else if("reasoning-end"===n.type)T="";else if(n.type.startsWith("data-")){const e=n;k.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Gt.current=X(k);const i=X(k);Je((e=>{const t=e.findIndex((e=>e.id===h)),s=Object.assign(Object.assign({},b),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft([..._]),mt.startsWith("inline")||gt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ft(_),mt.startsWith("inline")||gt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft(_),mt.startsWith("inline")||gt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");_=_.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ft(_)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ft(_.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);if(t.limitData)return Ze(t.limitData),et(""),void(C=!0);const s=t.error||t.message||(null==Ee?void 0:Ee["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Cs(t))return void(C=!0);et(s)}else"stop"===e.event&&(C=!0)}else C=!0}});for(;;){if(O()){C=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(O()){C=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}C||O()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||K(e)||O())return void(C=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Xe||Xe(ye)}catch(e){if(K(e))return;if(e.limitData)Ze(e.limitData),et("");else{let t=C.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==Ee?void 0:Ee["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Cs(t)||et(t)}}finally{const e=!l||Wt.current===l;ut(),e&&(Qe("idle"),ct(),Ht.current=null),l&&e&&(Wt.current=null,Gt.current=[]),yield As()}}));return s.useEffect((()=>{if(Ye||St||_t||0===Nt.length)return;const t=Nt[0];Et(!0),Tt(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield an(t.predecessorSubmissionId)))return void et((null==Ee?void 0:Ee["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");kt((e=>e.filter((e=>e.id!==t.id)))),yield dn(t.message,!1,!0,t.id)}finally{Et(!1),Tt(null)}}))}),[Ye,_t,St,Nt]),Es?null:t.jsx("div",Object.assign({className:A.default("flex w-full flex-shrink-0 flex-col items-center",!_s&&"px-4 pb-8"),dir:Ae?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Nt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:_e.text+"18",backgroundColor:null!==(ve=xs.backgroundColor)&&void 0!==ve?ve:_e.text+"08",color:_e.text,borderTopLeftRadius:Math.max(ke.cornerRadius-4,12),borderTopRightRadius:Math.max(ke.cornerRadius-4,12)}},{children:Nt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<Nt.length-1?{borderBottom:`1px solid ${_e.text}12`}:void 0},{children:[t.jsx(y.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),Ut===s.id||Ct===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),Ut===s.id?(null==Ee?void 0:Ee.steering)||"Steering...":(null==Ee?void 0:Ee.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:St||!Ye,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=Wt.current;if(!e||St)return;const s=Nt.findIndex((e=>e.id===t.id));if(-1===s)return;Ot(!0),At(t.id),et(""),on(e);let n=!1;try{if(!(yield rn(e)))throw new Error((null==Ee?void 0:Ee["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield an(e)))throw new Error((null==Ee?void 0:Ee["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");Qe("idle"),kt((e=>e.filter((e=>e.id!==t.id)))),n=!0,Ot(!1),At(null),yield dn(t.message,!1,!0,t.id)}catch(e){Qe("idle"),n&&kt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),et(C.default(e))}finally{Ot(!1),At(null)}}))})(s)},"aria-label":`${(null==Ee?void 0:Ee["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ee?void 0:Ee.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:St,onClick:()=>{return e=s.id,void kt((t=>V(t,e)));var e},"aria-label":`${(null==Ee?void 0:Ee["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(j.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(k.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(_.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:St,role:"button",tabIndex:St?-1:0,"aria-haspopup":"menu","aria-label":(null==Ee?void 0:Ee["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(E.default,Object.assign({role:"menu",align:Ae?"bottom-start":"bottom-end",positionStrategy:De?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=xs.backgroundColor)&&void 0!==i?i:_e.primary,color:_e.text,borderRadius:"12px"},border:`1px solid ${_e.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{kt((t=>V(t,e.id))),xt(e.message),requestAnimationFrame((()=>{const t=Yt.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(w.default,{className:"h-4 w-4 shrink-0"}),(null==Ee?void 0:Ee["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:Qt,className:A.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ke.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},xs),{maxHeight:`${ss}px`,overflowY:"auto"})},{children:[Js&&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:xs.backgroundColor?`${xs.backgroundColor}E6`:void 0,borderColor:_e.text+"20",color:_e.text,borderTopRightRadius:ke.cornerRadius+"px",borderTopLeftRadius:ke.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Hs.toLocaleString()," ",Ls?(null==Ee?void 0:Ee.credits)||"Credits":(null==Ee?void 0:Ee.uses)||"Uses"," ",(null==Ee?void 0:Ee.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[Zs&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:_e.accent,color:_e.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),en)return void window.open(en,"_blank","noopener,noreferrer");if(Be)return void Be();const t=D.buildUpgradeUrl({baseUrl:Lt,accessGroupId:null==Le?void 0:Le.accessGroupId});t&&D.openAuthenticatedPricingUrl({deploymentId:Se,pricingUrl:t,studioId:null==Ne?void 0:Ne.studioid,studioSessionToken:Ke})}},{children:tn})),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:()=>Vt(!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"})}))}))]}))]})),!Ye&&tt.length>0&&t.jsx(S.default,{className:"p-4 pb-0",isDisabled:Ye}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ns&&t.jsxs("div",Object.assign({className:A.default("pointer-events-none absolute top-1/2 z-10 flex -translate-y-1/2 select-none items-center gap-x-2",Ae?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(he=_e.accent)&&void 0!==he?he:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:_e.text+"90"}},{children:(null==Ee?void 0:Ee.listening)||"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Yt,className:A.default(bs.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!bt.trim()&&!bt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Ae?"text-right":"text-left",Us&&"mb-12"),value:bt,placeholder:Ns?"":Ts,onChange:e=>{xt(e)},onKeyDown:e=>{Te||lt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),st||St||(Ye?ln():dn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Ss)return;t.preventDefault(),Re(!1),yield it(e)}}))},Y&&{onFocus:Y},J&&{onBlur:J},{dir:Ae?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Jt,className:A.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",Us?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Us&&xs.backgroundColor&&{backgroundColor:xs.backgroundColor}),{borderTopRightRadius:ke.cornerRadius+"px",borderBottomRightRadius:ke.cornerRadius+"px"})},{children:Ye?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ee?void 0:Ee["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=Wt.current;e&&(on(e),rn(e)),Qe("idle")},style:{backgroundColor:_e.accent+"10",color:_e.accent}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ee?void 0:Ee["queue-message"])||"Queue message",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",disabled:St||st||!bt.trim(),onClick:ln,style:{backgroundColor:bt.trim()?_e.accent:_e.accent+"10",color:bt.trim()?_e.accentText:_e.accent+"80"}},{children:t.jsx(b.default,{className:A.default("h-6 w-6 shrink-0",Ae&&"scale-x-[-1] transform")})}))]}):is?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:ls,style:{backgroundColor:_e.accent,color:_e.accentText}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ss&&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:ms?_e.accent+"10":void 0,color:ms?_e.accent:_e.accent+"80"},disabled:st||Ye,onClick:()=>{var e;return null===(e=Xt.current)||void 0===e?void 0:e.click()}},fs,{children:[t.jsx("input",{id:"file-upload",ref:Xt,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*(){Re(!1),yield it(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Os&&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:is?_e.accent:vs?_e.accent+"10":void 0,color:is?_e.accentText:vs?_e.accent:_e.accent+"80"},disabled:st||Ye||rs,onClick:()=>{is?ls():(Kt.current=bt,as(Ce||"en-US"))}},hs,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:cs||nn?_e.accent:_e.accent+"10",color:cs||nn?_e.accentText:_e.accent+"80"},disabled:!nn,onClick:()=>dn()},us,{children:t.jsx(b.default,{className:A.default("h-6 w-6 shrink-0",Ae&&"scale-x-[-1] transform")})}))]})}))]}))]})),nt&&t.jsx(N.default,{error:nt,className:"mt-3"})]}))}))}));Y.displayName="Input",exports.default=Y;
|
|
@@ -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"),
|
|
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"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,g,v;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:S,isRtl:A,setSessionId:I,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=i.useResponseContext(),{scrollTargetRef:R}=n.useScrollContext(),{setDocuments:T}=l.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=o.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w,isStreaming:M},A&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},S&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[],isStreaming:M})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?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:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{content:(null!==(v=null===(g=D.question)||void 0===g?void 0:g.responseParts)&&void 0!==v?v:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void I(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../common/TextShimmer.js");exports.ActionCaption=({node:o,children:s})=>{const{theme:i,actionState:c}=r.usePickaxeMarkdownContext(),d=t.useMemo((()=>{if(!o||!o.properties)return"processing";const e=o.properties.dataIndex;return e?c[e]:"processing"}),[c]),u=t.useMemo((()=>{try{if("undefined"==typeof window||"undefined"==typeof document)return!1;if(!document.documentElement)return!1;return""!==getComputedStyle(document.documentElement).getPropertyValue("--tw-ring-color")}catch(e){return!1}}),[]),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../common/TextShimmer.js");exports.ActionCaption=({node:o,children:s})=>{const{theme:i,actionState:c,isStreaming:a}=r.usePickaxeMarkdownContext(),d=t.useMemo((()=>{if(!o||!o.properties)return"processing";const e=o.properties.dataIndex;return e?c[e]:"processing"}),[c]),u=t.useMemo((()=>{try{if("undefined"==typeof window||"undefined"==typeof document)return!1;if(!document.documentElement)return!1;return""!==getComputedStyle(document.documentElement).getPropertyValue("--tw-ring-color")}catch(e){return!1}}),[]),p=t.useMemo((()=>"string"==typeof s?s:(null==s?void 0:s.toString())||"Processing..."),[s]),x=!a||"done"===d||"error"===d;return e.jsx(n.default,Object.assign({theme:i,isDisabled:x||!u},!x&&!u&&{className:"pxe-blink"},{children:p}))},exports.ActionError=({node:n,children:o})=>{const{setActionState:s}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&s((t=>Object.assign(Object.assign({},t),{[e]:"error"})))}),[]),e.jsx("div",Object.assign({className:"pxe-red pxe-action-error"},{children:o}))},exports.ActionFinished=({node:n})=>{const{setActionState:o}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&o((t=>Object.assign(Object.assign({},t),{[e]:"done"})))}),[]),e.jsx("div",{})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,colors:l={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},readOnly:i=!1,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,colors:l={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},readOnly:i=!1,isStreaming:s=!1,rtl:d=!1,disableHtml:F=!1,disableJs:m=!1,disableCss:p=!1,disableReasoning:g=!1,onArtifactClick:C})=>{const[b,u]=o.useState(n),[h,y]=o.useState({});return e.jsx(t.Provider,Object.assign({value:Object.assign(Object.assign({theme:b,colors:l,styles:c,actionState:h,isStreaming:s,readOnly:i,rtl:d,disableHtml:F,disableJs:m,disableCss:p,disableReasoning:g,setTheme:u,setActionState:y},!!C&&{onArtifactClick:C}),{syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}})},{children:r}))};exports.PickaxeMarkdown=r,exports.PickaxeMarkdownContext=t,exports.default=r;
|
package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./TextShimmer.js");exports.default=({caption:s,isLoading:r,isVisible:a})=>{const{colors:o,translations:n}=i.usePickaxeContext();return a?e.jsx(t.default,Object.assign({theme:"#000000"===o.text?"light":"dark",isDisabled:!r},{children:s||((null==n?void 0:n.loading)||"Loading...")})):null};
|
package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../ActionToolCaptionPart/TextShimmer.js");exports.default=({caption:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../ActionToolCaptionPart/TextShimmer.js");exports.default=({caption:s,isLoading:r,isVisible:o})=>{const{colors:a,translations:n}=t.usePickaxeContext();return o?e.jsx(i.default,Object.assign({theme:"#000000"===a.text?"light":"dark",isDisabled:!r},{children:s||((null==n?void 0:n.loading)||"Loading...")})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),s=require("../PickaxeMarkdown/Components/A/FilePreview.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),s=require("../PickaxeMarkdown/Components/A/FilePreview.js"),i=require("../../../../common/utils.js"),t=require("../../../../common/cn.js");const a=n.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),o=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),l=n.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),u=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),c=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,d=e=>{const n=new Set;for(const r of e){if("data-tool-assets"!==r.type)continue;const e=i.safeJSONParse(r.content);if(null==e?void 0:e.assets)for(const r of e.assets)r.value&&!s.isGeneratedFileUrl(r.value)&&n.add(s.normalizeMarkdownUrl(r.value))}return n};exports.default=({className:p,parts:f,isStreaming:v=!1})=>{const m=n.useRef(new Set);m.current=new Set;const x=d(f),w=f.reduce(((e,n,r)=>n.isVisible?r:e),-1);return e.jsx("div",Object.assign({className:t.default("flex flex-col gap-2",p)},{children:e.jsx(n.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:f.map(((n,t)=>{if(!n.isVisible)return null;if("text"===n.type){const i=((e,n,r)=>{var i,t;const a=[];let o=0;for(const l of e.matchAll(c)){const u=null!==(i=l.index)&&void 0!==i?i:0,c=l[0],d="!"===l[1],p=null===(t=l[2])||void 0===t?void 0:t.trim(),f=l[3],v=s.getFilePreviewInfo(f);if(!v)continue;if(s.shouldSuppressRichPreviewForUrl(v.url,r))continue;u>o&&a.push({type:"markdown",value:e.slice(o,u)});const m=p&&s.normalizeMarkdownUrl(p)!==v.url?p:void 0;s.shouldRenderFilePreview(v,n)?a.push({type:"preview",key:`${v.url}-${u}`,fileInfo:v,displayName:m}):a.push({type:"markdown",value:d?c:`[${p||v.fileName}](${v.url})`}),o=u+c.length}return o<e.length&&a.push({type:"markdown",value:e.slice(o)}),a.length?a:[{type:"markdown",value:e}]})(n.content,m,x);return e.jsx(a,{children:i.map(((n,i)=>"preview"===n.type?e.jsx(s.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(r.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:m,suppressedRichPreviewUrls:x},i):null))},t)}if("reasoning"===n.type)return e.jsx(o,Object.assign({isReasoning:t===f.length-1},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:n.content,suppressedRichPreviewUrls:x})}),t);if("data-action-tool-caption"===n.type){const r=i.safeJSONParse(n.content),s=t===w;return e.jsx(l,Object.assign({},r&&r,{isLoading:v&&s,isVisible:s}),t)}if("data-reasoning-caption"===n.type){const r=i.safeJSONParse(n.content),s=t===w;return e.jsx(u,Object.assign({},r&&r,{isLoading:v&&s,isVisible:s}),t)}return null}))}))}))},exports.getSuppressedRichPreviewUrls=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("../../common/api/pickaxe.js"),r=require("react");function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}const o={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",he:"he-IL",hi:"hi-IN",it:"it-IT",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};let i=null;const s=new Map,l=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),a=({text:r,language:a,provider:c,pickaxeId:u,preferredVoiceName:d,browserVoices:p=[],onLoading:h,onPlay:f,onEnd:v})=>{var w;null==i||i.cancel(),null===(w=window.speechSynthesis)||void 0===w||w.cancel();let y=null,g=null,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("../../common/api/pickaxe.js"),r=require("react");function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}const o={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",he:"he-IL",hi:"hi-IN",it:"it-IT",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};let i=null;const s=new Map,l=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),a=({text:r,language:a,provider:c,pickaxeId:u,preferredVoiceName:d,browserVoices:p=[],onLoading:h,onPlay:f,onEnd:v})=>{var w;null==i||i.cancel(),null===(w=window.speechSynthesis)||void 0===w||w.cancel();let y=null,g=null,b=null,S=null,m=null,k=!1,L=!1,E=!1,A=!1;const R=()=>{L||(L=!0,null==y||y.close(),y=null,null==m||m.abort(),m=null,null==b||b.pause(),b=null,S&&URL.revokeObjectURL(S),S=null,i===x&&(i=null),v())},O=()=>{k||L||f()},x={cancel:()=>{var e;k||L||(k=!0,null==g||g.close(),g=null,null==y||y.pause(),null==y||y.close(),y=null,null==m||m.abort(),m=null,null==b||b.pause(),b=null,S&&URL.revokeObjectURL(S),S=null,null===(e=window.speechSynthesis)||void 0===e||e.cancel(),R())}};i=x,h();const j=(i=!0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const[{data:c},u]=yield Promise.all([n.pickaxeApi2.post("/speech"),Promise.resolve().then((function(){return t(require("microsoft-cognitiveservices-speech-sdk"))}))]);if(!c.success||!c.token)throw new Error(c.error||"Azure Speech token was not returned");if(k||L)return;const p=(e=>{if(!e)return"en-US";const n=e.toLowerCase();return"pt-br"===n?"pt-BR":o[n.split("-")[0]]||e})(a),h=u.SpeechConfig.fromAuthorizationToken(c.token,"eastus");h.speechSynthesisLanguage=p,h.speechSynthesisOutputFormat=u.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3;const f=new u.SpeakerAudioDestination;f.onAudioStart=()=>{const e=f.internalAudio;e?e.addEventListener("playing",O,{once:!0}):O()},f.onAudioEnd=R,y=f;const v=u.AudioConfig.fromSpeakerOutput(f),w=new u.SpeechSynthesizer(h,v);g=w;let b=(i?d:void 0)||s.get(p);if(!b){const n=yield w.getVoicesAsync(p);if(k||L)return;if(b=null===(e=n.voices.find((e=>e.locale===p)))||void 0===e?void 0:e.shortName,!b)throw new Error(`No Azure voice is available for ${p}`);s.set(p,b)}const S=b,m=yield new Promise(((e,n)=>{const t=`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${p}"><voice name="${l(S)}"><break time="500ms"/>${l(r)}</voice></speak>`;w.speakSsmlAsync(t,e,n)}));if(w.close(),g=null,k||L)return;if(m.reason!==u.ResultReason.SynthesizingAudioCompleted)throw new Error(m.errorDetails||"Azure speech synthesis failed")}catch(e){if(null==g||g.close(),g=null,null==y||y.close(),y=null,k||L)return;console.warn("Azure text-to-speech failed; using browser speech",e),(()=>{if(k||L||E)return;if(E=!0,!("speechSynthesis"in window)||!("SpeechSynthesisUtterance"in window))return void R();const e=new SpeechSynthesisUtterance(r),n=a||"en",t=p.find((e=>e.lang.startsWith(n)&&e.name.includes("Google")))||p.find((e=>e.lang.startsWith(n)));t?(e.voice=t,e.lang=t.lang):e.lang=n,e.onstart=O,e.onend=R,e.onerror=R,window.speechSynthesis.speak(e)})()}})),U=e=>{k||L||A||(A=!0,console.warn("ElevenLabs text-to-speech failed; using Azure speech",e),null==m||m.abort(),m=null,b&&(b.onplaying=null,b.onended=null,b.onerror=null,b.pause()),b=null,S&&URL.revokeObjectURL(S),S=null,j(!1))};return"elevenlabs"===c?e.__awaiter(void 0,void 0,void 0,(function*(){let e=!1,t=!1;try{if(!u)throw new Error("A Pickaxe ID is required");m=new AbortController;const o=yield fetch(`${n.pickaxeApi2.defaults.baseURL}/speech/elevenlabs/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r,pickaxeId:u}),signal:m.signal});if(!o.ok)throw new Error("ElevenLabs speech synthesis failed");if(k||L)return;if(b=new Audio,b.onplaying=O,b.onended=()=>{!e||t?R():console.warn("ElevenLabs audio ended before its response stream completed; waiting for more audio")},b.onerror=()=>{const e=null==b?void 0:b.error;U(new Error("ElevenLabs audio playback failed"+(e?` (code ${e.code})`:"")))},!("MediaSource"in window)||!MediaSource.isTypeSupported("audio/mpeg")||!o.body)return S=URL.createObjectURL(yield o.blob()),b.src=S,void(yield b.play());e=!0;const i=new MediaSource;S=URL.createObjectURL(i),b.src=S;const s=yield new Promise(((e,n)=>{i.addEventListener("sourceopen",(()=>{try{e(i.addSourceBuffer("audio/mpeg"))}catch(e){n(e)}}),{once:!0})})),l=o.body.getReader();let a,c=!1,d=null;for(;!k&&!L&&!A;){const{done:e,value:n}=yield l.read();if(e)break;(null==n?void 0:n.byteLength)&&(yield new Promise(((e,r)=>{const t=()=>{s.removeEventListener("updateend",o),s.removeEventListener("error",i)},o=()=>{t(),e()},i=()=>{t(),r(new Error("Audio buffer failed"))};s.addEventListener("updateend",o),s.addEventListener("error",i),s.appendBuffer(n)})),c?!b.paused||k||L||b.play().catch(U):(c=!0,d=b.play().catch((e=>{a=e}))))}if(t=!0,k||"open"!==i.readyState||i.endOfStream(),k||A||!(null==b?void 0:b.ended)||R(),!d)throw new Error("ElevenLabs returned no audio");if(yield d,a)throw a}catch(e){U(e)}})):j(),x};exports.useTextToSpeech=(e=!0,n={})=>{const[t,o]=r.useState(!1),[i,s]=r.useState(!1),[l,c]=r.useState([]),u=r.useRef(null),d=r.useRef(!0);r.useEffect((()=>(d.current=!0,()=>{var e;d.current=!1,null===(e=u.current)||void 0===e||e.cancel(),u.current=null})),[]),r.useEffect((()=>{if(!e||!("speechSynthesis"in window))return;const n=()=>{const e=window.speechSynthesis.getVoices();e.length>0&&c(e)};return n(),window.speechSynthesis.addEventListener("voiceschanged",n),()=>{window.speechSynthesis.removeEventListener("voiceschanged",n)}}),[e]);const p=r.useCallback((()=>{var e;null===(e=u.current)||void 0===e||e.cancel(),u.current=null}),[]);return{isLoading:t,isSpeaking:i,speak:r.useCallback(((e,r)=>{if(!e)return;const t=a({text:e,language:r,provider:n.provider,pickaxeId:n.pickaxeId,preferredVoiceName:n.voiceName,browserVoices:l,onLoading:()=>{d.current&&(o(!0),s(!1))},onPlay:()=>{d.current&&(o(!1),s(!0))},onEnd:()=>{u.current===t&&(u.current=null),d.current&&(o(!1),s(!1))}});u.current=t}),[l,n]),stop:p}};
|
|
@@ -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};
|