@pickaxeproject/react 6.0.1-1 → 6.0.1-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/components/Pickaxe/Addons/Auth/Provider.js +1 -1
  2. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  7. package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
  8. package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  9. package/dist/cjs/components/Pickaxe/index.js +1 -1
  10. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  11. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  12. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  13. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  14. package/dist/cjs/src/components/Pickaxe/Addons/Auth/Provider.d.ts +2 -0
  15. package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuth.d.ts +1 -0
  16. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +3 -4
  17. package/dist/esm/components/Pickaxe/Addons/Auth/Provider.js +1 -1
  18. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  19. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  20. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  21. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  22. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  23. package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
  24. package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  25. package/dist/esm/components/Pickaxe/index.js +1 -1
  26. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  27. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  28. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  29. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  30. package/dist/esm/src/components/Pickaxe/Addons/Auth/Provider.d.ts +2 -0
  31. package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuth.d.ts +1 -0
  32. package/dist/esm/src/components/Pickaxe/Provider.d.ts +3 -4
  33. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.AuthContext=s,exports.default=({children:n})=>{const[i,r]=t.useState(""),[u,a]=t.useState(null),[o,d]=t.useState(!1),[g,l]=t.useState(!1),[c,S]=t.useState(!1),[I,x]=t.useState(!1);return e.jsx(s.Provider,Object.assign({value:{emailInput:i,token:u,isLoggedIn:!!u,isLoggedOut:!u,isLoggingIn:o,isSending:g,isResendDisabled:c,isSent:I,setEmailInput:r,setToken:a,setIsLoggingIn:d,setIsSending:l,setIsResendDisabled:S,setIsSent:x}},{children:n}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.AuthContext=s,exports.default=({children:n})=>{const[i,r]=t.useState(""),[u,a]=t.useState(null),[o,g]=t.useState(!1),[d,c]=t.useState(!1),[l,S]=t.useState(!1),[I,x]=t.useState(!1),[p,h]=t.useState(!1);return e.jsx(s.Provider,Object.assign({value:{emailInput:i,token:u,isLoggedIn:!!u,isLoggedOut:!u,isLoggingIn:o,isSending:l,isResendDisabled:I,isSent:p,isPricingAuth:d,setIsPricingAuth:c,setEmailInput:r,setToken:a,setIsLoggingIn:g,setIsSending:S,setIsResendDisabled:x,setIsSent:h}},{children:n}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("./useAuthContext.js"),o=require("./useAuthVerify.js"),r=require("../../../../../common/utils.js"),n=require("../../../../../common/api/pickaxe.js"),d=require("../../../../../common/error.js");exports.useAuth=()=>{const{deploymentId:u,pickaxe:a,isEmailLogin:l,setSender:c,setSenderType:f}=i.usePickaxeContext(),{emailInput:m,isSending:k,isLoggedOut:p,setToken:g,setIsLoggingIn:h,setIsSending:I,setIsSent:w,setIsResendDisabled:x}=s.useAuthContext(),y=o.useAuthVerify({token:r.getAuthToken((null==a?void 0:a.studioid)||"")||"",enabled:l&&p,setIsLoggingIn:h});t.useEffect((()=>{if("undefined"==typeof window)return;if(!y.data)return;const{success:e,token:t,error:i}=y.data;e&&!i?(g(t),c(void 0),f("STUDIO_USER")):r.deleteAuthToken(`PXE-token-${null==a?void 0:a.studioid}`)}),[y.data,null==a?void 0:a.studioid]);return{onSend:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!a)return;if(k)return;const e=m.trim().toLowerCase();if(!e)throw new Error("Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error("Please enter a valid email address.");if(!a.studioid)throw new Error(`Studio ID is missing for ${a.formid}. Please contact support.`);I(!0),t&&x(!0);const i=(yield n.default.post("/auth/email",Object.assign({pickaxeId:a.formid,studioId:a.studioid,email:e},u&&{deploymentId:u}))).data;if(!i.success)throw new Error(i.error||"Failed to send sign-in link.");I(!1),w(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),x(!1)),r.setAuthToken(`PXE-token-${a.studioid}`,i.token)}catch(e){const t=d.default(e);alert(t)}finally{I(!1)}}))}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("./useAuthContext.js"),s=require("./useAuthVerify.js"),r=require("../../../../../common/utils.js"),n=require("../../../../../common/api/pickaxe.js"),d=require("../../../../../common/error.js"),u=require("../../../../../hooks/pickaxe/useResponseContext.js");exports.useAuth=()=>{const{deploymentId:a,pickaxe:c,setSender:l,setSenderType:f}=i.usePickaxeContext(),{emailInput:k,isSending:p,isLoggedOut:m,isPricingAuth:h,setToken:w,setIsLoggingIn:g,setIsSending:I,setIsSent:x,setIsResendDisabled:v,setIsPricingAuth:y}=o.useAuthContext(),P=s.useAuthVerify({token:r.getAuthToken((null==c?void 0:c.studioid)||"")||"",enabled:h&&m,setIsLoggingIn:g}),{setLimitData:E}=u.useResponseContext();t.useEffect((()=>{if("undefined"==typeof window)return;if(!P.data)return;const{success:e,token:t,error:i}=P.data;if(!e||i)return r.deleteAuthToken(`PXE-token-${null==c?void 0:c.studioid}`),void y(!1);e&&t&&(w(t),l(void 0),f("STUDIO_USER"),h&&(y(!1),E(null)))}),[P.data,null==c?void 0:c.studioid]);return{onSend:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!c)return;if(p)return;const e=k.trim().toLowerCase();if(!e)throw new Error("Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error("Please enter a valid email address.");if(!c.studioid)throw new Error(`Studio ID is missing for ${c.formid}. Please contact support.`);I(!0),t&&v(!0);const i=(yield n.default.post("/auth/email",Object.assign({pickaxeId:c.formid,studioId:c.studioid,email:e},a&&{deploymentId:a}))).data;if(!i.success)throw new Error(i.error||"Failed to send sign-in link.");I(!1),x(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),r.setAuthToken(`PXE-token-${c.studioid}`,i.token)}catch(e){const t=d.default(e);alert(t)}finally{I(!1)}})),onOpenPricing:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!c)return;if(!c.studioid)throw new Error(`Studio ID is missing for ${c.formid}. Please contact support.`);const e=(yield n.default.post("/auth/token",{pickaxeId:c.formid,studioId:c.studioid})).data;if(!e.success)throw new Error(e.error||"Failed to create sign-in token.");r.setAuthToken(`PXE-token-${c.studioid}`,e.token),y(!0),window.open(`${t}?embed_token=${e.token}`)}catch(e){const t=d.default(e);alert(t)}}))}};
