@devtable/dashboard 13.27.4 → 13.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard.es.js +429 -420
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
package/dist/dashboard.umd.js
CHANGED
|
@@ -59,7 +59,7 @@ Check the top-level render call using <`+L+">.")}return A}}function Cg(C,A){{if(
|
|
|
59
59
|
`,textSerializers:l={}}=n||{};let c="",u=!0;return e.nodesBetween(s,i,(d,p,h,f)=>{var m;const y=l==null?void 0:l[d.type.name];y?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=y({node:d,pos:p,parent:h,index:f,range:t}))):d.isText?(c+=(m=d==null?void 0:d.text)===null||m===void 0?void 0:m.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function ax(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}Vt.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new xr({key:new yr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:s,selection:i}=t,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=ax(n);return ix(s,{from:l,to:c},{textSerializers:u})}}})]}});const ox=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),lx=(e=!1)=>({commands:t})=>t.setContent("",e),cx=()=>({state:e,tr:t,dispatch:n})=>{const{selection:s}=t,{ranges:i}=s;return n&&i.forEach(({$from:a,$to:l})=>{e.doc.nodesBetween(a.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=t,h=d.resolve(p.map(u)),f=d.resolve(p.map(u+c.nodeSize)),m=h.blockRange(f);if(!m)return;const y=Xm(m);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(m.start,j)}(y||y===0)&&t.lift(m,y)})}),!0},ux=e=>t=>e(t),dx=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),px=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,s=n.$anchor.node();if(s.content.size>0)return!1;const i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s.type){if(t){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},hx=e=>({tr:t,state:n,dispatch:s})=>{const i=Oe(e,n.schema),a=t.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(s){const u=a.before(l),d=a.after(l);t.delete(u,d).scrollIntoView()}return!0}return!1},fx=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},gx=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),mx=()=>({commands:e})=>e.keyboardShortcut("Enter"),xx=()=>({state:e,dispatch:t})=>De.exitCode(e,t);function fs(e,t,n={strict:!0}){const s=Object.keys(t);return s.length?s.every(i=>n.strict?t[i]===e[i]:rx(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function qi(e,t,n={}){return e.find(s=>s.type===t&&fs(s.attrs,n))}function yx(e,t,n={}){return!!qi(e,t,n)}function Uc(e,t,n={}){if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(e.parentOffset===s.offset&&s.offset!==0&&(s=e.parent.childBefore(e.parentOffset)),!s.node)return;const i=qi([...s.node.marks],t,n);if(!i)return;let a=s.index,l=e.start()+s.offset,c=a+1,u=l+s.node.nodeSize;for(qi([...s.node.marks],t,n);a>0&&i.isInSet(e.parent.child(a-1).marks);)a-=1,l-=e.parent.child(a).nodeSize;for(;c<e.parent.childCount&&yx([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function ln(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const bx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=ln(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=Uc(u,a,t);if(h&&h.from<=d&&h.to>=p){const f=Se.create(l,h.from,h.to);n.setSelection(f)}}return!0},vx=e=>t=>{const n=typeof e=="function"?e(t):e;for(let s=0;s<n.length;s+=1)if(n[s](t))return!0;return!1};function Yc(e){return e instanceof Se}function Sn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function _x(e,t=null){if(!t)return null;const n=ge.atStart(e),s=ge.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return s;const i=n.from,a=s.to;return t==="all"?Se.create(e,Sn(0,i,a),Sn(e.content.size,i,a)):Se.create(e,Sn(t,i,a),Sn(t,i,a))}function Vi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const jx=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{Vi()&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!Yc(n.state.selection))return l(),!0;const c=_x(i.doc,e)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},wx=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),Cx=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function Kc(e){const t=`<body>${e}</body>`;return new window.DOMParser().parseFromString(t,"text/html").body}function gs(e,t,n){if(n={slice:!0,parseOptions:{},...n},typeof e=="object"&&e!==null)try{return Array.isArray(e)&&e.length>0?H.fromArray(e.map(s=>t.nodeFromJSON(s))):t.nodeFromJSON(e)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),gs("",t,n)}if(typeof e=="string"){const s=Nm.fromSchema(t);return n.slice?s.parseSlice(Kc(e),n.parseOptions).content:s.parse(Kc(e),n.parseOptions)}return gs("",t,n)}function Sx(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof qt||i instanceof Cn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(ge.near(e.doc.resolve(l),n))}const kx=e=>e.toString().startsWith("<"),Tx=(e,t,n)=>({tr:s,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=gs(t,a.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof e=="number"?{from:e,to:e}:e,d=!0,p=!0;if((kx(l)?l:[l]).forEach(f=>{f.check(),d=d?f.isText&&f.marks.length===0:!1,p=p?f.isBlock:!1}),c===u&&p){const{parent:f}=s.doc.resolve(c);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(c-=1,u+=1)}d?Array.isArray(t)?s.insertText(t.map(f=>f.text||"").join(""),c,u):typeof t=="object"&&t&&t.text?s.insertText(t.text,c,u):s.insertText(t,c,u):s.replaceWith(c,u,l),n.updateSelection&&Sx(s,s.steps.length-1,-1)}return!0},Dx=()=>({state:e,dispatch:t})=>De.joinUp(e,t),Mx=()=>({state:e,dispatch:t})=>De.joinDown(e,t),Ix=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),zx=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function Xc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ex(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let s,i,a,l;for(let c=0;c<t.length-1;c+=1){const u=t[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))Vi()||Xc()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}const Ax=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=Ex(e).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=t.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(s.mapping);p&&i&&s.maybeStep(p)}),!0};function Ni(e,t,n={}){const{from:s,to:i,empty:a}=e.selection,l=t?Oe(t,e.schema):null,c=[];e.doc.nodesBetween(s,i,(h,f)=>{if(h.isText)return;const m=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:m,to:y})});const u=i-s,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>fs(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=u}const Px=(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?De.lift(n,s):!1},Ox=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),Lx=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.liftListItem(s)(t,n)},Bx=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function Jc(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Zc(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((s,i)=>(n.includes(i)||(s[i]=e[i]),s),{})}const qx=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Jc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{s.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,Zc(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(Zc(h.attrs,t)))})})}),!0):!1},Vx=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Nx=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),$x=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),Fx=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),Gx=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),Wx=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),Rx=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function Qx(e,t,n={}){return gs(e,t,{slice:!1,parseOptions:n})}const Ux=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=Qx(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function Yx(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Kx(e,t){for(let n=e.depth;n>0;n-=1){const s=e.node(n);if(t(s))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:s}}}function $i(e){return t=>Kx(t.$from,e)}function Xx(e,t){const n=ln(t,e.schema),{from:s,to:i,empty:a}=e.selection,l=[];a?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(s,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function ms(e,t,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const i=e.find(a=>a.type===t&&a.name===s);return i?i.attribute.keepOnSplit:!1}))}function Jx(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?ln(t,e.schema):null;if(s)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>fs(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:f})=>{const m=h.pos,y=f.pos;e.doc.nodesBetween(m,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(m,k),T=Math.min(y,k+j.nodeSize),I=T-S;l+=I,c.push(...j.marks.map(z=>({mark:z,from:S,to:T})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>fs(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,f)=>h+f.to-f.from,0);return(u>0?u+d:u)>=l}function Hc(e,t){const{nodeExtensions:n}=tx(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=jt(nt(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Zx(e,t,n){var s;const{selection:i}=t;let a=null;if(Yc(i)&&(a=i.$cursor),a){const c=(s=e.storedMarks)!==null&&s!==void 0?s:a.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(c.pos,u.pos,(p,h,f)=>{if(d)return!1;if(p.isInline){const m=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=m&&y}return!d}),d})}const Hx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=ln(e,s.schema);if(i)if(l){const d=Xx(s,u);n.addStoredMark(u.create({...d,...t}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(p,h,(f,m)=>{const y=Math.max(m,p),j=Math.min(m+f.nodeSize,h);f.marks.find(S=>S.type===u)?f.marks.forEach(S=>{u===S.type&&n.addMark(y,j,u.create({...S.attrs,...t}))}):n.addMark(y,j,u.create(t))})});return Zx(s,n,u)},ey=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),ty=(e,t={})=>({state:n,dispatch:s,chain:i})=>{const a=Oe(e,n.schema);return a.isTextblock?i().command(({commands:l})=>De.setBlockType(a,t)(n)?!0:l.clearNodes()).command(({state:l})=>De.setBlockType(a,t)(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ny=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=Sn(e,0,s.content.size),a=tt.create(s,i);t.setSelection(a)}return!0},ry=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,{from:i,to:a}=typeof e=="number"?{from:e,to:e}:e,l=Se.atStart(s).from,c=Se.atEnd(s).to,u=Sn(i,l,c),d=Sn(a,l,c),p=Se.create(s,u,d);t.setSelection(p)}return!0},sy=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.sinkListItem(s)(t,n)};function eu(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const s=n.filter(i=>t==null?void 0:t.includes(i.type.name));e.tr.ensureMarks(s)}}const iy=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:s,editor:i})=>{const{selection:a,doc:l}=t,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=ms(d,c.node().type.name,c.node().attrs);if(a instanceof tt&&a.node.isBlock)return!c.parentOffset||!ds(l,c.pos)?!1:(s&&(e&&eu(n,i.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(s){const h=u.parentOffset===u.parent.content.size;a instanceof Se&&t.deleteSelection();const f=c.depth===0?void 0:Yx(c.node(-1).contentMatchAt(c.indexAfter(-1)));let m=h&&f?[{type:f,attrs:p}]:void 0,y=ds(t.doc,t.mapping.map(c.pos),1,m);if(!m&&!y&&ds(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,m=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,m),f&&!h&&!c.parentOffset&&c.parent.type!==f)){const j=t.mapping.map(c.before()),k=t.doc.resolve(j);c.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&t.setNodeMarkup(t.mapping.map(c.before()),f)}e&&eu(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},ay=e=>({tr:t,state:n,dispatch:s,editor:i})=>{var a;const l=Oe(e,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let k=H.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)k=H.from(c.node(R).copy(k));const T=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,I=ms(h,c.node().type.name,c.node().attrs),z=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(I))||void 0;k=k.append(H.from(l.createAndFill(null,z)||void 0));const E=c.before(c.depth-(S-1));t.replace(E,c.after(-T),new re(k,4-S,0));let N=-1;t.doc.nodesBetween(E,t.doc.content.size,(R,he)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=he+1)}),N>-1&&t.setSelection(Se.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const f=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,m=ms(h,p.type.name,p.attrs),y=ms(h,c.node().type.name,c.node().attrs);t.delete(c.pos,u.pos);const j=f?[{type:l,attrs:m},{type:f,attrs:y}]:[{type:l,attrs:m}];if(!ds(t.doc,c.pos,2))return!1;if(s){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=i.extensionManager,I=S||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,j).scrollIntoView(),!I||!s)return!0;const z=I.filter(E=>T.includes(E.type.name));t.ensureMarks(z)}return!0},Fi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&Vc(e.doc,n.pos)&&e.join(n.pos),!0},Gi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&Vc(e.doc,s)&&e.join(s),!0};var oy=Object.freeze({__proto__:null,blur:ox,clearContent:lx,clearNodes:cx,command:ux,createParagraphNear:dx,deleteCurrentNode:px,deleteNode:hx,deleteRange:fx,deleteSelection:gx,enter:mx,exitCode:xx,extendMarkRange:bx,first:vx,focus:jx,forEach:wx,insertContent:Cx,insertContentAt:Tx,joinUp:Dx,joinDown:Mx,joinBackward:Ix,joinForward:zx,keyboardShortcut:Ax,lift:Px,liftEmptyBlock:Ox,liftListItem:Lx,newlineInCode:Bx,resetAttributes:qx,scrollIntoView:Vx,selectAll:Nx,selectNodeBackward:$x,selectNodeForward:Fx,selectParentNode:Gx,selectTextblockEnd:Wx,selectTextblockStart:Rx,setContent:Ux,setMark:Hx,setMeta:ey,setNode:ty,setNodeSelection:ny,setTextSelection:ry,sinkListItem:sy,splitBlock:iy,splitListItem:ay,toggleList:(e,t,n,s={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,m=Oe(e,l.schema),y=Oe(t,l.schema),{selection:j,storedMarks:k}=l,{$from:S,$to:T}=j,I=S.blockRange(T),z=k||j.$to.parentOffset&&j.$from.marks();if(!I)return!1;const E=$i(N=>Hc(N.type.name,h))(j);if(I.depth>=1&&E&&I.depth-E.depth<=1){if(E.node.type===m)return d.liftListItem(y);if(Hc(E.node.type.name,h)&&m.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()}return!n||!z||!c?u().command(()=>p().wrapInList(m,s)?!0:d.clearNodes()).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run():u().command(()=>{const N=p().wrapInList(m,s),R=z.filter(he=>f.includes(he.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=ln(e,s.schema);return Jx(s,l,t)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,t)},toggleNode:(e,t,n={})=>({state:s,commands:i})=>{const a=Oe(e,s.schema),l=Oe(t,s.schema);return Ni(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?s.lift(i):s.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let s=0;s<n.length;s+=1){const i=n[s];let a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){const l=e.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,e.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:s,ranges:i}=n;return s||t&&i.forEach(a=>{e.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:s,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=t,{selection:c}=n,u=ln(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:m}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=Uc(d,u,y);j&&(f=j.from,m=j.to),n.removeMark(f,m,u)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(e,t={})=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Jc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;s.doc.nodesBetween(d,p,(h,f)=>{a&&a===h.type&&n.setNodeMarkup(f,void 0,{...h.attrs,...t}),l&&h.marks.length&&h.marks.forEach(m=>{if(l===m.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...m.attrs,...t}))}})})}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return De.wrapIn(i,t)(n,s)},wrapInList:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return _i.wrapInList(i,t)(n,s)}});Vt.create({name:"commands",addCommands(){return{...oy}}}),Vt.create({name:"editable",addProseMirrorPlugins(){return[new xr({key:new yr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Vt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new xr({key:new yr("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const s=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1},blur:(t,n)=>{e.isFocused=!1;const s=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1}}}})]}}),Vt.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:f,parent:m}=h,y=ge.atStart(d).from===f;return!p||!y||!m.type.isTextblock||m.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},a={...s,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Vi()||Xc()?a:i},addProseMirrorPlugins(){return[new xr({key:new yr("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(y=>y.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=t.selection,c=ge.atStart(t.doc).from,u=ge.atEnd(t.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,f=Qc({state:n,transaction:h}),{commands:m}=new ex({editor:this.editor,state:f});if(m.clearNodes(),!!h.steps.length)return h}})]}}),Vt.create({name:"tabindex",addProseMirrorPlugins(){return[new xr({key:new yr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class xs{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=jt(nt(this,"addOptions",{name:this.name}))),this.storage=jt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new xs(t)}configure(t={}){const n=this.extend();return n.options=Bi(this.options,t),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new xs(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=jt(nt(n,"addOptions",{name:n.name})),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:s}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",i.pos),t.view.dispatch(s),!0}return!1}}const Wi="function color({ variables }, { filters, context }, utils) {",tu="}",ly=[Wi,' return "red";',tu].join(`
|
|
60
60
|
`);function cy(e){const t=e.split(`
|
|
61
61
|
`);if(t.length===2)return console.warn("[getDynamicColorRestrictions]unexpected lines of code: ",e),[];const n=t[t.length-2];return n?[{range:[2,1,t.length-1,n.length+1],label:"body",allowMultiline:!0}]:[]}const uy=e=>!e||e.startsWith(Wi)?e:[Wi,e,tu].join(`
|
|
62
|
-
`),Ri="dyn_color_",dy=new RegExp(`^(?!${Ri})(.+)$`);function nu(e){return e&&e.replace(dy,`${Ri}$1`)}const ru=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);crypto.getRandomValues(a);const l=a.reduce((c,u)=>`${c}${i[u&61]}`,"");return`${Ri}${l}`};function py(e,t,n){const s={},i=l=>new Function(`return ${uy(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${nu(l.id)}`]={color:i(c)})}),s}const br="data-value",hy=br,su="dynamicColor",iu=xs.create({name:su,addAttributes(){return{id:{default:ru(6),parseHTML:e=>{const t=e.getAttribute("id");return nu(t)}},[br]:{default:null,parseHTML:e=>e.getAttribute(br)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(br)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[br]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),fy=({value:e,onChange:t,onMount:n})=>{const s=i=>{if(!i){t("");return}t(i)};return r.jsx(et,{className:"function-editor",height:"100%",defaultLanguage:"javascript",defaultValue:e,value:e,onChange:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:n})},Nn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((j,k)=>{if(i.length===0)return;const S=zg.constrainedEditor(k),T=j.getModel();if(S.initializeIn(j),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const I=T.getCurrentEditableRanges(),z=T.getValueInEditableRanges();console.debug({model:T,currentRanges:I,currentValue:z})}},[]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(ou,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(fy,{value:c,onChange:u,onMount:f})]})]})}),Qi=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:m,close:y}]=fe.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Nn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),gy=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},my=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(su)[hy]??"";return r.jsxs(r.Fragment,{children:[r.jsx(Qi,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:ly,renderTriggerButton:gy,restrictions:cy(n),zIndex:340}),r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.clear"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},disabled:!n,onClick:()=>e.chain().focus().unsetDynamicColor().run(),children:r.jsx(M.IconMathFunctionOff,{stroke:1.5,size:16})})})]})},au=Vt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),xy=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),yy=[{label:"auto",value:""}].concat(xy.map(e=>({label:e,value:e}))),by={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},vy=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:yy,styles:by,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},vr=({value:e,styles:t={},sx:n={},dashboardState:s=Ki(),variableAggValueMap:i={}})=>{const a=ac.useEditor({extensions:[oc,ic,Q.Link,Zl,Jl,Kl,Hl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),nc,tc,ec,rc.configure({types:["heading","paragraph"]}),Xl.configure({placeholder:"This is placeholder"}),sc,Yl.Color,au,iu],content:e,editable:!1});g.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=g.useMemo(()=>py(l,s,i),[l,s,i]),u=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function ou(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=fe.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(vr,{value:km(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const lu=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),Ui=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(et,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},_y=["gray","red","grape","blue","cyan","green","yellow"],jy=({editor:e})=>{const{t}=_.useTranslation(),n=o.useMantineTheme(),[s,{set:i,setFalse:a,toggle:l}]=W.useBoolean(),c=e.getAttributes("textStyle").color||n.black,u=g.useMemo(()=>Ot(c).hex(),[c]),d=g.useMemo(()=>{const f=[];return _y.forEach(m=>{const y=n.colors[m];y&&y.forEach(j=>{f.push(j)})}),f},[n.colors]),p=(f,m=!0)=>{e.chain().focus().setColor(f).run(),m&&a()},h=()=>{e.chain().focus().unsetColor().run(),a()};return r.jsxs(o.Popover,{opened:s,onChange:i,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[r.jsx(o.Popover.Target,{children:r.jsx(Q.RichTextEditor.Control,{onClick:l,children:r.jsx(o.ColorSwatch,{color:u,size:14})})}),r.jsx(o.Popover.Dropdown,{children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"right",children:[r.jsx(o.ColorInput,{value:u,onChangeEnd:f=>p(f,!1),size:"xs",withPicker:!1,dropdownZIndex:340,styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center"}}}),r.jsx(o.ActionIcon,{variant:"default",onClick:h,title:t("common.actions.clear"),children:r.jsx(M.IconCircleOff,{stroke:1.5,size:"1rem"})}),r.jsx(o.ActionIcon,{variant:"default",onClick:a,title:t("common.actions.close"),children:r.jsx(M.IconX,{stroke:1.5,size:"1rem"})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.ColorPicker,{format:"hex",swatches:d,value:u,onChange:f=>p(f,!1),size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),r.jsx(o.ColorPicker,{format:"hex",fullWidth:!0,value:u,onChange:f=>p(f,!1)})]})]})})]})},wy={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function Cy(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const[c,u]=g.useState(e),d=ac.useEditor({extensions:[oc,ic,Q.Link,Zl,Jl,Kl,Hl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),nc,tc,ec,rc.configure({types:["heading","paragraph"]}),Xl.configure({placeholder:"This is placeholder"}),sc,Yl.Color,au,iu],content:c,onUpdate:({editor:m})=>{const y=m.getHTML();u(y)}});g.useEffect(()=>{u(m=>e===m?m:(d==null||d.commands.setContent(e),e))},[e]);const p=()=>{t(c),a==null||a()},h=e!==c;g.useEffect(()=>{i&&p()},[i,h]);const f=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...wy}},n),[n]);return d?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!h,onClick:p,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:d,styles:f,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(jy,{editor:d}),r.jsx(my,{editor:d})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(Cy,{})}),r.jsx(vy,{editor:d})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null}),Me={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function U(e,{absolute:t,...n}){if(e===null)return String(e);try{let s=Zr(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),Zr(s).format(n)}catch(s){return console.debug(s),String(e)}}function Sy(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Nt({data_field:e,aggregation:t},n){return is(n,e,t)}function rt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return Sy(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function cu(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const p=ru(6),h=`try {
|
|
62
|
+
`),Ri="dyn_color_",dy=new RegExp(`^(?!${Ri})(.+)$`);function nu(e){return e&&e.replace(dy,`${Ri}$1`)}const ru=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);crypto.getRandomValues(a);const l=a.reduce((c,u)=>`${c}${i[u&61]}`,"");return`${Ri}${l}`};function py(e,t,n){const s={},i=l=>new Function(`return ${uy(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${nu(l.id)}`]={color:i(c)})}),s}const br="data-value",hy=br,su="dynamicColor",iu=xs.create({name:su,addAttributes(){return{id:{default:ru(6),parseHTML:e=>{const t=e.getAttribute("id");return nu(t)}},[br]:{default:null,parseHTML:e=>e.getAttribute(br)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(br)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[br]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),fy=({value:e,onChange:t,onMount:n})=>{const s=g.useRef(null),i=g.useRef(null),a=c=>{if(!c){t("");return}t(c)};g.useEffect(()=>{var u;const c=(u=s.current)==null?void 0:u.getModel();c&&(c.getValue()||c.setValue(e))},[e]);const l=(c,u)=>{s.current=c,i.current=u,n==null||n(c,u)};return console.log({value:e}),r.jsx(et,{className:"function-editor",height:"100%",defaultLanguage:"javascript",defaultValue:e,onChange:a,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:l})},Nn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((j,k)=>{if(i.length===0)return;const S=zg.constrainedEditor(k),T=j.getModel();if(S.initializeIn(j),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const I=T.getCurrentEditableRanges(),z=T.getValueInEditableRanges();console.debug({model:T,currentRanges:I,currentValue:z})}},[]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(ou,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(fy,{value:c,onChange:u,onMount:f})]})]})}),Qi=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:m,close:y}]=fe.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Nn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),gy=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},my=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(su)[hy]??"";return r.jsxs(r.Fragment,{children:[r.jsx(Qi,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:ly,renderTriggerButton:gy,restrictions:cy(n),zIndex:340}),r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.clear"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},disabled:!n,onClick:()=>e.chain().focus().unsetDynamicColor().run(),children:r.jsx(M.IconMathFunctionOff,{stroke:1.5,size:16})})})]})},au=Vt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),xy=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),yy=[{label:"auto",value:""}].concat(xy.map(e=>({label:e,value:e}))),by={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},vy=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:yy,styles:by,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},vr=({value:e,styles:t={},sx:n={},dashboardState:s=Ki(),variableAggValueMap:i={}})=>{const a=ac.useEditor({extensions:[oc,ic,Q.Link,Zl,Jl,Kl,Hl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),nc,tc,ec,rc.configure({types:["heading","paragraph"]}),Xl.configure({placeholder:"This is placeholder"}),sc,Yl.Color,au,iu],content:e,editable:!1});g.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=g.useMemo(()=>py(l,s,i),[l,s,i]),u=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function ou(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=fe.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(vr,{value:km(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const lu=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),Ui=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(et,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},_y=["gray","red","grape","blue","cyan","green","yellow"],jy=({editor:e})=>{const{t}=_.useTranslation(),n=o.useMantineTheme(),[s,{set:i,setFalse:a,toggle:l}]=W.useBoolean(),c=e.getAttributes("textStyle").color||n.black,u=g.useMemo(()=>Ot(c).hex(),[c]),d=g.useMemo(()=>{const f=[];return _y.forEach(m=>{const y=n.colors[m];y&&y.forEach(j=>{f.push(j)})}),f},[n.colors]),p=(f,m=!0)=>{e.chain().focus().setColor(f).run(),m&&a()},h=()=>{e.chain().focus().unsetColor().run(),a()};return r.jsxs(o.Popover,{opened:s,onChange:i,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[r.jsx(o.Popover.Target,{children:r.jsx(Q.RichTextEditor.Control,{onClick:l,children:r.jsx(o.ColorSwatch,{color:u,size:14})})}),r.jsx(o.Popover.Dropdown,{children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"right",children:[r.jsx(o.ColorInput,{value:u,onChangeEnd:f=>p(f,!1),size:"xs",withPicker:!1,dropdownZIndex:340,styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center"}}}),r.jsx(o.ActionIcon,{variant:"default",onClick:h,title:t("common.actions.clear"),children:r.jsx(M.IconCircleOff,{stroke:1.5,size:"1rem"})}),r.jsx(o.ActionIcon,{variant:"default",onClick:a,title:t("common.actions.close"),children:r.jsx(M.IconX,{stroke:1.5,size:"1rem"})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.ColorPicker,{format:"hex",swatches:d,value:u,onChange:f=>p(f,!1),size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),r.jsx(o.ColorPicker,{format:"hex",fullWidth:!0,value:u,onChange:f=>p(f,!1)})]})]})})]})},wy={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function Cy(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const[c,u]=g.useState(e),d=ac.useEditor({extensions:[oc,ic,Q.Link,Zl,Jl,Kl,Hl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),nc,tc,ec,rc.configure({types:["heading","paragraph"]}),Xl.configure({placeholder:"This is placeholder"}),sc,Yl.Color,au,iu],content:c,onUpdate:({editor:m})=>{const y=m.getHTML();u(y)}});g.useEffect(()=>{u(m=>e===m?m:(d==null||d.commands.setContent(e),e))},[e]);const p=()=>{t(c),a==null||a()},h=e!==c;g.useEffect(()=>{i&&p()},[i,h]);const f=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...wy}},n),[n]);return d?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!h,onClick:p,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:d,styles:f,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(jy,{editor:d}),r.jsx(my,{editor:d})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(Cy,{})}),r.jsx(vy,{editor:d})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null}),Me={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function U(e,{absolute:t,...n}){if(e===null)return String(e);try{let s=Zr(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),Zr(s).format(n)}catch(s){return console.debug(s),String(e)}}function Sy(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Nt({data_field:e,aggregation:t},n){return is(n,e,t)}function rt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return Sy(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function cu(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const p=ru(6),h=`try {
|
|
63
63
|
return utils.popmotion.interpolate(${JSON.stringify(d.valueRange)}, ${JSON.stringify(d.colorRange)})(variables["${i}"]);
|
|
64
64
|
} catch (error) {
|
|
65
65
|
console.error(error);
|
|
@@ -71,7 +71,7 @@ Check the top-level render call using <`+L+">.")}return A}}function Cg(C,A){{if(
|
|
|
71
71
|
${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
|
|
72
72
|
`)}
|
|
73
73
|
return ${e};
|
|
74
|
-
`)(n)}catch(s){return console.error(s),console.log(e),e}}function fu(e,t,n,s){const i=Ny(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=$y(c);return Fy(d,i,n)})}function Gy(e,t){const n=cc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Wy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Tm({sql:p,pre_process:u}),f=cc.encode(h);Gy(h,f);let m=await Lt.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Dm(d,m,Xi(n)),m}async function Ry({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Lt.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Ji(){try{return(await Lt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function gu(){try{return(await Lt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class mu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class Qy{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new uc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new uc;return this.channels.set(t,s),s}}class Uy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Qy,instanceData:new mu(t.viz.conf)};return this.instances.set(t.id,s),s}}function xu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new mu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Yy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...xu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Ky=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...xu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},yu=(e,t)=>{const n=Ot.bezier(e),s=Ot.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Ot.bezier(e);return function(n){return t(n/100).hex()}},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:yu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Jy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:yu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Zy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Hy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},eb={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},tb={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class nb{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new nb(e)}class Zi{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Zi;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const bu="13.27.4",rb=Object.freeze(Object.defineProperty({__proto__:null,version:bu},Symbol.toStringTag,{value:"Module"}));class sb{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class ib{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ab{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends ab{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Hi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function ob({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Hi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,z=>z[y.columnKey]),I=v.maxBy(h,z=>z[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(I,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const vu=g.createContext(null),ea=vu.Provider;function ta(){const e=g.useContext(vu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ta(),_u=()=>ta(),ju=g.createContext({searchButtonProps:{}}),na=ju.Provider;function wu(){return g.useContext(ju)}const Cu=g.createContext(null),ra=Cu.Provider;function Su(){const e=g.useContext(Cu);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>Su(),_e=()=>Su(),lb={inEditMode:!1},js=g.createContext(lb),ku=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),sa=ku.Provider;function Tu(){const e=g.useContext(ku);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Tu(),Ge=()=>Tu(),cb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},ia=g.createContext(cb);function Du(){const e=g.useContext(ia);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ub={en:"en",zh:"zh-cn"};function aa({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ub[s]??"en"},[t.language]);return r.jsx(dc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function db({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Hi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const pb=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function hb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class fb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:hb(i,s)}})}}const gb={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new fb,name:"bar-3d",viewRender:ob,configRender:db,createConfig(){return{version:2,config:v.cloneDeep(Hi)}},translation:pb},mb=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
74
|
+
`)(n)}catch(s){return console.error(s),console.log(e),e}}function fu(e,t,n,s){const i=Ny(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=$y(c);return Fy(d,i,n)})}function Gy(e,t){const n=cc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Wy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Tm({sql:p,pre_process:u}),f=cc.encode(h);Gy(h,f);let m=await Lt.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Dm(d,m,Xi(n)),m}async function Ry({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Lt.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Ji(){try{return(await Lt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function gu(){try{return(await Lt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class mu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class Qy{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new uc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new uc;return this.channels.set(t,s),s}}class Uy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Qy,instanceData:new mu(t.viz.conf)};return this.instances.set(t.id,s),s}}function xu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new mu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Yy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...xu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Ky=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...xu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},yu=(e,t)=>{const n=Ot.bezier(e),s=Ot.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Ot.bezier(e);return function(n){return t(n/100).hex()}},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:yu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Jy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:yu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Zy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Hy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},eb={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},tb={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class nb{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new nb(e)}class Zi{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Zi;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const bu="13.27.5",rb=Object.freeze(Object.defineProperty({__proto__:null,version:bu},Symbol.toStringTag,{value:"Module"}));class sb{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class ib{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ab{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends ab{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Hi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function ob({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Hi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,z=>z[y.columnKey]),I=v.maxBy(h,z=>z[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(I,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const vu=g.createContext(null),ea=vu.Provider;function ta(){const e=g.useContext(vu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ta(),_u=()=>ta(),ju=g.createContext({searchButtonProps:{}}),na=ju.Provider;function wu(){return g.useContext(ju)}const Cu=g.createContext(null),ra=Cu.Provider;function Su(){const e=g.useContext(Cu);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>Su(),_e=()=>Su(),lb={inEditMode:!1},js=g.createContext(lb),ku=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),sa=ku.Provider;function Tu(){const e=g.useContext(ku);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Tu(),Ge=()=>Tu(),cb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},ia=g.createContext(cb);function Du(){const e=g.useContext(ia);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ub={en:"en",zh:"zh-cn"};function aa({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ub[s]??"en"},[t.language]);return r.jsx(dc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function db({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Hi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const pb=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function hb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class fb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:hb(i,s)}})}}const gb={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new fb,name:"bar-3d",viewRender:ob,configRender:db,createConfig(){return{version:2,config:v.cloneDeep(Hi)}},translation:pb},mb=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
75
75
|
`)}}const kt=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},m=k=>{d(S=>({...S,func_content:k}))},y=()=>{m(Le().func_content)},j=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),r.jsx(o.Modal,{size:800,title:j,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>p(k.currentTarget.checked)}),r.jsx(mb,{value:u.func_content,onChange:m,disabled:!u.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:y,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:f,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Tn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Mu(){return v.cloneDeep(Tn)}const xb=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Iu={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:bb,configRender:yb,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function yb(e){return r.jsx(r.Fragment,{})}function bb(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const ws=g.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=g.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[a.language]);return r.jsxs(o.Stack,{spacing:0,children:[e&&r.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Tt=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},a=l=>{t({...e,in_tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:a})]})});function Ke(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function ut({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
76
76
|
max-width: ${t}px;
|
|
77
77
|
word-break: ${n};
|