@baishuyun/chat-sdk 0.1.2 → 0.1.4

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.
@@ -508,7 +508,7 @@ ${k}
508
508
  `)},xE=function(){var e=parseInt(document.body.getAttribute(l1)||"0",10);return isFinite(e)?e:0},Qq=function(){A.useEffect(function(){return document.body.setAttribute(l1,(xE()+1).toString()),function(){var e=xE()-1;e<=0?document.body.removeAttribute(l1):document.body.setAttribute(l1,e.toString())}},[])},Kq=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,s=i===void 0?"margin":i;Qq();var u=A.useMemo(function(){return Yq(s)},[s]);return A.createElement(Xq,{styles:Jq(u,!t,s,n?"":"!important")})},I5=!1;if(typeof window!="undefined")try{var m2=Object.defineProperty({},"passive",{get:function(){return I5=!0,!0}});window.addEventListener("test",m2,m2),window.removeEventListener("test",m2,m2)}catch(e){I5=!1}var u1=I5?{passive:!1}:!1,eY=function(e){return e.tagName==="TEXTAREA"},wE=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!eY(e)&&n[t]==="visible")},tY=function(e){return wE(e,"overflowY")},nY=function(e){return wE(e,"overflowX")},bE=function(e,t){var n=t.ownerDocument,i=t;do{typeof ShadowRoot!="undefined"&&i instanceof ShadowRoot&&(i=i.host);var s=CE(e,i);if(s){var u=SE(e,i),f=u[1],d=u[2];if(f>d)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},rY=function(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;return[t,n,i]},oY=function(e){var t=e.scrollLeft,n=e.scrollWidth,i=e.clientWidth;return[t,n,i]},CE=function(e,t){return e==="v"?tY(t):nY(t)},SE=function(e,t){return e==="v"?rY(t):oY(t)},iY=function(e,t){return e==="h"&&t==="rtl"?-1:1},aY=function(e,t,n,i,s){var u=iY(e,window.getComputedStyle(t).direction),f=u*i,d=n.target,m=t.contains(d),v=!1,y=f>0,x=0,k=0;do{if(!d)break;var S=SE(e,d),L=S[0],T=S[1],M=S[2],j=T-M-u*L;(L||j)&&CE(e,d)&&(x+=j,k+=L);var F=d.parentNode;d=F&&F.nodeType===Node.DOCUMENT_FRAGMENT_NODE?F.host:F}while(!m&&d!==document.body||m&&(t.contains(d)||t===d));return(y&&Math.abs(x)<1||!y&&Math.abs(k)<1)&&(v=!0),v},g2=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},kE=function(e){return[e.deltaX,e.deltaY]},EE=function(e){return e&&"current"in e?e.current:e},sY=function(e,t){return e[0]===t[0]&&e[1]===t[1]},lY=function(e){return`
509
509
  .block-interactivity-`.concat(e,` {pointer-events: none;}