@@ -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"),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"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=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"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=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");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:S,isInputFocused:A,onSubmit:P,resubmitPrompt:I})=>{var H,L,R,M,D;const{sessionId:E,deploymentType:F,pickaxe:B,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isEmailLogin:U,isShowIceBreaker:V,setSessionId:G,setLastSessionId:J}=i.usePickaxeContext(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=a.useAuthContext(),{onSend:ee}=t.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:ae,error:te}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==B?void 0:B.icebreakers)?B.icebreakers.slice(0,3):[]),[null==B?void 0:B.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!S&&de.isSuccess&&W&&!e}),[S,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==B?void 0:B.chatflag)&&(null==B?void 0:B.enablechatresponses)&&ie.length>0),[B,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===F&&U&&Q&&Z,ge=V&&!A&&!je&&me&&ne>767,pe=V&&!A&&(je||ne<=767),be=()=>{J(E),G("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}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(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===F&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),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]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),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",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?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:K}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(R=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==R?R:"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:()=>{Y||X||ee(!0)}},{children:X?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==B?void 0:B.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&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"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?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:[(null!==(L=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==L?L:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var a,t;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(t=null===(a=de.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),ae?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):te?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:te})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),a=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=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"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=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");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:A,isInputFocused:S,onSubmit:P,resubmitPrompt:I})=>{var H,R,L,M,D;const{sessionId:F,deploymentType:B,pickaxe:E,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isShowIceBreaker:U,setSessionId:V,setLastSessionId:G}=i.usePickaxeContext(),{emailInput:J,isLoggedOut:K,isSending:Q,isResendDisabled:X,isSent:Y,isPricingAuth:Z}=t.useAuthContext(),{onSend:ee}=a.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:te,error:ae}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==E?void 0:E.icebreakers)?E.icebreakers.slice(0,3):[]),[null==E?void 0:E.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!A&&de.isSuccess&&W&&!e}),[A,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==E?void 0:E.chatflag)&&(null==E?void 0:E.enablechatresponses)&&ie.length>0),[E,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===B&&Z&&K&&Y,ge=U&&!S&&!je&&me&&ne>767,pe=U&&!S&&(je||ne<=767),be=()=>{G(F),V("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}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(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===B&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),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]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),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",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?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:J}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(L=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==L?L:"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:()=>{X||Q||ee(!0)}},{children:Q?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==E?void 0:E.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&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"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?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:[(null!==(R=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==R?R:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var t,a;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(a=null===(t=de.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),te?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):ae?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:ae})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.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");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),y=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),I=require("../../../common/cn.js"),C=require("../../../common/utils.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=N(n);const E=s.forwardRef((({resubmitPrompt:N,onFocus:E,onBlur:A,onInputHeightChange:q,initSmitheryAuthData:R},T)=>{var P,D,L;const{origin:H,pickaxeId:M,sessionId:F,sender:$,senderType:W,portalId:B,deploymentId:U,deploymentType:J,pickaxe:V,styles:z,colors:K,locale:X,forceMobile:G,isNewChat:Q,isRtl:Y,isEmailLogin:Z,isShowFeedbackMessage:ee,setIsNewChat:te,setIsShowIceBreaker:se,onGenerateComplete:ne}=i.usePickaxeContext(),{token:ie,isLoggedOut:re,isSent:oe}=u.useAuthContext(),{messages:ae,isGenerating:le,setMessages:ce,setStatus:ue,setLimitData:de,setError:fe}=r.useResponseContext(),{documents:pe,isUploading:me,documentError:he,onFileUpload:ge,setDocuments:ve,setDocumentError:be}=d.useDocument(),{scrollStartSession:ye,scrollEndSession:xe,scrollToBottom:je}=f.useScroll({auto:!0}),{artifacts:we,currentPopupType:Oe,setArtifacts:Se,setCurrentArtifact:ke}=p.useArtifactContext(),{height:Ie}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,_e]=s.useState(""),[Ee,Ae]=s.useState(!1),[qe,Re]=s.useState(!1),Te=s.useRef(null),Pe=s.useRef(""),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=s.useRef(null),Fe=s.useRef(null),$e=Math.max(.4*Ie,100),{transcript:We,listening:Be,resetTranscript:Ue,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ve]=h.useMediaQuery("(max-width: 480px)"),ze=m.useHover(),{isHover:Ke}=ze,Xe=e.__rest(ze,["isHover"]),Ge=m.useHover(),{isHover:Qe}=Ge,Ye=e.__rest(Ge,["isHover"]),Ze=m.useHover(),{isHover:et}=Ze,tt=e.__rest(Ze,["isHover"]),st=a.useStyleFontSize(),nt=o.useStyleInput(),it="undefined"!=typeof window?window.location.hostname:"",rt="undefined"!=typeof window?window.location.href:"",ot="undefined"!=typeof window&&window.self!==window.top,at=it.includes("pickaxe.co")&&!rt.includes("https://studio.pickaxe.co/_embed")&&!ot,lt=null===(P=null==V?void 0:V.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),ct=Je&&(null==V?void 0:V.enablevoicetotext),ut="chat-input"===J&&Q&&!oe,dt="chat-input"===J&&Z&&re&&oe,ft=null!==(D=null==V?void 0:V.placeholdertext)&&void 0!==D?D:Y?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",pt=Ee||qe,mt=s.useMemo((()=>{var e,t,s;return!!Q&&(!!V&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=V.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!ut)))))}),[V,Q,ee,ut,Ce.data,Ce.isLoading]),ht=s.useMemo((()=>{if(le||me)return!1;const e=pe.length>0&&pe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&pe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[le,me,Ne,pe]);s.useImperativeHandle(T,(()=>({onSubmit:gt}))),s.useEffect((()=>{se(mt)}),[mt]),s.useEffect((()=>{var e;if(N){const t=Array.from(ae),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;gt(s,!0)}}),[N]),s.useEffect((()=>{if(!Me.current||!q)return;const e=new ResizeObserver((e=>{for(const t of e)q(t.contentRect.height)}));return e.observe(Me.current),()=>{e.disconnect()}}),[q]),s.useEffect((()=>{if(!Be)return;const e=Pe.current?`${Pe.current} `:"";_e(`${e}${We}`)}),[We,Be]),s.useEffect((()=>{if(!Le.current)return;(()=>{if(!Le.current)return;let e=Le.current.scrollHeight>52;Ne.includes("\n")||pe.length?e=!0:Ne.trim()||(e=!1),Ae(e)})()}),[Ne,pe]),s.useEffect((()=>{const e=Le.current,t=He.current;if(!e||!t||Ee||Ne.includes("\n"))return void Re(!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=Ne||ft,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;Re(r>l)}),[Ne,Ee,ft]);const gt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(le||me)return;const r=pe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Ne;if(!c&&!l)return;fe(""),be(""),de(null),_e(""),te(!1),ue("fetching"),ye(),je();const u=null!==(n=null===(e=null==V?void 0:V.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(ae.slice(0,ae.length-1)):Array.from(ae),...s?[]:[{id:ae.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:ae.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ce(d),je(),u&&ve([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:H,pickaxeId:M,sessionId:F,senderType:W,value:c},u&&{documentIds:o}),$&&{sender:$}),ie&&{studioSessionToken:ie}),!ie&&!$&&{sender:C.initializeEmbedUserId()}),B&&{portalId:B}),U&&{deploymentId:U}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),at&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;ue("streaming"),Fe.current=new AbortController;const h=d.length-1,g=[];let b=[...null!=we?we:[]],y=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${y}`,{signal:null===(i=Fe.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();De.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&y++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return fe(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&R){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw x=!0,R({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw x=!0,R({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ce([...d.slice(0,h),Object.assign(Object.assign({},d[d.length-1]),{id:ae.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se([...b]),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Se(b),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se(b),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Se(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Se(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);fe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ne||ne(F)}catch(e){if(e.limitData)de(e.limitData),fe("");else{let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),fe(t)}}finally{je(),ue("idle"),xe(),De.current=null}}));return dt?null:t.jsx("div",Object.assign({className:I.default("flex w-full flex-shrink-0 flex-col items-center",!ut&&"px-4 pb-8"),dir:Y?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Me,className:I.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===z.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},nt),{maxHeight:`${$e}px`,overflowY:"auto"})},{children:[Be&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(L=K.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:K.text+"90"}},{children:"Listening..."}))]})),!le&&pe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:le}),t.jsx(O.default,Object.assign({ref:Le,className:I.default(st.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Y?"text-right":"text-left",pt&&"mb-12",Be&&"text-transparent"),value:Ne,placeholder:ft,onChange:e=>{if(_e(e),q){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void q(0);if(t>=11)return;let s=0;t>1&&(s=50),q(24*(t-1)+s)}},onKeyDown:e=>{G||Ve||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),me||le||gt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),te(!1),yield ge(e))}))},E&&{onFocus:E},A&&{onBlur:A},{dir:Y?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:He,className:I.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",pt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!pt&&nt.backgroundColor&&{backgroundColor:nt.backgroundColor}),{borderTopRightRadius:z.cornerRadius+"px",borderBottomRightRadius:z.cornerRadius+"px"})},{children:le?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Fe.current&&(Fe.current.abort(),Fe.current=null),De.current&&(De.current.cancel(),De.current=null),ue("idle")},style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Be?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:_.default.stopListening,style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[lt&&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:Qe?K.accent+"10":void 0,color:Qe?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{var e;return null===(e=Te.current)||void 0===e?void 0:e.click()}},Ye,{children:[t.jsx("input",{id:"file-upload",ref:Te,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*(){te(!1),yield ge(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),ct&&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:Be?K.accent:et?K.accent+"10":void 0,color:Be?K.accentText:et?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{Be?_.default.stopListening():(Pe.current=Ne,Ue(),_.default.startListening({continuous:!0,interimResults:!0,language:X||"en-US"}))}},tt,{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:Ke||ht?K.accent:K.accent+"10",color:Ke||ht?K.accentText:K.accent+"80"},disabled:!ht,onClick:()=>gt()},Xe,{children:t.jsx(y.default,{className:I.default("h-6 w-6 shrink-0",Y&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),y=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),I=require("../../../common/cn.js"),C=require("../../../common/utils.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=N(n);const E=s.forwardRef((({resubmitPrompt:N,onFocus:E,onBlur:A,onInputHeightChange:q,initSmitheryAuthData:R},T)=>{var P,D,L;const{origin:H,pickaxeId:M,sessionId:F,sender:$,senderType:W,portalId:B,deploymentId:U,deploymentType:J,pickaxe:V,styles:z,colors:K,locale:X,forceMobile:G,isNewChat:Q,isRtl:Y,isShowFeedbackMessage:Z,setIsNewChat:ee,setIsShowIceBreaker:te,onGenerateComplete:se}=i.usePickaxeContext(),{token:ne,isLoggedOut:ie,isSent:re,isPricingAuth:oe}=u.useAuthContext(),{messages:ae,isGenerating:le,setMessages:ce,setStatus:ue,setLimitData:de,setError:fe}=r.useResponseContext(),{documents:pe,isUploading:me,documentError:he,onFileUpload:ge,setDocuments:ve,setDocumentError:be}=d.useDocument(),{scrollStartSession:ye,scrollEndSession:xe,scrollToBottom:je}=f.useScroll({auto:!0}),{artifacts:we,currentPopupType:Oe,setArtifacts:Se,setCurrentArtifact:ke}=p.useArtifactContext(),{height:Ie}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,_e]=s.useState(""),[Ee,Ae]=s.useState(!1),[qe,Re]=s.useState(!1),Te=s.useRef(null),Pe=s.useRef(""),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=s.useRef(null),Fe=s.useRef(null),$e=Math.max(.4*Ie,100),{transcript:We,listening:Be,resetTranscript:Ue,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ve]=h.useMediaQuery("(max-width: 480px)"),ze=m.useHover(),{isHover:Ke}=ze,Xe=e.__rest(ze,["isHover"]),Ge=m.useHover(),{isHover:Qe}=Ge,Ye=e.__rest(Ge,["isHover"]),Ze=m.useHover(),{isHover:et}=Ze,tt=e.__rest(Ze,["isHover"]),st=a.useStyleFontSize(),nt=o.useStyleInput(),it="undefined"!=typeof window?window.location.hostname:"",rt="undefined"!=typeof window?window.location.href:"",ot="undefined"!=typeof window&&window.self!==window.top,at=it.includes("pickaxe.co")&&!rt.includes("https://studio.pickaxe.co/_embed")&&!ot,lt=null===(P=null==V?void 0:V.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),ct=Je&&(null==V?void 0:V.enablevoicetotext),ut="chat-input"===J&&Q&&!re,dt="chat-input"===J&&oe&&ie&&re,ft=null!==(D=null==V?void 0:V.placeholdertext)&&void 0!==D?D:Y?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",pt=Ee||qe,mt=s.useMemo((()=>{var e,t,s;return!!Q&&(!!V&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=V.icebreakers)||void 0===s?void 0:s.length)&&(!Z&&!ut)))))}),[V,Q,Z,ut,Ce.data,Ce.isLoading]),ht=s.useMemo((()=>{if(le||me)return!1;const e=pe.length>0&&pe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&pe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[le,me,Ne,pe]);s.useImperativeHandle(T,(()=>({onSubmit:gt}))),s.useEffect((()=>{te(mt)}),[mt]),s.useEffect((()=>{var e;if(N){const t=Array.from(ae),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;gt(s,!0)}}),[N]),s.useEffect((()=>{if(!Me.current||!q)return;const e=new ResizeObserver((e=>{for(const t of e)q(t.contentRect.height)}));return e.observe(Me.current),()=>{e.disconnect()}}),[q]),s.useEffect((()=>{if(!Be)return;const e=Pe.current?`${Pe.current} `:"";_e(`${e}${We}`)}),[We,Be]),s.useEffect((()=>{if(!Le.current)return;(()=>{if(!Le.current)return;let e=Le.current.scrollHeight>52;Ne.includes("\n")||pe.length?e=!0:Ne.trim()||(e=!1),Ae(e)})()}),[Ne,pe]),s.useEffect((()=>{const e=Le.current,t=He.current;if(!e||!t||Ee||Ne.includes("\n"))return void Re(!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=Ne||ft,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;Re(r>l)}),[Ne,Ee,ft]);const gt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(le||me)return;const r=pe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Ne;if(!c&&!l)return;fe(""),be(""),de(null),_e(""),ee(!1),ue("fetching"),ye(),je();const u=null!==(n=null===(e=null==V?void 0:V.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(ae.slice(0,ae.length-1)):Array.from(ae),...s?[]:[{id:ae.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:ae.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ce(d),je(),u&&ve([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:H,pickaxeId:M,sessionId:F,senderType:W,value:c},u&&{documentIds:o}),$&&{sender:$}),ne&&{studioSessionToken:ne}),!ne&&!$&&{sender:C.initializeEmbedUserId()}),B&&{portalId:B}),U&&{deploymentId:U}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),at&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;ue("streaming"),Fe.current=new AbortController;const h=d.length-1,g=[];let b=[...null!=we?we:[]],y=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${y}`,{signal:null===(i=Fe.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();De.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&y++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return fe(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&R){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw x=!0,R({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw x=!0,R({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ce([...d.slice(0,h),Object.assign(Object.assign({},d[d.length-1]),{id:ae.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se([...b]),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Se(b),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se(b),Oe.startsWith("inline")||ke({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Se(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Se(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);fe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==se||se(F)}catch(e){if(e.limitData)de(e.limitData),fe("");else{let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),fe(t)}}finally{je(),ue("idle"),xe(),De.current=null}}));return dt?null:t.jsx("div",Object.assign({className:I.default("flex w-full flex-shrink-0 flex-col items-center",!ut&&"px-4 pb-8"),dir:Y?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Me,className:I.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===z.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},nt),{maxHeight:`${$e}px`,overflowY:"auto"})},{children:[Be&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(L=K.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:K.text+"90"}},{children:"Listening..."}))]})),!le&&pe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:le}),t.jsx(O.default,Object.assign({ref:Le,className:I.default(st.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Y?"text-right":"text-left",pt&&"mb-12",Be&&"text-transparent"),value:Ne,placeholder:ft,onChange:e=>{if(_e(e),q){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void q(0);if(t>=11)return;let s=0;t>1&&(s=50),q(24*(t-1)+s)}},onKeyDown:e=>{G||Ve||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),me||le||gt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ee(!1),yield ge(e))}))},E&&{onFocus:E},A&&{onBlur:A},{dir:Y?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:He,className:I.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",pt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!pt&&nt.backgroundColor&&{backgroundColor:nt.backgroundColor}),{borderTopRightRadius:z.cornerRadius+"px",borderBottomRightRadius:z.cornerRadius+"px"})},{children:le?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Fe.current&&(Fe.current.abort(),Fe.current=null),De.current&&(De.current.cancel(),De.current=null),ue("idle")},style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Be?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:_.default.stopListening,style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[lt&&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:Qe?K.accent+"10":void 0,color:Qe?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{var e;return null===(e=Te.current)||void 0===e?void 0:e.click()}},Ye,{children:[t.jsx("input",{id:"file-upload",ref:Te,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*(){ee(!1),yield ge(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),ct&&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:Be?K.accent:et?K.accent+"10":void 0,color:Be?K.accentText:et?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{Be?_.default.stopListening():(Pe.current=Ne,Ue(),_.default.startListening({continuous:!0,interimResults:!0,language:X||"en-US"}))}},tt,{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:Ke||ht?K.accent:K.accent+"10",color:Ke||ht?K.accentText:K.accent+"80"},disabled:!ht,onClick:()=>gt()},Xe,{children:t.jsx(y.default,{className:I.default("h-6 w-6 shrink-0",Y&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../hooks/pickaxe/useDimensionContext.js"),i=require("../Addons/Document/hooks/useDocument.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),c=require("./Input.js"),u=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),x=require("lucide-react"),f=require("uuid"),h=require("../../Icons/trash-2.svg.js"),p=require("../../Icons/pencil.svg.js"),b=require("../../../hooks/pickaxe/useResponseContext.js");const j=({children:e,className:s})=>t.jsx("div",Object.assign({className:d.default("flex items-center gap-2 transition-all duration-200 select-none","rounded-[40px] h-[72px] border border-white/70 px-6 py-3 bg-white/10 backdrop-blur-md shadow-lg",s)},{children:e})),g=({text:e,icon:s,className:n,onClick:r})=>t.jsx("div",Object.assign({onClick:r,className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 transition-all duration-200 rounded-[40px] border border-white/70 bg-[#FFFFFF1A]",n)},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20"},{children:[s&&t.jsx("img",{src:s,alt:"",className:"h-5 w-5 rounded-full object-cover"}),t.jsx("p",Object.assign({className:"text-sm font-medium truncate max-w-[150px] text-foreground"},{children:e}))]}))})),v=({text:n,className:r,onRename:o,onDelete:i})=>{const[a,l]=s.useState(!1),[c,u]=s.useState(!1),[m,f]=s.useState(n),[b,j]=s.useState(!1),g=s.useRef(null),v=s.useRef(null);s.useEffect((()=>{c||f(n)}),[n,c]),s.useEffect((()=>{const e=e=>{v.current&&!v.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const w=()=>e.__awaiter(void 0,void 0,void 0,(function*(){m.trim()&&(j(!0),yield o(m),j(!1),u(!1))})),y=()=>{f(n),u(!1)};return t.jsxs("div",Object.assign({ref:v,className:"relative z-40 h-full"},{children:[t.jsx("div",Object.assign({className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 rounded-[40px] overflow-visible transition-all duration-200 cursor-pointer group border border-white/70 bg-[#FFFFFF1A]",r),onClick:e=>{e.stopPropagation(),c||a?a&&l(!1):l(!0)}},{children:c?t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t.jsx("input",{autoFocus:!0,type:"text",value:m,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&w(),"Escape"===e.key&&y()},className:"bg-transparent border-b border-black/30 text-sm font-medium focus:outline-none w-full min-w-[80px] text-foreground"}),t.jsx("button",Object.assign({onClick:w,disabled:b,className:"p-1 rounded hover:bg-black/10 text-green-600"},{children:t.jsx(x.Check,{className:"h-4 w-4"})})),t.jsx("button",Object.assign({onClick:y,disabled:b,className:"p-1 rounded hover:bg-black/10 text-red-600"},{children:t.jsx(x.X,{className:"h-4 w-4"})}))]})):t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 max-w-[200px]"},{children:[t.jsx("p",Object.assign({className:"text-sm font-medium truncate text-foreground"},{children:n})),t.jsx(x.MoreHorizontal,{className:d.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity")})]}))})),a&&t.jsxs("div",Object.assign({className:"absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] border border-white/70 bg-neutral-50 backdrop-blur-md overflow-hidden animate-in fade-in zoom-in-95 duration-100",ref:g},{children:[t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),u(!0)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b border-white/10 hover:bg-white/10"},{children:[t.jsx(p.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),i()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:bg-white/10"},{children:[t.jsx(h.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))};exports.default=()=>{const{deploymentType:x,isNewChat:h,setIsNewChat:p,sessionId:w,setSessionId:y,pickaxeId:k,sender:N,colors:O,styles:C,pickaxe:F,isEmbed:D}=n.usePickaxeContext(),{isSent:_}=r.useAuthContext(),{width:I,height:S,setDimension:q}=o.useDimensionContext(),{setDocuments:E,onFileUpload:P}=i.useDocument(),{isGenerating:z}=b.useResponseContext(),A=a.useStyleFontSize(),[R,T]=s.useState(0),[H,L]=s.useState(!1),[M,B]=s.useState(!1),G=s.useRef(null),K=s.useRef(null),U=s.useRef(0),[X,J]=s.useState(null),[Q,V]=s.useState(!1),W="chat-input"===x&&h&&!_;s.useEffect((()=>()=>{E([])}),[]);const Y=s.useCallback((()=>{if(!k||!N)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.default.post("/get_pickaxe_conversation",{sessionId:w,userId:N});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void $(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[k,N,w]);s.useEffect((()=>{z||h||!w||Y()}),[z,h,w,Y]),s.useEffect((()=>{if(!G.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;q(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(G.current),()=>{e.disconnect()}}),[G.current]);const[Z,$]=s.useState("New Chat"),ee=(null==F?void 0:F.formtitle)||"Pickaxe",te=(null==F?void 0:F.coverphoto)||void 0,se=!W&&!D;return t.jsxs("div",Object.assign({ref:G,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),U.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&B(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),U.current-=1,0===U.current&&B(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),B(!1),U.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(p(!1),yield P(e))}))},{children:[M&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(u.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(A.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(A.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),W?t.jsx(c.default,{}):t.jsxs(t.Fragment,{children:[t.jsxs("div",Object.assign({className:d.default("flex flex-col w-full items-center h-full relative z-0",se?"pt-6":"")},{children:[se&&t.jsx("div",Object.assign({className:"w-full max-w-3xl px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500"},{children:t.jsxs(j,Object.assign({colors:O,styles:C},{children:[t.jsx(g,{text:ee,icon:te,colors:O,styles:C}),h||"New Chat"===Z?t.jsx(g,{text:Z,colors:O,styles:C}):t.jsx(v,{text:Z,sessionId:w,colors:O,styles:C,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w)try{yield m.default.post("/edit_conversation_name",{sessionId:w,name:t,userId:N}),$(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w&&window.confirm("Are you sure you want to delete this conversation?"))try{yield m.default.post("/delete_pickaxe_conversation",{sessionId:w,userId:N}),p(!0),y(f.v4()),$("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}}))})]}))})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:S<=545||I<=350||H,isInputFocused:H,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){K.current&&K.current.onSubmit(t)})),smitheryAuthData:X,resubmitPrompt:()=>{J(null),V(!0)}})]})),t.jsx(c.default,{ref:K,onFocus:()=>L(!0),onBlur:()=>L(!1),onInputHeightChange:T,initSmitheryAuthData:e=>J(e),resubmitPrompt:Q})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),a=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),c=require("./Input.js"),u=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),x=require("lucide-react"),f=require("uuid"),h=require("../../Icons/trash-2.svg.js"),p=require("../../Icons/pencil.svg.js"),v=require("../../../hooks/pickaxe/useResponseContext.js");const g=({text:e,icon:s,className:n,onClick:i})=>t.jsx("div",Object.assign({onClick:i,className:d.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",n)},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[s&&t.jsx("img",{src:s,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),t.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))})),j=({text:n,className:i,onRename:a,onDelete:r,isDarkGlass:o})=>{const[l,c]=s.useState(!1),[u,m]=s.useState(!1),[f,v]=s.useState(n),[g,j]=s.useState(!1),b=s.useRef(null),w=s.useRef(null);s.useEffect((()=>{u||v(n)}),[n,u]),s.useEffect((()=>{const e=e=>{w.current&&!w.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const k=()=>e.__awaiter(void 0,void 0,void 0,(function*(){f.trim()&&(j(!0),yield a(f),j(!1),m(!1))})),y=()=>{v(n),m(!1)};return t.jsxs("div",Object.assign({ref:w,className:"relative z-40 h-full shrink min-w-0"},{children:[t.jsx("div",Object.assign({className:d.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",i),onClick:e=>{e.stopPropagation(),u||l?l&&c(!1):c(!0)}},{children:u?t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t.jsx("input",{autoFocus:!0,type:"text",value:f,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k(),"Escape"===e.key&&y()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),t.jsx("button",Object.assign({onClick:k,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t.jsx(x.Check,{className:"h-4 w-4"})})),t.jsx("button",Object.assign({onClick:y,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t.jsx(x.X,{className:"h-4 w-4"})}))]})):t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[t.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:n})),t.jsx(x.MoreHorizontal,{className:d.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),l&&t.jsxs("div",Object.assign({className:d.default("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",o?"bg-[#313131] text-white":"bg-white text-black"),ref:b},{children:[t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),c(!1),m(!0)},className:d.default("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",o?"border-current":"border-[#EBEAEB]")},{children:[t.jsx(p.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),c(!1),r()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[t.jsx(h.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))};exports.default=()=>{const{deploymentType:x,isNewChat:h,setIsNewChat:p,sessionId:b,setSessionId:w,pickaxeId:k,sender:y,pickaxe:N,styles:C,isEmbed:D}=n.usePickaxeContext(),{isSent:O}=i.useAuthContext(),{width:_,height:S,setDimension:I}=a.useDimensionContext(),{setDocuments:q,onFileUpload:E}=r.useDocument(),{isGenerating:P,messages:z}=v.useResponseContext(),F=o.useStyleFontSize(),[R,A]=s.useState(0),[T,H]=s.useState(!1),[B,G]=s.useState(!1),L=s.useRef(null),M=s.useRef(null),K=s.useRef(0),[U,X]=s.useState(null),[J,Q]=s.useState(!1),V="chat-input"===x&&h&&!O;s.useEffect((()=>()=>{q([])}),[]);const W=s.useCallback((()=>{if(!k||!y)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.default.post("/get_pickaxe_conversation",{sessionId:b,userId:y});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void Z(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[k,y,b]);s.useEffect((()=>{P||h||!b||W()}),[P,h,b,W]),s.useEffect((()=>{if(!L.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;I(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(L.current),()=>{e.disconnect()}}),[L.current]);const[Y,Z]=s.useState("New Chat"),$=(null==N?void 0:N.formtitle)||"Pickaxe",ee=(null==N?void 0:N.coverphoto)||void 0,[te,se]=s.useState(!1);s.useEffect((()=>{const e=!V&&!D&&C.portalTheme&&(z.filter((e=>"user"===e.role)).length>0||T||!h);se(null!=e&&e)}),[z,T,h]);return t.jsxs("div",Object.assign({ref:L,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),K.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&G(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),K.current-=1,0===K.current&&G(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),G(!1),K.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(p(!1),yield E(e))}))},{children:[B&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(u.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(F.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(F.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),V?t.jsx(c.default,{}):t.jsxs(t.Fragment,{children:[te&&t.jsxs("div",Object.assign({className:d.default("direct-link"===x?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===C.portalTheme?"glass-dark ":"")},{children:[t.jsx(g,{text:$,icon:ee}),h||"New Chat"===Y?t.jsx(g,{text:Y}):t.jsx(j,{text:Y,sessionId:b,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b)try{yield m.default.post("/edit_conversation_name",{sessionId:b,name:t,userId:y}),Z(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b&&window.confirm("Are you sure you want to delete this conversation?"))try{yield m.default.post("/delete_pickaxe_conversation",{sessionId:b,userId:y}),p(!0),w(f.v4()),Z("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===C.portalTheme})]})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:S<=545||_<=350||T,isInputFocused:T,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){M.current&&M.current.onSubmit(t)})),smitheryAuthData:U,resubmitPrompt:()=>{X(null),Q(!0)}}),t.jsx(c.default,{ref:M,onFocus:()=>H(!0),onBlur:()=>H(!1),onInputHeightChange:A,initSmitheryAuthData:e=>X(e),resubmitPrompt:J})]})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:x,limits:S={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:k="en",opacity:I=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:E=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:H=!1,isDropShadow:L=!1,isEmailLogin:M=!1,allowGuestUsage:R=!0,onGenerateComplete:_})=>{const[A,B]=i.useState(""),[G,N]=i.useState(""),[U,W]=i.useState(""),[z,J]=i.useState(""),[Y,K]=i.useState(f),[Q,V]=i.useState(p),[X,Z]=i.useState(null),[$,ee]=i.useState(!1),[te,ie]=i.useState(!0),[se,oe]=i.useState(!0),[re,ne]=i.useState(!1);return i.useEffect((()=>{ee(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!$&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{ee(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ee(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ee(!0)}}))}),[T,$,null==v?void 0:v.font]),i.useEffect((()=>{K(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:A,pickaxeId:G,sessionId:U,lastSessionId:z,sender:Y,senderType:Q,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,pickaxe:X,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},x),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},P),artifact:w,responsiveBy:F,locale:k,opacity:I,forceMobile:C,loadFont:T,disableHtml:O,disableJs:E,disableCss:D,isFontLoaded:$,isNewChat:te,isShowIceBreaker:se,isShowFeedbackMessage:re,isRtl:q,isEmbed:H,isDropShadow:L,isEmailLogin:M,allowGuestUsage:R,setContextId:B,setPickaxeId:N,setSessionId:W,setLastSessionId:J,setSender:K,setSenderType:V,setPickaxe:Z,setIsFontLoaded:ee,setIsNewChat:ie,setIsShowIceBreaker:oe,setIsShowFeedbackMessage:ne},_&&{onGenerateComplete:_})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:x,limits:S={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:k="en",opacity:I=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:D=!1,disableCss:T=!1,loadFont:q=!0,isRtl:E=!1,isEmbed:H=!1,isDropShadow:M=!1,allowGuestUsage:R=!0,onGenerateComplete:_})=>{const[A,L]=i.useState(""),[B,G]=i.useState(""),[N,U]=i.useState(""),[W,z]=i.useState(""),[J,Y]=i.useState(f),[K,Q]=i.useState(p),[V,X]=i.useState(null),[Z,$]=i.useState(!1),[ee,te]=i.useState(!0),[ie,se]=i.useState(!0),[oe,re]=i.useState(!1);return i.useEffect((()=>{$(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!Z&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{$(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),$(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),$(!0)}}))}),[q,Z,null==v?void 0:v.font]),i.useEffect((()=>{Y(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:A,pickaxeId:B,sessionId:N,lastSessionId:W,sender:J,senderType:K,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,pickaxe:V,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},x),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},P),artifact:w,responsiveBy:F,locale:k,opacity:I,forceMobile:C,loadFont:q,disableHtml:O,disableJs:D,disableCss:T,isFontLoaded:Z,isNewChat:ee,isShowIceBreaker:ie,isShowFeedbackMessage:oe,isRtl:E,isEmbed:H,isDropShadow:M,allowGuestUsage:R,setContextId:L,setPickaxeId:G,setSessionId:U,setLastSessionId:z,setSender:Y,setSenderType:Q,setPickaxe:X,setIsFontLoaded:$,setIsNewChat:te,setIsShowIceBreaker:se,setIsShowFeedbackMessage:re},_&&{onGenerateComplete:_})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("./PickaxeButton.js"),r=require("./PickaxeCommon.js"),n=require("./PickaxeCurrency.js"),o=require("./PickaxeAvatar.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../common/api/pickaxe.js"),d=require("../../../common/utils.js"),u=require("../../../hooks/pickaxe/useResponseContext.js");exports.default=({data:x,children:m,upgradeUrl:p})=>{var f;const{limitData:j}=u.useResponseContext(),{colors:b,sender:v,pickaxe:h}=t.usePickaxeContext(),{token:k}=c.useAuthContext(),y=i.useMemo((()=>{var e;return null!==(e=x.displayName)&&void 0!==e?e:x.name}),[x]),g=i.useMemo((()=>{var e;return null!==(e=x.displayDescription)&&void 0!==e?e:x.description}),[x]),O=i.useMemo((()=>{var e;const{price:s,priceInterval:i,currency:t}=x;if(!s)return{price:"Free",suffix:""};const a=r.intervalToSuffix(i,!0);return{price:`${(null!==(e=n.currencyOptions.find((e=>e.id===t)))&&void 0!==e?e:n.currencyOptions[0]).symbol}${s.toLocaleString()}`,suffix:a}}),[x]),w=i.useMemo((()=>{const{limit:e,limitInterval:s}=x;if(e===r.STUDIO_INFINITY_VALUE)return{limit:"Unlimited",suffix:""};const i=r.intervalToSuffix(s,!0);return{limit:e.toLocaleString(),suffix:i}}),[x]);return s.jsxs("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[m,s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs(o.Avatar,Object.assign({className:"h-8 w-8"},{children:[s.jsx(o.AvatarImage,{src:null!==(f=x.image)&&void 0!==f?f:"",alt:y}),s.jsx(o.AvatarFallback,{})]})),s.jsx("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:y},{children:y})),Boolean(g)&&s.jsx("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:g})),s.jsxs("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[O.price,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:O.suffix}))]}))]})),s.jsxs("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:b.secondaryText}},{children:[s.jsx("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:"USES"})),s.jsxs("p",Object.assign({className:"text-base font-semibold"},{children:[w.limit,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:w.suffix}))]}))]}))]})),s.jsx(a.default,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>{v||k?e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield l.default.post("/access_group_checkout",{data:{studioUserId:v||void 0,studioId:null==h?void 0:h.studioid,accessGroupId:x.accessGroupId,successUrl:document.URL,isEmbed:d.isInIframe(),studioSessionToken:k}});if(e.data.success){const s=e.data.url;if(s)if(d.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s;else window.location.reload()}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}})):window.open(p||(null==j?void 0:j.limitLink))}},{children:x.ctaButtonText}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("./PickaxeButton.js"),a=require("./PickaxeCommon.js"),n=require("./PickaxeCurrency.js"),o=require("./PickaxeAvatar.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../common/api/pickaxe.js"),u=require("../../../common/utils.js"),d=require("../../../hooks/pickaxe/useResponseContext.js"),x=require("../Addons/Auth/hooks/useAuth.js");exports.default=({data:m,children:p,upgradeUrl:f})=>{var j;const{limitData:h}=d.useResponseContext(),{colors:v,sender:b,pickaxe:k}=t.usePickaxeContext(),{token:g}=c.useAuthContext(),{onOpenPricing:y}=x.useAuth(),O=i.useMemo((()=>{var e;return null!==(e=m.displayName)&&void 0!==e?e:m.name}),[m]),I=i.useMemo((()=>{var e;return null!==(e=m.displayDescription)&&void 0!==e?e:m.description}),[m]),w=i.useMemo((()=>{var e;const{price:s,priceInterval:i,currency:t}=m;if(!s)return{price:"Free",suffix:""};const r=a.intervalToSuffix(i,!0);return{price:`${(null!==(e=n.currencyOptions.find((e=>e.id===t)))&&void 0!==e?e:n.currencyOptions[0]).symbol}${s.toLocaleString()}`,suffix:r}}),[m]),N=i.useMemo((()=>{const{limit:e,limitInterval:s}=m;if(e===a.STUDIO_INFINITY_VALUE)return{limit:"Unlimited",suffix:""};const i=a.intervalToSuffix(s,!0);return{limit:e.toLocaleString(),suffix:i}}),[m]);return s.jsxs("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:v.secondary,color:v.secondaryText}},{children:[p,s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs(o.Avatar,Object.assign({className:"h-8 w-8"},{children:[s.jsx(o.AvatarImage,{src:null!==(j=m.image)&&void 0!==j?j:"",alt:O}),s.jsx(o.AvatarFallback,{})]})),s.jsx("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:O},{children:O})),Boolean(I)&&s.jsx("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:I})),s.jsxs("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[w.price,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:w.suffix}))]}))]})),s.jsxs("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:v.secondaryText}},{children:[s.jsx("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:"USES"})),s.jsxs("p",Object.assign({className:"text-base font-semibold"},{children:[N.limit,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:N.suffix}))]}))]}))]})),s.jsx(r.default,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>{if(g)e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield l.default.post("/access_group_checkout",{data:{studioUserId:b||void 0,studioId:null==k?void 0:k.studioid,accessGroupId:m.accessGroupId,successUrl:document.URL,isEmbed:u.isInIframe(),studioSessionToken:g}});if(e.data.success){const s=e.data.url;if(s)if(u.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s;else window.location.reload()}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}}));else{const e=f||`${null==h?void 0:h.limitLink}?redirectUrl=${document.URL}`;u.isInIframe()?y(f||(null==h?void 0:h.limitLink)):window.location.href=e}}},{children:m.ctaButtonText}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("framer-motion"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),u=require("../../Core/HtmlRenderer.js"),d=require("./PickaxeButton.js"),x=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("./AccessGroupCardPreview.js");const j=({price:e,uses:t,isSelected:r,onClick:a,colors:o})=>s.jsxs("button",Object.assign({onClick:a,className:x.default("flex items-center gap-2 rounded-xl border px-4 py-3 shadow-sm transition-all duration-200 shrink-0",r?"border-2":"border opacity-80 hover:opacity-100"),style:{backgroundColor:o.secondary,color:o.secondaryText,borderColor:r?o.secondaryText:"rgba(0,0,0,0.1)"}},{children:[s.jsxs("span",Object.assign({className:"text-xl font-bold"},{children:["$",e]})),s.jsxs("span",Object.assign({className:"text-sm opacity-70"},{children:["/ ",t.toLocaleString()," uses"]}))]}));exports.default=({className:b,iconClassName:h,htmlClassName:g})=>{var y,v;const{colors:w,pickaxe:k,sender:C}=a.usePickaxeContext(),{token:N}=m.useAuthContext(),{limitData:q}=o.useResponseContext(),O=l.useStyleFontSize(),[_,A]=t.useState(0),S=window.location.href.includes("_embed"),U=i.isInIframe()&&!S?"_self":"_top";if(t.useEffect((()=>{var e;(null===(e=null==q?void 0:q.buyUses)||void 0===e?void 0:e.length)&&A(0)}),[q]),!q)return null;const I=q.limitLink,P=q.limitCTA,G=Array.isArray(q.upgradeGroups)&&q.upgradeGroups.length>0,T=Array.isArray(q.buyUses)&&q.buyUses.length>0,L=T&&Array.isArray(q.buyUses)&&q.buyUses[_];return s.jsx(r.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:x.default("flex flex-col gap-5 w-full",b)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:w.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:x.default("h-5 w-5 shrink-0 mt-0.5",h),style:{color:w.accent}}),s.jsx(u.default,{className:x.default(O.b2,"font-semibold leading-relaxed text-sm",g),style:{color:w.text},html:q.limitMessage||""})]})),P&&s.jsx("a",Object.assign({href:I,target:U,rel:"noreferrer",className:"shrink-0 w-full sm:w-auto"},{children:s.jsx(d.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm"},{children:P}))}))]})),G&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Available Plans"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(y=q.upgradeGroups)||void 0===y?void 0:y.map(((e,t)=>s.jsx(f.default,{data:e},e.accessGroupId||t)))}))]})),T&&L&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Buy Credits"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null===(v=q.buyUses)||void 0===v?void 0:v.map(((e,t)=>s.jsx(j,{price:e.price,uses:e.uses,isSelected:t===_,onClick:()=>A(t),colors:w},t)))})),s.jsxs(d.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>{return s=L.uses,t=L.price,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield p.default.post("/get_extra_usage_payment_link",{data:{sender:C||void 0,studioSessionToken:N,studioId:null==k?void 0:k.studioid,cost:t,extraUses:s,successUrl:document.URL}});if(e.data.success){const s=e.data.url;if(i.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}}));var s,t}},{children:["Buy ",L.uses.toLocaleString()," Uses for $",L.price]}))]}))]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("framer-motion"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),u=require("../../Core/HtmlRenderer.js"),d=require("./PickaxeButton.js"),x=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("./AccessGroupCardPreview.js"),j=require("../Addons/Auth/hooks/useAuth.js");const h=({price:e,uses:t,isSelected:r,onClick:a,colors:o})=>s.jsxs("button",Object.assign({onClick:a,className:x.default("flex items-center gap-2 rounded-xl border px-4 py-3 shadow-sm transition-all duration-200 shrink-0",r?"border-2":"border opacity-80 hover:opacity-100"),style:{backgroundColor:o.secondary,color:o.secondaryText,borderColor:r?o.secondaryText:"rgba(0,0,0,0.1)"}},{children:[s.jsxs("span",Object.assign({className:"text-xl font-bold"},{children:["$",e]})),s.jsxs("span",Object.assign({className:"text-sm opacity-70"},{children:["/ ",t.toLocaleString()," uses"]}))]}));exports.default=({className:b,iconClassName:g,htmlClassName:y})=>{var v,k;const{colors:w,pickaxe:C,sender:N}=a.usePickaxeContext(),{token:A}=m.useAuthContext(),{limitData:q}=o.useResponseContext(),O=i.useStyleFontSize(),[U,_]=t.useState(0),{onOpenPricing:S}=j.useAuth();if(t.useEffect((()=>{var e;(null===(e=null==q?void 0:q.buyUses)||void 0===e?void 0:e.length)&&_(0)}),[q]),!q)return null;const P=q.limitLink,I=q.limitCTA,G=Array.isArray(q.upgradeGroups)&&q.upgradeGroups.length>0,L=Array.isArray(q.buyUses)&&q.buyUses.length>0,R=L&&Array.isArray(q.buyUses)&&q.buyUses[U];return s.jsx(r.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:x.default("flex flex-col gap-5 w-full",b)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:w.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:x.default("h-5 w-5 shrink-0 mt-0.5",g),style:{color:w.accent}}),s.jsx(u.default,{className:x.default(O.b2,"font-semibold leading-relaxed text-sm",y),style:{color:w.text},html:q.limitMessage||""})]})),I&&s.jsx(d.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>{l.isInIframe()?A?window.open(P):S(P):window.location.href=`${P}?redirectUrl=${document.URL}`}},{children:I}))]})),G&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Available Plans"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(v=q.upgradeGroups)||void 0===v?void 0:v.map(((e,t)=>s.jsx(f.default,{data:e},e.accessGroupId||t)))}))]})),L&&R&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Buy Credits"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null===(k=q.buyUses)||void 0===k?void 0:k.map(((e,t)=>s.jsx(h,{price:e.price,uses:e.uses,isSelected:t===U,onClick:()=>_(t),colors:w},t)))})),s.jsxs(d.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>{return s=R.uses,t=R.price,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield p.default.post("/get_extra_usage_payment_link",{data:{sender:N||void 0,studioSessionToken:A,studioId:null==C?void 0:C.studioid,cost:t,extraUses:s,successUrl:document.URL}});if(e.data.success){const s=e.data.url;if(l.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}}));var s,t}},{children:["Buy ",R.uses.toLocaleString()," Uses for $",R.price]}))]}))]}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js");exports.Pickaxe=({pickaxeId:g,className:b})=>{const{sessionId:v,styles:w,colors:y,responsiveBy:k,deploymentType:q,isNewChat:N,isEmailLogin:O,isEmbed:C,opacity:A,deploymentId:_,sender:P,portalId:S,setContextId:I,setPickaxeId:E,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isLoggedOut:R,isSent:M,token:T}=l.useAuthContext(),{setMessages:U,setResponse:F,setError:G,setLimitData:$,setIsSwitchedToChat:B}=r.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:W}=o.useArtifactContext(),[z,J]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===q&&N&&!M,te="chat-input"!==q||!M;a.useEffect((()=>{E(g)}),[g]),a.useEffect((()=>{if(!_&&!S||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:_,sender:P||void 0,studioSessionToken:T,portalId:S,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),J(!0)):"Access denied."===s.data.message?(Q("access_denied"),J(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),J(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[_,P,T,S,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),I(n.v4()),e?U([]):F(null),G(""),H(""),$(null),W(null),B(!1),L(ee.data),J(!0)}),[ee.data]),a.useEffect((()=>{G(""),H(""),$(null),U([]),F(null),W(null)}),[v]);const ae=a.useMemo((()=>{const e=null!=A?A:1;if(!y.primary||!y.primary.startsWith("#")||e<0||e>1)return y.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${y.primary}${s}`}),[y.primary,A]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",b),style:Object.assign({backgroundColor:se?"transparent":ae,color:y.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!z||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===k?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C||O&&R&&te?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):v?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),v=require("../Icons/lock.svg.js");exports.Pickaxe=({pickaxeId:b,className:k})=>{const{sessionId:y,styles:w,colors:N,responsiveBy:q,deploymentType:O,isNewChat:A,isEmbed:C,opacity:_,deploymentId:S,sender:I,portalId:P,setContextId:E,setPickaxeId:R,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isSent:T,token:G}=r.useAuthContext(),{setMessages:F,setResponse:M,setError:U,setLimitData:$,setIsSwitchedToChat:B}=l.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:J}=o.useArtifactContext(),[W,z]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===O&&A&&!T;a.useEffect((()=>{R(b)}),[b]);a.useEffect((()=>{if(!S&&!P||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:S,sender:I||void 0,studioSessionToken:G,portalId:P,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),z(!0)):"Access denied."===s.data.message?(Q("access_denied"),X(s.data.upgradeGroups||[]),z(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),z(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[S,I,G,P,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),E(n.v4()),e?F([]):M(null),U(""),H(""),$(null),J(null),B(!1),L(ee.data),z(!0)}),[ee.data]),a.useEffect((()=>{U(""),H(""),$(null),F([]),M(null),J(null)}),[y]);const te=a.useMemo((()=>{const e=null!=_?_:1;if(!N.primary||!N.primary.startsWith("#")||e<0||e>1)return N.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${N.primary}${s}`}),[N.primary,_]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",k),style:Object.assign({backgroundColor:se?"transparent":te,color:N.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!W||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===q?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===q?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(g.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(g.AvatarImage,{src:null===(ae=ee.data)||void 0===ae?void 0:ae.coverphoto,alt:`${null===(ie=ee.data)||void 0===ie?void 0:ie.formtitle} Logo`}),s.jsx(g.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(v.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:N.accent,color:N.accentText,borderRadius:w.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=V.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:I||void 0,studioSessionToken:G,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolName:null===(s=ee.data)||void 0===s?void 0:s.formtitle,accessGroupIds:t})}});a.data.success?alert("Successfully requested access!"):alert(a.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):y?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var ae,ie};
@@ -1 +1 @@
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};
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};