!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d40641ff-687c-4418-8176-e2eea4e305e2",e._sentryDebugIdIdentifier="sentry-dbid-d40641ff-687c-4418-8176-e2eea4e305e2")}catch(e){}}();var _global="undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{};_global.SENTRY_RELEASE={id:"30b1ba65cc8722be7e184f4a401fb43e6b21634d"},(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[7332],{47332:(e,t,a)=>{a.r(t),a.d(t,{Dropdown:()=>j,default:()=>R});a(62953);var d=a(96540),o=a(8711),r=a(83199),n=a(43375),i=a(61360);var s=a(74618),l=a(15327),c=a(35304),u=a(21591),p=a(68980),b=a(28738),m=a(38257);const g=e=>(0,o.keyframes)(["from{border-color:",";border-width:2px;}to{border-color:",";border-width:1px;}"],(0,r.getColor)("primary")(e),(0,r.getColor)("textLite")(e)),h=(0,o.default)(r.Flex).withConfig({displayName:"dropArea__AnimatedFlex",componentId:"sc-vs4sjk-0"})(["animation:",";"],(e=>{let{animate:t}=e;return t?(0,o.css)([""," 0.15s linear infinite"],g):""})),f={},v=(0,d.memo)((e=>{let{item:t=f,itemProps:a=f}=e;const{id:o,name:i,isNew:s}=t,{overDashboardId:l}=a,{setNodeRef:c,isOver:u,over:b}=(0,n.zM)({id:o,data:{droppable:!0,dropArea:!0,dashboardId:o,onlyPointerWithin:!0}}),{processing:m,loading:g}=(0,p.fz)(o),v=m||g;return d.createElement(r.Flex,{padding:[2],flex:!0,background:l===o&&"successSemi"},d.createElement(h,{alignItems:"center",justifyContent:"center",padding:[2],border:{side:"all",type:"dashed",color:u?"primary":"textLite"},round:!0,ref:c,width:"100%",height:15,animate:(null===b||void 0===b?void 0:b.id)===o&&l!==o},v?d.createElement(r.Text,{color:"textLite"},"Loading..."):d.createElement(r.TextBig,{color:l===o?"successText":"text"},s?"":d.createElement(d.Fragment,null,"Add in "),d.createElement(r.TextBig,{strong:!0,color:s?"primary":l===o?"successText":"text"},i))))})),w=((0,o.default)(r.Drop).attrs({align:{top:"bottom",left:"left"},animation:!0,backdrop:!0,column:!0,padding:[2,0],background:"dropdown",round:1,overflow:{vertical:"auto"},margin:[.5,0,0],width:30}).withConfig({displayName:"list__Dropdown",componentId:"sc-s8yppy-0"})([""]),(0,d.memo)((e=>{let{dashboards:t,selected:a,setSelected:o,itemProps:n}=e;const i=(0,m.A)();return d.createElement(d.Fragment,null,d.createElement(v,{item:{id:"new",name:"Create a new dashboard",isNew:!0},itemProps:n}),d.createElement(r.MenuDropdown,{items:t,Item:v,value:a,hasSearch:!1,onItemClick:o,hideShadow:!0,itemProps:n,overflow:"hidden",ref:i}))})));var x=a(86008),D=a(3914),y=a(69765),I=a(91517),E=a(47767),A=a(80925),C=a(71835),S=a(79731),k=a(50876),_=a(2025),F=a(67544),L=a(4659),N=a(18202),M=a(54621);const P=e=>{let{onDone:t}=e;const a=(0,E.Zp)(),o=(0,D.vt)(),r=(0,y.ID)(),n=(0,D.ns)(o,"slug"),i=(0,y.wz)(r,"slug"),s=(0,A.e)(),[l,c]=(0,C.A)(),{sendLog:u}=(0,k.A)(),p=(0,M.tV)(),b=(0,_.DH)(null,{onSuccess:e=>{p({title:e.slug,id:e.id,destination:e.slug,type:"dashboards",droppable:!0,droppableProps:{dashboardId:e.id,dropArea:!0}}),l({header:"Added",text:d.createElement(d.Fragment,null,"Chart added in"," ",d.createElement(L.A,{as:"a",strong:!0,onClick:()=>a("/spaces/".concat(n,"/rooms/").concat(i,"/dashboards/").concat(e.slug))},e.name)," ","dashboard.")}),setTimeout((()=>t()),2e3),u({feature:"drag-in-dashboard",isSuccess:!0})},onFail:e=>{var a;const d=null===e||void 0===e||null===(a=e.response)||void 0===a?void 0:a.data,o=(0,S.o)(null===d||void 0===d?void 0:d.errorMsgKey)||(null===d||void 0===d?void 0:d.errorMessage)||"Something went wrong";c({message:o}),t(),u({feature:"drag-in-dashboard",isFailure:!0,message:o})}}),m=(0,F.nM)(),g=(0,F.Dn)(o,r);return(0,d.useCallback)(((e,t)=>{const a=s.getNode({id:null===t||void 0===t?void 0:t.itemId}),d=(0,N.A)(a.getAttributes());"new"!==e?m(d.contextScope,{...d,dashboardId:e,itemLayout:t},(()=>b(e))):g({name:"[Untitled]"},(e=>{m(d.contextScope,{...d,dashboardId:e.id,itemLayout:t},(()=>b(e.id)))}))}),[g,m])},T=(0,o.default)(r.Flex).attrs({background:"mainBackground",padding:[2],overflow:"auto",height:"80%",width:"600px"}).withConfig({displayName:"dropDashboard__ScaledDownContainer",componentId:"sc-zd7fpn-0"})(["box-shadow:0 0 0 1px rgba(63,63,68,0.05),-1px 0 15px 0 rgba(34,33,81,0.01),0px 15px 15px 0 rgba(34,33,81,0.25);"]),z=e=>{let{id:t,setOverDashboard:a}=e;const o=(0,D.vt)(),n=(0,y.ID)(),i=(0,D.ns)(o,"slug"),s=(0,y.wz)(n,"slug"),l=(0,I.A)(t,{spaceId:o,spaceSlug:i,roomId:n,roomSlug:s}),c=P({onDone:a});return t?d.createElement(r.Flex,{flex:!0,width:"100%",height:"100%",alignItems:"center",justifyContent:"center"},d.createElement(T,null,l?d.createElement(b.A,{title:"Loading dashboard..."}):d.createElement(x.A,{id:t,containerWidth:600,trashable:!1,containerDndProps:{droppable:!0},onDragEnd:(e,d)=>{if(!d)return a();c(t,d)}}))):null},j=(0,o.default)(r.Flex).attrs({column:!0,background:"dropdown",width:{max:"auto",min:100,base:100}}).withConfig({displayName:"dropInDashboard__Dropdown",componentId:"sc-12fd9r3-0"})(["box-shadow:0 0 0 1px rgba(63,63,68,0.05),-1px 0 15px 0 rgba(34,33,81,0.01),0px 15px 15px 0 rgba(34,33,81,0.25);"]),R=()=>{const[e,t]=(0,d.useState)(),[a,o]=(0,d.useState)();(0,c.A)();const m=(0,u.q)();let g=(0,p.Sf)(m);g=(0,d.useMemo)((()=>[...g].sort(((e,t)=>new Date(e.updatedAt)2&&void 0!==arguments[2]?arguments[2]:[];const[o,r]=(0,d.useState)();return(0,i.A)((()=>r(e)),t,[e,...a]),o}(null===a||void 0===a?void 0:a.id,500),v=P({onDone:o});(0,n.E5)({onDragMove:e=>{let{active:t,over:a}=e;if(null!==a&&void 0!==a&&a.id&&t)if(a.data.current.dropinDashboards&&t.data.current.dashboardable)o((e=>e||{active:t,dropinDashboards:!0}));else if(a.data.current.dashboardId&&t.data.current.dashboardable){if("new"===a.data.current.dashboardId)return;o((e=>e&&(null===e||void 0===e?void 0:e.id)===a.data.current.dashboardId?e:{...e,id:a.data.current.dashboardId,active:t}))}},onDragEnd:e=>{let{active:t,over:a}=e;null!==a&&void 0!==a&&a.id&&t&&(a.data.current.dashboardId&&t.data.current.dashboardable?v(a.data.current.dashboardId,t.data.current):setTimeout((()=>o()),1e3))},onDragCancel:()=>{o()}});const x=(0,d.useMemo)((()=>({overDashboardId:f})),[f]);if(null===a||void 0===a||!a.active)return null;const{isItem:D,isContainer:y,dashboardable:I}=a.active.data.current;return I&&(D||y)?d.createElement(r.Layer,{position:"right",full:!0,backdrop:!0,shadow:!0,justifyContent:"end"},d.createElement(z,{id:f,setOverDashboard:o}),(null===a||void 0===a?void 0:a.dropinDashboards)&&d.createElement(j,null,d.createElement(s.z,{title:"Drop in a dashboard",onClose:()=>o()}),d.createElement(l.Yv,{gap:2,height:"100%",overflow:"hidden",background:"dropdown"},h?d.createElement(w,{dashboards:g,selected:e,setSelected:t,itemProps:x}):d.createElement(b.A,{title:"Loading dashboards..."})))):null}}}]);