@limrun/ui 0.20.5 → 0.20.6

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 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),u=require("react"),E=require("./core-OsPKiOsB.js");function Y(e,o,n){const[i,a]=u.useState(e),s=u.useRef({nativeAngle:e,send:o,failed:n});s.current={nativeAngle:e,send:o,failed:n};const l=u.useRef(void 0),x=u.useRef(!1),d=u.useRef(null);return u.useEffect(()=>(d.current=new E.HingeSender(async h=>{await s.current.send(h),l.current===h&&(l.current=void 0)},h=>{l.current=void 0,s.current.failed(String(h)),a(s.current.nativeAngle)}),()=>d.current?.stop()),[]),u.useEffect(()=>{!x.current&&l.current===void 0&&a(e)},[e]),{angle:i,changeAngle:h=>{s.current.failed(void 0),l.current=h,a(h),d.current?.set(h)},interacting:x}}function $({angle:e,watchOnly:o=!1,changeAngle:n,interacting:i,rotate:a,onFold:s,foldTarget:l,onHingeDrag:x,children:d}){const f=u.useId();return r.jsxs("div",{className:"rc-duo-controls",onPointerDown:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"rc-duo-hinge",children:[r.jsx("button",{disabled:o,className:"rc-duo-fold",onClick:s??(()=>n(e<90?180:0)),children:(l??e)<90?"Unfold":"Fold"}),r.jsx("label",{htmlFor:f,children:"Hinge"}),r.jsx("input",{id:f,type:"range",disabled:o,min:0,max:180,step:1,value:e,onPointerDown:h=>{x?.(),i.current=!0,h.currentTarget.setPointerCapture(h.pointerId)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},onLostPointerCapture:()=>{i.current=!1},onChange:h=>n(Number(h.target.value))}),r.jsxs("output",{children:[Math.round(e),"°"]}),r.jsx("button",{disabled:o,className:"rc-duo-rotate","aria-label":"Rotate device",title:"Rotate device",onClick:a,children:r.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[r.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9a9 9 0 0 1 3-5M3 4v5h5M21 15a9 9 0 0 1-3 5m3 0v-5h-5"})]})})]}),d&&r.jsx("div",{className:"rc-duo-views","aria-label":"Device view",children:d})]})}function G({button:e}){return r.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="side"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"6",y:"10",width:"12",height:"11",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}):r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 9h4l5-5v16l-5-5H3zM17 12h5"}),e==="volumeUp"&&r.jsx("path",{d:"M19.5 9.5v5"})]})})}function B(e,o,n,i,a,s){return"M"+(e+a)+","+o+"H"+(e+n-s)+"a"+s+","+s+" 0 0 1 "+s+","+s+"V"+(o+i-s)+"a"+s+","+s+" 0 0 1 "+-s+","+s+"H"+(e+a)+"a"+a+","+a+" 0 0 1 "+-a+","+-a+"V"+(o+a)+"a"+a+","+a+" 0 0 1 "+a+","+-a+"Z"}function A({inner:e,width:o,height:n}){const i=u.useId().replace(/:/g,""),a=e?8.4:1.25,s=8.4;return r.jsxs("svg",{className:"rc-duo-flat-frame",viewBox:"0 0 "+o+" "+n,"aria-hidden":"true",children:[r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:i+"-silver",x1:"0",y1:"0",x2:"1",y2:"1",children:[r.jsx("stop",{offset:"0",stopColor:"#62676b"}),r.jsx("stop",{offset:"0.035",stopColor:"#f9faf9"}),r.jsx("stop",{offset:"0.11",stopColor:"#b0b4b6"}),r.jsx("stop",{offset:"0.31",stopColor:"#fdfefd"}),r.jsx("stop",{offset:"0.43",stopColor:"#797f84"}),r.jsx("stop",{offset:"0.51",stopColor:"#e8eaea"}),r.jsx("stop",{offset:"0.7",stopColor:"#979da1"}),r.jsx("stop",{offset:"0.87",stopColor:"#fafbf9"}),r.jsx("stop",{offset:"1",stopColor:"#5f676c"})]}),r.jsxs("linearGradient",{id:i+"-spine",children:[r.jsx("stop",{stopColor:"#4a5154"}),r.jsx("stop",{offset:"0.16",stopColor:"#d6d9d9"}),r.jsx("stop",{offset:"0.4",stopColor:"#f8f9f7"}),r.jsx("stop",{offset:"0.62",stopColor:"#a2a8ab"}),r.jsx("stop",{offset:"0.83",stopColor:"#e4e7e5"}),r.jsx("stop",{offset:"1",stopColor:"#666e72"})]})]}),!e&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"-2.3",y:"0.7",width:"3.3",height:n-1.4,rx:"0.85",fill:"url(#"+i+"-spine)",stroke:"#8b9296",strokeWidth:"0.15"}),r.jsx("path",{d:"M-.6 2V"+(n-2),stroke:"#f5f6f4",strokeWidth:"0.22"})]}),r.jsx("path",{d:B(0,0,o,n,a,s),fill:"url(#"+i+"-silver)",stroke:"#696f72",strokeWidth:"0.24"}),r.jsx("path",{d:B(.48,.48,o-.96,n-.96,Math.max(.5,a-.48),s-.48),fill:"none",stroke:"#ffffff",strokeOpacity:"0.85",strokeWidth:"0.2"}),r.jsx("path",{d:B(1.12,1.12,o-2.24,n-2.24,e?7.15:.65,7.15),fill:"#090b0d",stroke:"#34393c",strokeWidth:"0.2"}),[o-16,e?19:16].map(l=>r.jsx(u.Fragment,{children:r.jsx("path",{d:"M"+l+",0.17v0.82M"+l+","+(n-1)+"v0.82",stroke:"#b1b2ac",strokeWidth:"1.1"})},l)),e&&[0,n-.6].map(l=>r.jsx("rect",{x:o/2-2.2,y:l,width:"4.4",height:"0.6",rx:"0.18",fill:"url(#"+i+"-spine)",stroke:"#697074",strokeWidth:"0.14"},l)),r.jsx("path",{d:"M"+(o-.1)+",20h-.9m.9,"+(n-40)+"h-.9",stroke:"#b1b2ac",strokeWidth:"1.05"})]})}function ne(e,o,n,i){const a=E.DUO_DIMENSIONS.width/(e?1:2),s=E.DUO_DIMENSIONS.height,l=e?157.5:77.1,x=e?110.8:112.2,d=(o+(e?3:0))%4,f=Math.max(0,Math.min((n-120)/(d%2?s:a),(i-120)/(d%2?a:s))),h=(y,m)=>{y=(y-a/2)*f,m=(m-s/2)*f;const C=d===1?{x:-m,y}:d===2?{x:-y,y:-m}:d===3?{x:m,y:-y}:{x:y,y:m};return{x:C.x+n/2,y:C.y+i/2}},N=(d%2?s:a)*f,D=(d%2?a:s)*f,k={min:{x:(n-N)/2,y:(i-D)/2},max:{x:(n+N)/2,y:(i+D)/2}},g=[{button:"volumeDown",x:a-37,y:-.32,width:9.5,height:.65,edge:"top"},{button:"volumeUp",x:a-25,y:-.32,width:9.5,height:.65,edge:"top"},{button:"side",x:a+.35,y:s/2-21,width:.7,height:13,edge:"right"}],b=["top","right","bottom","left"],j=g.map(y=>{const m=b[(b.indexOf(y.edge)+d)%4],C=h(y.x,y.y);return m==="top"&&(C.y=k.min.y-28),m==="bottom"&&(C.y=k.max.y+28),m==="left"&&(C.x=k.min.x-28),m==="right"&&(C.x=k.max.x+28),{button:y.button,edge:m,...C,targetX:C.x,targetY:C.y}}),v=j.filter(y=>y.button!=="side"),p=d%2?"y":"x";v.sort((y,m)=>y[p]-m[p]);const S=d%2?"targetY":"targetX";if(v[1][p]-v[0][p]<44){const y=(v[0][p]+v[1][p])/2;v[0][S]=y-22,v[1][S]=y+22}return{bodyWidth:a,bodyHeight:s,screenWidth:l,screenHeight:x,scale:f,turns:d,buttons:g,guides:j,rect:k,iconSize:Math.min(Z(k),12*f)}}function Z(e){return Math.max(12,Math.min(24,Math.max(e.max.x-e.min.x,e.max.y-e.min.y)/24))}function J(e,o,n){return[["top",n.min.y-o,e,n.min.x,n.max.x],["bottom",o-n.max.y,e,n.min.x,n.max.x],["left",n.min.x-e,o,n.min.y,n.max.y],["right",e-n.max.x,o,n.min.y,n.max.y]].filter(([,a,s,l,x])=>a>=-7&&a<=52&&s>=l-12&&s<=x+12).sort((a,s)=>Math.abs(a[1])-Math.abs(s[1]))[0]?.[0]}function V(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return;const o=Math.min(1,1024/Math.max(e.videoWidth,e.videoHeight)),n=document.createElement("canvas");try{const i=n.getContext("2d");return i?(n.width=Math.round(e.videoWidth*o),n.height=Math.round(e.videoHeight*o),i.drawImage(e,0,0,n.width,n.height),n):void 0}catch{return}}function oe(e,o){let n=!1,i;const a=f=>{n||(d(),o(f))},s=()=>{if(n)return;const f=V(e);f&&a(f)},l=()=>{i=void 0,s(),n||(i=e?.requestVideoFrameCallback?.(l))},x=setTimeout(()=>a(void 0),2500);i=e?.requestVideoFrameCallback?.(l),e?.addEventListener("loadeddata",s),!e?.requestVideoFrameCallback&&e&&e.readyState>=2&&s();function d(){n=!0,clearTimeout(x),i!==void 0&&e?.cancelVideoFrameCallback(i),e?.removeEventListener("loadeddata",s)}return d}function se(e,o,n,i,a=!0){const s=u.useRef(void 0),l=u.useRef(i),x=u.useRef({inner:o,frame:n});x.current={inner:o,frame:n};const[d,f]=u.useState(),h=u.useRef(void 0),N=u.useRef(void 0),D=u.useCallback(()=>{clearTimeout(N.current),h.current=void 0,f(void 0)},[]),k=g=>{if(!a||g===o){D();return}if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||h.current)return;const b=V(e.current);if(!b)return;const j=x.current;h.current={from:j,to:j,before:b,ready:!1},f(h.current),N.current=setTimeout(D,5e3)};return u.useEffect(()=>()=>clearTimeout(N.current),[]),u.useLayoutEffect(()=>{const g=s.current,b={inner:o,frame:n};s.current=b;const j=l.current!==i;if(l.current=i,!g)return;const v=Math.abs(g.frame.rect.min.x+g.frame.rect.max.x-n.rect.min.x-n.rect.max.x)>.5||Math.abs(g.frame.rect.min.y+g.frame.rect.max.y-n.rect.min.y-n.rect.max.y)>.5;if(!a||v||j){D();return}if(g.inner===o||(f(void 0),!g.frame.scale||!n.scale)||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const p=h.current?.before??V(e.current),S=h.current?.from??g;clearTimeout(N.current),h.current=void 0,p&&f({from:S,to:b,before:p,ready:!1})},[o,n.scale,n.turns,n.rect.min.x,n.rect.min.y,i,a]),u.useEffect(()=>{if(!d||d.from.inner===o)return;const g=oe(e.current,v=>{v?f(p=>p&&{...p,to:x.current,after:v,ready:!0}):D()}),b=window.matchMedia?.("(prefers-reduced-motion: reduce)"),j=()=>{b?.matches&&f(void 0)};return b?.addEventListener("change",j),()=>{g(),b?.removeEventListener("change",j)}},[d?.from,o]),{motion:d,finish:D,prepare:k}}function ae({pose:e,image:o,scale:n}){const{bodyWidth:i,bodyHeight:a,screenWidth:s,screenHeight:l}=e.frame,x=s*n,d=l*n;return r.jsxs("div",{className:"rc-duo-fold-still",style:{width:i*n,height:a*n},children:[r.jsx(A,{inner:e.inner,width:i,height:a}),r.jsx("div",{className:"rc-duo-flat-screen",style:{width:x,height:d,left:(i-s)*n/2,top:(a-l)*n/2,borderRadius:e.inner?5.3*n:[.8,6.6,6.6,.8].map(f=>f*n+"px").join(" ")},children:o&&r.jsx("canvas",{ref:f=>{f&&(f.width=o.width,f.height=o.height,f.getContext("2d")?.drawImage(o,0,0))},style:{width:e.inner?d:x,height:e.inner?x:d,transform:`translate(-50%, -50%) rotate(${e.inner?90:0}deg)`}})})]})}function ie({motion:e,onFinish:o}){const n=u.useRef(null),[i,a]=u.useState(!1);return u.useEffect(()=>{if(a(!1),!e.ready)return;let s=!1,l;return Promise.resolve().then(()=>require("./duo-fold-renderer-DdltAnF7.js")).then(({renderFold:x})=>{s||!n.current||(l=x(n.current,e,o),a(!0))}).catch(()=>{s||o()}),()=>{s=!0,l?.()}},[e.ready,e.from,o]),r.jsxs(r.Fragment,{children:[!i&&r.jsx("div",{className:"rc-duo-fold-hold","aria-hidden":"true",style:{width:e.from.frame.bodyWidth*e.from.frame.scale,height:e.from.frame.bodyHeight*e.from.frame.scale,transform:`translate(-50%, -50%) rotate(${e.from.frame.turns*90}deg)`},children:r.jsx(ae,{pose:e.from,image:e.before,scale:e.from.frame.scale})}),r.jsx("canvas",{ref:n,className:"rc-duo-fold-canvas","aria-hidden":"true",style:{visibility:i?"visible":"hidden"}})]})}const ce=u.lazy(()=>Promise.resolve().then(()=>require("./duo-frame-n5_DJUKk.js")).then(e=>e.duoFrame));function ue(e){const[o,n]=u.useState("2d");return r.jsxs("div",{className:"rc-duo-view",children:[e.showFrame!==!1&&o==="3d"?r.jsx(u.Suspense,{fallback:r.jsx(X,{...e}),children:r.jsx(ce,{...e})}):r.jsx(X,{...e}),e.showFrame!==!1&&r.jsxs("div",{className:"rc-duo-mode",role:"group","aria-label":"Device rendering",children:[r.jsx("button",{type:"button","aria-pressed":o==="2d",onClick:()=>n("2d"),children:"2D"}),r.jsx("button",{type:"button","aria-pressed":o==="3d",onClick:()=>n("3d"),children:"3D"})]})]})}function X(e){const o=e.showFrame!==!1,n=u.useRef(null),i=u.useRef(null),a=u.useRef(e);a.current=e;const[s,l]=u.useState({width:0,height:0}),[x,d]=u.useState(),[f,h]=u.useState(),[N,D]=u.useState(),[k,g]=u.useState(),b=u.useRef(void 0),j=u.useRef(null);j.current||(j.current=new E.DuoTouchController((...t)=>a.current.touch(...t)));const v=u.useRef(null),p=E.getDuoDisplay(e.state),S=p?.id==="inner"?e.inner:e.outer,y=E.duoDisplayTurns(p?.orientation),m=p?.id==="inner",C={portrait:0,pud:2,"landscape-left":3,"landscape-right":1}[e.state.orientation],H=o?(C+(m?1:0))%4:y,w=ne(m,H,s.width,s.height),W=o?w.screenWidth:(m?p?.height:p?.width)??1,I=o?w.screenHeight:(m?p?.width:p?.height)??1,R=o?w.bodyWidth:W,F=o?w.bodyHeight:I,M=o?w.scale:Math.max(0,Math.min(s.width/(w.turns%2?F:R),s.height/(w.turns%2?R:F))),U=W*M,L=I*M;u.useEffect(()=>{const t=new ResizeObserver(([c])=>{c&&l({width:c.contentRect.width,height:c.contentRect.height})});return n.current&&t.observe(n.current),()=>t.disconnect()},[]),u.useEffect(()=>{const t=i.current;if(!t||!S)return;const c=()=>{t.srcObject!==S.srcObject&&(t.srcObject=S.srcObject),t.play().catch(()=>{}),e.outer?.pause(),e.inner?.pause()};return c(),S.addEventListener("loadedmetadata",c),()=>{S.removeEventListener("loadedmetadata",c),t.pause(),t.srcObject=null;for(const z of[e.outer,e.inner])z?.play().catch(()=>{})}},[S,e.outer,e.inner]);const{motion:P,finish:_,prepare:Q}=se(i,m,w,e.state.orientation,o),{angle:ee,changeAngle:te,interacting:re}=Y(e.state.angleDegrees,async t=>{Q(t>=90);try{await e.setAngle(t)}catch(c){throw _(),c}},d),T=()=>{j.current?.release(),b.current=void 0};u.useEffect(()=>{v.current=new E.DuoButtonSender((c,z)=>a.current.button(c,z),c=>d(String(c)));const t=()=>{T(),v.current?.release(),g(void 0)};return window.addEventListener("blur",t),()=>{t(),window.removeEventListener("blur",t)}},[]),u.useEffect(()=>{j.current?.setDisplay(p,H),j.current?.active||(b.current=void 0)},[p,H]);const O=()=>{v.current?.release(),g(void 0)},q=t=>({disabled:e.watchOnly,onPointerDown:c=>{e.watchOnly||P||c.button!==0||(c.currentTarget.setPointerCapture(c.pointerId),v.current?.press(t),g(t))},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onBlur:O,onPointerEnter:()=>D(t),onPointerLeave:()=>D(void 0),onFocus:()=>h(w.guides.find(c=>c.button===t)?.edge),onKeyDown:c=>{P||(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.repeat||(v.current?.press(t),g(t)))},onKeyUp:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),O())}}),K=t=>{const c=t.currentTarget.getBoundingClientRect();return{x:(t.clientX-c.left)/c.width,y:(t.clientY-c.top)/c.height}};return r.jsxs("div",{className:o?"rc-duo":"rc-duo rc-duo-frameless",children:[r.jsxs("div",{ref:n,className:"rc-duo-flat-stage","data-folding":!!P,"aria-busy":!!P,onPointerMove:t=>{if(!o)return;const c=t.currentTarget.getBoundingClientRect();h(J(t.clientX-c.left,t.clientY-c.top,w.rect))},onPointerLeave:()=>{h(void 0),D(void 0)},children:[r.jsxs("div",{className:"rc-duo-flat-device","data-display":m?"inner":"outer",style:{width:R*M,height:F*M,transform:"translate(-50%, -50%) rotate("+w.turns*90+"deg)"},children:[o&&r.jsx(A,{inner:m,width:R,height:F}),r.jsx("div",{className:"rc-duo-flat-screen",role:"application","aria-label":"iPhone Duo 2D simulator",tabIndex:0,style:{width:U,height:L,left:(R-W)/2*M,top:(F-I)/2*M,borderRadius:o?m?5.3*M:[.8,6.6,6.6,.8].map(t=>t*M+"px").join(" "):0},onKeyDown:P?void 0:e.onKeyDown,onKeyUp:e.onKeyUp,onPointerDown:t=>{if(e.watchOnly||P||b.current!==void 0||t.button!==0||!p)return;t.currentTarget.focus({preventScroll:!0}),t.currentTarget.setPointerCapture(t.pointerId);const c=K(t);b.current=t.pointerId,j.current?.touch("begin",c.x,c.y)},onPointerMove:t=>{if(b.current!==t.pointerId)return;const c=K(t);j.current?.touch("move",c.x,c.y)},onPointerUp:t=>{b.current===t.pointerId&&T()},onPointerCancel:T,onLostPointerCapture:T,children:r.jsx("video",{ref:i,autoPlay:!0,muted:!0,playsInline:!0,style:{width:m?L:U,height:m?U:L,transform:"translate(-50%, -50%) rotate("+(m?90:0)+"deg)"}})}),o&&w.buttons.map(t=>r.jsx("button",{type:"button",className:"rc-duo-physical","data-duo-button":t.button,"data-edge":t.edge,"data-highlighted":N===t.button,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button]+" physical button",title:E.DUO_BUTTONS[t.button],style:{left:t.x*M,top:t.y*M,width:t.edge==="top"?Math.max(28,t.width*M):28,height:t.edge==="top"?28:Math.max(28,t.height*M)},...q(t.button),children:r.jsx("span",{style:{width:Math.max(2,t.width*M),height:Math.max(2,t.height*M)}})},t.button))]}),o&&w.guides.map(t=>r.jsx("button",{type:"button",className:"rc-duo-hardware","data-duo-button":t.button,"data-visible":f===t.edge,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button],title:E.DUO_BUTTONS[t.button],style:{left:t.targetX,top:t.targetY,"--duo-hardware-icon-size":`${w.iconSize}px`,"--duo-hardware-icon-x":`${t.x-t.targetX}px`,"--duo-hardware-icon-y":`${t.y-t.targetY}px`},...q(t.button),children:r.jsx(G,{button:t.button})},t.button)),P&&r.jsx(ie,{motion:P,onFinish:_})]}),o&&r.jsx($,{watchOnly:e.watchOnly,angle:ee,changeAngle:te,interacting:re,rotate:()=>{e.setOrientation(e.state.orientation==="portrait"?"landscape-left":"portrait").catch(t=>d(String(t)))},children:r.jsx("span",{className:"rc-duo-view-label",children:"Front view"})}),x&&r.jsx("div",{role:"alert",className:"rc-duo-error",children:x})]})}const de=Object.freeze(Object.defineProperty({__proto__:null,default:ue},Symbol.toStringTag,{value:"Module"}));exports.DuoControls=$;exports.DuoHardwareIcon=G;exports.duoView=de;exports.flatHoverEdge=J;exports.hardwareIconSize=Z;exports.useDuoHinge=Y;
1
+ "use strict";const r=require("react/jsx-runtime"),u=require("react"),E=require("./core-Bdivxz74.js");function Y(e,o,n){const[i,a]=u.useState(e),s=u.useRef({nativeAngle:e,send:o,failed:n});s.current={nativeAngle:e,send:o,failed:n};const l=u.useRef(void 0),x=u.useRef(!1),d=u.useRef(null);return u.useEffect(()=>(d.current=new E.HingeSender(async h=>{await s.current.send(h),l.current===h&&(l.current=void 0)},h=>{l.current=void 0,s.current.failed(String(h)),a(s.current.nativeAngle)}),()=>d.current?.stop()),[]),u.useEffect(()=>{!x.current&&l.current===void 0&&a(e)},[e]),{angle:i,changeAngle:h=>{s.current.failed(void 0),l.current=h,a(h),d.current?.set(h)},interacting:x}}function $({angle:e,watchOnly:o=!1,changeAngle:n,interacting:i,rotate:a,onFold:s,foldTarget:l,onHingeDrag:x,children:d}){const f=u.useId();return r.jsxs("div",{className:"rc-duo-controls",onPointerDown:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"rc-duo-hinge",children:[r.jsx("button",{disabled:o,className:"rc-duo-fold",onClick:s??(()=>n(e<90?180:0)),children:(l??e)<90?"Unfold":"Fold"}),r.jsx("label",{htmlFor:f,children:"Hinge"}),r.jsx("input",{id:f,type:"range",disabled:o,min:0,max:180,step:1,value:e,onPointerDown:h=>{x?.(),i.current=!0,h.currentTarget.setPointerCapture(h.pointerId)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},onLostPointerCapture:()=>{i.current=!1},onChange:h=>n(Number(h.target.value))}),r.jsxs("output",{children:[Math.round(e),"°"]}),r.jsx("button",{disabled:o,className:"rc-duo-rotate","aria-label":"Rotate device",title:"Rotate device",onClick:a,children:r.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[r.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9a9 9 0 0 1 3-5M3 4v5h5M21 15a9 9 0 0 1-3 5m3 0v-5h-5"})]})})]}),d&&r.jsx("div",{className:"rc-duo-views","aria-label":"Device view",children:d})]})}function G({button:e}){return r.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="side"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"6",y:"10",width:"12",height:"11",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}):r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 9h4l5-5v16l-5-5H3zM17 12h5"}),e==="volumeUp"&&r.jsx("path",{d:"M19.5 9.5v5"})]})})}function B(e,o,n,i,a,s){return"M"+(e+a)+","+o+"H"+(e+n-s)+"a"+s+","+s+" 0 0 1 "+s+","+s+"V"+(o+i-s)+"a"+s+","+s+" 0 0 1 "+-s+","+s+"H"+(e+a)+"a"+a+","+a+" 0 0 1 "+-a+","+-a+"V"+(o+a)+"a"+a+","+a+" 0 0 1 "+a+","+-a+"Z"}function A({inner:e,width:o,height:n}){const i=u.useId().replace(/:/g,""),a=e?8.4:1.25,s=8.4;return r.jsxs("svg",{className:"rc-duo-flat-frame",viewBox:"0 0 "+o+" "+n,"aria-hidden":"true",children:[r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:i+"-silver",x1:"0",y1:"0",x2:"1",y2:"1",children:[r.jsx("stop",{offset:"0",stopColor:"#62676b"}),r.jsx("stop",{offset:"0.035",stopColor:"#f9faf9"}),r.jsx("stop",{offset:"0.11",stopColor:"#b0b4b6"}),r.jsx("stop",{offset:"0.31",stopColor:"#fdfefd"}),r.jsx("stop",{offset:"0.43",stopColor:"#797f84"}),r.jsx("stop",{offset:"0.51",stopColor:"#e8eaea"}),r.jsx("stop",{offset:"0.7",stopColor:"#979da1"}),r.jsx("stop",{offset:"0.87",stopColor:"#fafbf9"}),r.jsx("stop",{offset:"1",stopColor:"#5f676c"})]}),r.jsxs("linearGradient",{id:i+"-spine",children:[r.jsx("stop",{stopColor:"#4a5154"}),r.jsx("stop",{offset:"0.16",stopColor:"#d6d9d9"}),r.jsx("stop",{offset:"0.4",stopColor:"#f8f9f7"}),r.jsx("stop",{offset:"0.62",stopColor:"#a2a8ab"}),r.jsx("stop",{offset:"0.83",stopColor:"#e4e7e5"}),r.jsx("stop",{offset:"1",stopColor:"#666e72"})]})]}),!e&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"-2.3",y:"0.7",width:"3.3",height:n-1.4,rx:"0.85",fill:"url(#"+i+"-spine)",stroke:"#8b9296",strokeWidth:"0.15"}),r.jsx("path",{d:"M-.6 2V"+(n-2),stroke:"#f5f6f4",strokeWidth:"0.22"})]}),r.jsx("path",{d:B(0,0,o,n,a,s),fill:"url(#"+i+"-silver)",stroke:"#696f72",strokeWidth:"0.24"}),r.jsx("path",{d:B(.48,.48,o-.96,n-.96,Math.max(.5,a-.48),s-.48),fill:"none",stroke:"#ffffff",strokeOpacity:"0.85",strokeWidth:"0.2"}),r.jsx("path",{d:B(1.12,1.12,o-2.24,n-2.24,e?7.15:.65,7.15),fill:"#090b0d",stroke:"#34393c",strokeWidth:"0.2"}),[o-16,e?19:16].map(l=>r.jsx(u.Fragment,{children:r.jsx("path",{d:"M"+l+",0.17v0.82M"+l+","+(n-1)+"v0.82",stroke:"#b1b2ac",strokeWidth:"1.1"})},l)),e&&[0,n-.6].map(l=>r.jsx("rect",{x:o/2-2.2,y:l,width:"4.4",height:"0.6",rx:"0.18",fill:"url(#"+i+"-spine)",stroke:"#697074",strokeWidth:"0.14"},l)),r.jsx("path",{d:"M"+(o-.1)+",20h-.9m.9,"+(n-40)+"h-.9",stroke:"#b1b2ac",strokeWidth:"1.05"})]})}function ne(e,o,n,i){const a=E.DUO_DIMENSIONS.width/(e?1:2),s=E.DUO_DIMENSIONS.height,l=e?157.5:77.1,x=e?110.8:112.2,d=(o+(e?3:0))%4,f=Math.max(0,Math.min((n-120)/(d%2?s:a),(i-120)/(d%2?a:s))),h=(y,m)=>{y=(y-a/2)*f,m=(m-s/2)*f;const C=d===1?{x:-m,y}:d===2?{x:-y,y:-m}:d===3?{x:m,y:-y}:{x:y,y:m};return{x:C.x+n/2,y:C.y+i/2}},N=(d%2?s:a)*f,D=(d%2?a:s)*f,k={min:{x:(n-N)/2,y:(i-D)/2},max:{x:(n+N)/2,y:(i+D)/2}},g=[{button:"volumeDown",x:a-37,y:-.32,width:9.5,height:.65,edge:"top"},{button:"volumeUp",x:a-25,y:-.32,width:9.5,height:.65,edge:"top"},{button:"side",x:a+.35,y:s/2-21,width:.7,height:13,edge:"right"}],b=["top","right","bottom","left"],j=g.map(y=>{const m=b[(b.indexOf(y.edge)+d)%4],C=h(y.x,y.y);return m==="top"&&(C.y=k.min.y-28),m==="bottom"&&(C.y=k.max.y+28),m==="left"&&(C.x=k.min.x-28),m==="right"&&(C.x=k.max.x+28),{button:y.button,edge:m,...C,targetX:C.x,targetY:C.y}}),v=j.filter(y=>y.button!=="side"),p=d%2?"y":"x";v.sort((y,m)=>y[p]-m[p]);const S=d%2?"targetY":"targetX";if(v[1][p]-v[0][p]<44){const y=(v[0][p]+v[1][p])/2;v[0][S]=y-22,v[1][S]=y+22}return{bodyWidth:a,bodyHeight:s,screenWidth:l,screenHeight:x,scale:f,turns:d,buttons:g,guides:j,rect:k,iconSize:Math.min(Z(k),12*f)}}function Z(e){return Math.max(12,Math.min(24,Math.max(e.max.x-e.min.x,e.max.y-e.min.y)/24))}function J(e,o,n){return[["top",n.min.y-o,e,n.min.x,n.max.x],["bottom",o-n.max.y,e,n.min.x,n.max.x],["left",n.min.x-e,o,n.min.y,n.max.y],["right",e-n.max.x,o,n.min.y,n.max.y]].filter(([,a,s,l,x])=>a>=-7&&a<=52&&s>=l-12&&s<=x+12).sort((a,s)=>Math.abs(a[1])-Math.abs(s[1]))[0]?.[0]}function V(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return;const o=Math.min(1,1024/Math.max(e.videoWidth,e.videoHeight)),n=document.createElement("canvas");try{const i=n.getContext("2d");return i?(n.width=Math.round(e.videoWidth*o),n.height=Math.round(e.videoHeight*o),i.drawImage(e,0,0,n.width,n.height),n):void 0}catch{return}}function oe(e,o){let n=!1,i;const a=f=>{n||(d(),o(f))},s=()=>{if(n)return;const f=V(e);f&&a(f)},l=()=>{i=void 0,s(),n||(i=e?.requestVideoFrameCallback?.(l))},x=setTimeout(()=>a(void 0),2500);i=e?.requestVideoFrameCallback?.(l),e?.addEventListener("loadeddata",s),!e?.requestVideoFrameCallback&&e&&e.readyState>=2&&s();function d(){n=!0,clearTimeout(x),i!==void 0&&e?.cancelVideoFrameCallback(i),e?.removeEventListener("loadeddata",s)}return d}function se(e,o,n,i,a=!0){const s=u.useRef(void 0),l=u.useRef(i),x=u.useRef({inner:o,frame:n});x.current={inner:o,frame:n};const[d,f]=u.useState(),h=u.useRef(void 0),N=u.useRef(void 0),D=u.useCallback(()=>{clearTimeout(N.current),h.current=void 0,f(void 0)},[]),k=g=>{if(!a||g===o){D();return}if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||h.current)return;const b=V(e.current);if(!b)return;const j=x.current;h.current={from:j,to:j,before:b,ready:!1},f(h.current),N.current=setTimeout(D,5e3)};return u.useEffect(()=>()=>clearTimeout(N.current),[]),u.useLayoutEffect(()=>{const g=s.current,b={inner:o,frame:n};s.current=b;const j=l.current!==i;if(l.current=i,!g)return;const v=Math.abs(g.frame.rect.min.x+g.frame.rect.max.x-n.rect.min.x-n.rect.max.x)>.5||Math.abs(g.frame.rect.min.y+g.frame.rect.max.y-n.rect.min.y-n.rect.max.y)>.5;if(!a||v||j){D();return}if(g.inner===o||(f(void 0),!g.frame.scale||!n.scale)||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const p=h.current?.before??V(e.current),S=h.current?.from??g;clearTimeout(N.current),h.current=void 0,p&&f({from:S,to:b,before:p,ready:!1})},[o,n.scale,n.turns,n.rect.min.x,n.rect.min.y,i,a]),u.useEffect(()=>{if(!d||d.from.inner===o)return;const g=oe(e.current,v=>{v?f(p=>p&&{...p,to:x.current,after:v,ready:!0}):D()}),b=window.matchMedia?.("(prefers-reduced-motion: reduce)"),j=()=>{b?.matches&&f(void 0)};return b?.addEventListener("change",j),()=>{g(),b?.removeEventListener("change",j)}},[d?.from,o]),{motion:d,finish:D,prepare:k}}function ae({pose:e,image:o,scale:n}){const{bodyWidth:i,bodyHeight:a,screenWidth:s,screenHeight:l}=e.frame,x=s*n,d=l*n;return r.jsxs("div",{className:"rc-duo-fold-still",style:{width:i*n,height:a*n},children:[r.jsx(A,{inner:e.inner,width:i,height:a}),r.jsx("div",{className:"rc-duo-flat-screen",style:{width:x,height:d,left:(i-s)*n/2,top:(a-l)*n/2,borderRadius:e.inner?5.3*n:[.8,6.6,6.6,.8].map(f=>f*n+"px").join(" ")},children:o&&r.jsx("canvas",{ref:f=>{f&&(f.width=o.width,f.height=o.height,f.getContext("2d")?.drawImage(o,0,0))},style:{width:e.inner?d:x,height:e.inner?x:d,transform:`translate(-50%, -50%) rotate(${e.inner?90:0}deg)`}})})]})}function ie({motion:e,onFinish:o}){const n=u.useRef(null),[i,a]=u.useState(!1);return u.useEffect(()=>{if(a(!1),!e.ready)return;let s=!1,l;return Promise.resolve().then(()=>require("./duo-fold-renderer-DdltAnF7.js")).then(({renderFold:x})=>{s||!n.current||(l=x(n.current,e,o),a(!0))}).catch(()=>{s||o()}),()=>{s=!0,l?.()}},[e.ready,e.from,o]),r.jsxs(r.Fragment,{children:[!i&&r.jsx("div",{className:"rc-duo-fold-hold","aria-hidden":"true",style:{width:e.from.frame.bodyWidth*e.from.frame.scale,height:e.from.frame.bodyHeight*e.from.frame.scale,transform:`translate(-50%, -50%) rotate(${e.from.frame.turns*90}deg)`},children:r.jsx(ae,{pose:e.from,image:e.before,scale:e.from.frame.scale})}),r.jsx("canvas",{ref:n,className:"rc-duo-fold-canvas","aria-hidden":"true",style:{visibility:i?"visible":"hidden"}})]})}const ce=u.lazy(()=>Promise.resolve().then(()=>require("./duo-frame-gXvPDImv.js")).then(e=>e.duoFrame));function ue(e){const[o,n]=u.useState("2d");return r.jsxs("div",{className:"rc-duo-view",children:[e.showFrame!==!1&&o==="3d"?r.jsx(u.Suspense,{fallback:r.jsx(X,{...e}),children:r.jsx(ce,{...e})}):r.jsx(X,{...e}),e.showFrame!==!1&&r.jsxs("div",{className:"rc-duo-mode",role:"group","aria-label":"Device rendering",children:[r.jsx("button",{type:"button","aria-pressed":o==="2d",onClick:()=>n("2d"),children:"2D"}),r.jsx("button",{type:"button","aria-pressed":o==="3d",onClick:()=>n("3d"),children:"3D"})]})]})}function X(e){const o=e.showFrame!==!1,n=u.useRef(null),i=u.useRef(null),a=u.useRef(e);a.current=e;const[s,l]=u.useState({width:0,height:0}),[x,d]=u.useState(),[f,h]=u.useState(),[N,D]=u.useState(),[k,g]=u.useState(),b=u.useRef(void 0),j=u.useRef(null);j.current||(j.current=new E.DuoTouchController((...t)=>a.current.touch(...t)));const v=u.useRef(null),p=E.getDuoDisplay(e.state),S=p?.id==="inner"?e.inner:e.outer,y=E.duoDisplayTurns(p?.orientation),m=p?.id==="inner",C={portrait:0,pud:2,"landscape-left":3,"landscape-right":1}[e.state.orientation],H=o?(C+(m?1:0))%4:y,w=ne(m,H,s.width,s.height),W=o?w.screenWidth:(m?p?.height:p?.width)??1,I=o?w.screenHeight:(m?p?.width:p?.height)??1,R=o?w.bodyWidth:W,F=o?w.bodyHeight:I,M=o?w.scale:Math.max(0,Math.min(s.width/(w.turns%2?F:R),s.height/(w.turns%2?R:F))),U=W*M,L=I*M;u.useEffect(()=>{const t=new ResizeObserver(([c])=>{c&&l({width:c.contentRect.width,height:c.contentRect.height})});return n.current&&t.observe(n.current),()=>t.disconnect()},[]),u.useEffect(()=>{const t=i.current;if(!t||!S)return;const c=()=>{t.srcObject!==S.srcObject&&(t.srcObject=S.srcObject),t.play().catch(()=>{}),e.outer?.pause(),e.inner?.pause()};return c(),S.addEventListener("loadedmetadata",c),()=>{S.removeEventListener("loadedmetadata",c),t.pause(),t.srcObject=null;for(const z of[e.outer,e.inner])z?.play().catch(()=>{})}},[S,e.outer,e.inner]);const{motion:P,finish:_,prepare:Q}=se(i,m,w,e.state.orientation,o),{angle:ee,changeAngle:te,interacting:re}=Y(e.state.angleDegrees,async t=>{Q(t>=90);try{await e.setAngle(t)}catch(c){throw _(),c}},d),T=()=>{j.current?.release(),b.current=void 0};u.useEffect(()=>{v.current=new E.DuoButtonSender((c,z)=>a.current.button(c,z),c=>d(String(c)));const t=()=>{T(),v.current?.release(),g(void 0)};return window.addEventListener("blur",t),()=>{t(),window.removeEventListener("blur",t)}},[]),u.useEffect(()=>{j.current?.setDisplay(p,H),j.current?.active||(b.current=void 0)},[p,H]);const O=()=>{v.current?.release(),g(void 0)},q=t=>({disabled:e.watchOnly,onPointerDown:c=>{e.watchOnly||P||c.button!==0||(c.currentTarget.setPointerCapture(c.pointerId),v.current?.press(t),g(t))},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onBlur:O,onPointerEnter:()=>D(t),onPointerLeave:()=>D(void 0),onFocus:()=>h(w.guides.find(c=>c.button===t)?.edge),onKeyDown:c=>{P||(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.repeat||(v.current?.press(t),g(t)))},onKeyUp:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),O())}}),K=t=>{const c=t.currentTarget.getBoundingClientRect();return{x:(t.clientX-c.left)/c.width,y:(t.clientY-c.top)/c.height}};return r.jsxs("div",{className:o?"rc-duo":"rc-duo rc-duo-frameless",children:[r.jsxs("div",{ref:n,className:"rc-duo-flat-stage","data-folding":!!P,"aria-busy":!!P,onPointerMove:t=>{if(!o)return;const c=t.currentTarget.getBoundingClientRect();h(J(t.clientX-c.left,t.clientY-c.top,w.rect))},onPointerLeave:()=>{h(void 0),D(void 0)},children:[r.jsxs("div",{className:"rc-duo-flat-device","data-display":m?"inner":"outer",style:{width:R*M,height:F*M,transform:"translate(-50%, -50%) rotate("+w.turns*90+"deg)"},children:[o&&r.jsx(A,{inner:m,width:R,height:F}),r.jsx("div",{className:"rc-duo-flat-screen",role:"application","aria-label":"iPhone Duo 2D simulator",tabIndex:0,style:{width:U,height:L,left:(R-W)/2*M,top:(F-I)/2*M,borderRadius:o?m?5.3*M:[.8,6.6,6.6,.8].map(t=>t*M+"px").join(" "):0},onKeyDown:P?void 0:e.onKeyDown,onKeyUp:e.onKeyUp,onPointerDown:t=>{if(e.watchOnly||P||b.current!==void 0||t.button!==0||!p)return;t.currentTarget.focus({preventScroll:!0}),t.currentTarget.setPointerCapture(t.pointerId);const c=K(t);b.current=t.pointerId,j.current?.touch("begin",c.x,c.y)},onPointerMove:t=>{if(b.current!==t.pointerId)return;const c=K(t);j.current?.touch("move",c.x,c.y)},onPointerUp:t=>{b.current===t.pointerId&&T()},onPointerCancel:T,onLostPointerCapture:T,children:r.jsx("video",{ref:i,autoPlay:!0,muted:!0,playsInline:!0,style:{width:m?L:U,height:m?U:L,transform:"translate(-50%, -50%) rotate("+(m?90:0)+"deg)"}})}),o&&w.buttons.map(t=>r.jsx("button",{type:"button",className:"rc-duo-physical","data-duo-button":t.button,"data-edge":t.edge,"data-highlighted":N===t.button,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button]+" physical button",title:E.DUO_BUTTONS[t.button],style:{left:t.x*M,top:t.y*M,width:t.edge==="top"?Math.max(28,t.width*M):28,height:t.edge==="top"?28:Math.max(28,t.height*M)},...q(t.button),children:r.jsx("span",{style:{width:Math.max(2,t.width*M),height:Math.max(2,t.height*M)}})},t.button))]}),o&&w.guides.map(t=>r.jsx("button",{type:"button",className:"rc-duo-hardware","data-duo-button":t.button,"data-visible":f===t.edge,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button],title:E.DUO_BUTTONS[t.button],style:{left:t.targetX,top:t.targetY,"--duo-hardware-icon-size":`${w.iconSize}px`,"--duo-hardware-icon-x":`${t.x-t.targetX}px`,"--duo-hardware-icon-y":`${t.y-t.targetY}px`},...q(t.button),children:r.jsx(G,{button:t.button})},t.button)),P&&r.jsx(ie,{motion:P,onFinish:_})]}),o&&r.jsx($,{watchOnly:e.watchOnly,angle:ee,changeAngle:te,interacting:re,rotate:()=>{e.setOrientation(e.state.orientation==="portrait"?"landscape-left":"portrait").catch(t=>d(String(t)))},children:r.jsx("span",{className:"rc-duo-view-label",children:"Front view"})}),x&&r.jsx("div",{role:"alert",className:"rc-duo-error",children:x})]})}const de=Object.freeze(Object.defineProperty({__proto__:null,default:ue},Symbol.toStringTag,{value:"Module"}));exports.DuoControls=$;exports.DuoHardwareIcon=G;exports.duoView=de;exports.flatHoverEdge=J;exports.hardwareIconSize=Z;exports.useDuoHinge=Y;
@@ -1,6 +1,6 @@
1
1
  import { jsx as o, jsxs as x, Fragment as z } from "react/jsx-runtime";
2
2
  import ot, { useId as J, useState as W, useRef as M, useEffect as T, useCallback as at, useLayoutEffect as it, Suspense as st, lazy as ct } from "react";
3
- import { H as dt, D as A, v as ut, w as lt, x as ht, y as ft, z as j } from "./core-DuukW7sF.mjs";
3
+ import { H as dt, D as A, v as ut, w as lt, x as ht, y as ft, z as j } from "./core-BpV73M0K.mjs";
4
4
  function mt(t, n, r) {
5
5
  const [s, i] = W(t), a = M({ nativeAngle: t, send: n, failed: r });
6
6
  a.current = { nativeAngle: t, send: n, failed: r };
@@ -418,7 +418,7 @@ function Ct({ motion: t, onFinish: n }) {
418
418
  )
419
419
  ] });
420
420
  }
421
- const kt = ct(() => import("./duo-frame-xMRcGXf4.mjs").then((t) => t.ac));
421
+ const kt = ct(() => import("./duo-frame-Sz0TWot-.mjs").then((t) => t.ac));
422
422
  function Dt(t) {
423
423
  const [n, r] = W("2d");
424
424
  return /* @__PURE__ */ x("div", { className: "rc-duo-view", children: [