@pickaxeproject/react 6.14.1 → 6.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/agentPrefill.js +1 -0
- package/dist/cjs/common/date.js +1 -0
- package/dist/cjs/common/documents.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/src/common/agentPrefill.d.ts +14 -0
- package/dist/cjs/src/common/date.d.ts +13 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +3 -1
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/esm/common/agentPrefill.js +1 -0
- package/dist/esm/common/date.js +1 -0
- package/dist/esm/common/documents.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/index.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/src/common/agentPrefill.d.ts +14 -0
- package/dist/esm/src/common/date.d.ts +13 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +3 -1
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="agent_prefill";exports.AGENT_PREFILL_PARAM=e,exports.readAgentPrefill=(t=[],n)=>{var l,o,r;const i=null!=n?n:"undefined"==typeof window?"":window.location.search,s=new URLSearchParams(i),u=new Map,c=`${e}[`,f=Array.from(new Set(t.filter((e=>!!e))));for(const[e,t]of s){if(!e.startsWith(c)||!e.endsWith("]"))continue;const n=e.slice(c.length,-1);if(!n||n.includes("]["))continue;const o=null!==(l=u.get(n))&&void 0!==l?l:[];o.push(t),u.set(n,o)}for(const t of[...f].reverse()){const n=new Map,l=`${e}[${t}][`;for(const[e,t]of s){if(!e.startsWith(l)||!e.endsWith("]"))continue;const r=e.slice(l.length,-1);if(!r||r.includes("]["))continue;const i=null!==(o=n.get(r))&&void 0!==o?o:[];i.push(t),n.set(r,i)}for(const[e,t]of n)u.set(e,t)}const p=f.map((t=>s.get(`${e}[${t}]`))).find((e=>null!==e));return{chatInput:null!==(r=null!=p?p:s.get(e))&&void 0!==r?r:"",formInputs:u}},exports.resolveAgentFormPrefill=(e,t)=>{if(!(null==t?void 0:t.length))return null;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)return null;const n="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther,l=e.example.split("S3P32X");if("Multiple Choice"===e.type||"multiple"===e.type){const e=t[0];return l.includes(e)||n&&e?e:null}if("Checkbox"===e.type){const e=Array.from(new Set(t.filter((e=>e&&l.includes(e))))),o=n?t.find((e=>e&&!l.includes(e))):void 0;return o&&e.push(o),e.length?e.join(","):null}return t[0]};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("date-fns");const t=/(?:z|[+-]\d{2}:?\d{2})$/i,r=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/,a=e=>{if(e instanceof Date||"number"==typeof e)return new Date(e);const a=e.trim(),s=r.test(a)&&!t.test(a)?`${a.replace(" ","T")}Z`:a;return new Date(s)};exports.formatLocalDateTime=(t,r)=>{const s=a(t);return Number.isNaN(s.getTime())?"":e.format(s,r)},exports.parseUtcDateTime=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".doc",".md",".html",".htm"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/html","application/xml","text/xml","audio/mpeg","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".doc",".md",".html",".htm",".wav"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/html","application/xml","text/xml","audio/mpeg","audio/wav","audio/x-wav","audio/wave","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),I=require("../../Icons/arrow-right.svg.js"),b=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),x=require("../Addons/Document/List.js"),j=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),O=require("../../../common/error.js"),w=require("../../../common/chatMessages.js"),N=require("../../../common/api/pickaxe.js"),_=require("../../../common/validation.js"),k=require("../../../common/cn.js"),E=require("../../../common/utils.js"),T=require("../../../common/pickaxeConfig.js"),U=require("../../../common/deploymentWebhooks.js"),C=require("../../../hooks/studio/useStudio.js"),A=require("../../../hooks/pickaxe/useSpeechToText.js"),D=require("../common/PickaxeCommon.js");const P=e=>"string"==typeof e&&e.trim().length>0,L=e=>e.map((e=>Object.assign({},e))),M=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),R=(e,t)=>{if(e&&"object"==typeof e)return e[t]},q=(e,t)=>{const s=R(e,t);return P(s)?s:null},F=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},V=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(R(e,"uses"))?R(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>P(e)?{type:"deployment",id:e}:P(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},B=s.forwardRef((({resubmitPrompt:R,onFocus:B,onBlur:$,onInputHeightChange:X,initSmitheryAuthData:H},K)=>{var W,Y,z,G,J,Q,Z,ee,te,se,ne,ie;const{origin:re,pickaxeId:oe,sessionId:ae,sender:le,senderType:de,portalId:ce,deploymentId:ue,deploymentType:pe,pickaxe:me,styles:fe,colors:ge,translations:ve,locale:he,forceMobile:Ie,isNewChat:be,isRtl:ye,isShowFeedbackMessage:xe,accessGroup:je,setIsNewChat:Se,setIsShowIceBreaker:Oe,setValidationStatus:we,setValidationUpgradeGroups:Ne,setValidationUpgradeUrl:_e,setAccessGroup:ke,onGenerateComplete:Ee}=n.usePickaxeContext(),{token:Te,isLoggedOut:Ue,isSent:Ce,isPricingAuth:Ae}=d.useAuthContext(),{messages:De,isGenerating:Pe,setMessages:Le,setStatus:Me,setLimitData:Re,setError:qe}=i.useResponseContext(),{documents:Fe,isUploading:Ve,documentError:Be,onFileUpload:$e,setDocuments:Xe,setDocumentError:He}=c.useDocument(),{studio:Ke}=C.useStudio(),[We]=f.useMediaQuery("(max-width: 480px)"),{scrollStartSession:Ye,scrollEndSession:ze,scrollToBottom:Ge}=u.useScroll({auto:!0,smooth:!(Ie||We)}),{artifacts:Je,currentPopupType:Qe,setArtifacts:Ze,setCurrentArtifact:et}=p.useArtifactContext(),{height:tt}=l.useDimensionContext(),st=a.useConversation(),[nt,it]=s.useState(""),[rt,ot]=s.useState(!1),[at,lt]=s.useState(!1),[dt,ct]=s.useState(null),[ut,pt]=s.useState(null),[mt,ft]=s.useState(!1),[gt,vt]=s.useState(!1),[ht,It]=s.useState(0),bt=s.useRef(null),yt=s.useRef(""),xt=s.useRef(null),jt=s.useRef(null),St=s.useRef(null),Ot=s.useRef([]),wt=s.useRef(null),Nt=s.useRef(null),_t=s.useRef(null),kt=s.useRef(null),Et=s.useRef(new Set),Tt=s.useRef(null),Ut=Math.max(.4*tt,100),{speechTranscript:Ct,isSpeechListening:At,isSpeechProcessing:Dt,isSpeechSupported:Pt,onStartListening:Lt,onStopListening:Mt}=A.useSpeechToText(),Rt=m.useHover(),{isHover:qt}=Rt,Ft=e.__rest(Rt,["isHover"]),Vt=m.useHover(),{isHover:Bt}=Vt,$t=e.__rest(Vt,["isHover"]),Xt=m.useHover(),{isHover:Ht}=Xt,Kt=e.__rest(Xt,["isHover"]),Wt=o.useStyleFontSize(),Yt=r.useStyleInput(),zt="undefined"!=typeof window?window.location.hostname:"",Gt="undefined"!=typeof window?window.location.href:"",Jt="undefined"!=typeof window&&window.self!==window.top,Qt=zt.includes("pickaxe.co")&&!Gt.includes("https://studio.pickaxe.co/_embed")&&!Jt,Zt=null!==(Y=null===(W=null==me?void 0:me.documentuploadtype)||void 0===W?void 0:W.startsWith("enduserupload"))&&void 0!==Y&&Y,es=Pt&&(null==me?void 0:me.enablevoicetotext),ts=P(ue),ss="chat-input"===pe&&be&&!Ce,ns="chat-input"===pe&&Ae&&Ue&&Ce,is=s.useCallback((e=>{const t=_.getValidationFailure(e);return!!t&&(qe(""),Re(null),we(t.status),ke(t.accessGroup),Ne(t.upgradeGroups),_e(t.upgradeUrl),!0)}),[qe,Re,we,Ne,_e,ke]),rs=null!==(z=null==me?void 0:me.placeholdertext)&&void 0!==z?z:ye?"بماذا تريد أن تتحدث؟":(null==ve?void 0:ve["what-do-you-want-to-talk-about"])||"What do you want to talk about?",os=rt||at,as=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){ft(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==me?void 0:me.studioid},Te?{studioSessionToken:Te}:le?{sender:le}:{sender:E.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Qt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(ct(t.studioUser),pt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{ft(!0)}}))),[Qt,null==me?void 0:me.studioid,le,Te]);s.useEffect((()=>{as()}),[as]);const ls=Number(null!==(G=null==je?void 0:je.limit)&&void 0!==G?G:0),ds="string"==typeof(null==je?void 0:je.limitInterval)?je.limitInterval:null,cs=!!(null==Ke?void 0:Ke.data.usage)&&Ke.data.usage.isCredits,us=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=ce?ce:q(dt,"portalId"))&&void 0!==e?e:q(dt,"portalid"))&&void 0!==t?t:q(je,"portalId"))&&void 0!==s?s:q(je,"portalid"))&&void 0!==n?n:q(me,"portalId"))&&void 0!==i?i:q(me,"portalid")}),[je,ce,me,dt]),ps=s.useMemo((()=>V({studioUser:dt,deploymentId:ue,portalId:us})),[ue,us,dt]);s.useEffect((()=>{ts&&be&&ae&&Et.current.add(ae)}),[be,ae,ts]);const ms=s.useCallback((()=>{var e,t,s;return{studioId:null==me?void 0:me.studioid,userEmail:q(dt,"email"),userId:null!==(e=q(dt,"userId"))&&void 0!==e?e:q(dt,"userid"),sessionId:ae,deploymentId:ue,deploymentType:pe,portalId:us,accessGroupId:null!==(t=null==je?void 0:je.accessGroupId)&&void 0!==t?t:null,pickaxeId:oe,sender:le,senderType:de,origin:re,metadata:null!==(s=T.getPickaxeConfigMetadata(ue))&&void 0!==s?s:null}}),[null==je?void 0:je.accessGroupId,ue,pe,re,null==me?void 0:me.studioid,oe,us,le,de,ae,dt]),fs=s.useCallback((()=>!!(ts&&mt&&ae)&&(!!Et.current.has(ae)&&(U.fireDeploymentSessionInitializedWebhook(ms()),Et.current.delete(ae),!0))),[ms,mt,ae,ts]);s.useEffect((()=>{if(!mt||!ae)return;fs();const e=Tt.current;(null==e?void 0:e.sessionId)===ae&&(U.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),ms()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),Tt.current=null)}),[fs,ms,mt,ae]);const gs={currentUses:F(null==dt?void 0:dt.currentUses),extraUses:F(null==dt?void 0:dt.extraUses)},vs=ps.scope?{currentUses:null!==(Q=F(null===(J=ps.record)||void 0===J?void 0:J.currentUses))&&void 0!==Q?Q:0,extraUses:null!==(ee=F(null===(Z=ps.record)||void 0===Z?void 0:Z.extraUses))&&void 0!==ee?ee:0}:{currentUses:0,extraUses:0},hs=q(dt,"type"),Is="guest"===hs||!hs&&Ue?vs:gs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(cs&&(null===(e=null==Ke?void 0:Ke.data)||void 0===e?void 0:e.workspaceId))try{const e=yield N.pickaxeApi2.get(`/cost_per_run?workspaceId=${Ke.data.workspaceId}`,{withCredentials:!1});t&&It(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&It(0)}else t&&It(0)})),()=>{t=!1}}),[cs,null===(te=null==Ke?void 0:Ke.data)||void 0===te?void 0:te.workspaceId]);const bs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===D.STUDIO_INFINITY_VALUE||r===D.STUDIO_INFINITY_VALUE?D.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:Is.currentUses,extraUses:Is.extraUses,limit:ls,limitInterval:ds}),ys=bs===D.STUDIO_INFINITY_VALUE?D.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(bs)),xs=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===D.STUDIO_INFINITY_VALUE||n===D.STUDIO_INFINITY_VALUE?D.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:Is.extraUses,limit:ls,limitInterval:ds}),js=xs===D.STUDIO_INFINITY_VALUE?D.STUDIO_INFINITY_VALUE:Math.ceil(.05*xs),Ss=cs?Math.ceil(5*ht):5,Os=js===D.STUDIO_INFINITY_VALUE?D.STUDIO_INFINITY_VALUE:Math.max(js,Ss),ws=s.useMemo((()=>!!dt&&(!gt&&(ys!==D.STUDIO_INFINITY_VALUE&&(!(ys<=0)&&ys<=Os)))),[gt,Os,ys,dt]),Ns=Boolean(null==je?void 0:je.hideUpgradeOptions),_s=!Ns&&(null===(se=null==je?void 0:je.upgrade)||void 0===se?void 0:se.isLinkToCustomURL)&&"string"==typeof je.upgrade.limitLink&&je.upgrade.limitLink.trim().length>0?je.upgrade.limitLink.trim():null,ks=_s&&"string"==typeof(null===(ne=null==je?void 0:je.upgrade)||void 0===ne?void 0:ne.limitCTA)&&je.upgrade.limitCTA.trim().length>0?je.upgrade.limitCTA:(null==ve?void 0:ve["pricing.upgrade"])||(null==ve?void 0:ve.upgrade)||"Upgrade",Es=s.useMemo((()=>{var e,t,s;return!!be&&(!!me&&(!st.isLoading&&(!((null!==(t=null===(e=st.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=me.icebreakers)||void 0===s?void 0:s.length)&&(!xe&&!ss)))))}),[me,be,xe,ss,st.data,st.isLoading]),Ts=s.useMemo((()=>{if(Pe||Ve)return!1;const e=Zt&&Fe.length>0&&Fe.every((e=>"finished"===e.status));return!(!nt.trim()&&!e)&&Fe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Zt,Pe,Ve,nt,Fe]);s.useImperativeHandle(K,(()=>({onSubmit:Us}))),s.useEffect((()=>{Oe(Es)}),[Es]),s.useEffect((()=>{var e;if(R){const t=Array.from(De),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Us(s,!0)}}),[R]),s.useEffect((()=>{if(!_t.current||!X)return;const e=new ResizeObserver((e=>{for(const t of e)X(t.contentRect.height)}));return e.observe(_t.current),()=>{e.disconnect()}}),[X]),s.useEffect((()=>{if(!At)return;const e=yt.current?`${yt.current} `:"";it(`${e}${Ct}`)}),[Ct,At]),s.useEffect((()=>{if(!wt.current)return;(()=>{if(!wt.current)return;let e=wt.current.scrollHeight>52;nt.includes("\n")||Fe.length?e=!0:nt.trim()||(e=!1),ot(e)})()}),[nt,Fe]),s.useEffect((()=>{const e=wt.current,t=Nt.current;if(!e||!t||rt||nt.includes("\n"))return void lt(!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=nt||rs,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;lt(r>l)}),[nt,rt,rs]);const Us=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i,r,o,a;let l=null;try{if(Pe||Ve)return;const d=Fe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),c=d.map((e=>e.documentId)).filter(Boolean),u=d.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),p=null!=t?t:nt,m=null!==(n=null===(e=null==me?void 0:me.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&c.length>0;if(!p&&!m)return;qe(""),He(""),Re(null),it(""),Se(!1),Me("fetching"),Ye(),Ge();const f=null!==(r=null===(i=st.data)||void 0===i?void 0:i.messages)&&void 0!==r?r:[],g=w.getUnpersistedMemoryMessages(De,f),h=s?g.slice(0,g.length-1):g,I=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),b=I+(s?0:1),y={id:b,role:"assistant",parts:[],documentIds:[]},x=[...h,...s?[]:[{id:I,role:"user",parts:[{type:"text",content:p,isVisible:!0}],documentIds:m?c:[]}],y];Le(x),Ge(),m&&Xe([]);const j=T.getPickaxeConfigMetadata(ue),S="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`;l=S,jt.current=S,St.current=null,Ot.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:re,pickaxeId:oe,sessionId:ae,submissionId:S,senderType:de,value:p},m&&{documentIds:c}),le&&{sender:le}),Te&&{studioSessionToken:Te}),!Te&&!le&&{sender:E.initializeEmbedUserId()}),us&&{portalId:us}),ue&&{deploymentId:ue}),j&&{metadata:j}),m&&u.length>0?{uploadedModelImages:u}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Qt&&{credentials:"include"})),N=yield O.json();if(!N.success){if(N.limitData){const e=new Error(N.error||N.message||(null==ve?void 0:ve["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=N.limitData,e}if(is(N))return;throw new Error(N.error||N.message||(null==ve?void 0:ve["failed-to-start-generation"])||"Failed to start generation")}const _=null!==(o=N.submissionId)&&void 0!==o?o:S;l=_,jt.current=_;const k=()=>St.current===_;if(k())return;ts&&be&&ae&&Et.current.add(ae);const C=Object.assign(Object.assign({},ms()),{message:p,documentIds:m?c:[],uploadedModelImages:m?u:[],hasUploadedDocuments:m,isHidden:s,metadata:null!=j?j:null});mt?(fs(),U.fireDeploymentFirstMessageSubmittedWebhook(C)):Tt.current=C,Me("streaming"),kt.current=new AbortController;const A=[];let D=[...null!=Je?Je:[]],P=0,R=!1,q="";for(;!R;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${_}?index=${P}`,{signal:null===(a=kt.current)||void 0===a?void 0:a.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();xt.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(k())R=!0;else if(e.event&&"ping"!==e.event&&P++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),qe(""),void(R=!0);const s=t.error||t.message||(null==ve?void 0:ve["something-went-wrong"])||"Something went wrong.";return is(t)||qe(s),void(R=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&H){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw R=!0,H({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw R=!0,H({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw R=!0,H({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw R=!0,H({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)q="",A.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)q+=n.delta,A[A.length-1].content=q;else if("text-end"===n.type)q="";else if("reasoning-start"===n.type)q="",A.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)q+=n.delta,A[A.length-1].content=q;else if("reasoning-end"===n.type)q="";else if(n.type.startsWith("data-")){const e=n;A.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Ot.current=L(A);const i=L(A);Le((e=>{const t=e.findIndex((e=>e.id===b)),s=Object.assign(Object.assign({},y),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ze([...D]),Qe.startsWith("inline")||et({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ze(D),Qe.startsWith("inline")||et({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ze(D),Qe.startsWith("inline")||et({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");D=D.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ze(D)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ze(D.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),qe(""),void(R=!0);const s=t.error||t.message||(null==ve?void 0:ve["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(is(t))return void(R=!0);qe(s)}else"stop"===e.event&&(R=!0)}else R=!0}});for(;;){if(k()){R=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(k()){R=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}R||k()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||M(e)||k())return void(R=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Ee||Ee(ae)}catch(e){if(M(e))return;if(e.limitData)Re(e.limitData),qe("");else{let t=O.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==ve?void 0:ve["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),is(t)||qe(t)}}finally{const e=!l||jt.current===l;Ge(),e&&(Me("idle"),ze(),xt.current=null),l&&e&&(jt.current=null,Ot.current=[]),yield as()}}));return ns?null:t.jsx("div",Object.assign({className:k.default("flex w-full flex-shrink-0 flex-col items-center",!ss&&"px-4 pb-8"),dir:ye?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:_t,className:k.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===fe.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Yt),{maxHeight:`${Ut}px`,overflowY:"auto"})},{children:[ws&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Yt.backgroundColor?`${Yt.backgroundColor}E6`:void 0,borderColor:ge.text+"20",color:ge.text,borderTopRightRadius:fe.cornerRadius+"px",borderTopLeftRadius:fe.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[ys.toLocaleString()," ",cs?(null==ve?void 0:ve.credits)||"Credits":(null==ve?void 0:ve.uses)||"Uses"," ",(null==ve?void 0:ve.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[!Ns&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:ge.accent,color:ge.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),_s)return void window.open(_s,"_blank","noopener,noreferrer");const t=E.buildUpgradeUrl({baseUrl:ut,accessGroupId:null==je?void 0:je.accessGroupId,redirectUrl:document.URL});t&&(E.isInIframe()?window.open(t):location.href=t)}},{children:ks})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>vt(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!Pe&&Fe.length>0&&t.jsx(x.default,{className:"p-4 pb-0",isDisabled:Pe}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[At&&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!==(ie=ge.accent)&&void 0!==ie?ie:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:ge.text+"90"}},{children:(null==ve?void 0:ve.listening)||"Listening..."}))]})),t.jsx(j.default,Object.assign({ref:wt,className:k.default(Wt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!nt.trim()&&!nt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ye?"text-right":"text-left",os&&"mb-12",At&&"text-transparent"),value:nt,placeholder:rs,onChange:e=>{it(e)},onKeyDown:e=>{Ie||We||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Ve||Pe||Us()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Zt)return;t.preventDefault(),Se(!1),yield $e(e)}}))},B&&{onFocus:B},$&&{onBlur:$},{dir:ye?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Nt,className:k.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",os?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!os&&Yt.backgroundColor&&{backgroundColor:Yt.backgroundColor}),{borderTopRightRadius:fe.cornerRadius+"px",borderBottomRightRadius:fe.cornerRadius+"px"})},{children:Pe?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:()=>{const t=jt.current;t&&(St.current=t,(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:jt.current))return;const e=L(Ot.current);try{yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},Qt&&{credentials:"include"}))}catch(e){console.warn("Failed to cancel submission",e)}}))})(t)),kt.current&&(kt.current.abort(),kt.current=null),xt.current&&(xt.current.cancel().catch((()=>{})),xt.current=null),Me("idle")},style:{backgroundColor:ge.accent,color:ge.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):At?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:Mt,style:{backgroundColor:ge.accent,color:ge.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Zt&&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:Bt?ge.accent+"10":void 0,color:Bt?ge.accent:ge.accent+"80"},disabled:Ve||Pe,onClick:()=>{var e;return null===(e=bt.current)||void 0===e?void 0:e.click()}},$t,{children:[t.jsx("input",{id:"file-upload",ref:bt,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Se(!1),yield $e(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),es&&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:At?ge.accent:Ht?ge.accent+"10":void 0,color:At?ge.accentText:Ht?ge.accent:ge.accent+"80"},disabled:Ve||Pe||Dt,onClick:()=>{At?Mt():(yt.current=nt,Lt(he||"en-US"))}},Kt,{children:t.jsx(b.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:qt||Ts?ge.accent:ge.accent+"10",color:qt||Ts?ge.accentText:ge.accent+"80"},disabled:!Ts,onClick:()=>Us()},Ft,{children:t.jsx(I.default,{className:k.default("h-6 w-6 shrink-0",ye&&"scale-x-[-1] transform")})}))]})}))]}))]})),Be&&t.jsx(S.default,{error:Be,className:"mt-3"})]}))}))}));B.displayName="Input",exports.default=B;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),I=require("../../Icons/arrow-right.svg.js"),b=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),x=require("../Addons/Document/List.js"),j=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),O=require("../../../common/error.js"),w=require("../../../common/chatMessages.js"),N=require("../../../common/api/pickaxe.js"),_=require("../../../common/validation.js"),k=require("../../../common/cn.js"),E=require("../../../common/utils.js"),U=require("../../../common/pickaxeConfig.js"),T=require("../../../common/agentPrefill.js"),C=require("../../../common/deploymentWebhooks.js"),A=require("../../../hooks/studio/useStudio.js"),D=require("../../../hooks/pickaxe/useSpeechToText.js"),P=require("../common/PickaxeCommon.js");const L=e=>"string"==typeof e&&e.trim().length>0,M=e=>e.map((e=>Object.assign({},e))),R=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),q=(e,t)=>{if(e&&"object"==typeof e)return e[t]},F=(e,t)=>{const s=q(e,t);return L(s)?s:null},V=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},B=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(q(e,"uses"))?q(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>L(e)?{type:"deployment",id:e}:L(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},$=s.forwardRef((({resubmitPrompt:q,onFocus:$,onBlur:X,onInputHeightChange:H,initSmitheryAuthData:K},W)=>{var Y,z,G,J,Q,Z,ee,te,se,ne,ie,re;const{origin:oe,pickaxeId:ae,sessionId:le,sender:de,senderType:ce,portalId:ue,deploymentId:pe,deploymentType:me,pickaxe:fe,styles:ge,colors:ve,translations:he,locale:Ie,forceMobile:be,isNewChat:ye,isRtl:xe,isShowFeedbackMessage:je,accessGroup:Se,setIsNewChat:Oe,setIsShowIceBreaker:we,setValidationStatus:Ne,setValidationUpgradeGroups:_e,setValidationUpgradeUrl:ke,setAccessGroup:Ee,onUpgrade:Ue,onGenerateComplete:Te}=n.usePickaxeContext(),{token:Ce,isLoggedOut:Ae,isSent:De,isPricingAuth:Pe}=d.useAuthContext(),{messages:Le,isGenerating:Me,setMessages:Re,setStatus:qe,setLimitData:Fe,setError:Ve}=i.useResponseContext(),{documents:Be,isUploading:$e,documentError:Xe,onFileUpload:He,setDocuments:Ke,setDocumentError:We}=c.useDocument(),{studio:Ye}=A.useStudio(),[ze]=f.useMediaQuery("(max-width: 480px)"),{scrollStartSession:Ge,scrollEndSession:Je,scrollToBottom:Qe}=u.useScroll({auto:!0,smooth:!(be||ze)}),{artifacts:Ze,currentPopupType:et,setArtifacts:tt,setCurrentArtifact:st}=p.useArtifactContext(),{height:nt}=l.useDimensionContext(),it=a.useConversation(),[rt,ot]=s.useState((()=>T.readAgentPrefill([pe,ae]).chatInput)),[at,lt]=s.useState(!1),[dt,ct]=s.useState(!1),[ut,pt]=s.useState(null),[mt,ft]=s.useState(null),[gt,vt]=s.useState(!1),[ht,It]=s.useState(!1),[bt,yt]=s.useState(0),xt=s.useRef(null),jt=s.useRef(""),St=s.useRef(null),Ot=s.useRef(null),wt=s.useRef(null),Nt=s.useRef([]),_t=s.useRef(null),kt=s.useRef(null),Et=s.useRef(null),Ut=s.useRef(null),Tt=s.useRef(new Set),Ct=s.useRef(null),At=Math.max(.4*nt,100),{speechTranscript:Dt,isSpeechListening:Pt,isSpeechProcessing:Lt,isSpeechSupported:Mt,onStartListening:Rt,onStopListening:qt}=D.useSpeechToText(),Ft=m.useHover(),{isHover:Vt}=Ft,Bt=e.__rest(Ft,["isHover"]),$t=m.useHover(),{isHover:Xt}=$t,Ht=e.__rest($t,["isHover"]),Kt=m.useHover(),{isHover:Wt}=Kt,Yt=e.__rest(Kt,["isHover"]),zt=o.useStyleFontSize(),Gt=r.useStyleInput(),Jt="undefined"!=typeof window?window.location.hostname:"",Qt="undefined"!=typeof window?window.location.href:"",Zt="undefined"!=typeof window&&window.self!==window.top,es=Jt.includes("pickaxe.co")&&!Qt.includes("https://studio.pickaxe.co/_embed")&&!Zt,ts=null!==(z=null===(Y=null==fe?void 0:fe.documentuploadtype)||void 0===Y?void 0:Y.startsWith("enduserupload"))&&void 0!==z&&z,ss=Mt&&(null==fe?void 0:fe.enablevoicetotext),ns=L(pe),is="chat-input"===me&&ye&&!De,rs="chat-input"===me&&Pe&&Ae&&De,os=s.useCallback((e=>{const t=_.getValidationFailure(e);return!!t&&(Ve(""),Fe(null),Ne(t.status),Ee(t.accessGroup),_e(t.upgradeGroups),ke(t.upgradeUrl),!0)}),[Ve,Fe,Ne,_e,ke,Ee]),as=null!==(G=null==fe?void 0:fe.placeholdertext)&&void 0!==G?G:xe?"بماذا تريد أن تتحدث؟":(null==he?void 0:he["what-do-you-want-to-talk-about"])||"What do you want to talk about?",ls=at||dt,ds=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){vt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==fe?void 0:fe.studioid},Ce?{studioSessionToken:Ce}:de?{sender:de}:{sender:E.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),es&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(pt(t.studioUser),ft(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{vt(!0)}}))),[es,null==fe?void 0:fe.studioid,de,Ce]);s.useEffect((()=>{ds()}),[ds]);const cs=Number(null!==(J=null==Se?void 0:Se.limit)&&void 0!==J?J:0),us="string"==typeof(null==Se?void 0:Se.limitInterval)?Se.limitInterval:null,ps=!!(null==Ye?void 0:Ye.data.usage)&&Ye.data.usage.isCredits,ms=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=ue?ue:F(ut,"portalId"))&&void 0!==e?e:F(ut,"portalid"))&&void 0!==t?t:F(Se,"portalId"))&&void 0!==s?s:F(Se,"portalid"))&&void 0!==n?n:F(fe,"portalId"))&&void 0!==i?i:F(fe,"portalid")}),[Se,ue,fe,ut]),fs=s.useMemo((()=>B({studioUser:ut,deploymentId:pe,portalId:ms})),[pe,ms,ut]);s.useEffect((()=>{ns&&ye&&le&&Tt.current.add(le)}),[ye,le,ns]);const gs=s.useCallback((()=>{var e,t,s;return{studioId:null==fe?void 0:fe.studioid,userEmail:F(ut,"email"),userId:null!==(e=F(ut,"userId"))&&void 0!==e?e:F(ut,"userid"),sessionId:le,deploymentId:pe,deploymentType:me,portalId:ms,accessGroupId:null!==(t=null==Se?void 0:Se.accessGroupId)&&void 0!==t?t:null,pickaxeId:ae,sender:de,senderType:ce,origin:oe,metadata:null!==(s=U.getPickaxeConfigMetadata(pe))&&void 0!==s?s:null}}),[null==Se?void 0:Se.accessGroupId,pe,me,oe,null==fe?void 0:fe.studioid,ae,ms,de,ce,le,ut]),vs=s.useCallback((()=>!!(ns&>&&le)&&(!!Tt.current.has(le)&&(C.fireDeploymentSessionInitializedWebhook(gs()),Tt.current.delete(le),!0))),[gs,gt,le,ns]);s.useEffect((()=>{if(!gt||!le)return;vs();const e=Ct.current;(null==e?void 0:e.sessionId)===le&&(C.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),gs()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),Ct.current=null)}),[vs,gs,gt,le]);const hs={currentUses:V(null==ut?void 0:ut.currentUses),extraUses:V(null==ut?void 0:ut.extraUses)},Is=fs.scope?{currentUses:null!==(Z=V(null===(Q=fs.record)||void 0===Q?void 0:Q.currentUses))&&void 0!==Z?Z:0,extraUses:null!==(te=V(null===(ee=fs.record)||void 0===ee?void 0:ee.extraUses))&&void 0!==te?te:0}:{currentUses:0,extraUses:0},bs=F(ut,"type"),ys="guest"===bs||!bs&&Ae?Is:hs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(ps&&(null===(e=null==Ye?void 0:Ye.data)||void 0===e?void 0:e.workspaceId))try{const e=yield N.pickaxeApi2.get(`/cost_per_run?workspaceId=${Ye.data.workspaceId}`,{withCredentials:!1});t&&yt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&yt(0)}else t&&yt(0)})),()=>{t=!1}}),[ps,null===(se=null==Ye?void 0:Ye.data)||void 0===se?void 0:se.workspaceId]);const xs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===P.STUDIO_INFINITY_VALUE||r===P.STUDIO_INFINITY_VALUE?P.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:ys.currentUses,extraUses:ys.extraUses,limit:cs,limitInterval:us}),js=xs===P.STUDIO_INFINITY_VALUE?P.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(xs)),Ss=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===P.STUDIO_INFINITY_VALUE||n===P.STUDIO_INFINITY_VALUE?P.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:ys.extraUses,limit:cs,limitInterval:us}),Os=Ss===P.STUDIO_INFINITY_VALUE?P.STUDIO_INFINITY_VALUE:Math.ceil(.05*Ss),ws=ps?Math.ceil(5*bt):5,Ns=Os===P.STUDIO_INFINITY_VALUE?P.STUDIO_INFINITY_VALUE:Math.max(Os,ws),_s=s.useMemo((()=>!!ut&&(!ht&&(js!==P.STUDIO_INFINITY_VALUE&&js<=Ns))),[ht,Ns,js,ut]),ks=Boolean(null==Se?void 0:Se.hideUpgradeOptions),Es=!ks&&(null===(ne=null==Se?void 0:Se.upgrade)||void 0===ne?void 0:ne.isLinkToCustomURL)&&"string"==typeof Se.upgrade.limitLink&&Se.upgrade.limitLink.trim().length>0?Se.upgrade.limitLink.trim():null,Us=Es&&"string"==typeof(null===(ie=null==Se?void 0:Se.upgrade)||void 0===ie?void 0:ie.limitCTA)&&Se.upgrade.limitCTA.trim().length>0?Se.upgrade.limitCTA:(null==he?void 0:he["pricing.upgrade"])||(null==he?void 0:he.upgrade)||"Upgrade",Ts=s.useMemo((()=>{var e,t,s;return!!ye&&(!!fe&&(!it.isLoading&&(!((null!==(t=null===(e=it.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=fe.icebreakers)||void 0===s?void 0:s.length)&&(!je&&!is)))))}),[fe,ye,je,is,it.data,it.isLoading]),Cs=s.useMemo((()=>{if(Me||$e)return!1;const e=ts&&Be.length>0&&Be.every((e=>"finished"===e.status));return!(!rt.trim()&&!e)&&Be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ts,Me,$e,rt,Be]);s.useImperativeHandle(W,(()=>({onSubmit:As}))),s.useEffect((()=>{we(Ts)}),[Ts]),s.useEffect((()=>{var e;if(q){const t=Array.from(Le),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;As(s,!0)}}),[q]),s.useEffect((()=>{if(!Et.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(Et.current),()=>{e.disconnect()}}),[H]),s.useEffect((()=>{if(!Pt)return;const e=jt.current?`${jt.current} `:"";ot(`${e}${Dt}`)}),[Dt,Pt]),s.useEffect((()=>{if(!_t.current)return;(()=>{if(!_t.current)return;let e=_t.current.scrollHeight>52;rt.includes("\n")||Be.length?e=!0:rt.trim()||(e=!1),lt(e)})()}),[rt,Be]),s.useEffect((()=>{const e=_t.current,t=kt.current;if(!e||!t||at||rt.includes("\n"))return void ct(!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=rt||as,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;ct(r>l)}),[rt,at,as]);const As=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i,r,o,a;let l=null;try{if(Me||$e)return;const d=Be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),c=d.map((e=>e.documentId)).filter(Boolean),u=d.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),p=null!=t?t:rt,m=null!==(n=null===(e=null==fe?void 0:fe.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&c.length>0;if(!p&&!m)return;Ve(""),We(""),Fe(null),ot(""),Oe(!1),qe("fetching"),Ge(),Qe();const f=null!==(r=null===(i=it.data)||void 0===i?void 0:i.messages)&&void 0!==r?r:[],g=w.getUnpersistedMemoryMessages(Le,f),h=s?g.slice(0,g.length-1):g,I=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),b=I+(s?0:1),y={id:b,role:"assistant",parts:[],documentIds:[]},x=[...h,...s?[]:[{id:I,role:"user",parts:[{type:"text",content:p,isVisible:!0}],documentIds:m?c:[]}],y];Re(x),Qe(),m&&Ke([]);const j=U.getPickaxeConfigMetadata(pe),S="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`;l=S,Ot.current=S,wt.current=null,Nt.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:oe,pickaxeId:ae,sessionId:le,submissionId:S,senderType:ce,value:p},m&&{documentIds:c}),de&&{sender:de}),Ce&&{studioSessionToken:Ce}),!Ce&&!de&&{sender:E.initializeEmbedUserId()}),ms&&{portalId:ms}),pe&&{deploymentId:pe}),j&&{metadata:j}),m&&u.length>0?{uploadedModelImages:u}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},es&&{credentials:"include"})),N=yield O.json();if(!N.success){if(N.limitData){const e=new Error(N.error||N.message||(null==he?void 0:he["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=N.limitData,e}if(os(N))return;throw new Error(N.error||N.message||(null==he?void 0:he["failed-to-start-generation"])||"Failed to start generation")}const _=null!==(o=N.submissionId)&&void 0!==o?o:S;l=_,Ot.current=_;const k=()=>wt.current===_;if(k())return;ns&&ye&&le&&Tt.current.add(le);const T=Object.assign(Object.assign({},gs()),{message:p,documentIds:m?c:[],uploadedModelImages:m?u:[],hasUploadedDocuments:m,isHidden:s,metadata:null!=j?j:null});gt?(vs(),C.fireDeploymentFirstMessageSubmittedWebhook(T)):Ct.current=T,qe("streaming"),Ut.current=new AbortController;const A=[];let D=[...null!=Ze?Ze:[]],P=0,L=!1,q="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${_}?index=${P}`,{signal:null===(a=Ut.current)||void 0===a?void 0:a.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();St.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(k())L=!0;else if(e.event&&"ping"!==e.event&&P++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Fe(t.limitData),Ve(""),void(L=!0);const s=t.error||t.message||(null==he?void 0:he["something-went-wrong"])||"Something went wrong.";return os(t)||Ve(s),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&K){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw L=!0,K({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw L=!0,K({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw L=!0,K({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw L=!0,K({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)q="",A.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)q+=n.delta,A[A.length-1].content=q;else if("text-end"===n.type)q="";else if("reasoning-start"===n.type)q="",A.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)q+=n.delta,A[A.length-1].content=q;else if("reasoning-end"===n.type)q="";else if(n.type.startsWith("data-")){const e=n;A.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Nt.current=M(A);const i=M(A);Re((e=>{const t=e.findIndex((e=>e.id===b)),s=Object.assign(Object.assign({},y),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),tt([...D]),et.startsWith("inline")||st({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),tt(D),et.startsWith("inline")||st({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);D=D.filter((e=>!(e.id===t.id&&e.version===t.version))),D.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),tt(D),et.startsWith("inline")||st({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");D=D.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),tt(D)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);tt(D.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Fe(t.limitData),Ve(""),void(L=!0);const s=t.error||t.message||(null==he?void 0:he["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(os(t))return void(L=!0);Ve(s)}else"stop"===e.event&&(L=!0)}else L=!0}});for(;;){if(k()){L=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(k()){L=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}L||k()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||R(e)||k())return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Te||Te(le)}catch(e){if(R(e))return;if(e.limitData)Fe(e.limitData),Ve("");else{let t=O.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==he?void 0:he["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),os(t)||Ve(t)}}finally{const e=!l||Ot.current===l;Qe(),e&&(qe("idle"),Je(),St.current=null),l&&e&&(Ot.current=null,Nt.current=[]),yield ds()}}));return rs?null:t.jsx("div",Object.assign({className:k.default("flex w-full flex-shrink-0 flex-col items-center",!is&&"px-4 pb-8"),dir:xe?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Et,className:k.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ge.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Gt),{maxHeight:`${At}px`,overflowY:"auto"})},{children:[_s&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Gt.backgroundColor?`${Gt.backgroundColor}E6`:void 0,borderColor:ve.text+"20",color:ve.text,borderTopRightRadius:ge.cornerRadius+"px",borderTopLeftRadius:ge.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[js.toLocaleString()," ",ps?(null==he?void 0:he.credits)||"Credits":(null==he?void 0:he.uses)||"Uses"," ",(null==he?void 0:he.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[!ks&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:ve.accent,color:ve.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),Es)return void window.open(Es,"_blank","noopener,noreferrer");if(Ue)return void Ue();const t=E.buildUpgradeUrl({baseUrl:mt,accessGroupId:null==Se?void 0:Se.accessGroupId,redirectUrl:document.URL});t&&(E.isInIframe()?window.open(t):location.href=t)}},{children:Us})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>It(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!Me&&Be.length>0&&t.jsx(x.default,{className:"p-4 pb-0",isDisabled:Me}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Pt&&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!==(re=ve.accent)&&void 0!==re?re:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:ve.text+"90"}},{children:(null==he?void 0:he.listening)||"Listening..."}))]})),t.jsx(j.default,Object.assign({ref:_t,className:k.default(zt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!rt.trim()&&!rt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",xe?"text-right":"text-left",ls&&"mb-12",Pt&&"text-transparent"),value:rt,placeholder:as,onChange:e=>{ot(e)},onKeyDown:e=>{be||ze||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),$e||Me||As()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!ts)return;t.preventDefault(),Oe(!1),yield He(e)}}))},$&&{onFocus:$},X&&{onBlur:X},{dir:xe?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:kt,className:k.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",ls?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ls&&Gt.backgroundColor&&{backgroundColor:Gt.backgroundColor}),{borderTopRightRadius:ge.cornerRadius+"px",borderBottomRightRadius:ge.cornerRadius+"px"})},{children:Me?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:()=>{const t=Ot.current;t&&(wt.current=t,(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:Ot.current))return;const e=M(Nt.current);try{yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},es&&{credentials:"include"}))}catch(e){console.warn("Failed to cancel submission",e)}}))})(t)),Ut.current&&(Ut.current.abort(),Ut.current=null),St.current&&(St.current.cancel().catch((()=>{})),St.current=null),qe("idle")},style:{backgroundColor:ve.accent,color:ve.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):Pt?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:qt,style:{backgroundColor:ve.accent,color:ve.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[ts&&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:Xt?ve.accent+"10":void 0,color:Xt?ve.accent:ve.accent+"80"},disabled:$e||Me,onClick:()=>{var e;return null===(e=xt.current)||void 0===e?void 0:e.click()}},Ht,{children:[t.jsx("input",{id:"file-upload",ref:xt,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Oe(!1),yield He(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),ss&&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:Pt?ve.accent:Wt?ve.accent+"10":void 0,color:Pt?ve.accentText:Wt?ve.accent:ve.accent+"80"},disabled:$e||Me||Lt,onClick:()=>{Pt?qt():(jt.current=rt,Rt(Ie||"en-US"))}},Yt,{children:t.jsx(b.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Vt||Cs?ve.accent:ve.accent+"10",color:Vt||Cs?ve.accentText:ve.accent+"80"},disabled:!Cs,onClick:()=>As()},Bt,{children:t.jsx(I.default,{className:k.default("h-6 w-6 shrink-0",xe&&"scale-x-[-1] transform")})}))]})}))]}))]})),Xe&&t.jsx(S.default,{error:Xe,className:"mt-3"})]}))}))}));$.displayName="Input",exports.default=$;
|
|
@@ -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"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),r=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),u=require("../../../Icons/copy.svg.js"),m=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),v=require("../../common/PickaxeMarkdown/Renderer.js"),g=require("../../common/PickaxeMessageParts/index.js"),b=require("../../../../common/cn.js");exports.default=({item:j,onDelete:f})=>{const{pickaxe:y,sender:k,colors:w,translations:N,styles:C,isRtl:O,disableCss:_,disableHtml:q,disableJs:P,setSessionId:M,setIsNewChat:I}=n.usePickaxeContext(),{setMessages:R}=a.useResponseContext(),{setDocuments:S}=o.useDocument(),[E,D]=t.useState(!1),[T,F]=t.useState(!1),[A,H]=t.useState(!1),[$,z]=t.useState(!1),[J,L]=t.useState(!1),U=t.useRef(null),[B,K]=t.useState(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name")}),[j.shortSummary,j.summary,N]),t.useEffect((()=>{const e=e=>{U.current&&!U.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>j?"FORM"===j.pickaxeType?j.question?0===j.messages.length?j.question.responseParts?j.question.responseParts.length:0:j.messages.length:0:j.messages.length:0),[j]),V=l.formatLocalDateTime(j.updatedAt,"MMM dd, yyyy hh:mm a"),W=t.useMemo((()=>{var e,s;const t=(null==N?void 0:N["not-available"])||"n/a";if("FORM"===j.pickaxeType){if(j.messages&&0!==j.messages.length){const e=j.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=j.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return J?n.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=j.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[j,J,N]),Y=t.useMemo((()=>{var e,s,t,n,a,o;return"FORM"===j.pickaxeType?j.messages&&0!==j.messages.length?null!==(s=null===(e=j.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=j.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(o=null===(a=j.messages.find((e=>"assistant"===e.role)))||void 0===a?void 0:a.parts)&&void 0!==o?o:[]}),[j]),Z=t.useMemo((()=>Y.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[Y]),ee=t.useMemo((()=>g.getSuppressedRichPreviewUrls(Y)),[Y]),se=()=>{F(!1),G("")},te=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){H(!0);try{yield i.pickaxeApi2.patch("/conversation/title",{sessionId:j.sessionId,name:X,userId:k}),K(X),F(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==N?void 0:N["failed-update-name"])||"Failed to update name.")}finally{H(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:w.secondary,borderRadius:C.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:w.primary,color:w.text}},{children:T?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&te(),"Escape"===e.key&&se()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:w.primary,borderColor:w.secondary}}),s.jsx("button",Object.assign({onClick:te,disabled:A,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.save)||"Save"},{children:s.jsx(r.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:se,disabled:A,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.cancel)||"Cancel"},{children:s.jsx(r.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),L(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:J?(null==N?void 0:N.collapse)||"Collapse":(null==N?void 0:N.expand)||"Expand"},{children:J?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),D(!E)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(r.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:U,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:w.secondary,color:w.secondaryText,borderColor:w.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),F(!0),D(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:w.primary}},{children:[s.jsx(r.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==N?void 0:N["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield i.pickaxeApi2.delete("/conversation",{data:{sessionId:j.sessionId,userId:k}}),f&&f(j.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==N?void 0:N["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:b.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",J?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:b.default("w-full",J?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:C.theme,colors:w},O&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},_&&{disableCss:!0},{children:s.jsx(v.PickaxeMarkdownRenderer,{style:{display:"block"},className:b.default("w-full",!J&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],J&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:W})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:C.theme,colors:w},O&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},_&&{disableCss:!0},{children:s.jsx(v.PickaxeMarkdownRenderer,{style:{display:"block"},className:b.default("w-full text-sm",!J&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],J&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:Z,suppressedRichPreviewUrls:ee})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==y?void 0:y.chatflag)||!(null==y?void 0:y.chatflag)&&(null==y?void 0:y.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=j.sessionId,S([]),R([]),I(!1),M(s)},title:(null==N?void 0:N["open-chat"])||"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+($?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(Z),z(!0),setTimeout((()=>{z(!1)}),2e3)},title:$?(null==N?void 0:N.copied)||"Copied!":(null==N?void 0:N["copy-assistant-message"])||"Copy assistant message"},{children:$?s.jsx(m.default,{className:"h-4 w-4",style:{color:w.accent},fill:w.accent}):s.jsx(u.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:V}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("../../Addons/Scroll/hooks/useScrollContext.js"),n=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,v,g;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:A,isRtl:I,setSessionId:S,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=o.useResponseContext(),{scrollTargetRef:R}=l.useScrollContext(),{setDocuments:T}=n.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=i.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w},I&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},A&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[]})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{content:(null!==(g=null===(v=D.question)||void 0===v?void 0:v.responseParts)&&void 0!==g?g:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void S(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("../../../Icons/check.svg.js"),o=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:l,update:c})=>{const{colors:u,isRtl:d,translations:p}=t.usePickaxeContext(),{setError:x}=n.useResponseContext(),m=i.useStyleFontSize(),j=s.useRef(null),f=s.useMemo((()=>l.example.split("S3P32X")),[l.example]),b=s.useMemo((()=>l.input?l.input.split(","):[]),[l.input]),[h,g]=s.useState((()=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("../../../Icons/check.svg.js"),o=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:l,update:c})=>{const{colors:u,isRtl:d,translations:p}=t.usePickaxeContext(),{setError:x}=n.useResponseContext(),m=i.useStyleFontSize(),j=s.useRef(null),f=s.useMemo((()=>l.example.split("S3P32X")),[l.example]),b=s.useMemo((()=>l.input?l.input.split(","):[]),[l.input]),[h,g]=s.useState((()=>{var e;return l.allowOther&&null!==(e=b.find((e=>!f.includes(e))))&&void 0!==e?e:""}));return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3",dir:d?"rtl":"ltr"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:a.default(m.b3,"font-semibold opacity-70")},{children:l.main})),l.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:u.error}},{children:"*"}))]})),e.jsx(o.default,Object.assign({id:o.getDropdownMenuId(l.id),value:l.input.replace(/,/g,", "),placeholder:(null==p?void 0:p["select-options"])||"Select option(s)",closeOnSelect:!1,maxToken:l.maxLength,isDropdown:l.isDropdown},{children:e.jsxs("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[f.map(((s,t)=>e.jsxs("div",Object.assign({className:"flex min-w-0 items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{x("");const s=b.includes(e),t=l.input?l.input.split(","):[],n=new Set(t);s&&n.has(e)?n.delete(e):s||n.has(e)||n.add(e);const i=Array.from(n).filter((e=>""!==e.trim()));c(Object.assign(Object.assign({},l),{input:i.join(",")}))})(s)},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:b.includes(s)?u.accent:u.accent+"80"},b.includes(s)&&{backgroundColor:u.accent})},{children:e.jsx(r.default,{className:a.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",b.includes(s)&&"opacity-100"),style:{color:u.accentText}})})),e.jsx("p",Object.assign({className:a.default(m.b2,"min-w-0 select-none break-words"),style:{overflowWrap:"anywhere"}},{children:s}))]}),t))),l.allowOther&&e.jsxs("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{x("");const e=b.includes(h.trim()),s=l.input?l.input.split(","):[],t=Array.from(new Set(s)).filter((e=>""!==e.trim()&&f.includes(e)));e||t.push(h.trim()),c(Object.assign(Object.assign({},l),{input:t.join(",")})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:b.includes(h)?u.accent:u.accent+"80"},b.includes(h)&&{backgroundColor:u.accent})},{children:e.jsx(r.default,{className:a.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",b.includes(h)&&"opacity-100"),style:{color:u.accentText}})})),e.jsxs("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e.jsxs("p",Object.assign({className:a.default(m.b2,"select-none opacity-80 min-w-fit")},{children:[(null==p?void 0:p.other)||"Other",":"]})),e.jsx("input",{ref:j,type:"text",className:a.default(m.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:b.includes(h)?u.accent:"rgba(0,0,0,0.2)"},value:h,onChange:e=>(e=>{x(""),g(e);const s=b.includes(e.trim()),t=l.input?l.input.split(","):[],n=new Set(t.filter((e=>f.includes(e))));s?n.delete(e.trim()):n.add(e.trim());const i=Array.from(n).filter((e=>""!==e.trim()));c(Object.assign(Object.assign({},l),{input:i.join(",")}))})(e.target.value),placeholder:(null==p?void 0:p["type-your-answer"])||"Type your answer..."})]}))]}))]}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../Core/ErrorAlert.js"),o=require("../../common/PickaxeUpgradeCard.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../common/agentPrefill.js"),n=require("../../../Core/ErrorAlert.js"),o=require("../../common/PickaxeUpgradeCard.js"),u=require("./Input.js"),a=require("./Option.js"),l=require("./Document.js"),d=require("./Checkbox.js"),p=require("./Submit.js");exports.default=({onLongInputPaste:c})=>{const{deploymentId:x,pickaxeId:m,pickaxe:f,translations:g}=r.usePickaxeContext(),{error:j}=s.useResponseContext(),[h,q]=t.useState([]),[y,w]=t.useState([]),[k]=t.useState((()=>i.readAgentPrefill([x,m]))),O=t.useRef(!1),[P,b]=t.useState(null),v=e=>{q((t=>t.map((t=>t.id===e.id?e:t))))},C=t.useMemo((()=>y),[y]);return t.useEffect((()=>{if(!f)return;if(!f._questions)return;if(O.current)return;const e=new Date("2025-10-16T23:10:00Z"),t=!f.updatedAt||new Date(f.updatedAt)<e,r=f._questions.map(((e,r)=>{var s;let i="";const n="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||n||(i=t[0])}let o=e.secondary||"";return t&&(o=e.secondary||("Knowledge Upload"===e.type?null!==(s=null==g?void 0:g["form-doc-placeholder"])&&void 0!==s?s:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:r+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:o,allowOther:n},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})})),s=r.map((e=>{const t=i.resolveAgentFormPrefill(e,k.formInputs.get(e.id));return null===t?e:Object.assign(Object.assign({},e),{input:t,length:t.length})}));O.current=!0,q(s),w(r)}),[k,f,g]),e.jsxs("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[h.map(((r,s)=>"Multiple Choice"===r.type?e.jsx(t.Fragment,{children:e.jsx(a.default,{field:r,update:v})},s):"Checkbox"===r.type?e.jsx(t.Fragment,{children:e.jsx(d.default,{field:r,update:v})},s):"userinput:documentupload"===r.id?e.jsx(t.Fragment,{children:e.jsx(l.default,{field:r,update:v})},s):e.jsx(t.Fragment,{children:e.jsx(u.default,{field:r,update:v,activeVoiceId:P,setActiveVoiceId:b,onLongPaste:c})},s))),e.jsx(n.default,{error:j}),e.jsx(o.default,{}),e.jsx(p.default,{questions:h,update:v,resetQuestions:()=>q(C)})]}))};
|
|
@@ -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"),o=require("./Addons/Artifact/Provider.js"),a=require("./DimensionProvider.js"),n=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=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 o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{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:p,senderType:f,deploymentId:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),a=require("./DimensionProvider.js"),n=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=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 o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{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:p,senderType:f,deploymentId:g,portalId:h,deploymentType:m,deploymentDimensions:y,deploymentMisc:b,styles:v,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:x={popupType:"auto"},responsiveBy:C="viewport",locale:F="en",opacity:I=1,forceMobile:j=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:O=!1,loadFont:D=!0,isRtl:U=!1,isEmbed:A=!1,isDropShadow:E=!1,allowGuestUsage:R=!0,preventInitialSessionId:L=!1,onUpgrade:M,onGenerateComplete:G,onSessionIdChange:H})=>{const[W,_]=i.useState(""),[B,V]=i.useState(""),[N,X]=i.useState(""),[Y,z]=i.useState(""),[J,K]=i.useState(p),[Q,Z]=i.useState(null),[$,ee]=i.useState(f),[te,ie]=i.useState("loading"),[oe,ae]=i.useState([]),[ne,se]=i.useState(null),[re,le]=i.useState(null),[de,ce]=i.useState(null),[ue,pe]=i.useState(null),[fe,ge]=i.useState(!1),[he,me]=i.useState(!0),[ye,be]=i.useState(!0),[ve,we]=i.useState(!1);return i.useEffect((()=>{ge(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!fe&&(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:()=>{ge(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ge(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ge(!0)}}))}),[D,fe,null==v?void 0:v.font]),i.useEffect((()=>{K(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:W,pickaxeId:B,sessionId:N,lastSessionId:Y,sender:J,senderType:$,portalId:h,deploymentId:g,deploymentType:m,validationStatus:te,validationUpgradeGroups:oe,validationUpgradeUrl:ne,deploymentDimensions:y,deploymentMisc:b,accessGroup:Q,pickaxe:ue,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"},w),misc:k,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...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:x,responsiveBy:C,locale:F,opacity:I,forceMobile:j,loadFont:D,disableHtml:q,disableJs:T,disableCss:O,isFontLoaded:fe,isNewChat:he,isShowIceBreaker:ye,isShowFeedbackMessage:ve,isRtl:U,isEmbed:A,isDropShadow:E,allowGuestUsage:R,clientSecret:de,stripeAccountId:re,preventInitialSessionId:L,setClientSecret:ce,setStripeAccountId:le,setContextId:_,setValidationStatus:ie,setValidationUpgradeGroups:ae,setValidationUpgradeUrl:se,setPickaxeId:V,setSessionId:e=>{X((t=>{const i="function"==typeof e?e(t):e;return null==H||H(i),i}))},setLastSessionId:z,setSender:K,setSenderType:ee,setAccessGroup:Z,setPickaxe:pe,setIsFontLoaded:ge,setIsNewChat:me,setIsShowIceBreaker:be,setIsShowFeedbackMessage:we},M&&{onUpgrade:M}),G&&{onGenerateComplete:G})},{children:t.jsx(r.default,{children:t.jsx(a.default,{children:t.jsx(n.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},x,{children:c}))})}))})})}))};
|
|
@@ -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};
|