510
510
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
511
- `)},uY=0,c1=[];function cY(e){var t=A.useRef([]),n=A.useRef([0,0]),i=A.useRef(),s=A.useState(uY++)[0],u=A.useState(yE)[0],f=A.useRef(e);A.useEffect(function(){f.current=e},[e]),A.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var T=Nq([e.lockRef.current],(e.shards||[]).map(EE),!0).filter(Boolean);return T.forEach(function(M){return M.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),T.forEach(function(M){return M.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var d=A.useCallback(function(T,M){if("touches"in T&&T.touches.length===2||T.type==="wheel"&&T.ctrlKey)return!f.current.allowPinchZoom;var j=g2(T),F=n.current,P="deltaX"in T?T.deltaX:F[0]-j[0],z="deltaY"in T?T.deltaY:F[1]-j[1],Z,$=T.target,G=Math.abs(P)>Math.abs(z)?"h":"v";if("touches"in T&&G==="h"&&$.type==="range")return!1;var Y=window.getSelection(),me=Y&&Y.anchorNode,ce=me?me===$||me.contains($):!1;if(ce)return!1;var le=bE(G,$);if(!le)return!0;if(le?Z=G:(Z=G==="v"?"h":"v",le=bE(G,$)),!le)return!1;if(!i.current&&"changedTouches"in T&&(P||z)&&(i.current=Z),!Z)return!0;var se=i.current||Z;return aY(se,M,T,se==="h"?P:z)},[]),m=A.useCallback(function(T){var M=T;if(!(!c1.length||c1[c1.length-1]!==u)){var j="deltaY"in M?kE(M):g2(M),F=t.current.filter(function(Z){return Z.name===M.type&&(Z.target===M.target||M.target===Z.shadowParent)&&sY(Z.delta,j)})[0];if(F&&F.should){M.cancelable&&M.preventDefault();return}if(!F){var P=(f.current.shards||[]).map(EE).filter(Boolean).filter(function(Z){return Z.contains(M.target)}),z=P.length>0?d(M,P[0]):!f.current.noIsolation;z&&M.cancelable&&M.preventDefault()}}},[]),v=A.useCallback(function(T,M,j,F){var P={name:T,delta:M,target:j,should:F,shadowParent:fY(j)};t.current.push(P),setTimeout(function(){t.current=t.current.filter(function(z){return z!==P})},1)},[]),y=A.useCallback(function(T){n.current=g2(T),i.current=void 0},[]),x=A.useCallback(function(T){v(T.type,kE(T),T.target,d(T,e.lockRef.current))},[]),k=A.useCallback(function(T){v(T.type,g2(T),T.target,d(T,e.lockRef.current))},[]);A.useEffect(function(){return c1.push(u),e.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:k}),document.addEventListener("wheel",m,u1),document.addEventListener("touchmove",m,u1),document.addEventListener("touchstart",y,u1),function(){c1=c1.filter(function(T){return T!==u}),document.removeEventListener("wheel",m,u1),document.removeEventListener("touchmove",m,u1),document.removeEventListener("touchstart",y,u1)}},[]);var S=e.removeScrollBar,L=e.inert;return A.createElement(A.Fragment,null,L?A.createElement(u,{styles:lY(s)}):null,S?A.createElement(Kq,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fY(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const dY=Hq(vE,cY);var P5=A.forwardRef(function(e,t){return A.createElement(h2,Bs({},e,{ref:t,sideCar:dY}))});P5.classNames=h2.classNames;var pY=[" ","Enter","ArrowUp","ArrowDown"],hY=[" ","Enter"],v2="Select",[z5,y2,mY]=rE(v2),[f1]=Ds(v2,[mY,U0]),H5=U0(),[rae,qu]=f1(v2),[oae,gY]=f1(v2),_E="SelectTrigger",RE=A.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:i=!1,...s}=e,u=H5(n),f=qu(_E,n),d=f.disabled||i,m=Rn(t,f.onTriggerChange),v=y2(n),y=A.useRef("touch"),[x,k,S]=YE(T=>{const M=v().filter(P=>!P.disabled),j=M.find(P=>P.value===f.value),F=XE(M,T,j);F!==void 0&&f.onValueChange(F.value)}),L=T=>{d||(f.onOpenChange(!0),S()),T&&(f.triggerPointerDownPosRef.current={x:Math.round(T.pageX),y:Math.round(T.pageY)})};return b.jsx(BC,{asChild:!0,...u,children:b.jsx(Qt.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":qE(f.value)?"":void 0,...s,ref:m,onClick:Ut(s.onClick,T=>{T.currentTarget.focus(),y.current!=="mouse"&&L(T)}),onPointerDown:Ut(s.onPointerDown,T=>{y.current=T.pointerType;const M=T.target;M.hasPointerCapture(T.pointerId)&&M.releasePointerCapture(T.pointerId),T.button===0&&T.ctrlKey===!1&&T.pointerType==="mouse"&&(L(T),T.preventDefault())}),onKeyDown:Ut(s.onKeyDown,T=>{const M=x.current!=="";!(T.ctrlKey||T.altKey||T.metaKey)&&T.key.length===1&&k(T.key),!(M&&T.key===" ")&&pY.includes(T.key)&&(L(),T.preventDefault())})})})});RE.displayName=_E;var TE="SelectValue",vY=A.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:s,children:u,placeholder:f="",...d}=e,m=qu(TE,n),{onValueNodeHasChildrenChange:v}=m,y=u!==void 0,x=Rn(t,m.onValueNodeChange);return go(()=>{v(y)},[v,y]),b.jsx(Qt.span,{...d,ref:x,style:{pointerEvents:"none"},children:qE(m.value)?b.jsx(b.Fragment,{children:f}):u})});vY.displayName=TE;var yY="SelectIcon",LE=A.forwardRef((e,t)=>{const{__scopeSelect:n,children:i,...s}=e;return b.jsx(Qt.span,{"aria-hidden":!0,...s,ref:t,children:i||"▼"})});LE.displayName=yY;var xY="SelectPortal",AE=e=>b.jsx(B0,{asChild:!0,...e});AE.displayName=xY;var lf="SelectContent",NE=A.forwardRef((e,t)=>{const n=qu(lf,e.__scopeSelect),[i,s]=A.useState();if(go(()=>{s(new DocumentFragment)},[]),!n.open){const u=i;return u?Nl.createPortal(b.jsx(ME,{scope:e.__scopeSelect,children:b.jsx(z5.Slot,{scope:e.__scopeSelect,children:b.jsx("div",{children:e.children})})}),u):null}return b.jsx(OE,{...e,ref:t})});NE.displayName=lf;var ns=10,[ME,Yu]=f1(lf),wY="SelectContentImpl",bY=mh("SelectContent.RemoveScroll"),OE=A.forwardRef((e,t)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:u,onPointerDownOutside:f,side:d,sideOffset:m,align:v,alignOffset:y,arrowPadding:x,collisionBoundary:k,collisionPadding:S,sticky:L,hideWhenDetached:T,avoidCollisions:M,...j}=e,F=qu(lf,n),[P,z]=A.useState(null),[Z,$]=A.useState(null),G=Rn(t,xe=>z(xe)),[Y,me]=A.useState(null),[ce,le]=A.useState(null),se=y2(n),[ve,_e]=A.useState(!1),ke=A.useRef(!1);A.useEffect(()=>{if(P)return pE(P)},[P]),iE();const Ae=A.useCallback(xe=>{const[$e,...Ge]=se().map(Et=>Et.ref.current),[Ze]=Ge.slice(-1),ht=document.activeElement;for(const Et of xe)if(Et===ht||(Et==null||Et.scrollIntoView({block:"nearest"}),Et===$e&&Z&&(Z.scrollTop=0),Et===Ze&&Z&&(Z.scrollTop=Z.scrollHeight),Et==null||Et.focus(),document.activeElement!==ht))return},[se,Z]),we=A.useCallback(()=>Ae([Y,P]),[Ae,Y,P]);A.useEffect(()=>{ve&&we()},[ve,we]);const{onOpenChange:K,triggerPointerDownPosRef:Me}=F;A.useEffect(()=>{if(P){let xe={x:0,y:0};const $e=Ze=>{var ht,Et,Kt,fn;xe={x:Math.abs(Math.round(Ze.pageX)-((Et=(ht=Me.current)==null?void 0:ht.x)!=null?Et:0)),y:Math.abs(Math.round(Ze.pageY)-((fn=(Kt=Me.current)==null?void 0:Kt.y)!=null?fn:0))}},Ge=Ze=>{xe.x<=10&&xe.y<=10?Ze.preventDefault():P.contains(Ze.target)||K(!1),document.removeEventListener("pointermove",$e),Me.current=null};return Me.current!==null&&(document.addEventListener("pointermove",$e),document.addEventListener("pointerup",Ge,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$e),document.removeEventListener("pointerup",Ge,{capture:!0})}}},[P,K,Me]),A.useEffect(()=>{const xe=()=>K(!1);return window.addEventListener("blur",xe),window.addEventListener("resize",xe),()=>{window.removeEventListener("blur",xe),window.removeEventListener("resize",xe)}},[K]);const[U,J]=YE(xe=>{const $e=se().filter(ht=>!ht.disabled),Ge=$e.find(ht=>ht.ref.current===document.activeElement),Ze=XE($e,xe,Ge);Ze&&setTimeout(()=>Ze.ref.current.focus())}),he=A.useCallback((xe,$e,Ge)=>{const Ze=!ke.current&&!Ge;(F.value!==void 0&&F.value===$e||Ze)&&(me(xe),Ze&&(ke.current=!0))},[F.value]),B=A.useCallback(()=>P==null?void 0:P.focus(),[P]),Re=A.useCallback((xe,$e,Ge)=>{const Ze=!ke.current&&!Ge;(F.value!==void 0&&F.value===$e||Ze)&&le(xe)},[F.value]),We=i==="popper"?U5:DE,Ve=We===U5?{side:d,sideOffset:m,align:v,alignOffset:y,arrowPadding:x,collisionBoundary:k,collisionPadding:S,sticky:L,hideWhenDetached:T,avoidCollisions:M}:{};return b.jsx(ME,{scope:n,content:P,viewport:Z,onViewportChange:$,itemRefCallback:he,selectedItem:Y,onItemLeave:B,itemTextRefCallback:Re,focusSelectedItem:we,selectedItemText:ce,position:i,isPositioned:ve,searchRef:U,children:b.jsx(P5,{as:bY,allowPinchZoom:!0,children:b.jsx(N5,{asChild:!0,trapped:F.open,onMountAutoFocus:xe=>{xe.preventDefault()},onUnmountAutoFocus:Ut(s,xe=>{var $e;($e=F.trigger)==null||$e.focus({preventScroll:!0}),xe.preventDefault()}),children:b.jsx(A0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:xe=>xe.preventDefault(),onDismiss:()=>F.onOpenChange(!1),children:b.jsx(We,{role:"listbox",id:F.contentId,"data-state":F.open?"open":"closed",dir:F.dir,onContextMenu:xe=>xe.preventDefault(),...j,...Ve,onPlaced:()=>_e(!0),ref:G,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Ut(j.onKeyDown,xe=>{const $e=xe.ctrlKey||xe.altKey||xe.metaKey;if(xe.key==="Tab"&&xe.preventDefault(),!$e&&xe.key.length===1&&J(xe.key),["ArrowUp","ArrowDown","Home","End"].includes(xe.key)){let Ze=se().filter(ht=>!ht.disabled).map(ht=>ht.ref.current);if(["ArrowUp","End"].includes(xe.key)&&(Ze=Ze.slice().reverse()),["ArrowUp","ArrowDown"].includes(xe.key)){const ht=xe.target,Et=Ze.indexOf(ht);Ze=Ze.slice(Et+1)}setTimeout(()=>Ae(Ze)),xe.preventDefault()}})})})})})})});OE.displayName=wY;var CY="SelectItemAlignedPosition",DE=A.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:i,...s}=e,u=qu(lf,n),f=Yu(lf,n),[d,m]=A.useState(null),[v,y]=A.useState(null),x=Rn(t,G=>y(G)),k=y2(n),S=A.useRef(!1),L=A.useRef(!0),{viewport:T,selectedItem:M,selectedItemText:j,focusSelectedItem:F}=f,P=A.useCallback(()=>{if(u.trigger&&u.valueNode&&d&&v&&T&&M&&j){const G=u.trigger.getBoundingClientRect(),Y=v.getBoundingClientRect(),me=u.valueNode.getBoundingClientRect(),ce=j.getBoundingClientRect();if(u.dir!=="rtl"){const ht=ce.left-Y.left,Et=me.left-ht,Kt=G.left-Et,fn=G.width+Kt,pn=Math.max(fn,Y.width),En=window.innerWidth-ns,tr=nE(Et,[ns,Math.max(ns,En-pn)]);d.style.minWidth=fn+"px",d.style.left=tr+"px"}else{const ht=Y.right-ce.right,Et=window.innerWidth-me.right-ht,Kt=window.innerWidth-G.right-Et,fn=G.width+Kt,pn=Math.max(fn,Y.width),En=window.innerWidth-ns,tr=nE(Et,[ns,Math.max(ns,En-pn)]);d.style.minWidth=fn+"px",d.style.right=tr+"px"}const le=k(),se=window.innerHeight-ns*2,ve=T.scrollHeight,_e=window.getComputedStyle(v),ke=parseInt(_e.borderTopWidth,10),Ae=parseInt(_e.paddingTop,10),we=parseInt(_e.borderBottomWidth,10),K=parseInt(_e.paddingBottom,10),Me=ke+Ae+ve+K+we,U=Math.min(M.offsetHeight*5,Me),J=window.getComputedStyle(T),he=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),Re=G.top+G.height/2-ns,We=se-Re,Ve=M.offsetHeight/2,xe=M.offsetTop+Ve,$e=ke+Ae+xe,Ge=Me-$e;if($e<=Re){const ht=le.length>0&&M===le[le.length-1].ref.current;d.style.bottom="0px";const Et=v.clientHeight-T.offsetTop-T.offsetHeight,Kt=Math.max(We,Ve+(ht?B:0)+Et+we),fn=$e+Kt;d.style.height=fn+"px"}else{const ht=le.length>0&&M===le[0].ref.current;d.style.top="0px";const Kt=Math.max(Re,ke+T.offsetTop+(ht?he:0)+Ve)+Ge;d.style.height=Kt+"px",T.scrollTop=$e-Re+T.offsetTop}d.style.margin=`${ns}px 0`,d.style.minHeight=U+"px",d.style.maxHeight=se+"px",i==null||i(),requestAnimationFrame(()=>S.current=!0)}},[k,u.trigger,u.valueNode,d,v,T,M,j,u.dir,i]);go(()=>P(),[P]);const[z,Z]=A.useState();go(()=>{v&&Z(window.getComputedStyle(v).zIndex)},[v]);const $=A.useCallback(G=>{G&&L.current===!0&&(P(),F==null||F(),L.current=!1)},[P,F]);return b.jsx(kY,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:S,onScrollButtonChange:$,children:b.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:z},children:b.jsx(Qt.div,{...s,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});DE.displayName=CY;var SY="SelectPopperPosition",U5=A.forwardRef((e,t)=>{const{__scopeSelect:n,align:i="start",collisionPadding:s=ns,...u}=e,f=H5(n);return b.jsx(VC,{...f,...u,ref:t,align:i,collisionPadding:s,style:{boxSizing:"border-box",...u.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});U5.displayName=SY;var[kY,B5]=f1(lf,{}),V5="SelectViewport",jE=A.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:i,...s}=e,u=Yu(V5,n),f=B5(V5,n),d=Rn(t,u.onViewportChange),m=A.useRef(0);return b.jsxs(b.Fragment,{children:[b.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),b.jsx(z5.Slot,{scope:n,children:b.jsx(Qt.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Ut(s.onScroll,v=>{const y=v.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:k}=f;if(k!=null&&k.current&&x){const S=Math.abs(m.current-y.scrollTop);if(S>0){const L=window.innerHeight-ns*2,T=parseFloat(x.style.minHeight),M=parseFloat(x.style.height),j=Math.max(T,M);if(j<L){const F=j+S,P=Math.min(L,F),z=F-P;x.style.height=P+"px",x.style.bottom==="0px"&&(y.scrollTop=z>0?z:0,x.style.justifyContent="flex-end")}}}m.current=y.scrollTop})})})]})});jE.displayName=V5;var FE="SelectGroup",[EY,_Y]=f1(FE),RY=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=Uu();return b.jsx(EY,{scope:n,id:s,children:b.jsx(Qt.div,{role:"group","aria-labelledby":s,...i,ref:t})})});RY.displayName=FE;var IE="SelectLabel",PE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=_Y(IE,n);return b.jsx(Qt.div,{id:s.id,...i,ref:t})});PE.displayName=IE;var x2="SelectItem",[TY,zE]=f1(x2),HE=A.forwardRef((e,t)=>{const{__scopeSelect:n,value:i,disabled:s=!1,textValue:u,...f}=e,d=qu(x2,n),m=Yu(x2,n),v=d.value===i,[y,x]=A.useState(u!=null?u:""),[k,S]=A.useState(!1),L=Rn(t,F=>{var P;return(P=m.itemRefCallback)==null?void 0:P.call(m,F,i,s)}),T=Uu(),M=A.useRef("touch"),j=()=>{s||(d.onValueChange(i),d.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return b.jsx(TY,{scope:n,value:i,disabled:s,textId:T,isSelected:v,onItemTextChange:A.useCallback(F=>{x(P=>{var z;return P||((z=F==null?void 0:F.textContent)!=null?z:"").trim()})},[]),children:b.jsx(z5.ItemSlot,{scope:n,value:i,disabled:s,textValue:y,children:b.jsx(Qt.div,{role:"option","aria-labelledby":T,"data-highlighted":k?"":void 0,"aria-selected":v&&k,"data-state":v?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...f,ref:L,onFocus:Ut(f.onFocus,()=>S(!0)),onBlur:Ut(f.onBlur,()=>S(!1)),onClick:Ut(f.onClick,()=>{M.current!=="mouse"&&j()}),onPointerUp:Ut(f.onPointerUp,()=>{M.current==="mouse"&&j()}),onPointerDown:Ut(f.onPointerDown,F=>{M.current=F.pointerType}),onPointerMove:Ut(f.onPointerMove,F=>{var P;M.current=F.pointerType,s?(P=m.onItemLeave)==null||P.call(m):M.current==="mouse"&&F.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ut(f.onPointerLeave,F=>{var P;F.currentTarget===document.activeElement&&((P=m.onItemLeave)==null||P.call(m))}),onKeyDown:Ut(f.onKeyDown,F=>{var z;((z=m.searchRef)==null?void 0:z.current)!==""&&F.key===" "||(hY.includes(F.key)&&j(),F.key===" "&&F.preventDefault())})})})})});HE.displayName=x2;var Ih="SelectItemText",UE=A.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:s,...u}=e,f=qu(Ih,n),d=Yu(Ih,n),m=zE(Ih,n),v=gY(Ih,n),[y,x]=A.useState(null),k=Rn(t,j=>x(j),m.onItemTextChange,j=>{var F;return(F=d.itemTextRefCallback)==null?void 0:F.call(d,j,m.value,m.disabled)}),S=y==null?void 0:y.textContent,L=A.useMemo(()=>b.jsx("option",{value:m.value,disabled:m.disabled,children:S},m.value),[m.disabled,m.value,S]),{onNativeOptionAdd:T,onNativeOptionRemove:M}=v;return go(()=>(T(L),()=>M(L)),[T,M,L]),b.jsxs(b.Fragment,{children:[b.jsx(Qt.span,{id:m.textId,...u,ref:k}),m.isSelected&&f.valueNode&&!f.valueNodeHasChildren?Nl.createPortal(u.children,f.valueNode):null]})});UE.displayName=Ih;var BE="SelectItemIndicator",VE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return zE(BE,n).isSelected?b.jsx(Qt.span,{"aria-hidden":!0,...i,ref:t}):null});VE.displayName=BE;var $5="SelectScrollUpButton",$E=A.forwardRef((e,t)=>{const n=Yu($5,e.__scopeSelect),i=B5($5,e.__scopeSelect),[s,u]=A.useState(!1),f=Rn(t,i.onScrollButtonChange);return go(()=>{if(n.viewport&&n.isPositioned){let d=function(){const v=m.scrollTop>0;u(v)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),s?b.jsx(WE,{...e,ref:f,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});$E.displayName=$5;var Z5="SelectScrollDownButton",ZE=A.forwardRef((e,t)=>{const n=Yu(Z5,e.__scopeSelect),i=B5(Z5,e.__scopeSelect),[s,u]=A.useState(!1),f=Rn(t,i.onScrollButtonChange);return go(()=>{if(n.viewport&&n.isPositioned){let d=function(){const v=m.scrollHeight-m.clientHeight,y=Math.ceil(m.scrollTop)<v;u(y)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),s?b.jsx(WE,{...e,ref:f,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});ZE.displayName=Z5;var WE=A.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:i,...s}=e,u=Yu("SelectScrollButton",n),f=A.useRef(null),d=y2(n),m=A.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return A.useEffect(()=>()=>m(),[m]),go(()=>{var y;const v=d().find(x=>x.ref.current===document.activeElement);(y=v==null?void 0:v.ref.current)==null||y.scrollIntoView({block:"nearest"})},[d]),b.jsx(Qt.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:Ut(s.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(i,50))}),onPointerMove:Ut(s.onPointerMove,()=>{var v;(v=u.onItemLeave)==null||v.call(u),f.current===null&&(f.current=window.setInterval(i,50))}),onPointerLeave:Ut(s.onPointerLeave,()=>{m()})})}),LY="SelectSeparator",GE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return b.jsx(Qt.div,{"aria-hidden":!0,...i,ref:t})});GE.displayName=LY;var W5="SelectArrow",AY=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=H5(n),u=qu(W5,n),f=Yu(W5,n);return u.open&&f.position==="popper"?b.jsx($C,{...s,...i,ref:t}):null});AY.displayName=W5;var NY="SelectBubbleInput",MY=A.forwardRef(({__scopeSelect:e,value:t,...n},i)=>{const s=A.useRef(null),u=Rn(i,s),f=M5(t);return A.useEffect(()=>{const d=s.current;if(!d)return;const m=window.HTMLSelectElement.prototype,y=Object.getOwnPropertyDescriptor(m,"value").set;if(f!==t&&y){const x=new Event("change",{bubbles:!0});y.call(d,t),d.dispatchEvent(x)}},[f,t]),b.jsx(Qt.select,{...n,style:{...ZC,...n.style},ref:u,defaultValue:t})});MY.displayName=NY;function qE(e){return e===""||e===void 0}function YE(e){const t=Hu(e),n=A.useRef(""),i=A.useRef(0),s=A.useCallback(f=>{const d=n.current+f;t(d),function m(v){n.current=v,window.clearTimeout(i.current),v!==""&&(i.current=window.setTimeout(()=>m(""),1e3))}(d)},[t]),u=A.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return A.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,s,u]}function XE(e,t,n){const s=t.length>1&&Array.from(t).every(v=>v===t[0])?t[0]:t,u=n?e.indexOf(n):-1;let f=OY(e,Math.max(u,0));s.length===1&&(f=f.filter(v=>v!==n));const m=f.find(v=>v.textValue.toLowerCase().startsWith(s.toLowerCase()));return m!==n?m:void 0}function OY(e,t){return e.map((n,i)=>e[(t+i)%e.length])}var JE=RE,DY=LE,jY=AE,QE=NE,FY=jE,KE=PE,e_=HE,IY=UE,PY=VE,t_=$E,n_=ZE,r_=GE;const zY=A.forwardRef(({className:e,children:t,...n},i)=>b.jsxs(JE,{ref:i,className:Fe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,b.jsx(DY,{asChild:!0,children:b.jsx(eE,{className:"h-4 w-4 opacity-50"})})]}));zY.displayName=JE.displayName;const o_=A.forwardRef(({className:e,...t},n)=>b.jsx(t_,{ref:n,className:Fe("flex cursor-default items-center justify-center py-1",e),...t,children:b.jsx(vq,{className:"h-4 w-4"})}));o_.displayName=t_.displayName;const i_=A.forwardRef(({className:e,...t},n)=>b.jsx(n_,{ref:n,className:Fe("flex cursor-default items-center justify-center py-1",e),...t,children:b.jsx(eE,{className:"h-4 w-4"})}));i_.displayName=n_.displayName;const HY=A.forwardRef(({className:e,children:t,position:n="popper",...i},s)=>b.jsx(jY,{children:b.jsxs(QE,{ref:s,className:Fe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[b.jsx(o_,{}),b.jsx(FY,{className:Fe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),b.jsx(i_,{})]})}));HY.displayName=QE.displayName;const UY=A.forwardRef(({className:e,...t},n)=>b.jsx(KE,{ref:n,className:Fe("px-2 py-1.5 text-sm font-semibold",e),...t}));UY.displayName=KE.displayName;const BY=A.forwardRef(({className:e,children:t,...n},i)=>b.jsxs(e_,{ref:i,className:Fe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[b.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:b.jsx(PY,{children:b.jsx(gq,{className:"h-4 w-4"})})}),b.jsx(IY,{children:t})]}));BY.displayName=e_.displayName;const VY=A.forwardRef(({className:e,...t},n)=>b.jsx(r_,{ref:n,className:Fe("-mx-1 my-1 h-px bg-muted",e),...t}));VY.displayName=r_.displayName;const a_=A.forwardRef(({className:e,...t},n)=>b.jsx("textarea",{className:Fe("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));a_.displayName="Textarea";const $Y=({className:e,...t})=>b.jsx("form",{className:Fe("w-full overflow-hidden rounded-[10px] border bg-background shadow-xs",e),...t}),ZY=A.forwardRef(({onChange:e,className:t,placeholder:n="What would you like to know?",minHeight:i=50,maxHeight:s=164,disableAutoResize:u=!1,resizeOnNewLinesOnly:f=!1,...d},m)=>{const v=y=>{if(y.key==="Enter"){if(y.nativeEvent.isComposing||y.shiftKey)return;y.preventDefault();const x=y.currentTarget.form;x&&x.requestSubmit()}};return b.jsx(a_,{className:Fe("w-full resize-none rounded-none border-none shadow-none outline-hidden ring-0",u||f?"field-sizing-fixed":"field-sizing-content min-h-[3lh] max-h-[8lh]","bg-transparent dark:bg-transparent","focus-visible:ring-0",t),name:"message",onChange:y=>{e==null||e(y)},ref:m,onKeyDown:v,placeholder:n,...d})}),WY=({className:e,...t})=>b.jsx("div",{className:Fe("flex items-center justify-between p-1",e),...t}),GY=({className:e,...t})=>b.jsx("div",{className:Fe("flex items-center gap-1",e),...t}),qY=e=>{const t=tE,n=xq,i=yq;return e===void 0?b.jsx(i,{className:"size-4"}):{submitted:b.jsx(t,{className:"size-4 animate-spin"}),streaming:b.jsx(Bz,{}),error:b.jsx(n,{className:"size-4"}),ready:b.jsx(i,{className:"size-4"})}[e]||b.jsx(i,{className:"size-4"})},YY=({className:e,variant:t="default",size:n="icon",status:i,children:s,...u})=>{let f=qY(i);return b.jsx(bh,{content:"发送",children:b.jsx($d,{className:Fe("gap-1.5 rounded-full",e),size:n,type:"submit",variant:t,...u,children:s!=null?s:f})})},XY=({size:e=16})=>b.jsxs("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[b.jsxs("g",{clipPath:"url(#clip0_2393_1490)",children:[b.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),b.jsx("defs",{children:b.jsx("clipPath",{id:"clip0_2393_1490",children:b.jsx("rect",{fill:"white",height:"16",width:"16"})})})]}),JY=({size:e=16})=>b.jsx("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:b.jsx("path",{clipRule:"evenodd",d:"M12.0607 6.74999L11.5303 7.28032L8.7071 10.1035C8.31657 10.4941 7.68341 10.4941 7.29288 10.1035L4.46966 7.28032L3.93933 6.74999L4.99999 5.68933L5.53032 6.21966L7.99999 8.68933L10.4697 6.21966L11 5.68933L12.0607 6.74999Z",fill:"currentColor",fillRule:"evenodd"})}),Ph={"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{icon:R0,iconSize:52},"application/vnd.ms-excel":{icon:R0,iconSize:52},"text/csv":{icon:Xb,iconSize:16},"text/plain":{icon:T0,iconSize:16},"application/octet-stream":{icon:T0,iconSize:16}},QY={icon:Yb,iconSize:16},KY=e=>!!(e!=null&&e.startsWith("image/")),eX=(e,t)=>{var n;if(e&&Ph[e])return Ph[e];if(t)switch((n=t.split(".").pop())==null?void 0:n.toLowerCase()){case"xlsx":case"xls":return Ph["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];case"csv":return Ph["text/csv"];case"txt":case"ts":case"tsx":case"js":case"jsx":case"json":case"md":return Ph["text/plain"]}return QY},tX=()=>b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:b.jsx("path",{d:"M9 6L15 12L9 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),nX=()=>b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:b.jsx("path",{d:"M15 6L9 12L15 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),s_=({direction:e,onClick:t,className:n})=>b.jsx("button",{type:"button",onClick:t,className:Fe("flex items-center justify-center","size-[36px] p-1 rounded-[18px]","bg-white shadow-[0px_0px_10px_0px_rgba(0,0,0,0.06)]","cursor-pointer","hover:bg-gray-50","text-gray-600",Fr,n),children:e==="left"?b.jsx(nX,{}):b.jsx(tX,{})}),l_=({direction:e,height:t,visible:n})=>{const i=e==="left";return b.jsxs("div",{className:Fe("absolute top-[8px] pointer-events-none z-[5]",i?"left-0":"right-0",Fr,n?"opacity-100":"opacity-0"),style:{height:`${t}px`,width:"46px"},children:[b.jsx("div",{className:Fe("absolute inset-0",i?"bg-gradient-to-r from-white via-white via-[63.57%] to-transparent":"bg-gradient-to-l from-white via-white via-[63.57%] to-transparent")}),b.jsx("div",{className:"absolute inset-0 bg-white blur-[7px]"})]})},rX=({attachments:e,className:t,imageSize:n=53,gap:i=10,onImageClick:s,onImageRemove:u})=>{const f=A.useRef(null),d=A.useRef(null),[m,v]=A.useState(!1),[y,x]=A.useState(!1),k=A.useCallback(()=>{const L=d.current;if(!L)return;const{scrollLeft:T,scrollWidth:M,clientWidth:j}=L;v(T>0),x(T+j<M-1)},[]);A.useEffect(()=>{k();const L=d.current;if(L)return L.addEventListener("scroll",k),window.addEventListener("resize",k),()=>{L.removeEventListener("scroll",k),window.removeEventListener("resize",k)}},[k,e]);const S=L=>{const T=d.current;if(!T)return;const M=n+i,j=L==="left"?T.scrollLeft-M*2:T.scrollLeft+M*2;T.scrollTo({left:j,behavior:"smooth"})};return e.length?b.jsxs("div",{ref:f,className:Fe("relative w-full",t),style:{height:n+16},children:[b.jsx("div",{ref:d,className:"flex overflow-x-auto scrollbar-hide py-[8px]",style:{gap:i,height:n+16},children:e.map((L,T)=>{const M=KY(L.contentType),{icon:j,iconSize:F}=eX(L.contentType,L.alt),P=52/102*n,z=P/F;return b.jsxs("div",{className:Fe("relative shrink-0 cursor-pointer group border border-[#e0e0e0] rounded-[10px]",Fr),style:{width:n,height:n},onClick:()=>s==null?void 0:s(L,T),children:[M&&L.url?b.jsx("img",{src:L.url,alt:L.alt||`Attachment ${T+1}`,className:"absolute inset-0 h-full w-full rounded-[10px] object-cover"}):b.jsx("div",{className:"absolute inset-0 flex h-full w-full items-center justify-center rounded-[10px] bg-[#EFF0F6]",children:b.jsx("div",{className:"shrink-0 flex items-center justify-center",style:{width:P,height:P},children:b.jsx("div",{style:{transform:z!==1?`scale(${z})`:void 0,transformOrigin:"center"},children:b.jsx(j,{})})})}),L.isLoading&&b.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-[10px] bg-black/50 pointer-events-none",children:b.jsx("div",{className:"inline-flex animate-spin items-center justify-center",children:b.jsx(XY,{size:16})})}),u&&b.jsx("button",{className:Fe("absolute -top-[6px] -right-[6px]","flex items-center justify-center","opacity-0 group-hover:opacity-100 cursor-pointer",Fr),onClick:Z=>{Z.stopPropagation(),u(L,T)},children:b.jsx(Zz,{})})]},L.id)})}),b.jsx(l_,{direction:"left",height:n,visible:m}),b.jsx(s_,{direction:"left",onClick:()=>S("left"),className:Fe("absolute left-0 top-1/2 -translate-y-1/2 z-10",m?"opacity-100":"opacity-0 pointer-events-none")}),b.jsx(l_,{direction:"right",height:n,visible:y}),b.jsx(s_,{direction:"right",onClick:()=>S("right"),className:Fe("absolute right-0 top-1/2 -translate-y-1/2 z-10",y?"opacity-100":"opacity-0 pointer-events-none")})]}):null},oX=({setMessages:e,status:t,chatId:n})=>{const{exec:i=()=>{}}=Fl("onBeforeMessagesClear"),s=A.useCallback(()=>{i(n),e(()=>[])},[i,e]),{clearTimestamp:u}=Ci(f=>({clearTimestamp:f.msgClearTimestamp}));return A.useEffect(()=>{u&&s()},[u]),b.jsx(ef,{rounded:!0,tooltip:"删除历史消息",icon:b.jsx(Pz,{}),disabled:t!=="ready",onClick:f=>{f.preventDefault(),s()}})},iX=()=>{const e=Ki();return A.useCallback(n=>{e.emit("send-toast",n)},[e])};function aX({chatId:e,input:t,setInput:n,status:i,stop:s,attachments:u,setAttachments:f,fileUploadEndpoint:d,setMessages:m,sendMessage:v,className:y}){var K,Me,U,J,he;const x=A.useRef(null),k=A.useCallback(()=>{x.current&&(x.current.style.height="")},[]),{status:S}=u2();A.useEffect(()=>{x.current&&k()},[k]),A.useEffect(()=>{S==="hide"&&(ce(),n(""))},[S]);const L=A.useCallback(()=>{x.current&&(x.current.style.height="")},[]);A.useEffect(()=>{if(x.current){const Re=x.current.value||"";n(Re),k()}},[k,n]);const T=B=>{n(B.target.value)},M=A.useRef(null),[j,F]=A.useState([]),P=A.useRef(new Map),{exec:z}=Fl("onBeforeMessageSend"),{exec:Z}=Fl("onAfterMessageSend"),$=((K=Jd())==null?void 0:K.placeholder)||"Send a message...",G=((Me=Jd())==null?void 0:Me.acceptAttachmentMaxCount)||5,Y=((U=Jd())==null?void 0:U.acceptAttachmentMaxSizeMb)||50,me=`上传附件(仅识别文字),最多${G}个,单个文件最大${Y}MB`,ce=A.useCallback(()=>{f([]),F([]),M.current&&(M.current.value="")},[f]),le=A.useCallback(()=>{const B=z({text:t}),Re={role:"user",parts:[...u.map(We=>({type:"file",url:We.url,name:We.name,mediaType:We.contentType,providerMetadata:{uploadMetadata:We}})),{type:"text",text:t}]};v(Re,B.options),Z==null||Z(Re),f([]),L(),n("")},[t,n,u,v,f,e,L]),se=iX(),ve=A.useCallback(async(B,Re)=>{const We=new FormData;We.append("file",B);try{const Ve=await fetch(d,{method:"POST",body:We,signal:Re});if(Ve.ok){const $e=await Ve.json();return console.log($e),$e}const{error:xe}=await Ve.json();console.error("upload error",xe)}catch(Ve){}},[]),_e=A.useCallback(async B=>{const Re=Array.from(B.target.files||[]);if(Re.length===0)return;if(u.length+Re.length>G){se({type:"error",msg:`最多只能上传${G}个附件`});return}if(Re.some(Ve=>Ve.size>Y*1024*1024)){se({type:"error",msg:`单个文件大小不能超过${Y}MB`});return}F(Re.map(Ve=>Ve.name));try{const Ve=Re.map(Ge=>{const Ze=new AbortController;return P.current.set(Ge.name,Ze),ve(Ge,Ze.signal)}),xe=await Promise.all(Ve),$e=xe.filter(Ge=>Ge!==void 0);console.log("uploaded attachements",xe),f(Ge=>[...Ge,...$e])}catch(Ve){console.error("Error uploading files!",Ve)}finally{F([]),P.current.clear()}},[f,ve,u]),ke=A.useCallback(async B=>{var Ve;const Re=(Ve=B.clipboardData)==null?void 0:Ve.items;if(!Re)return;const We=Array.from(Re).filter(xe=>xe.type.startsWith("image/"));if(We.length!==0){B.preventDefault(),F(xe=>[...xe,"Pasted image"]);try{const xe=We.map(Ze=>Ze.getAsFile()).filter(Ze=>Ze!==null).map(Ze=>ve(Ze)),Ge=(await Promise.all(xe)).filter(Ze=>Ze!==void 0&&Ze.url!==void 0&&Ze.contentType!==void 0);f(Ze=>[...Ze,...Ge])}catch(xe){console.error("Error uploading pasted images:",xe)}finally{F([])}}},[f,ve]),Ae=(he=(J=Jd())==null?void 0:J.acceptAttachmentFileType)==null?void 0:he.join(","),we=!!Ae;return A.useEffect(()=>{const B=x.current;if(B)return B.addEventListener("paste",ke),()=>B.removeEventListener("paste",ke)},[ke]),b.jsxs("div",{className:Fe("relative flex w-full flex-col gap-4",y),children:[b.jsx("input",{className:"-top-4 -left-4 pointer-events-none fixed size-0.5 opacity-0",multiple:!0,onChange:_e,ref:M,tabIndex:-1,type:"file",accept:Ae}),b.jsxs($Y,{className:"border border-[#e0e0e0] bg-background p-[10px] shadow-xs transition-all duration-200 focus-within:border-border hover:border-[#0265ff]",onSubmit:B=>{B.preventDefault(),(i==="ready"||i==="error")&&le()},children:[(u.length>0||j.length>0)&&b.jsx(rX,{attachments:[...u.map(B=>({id:B.url,url:B.url,alt:B.name,contentType:B.contentType})),...j.map(B=>({id:`uploading-${B}`,url:"",alt:B,isLoading:!0}))],imageSize:52,onImageRemove:B=>{if(B.id.startsWith("uploading-")){const Re=B.alt||"",We=P.current.get(Re);We&&(We.abort(),P.current.delete(Re)),F(Ve=>Ve.filter(xe=>xe!==Re));return}f(Re=>Re.filter(We=>We.url!==B.id)),M.current&&(M.current.value="")}}),b.jsx("div",{className:"flex flex-row items-start gap-1 sm:gap-2",children:b.jsx(ZY,{className:"grow resize-none border-0! border-none! bg-transparent p-0 text-base outline-none ring-0 placeholder:text-[#999] focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 text-[#12111]","data-testid":"multimodal-input",onChange:T,placeholder:$,ref:x,rows:3,value:t})}),b.jsxs(WY,{className:"border-top-0! border-t-0! p-0 shadow-none dark:border-0 dark:border-transparent!",children:[b.jsx("div",{}),b.jsxs(GY,{className:"gap-2.5",children:[we?b.jsx(uX,{fileInputRef:M,status:i,tooltip:me}):null,b.jsx(oX,{setMessages:m,status:i,chatId:e}),b.jsx(Hz,{}),i==="submitted"||i==="streaming"?b.jsx(fX,{setMessages:m,stop:s}):b.jsx(YY,{className:"cursor-pointer rounded-full bg-[#0265FF] text-primary-foreground transition-colors duration-200 hover:bg-[#0265FF]/90 disabled:bg-[#E5E6EB] disabled:text-white h-[26px] w-[26px] disabled:opacity-100","data-testid":"send-button",disabled:!t.trim()&&u.length<=0||j.length>0,status:i,children:b.jsx(Iz,{})})]})]})]})]})}const sX=A.memo(aX,(e,t)=>!(e.input!==t.input||e.status!==t.status||!cq(e.attachments,t.attachments)));function lX({fileInputRef:e,status:t,tooltip:n}){return b.jsx(ef,{tooltip:n,rounded:!0,icon:b.jsx(Uz,{}),disabled:t!=="ready",onClick:i=>{var s;i.preventDefault(),(s=e.current)==null||s.click()}})}const uX=A.memo(lX);function cX({stop:e,setMessages:t}){return b.jsx(bh,{content:"停止生成",children:b.jsx($d,{className:"cursor-pointer rounded-full bg-[#0265FF] text-primary-foreground transition-colors duration-200 hover:bg-[#0265FF]/90 disabled:bg-[#E5E6EB] disabled:text-white h-[26px] w-[26px] flex items-center justify-center aspect-square p-0 disabled:!opacity-100",onClick:n=>{n.preventDefault(),e(),t(i=>i)},children:b.jsx("div",{className:"rounded-[2px] w-[8px] h-[8px] bg-white flex-shrink-0"})})})}const fX=A.memo(cX);function dX(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,i=0;return function(...u){clearTimeout(n);const f=Date.now(),d=f-i,m=t-d;m<=0?(i=f,e.apply(this,u)):n=setTimeout(()=>{i=Date.now(),e.apply(this,u)},m)}}var pX=dX;const hX=Ou(pX);var u_=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},er=(e,t,n)=>(u_(e,t,"read from private field"),n?n.call(e):t.get(e)),Vs=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Xu=(e,t,n,i)=>(u_(e,t,"write to private field"),t.set(e,n),n);function mX(e,t){return t!=null?hX(e,t):e}var ba,w2,b2,zh,Hh,Uh,d1,G5,q5,gX=class{constructor(e=[]){Vs(this,ba,void 0),Vs(this,w2,"ready"),Vs(this,b2,void 0),Vs(this,zh,new Set),Vs(this,Hh,new Set),Vs(this,Uh,new Set),this.pushMessage=t=>{Xu(this,ba,er(this,ba).concat(t)),er(this,d1).call(this)},this.popMessage=()=>{Xu(this,ba,er(this,ba).slice(0,-1)),er(this,d1).call(this)},this.replaceMessage=(t,n)=>{Xu(this,ba,[...er(this,ba).slice(0,t),this.snapshot(n),...er(this,ba).slice(t+1)]),er(this,d1).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const i=n?mX(t,n):t;return er(this,zh).add(i),()=>{er(this,zh).delete(i)}},this["~registerStatusCallback"]=t=>(er(this,Hh).add(t),()=>{er(this,Hh).delete(t)}),this["~registerErrorCallback"]=t=>(er(this,Uh).add(t),()=>{er(this,Uh).delete(t)}),Vs(this,d1,()=>{er(this,zh).forEach(t=>t())}),Vs(this,G5,()=>{er(this,Hh).forEach(t=>t())}),Vs(this,q5,()=>{er(this,Uh).forEach(t=>t())}),Xu(this,ba,e)}get status(){return er(this,w2)}set status(e){Xu(this,w2,e),er(this,G5).call(this)}get error(){return er(this,b2)}set error(e){Xu(this,b2,e),er(this,q5).call(this)}get messages(){return er(this,ba)}set messages(e){Xu(this,ba,[...e]),er(this,d1).call(this)}};ba=new WeakMap,w2=new WeakMap,b2=new WeakMap,zh=new WeakMap,Hh=new WeakMap,Uh=new WeakMap,d1=new WeakMap,G5=new WeakMap,q5=new WeakMap;var p1,c_=class extends vP{constructor({messages:t,...n}){const i=new gX(t);super({...n,state:i}),Vs(this,p1,void 0),this["~registerMessagesCallback"]=(s,u)=>er(this,p1)["~registerMessagesCallback"](s,u),this["~registerStatusCallback"]=s=>er(this,p1)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>er(this,p1)["~registerErrorCallback"](s),Xu(this,p1,i)}};p1=new WeakMap;function vX({experimental_throttle:e,resume:t=!1,...n}={}){const i=A.useRef("chat"in n?n.chat:new c_(n));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new c_(n));const u=A.useCallback(y=>i.current["~registerMessagesCallback"](y,e),[e,i.current.id]),f=A.useSyncExternalStore(u,()=>i.current.messages,()=>i.current.messages),d=A.useSyncExternalStore(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),m=A.useSyncExternalStore(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),v=A.useCallback(y=>{typeof y=="function"&&(y=y(i.current.messages)),i.current.messages=y},[i]);return A.useEffect(()=>{t&&i.current.resumeStream()},[t,i]),{id:i.current.id,messages:f,setMessages:v,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:m,resumeStream:i.current.resumeStream,status:d,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput}}function yX(e){const t=new Map,n=[],i=s=>s.parts.filter(u=>{if(u.type==="text"){const f=u.text;return f&&f.trim()!==""}return u.type!=="step-start"});for(const s of e)if(t.has(s.id)){const u=t.get(s.id);t.set(s.id,{...u,parts:[...i(u),...i(s)]})}else n.push(s.id),t.set(s.id,{...s,parts:i(s)});return n.map(s=>t.get(s)).filter(s=>s.parts.length>0)}function xX(e){const t=vX(e);if(!(e!=null&&e.enableMerge))return t;const n=A.useMemo(()=>yX(t.messages),[t.messages]);return{...t,messages:n}}const wX=(e,t)=>{const n=Ki();A.useEffect(()=>{n.emit("chat-msg-status-change",{messageId:e,status:t})},[e,t])},C2=(e,t)=>{const n=Ki();A.useEffect(()=>{const i=s=>t(s);return n.on(e,i),()=>{n.off(e,i)}},[e,t])},bX=({client:e})=>{var le,se,ve;const t=Jd(e),n=Ci(_e=>_e.setLastBotMessage),{exec:i=()=>{}}=Fl("onAfterChatAreaHide"),{exec:s=()=>{}}=Fl("onBeforeMessagesClear"),u=A.useMemo(()=>{var _e;return new xb({api:(_e=e==null?void 0:e.options)==null?void 0:_e.chatApiEndpoint,headers:()=>{var ke;return{...(ke=e==null?void 0:e.options)==null?void 0:ke.chatApiHeaders}}})},[(le=e==null?void 0:e.options)==null?void 0:le.chatApiEndpoint,(se=e==null?void 0:e.options)==null?void 0:se.chatApiHeaders]),{messages:f,sendMessage:d,status:m,id:v,setMessages:y,stop:x,addToolOutput:k,regenerate:S}=xX({transport:u,enableMerge:t==null?void 0:t.enableMessageMerge,onError:_e=>{console.error("Chat transport error:",_e),y(ke=>[...ke,{id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:`Error: ${_e.message||"An error occurred during chat."}`,providerMetadata:{raw:{data:{type:"agent-error",error:"智能体内部错误,请稍后重试"}}}}]}])}}),L=A.useCallback(_e=>{y(ke=>[...ke,{id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:_e,providerMetadata:{raw:{data:{type:"agent-fake-msg",error:_e}}}}]}])},[y]);A.useEffect(()=>{e._sendMessage=d,e._appendFakeBotMessage=L,e.markChatComponentReady()},[d,e,L]),A.useEffect(()=>{const _e=f.filter(ke=>ke.role==="assistant").pop();n(_e)},[f,n]);const T=sf();A.useEffect(()=>{var _e,ke;(m==="error"||m==="ready")&&(T==null||T.clearGlobalFakeLoadingMessage()),(ke=(_e=e==null?void 0:e.options)==null?void 0:_e.onMessageStatusChange)==null||ke.call(_e,m,(e==null?void 0:e.getLastBotMsg(!0))||"")},[m]),C2("send-ghost-msg",_e=>{const{text:ke,options:Ae}=_e;d({text:ke},Ae)});const{isHide:M}=u2();A.useEffect(()=>{M&&(x(),i({clearMsgs:()=>{s(v),y(()=>[])}}))},[M,x]);const[j,F]=A.useState(""),[P,z]=A.useState([]),Z=Vd("MessageInputTopSlot"),$=Z==null?void 0:Z.Component,G=`${_0((ve=e.options)==null?void 0:ve.backendApiEndpoint)}form/attachment/upload`,Y=b.jsx(sX,{fileUploadEndpoint:G,attachments:P,chatId:v,input:j,messages:f,sendMessage:d,setAttachments:z,setInput:F,setMessages:y,status:m,stop:x}),me=$?b.jsx($,{}):null,ce=$?b.jsxs("div",{className:"flex flex-col gap-[12px]",children:[me,Y]}):Y;return wX(v,m),A.useEffect(()=>()=>{x()},[]),b.jsx(yP,{messagesArea:b.jsx(lq,{regenerate:S,status:m,messages:f,setMessages:y,sendMessage:d,addToolOutput:k}),inputArea:ce})},S2=({children:e,className:t,minimal:n,entryVariant:i="default",icon:s,...u})=>{const f={default:"relative overflow-hidden bg-[linear-gradient(180deg,#DBE9FF_0%,#E9FFFD_100%)] h-[30px] hover:text-white before:content-[''] before:absolute before:inset-0 before:z-0 before:bg-[linear-gradient(180deg,#267AFF_0%,#B2EEFF_100%)] before:opacity-0 hover:before:opacity-100 before:transition-opacity before:duration-200 before:ease-out font-[500] text-[#0265ff]",ghost:"bg-transparent text-[#030303] font-[400] px-[10px] hover:bg-[#EFF0F6] h-[34px]",light:"text-[#030303] font-[400] px-[10px] bg-[#F0F6FF] hover:bg-[#d8dde5] h-[34px]",selected:"bg-[#EFF0F6] text-[#030303] font-[400] px-[10px]"};return b.jsx($d,{...u,variant:"entry",size:"entry",className:Fe("rounded-[4px] cursor-pointer",Fr,f[i],t),children:b.jsxs("span",{className:"relative z-10 inline-flex items-center gap-1.5",children:[s!=null?s:b.jsx(Kb,{}),n?null:e]})})},k2=({id:e,style:t="",rootEl:n,containerClasses:i=[],wrapperClasses:s=[],wrapperStyle:u={},extraHtml:f=""})=>{const[d,m]=A.useState(null),v=A.useRef(null);return A.useEffect(()=>{var y;(y=v.current)==null||y.classList.add(...s),d==null||d.classList.add(...i)},[s,i]),A.useEffect(()=>{v.current&&Object.entries(u).forEach(([y,x])=>{x!==void 0&&(v.current.style[y]=x)})},[u]),A.useEffect(()=>{v.current&&v.current.parentNode&&(v.current.parentNode.removeChild(v.current),v.current=null);try{const y=document.createElement("div");y.classList.add(...s,"wrapper"),v.current=y,Object.entries(u).forEach(([L,T])=>{T!==void 0&&(y.style[L]=T)});const x=y.attachShadow({mode:"open"});if(f&&(x.innerHTML=f),t){const L=document.createElement("style");L.textContent=t,x.appendChild(L)}const k=document.createElement("div");k.classList.add(...i,"shadow-container"),x.appendChild(k),(n||document.body).appendChild(y),m(k)}catch(y){console.error("创建Shadow DOM失败:",y),m(null)}},[n]),d&&(d.id=e),{shadowContainer:d,destroy:()=>{v.current&&v.current.parentNode&&(v.current.parentNode.removeChild(v.current),v.current=null)}}},CX=({avatar:e,width:t,onDockClick:n,onCloseClick:i,draggable:s,isDragging:u,isDocked:f,onDragStart:d})=>b.jsxs("div",{className:Fe("flex items-center justify-between","px-4","h-[52px] min-w-[200px]",{"w-full":!t,[`w-[${t}px]`]:t,"cursor-grab":s&&!u,"cursor-grabbing":u}),style:{backgroundImage:mz,backgroundSize:"cover",backgroundRepeat:"no-repeat"},onMouseDown:s?d:void 0,children:[e,b.jsxs("div",{className:"actions flex items-center gap-2.5 text-[#666]",children:[b.jsx(ef,{onMouseDown:m=>{m.stopPropagation()},tooltip:f?"悬浮":"右侧打开",icon:f?b.jsx(jz,{}):b.jsx(Dz,{}),onClick:n}),b.jsx(ef,{icon:b.jsx(Fz,{}),onClick:i})]})]}),SX={bottom:10,right:10};function kX(e={}){const{enabled:t=!0,initialPosition:n=SX,onPositionChange:i}=e,s=A.useMemo(()=>n,[n.bottom,n.right]),[u,f]=A.useState(s),[d,m]=A.useState(!1),v=A.useRef(i);v.current=i;const y=A.useRef({isDragging:!1,startX:0,startY:0,startBottom:0,startRight:0}),x=A.useRef(null),k=A.useCallback(()=>{var L;f(s),(L=v.current)==null||L.call(v,s)},[s]),S=A.useCallback(L=>{if(!t)return;L.preventDefault(),L.stopPropagation(),y.current={isDragging:!0,startX:L.clientX,startY:L.clientY,startBottom:u.bottom,startRight:u.right},m(!0),document.body.style.userSelect="none",document.body.style.cursor="grabbing";const T=j=>{y.current.isDragging&&(x.current!==null&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var Z;const F=j.clientX-y.current.startX,P=j.clientY-y.current.startY,z={right:Math.max(10,y.current.startRight-F),bottom:Math.min(y.current.startBottom-P,10)};f(z),(Z=v.current)==null||Z.call(v,z)}))},M=()=>{y.current.isDragging=!1,m(!1),document.body.style.userSelect="",document.body.style.cursor="",x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",T),document.addEventListener("mouseup",M)},[t,u]);return A.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),document.body.style.userSelect="",document.body.style.cursor=""},[]),{position:u,isDragging:d,handleDragStart:S,resetPosition:k}}const EX=({client:e})=>{var L,T,M,j;const{setStatus:t,isVisible:n,isFloat:i,isDock:s}=u2(),{position:u,isDragging:f,handleDragStart:d,resetPosition:m}=kX({enabled:i,initialPosition:{bottom:10,right:10}});A.useEffect(()=>{s&&m()},[s,m]);const v=Fe({"fixed z-50 rounded-lg":i,"shadow-lg":i&&!f,"shadow-2xl scale-[1.01] transition-shadow":i&&f,hidden:!n,"static w-full h-full shadow-md":s}),y=Vd("AvatarAndName"),x=y==null?void 0:y.Component,k=x?b.jsx(x,{variant:"active"}):b.jsx(hh,{name:((T=(L=e==null?void 0:e.options)==null?void 0:L.botInfo)==null?void 0:T.name)||"AI表单搭建",variant:"active"}),S=i?{width:354,height:"calc(100% - 20px)",bottom:`${u.bottom}px`,right:`${u.right}px`,zIndex:(j=(M=e==null?void 0:e.options)==null?void 0:M.safeZIndex)!=null?j:1}:{};return b.jsxs("div",{className:Fe("bg-white flex flex-col overflow-hidden",v),style:S,children:[b.jsx(CX,{onDockClick:()=>{t(i?"dock":"float")},isDocked:s,avatar:k,onCloseClick:()=>{t("hide")},draggable:i,isDragging:f,onDragStart:d}),b.jsx(bX,{client:e})]})},_X=({client:e})=>{var f,d,m;const{isVisible:t,container:n}=Ci(v=>({isVisible:v.chatStatus!=="hide",container:v.chatAreaContainer})),i=["h-full","w-full"],s={height:"100%",width:"100%"},{shadowContainer:u}=k2({id:"chat-sdk-content",style:((f=e==null?void 0:e.options)==null?void 0:f.style)||"",rootEl:n||((d=e==null?void 0:e.options)==null?void 0:d.el)||document.body,containerClasses:t?i:[],wrapperClasses:t?i:[],wrapperStyle:t?s:{},extraHtml:((m=e==null?void 0:e.options)==null?void 0:m.extraHtml)||""});return u?Nl.createPortal(b.jsx(EX,{client:e}),u):null},RX=({client:e})=>{var M,j,F;const{bottom:t=15,right:n=40}=((M=e==null?void 0:e.options)==null?void 0:M.btnOffset)||{},{entryVisible:i,status:s,entryWrapper:u,setStatus:f,isVisible:d,entryVariant:m}=Ci(P=>({setStatus:P.setChatStatus,entryVariant:P.chatEntryVariant,entryWrapper:P.chatEntryElWrapper,isVisible:P.chatStatus!=="hide",status:P.chatStatus,entryVisible:P.chatEntryVisible})),v=!!u,y=Vd("EntryButton"),x=y==null?void 0:y.Component,k=v?{cursor:"pointer"}:{position:"fixed",cursor:"pointer",bottom:t,right:n,zIndex:(j=e==null?void 0:e.options)==null?void 0:j.safeZIndex},S=x?b.jsx(x,{chatStatus:s,client:e,variant:m,chatVisible:d,style:k,onClick:()=>{f("dock")}}):b.jsx(S2,{style:k,minimal:d,onClick:()=>{f("dock")},children:"AI助手"}),{shadowContainer:L,destroy:T}=k2({id:"chat-sdk-entry",rootEl:u,containerClasses:["inline-flex"],wrapperClasses:["inline-flex","flex","items-center"],style:((F=e==null?void 0:e.options)==null?void 0:F.style)||""});return i?v?L?Nl.createPortal(S,L):null:(T(),S):null},TX=({client:e,config:t})=>{var S,L;const{setStatus:n,isVisible:i,status:s}=Ci(T=>({setStatus:T.setChatStatus,isVisible:T.chatStatus!=="hide",status:T.chatStatus})),u=Vd("EntryButton"),f=u==null?void 0:u.Component,d=!!t.wrapperEl,m=d?{cursor:"pointer"}:{position:"fixed",cursor:"pointer",zIndex:(S=e==null?void 0:e.options)==null?void 0:S.safeZIndex},v=()=>{n("dock")},y=f?b.jsx(f,{chatStatus:s,client:e,variant:t.variant,chatVisible:i,style:m,onClick:v}):b.jsx(S2,{style:m,minimal:i,onClick:v,children:"AI助手"}),{shadowContainer:x,destroy:k}=k2({id:`chat-sdk-entry-${t.id}`,rootEl:t.wrapperEl,containerClasses:["inline-flex"],wrapperClasses:["inline-flex"],style:((L=e==null?void 0:e.options)==null?void 0:L.style)||""});return t.visible?d?x?Nl.createPortal(y,x):null:(k(),y):null},LX=({client:e})=>{const t=Ci(i=>i.chatEntryButtons),n=Array.from(t.values());return n.length===0?null:b.jsx(b.Fragment,{children:n.map(i=>b.jsx(TX,{client:e,config:i},i.id))})},AX=({client:e})=>b.jsxs(b.Fragment,{children:[b.jsx(_X,{client:e}),b.jsx(RX,{client:e}),b.jsx(LX,{client:e})]}),NX=({store:e,client:t})=>{var n;return b.jsx(KN,{store:e,children:b.jsx(oS,{delayDuration:100,zIndex:((n=t==null?void 0:t.options)==null?void 0:n.safeZIndex)!=null?t.options.safeZIndex+1:50,children:b.jsx(AX,{client:t})})})};class MX{constructor(){ze(this,"events",new Map)}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),this}off(t,n){const i=this.events.get(t);if(!i)return this;const s=i.indexOf(n);return s>-1&&i.splice(s,1),this}emit(t,n){const i=this.events.get(t);return!i||i.length===0?!1:(i.slice().forEach(s=>{try{s(n)}catch(u){console.error(`Error in event handler for "${String(t)}":`,u)}}),!0)}once(t,n){const i=s=>{n(s),this.off(t,i)};return this.on(t,i)}listenerCount(t){var n,i;return(i=(n=this.events.get(t))==null?void 0:n.length)!=null?i:0}eventNames(){return Array.from(this.events.keys())}removeAllListeners(t){return t?this.events.delete(t):this.events.clear(),this}listeners(t){var n,i;return(i=(n=this.events.get(t))==null?void 0:n.slice())!=null?i:[]}}class OX extends MX{}const m1=class m1{constructor(t){ze(this,"root");ze(this,"Store");ze(this,"chatComponentReadyResolve");ze(this,"chatComponentReadyPromise");ze(this,"options");ze(this,"eventBus",new OX);ze(this,"_sendMessage");ze(this,"_appendFakeBotMessage");ze(this,"appendBotMessage",async t=>{var n;await this.whenChatComponentReady(),(n=this._appendFakeBotMessage)==null||n.call(this,t)});ze(this,"sendMessage",async(t,n,i)=>{var s;await this.whenChatComponentReady(),(s=this._sendMessage)==null||s.call(this,{text:t},{...i,body:{...(i==null?void 0:i.body)||{},userVar:n}})});this.chatComponentReadyPromise=new Promise(i=>{this.chatComponentReadyResolve=i}),this.options=t;const n=document.createElement("div");document.body.appendChild(n),n.id=`bs-chat-sdk-inst-root-${Date.now()}`,this.options.style+=__SDK_STYLES__,this.Store=HN(this),UN(this.Store,this.options),this.initPlugins(),this.root=Q4(n),this.root.render(b.jsx(NX,{client:this,store:this.Store})),m1.instances.push(this)}diposePlugins(){this.Store.getState().chatAreaPluginInstList.forEach(n=>{typeof n.dispose=="function"&&(n.dispose(),n.Context={})})}initPlugins(){var n;if(!this.options||!((n=this.options.plugins)!=null&&n.length))return;const t=this.options.plugins.map(i=>{var f;const s=i.createContext(),u=new i.Plugin(s);return(f=u.init)==null||f.call(u,this),u});this.Store.getState().setChatAreaPluginInstList(t)}setGlobalLoadingMessage(t){this.Store.getState().setGlobalFakeLoadingMessage(t)}getPluginCtx(t){var i;const n=this.Store.getState().chatAreaPluginInstList.find(s=>s.pluginName===t);return n?(i=n.getReadonlyContext)==null?void 0:i.call(n):void 0}getPluginMethod(t,n){const i=this.Store.getState().chatAreaPluginInstList.find(s=>s.pluginName===t);if(i&&typeof i[n]=="function")return i[n]}markChatComponentReady(){this.chatComponentReadyResolve()}whenChatComponentReady(){return this.chatComponentReadyPromise}clearChatHistory(){this.Store.getState().clearMessages()}getLastBotMsg(t){const n=this.Store.getState().lastBotMessage;if(n)return t?n.parts.filter(i=>i.type==="text").map(i=>i.text).join(""):n}getFullStyle(){return this.options.style}showChatArea(t,n){t?this.dockChatArea(n):this.Store.getState().setChatStatus("float")}setAuthToken(t){var i;((i=this.options.chatApiHeaders)==null?void 0:i.Authorization)!==`Bearer ${t}`&&(this.options.chatApiHeaders={...this.options.chatApiHeaders,Authorization:`Bearer ${t}`})}getChatStatus(){return this.Store.getState().chatStatus}isChatVisible(){return this.Store.getState().chatStatus!=="hide"}hideChatArea(){this.Store.getState().setChatStatus("hide")}dockChatArea(t){const n=this.Store.getState().chatAreaContainer;t===n&&this.Store.getState().chatStatus==="dock"||(this.Store.getState().setChatEntryVisible(!1),this.Store.getState().setChatAreaContainer(t),this.Store.getState().setChatStatus("dock"))}undockChatArea(){this.Store.getState().setChatAreaContainer(void 0),this.Store.getState().setChatEntryVisible(!0),this.Store.getState().setChatStatus("float")}isChatFloat(){return this.Store.getState().chatStatus==="float"}isChatDocked(){return this.Store.getState().chatStatus==="dock"}showChatEntryButton(t,n="default",i){i?this.upsertChatEntryButton(i,t,n):(this.Store.getState().setChatEntryVariant(n),this.Store.getState().setChatEntryVisible(!0,t))}hideChatEntryButton(t){t?this.Store.getState().setChatEntryButtonVisible(t,!1):this.Store.getState().setChatEntryVisible(!1)}upsertChatEntryButton(t,n,i="default"){this.Store.getState().upsertChatEntryButton({id:t,visible:!0,variant:i,wrapperEl:n})}removeChatEntryButton(t){this.Store.getState().removeChatEntryButton(t)}destroy(){this.diposePlugins(),this.eventBus.removeAllListeners(),m1.instances=m1.instances.filter(t=>t!==this)}};ze(m1,"instances",[]);let Y5=m1;const ea={CREATE_FORM:"form-builder-FormCreateConfirmed",CREATE_FORM_SUCCESS:"form-builder-FormCreateSuccess",CREATE_FORM_FAILED:"form-builder-FormCreateFailed",UPDATE_FORM_INFO:"form-builder-FormInfoUpdated",SAVE_FIELDS:"form-builder-FieldsConfirmed",FIELD_CREATED:"form-builder-FieldCreated",FIELDS_CLEARED:"form-builder-FieldsCleared",FIELDS_CREATED_FINISH:"form-builder-FieldsCreatedFinish",FIELD_CHECK_UPDATE:"form-builder-FieldCheckedChanged"},DX=()=>{const[e,t]=A.useState(!1);return C2(ea.SAVE_FIELDS,()=>{t(!0)}),e},uf=e=>{const{pluginMap:t}=Ci(n=>({pluginMap:n.chatAreaPluginMap}));return t.get(e)},Pl="McpFormBuilderPlugin",jX={mode:"tree",extendSet:{sort:["datahelp","module","formEvent"],status:!0,triggerField:"",triggerFieldMode:"none"},dataloadmode:["add","cover"]},cf={text:"输入框",password:"密码输入框",location:"定位",datetime:"日期时间选择器",radiogroup:"单选框",radio:"单选框",combo:"下拉框",address:"地址",button:"按钮",textarea:"多行输入框",combocheck:"多选下拉框",checkboxgroup:"多选框组",separator:"分割线",upload:"附件上传",number:"数字输入框",dataload:"数据加载",image:"图片上传",signature:"签名",dept:"部门选择",user:"成员选择",usergroup:"成员多选",deptgroup:"部门多选",unknown:"未知类型",sn:"流水号",formula:"公式字段",linkdata:"关联数据",linkquery:"关联查询",subform:"子表单",flowState:"流程状态",flowstate:"流程状态"},FX={address:"&#xe881;",subform:"&#xe847;",password:"&#xe854;",button:"&#xe8e8;",textarea:"&#xe84f;",datetime:"&#xe849;",text:"&#xe854;",location:"&#xe87f;",radiogroup:"&#xe853;",radio:"&#xe861;",combo:"&#xe84a;",formula:"",flowState:"",flowstate:"",combocheck:"&#xe84b;",separator:"&#xe850;",checkboxgroup:"&#xe84c;",upload:"&#xe621;",number:"&#xe846;",image:"&#xe880;",signature:"&#xe87e;",user:"&#xe856;",dataload:"&#xe848;",linkdata:"&#xe857;",linkquery:"&#xe857;",usergroup:"&#xe851;",dept:"&#xe84d;",sn:"&#xe882;",deptgroup:"&#xe852;",unknown:"&#xe848;"},IX={metric_table:"&#xe88c;",gauge_chart:"&#xe88d;",column_chart:"&#xe892;",funnel_chart:"&#xe89c;",line_chart:"&#xe88b;",pie_chart:"&#xe89e;",area_chart:"&#xe898;",radar_chart:"&#xe893;",bar_chart:"&#xe896;",gantt:"&#xe899;",multi_axes_chart:"&#xe88f;",data_table:"&#xe894;",background_table:"&#xe894;",pivot_table:"&#xe891;",map_chart:"&#xe89d;",newMap:"&#xe89d;",card:"&#xe8f4;",rili:"&#xe849;",description:"&#xe88e;",image:"&#xe890;",gauge_imageMore:"&#xe88d;"},X5=({type:e})=>{const t=FX[e]||"unknown";return e==="formula"?b.jsx(Jz,{}):b.jsx(ph,{code:t})},PX=(e,t)=>{const n=dh(e),i=Array.isArray(e)&&e.length?e:n?[e]:[],s=Ki(),u=uf(Pl);return i.map(f=>{var m;const d=$b(f);return d!=null&&d.widget?{field:d,disabled:t,onLoaded:v=>{const y=u==null?void 0:u.onBeforeFieldCreate(v);s.emit("form-builder-FieldCreated",{field:y,checked:!0}),u==null||u.onAfterFieldCreate(v)},icon:b.jsx(X5,{type:(m=d.widget)==null?void 0:m.type}),onChange:(v,y,x,k)=>{console.log("field checked changed:",{check:v,field:y,parentFieldName:x,index:k}),s.emit("form-builder-FieldCheckedChanged",{field:y,checked:v,parentFieldName:x,index:k})}}:null}).filter(Boolean)};var E2="Checkbox",[zX]=Ds(E2),[HX,J5]=zX(E2);function UX(e){const{__scopeCheckbox:t,checked:n,children:i,defaultChecked:s,disabled:u,form:f,name:d,onCheckedChange:m,required:v,value:y="on",internal_do_not_use_render:x}=e,[k,S]=Yd({prop:n,defaultProp:s!=null?s:!1,onChange:m,caller:E2}),[L,T]=A.useState(null),[M,j]=A.useState(null),F=A.useRef(!1),P=L?!!f||!!L.closest("form"):!0,z={checked:k,disabled:u,setChecked:S,control:L,setControl:T,name:d,form:f,value:y,hasConsumerStoppedPropagationRef:F,required:v,defaultChecked:Ju(s)?!1:s,isFormControl:P,bubbleInput:M,setBubbleInput:j};return b.jsx(HX,{scope:t,...z,children:BX(x)?x(z):i})}var f_="CheckboxTrigger",d_=A.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...i},s)=>{const{control:u,value:f,disabled:d,checked:m,required:v,setControl:y,setChecked:x,hasConsumerStoppedPropagationRef:k,isFormControl:S,bubbleInput:L}=J5(f_,e),T=Rn(s,y),M=A.useRef(m);return A.useEffect(()=>{const j=u==null?void 0:u.form;if(j){const F=()=>x(M.current);return j.addEventListener("reset",F),()=>j.removeEventListener("reset",F)}},[u,x]),b.jsx(Qt.button,{type:"button",role:"checkbox","aria-checked":Ju(m)?"mixed":m,"aria-required":v,"data-state":y_(m),"data-disabled":d?"":void 0,disabled:d,value:f,...i,ref:T,onKeyDown:Ut(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ut(n,j=>{x(F=>Ju(F)?!0:!F),L&&S&&(k.current=j.isPropagationStopped(),k.current||j.stopPropagation())})})});d_.displayName=f_;var p_=A.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:i,checked:s,defaultChecked:u,required:f,disabled:d,value:m,onCheckedChange:v,form:y,...x}=e;return b.jsx(UX,{__scopeCheckbox:n,checked:s,defaultChecked:u,disabled:d,required:f,onCheckedChange:v,name:i,form:y,value:m,internal_do_not_use_render:({isFormControl:k})=>b.jsxs(b.Fragment,{children:[b.jsx(d_,{...x,ref:t,__scopeCheckbox:n}),k&&b.jsx(v_,{__scopeCheckbox:n})]})})});p_.displayName=E2;var h_="CheckboxIndicator",m_=A.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:i,...s}=e,u=J5(h_,n);return b.jsx(jl,{present:i||Ju(u.checked)||u.checked===!0,children:b.jsx(Qt.span,{"data-state":y_(u.checked),"data-disabled":u.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});m_.displayName=h_;var g_="CheckboxBubbleInput",v_=A.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:i,hasConsumerStoppedPropagationRef:s,checked:u,defaultChecked:f,required:d,disabled:m,name:v,value:y,form:x,bubbleInput:k,setBubbleInput:S}=J5(g_,e),L=Rn(n,S),T=M5(u),M=T9(i);A.useEffect(()=>{const F=k;if(!F)return;const P=window.HTMLInputElement.prototype,Z=Object.getOwnPropertyDescriptor(P,"checked").set,$=!s.current;if(T!==u&&Z){const G=new Event("click",{bubbles:$});F.indeterminate=Ju(u),Z.call(F,Ju(u)?!1:u),F.dispatchEvent(G)}},[k,T,u,s]);const j=A.useRef(Ju(u)?!1:u);return b.jsx(Qt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f!=null?f:j.current,required:d,disabled:m,name:v,value:y,form:x,...t,tabIndex:-1,ref:L,style:{...t.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});v_.displayName=g_;function BX(e){return typeof e=="function"}function Ju(e){return e==="indeterminate"}function y_(e){return Ju(e)?"indeterminate":e?"checked":"unchecked"}const VX=()=>b.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("rect",{x:"0.5",y:"0.5",width:"7",height:"7",rx:"1",fill:"#0265ff"})}),Q5=A.forwardRef(({className:e,children:t,id:n,readonly:i,disabled:s,intermediate:u,...f},d)=>{const m=A.useId(),v=n!=null?n:m;return b.jsxs("label",{htmlFor:v,className:Fe("inline-flex items-center gap-[6px] select-none text-[#121111] text-[14px]",s?"cursor-not-allowed":"cursor-pointer",{"pointer-events-none":i}),children:[b.jsx(p_,{ref:d,id:v,disabled:s,className:Fe("inline-flex shrink-0 items-center justify-center","w-[16px] h-[16px] rounded-[2px] box-border border","transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0265FF] focus-visible:ring-offset-1","border-[#E0E0E0] bg-white","hover:border-[#0265FF]","data-[state=checked]:bg-[#0265FF] data-[state=checked]:border-[#0265FF]","disabled:cursor-not-allowed disabled:bg-[#F0F0F0] disabled:border-[#C2C2C2]","disabled:data-[state=checked]:bg-[#C2C2C2] disabled:data-[state=checked]:border-[#C2C2C2]",u&&"bg-white border-[#0265FF] text-[#0265FF]",e,{"opacity-50":i}),...f,children:b.jsx(m_,{className:"text-white",forceMount:u||void 0,children:u?b.jsx(VX,{}):b.jsx(Jb,{})})}),t!=null&&b.jsx("span",{className:Fe("text-sm leading-none",s&&"text-[#C2C2C2]"),children:t})]})});Q5.displayName="SquareChecker";const _2=({defaultChecked:e=!1,checked:t,disabled:n=!1,onCheckedChange:i,icon:s,className:u,title:f,extra:d,style:m,streaming:v,confirmed:y,readonly:x,shortDesc:k})=>{const[S,L]=A.useState(e);A.useEffect(()=>{t!==void 0&&L(t)},[t]);const T=()=>{if(v||n)return;const F=!S;L(F),i==null||i(F)},M=!!d,j=y&&S?b.jsx(Qb,{className:"grow-0 shrink-0 text-[#0265ff]"}):b.jsx(Q5,{className:Wr("outline-none grow-0 shrink-0 cursor-pointer",{"mt-[2px]":M,"opacity-80 cursor-not-allowed":n,"opacity-50":v,"pointer-events-none":v}),id:f,checked:S,disabled:n||y,onCheckedChange:T});return b.jsxs("div",{className:Fe("flex items-center gap-[10px] px-4 py-[10px] rounded-[4px]","w-full transition-colors cursor-pointer",{"cursor-not-allowed":n,"hover:bg-[#EFF0F6]":!n,"items-start":M,"items-center":!M,"pointer-events-none":v||n||x||y},u),style:m,onClick:()=>{T()},children:[x?null:j,b.jsxs("div",{className:Wr("flex flex-col flex-1 min-w-0",{"gap-2.5":M}),children:[b.jsxs("div",{className:Wr("flex items-center justify-between w-full",{"gap-1.5":!!s,"gap-2.5":!s}),children:[b.jsxs("div",{className:Wr("flex items-center gap-[6px] min-w-0",{"flex-1":!!s,"w-[100px] flex-shrink-0":!s}),children:[s&&b.jsx("div",{className:"w-4 h-4 flex-shrink-0 text-[#6F829E] leading-[16px]",children:s}),b.jsx("p",{className:Wr(" min-w-0 text-sm text-[#121111] truncate text-[12px]",{"flex-1":!!s,"flex-grow-1 flex-shrink-0":!s,"!text-[#666]":x}),children:f})]}),k&&b.jsx("p",{className:Wr("text-sm text-[#666] text-[12px]",{"whitespace-nowrap flex-shrink-0":!!s,anywhere:!s,"!text-[#121111]":x}),children:k})]}),M?b.jsx("div",{className:Fe("overflow-x-auto whitespace-nowrap no-scrollbar flex items-center gap-2",{"!overflow-x-hidden":n||x||y}),children:d}):null]})]})},$X=({bgColor:e="#E8F4FF",color:t="#0265FF",label:n,children:i})=>b.jsx("div",{className:"flex items-center justify-center gap-1.5 px-1.5 h-[26px] rounded-[100px] text-[13px]",style:{backgroundColor:e,color:t},children:n||i}),x_=A.memo(({field:e,disabled:t,isSubField:n,onChange:i,onLoaded:s,icon:u,value:f,checked:d,streaming:m,confirmed:v})=>{const{widget:y,label:x}=e;if(!y)return null;const{type:k}=y,S=k;if(!cf.hasOwnProperty(k))return null;const L=cf[S]||cf.unknown,T=k==="subform",M=T?[]:y.items||[],j=T?y.items:[],[F,P]=A.useState(()=>Object.fromEntries(j.map((Y,me)=>[me,!0]))),z=A.useRef(d);A.useEffect(()=>{T&&d!==z.current&&(z.current=d,d!==void 0&&P(Object.fromEntries(j.map((Y,me)=>[me,d]))))},[d,T,j.length]);const Z=(Y,me,ce)=>{P(le=>{const se={...le,[ce]:Y};return Object.values(se).every(Boolean)&&(i==null||i(!0,e)),Object.values(se).every(ke=>ke===!1)&&(i==null||i(!1,e)),se}),i==null||i(Y,me,e.widget.widgetName,ce)};A.useEffect(()=>{s==null||s(e)},[]);const $=Y=>{i==null||i(Y,e)},G=n?"pl-[38px]":"";return f?b.jsx(_2,{title:x,disabled:t,checked:d,defaultChecked:!0,onCheckedChange:$,icon:u,className:G,shortDesc:f}):b.jsxs(b.Fragment,{children:[b.jsx(_2,{streaming:m,confirmed:v,title:x,disabled:t,checked:d,defaultChecked:!0,onCheckedChange:$,icon:u,shortDesc:L,className:G,extra:M.length?b.jsx(b.Fragment,{children:M.map(({value:Y,text:me,color:ce})=>b.jsx($X,{color:ce?"white":void 0,bgColor:ce,children:me},Y))}):null}),T?j.map((Y,me)=>{var ce;return b.jsx(x_,{confirmed:v,streaming:m,isSubField:!0,disabled:t,checked:F[me],field:Y,icon:b.jsx(X5,{type:(ce=Y.widget)==null?void 0:ce.type}),onChange:le=>{Z(le,Y,me)}},Y.label)}):null]})},(e,t)=>{var n,i;return((n=e.field)==null?void 0:n.label)===((i=t.field)==null?void 0:i.label)&&e.disabled===t.disabled&&e.checked===t.checked&&e.confirmed===t.confirmed&&e.streaming===t.streaming}),Qu="form-filling-plugin",ri={FORM_STRUCTURE_READY:"form-filling-structure-ready",FIELD_FILLED_UPDATE:"form-filling-field-filling-update",FIELDS_CHECKED_UPDATE:"form-filling-fields-checked-update",FILL_MODE_UPDATE:"form-filling-mode-update",BATCH_FILL_BEGIN:"form-filling-batch-fill-begin",FILL_DATA_CONFIRMED:"form-filling-fields-data-confirmed"},ZX=new Set(["password","textarea","datetime","text","radiogroup","radio","combo","combocheck","checkboxgroup","number"]),ff=10;function WX(e){return Array.isArray(e)?e.every(t=>typeof t=="string"):!1}function w_(e){return Array.isArray(e)?e.every(t=>typeof t=="object"&&t!==null&&"label"in t&&"value"in t&&typeof t.label=="string"&&typeof t.value=="string"):!1}const b_=e=>WX(e)?e.join(", "):w_(e)?e.map(n=>n.value).join(", "):e,C_=(e,t)=>{if(t==="address"&&typeof e=="object"){const n=e;return`${n.province} ${n.city} ${n.district} ${n.detail}`}if(t==="location"&&typeof e=="object"){const i=e.lnglatXY||["",""];return`经度: ${i[0]||""}, 纬度: ${i[1]||""}`}return Array.isArray(e)?e.join(", "):w_(e)?e.map(i=>i.value).join(", "):e},S_=e=>Array.isArray(e)?e.filter(t=>{var n;return ZX.has((n=t.widget)==null?void 0:n.type)}):[];var R2="Collapsible",[GX]=Ds(R2),[qX,K5]=GX(R2),k_=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:i,defaultOpen:s,disabled:u,onOpenChange:f,...d}=e,[m,v]=Yd({prop:i,defaultProp:s!=null?s:!1,onChange:f,caller:R2});return b.jsx(qX,{scope:n,disabled:u,contentId:Uu(),open:m,onOpenToggle:A.useCallback(()=>v(y=>!y),[v]),children:b.jsx(Qt.div,{"data-state":ty(m),"data-disabled":u?"":void 0,...d,ref:t})})});k_.displayName=R2;var E_="CollapsibleTrigger",YX=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,...i}=e,s=K5(E_,n);return b.jsx(Qt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":ty(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:t,onClick:Ut(e.onClick,s.onOpenToggle)})});YX.displayName=E_;var ey="CollapsibleContent",__=A.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=K5(ey,e.__scopeCollapsible);return b.jsx(jl,{present:n||s.open,children:({present:u})=>b.jsx(XX,{...i,ref:t,present:u})})});__.displayName=ey;var XX=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:i,children:s,...u}=e,f=K5(ey,n),[d,m]=A.useState(i),v=A.useRef(null),y=Rn(t,v),x=A.useRef(0),k=x.current,S=A.useRef(0),L=S.current,T=f.open||d,M=A.useRef(T),j=A.useRef(void 0);return A.useEffect(()=>{const F=requestAnimationFrame(()=>M.current=!1);return()=>cancelAnimationFrame(F)},[]),go(()=>{const F=v.current;if(F){j.current=j.current||{transitionDuration:F.style.transitionDuration,animationName:F.style.animationName},F.style.transitionDuration="0s",F.style.animationName="none";const P=F.getBoundingClientRect();x.current=P.height,S.current=P.width,M.current||(F.style.transitionDuration=j.current.transitionDuration,F.style.animationName=j.current.animationName),m(i)}},[f.open,i]),b.jsx(Qt.div,{"data-state":ty(f.open),"data-disabled":f.disabled?"":void 0,id:f.contentId,hidden:!T,...u,ref:y,style:{"--radix-collapsible-content-height":k?`${k}px`:void 0,"--radix-collapsible-content-width":L?`${L}px`:void 0,...e.style},children:T&&s})});function ty(e){return e?"open":"closed"}var JX=k_;const R_=JX,T_=__,QX=({disabled:e,onCheckedChange:t,label:n,val:i,streaming:s,readonly:u})=>b.jsx(_2,{streaming:s,readonly:u,title:n,disabled:e,defaultChecked:!0,onCheckedChange:t,className:"pl-[36px]",shortDesc:i}),KX=A.memo(({field:e,readonly:t,onCheckedChange:n,streaming:i})=>{const{widget:s,label:u}=e;if(!s)return null;const{type:f,value:d}=s,m=f;if(!cf.hasOwnProperty(m))return null;const v=C_(d,m),y=cf[m]||cf.unknown,x=A.useCallback(k=>{n(k,e)},[e]);return A.useEffect(()=>{x(!0)},[]),b.jsx(QX,{streaming:i,readonly:t,desc:y,label:u,val:v,onCheckedChange:x})},(e,t)=>{var i,s;return((i=e.field.widget)==null?void 0:i.widgetName)===((s=t.field.widget)==null?void 0:s.widgetName)&&e.readonly===t.readonly&&e.streaming===t.streaming}),eJ=({subformField:e,onChange:t,streaming:n,readonly:i})=>{if(!e.widget.value||!e.widget.value.length)return null;const s=e.widget.value,[u,f]=A.useState(!0);return b.jsx(R_,{open:u,onOpenChange:f,children:b.jsx(T_,{children:s.map((d,m)=>b.jsx(R_,{defaultOpen:!0,children:b.jsx(T_,{children:d.map((v,y)=>b.jsx(KX,{readonly:i,streaming:n,field:{label:v.label,widget:{widgetName:v.fieldName,type:v.fieldType,value:v.value}},onCheckedChange:(x,k)=>{t({checked:x,field:k,row:m,col:y,parentFieldName:e.widget.widgetName})}}))})},m))})})},tJ=A.memo(({field:e,disabled:t,isSubField:n,readonly:i,streaming:s,onChange:u,onLoaded:f})=>{const{widget:d,label:m}=e;if(!d)return null;const{type:v,value:y}=d,k=C_(y,v);if(!cf.hasOwnProperty(v))return null;const S=v==="subform";A.useEffect(()=>{f==null||f(e)},[]);const L=M=>{u==null||u(M,e)},T=n?"pl-6":"";return b.jsxs(b.Fragment,{children:[b.jsx(_2,{streaming:s,title:m,disabled:t,defaultChecked:!0,onCheckedChange:L,className:T,readonly:i,shortDesc:S?"":k}),S&&b.jsx(eJ,{readonly:i,subformField:e,onChange:M=>{u==null||u(M.checked,M.field,M.parentFieldName,M.row)},streaming:s})]})},(e,t)=>{var d,m,v,y,x,k;return!(((d=e.field)==null?void 0:d.label)===((m=t.field)==null?void 0:m.label))||!(((y=(v=e.field)==null?void 0:v.widget)==null?void 0:y.widgetName)===((k=(x=t.field)==null?void 0:x.widget)==null?void 0:k.widgetName))||!(e.disabled===t.disabled)||!(e.readonly===t.readonly)||!(e.streaming===t.streaming)?!1:Lz(e==null?void 0:e.field,t==null?void 0:t.field)}),nJ=A.memo(A.forwardRef(({fields:e,children:t,streaming:n,confirmed:i},s)=>{const[u,f]=A.useState(()=>Object.fromEntries(e.map(x=>{var k,S;return[(S=(k=x.field)==null?void 0:k.label)!=null?S:"",!0]}))),d=A.useMemo(()=>e.length>0&&e.every(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}),[u,e]),m=A.useMemo(()=>e.some(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}),[u,e]),v=n||!d&&m;A.useImperativeHandle(s,()=>({getCheckedFieldsLength:()=>e.filter(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}).length}),[u,e]);const y=A.useCallback(x=>{const k=x===!0;f(Object.fromEntries(e.map(S=>{var L,T;return[(T=(L=S.field)==null?void 0:L.label)!=null?T:"",k]}))),e.forEach(S=>{var L;return(L=S.onChange)==null?void 0:L.call(S,k,S.field)})},[e]);return b.jsxs(o1,{title:"字段生成",icon:b.jsx(zz,{}),defaultOpen:!0,children:[b.jsx("div",{className:Fe("flex gap-[10px] px-4 py-[10px] rounded-[4px] w-full transition-colors cursor-pointer hover:bg-[#EFF0F6] items-center",{"pointer-events-none":i||n}),onClick:()=>{if(i)return;y(!d)},children:b.jsx(Q5,{readonly:i||n,checked:d&&!n,onCheckedChange:y,intermediate:v,children:b.jsx("span",{className:"!text-[#0265ff] !font-[700]",children:"全选"})})}),e.map(x=>{var k,S,L;return A.createElement(x_,{...x,key:(k=x.field)==null?void 0:k.label,checked:u[(L=(S=x.field)==null?void 0:S.label)!=null?L:""],streaming:n,confirmed:i,onChange:(T,M,j,F)=>{var z;F!==void 0&&j!==void 0||f(Z=>{var $,G;return{...Z,[(G=($=x.field)==null?void 0:$.label)!=null?G:""]:T}}),(z=x.onChange)==null||z.call(x,T,M,j,F)}})}),t]})})),rJ=A.memo(({props:e,readonly:t,children:n,streaming:i})=>b.jsxs(o1,{title:"字段填写",icon:b.jsx(qb,{}),defaultOpen:!0,children:[e.map(s=>b.jsx(tJ,{...s,readonly:t,streaming:i})),n]})),df=({text:e="确认",prefixDesc:t,className:n,disabled:i,light:s,icon:u,children:f,...d})=>{const m=b.jsxs($d,{...d,variant:"default",disabled:i,className:Fe("px-[10px] py-0 rounded-[100px] text-[14px] leading-normal h-[34px] min-w-[100px] cursor-pointer w-full disabled:opacity-100 gap-[6px] shadow-none",i?"bg-[#f0f0f0] text-[#999] cursor-not-allowed shadow-none":s?"bg-[#F0F6FF] text-[#0265FF] hover:bg-[#0265FF] hover:text-white":"bg-[#0265ff] text-white hover:bg-[#0265ff]/80",Fr,{"!bg-[#E5E6EB] !text-[#121111] shadow-none font-[400]":d.disabledWithInfo},n),children:[u,f||e]});return t?b.jsxs("div",{className:"flex flex-col items-start gap-2.5",children:[b.jsx("p",{className:"text-[#4D609F]",children:t}),m]}):m},oJ=e=>{var S,L,T;const{confirmed:t,part:n,status:i}=e,u=PX(n,!!t),f=A.useRef(null),d=uf(Pl),m=((S=d==null?void 0:d.getCurrentWorkingForm())==null?void 0:S.formName)||"",v=Ki(),y=b.jsxs("div",{children:[b.jsx("b",{style:{display:"inline-block"},children:m}),` 已生成${u.length}个字段`]}),x=t?b.jsxs(b.Fragment,{children:[b.jsx(Qb,{className:"text-[#0265ff]"})," 已保存"," ",(T=(L=f.current)==null?void 0:L.getCheckedFieldsLength())!=null?T:0," 个字段"]}):"保存字段",k=i==="ready"?"请选择需要的字段添加到表单。您可以补充描述后重新生成,表单中已添加字段在下次生成时保留。":null;return b.jsxs(tf,{className:"gap-0 py-0",compact:!0,children:[y,b.jsx(nJ,{ref:f,fields:u,streaming:i==="streaming",confirmed:t,children:i==="ready"?b.jsx(df,{className:"mt-[20px] mb-[10px]",disabledWithInfo:t,onClick:()=>{v.emit("form-builder-FieldsConfirmed",d==null?void 0:d.getCurrentWorkingForm()),d.onAfterFieldsSave(M=>{v.emit("form-builder-FieldsConfirmed",M)})},children:x}):null}),k]})},pf=A.forwardRef(({className:e,children:t,hoverTextCls:n,tooltip:i,icon:s,type:u,...f},d)=>{const m=b.jsxs("button",{ref:d,type:u!=null?u:"button",className:Fe("group inline-flex items-center gap-[6px] px-[16px] rounded-[4px] h-[34px]","border border-solid border-[#E0E0E0] bg-transparent","text-[14px] font-[400] leading-[normal] text-[#030303]","hover:bg-[#EFF0F6] hover:border-transparent","cursor-pointer",{"hover:text-[#0265FF]":!n,[`hover:${n}`]:n},Fr,e),...f,children:[s?b.jsx("span",{className:"shrink-0",children:s}):null,t?b.jsx("span",{className:"whitespace-nowrap",children:t}):null]});return i?b.jsx(bh,{content:i,children:m}):m});pf.displayName="BaseButton";const iJ=e=>{const t=e.match(/&#x[a-fA-F0-9]+;/);return t?t[0]:"&#xe817;"},aJ=e=>{const t=iJ(e.description),n=t?b.jsx(ph,{code:t,className:"text-[16px] text-[#999]"}):null,i=t?e.description.replace(t,"").trim():e.description,s=t?e.title.replace(t,"").trim():e.title;return b.jsx(pf,{icon:n,className:"self-start w-full px-[10px]",hoverTextCls:"text-[#121111]",onClick:()=>{var u;(u=e.onSelect)==null||u.call(e,s,t||"")},children:i})},rs=e=>{const t=uf(e);return t?t.Context:null},sJ=e=>{const{confirmed:t}=e,n=uf(Pl),i=n==null?void 0:n.getCurrentWorkingForm(),s=Ki();return A.useEffect(()=>{s.emit("form-builder-FieldsCreatedFinish",i)},[]),b.jsx(b.Fragment,{children:t?b.jsx(Wu,{children:"试试以下建议"}):null})},lJ=e=>{const{confirmed:t,sendMessage:n,part:i}=e,s=i,u=rs(Pl);return t?b.jsx(aJ,{title:s.text,description:s.text,onSelect:(f,d)=>{u&&(u.workStage,console.log("follow up icon code",d),console.log("follow up icon value",u9(d)),u.pickedIconValue=u9(d)),n({text:f},{body:{stage:"design"}})},headless:!0}):null},uJ=e=>{var u;const t=dh(e);return(Array.isArray(e)&&e.length?e:t?[e]:[]).length?"fields":Ez(e)?"followup":_z(e)?"followup_prefix":((u=e.text)==null?void 0:u.startsWith("待搭建表单信息"))?"design_doc":"markdown"};function L_(e,t){const n=e.match(t);return n?n[1]:""}function A_(e){if(!e)return"";const t=[/关联来源:(.*)表?,/,/关联(.*)表?/,/(从(.*)表?中查询)/,/来自(.*)表?/];for(const n of t)return L_(e,n);return""}const cJ=e=>{const t=e.split("-");return t.length>1?{isSubForm:t[0].trim().toLowerCase()==="子表单",formName:t[1].trim()}:{isSubForm:!1,formName:""}};function N_(e){const t=e.split(`
511
+ `)},uY=0,c1=[];function cY(e){var t=A.useRef([]),n=A.useRef([0,0]),i=A.useRef(),s=A.useState(uY++)[0],u=A.useState(yE)[0],f=A.useRef(e);A.useEffect(function(){f.current=e},[e]),A.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var T=Nq([e.lockRef.current],(e.shards||[]).map(EE),!0).filter(Boolean);return T.forEach(function(M){return M.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),T.forEach(function(M){return M.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var d=A.useCallback(function(T,M){if("touches"in T&&T.touches.length===2||T.type==="wheel"&&T.ctrlKey)return!f.current.allowPinchZoom;var j=g2(T),F=n.current,P="deltaX"in T?T.deltaX:F[0]-j[0],z="deltaY"in T?T.deltaY:F[1]-j[1],Z,$=T.target,G=Math.abs(P)>Math.abs(z)?"h":"v";if("touches"in T&&G==="h"&&$.type==="range")return!1;var Y=window.getSelection(),me=Y&&Y.anchorNode,ce=me?me===$||me.contains($):!1;if(ce)return!1;var le=bE(G,$);if(!le)return!0;if(le?Z=G:(Z=G==="v"?"h":"v",le=bE(G,$)),!le)return!1;if(!i.current&&"changedTouches"in T&&(P||z)&&(i.current=Z),!Z)return!0;var se=i.current||Z;return aY(se,M,T,se==="h"?P:z)},[]),m=A.useCallback(function(T){var M=T;if(!(!c1.length||c1[c1.length-1]!==u)){var j="deltaY"in M?kE(M):g2(M),F=t.current.filter(function(Z){return Z.name===M.type&&(Z.target===M.target||M.target===Z.shadowParent)&&sY(Z.delta,j)})[0];if(F&&F.should){M.cancelable&&M.preventDefault();return}if(!F){var P=(f.current.shards||[]).map(EE).filter(Boolean).filter(function(Z){return Z.contains(M.target)}),z=P.length>0?d(M,P[0]):!f.current.noIsolation;z&&M.cancelable&&M.preventDefault()}}},[]),v=A.useCallback(function(T,M,j,F){var P={name:T,delta:M,target:j,should:F,shadowParent:fY(j)};t.current.push(P),setTimeout(function(){t.current=t.current.filter(function(z){return z!==P})},1)},[]),y=A.useCallback(function(T){n.current=g2(T),i.current=void 0},[]),x=A.useCallback(function(T){v(T.type,kE(T),T.target,d(T,e.lockRef.current))},[]),k=A.useCallback(function(T){v(T.type,g2(T),T.target,d(T,e.lockRef.current))},[]);A.useEffect(function(){return c1.push(u),e.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:k}),document.addEventListener("wheel",m,u1),document.addEventListener("touchmove",m,u1),document.addEventListener("touchstart",y,u1),function(){c1=c1.filter(function(T){return T!==u}),document.removeEventListener("wheel",m,u1),document.removeEventListener("touchmove",m,u1),document.removeEventListener("touchstart",y,u1)}},[]);var S=e.removeScrollBar,L=e.inert;return A.createElement(A.Fragment,null,L?A.createElement(u,{styles:lY(s)}):null,S?A.createElement(Kq,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fY(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const dY=Hq(vE,cY);var P5=A.forwardRef(function(e,t){return A.createElement(h2,Bs({},e,{ref:t,sideCar:dY}))});P5.classNames=h2.classNames;var pY=[" ","Enter","ArrowUp","ArrowDown"],hY=[" ","Enter"],v2="Select",[z5,y2,mY]=rE(v2),[f1]=Ds(v2,[mY,U0]),H5=U0(),[rae,qu]=f1(v2),[oae,gY]=f1(v2),_E="SelectTrigger",RE=A.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:i=!1,...s}=e,u=H5(n),f=qu(_E,n),d=f.disabled||i,m=Rn(t,f.onTriggerChange),v=y2(n),y=A.useRef("touch"),[x,k,S]=YE(T=>{const M=v().filter(P=>!P.disabled),j=M.find(P=>P.value===f.value),F=XE(M,T,j);F!==void 0&&f.onValueChange(F.value)}),L=T=>{d||(f.onOpenChange(!0),S()),T&&(f.triggerPointerDownPosRef.current={x:Math.round(T.pageX),y:Math.round(T.pageY)})};return b.jsx(BC,{asChild:!0,...u,children:b.jsx(Qt.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":qE(f.value)?"":void 0,...s,ref:m,onClick:Ut(s.onClick,T=>{T.currentTarget.focus(),y.current!=="mouse"&&L(T)}),onPointerDown:Ut(s.onPointerDown,T=>{y.current=T.pointerType;const M=T.target;M.hasPointerCapture(T.pointerId)&&M.releasePointerCapture(T.pointerId),T.button===0&&T.ctrlKey===!1&&T.pointerType==="mouse"&&(L(T),T.preventDefault())}),onKeyDown:Ut(s.onKeyDown,T=>{const M=x.current!=="";!(T.ctrlKey||T.altKey||T.metaKey)&&T.key.length===1&&k(T.key),!(M&&T.key===" ")&&pY.includes(T.key)&&(L(),T.preventDefault())})})})});RE.displayName=_E;var TE="SelectValue",vY=A.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:s,children:u,placeholder:f="",...d}=e,m=qu(TE,n),{onValueNodeHasChildrenChange:v}=m,y=u!==void 0,x=Rn(t,m.onValueNodeChange);return go(()=>{v(y)},[v,y]),b.jsx(Qt.span,{...d,ref:x,style:{pointerEvents:"none"},children:qE(m.value)?b.jsx(b.Fragment,{children:f}):u})});vY.displayName=TE;var yY="SelectIcon",LE=A.forwardRef((e,t)=>{const{__scopeSelect:n,children:i,...s}=e;return b.jsx(Qt.span,{"aria-hidden":!0,...s,ref:t,children:i||"▼"})});LE.displayName=yY;var xY="SelectPortal",AE=e=>b.jsx(B0,{asChild:!0,...e});AE.displayName=xY;var lf="SelectContent",NE=A.forwardRef((e,t)=>{const n=qu(lf,e.__scopeSelect),[i,s]=A.useState();if(go(()=>{s(new DocumentFragment)},[]),!n.open){const u=i;return u?Nl.createPortal(b.jsx(ME,{scope:e.__scopeSelect,children:b.jsx(z5.Slot,{scope:e.__scopeSelect,children:b.jsx("div",{children:e.children})})}),u):null}return b.jsx(OE,{...e,ref:t})});NE.displayName=lf;var ns=10,[ME,Yu]=f1(lf),wY="SelectContentImpl",bY=mh("SelectContent.RemoveScroll"),OE=A.forwardRef((e,t)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:u,onPointerDownOutside:f,side:d,sideOffset:m,align:v,alignOffset:y,arrowPadding:x,collisionBoundary:k,collisionPadding:S,sticky:L,hideWhenDetached:T,avoidCollisions:M,...j}=e,F=qu(lf,n),[P,z]=A.useState(null),[Z,$]=A.useState(null),G=Rn(t,xe=>z(xe)),[Y,me]=A.useState(null),[ce,le]=A.useState(null),se=y2(n),[ve,_e]=A.useState(!1),ke=A.useRef(!1);A.useEffect(()=>{if(P)return pE(P)},[P]),iE();const Ae=A.useCallback(xe=>{const[$e,...Ge]=se().map(Et=>Et.ref.current),[Ze]=Ge.slice(-1),ht=document.activeElement;for(const Et of xe)if(Et===ht||(Et==null||Et.scrollIntoView({block:"nearest"}),Et===$e&&Z&&(Z.scrollTop=0),Et===Ze&&Z&&(Z.scrollTop=Z.scrollHeight),Et==null||Et.focus(),document.activeElement!==ht))return},[se,Z]),we=A.useCallback(()=>Ae([Y,P]),[Ae,Y,P]);A.useEffect(()=>{ve&&we()},[ve,we]);const{onOpenChange:K,triggerPointerDownPosRef:Me}=F;A.useEffect(()=>{if(P){let xe={x:0,y:0};const $e=Ze=>{var ht,Et,Kt,fn;xe={x:Math.abs(Math.round(Ze.pageX)-((Et=(ht=Me.current)==null?void 0:ht.x)!=null?Et:0)),y:Math.abs(Math.round(Ze.pageY)-((fn=(Kt=Me.current)==null?void 0:Kt.y)!=null?fn:0))}},Ge=Ze=>{xe.x<=10&&xe.y<=10?Ze.preventDefault():P.contains(Ze.target)||K(!1),document.removeEventListener("pointermove",$e),Me.current=null};return Me.current!==null&&(document.addEventListener("pointermove",$e),document.addEventListener("pointerup",Ge,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$e),document.removeEventListener("pointerup",Ge,{capture:!0})}}},[P,K,Me]),A.useEffect(()=>{const xe=()=>K(!1);return window.addEventListener("blur",xe),window.addEventListener("resize",xe),()=>{window.removeEventListener("blur",xe),window.removeEventListener("resize",xe)}},[K]);const[U,J]=YE(xe=>{const $e=se().filter(ht=>!ht.disabled),Ge=$e.find(ht=>ht.ref.current===document.activeElement),Ze=XE($e,xe,Ge);Ze&&setTimeout(()=>Ze.ref.current.focus())}),he=A.useCallback((xe,$e,Ge)=>{const Ze=!ke.current&&!Ge;(F.value!==void 0&&F.value===$e||Ze)&&(me(xe),Ze&&(ke.current=!0))},[F.value]),B=A.useCallback(()=>P==null?void 0:P.focus(),[P]),Re=A.useCallback((xe,$e,Ge)=>{const Ze=!ke.current&&!Ge;(F.value!==void 0&&F.value===$e||Ze)&&le(xe)},[F.value]),We=i==="popper"?U5:DE,Ve=We===U5?{side:d,sideOffset:m,align:v,alignOffset:y,arrowPadding:x,collisionBoundary:k,collisionPadding:S,sticky:L,hideWhenDetached:T,avoidCollisions:M}:{};return b.jsx(ME,{scope:n,content:P,viewport:Z,onViewportChange:$,itemRefCallback:he,selectedItem:Y,onItemLeave:B,itemTextRefCallback:Re,focusSelectedItem:we,selectedItemText:ce,position:i,isPositioned:ve,searchRef:U,children:b.jsx(P5,{as:bY,allowPinchZoom:!0,children:b.jsx(N5,{asChild:!0,trapped:F.open,onMountAutoFocus:xe=>{xe.preventDefault()},onUnmountAutoFocus:Ut(s,xe=>{var $e;($e=F.trigger)==null||$e.focus({preventScroll:!0}),xe.preventDefault()}),children:b.jsx(A0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:xe=>xe.preventDefault(),onDismiss:()=>F.onOpenChange(!1),children:b.jsx(We,{role:"listbox",id:F.contentId,"data-state":F.open?"open":"closed",dir:F.dir,onContextMenu:xe=>xe.preventDefault(),...j,...Ve,onPlaced:()=>_e(!0),ref:G,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Ut(j.onKeyDown,xe=>{const $e=xe.ctrlKey||xe.altKey||xe.metaKey;if(xe.key==="Tab"&&xe.preventDefault(),!$e&&xe.key.length===1&&J(xe.key),["ArrowUp","ArrowDown","Home","End"].includes(xe.key)){let Ze=se().filter(ht=>!ht.disabled).map(ht=>ht.ref.current);if(["ArrowUp","End"].includes(xe.key)&&(Ze=Ze.slice().reverse()),["ArrowUp","ArrowDown"].includes(xe.key)){const ht=xe.target,Et=Ze.indexOf(ht);Ze=Ze.slice(Et+1)}setTimeout(()=>Ae(Ze)),xe.preventDefault()}})})})})})})});OE.displayName=wY;var CY="SelectItemAlignedPosition",DE=A.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:i,...s}=e,u=qu(lf,n),f=Yu(lf,n),[d,m]=A.useState(null),[v,y]=A.useState(null),x=Rn(t,G=>y(G)),k=y2(n),S=A.useRef(!1),L=A.useRef(!0),{viewport:T,selectedItem:M,selectedItemText:j,focusSelectedItem:F}=f,P=A.useCallback(()=>{if(u.trigger&&u.valueNode&&d&&v&&T&&M&&j){const G=u.trigger.getBoundingClientRect(),Y=v.getBoundingClientRect(),me=u.valueNode.getBoundingClientRect(),ce=j.getBoundingClientRect();if(u.dir!=="rtl"){const ht=ce.left-Y.left,Et=me.left-ht,Kt=G.left-Et,fn=G.width+Kt,pn=Math.max(fn,Y.width),En=window.innerWidth-ns,tr=nE(Et,[ns,Math.max(ns,En-pn)]);d.style.minWidth=fn+"px",d.style.left=tr+"px"}else{const ht=Y.right-ce.right,Et=window.innerWidth-me.right-ht,Kt=window.innerWidth-G.right-Et,fn=G.width+Kt,pn=Math.max(fn,Y.width),En=window.innerWidth-ns,tr=nE(Et,[ns,Math.max(ns,En-pn)]);d.style.minWidth=fn+"px",d.style.right=tr+"px"}const le=k(),se=window.innerHeight-ns*2,ve=T.scrollHeight,_e=window.getComputedStyle(v),ke=parseInt(_e.borderTopWidth,10),Ae=parseInt(_e.paddingTop,10),we=parseInt(_e.borderBottomWidth,10),K=parseInt(_e.paddingBottom,10),Me=ke+Ae+ve+K+we,U=Math.min(M.offsetHeight*5,Me),J=window.getComputedStyle(T),he=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),Re=G.top+G.height/2-ns,We=se-Re,Ve=M.offsetHeight/2,xe=M.offsetTop+Ve,$e=ke+Ae+xe,Ge=Me-$e;if($e<=Re){const ht=le.length>0&&M===le[le.length-1].ref.current;d.style.bottom="0px";const Et=v.clientHeight-T.offsetTop-T.offsetHeight,Kt=Math.max(We,Ve+(ht?B:0)+Et+we),fn=$e+Kt;d.style.height=fn+"px"}else{const ht=le.length>0&&M===le[0].ref.current;d.style.top="0px";const Kt=Math.max(Re,ke+T.offsetTop+(ht?he:0)+Ve)+Ge;d.style.height=Kt+"px",T.scrollTop=$e-Re+T.offsetTop}d.style.margin=`${ns}px 0`,d.style.minHeight=U+"px",d.style.maxHeight=se+"px",i==null||i(),requestAnimationFrame(()=>S.current=!0)}},[k,u.trigger,u.valueNode,d,v,T,M,j,u.dir,i]);go(()=>P(),[P]);const[z,Z]=A.useState();go(()=>{v&&Z(window.getComputedStyle(v).zIndex)},[v]);const $=A.useCallback(G=>{G&&L.current===!0&&(P(),F==null||F(),L.current=!1)},[P,F]);return b.jsx(kY,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:S,onScrollButtonChange:$,children:b.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:z},children:b.jsx(Qt.div,{...s,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});DE.displayName=CY;var SY="SelectPopperPosition",U5=A.forwardRef((e,t)=>{const{__scopeSelect:n,align:i="start",collisionPadding:s=ns,...u}=e,f=H5(n);return b.jsx(VC,{...f,...u,ref:t,align:i,collisionPadding:s,style:{boxSizing:"border-box",...u.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});U5.displayName=SY;var[kY,B5]=f1(lf,{}),V5="SelectViewport",jE=A.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:i,...s}=e,u=Yu(V5,n),f=B5(V5,n),d=Rn(t,u.onViewportChange),m=A.useRef(0);return b.jsxs(b.Fragment,{children:[b.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),b.jsx(z5.Slot,{scope:n,children:b.jsx(Qt.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Ut(s.onScroll,v=>{const y=v.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:k}=f;if(k!=null&&k.current&&x){const S=Math.abs(m.current-y.scrollTop);if(S>0){const L=window.innerHeight-ns*2,T=parseFloat(x.style.minHeight),M=parseFloat(x.style.height),j=Math.max(T,M);if(j<L){const F=j+S,P=Math.min(L,F),z=F-P;x.style.height=P+"px",x.style.bottom==="0px"&&(y.scrollTop=z>0?z:0,x.style.justifyContent="flex-end")}}}m.current=y.scrollTop})})})]})});jE.displayName=V5;var FE="SelectGroup",[EY,_Y]=f1(FE),RY=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=Uu();return b.jsx(EY,{scope:n,id:s,children:b.jsx(Qt.div,{role:"group","aria-labelledby":s,...i,ref:t})})});RY.displayName=FE;var IE="SelectLabel",PE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=_Y(IE,n);return b.jsx(Qt.div,{id:s.id,...i,ref:t})});PE.displayName=IE;var x2="SelectItem",[TY,zE]=f1(x2),HE=A.forwardRef((e,t)=>{const{__scopeSelect:n,value:i,disabled:s=!1,textValue:u,...f}=e,d=qu(x2,n),m=Yu(x2,n),v=d.value===i,[y,x]=A.useState(u!=null?u:""),[k,S]=A.useState(!1),L=Rn(t,F=>{var P;return(P=m.itemRefCallback)==null?void 0:P.call(m,F,i,s)}),T=Uu(),M=A.useRef("touch"),j=()=>{s||(d.onValueChange(i),d.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return b.jsx(TY,{scope:n,value:i,disabled:s,textId:T,isSelected:v,onItemTextChange:A.useCallback(F=>{x(P=>{var z;return P||((z=F==null?void 0:F.textContent)!=null?z:"").trim()})},[]),children:b.jsx(z5.ItemSlot,{scope:n,value:i,disabled:s,textValue:y,children:b.jsx(Qt.div,{role:"option","aria-labelledby":T,"data-highlighted":k?"":void 0,"aria-selected":v&&k,"data-state":v?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...f,ref:L,onFocus:Ut(f.onFocus,()=>S(!0)),onBlur:Ut(f.onBlur,()=>S(!1)),onClick:Ut(f.onClick,()=>{M.current!=="mouse"&&j()}),onPointerUp:Ut(f.onPointerUp,()=>{M.current==="mouse"&&j()}),onPointerDown:Ut(f.onPointerDown,F=>{M.current=F.pointerType}),onPointerMove:Ut(f.onPointerMove,F=>{var P;M.current=F.pointerType,s?(P=m.onItemLeave)==null||P.call(m):M.current==="mouse"&&F.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ut(f.onPointerLeave,F=>{var P;F.currentTarget===document.activeElement&&((P=m.onItemLeave)==null||P.call(m))}),onKeyDown:Ut(f.onKeyDown,F=>{var z;((z=m.searchRef)==null?void 0:z.current)!==""&&F.key===" "||(hY.includes(F.key)&&j(),F.key===" "&&F.preventDefault())})})})})});HE.displayName=x2;var Ih="SelectItemText",UE=A.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:s,...u}=e,f=qu(Ih,n),d=Yu(Ih,n),m=zE(Ih,n),v=gY(Ih,n),[y,x]=A.useState(null),k=Rn(t,j=>x(j),m.onItemTextChange,j=>{var F;return(F=d.itemTextRefCallback)==null?void 0:F.call(d,j,m.value,m.disabled)}),S=y==null?void 0:y.textContent,L=A.useMemo(()=>b.jsx("option",{value:m.value,disabled:m.disabled,children:S},m.value),[m.disabled,m.value,S]),{onNativeOptionAdd:T,onNativeOptionRemove:M}=v;return go(()=>(T(L),()=>M(L)),[T,M,L]),b.jsxs(b.Fragment,{children:[b.jsx(Qt.span,{id:m.textId,...u,ref:k}),m.isSelected&&f.valueNode&&!f.valueNodeHasChildren?Nl.createPortal(u.children,f.valueNode):null]})});UE.displayName=Ih;var BE="SelectItemIndicator",VE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return zE(BE,n).isSelected?b.jsx(Qt.span,{"aria-hidden":!0,...i,ref:t}):null});VE.displayName=BE;var $5="SelectScrollUpButton",$E=A.forwardRef((e,t)=>{const n=Yu($5,e.__scopeSelect),i=B5($5,e.__scopeSelect),[s,u]=A.useState(!1),f=Rn(t,i.onScrollButtonChange);return go(()=>{if(n.viewport&&n.isPositioned){let d=function(){const v=m.scrollTop>0;u(v)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),s?b.jsx(WE,{...e,ref:f,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});$E.displayName=$5;var Z5="SelectScrollDownButton",ZE=A.forwardRef((e,t)=>{const n=Yu(Z5,e.__scopeSelect),i=B5(Z5,e.__scopeSelect),[s,u]=A.useState(!1),f=Rn(t,i.onScrollButtonChange);return go(()=>{if(n.viewport&&n.isPositioned){let d=function(){const v=m.scrollHeight-m.clientHeight,y=Math.ceil(m.scrollTop)<v;u(y)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),s?b.jsx(WE,{...e,ref:f,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});ZE.displayName=Z5;var WE=A.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:i,...s}=e,u=Yu("SelectScrollButton",n),f=A.useRef(null),d=y2(n),m=A.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return A.useEffect(()=>()=>m(),[m]),go(()=>{var y;const v=d().find(x=>x.ref.current===document.activeElement);(y=v==null?void 0:v.ref.current)==null||y.scrollIntoView({block:"nearest"})},[d]),b.jsx(Qt.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:Ut(s.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(i,50))}),onPointerMove:Ut(s.onPointerMove,()=>{var v;(v=u.onItemLeave)==null||v.call(u),f.current===null&&(f.current=window.setInterval(i,50))}),onPointerLeave:Ut(s.onPointerLeave,()=>{m()})})}),LY="SelectSeparator",GE=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return b.jsx(Qt.div,{"aria-hidden":!0,...i,ref:t})});GE.displayName=LY;var W5="SelectArrow",AY=A.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,s=H5(n),u=qu(W5,n),f=Yu(W5,n);return u.open&&f.position==="popper"?b.jsx($C,{...s,...i,ref:t}):null});AY.displayName=W5;var NY="SelectBubbleInput",MY=A.forwardRef(({__scopeSelect:e,value:t,...n},i)=>{const s=A.useRef(null),u=Rn(i,s),f=M5(t);return A.useEffect(()=>{const d=s.current;if(!d)return;const m=window.HTMLSelectElement.prototype,y=Object.getOwnPropertyDescriptor(m,"value").set;if(f!==t&&y){const x=new Event("change",{bubbles:!0});y.call(d,t),d.dispatchEvent(x)}},[f,t]),b.jsx(Qt.select,{...n,style:{...ZC,...n.style},ref:u,defaultValue:t})});MY.displayName=NY;function qE(e){return e===""||e===void 0}function YE(e){const t=Hu(e),n=A.useRef(""),i=A.useRef(0),s=A.useCallback(f=>{const d=n.current+f;t(d),function m(v){n.current=v,window.clearTimeout(i.current),v!==""&&(i.current=window.setTimeout(()=>m(""),1e3))}(d)},[t]),u=A.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return A.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,s,u]}function XE(e,t,n){const s=t.length>1&&Array.from(t).every(v=>v===t[0])?t[0]:t,u=n?e.indexOf(n):-1;let f=OY(e,Math.max(u,0));s.length===1&&(f=f.filter(v=>v!==n));const m=f.find(v=>v.textValue.toLowerCase().startsWith(s.toLowerCase()));return m!==n?m:void 0}function OY(e,t){return e.map((n,i)=>e[(t+i)%e.length])}var JE=RE,DY=LE,jY=AE,QE=NE,FY=jE,KE=PE,e_=HE,IY=UE,PY=VE,t_=$E,n_=ZE,r_=GE;const zY=A.forwardRef(({className:e,children:t,...n},i)=>b.jsxs(JE,{ref:i,className:Fe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,b.jsx(DY,{asChild:!0,children:b.jsx(eE,{className:"h-4 w-4 opacity-50"})})]}));zY.displayName=JE.displayName;const o_=A.forwardRef(({className:e,...t},n)=>b.jsx(t_,{ref:n,className:Fe("flex cursor-default items-center justify-center py-1",e),...t,children:b.jsx(vq,{className:"h-4 w-4"})}));o_.displayName=t_.displayName;const i_=A.forwardRef(({className:e,...t},n)=>b.jsx(n_,{ref:n,className:Fe("flex cursor-default items-center justify-center py-1",e),...t,children:b.jsx(eE,{className:"h-4 w-4"})}));i_.displayName=n_.displayName;const HY=A.forwardRef(({className:e,children:t,position:n="popper",...i},s)=>b.jsx(jY,{children:b.jsxs(QE,{ref:s,className:Fe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[b.jsx(o_,{}),b.jsx(FY,{className:Fe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),b.jsx(i_,{})]})}));HY.displayName=QE.displayName;const UY=A.forwardRef(({className:e,...t},n)=>b.jsx(KE,{ref:n,className:Fe("px-2 py-1.5 text-sm font-semibold",e),...t}));UY.displayName=KE.displayName;const BY=A.forwardRef(({className:e,children:t,...n},i)=>b.jsxs(e_,{ref:i,className:Fe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[b.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:b.jsx(PY,{children:b.jsx(gq,{className:"h-4 w-4"})})}),b.jsx(IY,{children:t})]}));BY.displayName=e_.displayName;const VY=A.forwardRef(({className:e,...t},n)=>b.jsx(r_,{ref:n,className:Fe("-mx-1 my-1 h-px bg-muted",e),...t}));VY.displayName=r_.displayName;const a_=A.forwardRef(({className:e,...t},n)=>b.jsx("textarea",{className:Fe("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));a_.displayName="Textarea";const $Y=({className:e,...t})=>b.jsx("form",{className:Fe("w-full overflow-hidden rounded-[10px] border bg-background shadow-xs",e),...t}),ZY=A.forwardRef(({onChange:e,className:t,placeholder:n="What would you like to know?",minHeight:i=50,maxHeight:s=164,disableAutoResize:u=!1,resizeOnNewLinesOnly:f=!1,...d},m)=>{const v=y=>{if(y.key==="Enter"){if(y.nativeEvent.isComposing||y.shiftKey)return;y.preventDefault();const x=y.currentTarget.form;x&&x.requestSubmit()}};return b.jsx(a_,{className:Fe("w-full resize-none rounded-none border-none shadow-none outline-hidden ring-0",u||f?"field-sizing-fixed":"field-sizing-content min-h-[3lh] max-h-[8lh]","bg-transparent dark:bg-transparent","focus-visible:ring-0",t),name:"message",onChange:y=>{e==null||e(y)},ref:m,onKeyDown:v,placeholder:n,...d})}),WY=({className:e,...t})=>b.jsx("div",{className:Fe("flex items-center justify-between p-1",e),...t}),GY=({className:e,...t})=>b.jsx("div",{className:Fe("flex items-center gap-1",e),...t}),qY=e=>{const t=tE,n=xq,i=yq;return e===void 0?b.jsx(i,{className:"size-4"}):{submitted:b.jsx(t,{className:"size-4 animate-spin"}),streaming:b.jsx(Bz,{}),error:b.jsx(n,{className:"size-4"}),ready:b.jsx(i,{className:"size-4"})}[e]||b.jsx(i,{className:"size-4"})},YY=({className:e,variant:t="default",size:n="icon",status:i,children:s,...u})=>{let f=qY(i);return b.jsx(bh,{content:"发送",children:b.jsx($d,{className:Fe("gap-1.5 rounded-full",e),size:n,type:"submit",variant:t,...u,children:s!=null?s:f})})},XY=({size:e=16})=>b.jsxs("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[b.jsxs("g",{clipPath:"url(#clip0_2393_1490)",children:[b.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),b.jsx("defs",{children:b.jsx("clipPath",{id:"clip0_2393_1490",children:b.jsx("rect",{fill:"white",height:"16",width:"16"})})})]}),JY=({size:e=16})=>b.jsx("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:b.jsx("path",{clipRule:"evenodd",d:"M12.0607 6.74999L11.5303 7.28032L8.7071 10.1035C8.31657 10.4941 7.68341 10.4941 7.29288 10.1035L4.46966 7.28032L3.93933 6.74999L4.99999 5.68933L5.53032 6.21966L7.99999 8.68933L10.4697 6.21966L11 5.68933L12.0607 6.74999Z",fill:"currentColor",fillRule:"evenodd"})}),Ph={"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{icon:R0,iconSize:52},"application/vnd.ms-excel":{icon:R0,iconSize:52},"text/csv":{icon:Xb,iconSize:16},"text/plain":{icon:T0,iconSize:16},"application/octet-stream":{icon:T0,iconSize:16}},QY={icon:Yb,iconSize:16},KY=e=>!!(e!=null&&e.startsWith("image/")),eX=(e,t)=>{var n;if(e&&Ph[e])return Ph[e];if(t)switch((n=t.split(".").pop())==null?void 0:n.toLowerCase()){case"xlsx":case"xls":return Ph["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];case"csv":return Ph["text/csv"];case"txt":case"ts":case"tsx":case"js":case"jsx":case"json":case"md":return Ph["text/plain"]}return QY},tX=()=>b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:b.jsx("path",{d:"M9 6L15 12L9 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),nX=()=>b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:b.jsx("path",{d:"M15 6L9 12L15 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),s_=({direction:e,onClick:t,className:n})=>b.jsx("button",{type:"button",onClick:t,className:Fe("flex items-center justify-center","size-[36px] p-1 rounded-[18px]","bg-white shadow-[0px_0px_10px_0px_rgba(0,0,0,0.06)]","cursor-pointer","hover:bg-gray-50","text-gray-600",Fr,n),children:e==="left"?b.jsx(nX,{}):b.jsx(tX,{})}),l_=({direction:e,height:t,visible:n})=>{const i=e==="left";return b.jsxs("div",{className:Fe("absolute top-[8px] pointer-events-none z-[5]",i?"left-0":"right-0",Fr,n?"opacity-100":"opacity-0"),style:{height:`${t}px`,width:"46px"},children:[b.jsx("div",{className:Fe("absolute inset-0",i?"bg-gradient-to-r from-white via-white via-[63.57%] to-transparent":"bg-gradient-to-l from-white via-white via-[63.57%] to-transparent")}),b.jsx("div",{className:"absolute inset-0 bg-white blur-[7px]"})]})},rX=({attachments:e,className:t,imageSize:n=53,gap:i=10,onImageClick:s,onImageRemove:u})=>{const f=A.useRef(null),d=A.useRef(null),[m,v]=A.useState(!1),[y,x]=A.useState(!1),k=A.useCallback(()=>{const L=d.current;if(!L)return;const{scrollLeft:T,scrollWidth:M,clientWidth:j}=L;v(T>0),x(T+j<M-1)},[]);A.useEffect(()=>{k();const L=d.current;if(L)return L.addEventListener("scroll",k),window.addEventListener("resize",k),()=>{L.removeEventListener("scroll",k),window.removeEventListener("resize",k)}},[k,e]);const S=L=>{const T=d.current;if(!T)return;const M=n+i,j=L==="left"?T.scrollLeft-M*2:T.scrollLeft+M*2;T.scrollTo({left:j,behavior:"smooth"})};return e.length?b.jsxs("div",{ref:f,className:Fe("relative w-full",t),style:{height:n+16},children:[b.jsx("div",{ref:d,className:"flex overflow-x-auto scrollbar-hide py-[8px]",style:{gap:i,height:n+16},children:e.map((L,T)=>{const M=KY(L.contentType),{icon:j,iconSize:F}=eX(L.contentType,L.alt),P=52/102*n,z=P/F;return b.jsxs("div",{className:Fe("relative shrink-0 cursor-pointer group border border-[#e0e0e0] rounded-[10px]",Fr),style:{width:n,height:n},onClick:()=>s==null?void 0:s(L,T),children:[M&&L.url?b.jsx("img",{src:L.url,alt:L.alt||`Attachment ${T+1}`,className:"absolute inset-0 h-full w-full rounded-[10px] object-cover"}):b.jsx("div",{className:"absolute inset-0 flex h-full w-full items-center justify-center rounded-[10px] bg-[#EFF0F6]",children:b.jsx("div",{className:"shrink-0 flex items-center justify-center",style:{width:P,height:P},children:b.jsx("div",{style:{transform:z!==1?`scale(${z})`:void 0,transformOrigin:"center"},children:b.jsx(j,{})})})}),L.isLoading&&b.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-[10px] bg-black/50 pointer-events-none",children:b.jsx("div",{className:"inline-flex animate-spin items-center justify-center",children:b.jsx(XY,{size:16})})}),u&&b.jsx("button",{className:Fe("absolute -top-[6px] -right-[6px]","flex items-center justify-center","opacity-0 group-hover:opacity-100 cursor-pointer",Fr),onClick:Z=>{Z.stopPropagation(),u(L,T)},children:b.jsx(Zz,{})})]},L.id)})}),b.jsx(l_,{direction:"left",height:n,visible:m}),b.jsx(s_,{direction:"left",onClick:()=>S("left"),className:Fe("absolute left-0 top-1/2 -translate-y-1/2 z-10",m?"opacity-100":"opacity-0 pointer-events-none")}),b.jsx(l_,{direction:"right",height:n,visible:y}),b.jsx(s_,{direction:"right",onClick:()=>S("right"),className:Fe("absolute right-0 top-1/2 -translate-y-1/2 z-10",y?"opacity-100":"opacity-0 pointer-events-none")})]}):null},oX=({setMessages:e,status:t,chatId:n})=>{const{exec:i=()=>{}}=Fl("onBeforeMessagesClear"),s=A.useCallback(()=>{i(n),e(()=>[])},[i,e]),{clearTimestamp:u}=Ci(f=>({clearTimestamp:f.msgClearTimestamp}));return A.useEffect(()=>{u&&s()},[u]),b.jsx(ef,{rounded:!0,tooltip:"删除历史消息",icon:b.jsx(Pz,{}),disabled:t!=="ready",onClick:f=>{f.preventDefault(),s()}})},iX=()=>{const e=Ki();return A.useCallback(n=>{e.emit("send-toast",n)},[e])};function aX({chatId:e,input:t,setInput:n,status:i,stop:s,attachments:u,setAttachments:f,fileUploadEndpoint:d,setMessages:m,sendMessage:v,className:y}){var K,Me,U,J,he;const x=A.useRef(null),k=A.useCallback(()=>{x.current&&(x.current.style.height="")},[]),{status:S}=u2();A.useEffect(()=>{x.current&&k()},[k]),A.useEffect(()=>{S==="hide"&&(ce(),n(""))},[S]);const L=A.useCallback(()=>{x.current&&(x.current.style.height="")},[]);A.useEffect(()=>{if(x.current){const Re=x.current.value||"";n(Re),k()}},[k,n]);const T=B=>{n(B.target.value)},M=A.useRef(null),[j,F]=A.useState([]),P=A.useRef(new Map),{exec:z}=Fl("onBeforeMessageSend"),{exec:Z}=Fl("onAfterMessageSend"),$=((K=Jd())==null?void 0:K.placeholder)||"Send a message...",G=((Me=Jd())==null?void 0:Me.acceptAttachmentMaxCount)||5,Y=((U=Jd())==null?void 0:U.acceptAttachmentMaxSizeMb)||50,me=`上传附件(仅识别文字),最多${G}个,单个文件最大${Y}MB`,ce=A.useCallback(()=>{f([]),F([]),M.current&&(M.current.value="")},[f]),le=A.useCallback(()=>{const B=z({text:t}),Re={role:"user",parts:[...u.map(We=>({type:"file",url:We.url,name:We.name,mediaType:We.contentType,providerMetadata:{uploadMetadata:We}})),{type:"text",text:t}]};v(Re,B.options),Z==null||Z(Re),f([]),L(),n("")},[t,n,u,v,f,e,L]),se=iX(),ve=A.useCallback(async(B,Re)=>{const We=new FormData;We.append("file",B);try{const Ve=await fetch(d,{method:"POST",body:We,signal:Re});if(Ve.ok){const $e=await Ve.json();return console.log($e),$e}const{error:xe}=await Ve.json();console.error("upload error",xe)}catch(Ve){}},[]),_e=A.useCallback(async B=>{const Re=Array.from(B.target.files||[]);if(Re.length===0)return;if(u.length+Re.length>G){se({type:"error",msg:`最多只能上传${G}个附件`});return}if(Re.some(Ve=>Ve.size>Y*1024*1024)){se({type:"error",msg:`单个文件大小不能超过${Y}MB`});return}F(Re.map(Ve=>Ve.name));try{const Ve=Re.map(Ge=>{const Ze=new AbortController;return P.current.set(Ge.name,Ze),ve(Ge,Ze.signal)}),xe=await Promise.all(Ve),$e=xe.filter(Ge=>Ge!==void 0);console.log("uploaded attachements",xe),f(Ge=>[...Ge,...$e])}catch(Ve){console.error("Error uploading files!",Ve)}finally{F([]),P.current.clear()}},[f,ve,u]),ke=A.useCallback(async B=>{var Ve;const Re=(Ve=B.clipboardData)==null?void 0:Ve.items;if(!Re)return;const We=Array.from(Re).filter(xe=>xe.type.startsWith("image/"));if(We.length!==0){B.preventDefault(),F(xe=>[...xe,"Pasted image"]);try{const xe=We.map(Ze=>Ze.getAsFile()).filter(Ze=>Ze!==null).map(Ze=>ve(Ze)),Ge=(await Promise.all(xe)).filter(Ze=>Ze!==void 0&&Ze.url!==void 0&&Ze.contentType!==void 0);f(Ze=>[...Ze,...Ge])}catch(xe){console.error("Error uploading pasted images:",xe)}finally{F([])}}},[f,ve]),Ae=(he=((J=Jd())==null?void 0:J.acceptAttachmentFileType)||[".csv","text/csv","text/plain",".txt","image/*",".xls",".xlsx"])==null?void 0:he.join(","),we=!!Ae;return A.useEffect(()=>{const B=x.current;if(B)return B.addEventListener("paste",ke),()=>B.removeEventListener("paste",ke)},[ke]),b.jsxs("div",{className:Fe("relative flex w-full flex-col gap-4",y),children:[b.jsx("input",{className:"-top-4 -left-4 pointer-events-none fixed size-0.5 opacity-0",multiple:!0,onChange:_e,ref:M,tabIndex:-1,type:"file",accept:Ae}),b.jsxs($Y,{className:"border border-[#e0e0e0] bg-background p-[10px] shadow-xs transition-all duration-200 focus-within:border-border hover:border-[#0265ff]",onSubmit:B=>{B.preventDefault(),(i==="ready"||i==="error")&&le()},children:[(u.length>0||j.length>0)&&b.jsx(rX,{attachments:[...u.map(B=>({id:B.url,url:B.url,alt:B.name,contentType:B.contentType})),...j.map(B=>({id:`uploading-${B}`,url:"",alt:B,isLoading:!0}))],imageSize:52,onImageRemove:B=>{if(B.id.startsWith("uploading-")){const Re=B.alt||"",We=P.current.get(Re);We&&(We.abort(),P.current.delete(Re)),F(Ve=>Ve.filter(xe=>xe!==Re));return}f(Re=>Re.filter(We=>We.url!==B.id)),M.current&&(M.current.value="")}}),b.jsx("div",{className:"flex flex-row items-start gap-1 sm:gap-2",children:b.jsx(ZY,{className:"grow resize-none border-0! border-none! bg-transparent p-0 text-base outline-none ring-0 placeholder:text-[#999] focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 text-[#12111]","data-testid":"multimodal-input",onChange:T,placeholder:$,ref:x,rows:3,value:t})}),b.jsxs(WY,{className:"border-top-0! border-t-0! p-0 shadow-none dark:border-0 dark:border-transparent!",children:[b.jsx("div",{}),b.jsxs(GY,{className:"gap-2.5",children:[we?b.jsx(uX,{fileInputRef:M,status:i,tooltip:me}):null,b.jsx(oX,{setMessages:m,status:i,chatId:e}),b.jsx(Hz,{}),i==="submitted"||i==="streaming"?b.jsx(fX,{setMessages:m,stop:s}):b.jsx(YY,{className:"cursor-pointer rounded-full bg-[#0265FF] text-primary-foreground transition-colors duration-200 hover:bg-[#0265FF]/90 disabled:bg-[#E5E6EB] disabled:text-white h-[26px] w-[26px] disabled:opacity-100","data-testid":"send-button",disabled:!t.trim()&&u.length<=0||j.length>0,status:i,children:b.jsx(Iz,{})})]})]})]})]})}const sX=A.memo(aX,(e,t)=>!(e.input!==t.input||e.status!==t.status||!cq(e.attachments,t.attachments)));function lX({fileInputRef:e,status:t,tooltip:n}){return b.jsx(ef,{tooltip:n,rounded:!0,icon:b.jsx(Uz,{}),disabled:t!=="ready",onClick:i=>{var s;i.preventDefault(),(s=e.current)==null||s.click()}})}const uX=A.memo(lX);function cX({stop:e,setMessages:t}){return b.jsx(bh,{content:"停止生成",children:b.jsx($d,{className:"cursor-pointer rounded-full bg-[#0265FF] text-primary-foreground transition-colors duration-200 hover:bg-[#0265FF]/90 disabled:bg-[#E5E6EB] disabled:text-white h-[26px] w-[26px] flex items-center justify-center aspect-square p-0 disabled:!opacity-100",onClick:n=>{n.preventDefault(),e(),t(i=>i)},children:b.jsx("div",{className:"rounded-[2px] w-[8px] h-[8px] bg-white flex-shrink-0"})})})}const fX=A.memo(cX);function dX(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,i=0;return function(...u){clearTimeout(n);const f=Date.now(),d=f-i,m=t-d;m<=0?(i=f,e.apply(this,u)):n=setTimeout(()=>{i=Date.now(),e.apply(this,u)},m)}}var pX=dX;const hX=Ou(pX);var u_=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},er=(e,t,n)=>(u_(e,t,"read from private field"),n?n.call(e):t.get(e)),Vs=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Xu=(e,t,n,i)=>(u_(e,t,"write to private field"),t.set(e,n),n);function mX(e,t){return t!=null?hX(e,t):e}var ba,w2,b2,zh,Hh,Uh,d1,G5,q5,gX=class{constructor(e=[]){Vs(this,ba,void 0),Vs(this,w2,"ready"),Vs(this,b2,void 0),Vs(this,zh,new Set),Vs(this,Hh,new Set),Vs(this,Uh,new Set),this.pushMessage=t=>{Xu(this,ba,er(this,ba).concat(t)),er(this,d1).call(this)},this.popMessage=()=>{Xu(this,ba,er(this,ba).slice(0,-1)),er(this,d1).call(this)},this.replaceMessage=(t,n)=>{Xu(this,ba,[...er(this,ba).slice(0,t),this.snapshot(n),...er(this,ba).slice(t+1)]),er(this,d1).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const i=n?mX(t,n):t;return er(this,zh).add(i),()=>{er(this,zh).delete(i)}},this["~registerStatusCallback"]=t=>(er(this,Hh).add(t),()=>{er(this,Hh).delete(t)}),this["~registerErrorCallback"]=t=>(er(this,Uh).add(t),()=>{er(this,Uh).delete(t)}),Vs(this,d1,()=>{er(this,zh).forEach(t=>t())}),Vs(this,G5,()=>{er(this,Hh).forEach(t=>t())}),Vs(this,q5,()=>{er(this,Uh).forEach(t=>t())}),Xu(this,ba,e)}get status(){return er(this,w2)}set status(e){Xu(this,w2,e),er(this,G5).call(this)}get error(){return er(this,b2)}set error(e){Xu(this,b2,e),er(this,q5).call(this)}get messages(){return er(this,ba)}set messages(e){Xu(this,ba,[...e]),er(this,d1).call(this)}};ba=new WeakMap,w2=new WeakMap,b2=new WeakMap,zh=new WeakMap,Hh=new WeakMap,Uh=new WeakMap,d1=new WeakMap,G5=new WeakMap,q5=new WeakMap;var p1,c_=class extends vP{constructor({messages:t,...n}){const i=new gX(t);super({...n,state:i}),Vs(this,p1,void 0),this["~registerMessagesCallback"]=(s,u)=>er(this,p1)["~registerMessagesCallback"](s,u),this["~registerStatusCallback"]=s=>er(this,p1)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>er(this,p1)["~registerErrorCallback"](s),Xu(this,p1,i)}};p1=new WeakMap;function vX({experimental_throttle:e,resume:t=!1,...n}={}){const i=A.useRef("chat"in n?n.chat:new c_(n));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new c_(n));const u=A.useCallback(y=>i.current["~registerMessagesCallback"](y,e),[e,i.current.id]),f=A.useSyncExternalStore(u,()=>i.current.messages,()=>i.current.messages),d=A.useSyncExternalStore(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),m=A.useSyncExternalStore(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),v=A.useCallback(y=>{typeof y=="function"&&(y=y(i.current.messages)),i.current.messages=y},[i]);return A.useEffect(()=>{t&&i.current.resumeStream()},[t,i]),{id:i.current.id,messages:f,setMessages:v,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:m,resumeStream:i.current.resumeStream,status:d,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput}}function yX(e){const t=new Map,n=[],i=s=>s.parts.filter(u=>{if(u.type==="text"){const f=u.text;return f&&f.trim()!==""}return u.type!=="step-start"});for(const s of e)if(t.has(s.id)){const u=t.get(s.id);t.set(s.id,{...u,parts:[...i(u),...i(s)]})}else n.push(s.id),t.set(s.id,{...s,parts:i(s)});return n.map(s=>t.get(s)).filter(s=>s.parts.length>0)}function xX(e){const t=vX(e);if(!(e!=null&&e.enableMerge))return t;const n=A.useMemo(()=>yX(t.messages),[t.messages]);return{...t,messages:n}}const wX=(e,t)=>{const n=Ki();A.useEffect(()=>{n.emit("chat-msg-status-change",{messageId:e,status:t})},[e,t])},C2=(e,t)=>{const n=Ki();A.useEffect(()=>{const i=s=>t(s);return n.on(e,i),()=>{n.off(e,i)}},[e,t])},bX=({client:e})=>{var le,se,ve;const t=Jd(e),n=Ci(_e=>_e.setLastBotMessage),{exec:i=()=>{}}=Fl("onAfterChatAreaHide"),{exec:s=()=>{}}=Fl("onBeforeMessagesClear"),u=A.useMemo(()=>{var _e;return new xb({api:(_e=e==null?void 0:e.options)==null?void 0:_e.chatApiEndpoint,headers:()=>{var ke;return{...(ke=e==null?void 0:e.options)==null?void 0:ke.chatApiHeaders}}})},[(le=e==null?void 0:e.options)==null?void 0:le.chatApiEndpoint,(se=e==null?void 0:e.options)==null?void 0:se.chatApiHeaders]),{messages:f,sendMessage:d,status:m,id:v,setMessages:y,stop:x,addToolOutput:k,regenerate:S}=xX({transport:u,enableMerge:t==null?void 0:t.enableMessageMerge,onError:_e=>{console.error("Chat transport error:",_e),y(ke=>[...ke,{id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:`Error: ${_e.message||"An error occurred during chat."}`,providerMetadata:{raw:{data:{type:"agent-error",error:"智能体内部错误,请稍后重试"}}}}]}])}}),L=A.useCallback(_e=>{y(ke=>[...ke,{id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:_e,providerMetadata:{raw:{data:{type:"agent-fake-msg",error:_e}}}}]}])},[y]);A.useEffect(()=>{e._sendMessage=d,e._appendFakeBotMessage=L,e.markChatComponentReady()},[d,e,L]),A.useEffect(()=>{const _e=f.filter(ke=>ke.role==="assistant").pop();n(_e)},[f,n]);const T=sf();A.useEffect(()=>{var _e,ke;(m==="error"||m==="ready")&&(T==null||T.clearGlobalFakeLoadingMessage()),(ke=(_e=e==null?void 0:e.options)==null?void 0:_e.onMessageStatusChange)==null||ke.call(_e,m,(e==null?void 0:e.getLastBotMsg(!0))||"")},[m]),C2("send-ghost-msg",_e=>{const{text:ke,options:Ae}=_e;d({text:ke},Ae)});const{isHide:M}=u2();A.useEffect(()=>{M&&(x(),i({clearMsgs:()=>{s(v),y(()=>[])}}))},[M,x]);const[j,F]=A.useState(""),[P,z]=A.useState([]),Z=Vd("MessageInputTopSlot"),$=Z==null?void 0:Z.Component,G=`${_0((ve=e.options)==null?void 0:ve.backendApiEndpoint)}form/attachment/upload`,Y=b.jsx(sX,{fileUploadEndpoint:G,attachments:P,chatId:v,input:j,messages:f,sendMessage:d,setAttachments:z,setInput:F,setMessages:y,status:m,stop:x}),me=$?b.jsx($,{}):null,ce=$?b.jsxs("div",{className:"flex flex-col gap-[12px]",children:[me,Y]}):Y;return wX(v,m),A.useEffect(()=>()=>{x()},[]),b.jsx(yP,{messagesArea:b.jsx(lq,{regenerate:S,status:m,messages:f,setMessages:y,sendMessage:d,addToolOutput:k}),inputArea:ce})},S2=({children:e,className:t,minimal:n,entryVariant:i="default",icon:s,...u})=>{const f={default:"relative overflow-hidden bg-[linear-gradient(180deg,#DBE9FF_0%,#E9FFFD_100%)] h-[30px] hover:text-white before:content-[''] before:absolute before:inset-0 before:z-0 before:bg-[linear-gradient(180deg,#267AFF_0%,#B2EEFF_100%)] before:opacity-0 hover:before:opacity-100 before:transition-opacity before:duration-200 before:ease-out font-[500] text-[#0265ff]",ghost:"bg-transparent text-[#030303] font-[400] px-[10px] hover:bg-[#EFF0F6] h-[34px]",light:"text-[#030303] font-[400] px-[10px] bg-[#F0F6FF] hover:bg-[#d8dde5] h-[34px]",selected:"bg-[#EFF0F6] text-[#030303] font-[400] px-[10px]"};return b.jsx($d,{...u,variant:"entry",size:"entry",className:Fe("rounded-[4px] cursor-pointer",Fr,f[i],t),children:b.jsxs("span",{className:"relative z-10 inline-flex items-center gap-1.5",children:[s!=null?s:b.jsx(Kb,{}),n?null:e]})})},k2=({id:e,style:t="",rootEl:n,containerClasses:i=[],wrapperClasses:s=[],wrapperStyle:u={},extraHtml:f=""})=>{const[d,m]=A.useState(null),v=A.useRef(null);return A.useEffect(()=>{var y;(y=v.current)==null||y.classList.add(...s),d==null||d.classList.add(...i)},[s,i]),A.useEffect(()=>{v.current&&Object.entries(u).forEach(([y,x])=>{x!==void 0&&(v.current.style[y]=x)})},[u]),A.useEffect(()=>{v.current&&v.current.parentNode&&(v.current.parentNode.removeChild(v.current),v.current=null);try{const y=document.createElement("div");y.classList.add(...s,"wrapper"),v.current=y,Object.entries(u).forEach(([L,T])=>{T!==void 0&&(y.style[L]=T)});const x=y.attachShadow({mode:"open"});if(f&&(x.innerHTML=f),t){const L=document.createElement("style");L.textContent=t,x.appendChild(L)}const k=document.createElement("div");k.classList.add(...i,"shadow-container"),x.appendChild(k),(n||document.body).appendChild(y),m(k)}catch(y){console.error("创建Shadow DOM失败:",y),m(null)}},[n]),d&&(d.id=e),{shadowContainer:d,destroy:()=>{v.current&&v.current.parentNode&&(v.current.parentNode.removeChild(v.current),v.current=null)}}},CX=({avatar:e,width:t,onDockClick:n,onCloseClick:i,draggable:s,isDragging:u,isDocked:f,onDragStart:d})=>b.jsxs("div",{className:Fe("flex items-center justify-between","px-4","h-[52px] min-w-[200px]",{"w-full":!t,[`w-[${t}px]`]:t,"cursor-grab":s&&!u,"cursor-grabbing":u}),style:{backgroundImage:mz,backgroundSize:"cover",backgroundRepeat:"no-repeat"},onMouseDown:s?d:void 0,children:[e,b.jsxs("div",{className:"actions flex items-center gap-2.5 text-[#666]",children:[b.jsx(ef,{onMouseDown:m=>{m.stopPropagation()},tooltip:f?"悬浮":"右侧打开",icon:f?b.jsx(jz,{}):b.jsx(Dz,{}),onClick:n}),b.jsx(ef,{icon:b.jsx(Fz,{}),onClick:i})]})]}),SX={bottom:10,right:10};function kX(e={}){const{enabled:t=!0,initialPosition:n=SX,onPositionChange:i}=e,s=A.useMemo(()=>n,[n.bottom,n.right]),[u,f]=A.useState(s),[d,m]=A.useState(!1),v=A.useRef(i);v.current=i;const y=A.useRef({isDragging:!1,startX:0,startY:0,startBottom:0,startRight:0}),x=A.useRef(null),k=A.useCallback(()=>{var L;f(s),(L=v.current)==null||L.call(v,s)},[s]),S=A.useCallback(L=>{if(!t)return;L.preventDefault(),L.stopPropagation(),y.current={isDragging:!0,startX:L.clientX,startY:L.clientY,startBottom:u.bottom,startRight:u.right},m(!0),document.body.style.userSelect="none",document.body.style.cursor="grabbing";const T=j=>{y.current.isDragging&&(x.current!==null&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var Z;const F=j.clientX-y.current.startX,P=j.clientY-y.current.startY,z={right:Math.max(10,y.current.startRight-F),bottom:Math.min(y.current.startBottom-P,10)};f(z),(Z=v.current)==null||Z.call(v,z)}))},M=()=>{y.current.isDragging=!1,m(!1),document.body.style.userSelect="",document.body.style.cursor="",x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",T),document.addEventListener("mouseup",M)},[t,u]);return A.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),document.body.style.userSelect="",document.body.style.cursor=""},[]),{position:u,isDragging:d,handleDragStart:S,resetPosition:k}}const EX=({client:e})=>{var L,T,M,j;const{setStatus:t,isVisible:n,isFloat:i,isDock:s}=u2(),{position:u,isDragging:f,handleDragStart:d,resetPosition:m}=kX({enabled:i,initialPosition:{bottom:10,right:10}});A.useEffect(()=>{s&&m()},[s,m]);const v=Fe({"fixed z-50 rounded-lg":i,"shadow-lg":i&&!f,"shadow-2xl scale-[1.01] transition-shadow":i&&f,hidden:!n,"static w-full h-full shadow-md":s}),y=Vd("AvatarAndName"),x=y==null?void 0:y.Component,k=x?b.jsx(x,{variant:"active"}):b.jsx(hh,{name:((T=(L=e==null?void 0:e.options)==null?void 0:L.botInfo)==null?void 0:T.name)||"AI表单搭建",variant:"active"}),S=i?{width:354,height:"calc(100% - 20px)",bottom:`${u.bottom}px`,right:`${u.right}px`,zIndex:(j=(M=e==null?void 0:e.options)==null?void 0:M.safeZIndex)!=null?j:1}:{};return b.jsxs("div",{className:Fe("bg-white flex flex-col overflow-hidden",v),style:S,children:[b.jsx(CX,{onDockClick:()=>{t(i?"dock":"float")},isDocked:s,avatar:k,onCloseClick:()=>{t("hide")},draggable:i,isDragging:f,onDragStart:d}),b.jsx(bX,{client:e})]})},_X=({client:e})=>{var f,d,m;const{isVisible:t,container:n}=Ci(v=>({isVisible:v.chatStatus!=="hide",container:v.chatAreaContainer})),i=["h-full","w-full"],s={height:"100%",width:"100%"},{shadowContainer:u}=k2({id:"chat-sdk-content",style:((f=e==null?void 0:e.options)==null?void 0:f.style)||"",rootEl:n||((d=e==null?void 0:e.options)==null?void 0:d.el)||document.body,containerClasses:t?i:[],wrapperClasses:t?i:[],wrapperStyle:t?s:{},extraHtml:((m=e==null?void 0:e.options)==null?void 0:m.extraHtml)||""});return u?Nl.createPortal(b.jsx(EX,{client:e}),u):null},RX=({client:e})=>{var M,j,F;const{bottom:t=15,right:n=40}=((M=e==null?void 0:e.options)==null?void 0:M.btnOffset)||{},{entryVisible:i,status:s,entryWrapper:u,setStatus:f,isVisible:d,entryVariant:m}=Ci(P=>({setStatus:P.setChatStatus,entryVariant:P.chatEntryVariant,entryWrapper:P.chatEntryElWrapper,isVisible:P.chatStatus!=="hide",status:P.chatStatus,entryVisible:P.chatEntryVisible})),v=!!u,y=Vd("EntryButton"),x=y==null?void 0:y.Component,k=v?{cursor:"pointer"}:{position:"fixed",cursor:"pointer",bottom:t,right:n,zIndex:(j=e==null?void 0:e.options)==null?void 0:j.safeZIndex},S=x?b.jsx(x,{chatStatus:s,client:e,variant:m,chatVisible:d,style:k,onClick:()=>{f("dock")}}):b.jsx(S2,{style:k,minimal:d,onClick:()=>{f("dock")},children:"AI助手"}),{shadowContainer:L,destroy:T}=k2({id:"chat-sdk-entry",rootEl:u,containerClasses:["inline-flex"],wrapperClasses:["inline-flex","flex","items-center"],style:((F=e==null?void 0:e.options)==null?void 0:F.style)||""});return i?v?L?Nl.createPortal(S,L):null:(T(),S):null},TX=({client:e,config:t})=>{var S,L;const{setStatus:n,isVisible:i,status:s}=Ci(T=>({setStatus:T.setChatStatus,isVisible:T.chatStatus!=="hide",status:T.chatStatus})),u=Vd("EntryButton"),f=u==null?void 0:u.Component,d=!!t.wrapperEl,m=d?{cursor:"pointer"}:{position:"fixed",cursor:"pointer",zIndex:(S=e==null?void 0:e.options)==null?void 0:S.safeZIndex},v=()=>{n("dock")},y=f?b.jsx(f,{chatStatus:s,client:e,variant:t.variant,chatVisible:i,style:m,onClick:v}):b.jsx(S2,{style:m,minimal:i,onClick:v,children:"AI助手"}),{shadowContainer:x,destroy:k}=k2({id:`chat-sdk-entry-${t.id}`,rootEl:t.wrapperEl,containerClasses:["inline-flex"],wrapperClasses:["inline-flex"],style:((L=e==null?void 0:e.options)==null?void 0:L.style)||""});return t.visible?d?x?Nl.createPortal(y,x):null:(k(),y):null},LX=({client:e})=>{const t=Ci(i=>i.chatEntryButtons),n=Array.from(t.values());return n.length===0?null:b.jsx(b.Fragment,{children:n.map(i=>b.jsx(TX,{client:e,config:i},i.id))})},AX=({client:e})=>b.jsxs(b.Fragment,{children:[b.jsx(_X,{client:e}),b.jsx(RX,{client:e}),b.jsx(LX,{client:e})]}),NX=({store:e,client:t})=>{var n;return b.jsx(KN,{store:e,children:b.jsx(oS,{delayDuration:100,zIndex:((n=t==null?void 0:t.options)==null?void 0:n.safeZIndex)!=null?t.options.safeZIndex+1:50,children:b.jsx(AX,{client:t})})})};class MX{constructor(){ze(this,"events",new Map)}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),this}off(t,n){const i=this.events.get(t);if(!i)return this;const s=i.indexOf(n);return s>-1&&i.splice(s,1),this}emit(t,n){const i=this.events.get(t);return!i||i.length===0?!1:(i.slice().forEach(s=>{try{s(n)}catch(u){console.error(`Error in event handler for "${String(t)}":`,u)}}),!0)}once(t,n){const i=s=>{n(s),this.off(t,i)};return this.on(t,i)}listenerCount(t){var n,i;return(i=(n=this.events.get(t))==null?void 0:n.length)!=null?i:0}eventNames(){return Array.from(this.events.keys())}removeAllListeners(t){return t?this.events.delete(t):this.events.clear(),this}listeners(t){var n,i;return(i=(n=this.events.get(t))==null?void 0:n.slice())!=null?i:[]}}class OX extends MX{}const m1=class m1{constructor(t){ze(this,"root");ze(this,"Store");ze(this,"chatComponentReadyResolve");ze(this,"chatComponentReadyPromise");ze(this,"options");ze(this,"eventBus",new OX);ze(this,"_sendMessage");ze(this,"_appendFakeBotMessage");ze(this,"appendBotMessage",async t=>{var n;await this.whenChatComponentReady(),(n=this._appendFakeBotMessage)==null||n.call(this,t)});ze(this,"sendMessage",async(t,n,i)=>{var s;await this.whenChatComponentReady(),(s=this._sendMessage)==null||s.call(this,{text:t},{...i,body:{...(i==null?void 0:i.body)||{},userVar:n}})});this.chatComponentReadyPromise=new Promise(i=>{this.chatComponentReadyResolve=i}),this.options=t;const n=document.createElement("div");document.body.appendChild(n),n.id=`bs-chat-sdk-inst-root-${Date.now()}`,this.options.style+=__SDK_STYLES__,this.Store=HN(this),UN(this.Store,this.options),this.initPlugins(),this.root=Q4(n),this.root.render(b.jsx(NX,{client:this,store:this.Store})),m1.instances.push(this)}diposePlugins(){this.Store.getState().chatAreaPluginInstList.forEach(n=>{typeof n.dispose=="function"&&(n.dispose(),n.Context={})})}initPlugins(){var n;if(!this.options||!((n=this.options.plugins)!=null&&n.length))return;const t=this.options.plugins.map(i=>{var f;const s=i.createContext(),u=new i.Plugin(s);return(f=u.init)==null||f.call(u,this),u});this.Store.getState().setChatAreaPluginInstList(t)}setGlobalLoadingMessage(t){this.Store.getState().setGlobalFakeLoadingMessage(t)}getPluginCtx(t){var i;const n=this.Store.getState().chatAreaPluginInstList.find(s=>s.pluginName===t);return n?(i=n.getReadonlyContext)==null?void 0:i.call(n):void 0}getPluginMethod(t,n){const i=this.Store.getState().chatAreaPluginInstList.find(s=>s.pluginName===t);if(i&&typeof i[n]=="function")return i[n]}markChatComponentReady(){this.chatComponentReadyResolve()}whenChatComponentReady(){return this.chatComponentReadyPromise}clearChatHistory(){this.Store.getState().clearMessages()}getLastBotMsg(t){const n=this.Store.getState().lastBotMessage;if(n)return t?n.parts.filter(i=>i.type==="text").map(i=>i.text).join(""):n}getFullStyle(){return this.options.style}showChatArea(t,n){t?this.dockChatArea(n):this.Store.getState().setChatStatus("float")}setAuthToken(t){var i;((i=this.options.chatApiHeaders)==null?void 0:i.Authorization)!==`Bearer ${t}`&&(this.options.chatApiHeaders={...this.options.chatApiHeaders,Authorization:`Bearer ${t}`})}getChatStatus(){return this.Store.getState().chatStatus}isChatVisible(){return this.Store.getState().chatStatus!=="hide"}hideChatArea(){this.Store.getState().setChatStatus("hide")}dockChatArea(t){const n=this.Store.getState().chatAreaContainer;t===n&&this.Store.getState().chatStatus==="dock"||(this.Store.getState().setChatEntryVisible(!1),this.Store.getState().setChatAreaContainer(t),this.Store.getState().setChatStatus("dock"))}undockChatArea(){this.Store.getState().setChatAreaContainer(void 0),this.Store.getState().setChatEntryVisible(!0),this.Store.getState().setChatStatus("float")}isChatFloat(){return this.Store.getState().chatStatus==="float"}isChatDocked(){return this.Store.getState().chatStatus==="dock"}showChatEntryButton(t,n="default",i){i?this.upsertChatEntryButton(i,t,n):(this.Store.getState().setChatEntryVariant(n),this.Store.getState().setChatEntryVisible(!0,t))}hideChatEntryButton(t){t?this.Store.getState().setChatEntryButtonVisible(t,!1):this.Store.getState().setChatEntryVisible(!1)}upsertChatEntryButton(t,n,i="default"){this.Store.getState().upsertChatEntryButton({id:t,visible:!0,variant:i,wrapperEl:n})}removeChatEntryButton(t){this.Store.getState().removeChatEntryButton(t)}destroy(){this.diposePlugins(),this.eventBus.removeAllListeners(),m1.instances=m1.instances.filter(t=>t!==this)}};ze(m1,"instances",[]);let Y5=m1;const ea={CREATE_FORM:"form-builder-FormCreateConfirmed",CREATE_FORM_SUCCESS:"form-builder-FormCreateSuccess",CREATE_FORM_FAILED:"form-builder-FormCreateFailed",UPDATE_FORM_INFO:"form-builder-FormInfoUpdated",SAVE_FIELDS:"form-builder-FieldsConfirmed",FIELD_CREATED:"form-builder-FieldCreated",FIELDS_CLEARED:"form-builder-FieldsCleared",FIELDS_CREATED_FINISH:"form-builder-FieldsCreatedFinish",FIELD_CHECK_UPDATE:"form-builder-FieldCheckedChanged"},DX=()=>{const[e,t]=A.useState(!1);return C2(ea.SAVE_FIELDS,()=>{t(!0)}),e},uf=e=>{const{pluginMap:t}=Ci(n=>({pluginMap:n.chatAreaPluginMap}));return t.get(e)},Pl="McpFormBuilderPlugin",jX={mode:"tree",extendSet:{sort:["datahelp","module","formEvent"],status:!0,triggerField:"",triggerFieldMode:"none"},dataloadmode:["add","cover"]},cf={text:"输入框",password:"密码输入框",location:"定位",datetime:"日期时间选择器",radiogroup:"单选框",radio:"单选框",combo:"下拉框",address:"地址",button:"按钮",textarea:"多行输入框",combocheck:"多选下拉框",checkboxgroup:"多选框组",separator:"分割线",upload:"附件上传",number:"数字输入框",dataload:"数据加载",image:"图片上传",signature:"签名",dept:"部门选择",user:"成员选择",usergroup:"成员多选",deptgroup:"部门多选",unknown:"未知类型",sn:"流水号",formula:"公式字段",linkdata:"关联数据",linkquery:"关联查询",subform:"子表单",flowState:"流程状态",flowstate:"流程状态"},FX={address:"&#xe881;",subform:"&#xe847;",password:"&#xe854;",button:"&#xe8e8;",textarea:"&#xe84f;",datetime:"&#xe849;",text:"&#xe854;",location:"&#xe87f;",radiogroup:"&#xe853;",radio:"&#xe861;",combo:"&#xe84a;",formula:"",flowState:"",flowstate:"",combocheck:"&#xe84b;",separator:"&#xe850;",checkboxgroup:"&#xe84c;",upload:"&#xe621;",number:"&#xe846;",image:"&#xe880;",signature:"&#xe87e;",user:"&#xe856;",dataload:"&#xe848;",linkdata:"&#xe857;",linkquery:"&#xe857;",usergroup:"&#xe851;",dept:"&#xe84d;",sn:"&#xe882;",deptgroup:"&#xe852;",unknown:"&#xe848;"},IX={metric_table:"&#xe88c;",gauge_chart:"&#xe88d;",column_chart:"&#xe892;",funnel_chart:"&#xe89c;",line_chart:"&#xe88b;",pie_chart:"&#xe89e;",area_chart:"&#xe898;",radar_chart:"&#xe893;",bar_chart:"&#xe896;",gantt:"&#xe899;",multi_axes_chart:"&#xe88f;",data_table:"&#xe894;",background_table:"&#xe894;",pivot_table:"&#xe891;",map_chart:"&#xe89d;",newMap:"&#xe89d;",card:"&#xe8f4;",rili:"&#xe849;",description:"&#xe88e;",image:"&#xe890;",gauge_imageMore:"&#xe88d;"},X5=({type:e})=>{const t=FX[e]||"unknown";return e==="formula"?b.jsx(Jz,{}):b.jsx(ph,{code:t})},PX=(e,t)=>{const n=dh(e),i=Array.isArray(e)&&e.length?e:n?[e]:[],s=Ki(),u=uf(Pl);return i.map(f=>{var m;const d=$b(f);return d!=null&&d.widget?{field:d,disabled:t,onLoaded:v=>{const y=u==null?void 0:u.onBeforeFieldCreate(v);s.emit("form-builder-FieldCreated",{field:y,checked:!0}),u==null||u.onAfterFieldCreate(v)},icon:b.jsx(X5,{type:(m=d.widget)==null?void 0:m.type}),onChange:(v,y,x,k)=>{console.log("field checked changed:",{check:v,field:y,parentFieldName:x,index:k}),s.emit("form-builder-FieldCheckedChanged",{field:y,checked:v,parentFieldName:x,index:k})}}:null}).filter(Boolean)};var E2="Checkbox",[zX]=Ds(E2),[HX,J5]=zX(E2);function UX(e){const{__scopeCheckbox:t,checked:n,children:i,defaultChecked:s,disabled:u,form:f,name:d,onCheckedChange:m,required:v,value:y="on",internal_do_not_use_render:x}=e,[k,S]=Yd({prop:n,defaultProp:s!=null?s:!1,onChange:m,caller:E2}),[L,T]=A.useState(null),[M,j]=A.useState(null),F=A.useRef(!1),P=L?!!f||!!L.closest("form"):!0,z={checked:k,disabled:u,setChecked:S,control:L,setControl:T,name:d,form:f,value:y,hasConsumerStoppedPropagationRef:F,required:v,defaultChecked:Ju(s)?!1:s,isFormControl:P,bubbleInput:M,setBubbleInput:j};return b.jsx(HX,{scope:t,...z,children:BX(x)?x(z):i})}var f_="CheckboxTrigger",d_=A.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...i},s)=>{const{control:u,value:f,disabled:d,checked:m,required:v,setControl:y,setChecked:x,hasConsumerStoppedPropagationRef:k,isFormControl:S,bubbleInput:L}=J5(f_,e),T=Rn(s,y),M=A.useRef(m);return A.useEffect(()=>{const j=u==null?void 0:u.form;if(j){const F=()=>x(M.current);return j.addEventListener("reset",F),()=>j.removeEventListener("reset",F)}},[u,x]),b.jsx(Qt.button,{type:"button",role:"checkbox","aria-checked":Ju(m)?"mixed":m,"aria-required":v,"data-state":y_(m),"data-disabled":d?"":void 0,disabled:d,value:f,...i,ref:T,onKeyDown:Ut(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ut(n,j=>{x(F=>Ju(F)?!0:!F),L&&S&&(k.current=j.isPropagationStopped(),k.current||j.stopPropagation())})})});d_.displayName=f_;var p_=A.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:i,checked:s,defaultChecked:u,required:f,disabled:d,value:m,onCheckedChange:v,form:y,...x}=e;return b.jsx(UX,{__scopeCheckbox:n,checked:s,defaultChecked:u,disabled:d,required:f,onCheckedChange:v,name:i,form:y,value:m,internal_do_not_use_render:({isFormControl:k})=>b.jsxs(b.Fragment,{children:[b.jsx(d_,{...x,ref:t,__scopeCheckbox:n}),k&&b.jsx(v_,{__scopeCheckbox:n})]})})});p_.displayName=E2;var h_="CheckboxIndicator",m_=A.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:i,...s}=e,u=J5(h_,n);return b.jsx(jl,{present:i||Ju(u.checked)||u.checked===!0,children:b.jsx(Qt.span,{"data-state":y_(u.checked),"data-disabled":u.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});m_.displayName=h_;var g_="CheckboxBubbleInput",v_=A.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:i,hasConsumerStoppedPropagationRef:s,checked:u,defaultChecked:f,required:d,disabled:m,name:v,value:y,form:x,bubbleInput:k,setBubbleInput:S}=J5(g_,e),L=Rn(n,S),T=M5(u),M=T9(i);A.useEffect(()=>{const F=k;if(!F)return;const P=window.HTMLInputElement.prototype,Z=Object.getOwnPropertyDescriptor(P,"checked").set,$=!s.current;if(T!==u&&Z){const G=new Event("click",{bubbles:$});F.indeterminate=Ju(u),Z.call(F,Ju(u)?!1:u),F.dispatchEvent(G)}},[k,T,u,s]);const j=A.useRef(Ju(u)?!1:u);return b.jsx(Qt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f!=null?f:j.current,required:d,disabled:m,name:v,value:y,form:x,...t,tabIndex:-1,ref:L,style:{...t.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});v_.displayName=g_;function BX(e){return typeof e=="function"}function Ju(e){return e==="indeterminate"}function y_(e){return Ju(e)?"indeterminate":e?"checked":"unchecked"}const VX=()=>b.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("rect",{x:"0.5",y:"0.5",width:"7",height:"7",rx:"1",fill:"#0265ff"})}),Q5=A.forwardRef(({className:e,children:t,id:n,readonly:i,disabled:s,intermediate:u,...f},d)=>{const m=A.useId(),v=n!=null?n:m;return b.jsxs("label",{htmlFor:v,className:Fe("inline-flex items-center gap-[6px] select-none text-[#121111] text-[14px]",s?"cursor-not-allowed":"cursor-pointer",{"pointer-events-none":i}),children:[b.jsx(p_,{ref:d,id:v,disabled:s,className:Fe("inline-flex shrink-0 items-center justify-center","w-[16px] h-[16px] rounded-[2px] box-border border","transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0265FF] focus-visible:ring-offset-1","border-[#E0E0E0] bg-white","hover:border-[#0265FF]","data-[state=checked]:bg-[#0265FF] data-[state=checked]:border-[#0265FF]","disabled:cursor-not-allowed disabled:bg-[#F0F0F0] disabled:border-[#C2C2C2]","disabled:data-[state=checked]:bg-[#C2C2C2] disabled:data-[state=checked]:border-[#C2C2C2]",u&&"bg-white border-[#0265FF] text-[#0265FF]",e,{"opacity-50":i}),...f,children:b.jsx(m_,{className:"text-white",forceMount:u||void 0,children:u?b.jsx(VX,{}):b.jsx(Jb,{})})}),t!=null&&b.jsx("span",{className:Fe("text-sm leading-none",s&&"text-[#C2C2C2]"),children:t})]})});Q5.displayName="SquareChecker";const _2=({defaultChecked:e=!1,checked:t,disabled:n=!1,onCheckedChange:i,icon:s,className:u,title:f,extra:d,style:m,streaming:v,confirmed:y,readonly:x,shortDesc:k})=>{const[S,L]=A.useState(e);A.useEffect(()=>{t!==void 0&&L(t)},[t]);const T=()=>{if(v||n)return;const F=!S;L(F),i==null||i(F)},M=!!d,j=y&&S?b.jsx(Qb,{className:"grow-0 shrink-0 text-[#0265ff]"}):b.jsx(Q5,{className:Wr("outline-none grow-0 shrink-0 cursor-pointer",{"mt-[2px]":M,"opacity-80 cursor-not-allowed":n,"opacity-50":v,"pointer-events-none":v}),id:f,checked:S,disabled:n||y,onCheckedChange:T});return b.jsxs("div",{className:Fe("flex items-center gap-[10px] px-4 py-[10px] rounded-[4px]","w-full transition-colors cursor-pointer",{"cursor-not-allowed":n,"hover:bg-[#EFF0F6]":!n,"items-start":M,"items-center":!M,"pointer-events-none":v||n||x||y},u),style:m,onClick:()=>{T()},children:[x?null:j,b.jsxs("div",{className:Wr("flex flex-col flex-1 min-w-0",{"gap-2.5":M}),children:[b.jsxs("div",{className:Wr("flex items-center justify-between w-full",{"gap-1.5":!!s,"gap-2.5":!s}),children:[b.jsxs("div",{className:Wr("flex items-center gap-[6px] min-w-0",{"flex-1":!!s,"w-[100px] flex-shrink-0":!s}),children:[s&&b.jsx("div",{className:"w-4 h-4 flex-shrink-0 text-[#6F829E] leading-[16px]",children:s}),b.jsx("p",{className:Wr(" min-w-0 text-sm text-[#121111] truncate text-[12px]",{"flex-1":!!s,"flex-grow-1 flex-shrink-0":!s,"!text-[#666]":x}),children:f})]}),k&&b.jsx("p",{className:Wr("text-sm text-[#666] text-[12px]",{"whitespace-nowrap flex-shrink-0":!!s,anywhere:!s,"!text-[#121111]":x}),children:k})]}),M?b.jsx("div",{className:Fe("overflow-x-auto whitespace-nowrap no-scrollbar flex items-center gap-2",{"!overflow-x-hidden":n||x||y}),children:d}):null]})]})},$X=({bgColor:e="#E8F4FF",color:t="#0265FF",label:n,children:i})=>b.jsx("div",{className:"flex items-center justify-center gap-1.5 px-1.5 h-[26px] rounded-[100px] text-[13px]",style:{backgroundColor:e,color:t},children:n||i}),x_=A.memo(({field:e,disabled:t,isSubField:n,onChange:i,onLoaded:s,icon:u,value:f,checked:d,streaming:m,confirmed:v})=>{const{widget:y,label:x}=e;if(!y)return null;const{type:k}=y,S=k;if(!cf.hasOwnProperty(k))return null;const L=cf[S]||cf.unknown,T=k==="subform",M=T?[]:y.items||[],j=T?y.items:[],[F,P]=A.useState(()=>Object.fromEntries(j.map((Y,me)=>[me,!0]))),z=A.useRef(d);A.useEffect(()=>{T&&d!==z.current&&(z.current=d,d!==void 0&&P(Object.fromEntries(j.map((Y,me)=>[me,d]))))},[d,T,j.length]);const Z=(Y,me,ce)=>{P(le=>{const se={...le,[ce]:Y};return Object.values(se).every(Boolean)&&(i==null||i(!0,e)),Object.values(se).every(ke=>ke===!1)&&(i==null||i(!1,e)),se}),i==null||i(Y,me,e.widget.widgetName,ce)};A.useEffect(()=>{s==null||s(e)},[]);const $=Y=>{i==null||i(Y,e)},G=n?"pl-[38px]":"";return f?b.jsx(_2,{title:x,disabled:t,checked:d,defaultChecked:!0,onCheckedChange:$,icon:u,className:G,shortDesc:f}):b.jsxs(b.Fragment,{children:[b.jsx(_2,{streaming:m,confirmed:v,title:x,disabled:t,checked:d,defaultChecked:!0,onCheckedChange:$,icon:u,shortDesc:L,className:G,extra:M.length?b.jsx(b.Fragment,{children:M.map(({value:Y,text:me,color:ce})=>b.jsx($X,{color:ce?"white":void 0,bgColor:ce,children:me},Y))}):null}),T?j.map((Y,me)=>{var ce;return b.jsx(x_,{confirmed:v,streaming:m,isSubField:!0,disabled:t,checked:F[me],field:Y,icon:b.jsx(X5,{type:(ce=Y.widget)==null?void 0:ce.type}),onChange:le=>{Z(le,Y,me)}},Y.label)}):null]})},(e,t)=>{var n,i;return((n=e.field)==null?void 0:n.label)===((i=t.field)==null?void 0:i.label)&&e.disabled===t.disabled&&e.checked===t.checked&&e.confirmed===t.confirmed&&e.streaming===t.streaming}),Qu="form-filling-plugin",ri={FORM_STRUCTURE_READY:"form-filling-structure-ready",FIELD_FILLED_UPDATE:"form-filling-field-filling-update",FIELDS_CHECKED_UPDATE:"form-filling-fields-checked-update",FILL_MODE_UPDATE:"form-filling-mode-update",BATCH_FILL_BEGIN:"form-filling-batch-fill-begin",FILL_DATA_CONFIRMED:"form-filling-fields-data-confirmed"},ZX=new Set(["password","textarea","datetime","text","radiogroup","radio","combo","combocheck","checkboxgroup","number"]),ff=10;function WX(e){return Array.isArray(e)?e.every(t=>typeof t=="string"):!1}function w_(e){return Array.isArray(e)?e.every(t=>typeof t=="object"&&t!==null&&"label"in t&&"value"in t&&typeof t.label=="string"&&typeof t.value=="string"):!1}const b_=e=>WX(e)?e.join(", "):w_(e)?e.map(n=>n.value).join(", "):e,C_=(e,t)=>{if(t==="address"&&typeof e=="object"){const n=e;return`${n.province} ${n.city} ${n.district} ${n.detail}`}if(t==="location"&&typeof e=="object"){const i=e.lnglatXY||["",""];return`经度: ${i[0]||""}, 纬度: ${i[1]||""}`}return Array.isArray(e)?e.join(", "):w_(e)?e.map(i=>i.value).join(", "):e},S_=e=>Array.isArray(e)?e.filter(t=>{var n;return ZX.has((n=t.widget)==null?void 0:n.type)}):[];var R2="Collapsible",[GX]=Ds(R2),[qX,K5]=GX(R2),k_=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:i,defaultOpen:s,disabled:u,onOpenChange:f,...d}=e,[m,v]=Yd({prop:i,defaultProp:s!=null?s:!1,onChange:f,caller:R2});return b.jsx(qX,{scope:n,disabled:u,contentId:Uu(),open:m,onOpenToggle:A.useCallback(()=>v(y=>!y),[v]),children:b.jsx(Qt.div,{"data-state":ty(m),"data-disabled":u?"":void 0,...d,ref:t})})});k_.displayName=R2;var E_="CollapsibleTrigger",YX=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,...i}=e,s=K5(E_,n);return b.jsx(Qt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":ty(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:t,onClick:Ut(e.onClick,s.onOpenToggle)})});YX.displayName=E_;var ey="CollapsibleContent",__=A.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=K5(ey,e.__scopeCollapsible);return b.jsx(jl,{present:n||s.open,children:({present:u})=>b.jsx(XX,{...i,ref:t,present:u})})});__.displayName=ey;var XX=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:i,children:s,...u}=e,f=K5(ey,n),[d,m]=A.useState(i),v=A.useRef(null),y=Rn(t,v),x=A.useRef(0),k=x.current,S=A.useRef(0),L=S.current,T=f.open||d,M=A.useRef(T),j=A.useRef(void 0);return A.useEffect(()=>{const F=requestAnimationFrame(()=>M.current=!1);return()=>cancelAnimationFrame(F)},[]),go(()=>{const F=v.current;if(F){j.current=j.current||{transitionDuration:F.style.transitionDuration,animationName:F.style.animationName},F.style.transitionDuration="0s",F.style.animationName="none";const P=F.getBoundingClientRect();x.current=P.height,S.current=P.width,M.current||(F.style.transitionDuration=j.current.transitionDuration,F.style.animationName=j.current.animationName),m(i)}},[f.open,i]),b.jsx(Qt.div,{"data-state":ty(f.open),"data-disabled":f.disabled?"":void 0,id:f.contentId,hidden:!T,...u,ref:y,style:{"--radix-collapsible-content-height":k?`${k}px`:void 0,"--radix-collapsible-content-width":L?`${L}px`:void 0,...e.style},children:T&&s})});function ty(e){return e?"open":"closed"}var JX=k_;const R_=JX,T_=__,QX=({disabled:e,onCheckedChange:t,label:n,val:i,streaming:s,readonly:u})=>b.jsx(_2,{streaming:s,readonly:u,title:n,disabled:e,defaultChecked:!0,onCheckedChange:t,className:"pl-[36px]",shortDesc:i}),KX=A.memo(({field:e,readonly:t,onCheckedChange:n,streaming:i})=>{const{widget:s,label:u}=e;if(!s)return null;const{type:f,value:d}=s,m=f;if(!cf.hasOwnProperty(m))return null;const v=C_(d,m),y=cf[m]||cf.unknown,x=A.useCallback(k=>{n(k,e)},[e]);return A.useEffect(()=>{x(!0)},[]),b.jsx(QX,{streaming:i,readonly:t,desc:y,label:u,val:v,onCheckedChange:x})},(e,t)=>{var i,s;return((i=e.field.widget)==null?void 0:i.widgetName)===((s=t.field.widget)==null?void 0:s.widgetName)&&e.readonly===t.readonly&&e.streaming===t.streaming}),eJ=({subformField:e,onChange:t,streaming:n,readonly:i})=>{if(!e.widget.value||!e.widget.value.length)return null;const s=e.widget.value,[u,f]=A.useState(!0);return b.jsx(R_,{open:u,onOpenChange:f,children:b.jsx(T_,{children:s.map((d,m)=>b.jsx(R_,{defaultOpen:!0,children:b.jsx(T_,{children:d.map((v,y)=>b.jsx(KX,{readonly:i,streaming:n,field:{label:v.label,widget:{widgetName:v.fieldName,type:v.fieldType,value:v.value}},onCheckedChange:(x,k)=>{t({checked:x,field:k,row:m,col:y,parentFieldName:e.widget.widgetName})}}))})},m))})})},tJ=A.memo(({field:e,disabled:t,isSubField:n,readonly:i,streaming:s,onChange:u,onLoaded:f})=>{const{widget:d,label:m}=e;if(!d)return null;const{type:v,value:y}=d,k=C_(y,v);if(!cf.hasOwnProperty(v))return null;const S=v==="subform";A.useEffect(()=>{f==null||f(e)},[]);const L=M=>{u==null||u(M,e)},T=n?"pl-6":"";return b.jsxs(b.Fragment,{children:[b.jsx(_2,{streaming:s,title:m,disabled:t,defaultChecked:!0,onCheckedChange:L,className:T,readonly:i,shortDesc:S?"":k}),S&&b.jsx(eJ,{readonly:i,subformField:e,onChange:M=>{u==null||u(M.checked,M.field,M.parentFieldName,M.row)},streaming:s})]})},(e,t)=>{var d,m,v,y,x,k;return!(((d=e.field)==null?void 0:d.label)===((m=t.field)==null?void 0:m.label))||!(((y=(v=e.field)==null?void 0:v.widget)==null?void 0:y.widgetName)===((k=(x=t.field)==null?void 0:x.widget)==null?void 0:k.widgetName))||!(e.disabled===t.disabled)||!(e.readonly===t.readonly)||!(e.streaming===t.streaming)?!1:Lz(e==null?void 0:e.field,t==null?void 0:t.field)}),nJ=A.memo(A.forwardRef(({fields:e,children:t,streaming:n,confirmed:i},s)=>{const[u,f]=A.useState(()=>Object.fromEntries(e.map(x=>{var k,S;return[(S=(k=x.field)==null?void 0:k.label)!=null?S:"",!0]}))),d=A.useMemo(()=>e.length>0&&e.every(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}),[u,e]),m=A.useMemo(()=>e.some(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}),[u,e]),v=n||!d&&m;A.useImperativeHandle(s,()=>({getCheckedFieldsLength:()=>e.filter(x=>{var k,S;return u[(S=(k=x.field)==null?void 0:k.label)!=null?S:""]!==!1}).length}),[u,e]);const y=A.useCallback(x=>{const k=x===!0;f(Object.fromEntries(e.map(S=>{var L,T;return[(T=(L=S.field)==null?void 0:L.label)!=null?T:"",k]}))),e.forEach(S=>{var L;return(L=S.onChange)==null?void 0:L.call(S,k,S.field)})},[e]);return b.jsxs(o1,{title:"字段生成",icon:b.jsx(zz,{}),defaultOpen:!0,children:[b.jsx("div",{className:Fe("flex gap-[10px] px-4 py-[10px] rounded-[4px] w-full transition-colors cursor-pointer hover:bg-[#EFF0F6] items-center",{"pointer-events-none":i||n}),onClick:()=>{if(i)return;y(!d)},children:b.jsx(Q5,{readonly:i||n,checked:d&&!n,onCheckedChange:y,intermediate:v,children:b.jsx("span",{className:"!text-[#0265ff] !font-[700]",children:"全选"})})}),e.map(x=>{var k,S,L;return A.createElement(x_,{...x,key:(k=x.field)==null?void 0:k.label,checked:u[(L=(S=x.field)==null?void 0:S.label)!=null?L:""],streaming:n,confirmed:i,onChange:(T,M,j,F)=>{var z;F!==void 0&&j!==void 0||f(Z=>{var $,G;return{...Z,[(G=($=x.field)==null?void 0:$.label)!=null?G:""]:T}}),(z=x.onChange)==null||z.call(x,T,M,j,F)}})}),t]})})),rJ=A.memo(({props:e,readonly:t,children:n,streaming:i})=>b.jsxs(o1,{title:"字段填写",icon:b.jsx(qb,{}),defaultOpen:!0,children:[e.map(s=>b.jsx(tJ,{...s,readonly:t,streaming:i})),n]})),df=({text:e="确认",prefixDesc:t,className:n,disabled:i,light:s,icon:u,children:f,...d})=>{const m=b.jsxs($d,{...d,variant:"default",disabled:i,className:Fe("px-[10px] py-0 rounded-[100px] text-[14px] leading-normal h-[34px] min-w-[100px] cursor-pointer w-full disabled:opacity-100 gap-[6px] shadow-none",i?"bg-[#f0f0f0] text-[#999] cursor-not-allowed shadow-none":s?"bg-[#F0F6FF] text-[#0265FF] hover:bg-[#0265FF] hover:text-white":"bg-[#0265ff] text-white hover:bg-[#0265ff]/80",Fr,{"!bg-[#E5E6EB] !text-[#121111] shadow-none font-[400]":d.disabledWithInfo},n),children:[u,f||e]});return t?b.jsxs("div",{className:"flex flex-col items-start gap-2.5",children:[b.jsx("p",{className:"text-[#4D609F]",children:t}),m]}):m},oJ=e=>{var S,L,T;const{confirmed:t,part:n,status:i}=e,u=PX(n,!!t),f=A.useRef(null),d=uf(Pl),m=((S=d==null?void 0:d.getCurrentWorkingForm())==null?void 0:S.formName)||"",v=Ki(),y=b.jsxs("div",{children:[b.jsx("b",{style:{display:"inline-block"},children:m}),` 已生成${u.length}个字段`]}),x=t?b.jsxs(b.Fragment,{children:[b.jsx(Qb,{className:"text-[#0265ff]"})," 已保存"," ",(T=(L=f.current)==null?void 0:L.getCheckedFieldsLength())!=null?T:0," 个字段"]}):"保存字段",k=i==="ready"?"请选择需要的字段添加到表单。您可以补充描述后重新生成,表单中已添加字段在下次生成时保留。":null;return b.jsxs(tf,{className:"gap-0 py-0",compact:!0,children:[y,b.jsx(nJ,{ref:f,fields:u,streaming:i==="streaming",confirmed:t,children:i==="ready"?b.jsx(df,{className:"mt-[20px] mb-[10px]",disabledWithInfo:t,onClick:()=>{v.emit("form-builder-FieldsConfirmed",d==null?void 0:d.getCurrentWorkingForm()),d.onAfterFieldsSave(M=>{v.emit("form-builder-FieldsConfirmed",M)})},children:x}):null}),k]})},pf=A.forwardRef(({className:e,children:t,hoverTextCls:n,tooltip:i,icon:s,type:u,...f},d)=>{const m=b.jsxs("button",{ref:d,type:u!=null?u:"button",className:Fe("group inline-flex items-center gap-[6px] px-[16px] rounded-[4px] h-[34px]","border border-solid border-[#E0E0E0] bg-transparent","text-[14px] font-[400] leading-[normal] text-[#030303]","hover:bg-[#EFF0F6] hover:border-transparent","cursor-pointer",{"hover:text-[#0265FF]":!n,[`hover:${n}`]:n},Fr,e),...f,children:[s?b.jsx("span",{className:"shrink-0",children:s}):null,t?b.jsx("span",{className:"whitespace-nowrap",children:t}):null]});return i?b.jsx(bh,{content:i,children:m}):m});pf.displayName="BaseButton";const iJ=e=>{const t=e.match(/&#x[a-fA-F0-9]+;/);return t?t[0]:"&#xe817;"},aJ=e=>{const t=iJ(e.description),n=t?b.jsx(ph,{code:t,className:"text-[16px] text-[#999]"}):null,i=t?e.description.replace(t,"").trim():e.description,s=t?e.title.replace(t,"").trim():e.title;return b.jsx(pf,{icon:n,className:"self-start w-full px-[10px]",hoverTextCls:"text-[#121111]",onClick:()=>{var u;(u=e.onSelect)==null||u.call(e,s,t||"")},children:i})},rs=e=>{const t=uf(e);return t?t.Context:null},sJ=e=>{const{confirmed:t}=e,n=uf(Pl),i=n==null?void 0:n.getCurrentWorkingForm(),s=Ki();return A.useEffect(()=>{s.emit("form-builder-FieldsCreatedFinish",i)},[]),b.jsx(b.Fragment,{children:t?b.jsx(Wu,{children:"试试以下建议"}):null})},lJ=e=>{const{confirmed:t,sendMessage:n,part:i}=e,s=i,u=rs(Pl);return t?b.jsx(aJ,{title:s.text,description:s.text,onSelect:(f,d)=>{u&&(u.workStage,console.log("follow up icon code",d),console.log("follow up icon value",u9(d)),u.pickedIconValue=u9(d)),n({text:f},{body:{stage:"design"}})},headless:!0}):null},uJ=e=>{var u;const t=dh(e);return(Array.isArray(e)&&e.length?e:t?[e]:[]).length?"fields":Ez(e)?"followup":_z(e)?"followup_prefix":((u=e.text)==null?void 0:u.startsWith("待搭建表单信息"))?"design_doc":"markdown"};function L_(e,t){const n=e.match(t);return n?n[1]:""}function A_(e){if(!e)return"";const t=[/关联来源:(.*)表?,/,/关联(.*)表?/,/(从(.*)表?中查询)/,/来自(.*)表?/];for(const n of t)return L_(e,n);return""}const cJ=e=>{const t=e.split("-");return t.length>1?{isSubForm:t[0].trim().toLowerCase()==="子表单",formName:t[1].trim()}:{isSubForm:!1,formName:""}};function N_(e){const t=e.split(`
512
512
  `).filter(s=>s.trim()),n=[];let i="";return t.forEach(s=>{let[u,f,d,m,v=""]=s.split("|").map(Z=>Z.trim());if(!u||!f||!d||!m)return;const y=f.match(/类型:(.*)/),x=y?y[1]:"";x==="子表单"&&(i=u);const k=d.match(/必填:(\w+)/),S=k?k[1]==="是":!1,L=m.match(/说明:(.+)/),T=L?L[1]:"",M=L_(v,/关系:(.+)/);u=u.replace(/^\d+\.\s*/,"");const j=cJ(T),F=u.split("-"),P=F.length>1||j.isSubForm||T.includes("子表单"),z=(P?F[0]||j.formName:void 0)||i;n.push({fieldName:P?F[F.length-1]:u,type:x,required:S,description:T,relationDesc:M,isSubForm:x==="子表单"||j.isSubForm,isFieldInSubForm:P,parentFormName:z})}),n}function fJ(e){const t=new Map;return e.forEach(n=>{if(n.type==="关联查询"||n.type==="关联数据"){const i=A_(n.description)||A_(n.relationDesc),s=n.fieldName.match(/\d+\. (.*)/),u=s?s[1]:n.fieldName,f=u.split("-"),d=f.length>1?f[f.length-1]:u;t.set(d,{fieldName:d,targetFormName:i})}}),t}const Bh=e=>e.replace(/表单|表|管理表/g,"").trim(),dJ=e=>({linkInfoMap:fJ(N_(e)),formName:Bh(Rz(e))}),hf=(e,t)=>!e||!e.widget?!1:e.widget.type===t,pJ=e=>{var t,n;return hf(e,"subform")?((n=(t=e.widget)==null?void 0:t.items)==null?void 0:n.length)>0:!1},hJ=e=>hf(e,"linkdata")||hf(e,"linkquery"),mJ=e=>!e||!e.widget?!1:e.widget.type==="sn",gJ=e=>!e||!e.widget?!1:e.widget.type==="text",vJ=e=>e?e.linkInfoMap&&e.linkInfoMap.size>0:!1,yJ=(e,t)=>{const{isTargetForm:n,isTargetField:i,fieldProcessor:s,onFormProcessed:u}=t;let f;for(const[d,m]of e){if(f=!1,!n(Bh(d),m)){console.log("[formFieldsWalker]","不是目标表单,不处理",d,m);continue}const v=m.designInfo.linkInfoMap;for(const[y,x]of v){if(!i(y,x)){console.log("[formFieldsWalker]","不是目标字段,不处理",d,m,y);continue}const k=m.fieldMap.get(y);if(!k){console.log("[formFieldsWalker]","未找到目标字段,不处理",d,m,y);continue}const S=s(m,k,x);f=!0,m.fieldMap.set(y,S)}f&&u(m)}},M_=(e="_widget",t)=>{const n=`${e}_${Date.now()}`;if(t===void 0)return n;const i=t.toString().length;return`${n.slice(0,-i)}${t}`},xJ=(e,t,n,i)=>{var d,m,v,y;if(!hf(e,"dataload"))return console.log("非数据加载字段,跳过处理",e),e;if(!t.targetFormName)return console.log("无关联信息,跳过处理",e),e;if(n.size===0)return console.log("无表单映射,跳过处理",e),e;const s=n.get(t.targetFormName);if(!s)return console.log("无表单映射,跳过处理",e),e.widget.loaddataconfig=jX,e;const u=((m=(d=e.widget)==null?void 0:d.loaddataconfig)==null?void 0:m.mapFields)||[],f=((y=(v=e.widget)==null?void 0:v.loaddataconfig)==null?void 0:y.fields)||[];if(!u||u.length===0||u.length!==f.length)return console.log("无映射字段,跳过处理",e),e;console.log("开始数据加载补全逻辑",e,s),e.widget.loaddataconfig.forms=s.formId;for(let x=0;x<u.length;x++){const k=u[x],S=f[x],L=k.depend.field,T=s.fieldMap.get(L);if(!T){console.log("未找到目标依赖字段,跳过处理该映射字段",k);continue}const M=M_("f",x);k.field=M_("_widget",x),k.depend.field=M,S.name=T.widget.widgetName,S.form=s.formId,S.tag=M}return console.log("数据加载字段信息已补全",e),i(e),e},O_=(e,t,n,i)=>{if(console.log("开始关联字段处理",e,t,n),!hJ(e))return console.log("[enhanceLinkField] 非关联字段,跳过处理",e),e;if(!t.targetFormName)return console.log("[enhanceLinkField] 无关联信息,跳过处理",e),e;if(n.size===0)return console.log("[enhanceLinkField] 无表单映射,跳过处理",e),e;const s=n.get(Bh(t.targetFormName));if(!s)return console.log("[enhanceLinkField] 未找到目标表单,跳过处理",n,t.targetFormName),e;try{e.widget.refAppId=s.appId,e.widget.linkForm=s.formId}catch(d){return console.log("[enhanceLinkField] 尝试建立表单关联失败"),e}const u=s.fields.find(mJ);if(!u)return console.log("[enhanceLinkField] 未找到目标表单的主键字段,跳过处理",e),e;if(hf(e,"linkdata"))try{e.widget.linkKey=u.widget.widgetName,e.widget.linkType="sn"}catch(d){return console.log("[enhanceLinkField] 尝试建立主键关联失败"),e}const f=s.fields.find(gJ);if(!f)return console.log("[enhanceLinkField] 未找到目标表单的显示字段,跳过处理",e),e;try{e.widget.linkFields=[{text:f.label,name:f.widget.widgetName,type:"text"}]}catch(d){return console.log("[enhanceLinkField] 尝试建立显示字段关联失败"),e}return console.log("[enhanceLinkField] 关联字段信息已补全",e),i(e),e},ny={linkdata:e=>(t,n,i)=>O_(n,i,e,s=>{t.designInfo.linkInfoMap.delete(i.fieldName)}),linkquery:e=>(t,n,i)=>O_(n,i,e,s=>{t.designInfo.linkInfoMap.delete(i.fieldName)}),dataload:e=>(t,n,i)=>xJ(n,i,e,s=>{t.designInfo.linkInfoMap.delete(i.fieldName)})};function wJ(e){const t=[];let n=0;for(;n<e.length;){const i=e[n];if(i.isSubForm){const s=[];let u=n+1;for(;u<e.length&&e[u].isFieldInSubForm&&e[u].parentFormName===i.fieldName;)s.push(e[u]),u++;t.push({kind:"subform",parent:i,children:s}),n=u}else t.push({kind:"field",field:i}),n++}return t}const Ca="flex items-center px-1.5 py-2.5 text-xs leading-normal";function D_({field:e,isSubFormChild:t=!1}){return b.jsxs("div",{className:"flex items-center w-full",children:[b.jsxs("div",{className:Fe(Ca,"w-20 shrink-0 min-h-[34px]"),children:[t&&b.jsx("span",{className:"inline-flex items-center justify-center shrink-0 w-5 h-5 opacity-0",children:b.jsx(d9,{})}),b.jsx("span",{children:e.fieldName})]}),b.jsx("div",{className:Fe(Ca,"w-[72px] shrink-0 min-h-[34px]"),children:e.type}),b.jsx("div",{className:Fe(Ca,"w-9 shrink-0 min-h-[34px]"),children:e.required?"是":"否"}),b.jsx("div",{className:Fe(Ca,"flex-1 min-w-0 min-h-[34px]"),children:b.jsx("span",{className:"break-words min-w-0",children:e.description})})]})}function bJ({parent:e,children:t}){const[n,i]=A.useState(!0),s=A.useCallback(()=>i(u=>!u),[]);return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center w-full",children:[b.jsxs("div",{className:Fe(Ca,"w-20 shrink-0 min-h-[34px]"),children:[b.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center justify-center shrink-0 w-5 h-5 rounded cursor-pointer text-[#666] relative -left-[2px]",children:b.jsx(d9,{isOpen:n})}),b.jsx("span",{children:e.fieldName})]}),b.jsx("div",{className:Fe(Ca,"w-[72px] shrink-0 min-h-[34px] "),children:e.type}),b.jsx("div",{className:Fe(Ca,"w-9 shrink-0 min-h-[34px]"),children:e.required?"是":"否"}),b.jsx("div",{className:Fe(Ca,"flex-1 min-w-0 min-h-[34px]"),children:b.jsx("span",{className:"break-words min-w-0",children:e.description})})]}),n&&t.map((u,f)=>b.jsx(D_,{field:u,isSubFormChild:!0},f))]})}function CJ({fields:e}){const t=A.useMemo(()=>wJ(e),[e]);return b.jsxs("div",{className:"flex flex-col items-start w-full bg-white rounded-[10px] overflow-hidden text-black my-[10px] border border-[#E0E0E0]",children:[b.jsxs("div",{className:"flex items-center w-full shrink-0 bg-[#E5E6EB] rounded-t-[10px] border-b border-[#E0E0E0]",children:[b.jsx("div",{className:Fe(Ca,"w-20 shrink-0 h-[34px] font-bold"),children:"名称"}),b.jsx("div",{className:Fe(Ca,"w-[72px] shrink-0 h-[34px] font-bold"),children:"类型"}),b.jsx("div",{className:Fe(Ca,"w-9 shrink-0 h-[34px] font-bold justify-center"),children:"必填"}),b.jsx("div",{className:Fe(Ca,"flex-1 min-w-0 h-[34px] font-bold"),children:"说明"})]}),b.jsx("div",{className:"flex flex-col items-start w-full",children:t.map((n,i)=>n.kind==="field"?b.jsx(D_,{field:n.field},i):b.jsx(bJ,{parent:n.parent,children:n.children},i))})]})}function SJ(e){const t=e.trim(),n=t.match(/字段清单[::]\s*/),i=t.match(/设计说明[::]\s*/),s=t.match(/【确认搭建[::][^】]*】\s*$/),u=n?n.index:-1,f=i?i.index:-1,d=s?s.index:t.length;let m="",v="",y="";if(u!==-1?m=t.substring(0,u):m=t,m=m.replace(/^待搭建表单信息\s*/,"").trim(),u!==-1){const x=u+n[0].length,k=f!==-1?f:s?d:t.length;v=t.substring(x,k).trim()}if(f!==-1){const x=f+i[0].length,k=s?d:t.length;y=t.substring(x,k).trim()}return{formInfo:m,fieldsListInfo:v,designDescInfo:y}}const kJ=({designMarkdown:e,id:t,children:n})=>{if(!e)return null;const i=SJ(e),s=N_(i.fieldsListInfo);return b.jsxs(tf,{className:Fe("text-[14px]",{"bg-transparent px-0 py-0 text-left":!0}),"data-testid":"message-content",children:[b.jsxs(o1,{title:"表单设计",icon:b.jsx(c9,{}),defaultOpen:!0,children:[b.jsx("article",{className:"prose",style:{fontSize:14},children:b.jsx(jh,{id:t+"pre",content:s9(i.formInfo)})}),s.length?b.jsx(CJ,{fields:s}):null,b.jsx("article",{className:"prose",style:{fontSize:14},children:b.jsx(jh,{id:t+"suff",content:s9(i.designDescInfo)})})]}),n]})},ry=({size:e=36,code:t,style:n})=>{const i=e*.238,s=e*.6875;return b.jsx("div",{className:"relative flex items-center justify-center bg-[#0265ff] flex-shrink-0 text-white",style:{width:e,height:e,borderRadius:i,fontSize:s,...n},children:b.jsx(ph,{code:t||fh[0].code,style:{fontSize:s}})})},EJ=A.memo(({name:e,onNameChange:t,onMount:n,selectedIcon:i=fh[0],iconOptions:s=[],onIconChange:u,readonly:f,onConfirm:d,expanded:m,onExpandedChange:v,className:y})=>{const[x,k]=A.useState(!1),[S,L]=A.useState(!1),T=m!=null?m:x,M=Z=>{k(Z),v==null||v(Z)},[j,F]=A.useState(e),[P,z]=A.useState(i);return A.useEffect(()=>{n==null||n()},[]),!T||f?b.jsxs("div",{className:Fe("bg-white hover:bg-[#fafafa] border border-[#e0e0e0] rounded-[10px] px-[10px] py-0 flex items-center justify-between h-[56px] cursor-pointer",Fr,y,"duration-100"),onClick:()=>{f||M(!0)},children:[b.jsxs("div",{className:"flex items-center gap-[10px] min-w-0 flex-1 mr-[10px]",children:[b.jsx(ry,{size:36,code:P==null?void 0:P.code}),b.jsx("p",{className:"text-[14px] text-black leading-normal truncate",children:j})]}),b.jsx("button",{onClick:()=>{f||M(!0)},className:Fe("w-[16px] h-[16px] flex items-center justify-center cursor-pointer hover:text-[#0265ff]",Fr,{"pointer-events-none opacity-0":f}),children:b.jsx(qb,{})})]}):b.jsxs("div",{className:Fe("bg-[#fafafa] border border-[#e0e0e0] rounded-[10px] p-[12px] flex flex-col gap-[22px]",Fr,y,"duration-100"),children:[b.jsxs("div",{className:"flex flex-col gap-[10px] w-full",children:[b.jsx("p",{className:"text-[14px] text-[#030303] font-bold leading-normal",children:"名称"}),b.jsx("input",{type:"text",value:j,onChange:Z=>{F(Z.target.value)},onBlur:()=>{t==null||t(j)},className:Fe("bg-white border border-[#e0e0e0] rounded-[4px] h-[34px] px-[10px] py-[7px] w-full","text-[14px] text-[#030303] leading-normal outline-none","focus:border-[#0265ff]","hover:border-[#0265ff]",Fr)})]}),b.jsxs("div",{className:"flex flex-col gap-[10px] w-full",children:[b.jsx("p",{className:"text-[14px] text-[#030303] font-bold leading-normal",children:"图标"}),b.jsxs("div",{className:"relative",style:{zIndex:10},children:[b.jsxs("button",{onClick:()=>L(!S),className:Fe("bg-white border border-[#e0e0e0] rounded-[4px] h-[34px] px-[10px] py-[7px] w-full","flex items-center justify-between cursor-pointer","hover:border-[#0265ff]",Fr),children:[b.jsx("div",{className:"flex items-center",children:b.jsx(ry,{size:16,code:P==null?void 0:P.code})}),b.jsx("div",{className:Fe("text-[#666]",Fr,S&&"rotate-180"),children:b.jsx(JY,{size:16})})]}),S&&s.length>0&&b.jsx("div",{className:Fe("absolute top-full left-0 mt-[4px] bg-white rounded-[10px] shadow-md z-10 p-[12px]",Fr),children:b.jsx("div",{className:"grid grid-cols-6 gap-[8px]",children:s.map(Z=>b.jsx("button",{onClick:()=>{u==null||u(Z),z(Z),L(!1)},className:Fe("aspect-square rounded-[9.5px] border flex items-center justify-center cursor-pointer overflow-hidden",(P==null?void 0:P.id)===Z.id?"border-[#0265ff] border-2":"border-[#e0e0e0] hover:bg-[#eff0f6]",Fr),title:Z.label,children:b.jsx(ry,{code:Z.code,style:{background:"transparent",color:"#0265ff"}})},Z.id))})})]})]}),b.jsx(df,{text:"确认",onClick:()=>{d==null||d(j,(P==null?void 0:P.value)||25),M(!1)}})]})},(e,t)=>{var n,i;return e.name===t.name&&((n=e.selectedIcon)==null?void 0:n.id)===((i=t.selectedIcon)==null?void 0:i.id)&&e.expanded===t.expanded&&e.iconOptions===t.iconOptions}),_J=A.memo(({designDoc:e,sendMessage:t})=>{var T,M;const n=uf(Pl),i=rs(Pl),[s,u]=A.useState(!1),[f,d]=A.useState(!1),[m,v]=A.useState(!1),y=Ki(),x=A.useRef(null);C2(ea.CREATE_FORM_SUCCESS,j=>{const F=j;n==null||n.onFormCreate(F),d(!0),x.current=F}),C2(ea.CREATE_FORM_FAILED,j=>{v(!0)}),A.useEffect(()=>{x.current&&y.emit("form-builder-FieldsCreatedFinish",x.current)},[]);const k=dJ(e),S=m?b.jsx(Xk,{message:"表单创建失败"}):b.jsx(Qd,{children:"创建中"}),L=b.jsx(Wu,{children:f?b.jsxs(b.Fragment,{children:[b.jsxs("span",{className:"text-[#4d609f]",children:["已为你创建",k.formName]}),b.jsx(EJ,{selectedIcon:Nz((M=(T=n.getCurrentWorkingForm())==null?void 0:T.iconValue)!=null?M:i==null?void 0:i.pickedIconValue),onConfirm:(j,F)=>{x.current&&(x.current.formName=j,x.current.formIcon=F,y.emit(ea.UPDATE_FORM_INFO,x.current))},onNameChange:j=>{x.current&&(x.current.formName=j,y.emit(ea.UPDATE_FORM_INFO,x.current))},onIconChange:j=>{x.current&&(x.current.formIcon=j.value,y.emit(ea.UPDATE_FORM_INFO,x.current))},name:k.formName,iconOptions:fh,className:"w-full",onMount:()=>{setTimeout(()=>{var j;t({text:""},{body:{stage:"build",name:(j=n.getCurrentWorkingForm())==null?void 0:j.formName}})},500)}})]}):S});return b.jsxs(b.Fragment,{children:[b.jsx(df,{disabled:s,prefixDesc:`确认搭建:${k.formName}`,onClick:()=>{n==null||n.onBeforeFormCreate(k),y.emit("form-builder-FormCreateConfirmed",{name:k.formName}),u(!0)}}),s?null:`如果您希望“${k.formName}”更具体地应用于某个行业(如教育、金融)、某种视图类型(如仪表盘视图、报表视图)或特定的权限管理策略,请补充说明,我可以帮您进一步细化字段设计和关联管理。`,s?L:null]})},(e,t)=>e.designDoc===t.designDoc),RJ={fields:oJ,followup:lJ,followup_prefix:sJ,design_doc:e=>{var s;const{part:t,sendMessage:n}=e,i=(s=t.text)==null?void 0:s.includes("【确认搭建");return b.jsx(kJ,{designMarkdown:t.text,id:e.id,children:i?b.jsx(_J,{sendMessage:n,designDoc:t.text}):null})},markdown:i1,unknown:i1},TJ=e=>{const{part:t}=e,n=t,i=uJ(n),s=RJ[i]||i1,u=DX();return b.jsx(s,{...e,part:n,confirmed:u})},LJ={countDistinct:"去重计数",count:"计数",sum:"求和",max:"最大值",min:"最小值",average:"平均"};var h1;(function(e){e.NONE="none",e.SHALLOW="shallow",e.DEEP="deep"})(h1||(h1={}));class oy{constructor(t){this.Context=t}}class AJ extends oy{constructor(){super(...arguments);ze(this,"pluginName","base-form-builder-plugin");ze(this,"publicMethods",{dispatchCreateFormEvent:n=>{const i=new CustomEvent(ea.CREATE_FORM,{detail:{name:n}});return dispatchEvent(i),i},dispatchSaveFieldsEvent:()=>{const n=new CustomEvent(ea.SAVE_FIELDS);return dispatchEvent(n),n},dispatchFieldCreatedEvt:n=>{const i=new CustomEvent(ea.FIELD_CREATED,{detail:{field:n,checked:!0}});return dispatchEvent(i),i},dispatchFieldCheckUpdateEvt:(n,i)=>{const s=new CustomEvent(ea.FIELD_CHECK_UPDATE,{detail:{field:n,checked:i}});return dispatchEvent(s),s},dispatchCreateRleatedFormsEvent:n=>{const i=new CustomEvent(ea.CREATE_RELATED_FORMS,{detail:{fields:n}});return dispatchEvent(i),i}})}}const NJ=({style:e,chatStatus:t,chatVisible:n,onClick:i,variant:s,client:u})=>{const f=uf(Pl),d=t==="dock";return s==="build-fields"?b.jsx(pf,{icon:b.jsx(f9,{}),onClick:()=>{i==null||i();const m=f==null?void 0:f.getCurrentWorkingForm();m&&u.eventBus.emit("send-ghost-msg",{text:`确认搭建:${m.formName}`,options:{body:{stage:"build"}}})},children:"AI生成字段"}):b.jsx(S2,{style:e,minimal:d,onClick:i,children:"AI表单搭建"})},MJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("rounded-xl border bg-card text-card-foreground shadow",e),...t}));MJ.displayName="Card";const OJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("flex flex-col space-y-1.5 p-6",e),...t}));OJ.displayName="CardHeader";const DJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("font-semibold leading-none tracking-tight",e),...t}));DJ.displayName="CardTitle";const jJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("text-sm text-muted-foreground",e),...t}));jJ.displayName="CardDescription";const FJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("p-6 pt-0",e),...t}));FJ.displayName="CardContent";const IJ=A.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:Fe("flex items-center p-6 pt-0",e),...t}));IJ.displayName="CardFooter";const PJ=({title:e,desc:t,index:n,icon:i,onClick:s,iconCode:u})=>b.jsxs("div",{className:Fe("bs-card group flex flex-col cursor-pointer p-2.5 gap-2.5 rounded-lg bg-[#F5F7FA] max-w-[350px] border border-transparent hover:border-[#e0e0e0] hover:bg-white",{transCls:Fr}),onClick:()=>{s==null||s(e,u)},children:[b.jsxs("div",{className:"px-2.5 flex items-center gap-1.5 rounded-[4px] h-[34px] bg-white",children:[n===void 0?null:b.jsx("div",{children:n}),i===void 0?null:b.jsx("div",{className:"text-[#0265FF]",children:i}),b.jsx("div",{className:"truncate !text-[#12111] group-hover:text-[#0265FF]",children:e})]}),b.jsx("div",{className:"text-[#666] leading-5 text-[12px]",children:t})]}),zJ=[{icon:b.jsx(Zb,{}),iconCode:"&#xe814;",title:"供应商管理,子表单为产品信息",description:"用于记录和管理企业供应商的基本信息、资质认证、合作状态等,便于采购部门进行供应商评估和选择。"},{icon:b.jsx(Wb,{}),iconCode:"&#xe806;",title:"搭建订单表",description:"子表单为商品列表(包含:商品ID、商品名称、商品供应商为关联数据字段、商品原价、商品销售价、商品型号为关联查询字段)"},{icon:b.jsx(Gb,{}),iconCode:"&#xe81d;",title:"创建合同表关联供应商信息管理表",description:"创建合同表用于记录与供应商签订的合同信息,并与供应商信息管理表进行关联,方便查询和管理合同相关的供应商信息。"}],j_=({items:e=zJ,iconColor:t,onSelect:n})=>b.jsx(b.Fragment,{children:e.map((i,s)=>b.jsx(PJ,{icon:b.jsx("div",{style:{color:t},children:i.icon}),iconCode:i.iconCode,index:s+1,title:i.title,desc:i.description,onClick:n},s))}),HJ=({sendMessage:e,setMessages:t})=>{const n=rs(Pl);return b.jsxs(b.Fragment,{children:["👋 你好,你想创建什么表单呢,不知道的话,可以试试下面的建议~",b.jsx(j_,{onSelect:(i,s)=>{n&&(n.pickedIconValue=u9(s)),e({text:i},{body:{stage:"design",name:i}})}})]})};class F_ extends AJ{constructor(n){super(n);ze(this,"pluginName",Pl);ze(this,"init",n=>{this._chatInstance=n});ze(this,"_chatInstance",null);ze(this,"currentWorkingFormName","");ze(this,"customComponents",{MessagePart:TJ,EntryButton:NJ,OpeningLines:HJ});ze(this,"clearCurrentWorkingForm",()=>{var s;if(this.Context.workStage!=="build"||!this.getCurrentWorkingForm())return;const i=(s=this._chatInstance)==null?void 0:s.eventBus;i&&i.emit(ea.FIELDS_CLEARED,{})});ze(this,"lifecycleHooks",{onBeforeMessagesClear:n=>{this.clearHistoryConversation(n||"",this._chatInstance||void 0),this.Context.workStage="design"},onBeforeMessagePartsRender(n){return l9(n,dh)},onBeforeMessageSend:({text:n})=>{var i;return this.clearCurrentWorkingForm(),{text:n,options:{body:{stage:this.Context.workStage,name:((i=this.getCurrentWorkingForm())==null?void 0:i.formName)||n,text:n}}}},onAfterChatAreaHide:({clearMsgs:n})=>{n(),this.clearCurrentWorkingForm(),this.Context={formMap:new Map,workStage:"design"}},onBeforeChatRender:()=>({appendLoadingIndicator:!0,placeholder:"描述你的需求,如:搭建一张供应商管理表",acceptAttachmentFileType:[".csv","text/csv","text/plain",".txt","image/*",".xls",".xlsx"]})});ze(this,"dispose",()=>{this.removeEventListeners()});ze(this,"clearHistoryConversation",async(n,i)=>{const s=i==null?void 0:i.options.backendApiEndpoint;if(!s){console.error("Backend API endpoint is not defined in SDK options.");return}if(!n){console.error("Conversation ID is required to clear history.");return}await fetch(`${_0(s)}form/conversation/clear`,{method:"POST",body:JSON.stringify({conversationId:n})})});ze(this,"skipDesignToBuildFields",n=>{this.onBeforeFormCreate({formName:n.formName,linkInfoMap:new Map}),this.onFormCreate(n)});ze(this,"onBeforeFormCreate",n=>{const i=n.formName||"Unnamed Form";console.log("表单设计信息提取完毕,结构化数据如下:",n),this.Context.formMap.get(i)||this.Context.formMap.set(i,{designInfo:n,fields:[],iconValue:this.getPickedIconValue(),fieldMap:new Map,formName:i}),this.currentWorkingFormName=i});ze(this,"onFormCreate",n=>{const i=this.Context.formMap.get(n.formName);if(!i){console.log("未找到已有表单,放弃更新信息");return}i.formId=n.formId,i.appId=n.appId,this.resetPickedIconValue(),this.Context.workStage="build"});ze(this,"getPickedIconValue",()=>this.Context.pickedIconValue);ze(this,"resetPickedIconValue",()=>{this.Context.pickedIconValue=33});ze(this,"onAfterFieldsSave",n=>{const i=this.getCurrentWorkingForm();i&&yJ(this.Context.formMap,{isTargetForm:(s,u)=>s===i.formName?!1:vJ(u.designInfo)?!0:(console.log("关联信息为空,不处理"),!1),isTargetField:(s,u)=>Bh(u.targetFormName)===Bh(i.formName),fieldProcessor:(s,u,f)=>{var y;if(!u){console.log("[fieldProcessor] 字段信息不存在,跳过处理");return}const d=(y=u.widget)==null?void 0:y.type;if(!ny[d]){console.log(`[fieldProcessor] 未找到${d}类型的处理器,跳过处理`);return}const m=ny[d];return m(this.Context.formMap)(s,u,f)},onFormProcessed:n})});this.addEventListeners()}onAfterFieldCreate(n){var s;const i=this.Context.formMap.get(this.currentWorkingFormName);i&&(i.fieldMap.has(n.label)||(i.fields.push(n),i.fieldMap.set(n.label,n)),pJ(n)&&n.widget.items.forEach(u=>{i.fieldMap.set(u.label,u)}),hf(n,"dataload")&&i.designInfo.linkInfoMap.set(n.label,{fieldName:n.label,targetFormName:((s=n.widget.loaddataconfig)==null?void 0:s.forms)||""}))}enhanceField(n){const i=ny[n.widget.type];if(!i)return n;const s=this.Context.formMap.get(this.currentWorkingFormName);if(!s)return n;const u=i(this.Context.formMap),f=s.designInfo.linkInfoMap.get(n.label);return f?(console.log("识别到表单中有关联字段,尝试补全关联信息"),u(s,n,f)):n}onBeforeFieldCreate(n){return hf(n,"subform")?(!n.widget.items||n.widget.items.length===0||(n.widget.items=n.widget.items.map(i=>this.enhanceField(i))),n):this.enhanceField(n)}getCurrentWorkingForm(){return this.Context.formMap.get(this.currentWorkingFormName)}addEventListeners(){}removeEventListeners(){}}const UJ={EVENTS:ea,Plugin:F_,createContext:()=>({formMap:new Map,workStage:"design"})},BJ=({sendMessage:e})=>{const t=rs(Qu),n=sf(),i=Ki();if((t==null?void 0:t.fillMode)==="batch"){const s=Array.from((t==null?void 0:t.fieldMap.values())||[]);return b.jsxs(b.Fragment,{children:["需要测试数据?试试AI示例数据功能。如果您对添加的数据有具体要求也可以告诉我。",b.jsx(df,{light:!0,onClick:()=>{i.emit("form-filling-batch-fill-begin",{}),n==null||n.setGlobalFakeLoadingMessage("正在处理"),e({text:`添加 ${ff} 条示例数据`},{body:{stage:"fill",formStructure:S_(s),mode:t==null?void 0:t.fillMode,count:ff}})},text:"直接添加"})]})}return b.jsx(b.Fragment,{children:"我可以为您解析文本内容,智能填写到表单字段,请方输入内容开始创建"})},VJ=(e,t)=>{A.useEffect(()=>{e&&t&&(e.conversationId=t)},[e,t])},$J=e=>Array.isArray(e)&&e.length>0?e:dh(e)?[e]:[],ZJ=(e,t)=>e.length>0&&t!==null&&t.fillMode!=="batch",WJ=(e,t,n)=>{var f,d;const i=$b(e);if(!i)return null;if(!(((f=t.fieldMap)==null?void 0:f.has(i.fieldName))||((d=t.subFieldsNameMap)==null?void 0:d.has(i.fieldName))))return console.warn("[useFieldsData] Unregistered field skipped:",i.fieldName),null;const u=b_(i.value);return{field:{label:i.label,widget:{widgetName:i.fieldName,type:i.fieldType,value:i.value}},onLoaded:m=>{var v;m.widget.value=u,t.valueMap.set((v=m.widget)==null?void 0:v.widgetName,u),n.emit(ri.FIELD_FILLED_UPDATE,{field:m,checked:!0})},onChange:(m,v,y,x)=>{var k;m&&t.valueMap.set((k=v.widget)==null?void 0:k.widgetName,u),n.emit(ri.FIELD_FILLED_UPDATE,{field:v,checked:m,parentFieldName:y,rowIndex:x})}}},GJ=(e,t)=>{const n=Ki(),i=A.useMemo(()=>$J(e),[e]),s=A.useMemo(()=>ZJ(i,t),[i,t]),u=A.useMemo(()=>!s||!t?[]:i.map(f=>WJ(f,t,n)).filter(f=>f!==null),[i,t,n,s]);return A.useMemo(()=>({fieldsParts:i,fieldPropsArray:u,filledFields:u.filter(Boolean)}),[i,u])},qJ=({defaultChecked:e=!1,checked:t,onCheckedChange:n,children:i,disabled:s=!1,className:u})=>{const[f,d]=A.useState(e),m=t!==void 0,v=m?t:f,y=()=>{if(s)return;const x=!v;m||d(x),n==null||n(x)};return b.jsxs("button",{type:"button",role:"checkbox","aria-checked":v,disabled:s,onClick:y,className:Fe("inline-flex items-center gap-[6px] cursor-pointer select-none","text-[#121111] text-[14px]",s&&"cursor-not-allowed opacity-50",u),children:[b.jsx("span",{className:Fe("inline-flex items-center justify-center w-4 h-4 rounded-full transition-colors duration-200 box-border border",v?"bg-[#2E60FF] border-transparent":"bg-white border-[#e0e0e0]"),children:v&&b.jsx("span",{className:"text-white",children:b.jsx(Jb,{})})}),i&&b.jsx("span",{className:"text-sm",children:i})]})},YJ=({count:e,handleCheckChange:t})=>b.jsx("div",{className:"flex items-center w-full py-[10px] px-[16px] gap-[6px]",children:b.jsxs(qJ,{defaultChecked:!0,onCheckedChange:t,children:["已生成",e,"条数据"]})}),XJ=`linear-gradient(90deg,
513
513
  rgba(132, 180, 255, 0) 0%,
514
514
  rgba(132, 180, 255, 0.5) 10%,
@@ -584,5 +584,5 @@ ${k}
584
584
 
585
585
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
586
586
 
587
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return A.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},OK="DialogDescriptionWarning",DK=({contentRef:e,descriptionId:t})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${LR(OK).contentName}}.`;return A.useEffect(()=>{var u;const s=(u=e.current)==null?void 0:u.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(i))},[i,e,t]),null},jK=vR,FK=wR,AR=bR,NR=CR,MR=kR,OR=_R;const IK=jK,PK=FK,DR=A.forwardRef(({className:e,position:t="fixed",...n},i)=>b.jsx(AR,{ref:i,className:Fe("inset-0 z-50 bg-black/30 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t==="absolute"?"absolute":"fixed",e),...n}));DR.displayName=AR.displayName;const jR=A.forwardRef(({className:e,children:t,container:n,...i},s)=>b.jsxs(PK,{container:n,children:[b.jsx(DR,{position:n?"absolute":"fixed"}),b.jsx(NR,{style:{padding:0},ref:s,className:Fe("left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",n?"absolute":"fixed",e),...i,children:t})]}));jR.displayName=NR.displayName;const FR=({className:e,...t})=>b.jsx("div",{className:Fe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});FR.displayName="DialogHeader";const IR=({className:e,...t})=>b.jsx("div",{className:Fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});IR.displayName="DialogFooter";const PR=A.forwardRef(({className:e,...t},n)=>b.jsx(MR,{ref:n,className:Fe("text-lg font-semibold leading-none tracking-tight",e),...t}));PR.displayName=MR.displayName;const zR=A.forwardRef(({className:e,...t},n)=>b.jsx(OR,{ref:n,className:Fe("text-sm text-muted-foreground",e),...t}));zR.displayName=OR.displayName;function zK({open:e,onOpenChange:t,title:n,description:i,linkText:s="留在此页",onLinkClick:u,cancelText:f="不保存",onCancel:d,confirmText:m="保存并继续",onConfirm:v,container:y,showLink:x=!0,showCancel:k=!0}){const S={borderRadius:4,padding:"6px 20px"};return b.jsx(IK,{open:e,onOpenChange:t,children:b.jsxs(jR,{container:y,className:Fe("w-[480px] max-w-[480px] p-0 gap-0 rounded-[10px] border-none","shadow-[0px_0px_10px_0px_rgba(0,0,0,0.04)]","[&>button]:hidden"),children:[b.jsxs(FR,{className:"flex flex-row items-start gap-[10px] p-9 pb-0",children:[b.jsx("div",{className:"size-[30px] shrink-0 text-[#0265FF]",children:b.jsx(Vz,{})}),b.jsxs("div",{className:"flex flex-col gap-2",children:[b.jsx(PR,{className:"text-[16px] font-[700] text-[#030303] leading-normal",children:n}),i&&b.jsx(zR,{className:"text-[14px] text-[#666] leading-normal",children:i})]})]}),b.jsxs(IR,{className:"flex flex-row items-center !justify-between p-9 pt-6",children:[x?b.jsx("button",{type:"button",className:"text-[14px] text-[#0265ff] hover:text-[#0265ff]/80 bg-transparent border-none cursor-pointer",children:s}):b.jsx("div",{}),b.jsxs("div",{className:"flex items-center gap-3",children:[k&&b.jsx(pf,{className:"hover:text-[#121111]",onClick:d,children:f}),b.jsx("button",{type:"button",onClick:v,style:S,className:Fe("text-[14px] text-white bg-[#0265ff]","hover:bg-[#0265ff]/80 cursor-pointer border-none"),children:m})]})]})]})})}function HK({className:e,...t}){return b.jsx(tE,{role:"status","aria-label":"Loading",className:Fe("size-4 animate-spin",e),...t})}const UK=({title:e,tips:t,style:n,confirmContent:i,confirmTitle:s,className:u,active:f,onBackClick:d,onSave:m,closeBtnLabel:v,onCancel:y,onClear:x,variant:k="fields-previewer",dialogContainer:S,disableConfirm:L,disableOperation:T})=>{const[M,j]=A.useState(!1),[F,P]=A.useState(!1),z=Wr("w-[94px] h-[34px] flex items-center justify-center rounded-[4px]"),Z=k==="data-previewer",$=k==="fields-previewer",G=Wr("font-[700]",{"text-[16px]":$,"text-[18px]":Z}),Y=b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center gap-3",children:[Z?null:b.jsx(ef,{icon:b.jsx(Wz,{}),onClick:()=>{if(L){y==null||y(),d==null||d();return}j(!0)},className:"text-[#0265FF] hover:text-[#0265FF]"}),b.jsx("span",{className:G,children:e}),t&&f&&b.jsxs("div",{className:"flex items-center gap-[6px] text-[#999999] text-[12px]",children:[b.jsx($z,{}),t]})]}),b.jsxs("div",{className:"flex items-center gap-[10px]",children:[x&&b.jsx(pf,{className:Fe("w-[34px] h-[34px] text-[#8d8d8d] p-0 flex items-center justify-center hover:border-[#e0e0e0] hover:text-[#8d8d8d] border border-solid border-[#e0e0e0] ",{"pointer-events-none opacity-50":T||F}),tooltip:"清除全部",icon:b.jsx(nH,{}),onClick:()=>{x==null||x()}}),m&&b.jsxs("button",{onClick:async()=>{P(!0);try{await m()}catch(le){console.error("Save failed:",le)}finally{P(!1)}},className:Wr(z,"flex items-center gap-[6px]","bg-[#0265FF] hover:opacity-90 text-white text-[14px]",{"w-[115px]":Z,"pointer-events-none opacity-50":T||F}),children:[F?b.jsx(HK,{}):null,$?"保存":"添加到表单"]}),y&&b.jsx("button",{onClick:()=>{if(L){y==null||y(),d==null||d();return}j(!0)},className:Wr(z,"text-[#121111] text-[14px] bg-[#fff] border border-solid border-[#e0e0e0] hover:bg-[#f0f0f0]",{"pointer-events-none opacity-50":F}),children:v||"取消"})]}),b.jsx(zK,{container:S,open:M,onOpenChange:j,title:s||"AI表单搭建有修改,是否保存?",description:i||"您修改了AI表单搭建但没有保存,是否需要保存并继续?",onLinkClick:()=>j(!1),onCancel:()=>{j(!1),y==null||y(),d==null||d()},onConfirm:async()=>{j(!1),P(!0);try{await(m==null?void 0:m(!0))}catch(le){console.error("Save failed:",le)}finally{P(!1)}}})]}),me=Wr({"border-b border-solid border-[#e0e0e0]":!f&&$,"border-none":Z});if(f)return b.jsx(SK,{height:52,style:n,childrenContainerStyle:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 20px"},children:Y});const ce=Wr({"px-[20px]":$,"px-[10px]":Z});return b.jsx("div",{style:n,className:Wr("w-full h-[52px] flex items-center justify-between",ce,u,me),children:Y})},BK=()=>b.jsx("div",{style:{borderRadius:10,width:"100%",height:"100%",border:"1px dashed var(---e0e0e0, #E0E0E0)"}}),VK=A.forwardRef(({zIndex:e=1,children:t,title:n,tips:i,active:s,fullscreen:u,padding:f=10,className:d,empty:m,rightSpaceWidth:v,rightSpaceRef:y,rightElement:x,streaming:k,streamingText:S,onBackClick:L,dialogContainer:T,variant:M="fields-previewer",onSave:j,onCancel:F,onClear:P,style:z,confirmContent:Z,fullContent:$,confirmTitle:G,containerStyle:Y,readonly:me,closeBtnLabel:ce,disableOperation:le,disableConfirm:se})=>{const ve=u?0:f,_e=u?0:v,[ke,Ae]=A.useState(null),we=M==="fields-previewer",K=M==="data-previewer",Me=Wr({"m-[20px]":we,"mx-[12px] mb-[10px]":K,"p-[10px]":we,"p-0":K,"opacity-60":k&&we,"w-[calc(100%-40px)] h-[calc(100%-90px)] relative overflow-x-hidden overflow-y-auto":we,"w-[calc(100%-24px)] h-[calc(100%-62px)] relative overflow-x-hidden overflow-y-auto":K,"rounded-[4px] bg-white":K}),U=$?{width:"100%",height:"100%",padding:0,margin:0}:{},{shadowContainer:J}=k2({id:"dialog-container",rootEl:T,style:Y,wrapperStyle:{zIndex:Date.now(),position:"absolute",width:"100%",height:"100%",pointerEvents:"none"}}),he=b.jsxs(b.Fragment,{children:[b.jsx(UK,{title:n,tips:i,active:s,variant:M,className:d,onBackClick:L,onSave:k?void 0:j,onCancel:k?void 0:F,style:z,dialogContainer:J||ke,confirmTitle:G,confirmContent:Z,closeBtnLabel:ce,disableOperation:le,disableConfirm:se,onClear:P}),b.jsxs("div",{className:Me,style:U,children:[m&&we?b.jsx(BK,{}):t,me&&b.jsx("div",{className:"absolute inset-0 z-50 cursor-not-allowed"})]}),k&&b.jsx("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2",children:b.jsx(CK,{children:S})})]}),B=we?b.jsx(mR,{width:_e?`calc(100% - ${_e}px)`:"100%",style:{overflow:"hidden"},children:he}):b.jsx("div",{className:"h-full",style:{width:_e?`calc(100% - ${_e}px)`:"100%"},children:he}),Re=b.jsx("div",{style:{width:u?0:v,position:"absolute",top:0,right:0,pointerEvents:u?"none":"auto"},className:"h-full",ref:We=>{We&&(y==null||y(We))},children:x});return b.jsx(oS,{delayDuration:100,zIndex:e,children:b.jsxs(hR,{zIndex:e,padding:we?ve:0,disableGradient:u||!we,bgColor:we?"#fff":"#F5F7FA",ref:Ae,children:[u?he:B,Re]})})}),$K=()=>A.createElement("slot");class HR extends HTMLElement{constructor(){super();ze(this,"root",null);ze(this,"shadowContainer",null);ze(this,"shadowWrapper",null);ze(this,"_props",{});ze(this,"_childrenOverride",null);ze(this,"_externalRootEl",null)}static get observedAttributes(){return["title","tips","fullscreen","streaming","empty","z-index","padding","right-space-width","active","variant","fields-count"]}connectedCallback(){this._externalRootEl||(this.setupShadowDOM(),this.render())}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.shadowWrapper&&this.shadowWrapper.parentNode&&(this.shadowWrapper.parentNode.removeChild(this.shadowWrapper),this.shadowWrapper=null)}setRootEl(n){this._externalRootEl===n&&!n||(this._externalRootEl=n,this.isConnected&&(this.cleanup(),this.setupShadowDOM(),this.render()))}cleanup(){this.root&&(this.root.unmount(),this.root=null),this.shadowWrapper&&this.shadowWrapper.parentNode&&(this.shadowWrapper.parentNode.removeChild(this.shadowWrapper),this.shadowWrapper=null)}attributeChangedCallback(n,i,s){i!==s&&(this.updatePropsFromAttributes(),this.render())}injectStyles(n){var u;const i=this._externalRootEl?(u=this.shadowWrapper)==null?void 0:u.shadowRoot:this.shadowRoot;if(!i)return;const s=new CSSStyleSheet;s.replaceSync(n),i.adoptedStyleSheets=[...i.adoptedStyleSheets,s],console.log("injected styles into shadow root")}setupShadowDOM(){this._externalRootEl?(this.shadowWrapper=document.createElement("div"),this.shadowWrapper.style.width="100%",this.shadowWrapper.style.height="100%",this._externalRootEl.appendChild(this.shadowWrapper),this.shadowWrapper.attachShadow({mode:"open"})):this.shadowRoot||this.attachShadow({mode:"open"});const n=this._externalRootEl?this.shadowWrapper.shadowRoot:this.shadowRoot;if(!n)return;console.log("found new shadow root:",this._externalRootEl);const i=document.createElement("style");i.textContent=typeof __SDK_STYLES__!="undefined"?__SDK_STYLES__:"",n.appendChild(i),this.shadowContainer=document.createElement("div"),this.shadowContainer.style.width="100%",this.shadowContainer.style.height="100%",n.appendChild(this.shadowContainer),this.root=Q4(this.shadowContainer)}updatePropsFromAttributes(){var s,u,f,d,m,v,y,x,k,S;const n=L=>{const T=this.getAttribute(L);if(T!==null)return T==="true"||T===""},i=L=>{const T=this.getAttribute(L);if(T===null)return;const M=parseFloat(T);return isNaN(M)?void 0:M};this._props={...this._props,title:(s=this.getAttribute("title"))!=null?s:this._props.title,variant:(u=this.getAttribute("variant"))!=null?u:"fields-previewer",tips:(f=this.getAttribute("tips"))!=null?f:this._props.tips,fullscreen:(d=n("fullscreen"))!=null?d:this._props.fullscreen,streaming:(m=n("streaming"))!=null?m:this._props.streaming,empty:(v=n("empty"))!=null?v:this._props.empty,active:(y=n("active"))!=null?y:this._props.active,zIndex:(x=i("z-index"))!=null?x:this._props.zIndex,padding:(k=i("padding"))!=null?k:this._props.padding,rightSpaceWidth:(S=i("right-space-width"))!=null?S:this._props.rightSpaceWidth}}setProps(n){if("children"in n){this._childrenOverride=n.children;const{children:i,...s}=n;this._props={...this._props,...s}}else this._props={...this._props,...n};this.render()}getProps(){return{...this._props}}render(){var s;if(!this.root)return;this.updatePropsFromAttributes();const n=(s=this._childrenOverride)!=null?s:A.createElement($K),i=A.createElement(VK,{...this._props,children:n});this.root.render(i)}}function ZK(e="previewer-container"){customElements.get(e)||customElements.define(e,HR)}typeof window!="undefined"&&ZK(),Zr.ChatSDK=Y5,Zr.FieldsPreviewerWebComponent=HR,Zr.FormBuilderPlugin=F_,Zr.FormBuilderPluginRegisterEntry=UJ,Zr.FormFillingPlugin=iR,Zr.FormFillingPluginRegisterEntry=IQ,Zr.ReportQueryPlugin=pR,Zr.ReportQueryPluginEntry=wK,Object.defineProperty(Zr,Symbol.toStringTag,{value:"Module"})});
587
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return A.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},OK="DialogDescriptionWarning",DK=({contentRef:e,descriptionId:t})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${LR(OK).contentName}}.`;return A.useEffect(()=>{var u;const s=(u=e.current)==null?void 0:u.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(i))},[i,e,t]),null},jK=vR,FK=wR,AR=bR,NR=CR,MR=kR,OR=_R;const IK=jK,PK=FK,DR=A.forwardRef(({className:e,position:t="fixed",...n},i)=>b.jsx(AR,{ref:i,className:Fe("inset-0 z-50 bg-black/30 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t==="absolute"?"absolute":"fixed",e),...n}));DR.displayName=AR.displayName;const jR=A.forwardRef(({className:e,children:t,container:n,...i},s)=>b.jsxs(PK,{container:n,children:[b.jsx(DR,{position:n?"absolute":"fixed"}),b.jsx(NR,{style:{padding:0},ref:s,className:Fe("left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",n?"absolute":"fixed",e),...i,children:t})]}));jR.displayName=NR.displayName;const FR=({className:e,...t})=>b.jsx("div",{className:Fe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});FR.displayName="DialogHeader";const IR=({className:e,...t})=>b.jsx("div",{className:Fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});IR.displayName="DialogFooter";const PR=A.forwardRef(({className:e,...t},n)=>b.jsx(MR,{ref:n,className:Fe("text-lg font-semibold leading-none tracking-tight",e),...t}));PR.displayName=MR.displayName;const zR=A.forwardRef(({className:e,...t},n)=>b.jsx(OR,{ref:n,className:Fe("text-sm text-muted-foreground",e),...t}));zR.displayName=OR.displayName;function zK({open:e,onOpenChange:t,title:n,description:i,linkText:s="留在此页",onLinkClick:u,cancelText:f="不保存",onCancel:d,confirmText:m="保存并继续",onConfirm:v,container:y,showLink:x=!0,showCancel:k=!0}){const S={borderRadius:4,padding:"6px 20px"};return b.jsx(IK,{open:e,onOpenChange:t,children:b.jsxs(jR,{container:y,className:Fe("w-[480px] max-w-[480px] p-0 gap-0 rounded-[10px] border-none","shadow-[0px_0px_10px_0px_rgba(0,0,0,0.04)]","[&>button]:hidden"),children:[b.jsxs(FR,{className:"flex flex-row items-start gap-[10px] p-9 pb-0",children:[b.jsx("div",{className:"size-[30px] shrink-0 text-[#0265FF]",children:b.jsx(Vz,{})}),b.jsxs("div",{className:"flex flex-col gap-2",children:[b.jsx(PR,{className:"text-[16px] font-[700] text-[#030303] leading-normal",children:n}),i&&b.jsx(zR,{className:"text-[14px] text-[#666] leading-normal",children:i})]})]}),b.jsxs(IR,{className:"flex flex-row items-center !justify-between p-9 pt-6",children:[x?b.jsx("button",{type:"button",className:"text-[14px] text-[#0265ff] hover:text-[#0265ff]/80 bg-transparent border-none cursor-pointer",onClick:u||(()=>{console.log("Link clicked"),t==null||t(!1)}),children:s}):b.jsx("div",{}),b.jsxs("div",{className:"flex items-center gap-3",children:[k&&b.jsx(pf,{className:"hover:text-[#121111]",onClick:d,children:f}),b.jsx("button",{type:"button",onClick:v,style:S,className:Fe("text-[14px] text-white bg-[#0265ff]","hover:bg-[#0265ff]/80 cursor-pointer border-none"),children:m})]})]})]})})}function HK({className:e,...t}){return b.jsx(tE,{role:"status","aria-label":"Loading",className:Fe("size-4 animate-spin",e),...t})}const UK=({title:e,tips:t,style:n,confirmContent:i,confirmTitle:s,className:u,active:f,onBackClick:d,onSave:m,closeBtnLabel:v,onCancel:y,onClear:x,variant:k="fields-previewer",dialogContainer:S,disableConfirm:L,disableOperation:T})=>{const[M,j]=A.useState(!1),[F,P]=A.useState(!1),z=Wr("w-[94px] h-[34px] flex items-center justify-center rounded-[4px]"),Z=k==="data-previewer",$=k==="fields-previewer",G=Wr("font-[700]",{"text-[16px]":$,"text-[18px]":Z}),Y=b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center gap-3",children:[Z?null:b.jsx(ef,{icon:b.jsx(Wz,{}),onClick:()=>{if(L){y==null||y(),d==null||d();return}j(!0)},className:"text-[#0265FF] hover:text-[#0265FF]"}),b.jsx("span",{className:G,children:e}),t&&f&&b.jsxs("div",{className:"flex items-center gap-[6px] text-[#999999] text-[12px]",children:[b.jsx($z,{}),t]})]}),b.jsxs("div",{className:"flex items-center gap-[10px]",children:[x&&b.jsx(pf,{className:Fe("w-[34px] h-[34px] text-[#8d8d8d] p-0 flex items-center justify-center hover:border-[#e0e0e0] hover:text-[#8d8d8d] border border-solid border-[#e0e0e0] ",{"pointer-events-none opacity-50":T||F}),tooltip:"清除全部",icon:b.jsx(nH,{}),onClick:()=>{x==null||x()}}),m&&b.jsxs("button",{onClick:async()=>{P(!0);try{await m()}catch(le){console.error("Save failed:",le)}finally{P(!1)}},className:Wr(z,"flex items-center gap-[6px]","bg-[#0265FF] hover:opacity-90 text-white text-[14px]",{"w-[115px]":Z,"pointer-events-none opacity-50":T||F}),children:[F?b.jsx(HK,{}):null,$?"保存":"添加到表单"]}),y&&b.jsx("button",{onClick:()=>{if(L){y==null||y(),d==null||d();return}j(!0)},className:Wr(z,"text-[#121111] text-[14px] bg-[#fff] border border-solid border-[#e0e0e0] hover:bg-[#f0f0f0]",{"pointer-events-none opacity-50":F}),children:v||"取消"})]}),b.jsx(zK,{container:S,open:M,onOpenChange:j,title:s||"AI表单搭建有修改,是否保存?",description:i||"您修改了AI表单搭建但没有保存,是否需要保存并继续?",onLinkClick:()=>j(!1),onCancel:()=>{j(!1),y==null||y(),d==null||d()},onConfirm:async()=>{j(!1),P(!0);try{await(m==null?void 0:m(!0))}catch(le){console.error("Save failed:",le)}finally{P(!1)}}})]}),me=Wr({"border-b border-solid border-[#e0e0e0]":!f&&$,"border-none":Z});if(f)return b.jsx(SK,{height:52,style:n,childrenContainerStyle:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 20px"},children:Y});const ce=Wr({"px-[20px]":$,"px-[10px]":Z});return b.jsx("div",{style:n,className:Wr("w-full h-[52px] flex items-center justify-between",ce,u,me),children:Y})},BK=()=>b.jsx("div",{style:{borderRadius:10,width:"100%",height:"100%",border:"1px dashed var(---e0e0e0, #E0E0E0)"}}),VK=A.forwardRef(({zIndex:e=1,children:t,title:n,tips:i,active:s,fullscreen:u,padding:f=10,className:d,empty:m,rightSpaceWidth:v,rightSpaceRef:y,rightElement:x,streaming:k,streamingText:S,onBackClick:L,dialogContainer:T,variant:M="fields-previewer",onSave:j,onCancel:F,onClear:P,style:z,confirmContent:Z,fullContent:$,confirmTitle:G,containerStyle:Y,readonly:me,closeBtnLabel:ce,disableOperation:le,disableConfirm:se})=>{const ve=u?0:f,_e=u?0:v,[ke,Ae]=A.useState(null),we=M==="fields-previewer",K=M==="data-previewer",Me=Wr({"m-[20px]":we,"mx-[12px] mb-[10px]":K,"p-[10px]":we,"p-0":K,"opacity-60":k&&we,"w-[calc(100%-40px)] h-[calc(100%-90px)] relative overflow-x-hidden overflow-y-auto":we,"w-[calc(100%-24px)] h-[calc(100%-62px)] relative overflow-x-hidden overflow-y-auto":K,"rounded-[4px] bg-white":K}),U=$?{width:"100%",height:"100%",padding:0,margin:0}:{},{shadowContainer:J}=k2({id:"dialog-container",rootEl:T,style:Y,wrapperStyle:{zIndex:Date.now(),position:"absolute",width:"100%",height:"100%",pointerEvents:"none"}}),he=b.jsxs(b.Fragment,{children:[b.jsx(UK,{title:n,tips:i,active:s,variant:M,className:d,onBackClick:L,onSave:k?void 0:j,onCancel:k?void 0:F,style:z,dialogContainer:J||ke,confirmTitle:G,confirmContent:Z,closeBtnLabel:ce,disableOperation:le,disableConfirm:se,onClear:P}),b.jsxs("div",{className:Me,style:U,children:[m&&we?b.jsx(BK,{}):t,me&&b.jsx("div",{className:"absolute inset-0 z-50 cursor-not-allowed"})]}),k&&b.jsx("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2",children:b.jsx(CK,{children:S})})]}),B=we?b.jsx(mR,{width:_e?`calc(100% - ${_e}px)`:"100%",style:{overflow:"hidden"},children:he}):b.jsx("div",{className:"h-full",style:{width:_e?`calc(100% - ${_e}px)`:"100%"},children:he}),Re=b.jsx("div",{style:{width:u?0:v,position:"absolute",top:0,right:0,pointerEvents:u?"none":"auto"},className:"h-full",ref:We=>{We&&(y==null||y(We))},children:x});return b.jsx(oS,{delayDuration:100,zIndex:e,children:b.jsxs(hR,{zIndex:e,padding:we?ve:0,disableGradient:u||!we,bgColor:we?"#fff":"#F5F7FA",ref:Ae,children:[u?he:B,Re]})})}),$K=()=>A.createElement("slot");class HR extends HTMLElement{constructor(){super();ze(this,"root",null);ze(this,"shadowContainer",null);ze(this,"shadowWrapper",null);ze(this,"_props",{});ze(this,"_childrenOverride",null);ze(this,"_externalRootEl",null)}static get observedAttributes(){return["title","tips","fullscreen","streaming","empty","z-index","padding","right-space-width","active","variant","fields-count"]}connectedCallback(){this._externalRootEl||(this.setupShadowDOM(),this.render())}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.shadowWrapper&&this.shadowWrapper.parentNode&&(this.shadowWrapper.parentNode.removeChild(this.shadowWrapper),this.shadowWrapper=null)}setRootEl(n){this._externalRootEl===n&&!n||(this._externalRootEl=n,this.isConnected&&(this.cleanup(),this.setupShadowDOM(),this.render()))}cleanup(){this.root&&(this.root.unmount(),this.root=null),this.shadowWrapper&&this.shadowWrapper.parentNode&&(this.shadowWrapper.parentNode.removeChild(this.shadowWrapper),this.shadowWrapper=null)}attributeChangedCallback(n,i,s){i!==s&&(this.updatePropsFromAttributes(),this.render())}injectStyles(n){var u;const i=this._externalRootEl?(u=this.shadowWrapper)==null?void 0:u.shadowRoot:this.shadowRoot;if(!i)return;const s=new CSSStyleSheet;s.replaceSync(n),i.adoptedStyleSheets=[...i.adoptedStyleSheets,s],console.log("injected styles into shadow root")}setupShadowDOM(){this._externalRootEl?(this.shadowWrapper=document.createElement("div"),this.shadowWrapper.style.width="100%",this.shadowWrapper.style.height="100%",this._externalRootEl.appendChild(this.shadowWrapper),this.shadowWrapper.attachShadow({mode:"open"})):this.shadowRoot||this.attachShadow({mode:"open"});const n=this._externalRootEl?this.shadowWrapper.shadowRoot:this.shadowRoot;if(!n)return;console.log("found new shadow root:",this._externalRootEl);const i=document.createElement("style");i.textContent=typeof __SDK_STYLES__!="undefined"?__SDK_STYLES__:"",n.appendChild(i),this.shadowContainer=document.createElement("div"),this.shadowContainer.style.width="100%",this.shadowContainer.style.height="100%",n.appendChild(this.shadowContainer),this.root=Q4(this.shadowContainer)}updatePropsFromAttributes(){var s,u,f,d,m,v,y,x,k,S;const n=L=>{const T=this.getAttribute(L);if(T!==null)return T==="true"||T===""},i=L=>{const T=this.getAttribute(L);if(T===null)return;const M=parseFloat(T);return isNaN(M)?void 0:M};this._props={...this._props,title:(s=this.getAttribute("title"))!=null?s:this._props.title,variant:(u=this.getAttribute("variant"))!=null?u:"fields-previewer",tips:(f=this.getAttribute("tips"))!=null?f:this._props.tips,fullscreen:(d=n("fullscreen"))!=null?d:this._props.fullscreen,streaming:(m=n("streaming"))!=null?m:this._props.streaming,empty:(v=n("empty"))!=null?v:this._props.empty,active:(y=n("active"))!=null?y:this._props.active,zIndex:(x=i("z-index"))!=null?x:this._props.zIndex,padding:(k=i("padding"))!=null?k:this._props.padding,rightSpaceWidth:(S=i("right-space-width"))!=null?S:this._props.rightSpaceWidth}}setProps(n){if("children"in n){this._childrenOverride=n.children;const{children:i,...s}=n;this._props={...this._props,...s}}else this._props={...this._props,...n};this.render()}getProps(){return{...this._props}}render(){var s;if(!this.root)return;this.updatePropsFromAttributes();const n=(s=this._childrenOverride)!=null?s:A.createElement($K),i=A.createElement(VK,{...this._props,children:n});this.root.render(i)}}function ZK(e="previewer-container"){customElements.get(e)||customElements.define(e,HR)}typeof window!="undefined"&&ZK(),Zr.ChatSDK=Y5,Zr.FieldsPreviewerWebComponent=HR,Zr.FormBuilderPlugin=F_,Zr.FormBuilderPluginRegisterEntry=UJ,Zr.FormFillingPlugin=iR,Zr.FormFillingPluginRegisterEntry=IQ,Zr.ReportQueryPlugin=pR,Zr.ReportQueryPluginEntry=wK,Object.defineProperty(Zr,Symbol.toStringTag,{value:"Module"})});
588
588
  //# sourceMappingURL=chat-sdk.umd.cjs.map