react-resizable-panels 4.12.0 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("react/jsx-runtime"),x=require("react");function ct(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function ft(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function dt(e){return e/100*window.innerHeight}function pt(e){return e/100*window.innerWidth}function ht(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function oe({groupSize:e,panelElement:t,styleProp:n}){let o;const[i,s]=ht(n);switch(s){case"%":{o=i/100*e;break}case"px":{o=i;break}case"rem":{o=ft(t,i);break}case"em":{o=ct(t,i);break}case"vh":{o=dt(i);break}case"vw":{o=pt(i);break}}return o}function T(e){return parseFloat(e.toFixed(3))}function te({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,i)=>(o+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,o),0)}function me(e){const{panels:t}=e,n=te({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:i,panelConstraints:s}=o;let u=0;if(s.collapsedSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.collapsedSize});u=T(c/n*100)}let a;if(s.defaultSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=T(c/n*100)}let r=0;if(s.minSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.minSize});r=T(c/n*100)}let l=100;if(s.maxSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.maxSize});l=T(c/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:r,maxSize:l,panelId:o.id}})}function C(e,t="Assertion error"){if(!e)throw Error(t)}function ge(e,t){return Array.from(t).sort(e==="horizontal"?mt:gt)}function mt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function gt(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function He(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ve(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function yt({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const u of t){const{x:a,y:r}=Ve(o,u),l=e==="horizontal"?a:r;l<s&&(s=l,i=u)}return C(i,"No rect found"),i}let ue;function Ue(){return ue===void 0&&(typeof matchMedia=="function"?ue=!!matchMedia("(pointer:coarse)").matches:ue=!1),ue}function Be(e){const{element:t,orientation:n,panels:o,separators:i}=e,s=ge(n,Array.from(t.children).filter(He).map(z=>({element:z}))).map(({element:z})=>z),u=[];let a=!1,r=!1,l=-1,c=-1,m=0,p,S=[];{let z=-1;for(const f of s)f.hasAttribute("data-panel")&&(z++,f.hasAttribute("data-disabled")||(m++,l===-1&&(l=z),c=z))}if(m>1){let z=-1;for(const f of s)if(f.hasAttribute("data-panel")){z++;const d=o.find(h=>h.element===f);if(d){if(p){const h=p.element.getBoundingClientRect(),y=f.getBoundingClientRect();let b;if(r){const v=n==="horizontal"?new DOMRect(h.right,h.top,0,h.height):new DOMRect(h.left,h.bottom,h.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(S.length){case 0:{b=[v,g];break}case 1:{const L=S[0],M=yt({orientation:n,rects:[h,y],targetRect:L.element.getBoundingClientRect()});b=[L,M===h?g:v];break}default:{b=S;break}}}else S.length?b=S:b=[n==="horizontal"?new DOMRect(h.right,y.top,y.left-h.right,y.height):new DOMRect(y.left,h.bottom,y.width,y.top-h.bottom)];for(const v of b){let g="width"in v?v:v.element.getBoundingClientRect();const L=Ue()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<L){const R=L-g.width;g=new DOMRect(g.x-R/2,g.y,g.width+R,g.height)}if(g.height<L){const R=L-g.height;g=new DOMRect(g.x,g.y-R/2,g.width,g.height+R)}const M=z<=l||z>c;!a&&!M&&u.push({group:e,groupSize:te({group:e}),panels:[p,d],separator:"width"in v?void 0:v,rect:g}),a=!1}}r=!1,p=d,S=[]}}else if(f.hasAttribute("data-separator")){f.ariaDisabled!==null&&(a=!0);const d=i.find(h=>h.element===f);d?S.push(d):(p=void 0,S=[])}else r=!0}return u}class We{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let i=!1,s=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const r=u[a];try{r.call(null,n)}catch(l){s===null&&(i=!0,s=l)}}if(i)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const i=o.indexOf(n);i>=0&&o.splice(i,1)}}}let F=new Map;const Ke=new We;function St(e){F=new Map(F),F.delete(e)}function Re(e,t){for(const[n]of F)if(n.id===e)return n}function H(e,t){for(const[n,o]of F)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function q(){return F}function ye(e,t){return Ke.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function $(e,t,n){const o=F.get(e);F=new Map(F),F.set(e,t),Ke.emit("groupChange",{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t})}function vt(e,t,n){let o,i={x:1/0,y:1/0};for(const s of t){const u=Ve(n,s.rect);switch(e){case"horizontal":{u.x<=i.x&&(o=s,i=u);break}case"vertical":{u.y<=i.y&&(o=s,i=u);break}}}return o?{distance:i,hitRegion:o}:void 0}function bt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function zt(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Me(e),b:Me(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();C(o,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ee(Ce(n.a)),b:Ee(Ce(n.b))};if(i.a===i.b){const s=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const r=s[a];if(r===u.a)return 1;if(r===u.b)return-1}}return Math.sign(i.a-i.b)}const xt=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Pt(e){const t=getComputedStyle(qe(e)??e).display;return t==="flex"||t==="inline-flex"}function wt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Pt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||xt.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ce(e){let t=e.length;for(;t--;){const n=e[t];if(C(n,"Missing node"),wt(n))return n}return null}function Ee(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Me(e){const t=[];for(;e;)t.push(e),e=qe(e);return t}function qe(e){const{parentNode:t}=e;return bt(t)?t.host:t}function Lt(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Rt({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!He(n)||n.contains(e)||e.contains(n))return!0;if(zt(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(Lt(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function Se(e,t){const n=[];return t.forEach((o,i)=>{if(i.disabled)return;const s=Be(i),u=vt(i.orientation,s,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Rt({groupElement:i.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function Ct(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function D(e,t,n=0){return Math.abs(T(e)-T(t))<=n}function A(e,t){return D(e,t)?0:e>t?1:-1}function Z({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:i=0,collapsible:s,disabled:u,maxSize:a=100,minSize:r=0}=t;if(u&&!e)return n;if(A(o,r)<0)if(s){const l=(i+r)/2;A(o,l)<0?o=i:o=r}else o=r;return o=Math.min(a,o),o=T(o),o}function se({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:i,trigger:s}){if(D(e,0))return t;const u=s==="imperative-api",a=Object.values(t),r=Object.values(i),l=[...a],[c,m]=o;C(c!=null,"Invalid first pivot index"),C(m!=null,"Invalid second pivot index");let p=0;switch(s){case"keyboard":{{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,h)){const g=b-v;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const f=e<0?c:m,d=n[f];C(d,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,b)){const g=v-h;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const h=a[f],{collapsible:y,collapsedSize:b,minSize:v}=d;if(y&&A(h,v)<0)if(e>0){const g=v-b,L=g/2,M=h+e;A(M,v)<0&&(e=A(e,L)<=0?0:g)}else{const g=v-b,L=100-g/2,M=h-e;A(M,v)<0&&(e=A(100+e,L)>0?0:-g)}break}}{const f=e<0?1:-1;let d=e<0?m:c,h=0;for(;;){const b=a[d];C(b!=null,`Previous layout not found for panel index ${d}`);const g=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:b,size:100})-b;if(h+=g,d+=f,d<0||d>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-y:y}{let d=e<0?c:m;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(p),y=a[d];C(y!=null,`Previous layout not found for panel index ${d}`);const b=y-h,v=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:y,size:b});if(!D(y,v)&&(p+=y-v,l[d]=v,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(Ct(r,l))return i;{const f=e<0?m:c,d=a[f];C(d!=null,`Previous layout not found for panel index ${f}`);const h=d+p,y=Z({overrideDisabledPanels:u,panelConstraints:n[f],prevSize:d,size:h});if(l[f]=y,!D(y,h)){let b=h-y,g=e<0?m:c;for(;g>=0&&g<n.length;){const L=l[g];C(L!=null,`Previous layout not found for panel index ${g}`);const M=L+b,R=Z({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:L,size:M});if(D(L,R)||(b-=R-L,l[g]=R),D(b,0))break;e>0?g--:g++}}}const S=Object.values(l).reduce((f,d)=>d+f,0);if(!D(S,100,.1))return i;const z=Object.keys(i);return l.reduce((f,d,h)=>(f[z[h]]=d,f),{})}function B(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||A(e[n],t[n])!==0)return!1;return!0}function W({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],i=o.reduce((a,r)=>a+r,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(a=>`${a}%`).join(", ")}`);if(!D(i,100)&&o.length>0)for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=100/i*r;o[a]=l}let s=0;for(let a=0;a<t.length;a++){const r=n[a];C(r!=null,`No layout data found for index ${a}`);const l=o[a];C(l!=null,`No layout data found for index ${a}`);const c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});l!=c&&(s+=l-c,o[a]=c)}if(!D(s,0))for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=r+s,c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});if(r!==c&&(s-=c-r,o[a]=c,D(s,0)))break}const u=Object.keys(e);return o.reduce((a,r,l)=>(a[u[l]]=r,a),{})}function Xe({groupId:e,panelId:t}){const n=()=>{const r=q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:m,layout:p,groupSize:S,separatorToPanels:z}]of r)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:l,groupSize:S,layout:p,separatorToPanels:z};throw Error(`Group ${e} not found`)},o=()=>{const r=n().derivedPanelConstraints.find(l=>l.panelId===t);if(r!==void 0)return r;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const r=n().group.panels.find(l=>l.id===t);if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const r=n().layout[t];if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:r,panels:l,prevLayout:c,derivedPanelConstraints:m})=>{const p=s(),S=l.findIndex(h=>h.id===t),z=S===0,f=S===l.length-1;if(f&&r<p&&(z||l.slice(0,S).every((h,y)=>{const b=m[y];return b?.collapsible&&D(b.collapsedSize,c[b.panelId])}))){const h=l.slice(0,S).reduce((y,b)=>y+c[b.id],0);return{...c,[t]:T(100-h)}}return se({delta:f?p-r:r-p,initialLayout:c,panelConstraints:m,pivotIndices:f?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"})},a=r=>{const l=s();if(r===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:p,groupSize:S,layout:z,separatorToPanels:f}=n(),d=u({nextSize:r,panels:p.panels,prevLayout:z,derivedPanelConstraints:m}),h=W({layout:d,panelConstraints:m});B(z,h)||$(p,{defaultLayoutDeferred:c,derivedPanelConstraints:m,groupSize:S,layout:h,separatorToPanels:f})};return{collapse:()=>{const{collapsible:r,collapsedSize:l}=o(),{mutableValues:c}=i(),m=s();r&&m!==l&&(c.expandToSize=m,a(l))},expand:()=>{const{collapsible:r,collapsedSize:l,minSize:c}=o(),{mutableValues:m}=i(),p=s();if(r&&p===l){let S=m.expandToSize??c;S===0&&(S=1),a(S)}},getSize:()=>{const{group:r}=n(),l=s(),{element:c}=i(),m=r.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:r,collapsedSize:l}=o(),c=s();return r&&D(l,c)},resize:r=>{const{group:l}=n(),{element:c}=i(),m=te({group:l}),p=oe({groupSize:m,panelElement:c,styleProp:r}),S=T(p/m*100);a(S)}}}function ke(e){if(e.defaultPrevented)return;const t=q();Se(e,t).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const i=o.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(i){const s=i.panelConstraints.defaultSize,u=Xe({groupId:o.group.id,panelId:i.id});u&&s!==void 0&&(u.resize(s),e.preventDefault())}}})}function fe(e){const t=q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function Ye({groupId:e}){const t=()=>{const n=q();for(const[o,i]of n)if(o.id===e)return{group:o,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:i,group:s,groupSize:u,layout:a,separatorToPanels:r}=t(),l=W({layout:n,panelConstraints:i});return o?a:(B(a,l)||$(s,{defaultLayoutDeferred:o,derivedPanelConstraints:i,groupSize:u,layout:l,separatorToPanels:r}),l)}}}function U(e,t){const n=fe(e),o=H(n.id,!0),i=n.separators.find(m=>m.element===e);C(i,"Matching separator not found");const s=o.separatorToPanels.get(i);C(s,"Matching panels not found");const u=s.map(m=>n.panels.indexOf(m)),r=Ye({groupId:n.id}).getLayout(),l=se({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=W({layout:l,panelConstraints:o.derivedPanelConstraints});B(r,c)||$(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:c,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function Ie(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=fe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&U(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&U(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&U(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&U(t,-5);break}case"End":{e.preventDefault(),U(t,100);break}case"Enter":{e.preventDefault();const o=fe(t),i=H(o.id,!0),{derivedPanelConstraints:s,layout:u,separatorToPanels:a}=i,r=o.separators.find(p=>p.element===t);C(r,"Matching separator not found");const l=a.get(r);C(l,"Matching panels not found");const c=l[0],m=s.find(p=>p.panelId===c.id);if(C(m,"Panel metadata not found"),m.collapsible){const p=u[c.id],S=m.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??m.minSize:m.collapsedSize;U(t,S-p)}break}case"F6":{e.preventDefault();const i=fe(t).separators.map(r=>r.element),s=Array.from(i).findIndex(r=>r===e.currentTarget);C(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:i.length-1:s+1<i.length?s+1:0;i[u].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),U(t,-100);break}}}let Q={cursorFlags:0,state:"inactive"};const ve=new We;function K(){return Q}function Et(e){return ve.addListener("change",e)}function Mt(e){const t=Q,n={...Q};n.cursorFlags=e,Q=n,ve.emit("change",{prev:t,next:n})}function ee(e){const t=Q;Q=e,ve.emit("change",{prev:t,next:e})}function De(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=q(),n=Se(e,t),o=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(s.group);u&&o.set(s.group,u.layout)}),ee({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}const kt=e=>e,he=()=>{},Je=1,Ze=2,Qe=4,et=8,Oe=3,Te=12;let ce;function Ge(){return ce===void 0&&(ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(ce=!0)),ce}function It({cursorFlags:e,groups:t,state:n}){let o=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{i++;break}}})}if(!(o===0&&i===0)){switch(n){case"active":{if(e&&Ge()){const s=(e&Je)!==0,u=(e&Ze)!==0,a=(e&Qe)!==0,r=(e&et)!==0;if(s)return a?"se-resize":r?"ne-resize":"e-resize";if(u)return a?"sw-resize":r?"nw-resize":"w-resize";if(a)return"s-resize";if(r)return"n-resize"}break}}return Ge()?o>0&&i>0?"move":o>0?"ew-resize":"ns-resize":o>0&&i>0?"grab":o>0?"col-resize":"row-resize"}}const Ae=new WeakMap;function be(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Ae.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=K();switch(o.state){case"active":case"hover":{const i=It({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Ae.set(e,{prevStyle:t,styleSheet:n})}function tt({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:m}=l,{orientation:p,panels:S}=c,{disableCursor:z}=c.mutableState;let f=0;s?p==="horizontal"?f=(t.clientX-s.x)/m*100:f=(t.clientY-s.y)/m*100:p==="horizontal"?f=t.clientX<0?-100:100:f=t.clientY<0?-100:100;const d=o.get(c),h=i.get(c);if(!d||!h)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:g,separatorToPanels:L}=h;if(b&&g&&L){const M=se({delta:f,initialLayout:d,panelConstraints:b,pivotIndices:l.panels.map(R=>S.indexOf(R)),prevLayout:g,trigger:"mouse-or-touch"});if(B(M,g)){if(f!==0&&!z)switch(p){case"horizontal":{a|=f<0?Je:Ze;break}case"vertical":{a|=f<0?Qe:et;break}}}else $(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:M,separatorToPanels:L})}});let r=0;t.movementX===0?r|=u&Oe:r|=a&Oe,t.movementY===0?r|=u&Te:r|=a&Te,Mt(r),be(e)}function Fe(e){const t=q(),n=K();switch(n.state){case"active":tt({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Ne(e){if(e.defaultPrevented)return;const t=K(),n=q();switch(t.state){case"active":{if(e.buttons===0){ee({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})});return}for(const o of t.hitRegions)if(o.separator){const{element:i}=o.separator;i.hasPointerCapture?.(e.pointerId)||i.setPointerCapture?.(e.pointerId)}tt({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=Se(e,n);o.length===0?t.state!=="inactive"&&ee({cursorFlags:0,state:"inactive"}):ee({cursorFlags:0,hitRegions:o,state:"hover"}),be(e.currentTarget);break}}}function _e(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(K().state){case"hover":ee({cursorFlags:0,state:"inactive"})}}function je(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=K();switch(t.state){case"active":ee({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(be(e.currentTarget),t.hitRegions.forEach(n=>{const o=H(n.group.id,!0);$(n.group,o,{isUserInteraction:!0})}),e.preventDefault())}}function $e(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=T(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=T((100-n)/i);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Dt(e,t,n){if(!n[0])return;const i=e.panels.find(l=>l.element===t);if(!i||!i.onResize)return;const s=te({group:e}),u=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,r={asPercentage:T(u/s*100),inPixels:u};i.mutableValues.prevSize=r,i.onResize(r,i.id,a)}function Ot(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function Tt({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let i=0,s=0,u=!1;const a=new Map,r=[];for(const m of e.panels){const p=o[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const S=p/100*n,z=T(S/t*100);a.set(m.id,z),i+=z;break}case"preserve-relative-size":default:{r.push(m.id),s+=p;break}}}if(!u||r.length===0)return o;const l=100-i,c={...o};if(a.forEach((m,p)=>{c[p]=m}),s>0)for(const m of r){const p=o[m]??0;c[m]=T(p/s*l)}else{const m=T(l/r.length);for(const p of r)c[p]=m}return c}function Gt(e,t){const n=e.map(i=>i.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i))return!1;return!0}const J=new Map;function At(e){let t=!0;C(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,i=new Set,s=new n(f=>{for(const d of f){const{borderBoxSize:h,target:y}=d;if(y===e.element){if(t){const b=te({group:e});if(b===0)return;const v=H(e.id);if(!v)return;const g=me(e),L=v.defaultLayoutDeferred?$e(g):v.layout,M=Tt({group:e,nextGroupSize:b,prevGroupSize:v.groupSize,prevLayout:L}),R=W({layout:M,panelConstraints:g});if(!v.defaultLayoutDeferred&&B(v.layout,R)&&Ot(v.derivedPanelConstraints,g)&&v.groupSize===b)return;$(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:g,groupSize:b,layout:R,separatorToPanels:v.separatorToPanels})}}else Dt(e,y,h)}});s.observe(e.element),e.panels.forEach(f=>{C(!o.has(f.id),`Panel ids must be unique; id "${f.id}" was used more than once`),o.add(f.id),f.onResize&&s.observe(f.element)});const u=te({group:e}),a=me(e),r=e.panels.map(({id:f})=>f).join(",");let l=e.mutableState.defaultLayout;l&&(Gt(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[r]??l??$e(a),m=W({layout:c,panelConstraints:a}),p=e.element.ownerDocument;J.set(p,(J.get(p)??0)+1);const S=new Map;return Be(e).forEach(f=>{f.separator&&S.set(f.separator,f.panels)}),$(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:m,separatorToPanels:S}),e.separators.forEach(f=>{C(!i.has(f.id),`Separator ids must be unique; id "${f.id}" was used more than once`),i.add(f.id),f.element.addEventListener("keydown",Ie)}),J.get(p)===1&&(p.addEventListener("dblclick",ke,!0),p.addEventListener("pointerdown",De,!0),p.addEventListener("pointerleave",Fe),p.addEventListener("pointermove",Ne),p.addEventListener("pointerout",_e),p.addEventListener("pointerup",je,!0)),function(){t=!1,J.set(p,Math.max(0,(J.get(p)??0)-1)),St(e),e.separators.forEach(d=>{d.element.removeEventListener("keydown",Ie)}),J.get(p)||(p.removeEventListener("dblclick",ke,!0),p.removeEventListener("pointerdown",De,!0),p.removeEventListener("pointerleave",Fe),p.removeEventListener("pointermove",Ne),p.removeEventListener("pointerout",_e),p.removeEventListener("pointerup",je,!0)),s.disconnect()}}function Ft(){const[e,t]=x.useState({}),n=x.useCallback(()=>t({}),[]);return[e,n]}function ze(e){const t=x.useId();return`${e??t}`}const X=typeof window<"u"?x.useLayoutEffect:x.useEffect;function ie(e){const t=x.useRef(e);return X(()=>{t.current=e},[e]),x.useCallback((...n)=>t.current?.(...n),[t])}function xe(...e){return ie(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Pe(e){const t=x.useRef({...e});return X(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const nt=x.createContext(null);function Nt(e,t){const n=x.useRef({getLayout:()=>({}),setLayout:kt});x.useImperativeHandle(t,()=>n.current,[]),X(()=>{Object.assign(n.current,Ye({groupId:e}))})}function ot({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:i,elementRef:s,groupRef:u,id:a,onLayoutChange:r,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:p,...S}){const z=x.useRef({onLayoutChange:{},onLayoutChanged:{}}),f=ie(P=>{B(z.current.onLayoutChange,P)||(z.current.onLayoutChange=P,r?.(P))}),d=ie((P,w)=>{B(z.current.onLayoutChanged,P)||(z.current.onLayoutChanged=P,l?.(P,{isUserInteraction:w}))}),h=ze(a),y=x.useRef(null),[b,v]=Ft(),g=x.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),L=xe(y,s);Nt(h,u);const M=ie((P,w)=>{const I=K(),E=Re(P),k=H(P);if(k){let O=!1;switch(I.state){case"active":{O=I.hitRegions.some(V=>V.group===E);break}}return{flexGrow:k.layout[w]??1,pointerEvents:O?"none":void 0}}if(n?.[w])return{flexGrow:n?.[w]}}),R=Pe({defaultLayout:n,disableCursor:o}),G=x.useMemo(()=>({get disableCursor(){return!!R.disableCursor},getPanelStyles:M,id:h,orientation:c,registerPanel:P=>{const w=g.current;return w.panels=ge(c,[...w.panels,P]),v(),()=>{w.panels=w.panels.filter(I=>I!==P),v()}},registerSeparator:P=>{const w=g.current;return w.separators=ge(c,[...w.separators,P]),v(),()=>{w.separators=w.separators.filter(I=>I!==P),v()}},updatePanelProps:(P,{disabled:w})=>{const E=g.current.panels.find(V=>V.id===P);E&&(E.panelConstraints.disabled=w);const k=Re(h),O=H(h);k&&O&&$(k,{...O,derivedPanelConstraints:me(k)})},updateSeparatorProps:(P,{disabled:w,disableDoubleClick:I})=>{const k=g.current.separators.find(O=>O.id===P);k&&(k.disabled=w,k.disableDoubleClick=I)}}),[M,h,v,c,R]),N=x.useRef(null);return X(()=>{const P=y.current;if(P===null)return;const w=g.current;let I;if(R.defaultLayout!==void 0&&Object.keys(R.defaultLayout).length===w.panels.length){I={};for(const _ of w.panels){const Y=R.defaultLayout[_.id];Y!==void 0&&(I[_.id]=Y)}}const E={disabled:!!i,element:P,id:h,mutableState:{defaultLayout:I,disableCursor:!!R.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:c,panels:w.panels,resizeTargetMinimumSize:w.resizeTargetMinimumSize,separators:w.separators};N.current=E;const k=At(E),{defaultLayoutDeferred:O,derivedPanelConstraints:V,layout:ae}=H(E.id,!0);!O&&V.length>0&&(f(ae),d(ae,!1));const ne=ye(h,_=>{const{defaultLayoutDeferred:Y,derivedPanelConstraints:Le,layout:le}=_.next;if(Y||Le.length===0)return;const st=E.panels.map(({id:j})=>j).join(",");E.mutableState.layouts[st]=le,Le.forEach(j=>{if(j.collapsible){const{layout:pe}=_.prev??{};if(pe){const lt=D(j.collapsedSize,le[j.panelId]),ut=D(j.collapsedSize,pe[j.panelId]);lt&&!ut&&(E.mutableState.expandedPanelSizes[j.panelId]=pe[j.panelId])}}});const at=K().state!=="active";f(le),at&&d(le,_.isUserInteraction)});return()=>{N.current=null,k(),ne()}},[i,h,d,f,c,b,R]),x.useEffect(()=>{const P=N.current;P&&(P.mutableState.defaultLayout=n,P.mutableState.disableCursor=!!o)}),re.jsx(nt.Provider,{value:G,children:re.jsx("div",{...S,className:t,"data-group":!0,"data-testid":h,id:h,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}ot.displayName="Group";function de(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function _t({id:e,panelIds:t,storage:n}){const o=de(e,[]),i=n.getItem(o);if(i)try{const s=JSON.parse(i);if(t){const u=t.join(","),a=s[u];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const r={};for(let l=0;l<t.length;l++)r[t[l]]=a.layout[l];return r}}else{const u=Object.keys(s);if(u.length===1){const a=s[u[0]];if(a&&Array.isArray(a.layout)){const r=u[0].split(",");if(r.length===a.layout.length){const l={};for(let c=0;c<r.length;c++)l[r[c]]=a.layout[c];return l}}}}}catch{}}function jt({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...i}){const s=n!==void 0,u="id"in i?i.id:i.groupId,a=de(u,n??[]),r=x.useSyncExternalStore($t,()=>o.getItem(a),()=>o.getItem(a)),l=x.useMemo(()=>{if(r){const d=JSON.parse(r),h=Object.values(d);if(Array.from(h).every(y=>typeof y=="number"))return d}},[r]),c=x.useMemo(()=>{if(!l)return _t({id:u,panelIds:n,storage:o})},[l,u,n,o]),m=l??c,p=x.useRef(null),S=x.useCallback(()=>{const d=p.current;d&&(p.current=null,clearTimeout(d))},[]);x.useLayoutEffect(()=>()=>{S()},[S]);const z=x.useCallback((d,h)=>{if(t&&!h.isUserInteraction)return;S();let y;s?y=de(u,Object.keys(d)):y=de(u,[]);try{o.setItem(y,JSON.stringify(d))}catch(b){console.error(b)}},[S,s,u,t,o]),f=x.useCallback(d=>{S(),e===0?z(d,{isUserInteraction:!1}):p.current=setTimeout(()=>{z(d,{isUserInteraction:!1})},e)},[S,e,z]);return{defaultLayout:m,onLayoutChange:f,onLayoutChanged:z}}function $t(){return function(){}}function Ht(){return x.useState(null)}function Vt(){return x.useRef(null)}function we(){const e=x.useContext(nt);return C(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Ut(e,t){const{id:n}=we(),o=x.useRef({collapse:he,expand:he,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:he});x.useImperativeHandle(t,()=>o.current,[]),X(()=>{Object.assign(o.current,Xe({groupId:n,panelId:e}))})}function it({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:i,disabled:s,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:r,maxSize:l="100%",minSize:c="0%",onResize:m,panelRef:p,style:S,...z}){const f=!!r,d=ze(r),h=Pe({disabled:s}),y=x.useRef(null),b=xe(y,u),{getPanelStyles:v,id:g,orientation:L,registerPanel:M,updatePanelProps:R}=we(),G=m!==null,N=ie((E,k,O)=>{m?.(E,r,O)});X(()=>{const E=y.current;if(E!==null){const k={element:E,id:d,idIsStable:f,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?N:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:i,disabled:h.disabled,maxSize:l,minSize:c}};return M(k)}},[a,n,o,i,G,d,f,l,c,N,M,h]),x.useEffect(()=>{R(d,{disabled:s})},[s,d,R]),Ut(d,p);const P=()=>{const E=v(g,d);if(E)return JSON.stringify(E)},w=x.useSyncExternalStore(E=>ye(g,E),P,P);let I;return w?I=JSON.parse(w):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},re.jsx("div",{...z,"data-disabled":s||void 0,"data-panel":!0,"data-testid":d,id:d,ref:b,style:{...Bt,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:re.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...S,touchAction:L==="horizontal"?"pan-y":"pan-x"},children:e})})}it.displayName="Panel";const Bt={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Wt(){return x.useState(null)}function Kt(){return x.useRef(null)}function qt({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let i,s;const u=e[n],a=t.find(r=>r.panelId===n);if(a){const r=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];s=W({layout:se({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],i=W({layout:se({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:u}}function rt({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:i,id:s,style:u,...a}){const r=ze(s),l=Pe({disabled:n,disableDoubleClick:o}),[c,m]=x.useState({}),[p,S]=x.useState("inactive"),[z,f]=x.useState(!1),d=x.useRef(null),h=xe(d,i),{disableCursor:y,id:b,orientation:v,registerSeparator:g,updateSeparatorProps:L}=we(),M=v==="horizontal"?"vertical":"horizontal";X(()=>{const N=d.current;if(N!==null){const P={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:N,id:r},w=g(P),I=Et(k=>{S(k.next.state!=="inactive"&&k.next.hitRegions.some(O=>O.separator===P)?k.next.state:"inactive")}),E=ye(b,k=>{const{derivedPanelConstraints:O,layout:V,separatorToPanels:ae}=k.next,ne=ae.get(P);if(ne){const _=ne[0],Y=ne.indexOf(_);m(qt({layout:V,panelConstraints:O,panelId:_.id,panelIndex:Y}))}});return()=>{I(),E(),w()}}},[b,r,g,l]),x.useEffect(()=>{L(r,{disabled:n,disableDoubleClick:o})},[n,o,r,L]);let R;n&&!y&&(R="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:z?G="focus":G=p}return re.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":M,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":r,id:r,onBlur:()=>f(!1),onFocus:()=>f(!0),ref:h,role:"separator",style:{flexBasis:"auto",cursor:R,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}rt.displayName="Separator";exports.Group=ot;exports.Panel=it;exports.Separator=rt;exports.isCoarsePointer=Ue;exports.useDefaultLayout=jt;exports.useGroupCallbackRef=Ht;exports.useGroupRef=Vt;exports.usePanelCallbackRef=Wt;exports.usePanelRef=Kt;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("react/jsx-runtime"),z=require("react");function dt(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function pt(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function ht(e){return e/100*window.innerHeight}function mt(e){return e/100*window.innerWidth}function gt(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function oe({groupSize:e,panelElement:t,styleProp:n}){let o;const[i,s]=gt(n);switch(s){case"%":{o=i/100*e;break}case"px":{o=i;break}case"rem":{o=pt(t,i);break}case"em":{o=dt(t,i);break}case"vh":{o=ht(i);break}case"vw":{o=mt(i);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function te({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,i)=>(o+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,o),0)}function me(e){const{panels:t}=e,n=te({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:i,panelConstraints:s}=o;let u=0;if(s.collapsedSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.collapsedSize});u=O(c/n*100)}let a;if(s.defaultSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=O(c/n*100)}let r=0;if(s.minSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.minSize});r=O(c/n*100)}let l=100;if(s.maxSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.maxSize});l=O(c/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:r,maxSize:l,panelId:o.id}})}function C(e,t="Assertion error"){if(!e)throw Error(t)}function ge(e,t){return Array.from(t).sort(e==="horizontal"?yt:St)}function yt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function St(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Ve(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ue(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function vt({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const u of t){const{x:a,y:r}=Ue(o,u),l=e==="horizontal"?a:r;l<s&&(s=l,i=u)}return C(i,"No rect found"),i}let ue;function Be(){return ue===void 0&&(typeof matchMedia=="function"?ue=!!matchMedia("(pointer:coarse)").matches:ue=!1),ue}function We(e){const{element:t,orientation:n,panels:o,separators:i}=e,s=ge(n,Array.from(t.children).filter(Ve).map(x=>({element:x}))).map(({element:x})=>x),u=[];let a=!1,r=!1,l=-1,c=-1,m=0,p,S=[];{let x=-1;for(const f of s)f.hasAttribute("data-panel")&&(x++,f.hasAttribute("data-disabled")||(m++,l===-1&&(l=x),c=x))}if(m>1){let x=-1;for(const f of s)if(f.hasAttribute("data-panel")){x++;const d=o.find(h=>h.element===f);if(d){if(p){const h=p.element.getBoundingClientRect(),y=f.getBoundingClientRect();let b;if(r){const v=n==="horizontal"?new DOMRect(h.right,h.top,0,h.height):new DOMRect(h.left,h.bottom,h.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(S.length){case 0:{b=[v,g];break}case 1:{const L=S[0],M=vt({orientation:n,rects:[h,y],targetRect:L.element.getBoundingClientRect()});b=[L,M===h?g:v];break}default:{b=S;break}}}else S.length?b=S:b=[n==="horizontal"?new DOMRect(h.right,y.top,y.left-h.right,y.height):new DOMRect(y.left,h.bottom,y.width,y.top-h.bottom)];for(const v of b){let g="width"in v?v:v.element.getBoundingClientRect();const L=Be()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<L){const R=L-g.width;g=new DOMRect(g.x-R/2,g.y,g.width+R,g.height)}if(g.height<L){const R=L-g.height;g=new DOMRect(g.x,g.y-R/2,g.width,g.height+R)}const M=x<=l||x>c;!a&&!M&&u.push({group:e,groupSize:te({group:e}),panels:[p,d],separator:"width"in v?void 0:v,rect:g}),a=!1}}r=!1,p=d,S=[]}}else if(f.hasAttribute("data-separator")){f.ariaDisabled!==null&&(a=!0);const d=i.find(h=>h.element===f);d?S.push(d):(p=void 0,S=[])}else r=!0}return u}class Ke{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let i=!1,s=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const r=u[a];try{r.call(null,n)}catch(l){s===null&&(i=!0,s=l)}}if(i)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const i=o.indexOf(n);i>=0&&o.splice(i,1)}}}let Q={cursorFlags:0,state:"inactive"};const ye=new Ke;function B(){return Q}function bt(e){return ye.addListener("change",e)}function xt(e){const t=Q,n={...Q};n.cursorFlags=e,Q=n,ye.emit("change",{prev:t,next:n})}function ee(e){const t=Q;Q=e,ye.emit("change",{prev:t,next:e})}const zt=e=>e,he=()=>{},qe=1,Xe=2,Ye=4,Je=8,Re=3,Ce=12;let ce;function Ee(){return ce===void 0&&(ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(ce=!0)),ce}function Pt({cursorFlags:e,groups:t,state:n}){let o=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{i++;break}}})}if(!(o===0&&i===0)){switch(n){case"active":{if(e&&Ee()){const s=(e&qe)!==0,u=(e&Xe)!==0,a=(e&Ye)!==0,r=(e&Je)!==0;if(s)return a?"se-resize":r?"ne-resize":"e-resize";if(u)return a?"sw-resize":r?"nw-resize":"w-resize";if(a)return"s-resize";if(r)return"n-resize"}break}}return Ee()?o>0&&i>0?"move":o>0?"ew-resize":"ns-resize":o>0&&i>0?"grab":o>0?"col-resize":"row-resize"}}const Me=new WeakMap;function Se(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Me.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=B();switch(o.state){case"active":case"hover":{const i=Pt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Me.set(e,{prevStyle:t,styleSheet:n})}let F=new Map;const Ze=new Ke;function wt(e){F=new Map(F),F.delete(e)}function ke(e,t){for(const[n]of F)if(n.id===e)return n}function H(e,t){for(const[n,o]of F)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function q(){return F}function ve(e,t){return Ze.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function $(e,t,n){const o=F.get(e);F=new Map(F),F.set(e,t),Ze.emit("groupChange",{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t})}function Qe(e){const t=B();let n=!1;switch(t.state){case"active":ee({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Se(e),n=!0,t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})}))}return n}function Ie(e){e.defaultPrevented||Qe(e.currentTarget)}function Lt(e,t,n){let o,i={x:1/0,y:1/0};for(const s of t){const u=Ue(n,s.rect);switch(e){case"horizontal":{u.x<=i.x&&(o=s,i=u);break}case"vertical":{u.y<=i.y&&(o=s,i=u);break}}}return o?{distance:i,hitRegion:o}:void 0}function Rt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ct(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Oe(e),b:Oe(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();C(o,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Te(De(n.a)),b:Te(De(n.b))};if(i.a===i.b){const s=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const r=s[a];if(r===u.a)return 1;if(r===u.b)return-1}}return Math.sign(i.a-i.b)}const Et=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mt(e){const t=getComputedStyle(et(e)??e).display;return t==="flex"||t==="inline-flex"}function kt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Et.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function De(e){let t=e.length;for(;t--;){const n=e[t];if(C(n,"Missing node"),kt(n))return n}return null}function Te(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Oe(e){const t=[];for(;e;)t.push(e),e=et(e);return t}function et(e){const{parentNode:t}=e;return Rt(t)?t.host:t}function It(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Dt({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ve(n)||n.contains(e)||e.contains(n))return!0;if(Ct(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(It(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function be(e,t){const n=[];return t.forEach((o,i)=>{if(i.disabled)return;const s=We(i),u=Lt(i.orientation,s,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Dt({groupElement:i.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function Tt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function D(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function A(e,t){return D(e,t)?0:e>t?1:-1}function Z({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:i=0,collapsible:s,disabled:u,maxSize:a=100,minSize:r=0}=t;if(u&&!e)return n;if(A(o,r)<0)if(s){const l=(i+r)/2;A(o,l)<0?o=i:o=r}else o=r;return o=Math.min(a,o),o=O(o),o}function se({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:i,trigger:s}){if(D(e,0))return t;const u=s==="imperative-api",a=Object.values(t),r=Object.values(i),l=[...a],[c,m]=o;C(c!=null,"Invalid first pivot index"),C(m!=null,"Invalid second pivot index");let p=0;switch(s){case"keyboard":{{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,h)){const g=b-v;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const f=e<0?c:m,d=n[f];C(d,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,b)){const g=v-h;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const h=a[f],{collapsible:y,collapsedSize:b,minSize:v}=d;if(y&&A(h,v)<0)if(e>0){const g=v-b,L=g/2,M=h+e;A(M,v)<0&&(e=A(e,L)<=0?0:g)}else{const g=v-b,L=100-g/2,M=h-e;A(M,v)<0&&(e=A(100+e,L)>0?0:-g)}break}}{const f=e<0?1:-1;let d=e<0?m:c,h=0;for(;;){const b=a[d];C(b!=null,`Previous layout not found for panel index ${d}`);const g=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:b,size:100})-b;if(h+=g,d+=f,d<0||d>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-y:y}{let d=e<0?c:m;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(p),y=a[d];C(y!=null,`Previous layout not found for panel index ${d}`);const b=y-h,v=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:y,size:b});if(!D(y,v)&&(p+=y-v,l[d]=v,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(Tt(r,l))return i;{const f=e<0?m:c,d=a[f];C(d!=null,`Previous layout not found for panel index ${f}`);const h=d+p,y=Z({overrideDisabledPanels:u,panelConstraints:n[f],prevSize:d,size:h});if(l[f]=y,!D(y,h)){let b=h-y,g=e<0?m:c;for(;g>=0&&g<n.length;){const L=l[g];C(L!=null,`Previous layout not found for panel index ${g}`);const M=L+b,R=Z({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:L,size:M});if(D(L,R)||(b-=R-L,l[g]=R),D(b,0))break;e>0?g--:g++}}}const S=Object.values(l).reduce((f,d)=>d+f,0);if(!D(S,100,.1))return i;const x=Object.keys(i);return l.reduce((f,d,h)=>(f[x[h]]=d,f),{})}function W(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||A(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],i=o.reduce((a,r)=>a+r,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(a=>`${a}%`).join(", ")}`);if(!D(i,100)&&o.length>0)for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=100/i*r;o[a]=l}let s=0;for(let a=0;a<t.length;a++){const r=n[a];C(r!=null,`No layout data found for index ${a}`);const l=o[a];C(l!=null,`No layout data found for index ${a}`);const c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});l!=c&&(s+=l-c,o[a]=c)}if(!D(s,0))for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=r+s,c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});if(r!==c&&(s-=c-r,o[a]=c,D(s,0)))break}const u=Object.keys(e);return o.reduce((a,r,l)=>(a[u[l]]=r,a),{})}function tt({groupId:e,panelId:t}){const n=()=>{const r=q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:m,layout:p,groupSize:S,separatorToPanels:x}]of r)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:l,groupSize:S,layout:p,separatorToPanels:x};throw Error(`Group ${e} not found`)},o=()=>{const r=n().derivedPanelConstraints.find(l=>l.panelId===t);if(r!==void 0)return r;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const r=n().group.panels.find(l=>l.id===t);if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const r=n().layout[t];if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:r,panels:l,prevLayout:c,derivedPanelConstraints:m})=>{const p=s(),S=l.findIndex(h=>h.id===t),x=S===0,f=S===l.length-1;if(f&&r<p&&(x||l.slice(0,S).every((h,y)=>{const b=m[y];return b?.collapsible&&D(b.collapsedSize,c[b.panelId])}))){const h=l.slice(0,S).reduce((y,b)=>y+c[b.id],0);return{...c,[t]:O(100-h)}}return se({delta:f?p-r:r-p,initialLayout:c,panelConstraints:m,pivotIndices:f?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"})},a=r=>{const l=s();if(r===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:p,groupSize:S,layout:x,separatorToPanels:f}=n(),d=u({nextSize:r,panels:p.panels,prevLayout:x,derivedPanelConstraints:m}),h=K({layout:d,panelConstraints:m});W(x,h)||$(p,{defaultLayoutDeferred:c,derivedPanelConstraints:m,groupSize:S,layout:h,separatorToPanels:f})};return{collapse:()=>{const{collapsible:r,collapsedSize:l}=o(),{mutableValues:c}=i(),m=s();r&&m!==l&&(c.expandToSize=m,a(l))},expand:()=>{const{collapsible:r,collapsedSize:l,minSize:c}=o(),{mutableValues:m}=i(),p=s();if(r&&p===l){let S=m.expandToSize??c;S===0&&(S=1),a(S)}},getSize:()=>{const{group:r}=n(),l=s(),{element:c}=i(),m=r.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:r,collapsedSize:l}=o(),c=s();return r&&D(l,c)},resize:r=>{const{group:l}=n(),{element:c}=i(),m=te({group:l}),p=oe({groupSize:m,panelElement:c,styleProp:r}),S=O(p/m*100);a(S)}}}function Ge(e){if(e.defaultPrevented)return;const t=q();be(e,t).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const i=o.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(i){const s=i.panelConstraints.defaultSize,u=tt({groupId:o.group.id,panelId:i.id});u&&s!==void 0&&(u.resize(s),e.preventDefault())}}})}function fe(e){const t=q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function nt({groupId:e}){const t=()=>{const n=q();for(const[o,i]of n)if(o.id===e)return{group:o,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:i,group:s,groupSize:u,layout:a,separatorToPanels:r}=t(),l=K({layout:n,panelConstraints:i});return o?a:(W(a,l)||$(s,{defaultLayoutDeferred:o,derivedPanelConstraints:i,groupSize:u,layout:l,separatorToPanels:r}),l)}}}function U(e,t){const n=fe(e),o=H(n.id,!0),i=n.separators.find(m=>m.element===e);C(i,"Matching separator not found");const s=o.separatorToPanels.get(i);C(s,"Matching panels not found");const u=s.map(m=>n.panels.indexOf(m)),r=nt({groupId:n.id}).getLayout(),l=se({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=K({layout:l,panelConstraints:o.derivedPanelConstraints});W(r,c)||$(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:c,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function Ae(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=fe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&U(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&U(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&U(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&U(t,-5);break}case"End":{e.preventDefault(),U(t,100);break}case"Enter":{e.preventDefault();const o=fe(t),i=H(o.id,!0),{derivedPanelConstraints:s,layout:u,separatorToPanels:a}=i,r=o.separators.find(p=>p.element===t);C(r,"Matching separator not found");const l=a.get(r);C(l,"Matching panels not found");const c=l[0],m=s.find(p=>p.panelId===c.id);if(C(m,"Panel metadata not found"),m.collapsible){const p=u[c.id],S=m.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??m.minSize:m.collapsedSize;U(t,S-p)}break}case"F6":{e.preventDefault();const i=fe(t).separators.map(r=>r.element),s=Array.from(i).findIndex(r=>r===e.currentTarget);C(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:i.length-1:s+1<i.length?s+1:0;i[u].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),U(t,-100);break}}}function Fe(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=q(),n=be(e,t),o=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(s.group);u&&o.set(s.group,u.layout)}),ee({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function ot({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:m}=l,{orientation:p,panels:S}=c,{disableCursor:x}=c.mutableState;let f=0;s?p==="horizontal"?f=(t.clientX-s.x)/m*100:f=(t.clientY-s.y)/m*100:p==="horizontal"?f=t.clientX<0?-100:100:f=t.clientY<0?-100:100;const d=o.get(c),h=i.get(c);if(!d||!h)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:g,separatorToPanels:L}=h;if(b&&g&&L){const M=se({delta:f,initialLayout:d,panelConstraints:b,pivotIndices:l.panels.map(R=>S.indexOf(R)),prevLayout:g,trigger:"mouse-or-touch"});if(W(M,g)){if(f!==0&&!x)switch(p){case"horizontal":{a|=f<0?qe:Xe;break}case"vertical":{a|=f<0?Ye:Je;break}}}else $(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:M,separatorToPanels:L})}});let r=0;t.movementX===0?r|=u&Re:r|=a&Re,t.movementY===0?r|=u&Ce:r|=a&Ce,xt(r),Se(e)}function Ne(e){const t=q(),n=B();switch(n.state){case"active":ot({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function _e(e){if(e.defaultPrevented)return;const t=B(),n=q();switch(t.state){case"active":{if(e.buttons===0){ee({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})});return}for(const o of t.hitRegions)if(o.separator){const{element:i}=o.separator;i.hasPointerCapture?.(e.pointerId)||i.setPointerCapture?.(e.pointerId)}ot({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=be(e,n);o.length===0?t.state!=="inactive"&&ee({cursorFlags:0,state:"inactive"}):ee({cursorFlags:0,hitRegions:o,state:"hover"}),Se(e.currentTarget);break}}}function je(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(B().state){case"hover":ee({cursorFlags:0,state:"inactive"})}}function $e(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;Qe(e.currentTarget)&&e.preventDefault()}function He(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=O(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=O((100-n)/i);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Ot(e,t,n){if(!n[0])return;const i=e.panels.find(l=>l.element===t);if(!i||!i.onResize)return;const s=te({group:e}),u=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,r={asPercentage:O(u/s*100),inPixels:u};i.mutableValues.prevSize=r,i.onResize(r,i.id,a)}function Gt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function At({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let i=0,s=0,u=!1;const a=new Map,r=[];for(const m of e.panels){const p=o[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const S=p/100*n,x=O(S/t*100);a.set(m.id,x),i+=x;break}case"preserve-relative-size":default:{r.push(m.id),s+=p;break}}}if(!u||r.length===0)return o;const l=100-i,c={...o};if(a.forEach((m,p)=>{c[p]=m}),s>0)for(const m of r){const p=o[m]??0;c[m]=O(p/s*l)}else{const m=O(l/r.length);for(const p of r)c[p]=m}return c}function Ft(e,t){const n=e.map(i=>i.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i))return!1;return!0}const J=new Map;function Nt(e){let t=!0;C(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,i=new Set,s=new n(f=>{for(const d of f){const{borderBoxSize:h,target:y}=d;if(y===e.element){if(t){const b=te({group:e});if(b===0)return;const v=H(e.id);if(!v)return;const g=me(e),L=v.defaultLayoutDeferred?He(g):v.layout,M=At({group:e,nextGroupSize:b,prevGroupSize:v.groupSize,prevLayout:L}),R=K({layout:M,panelConstraints:g});if(!v.defaultLayoutDeferred&&W(v.layout,R)&&Gt(v.derivedPanelConstraints,g)&&v.groupSize===b)return;$(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:g,groupSize:b,layout:R,separatorToPanels:v.separatorToPanels})}}else Ot(e,y,h)}});s.observe(e.element),e.panels.forEach(f=>{C(!o.has(f.id),`Panel ids must be unique; id "${f.id}" was used more than once`),o.add(f.id),f.onResize&&s.observe(f.element)});const u=te({group:e}),a=me(e),r=e.panels.map(({id:f})=>f).join(",");let l=e.mutableState.defaultLayout;l&&(Ft(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[r]??l??He(a),m=K({layout:c,panelConstraints:a}),p=e.element.ownerDocument;J.set(p,(J.get(p)??0)+1);const S=new Map;return We(e).forEach(f=>{f.separator&&S.set(f.separator,f.panels)}),$(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:m,separatorToPanels:S}),e.separators.forEach(f=>{C(!i.has(f.id),`Separator ids must be unique; id "${f.id}" was used more than once`),i.add(f.id),f.element.addEventListener("keydown",Ae)}),J.get(p)===1&&(p.addEventListener("contextmenu",Ie,!0),p.addEventListener("dblclick",Ge,!0),p.addEventListener("pointerdown",Fe,!0),p.addEventListener("pointerleave",Ne),p.addEventListener("pointermove",_e),p.addEventListener("pointerout",je),p.addEventListener("pointerup",$e,!0)),function(){t=!1,J.set(p,Math.max(0,(J.get(p)??0)-1)),wt(e),e.separators.forEach(d=>{d.element.removeEventListener("keydown",Ae)}),J.get(p)||(p.removeEventListener("contextmenu",Ie,!0),p.removeEventListener("dblclick",Ge,!0),p.removeEventListener("pointerdown",Fe,!0),p.removeEventListener("pointerleave",Ne),p.removeEventListener("pointermove",_e),p.removeEventListener("pointerout",je),p.removeEventListener("pointerup",$e,!0)),s.disconnect()}}function _t(){const[e,t]=z.useState({}),n=z.useCallback(()=>t({}),[]);return[e,n]}function xe(e){const t=z.useId();return`${e??t}`}const X=typeof window<"u"?z.useLayoutEffect:z.useEffect;function ie(e){const t=z.useRef(e);return X(()=>{t.current=e},[e]),z.useCallback((...n)=>t.current?.(...n),[t])}function ze(...e){return ie(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Pe(e){const t=z.useRef({...e});return X(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const it=z.createContext(null);function jt(e,t){const n=z.useRef({getLayout:()=>({}),setLayout:zt});z.useImperativeHandle(t,()=>n.current,[]),X(()=>{Object.assign(n.current,nt({groupId:e}))})}function rt({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:i,elementRef:s,groupRef:u,id:a,onLayoutChange:r,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:p,...S}){const x=z.useRef({onLayoutChange:{},onLayoutChanged:{}}),f=ie(P=>{W(x.current.onLayoutChange,P)||(x.current.onLayoutChange=P,r?.(P))}),d=ie((P,w)=>{W(x.current.onLayoutChanged,P)||(x.current.onLayoutChanged=P,l?.(P,{isUserInteraction:w}))}),h=xe(a),y=z.useRef(null),[b,v]=_t(),g=z.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),L=ze(y,s);jt(h,u);const M=ie((P,w)=>{const I=B(),E=ke(P),k=H(P);if(k){let T=!1;switch(I.state){case"active":{T=I.hitRegions.some(V=>V.group===E);break}}return{flexGrow:k.layout[w]??1,pointerEvents:T?"none":void 0}}if(n?.[w])return{flexGrow:n?.[w]}}),R=Pe({defaultLayout:n,disableCursor:o}),G=z.useMemo(()=>({get disableCursor(){return!!R.disableCursor},getPanelStyles:M,id:h,orientation:c,registerPanel:P=>{const w=g.current;return w.panels=ge(c,[...w.panels,P]),v(),()=>{w.panels=w.panels.filter(I=>I!==P),v()}},registerSeparator:P=>{const w=g.current;return w.separators=ge(c,[...w.separators,P]),v(),()=>{w.separators=w.separators.filter(I=>I!==P),v()}},updatePanelProps:(P,{disabled:w})=>{const E=g.current.panels.find(V=>V.id===P);E&&(E.panelConstraints.disabled=w);const k=ke(h),T=H(h);k&&T&&$(k,{...T,derivedPanelConstraints:me(k)})},updateSeparatorProps:(P,{disabled:w,disableDoubleClick:I})=>{const k=g.current.separators.find(T=>T.id===P);k&&(k.disabled=w,k.disableDoubleClick=I)}}),[M,h,v,c,R]),N=z.useRef(null);return X(()=>{const P=y.current;if(P===null)return;const w=g.current;let I;if(R.defaultLayout!==void 0&&Object.keys(R.defaultLayout).length===w.panels.length){I={};for(const _ of w.panels){const Y=R.defaultLayout[_.id];Y!==void 0&&(I[_.id]=Y)}}const E={disabled:!!i,element:P,id:h,mutableState:{defaultLayout:I,disableCursor:!!R.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:c,panels:w.panels,resizeTargetMinimumSize:w.resizeTargetMinimumSize,separators:w.separators};N.current=E;const k=Nt(E),{defaultLayoutDeferred:T,derivedPanelConstraints:V,layout:ae}=H(E.id,!0);!T&&V.length>0&&(f(ae),d(ae,!1));const ne=ve(h,_=>{const{defaultLayoutDeferred:Y,derivedPanelConstraints:Le,layout:le}=_.next;if(Y||Le.length===0)return;const lt=E.panels.map(({id:j})=>j).join(",");E.mutableState.layouts[lt]=le,Le.forEach(j=>{if(j.collapsible){const{layout:pe}=_.prev??{};if(pe){const ct=D(j.collapsedSize,le[j.panelId]),ft=D(j.collapsedSize,pe[j.panelId]);ct&&!ft&&(E.mutableState.expandedPanelSizes[j.panelId]=pe[j.panelId])}}});const ut=B().state!=="active";f(le),ut&&d(le,_.isUserInteraction)});return()=>{N.current=null,k(),ne()}},[i,h,d,f,c,b,R]),z.useEffect(()=>{const P=N.current;P&&(P.mutableState.defaultLayout=n,P.mutableState.disableCursor=!!o)}),re.jsx(it.Provider,{value:G,children:re.jsx("div",{...S,className:t,"data-group":!0,"data-testid":h,id:h,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}rt.displayName="Group";function de(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function $t({id:e,panelIds:t,storage:n}){const o=de(e,[]),i=n.getItem(o);if(i)try{const s=JSON.parse(i);if(t){const u=t.join(","),a=s[u];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const r={};for(let l=0;l<t.length;l++)r[t[l]]=a.layout[l];return r}}else{const u=Object.keys(s);if(u.length===1){const a=s[u[0]];if(a&&Array.isArray(a.layout)){const r=u[0].split(",");if(r.length===a.layout.length){const l={};for(let c=0;c<r.length;c++)l[r[c]]=a.layout[c];return l}}}}}catch{}}function Ht({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...i}){const s=n!==void 0,u="id"in i?i.id:i.groupId,a=de(u,n??[]),r=z.useSyncExternalStore(Vt,()=>o.getItem(a),()=>o.getItem(a)),l=z.useMemo(()=>{if(r){const d=JSON.parse(r),h=Object.values(d);if(Array.from(h).every(y=>typeof y=="number"))return d}},[r]),c=z.useMemo(()=>{if(!l)return $t({id:u,panelIds:n,storage:o})},[l,u,n,o]),m=l??c,p=z.useRef(null),S=z.useCallback(()=>{const d=p.current;d&&(p.current=null,clearTimeout(d))},[]);z.useLayoutEffect(()=>()=>{S()},[S]);const x=z.useCallback((d,h)=>{if(t&&!h.isUserInteraction)return;S();let y;s?y=de(u,Object.keys(d)):y=de(u,[]);try{o.setItem(y,JSON.stringify(d))}catch(b){console.error(b)}},[S,s,u,t,o]),f=z.useCallback(d=>{S(),e===0?x(d,{isUserInteraction:!1}):p.current=setTimeout(()=>{x(d,{isUserInteraction:!1})},e)},[S,e,x]);return{defaultLayout:m,onLayoutChange:f,onLayoutChanged:x}}function Vt(){return function(){}}function Ut(){return z.useState(null)}function Bt(){return z.useRef(null)}function we(){const e=z.useContext(it);return C(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Wt(e,t){const{id:n}=we(),o=z.useRef({collapse:he,expand:he,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:he});z.useImperativeHandle(t,()=>o.current,[]),X(()=>{Object.assign(o.current,tt({groupId:n,panelId:e}))})}function st({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:i,disabled:s,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:r,maxSize:l="100%",minSize:c="0%",onResize:m,panelRef:p,style:S,...x}){const f=!!r,d=xe(r),h=Pe({disabled:s}),y=z.useRef(null),b=ze(y,u),{getPanelStyles:v,id:g,orientation:L,registerPanel:M,updatePanelProps:R}=we(),G=m!==null,N=ie((E,k,T)=>{m?.(E,r,T)});X(()=>{const E=y.current;if(E!==null){const k={element:E,id:d,idIsStable:f,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?N:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:i,disabled:h.disabled,maxSize:l,minSize:c}};return M(k)}},[a,n,o,i,G,d,f,l,c,N,M,h]),z.useEffect(()=>{R(d,{disabled:s})},[s,d,R]),Wt(d,p);const P=()=>{const E=v(g,d);if(E)return JSON.stringify(E)},w=z.useSyncExternalStore(E=>ve(g,E),P,P);let I;return w?I=JSON.parse(w):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},re.jsx("div",{...x,"data-disabled":s||void 0,"data-panel":!0,"data-testid":d,id:d,ref:b,style:{...Kt,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:re.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...S,touchAction:L==="horizontal"?"pan-y":"pan-x"},children:e})})}st.displayName="Panel";const Kt={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function qt(){return z.useState(null)}function Xt(){return z.useRef(null)}function Yt({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let i,s;const u=e[n],a=t.find(r=>r.panelId===n);if(a){const r=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];s=K({layout:se({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],i=K({layout:se({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:u}}function at({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:i,id:s,style:u,...a}){const r=xe(s),l=Pe({disabled:n,disableDoubleClick:o}),[c,m]=z.useState({}),[p,S]=z.useState("inactive"),[x,f]=z.useState(!1),d=z.useRef(null),h=ze(d,i),{disableCursor:y,id:b,orientation:v,registerSeparator:g,updateSeparatorProps:L}=we(),M=v==="horizontal"?"vertical":"horizontal";X(()=>{const N=d.current;if(N!==null){const P={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:N,id:r},w=g(P),I=bt(k=>{S(k.next.state!=="inactive"&&k.next.hitRegions.some(T=>T.separator===P)?k.next.state:"inactive")}),E=ve(b,k=>{const{derivedPanelConstraints:T,layout:V,separatorToPanels:ae}=k.next,ne=ae.get(P);if(ne){const _=ne[0],Y=ne.indexOf(_);m(Yt({layout:V,panelConstraints:T,panelId:_.id,panelIndex:Y}))}});return()=>{I(),E(),w()}}},[b,r,g,l]),z.useEffect(()=>{L(r,{disabled:n,disableDoubleClick:o})},[n,o,r,L]);let R;n&&!y&&(R="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:x?G="focus":G=p}return re.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":M,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":r,id:r,onBlur:()=>f(!1),onFocus:()=>f(!0),ref:h,role:"separator",style:{flexBasis:"auto",cursor:R,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}at.displayName="Separator";exports.Group=rt;exports.Panel=st;exports.Separator=at;exports.isCoarsePointer=Be;exports.useDefaultLayout=Ht;exports.useGroupCallbackRef=Ut;exports.useGroupRef=Bt;exports.usePanelCallbackRef=qt;exports.usePanelRef=Xt;
|
|
2
2
|
//# sourceMappingURL=react-resizable-panels.cjs.map
|