@tatamicks/core 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +50 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1541 -1464
- package/dist/index.mjs.map +1 -1
- package/dist/src/index.d.ts +35 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";require('./index.css');var
|
|
1
|
+
"use strict";require('./index.css');var vr=Object.defineProperty;var gr=(e,t,n)=>t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pt=(e,t,n)=>gr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");var Ze={exports:{}},Ge={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var ln;function wr(){if(ln)return Ge;ln=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,a){var i=null;if(a!==void 0&&(i=""+a),o.key!==void 0&&(i=""+o.key),"key"in o){a={};for(var l in o)l!=="key"&&(a[l]=o[l])}else a=o;return o=a.ref,{$$typeof:e,type:s,key:i,ref:o!==void 0?o:null,props:a}}return Ge.Fragment=t,Ge.jsx=n,Ge.jsxs=n,Ge}var Be={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,20 +14,57 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var cn;function _r(){return cn||(cn=1,process.env.NODE_ENV!=="production"&&(function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===O?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case f:return"Fragment";case h:return"Profiler";case p:return"StrictMode";case M:return"Suspense";case $:return"SuspenseList";case k:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case y:return"Portal";case I:return g.displayName||"Context";case w:return(g._context.displayName||"Context")+".Consumer";case E:var C=g.render;return g=g.displayName,g||(g=C.displayName||C.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case _:return C=g.displayName||null,C!==null?C:e(g.type)||"Memo";case T:C=g._payload,g=g._init;try{return e(g(C))}catch{}}return null}function t(g){return""+g}function n(g){try{t(g);var C=!1}catch{C=!0}if(C){C=console;var A=C.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return A.call(C,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),t(g)}}function s(g){if(g===f)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===T)return"<...>";try{var C=e(g);return C?"<"+C+">":"<...>"}catch{return"<...>"}}function o(){var g=R.A;return g===null?null:g.getOwner()}function a(){return Error("react-stack-top-frame")}function i(g){if(L.call(g,"key")){var C=Object.getOwnPropertyDescriptor(g,"key").get;if(C&&C.isReactWarning)return!1}return g.key!==void 0}function l(g,C){function A(){P||(P=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",C))}A.isReactWarning=!0,Object.defineProperty(g,"key",{get:A,configurable:!0})}function c(){var g=e(this.type);return S[g]||(S[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function d(g,C,A,z,he,Oe){var q=A.ref;return g={$$typeof:j,type:g,key:C,props:A,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:c}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:he}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Oe}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function m(g,C,A,z,he,Oe){var q=C.children;if(q!==void 0)if(z)if(N(q)){for(z=0;z<q.length;z++)x(q[z]);Object.freeze&&Object.freeze(q)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(q);if(L.call(C,"key")){q=e(g);var ue=Object.keys(C).filter(function(qe){return qe!=="key"});z=0<ue.length?"{key: someKey, "+ue.join(": ..., ")+": ...}":"{key: someKey}",X[q+z]||(ue=0<ue.length?"{"+ue.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,z,q,ue,q),X[q+z]=!0)}if(q=null,A!==void 0&&(n(A),q=""+A),i(R)&&(n(R.key),q=""+R.key),"key"in R){A={};for(var ve in R)ve!=="key"&&(A[ve]=R[ve])}else A=R;return q&&a(A,typeof g=="function"?g.displayName||g.name||"Unknown":g),d(g,q,A,o(),me,Le)}function x(g){b(g)?g._store&&(g._store.validated=1):typeof g=="object"&&g!==null&&g.$$typeof===T&&(g._payload.status==="fulfilled"?b(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function b(g){return typeof g=="object"&&g!==null&&g.$$typeof===j}var v=u,j=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),I=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),C=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,N=Array.isArray,D=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(g){return g()}};var P,S={},F=v.react_stack_bottom_frame.bind(v,l)(),K=D(s(l)),X={};Ge.Fragment=h,Ge.jsx=function(g,R,A){var z=1e4>C.recentlyCreatedOwnerStacks++;return f(g,R,A,!1,z?Error("react-stack-top-frame"):F,z?D(s(g)):K)},Ge.jsxs=function(g,R,A){var z=1e4>C.recentlyCreatedOwnerStacks++;return f(g,R,A,!0,z?Error("react-stack-top-frame"):F,z?D(s(g)):K)}})()),Ge}var hn;function gr(){return hn||(hn=1,process.env.NODE_ENV==="production"?qe.exports=br():qe.exports=vr()),qe.exports}var r=gr(),Te=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(Te||{}),Re=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Re||{});const wr="_container_1mr3i_5",_r="_select_1mr3i_11",yr="_placeholderOverlay_1mr3i_44",xt={container:wr,select:_r,placeholderOverlay:yr},we=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",a=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),d=u.useCallback(j=>{const y=j.target.value;if(y==="")n(void 0);else{const h=l.find(p=>String(p.value)===y);n(h?h.value:y)}},[n,l]),f=t??"",x=t!==void 0&&t!=="",b={};a!==void 0?b.width=`${a}px`:b.width="100%";const v={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:b,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:v,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:v,value:f,onChange:d,disabled:s,children:l.map(j=>r.jsx("option",{value:String(j.value),children:j.label},String(j.value)))})]})};we.displayName="Select";const xn={justifyContent:{defaultValue:Te.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:we,config:{options:[{label:"左揃え",value:Te.left},{label:"中央揃え",value:Te.center},{label:"右揃え",value:Te.right}]}},alignItems:{defaultValue:Re.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:we,config:{options:[{label:"上揃え",value:Re.top},{label:"中央揃え",value:Re.center},{label:"下揃え",value:Re.bottom}]}}},Er="_container_1tnp6_5",jr="_input_1tnp6_13",Nr="_label_1tnp6_29",bt={container:Er,input:jr,label:Nr},xe=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const l=s??(o==null?void 0:o.label),i=u.useCallback(a=>{t(a.target.checked)},[t]);return r.jsxs("label",{className:bt.container,children:[r.jsx("input",{type:"checkbox",className:bt.input,checked:!!e,onChange:i,disabled:n}),l&&r.jsx("span",{className:bt.label,children:l})]})};xe.displayName="Checkbox";const Ir="_container_qbvob_5",Dr="_colorButton_qbvob_13",$r="_textInputWrapper_qbvob_40",Tr="_textInputPrefix_qbvob_62",Rr="_textInput_qbvob_40",Cr="_popover_qbvob_125",Mr="_palette_qbvob_141",kr="_paletteButton_qbvob_148",Pr="_selected_qbvob_171",Ar="_transparentPaletteButton_qbvob_177",Sr="_rgbaInputs_qbvob_183",Lr="_rgbaInputGroup_qbvob_190",Or="_rgbaLabel_qbvob_205",te={container:Ir,colorButton:Dr,textInputWrapper:$r,textInputPrefix:Tr,textInput:Rr,popover:Cr,palette:Mr,paletteButton:kr,selected:Pr,transparentPaletteButton:Ar,rgbaInputs:Sr,rgbaInputGroup:Lr,rgbaLabel:Or};function yt(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const s=t[1],o=Number.parseInt(s.slice(0,2),16),l=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),a=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:l,b:i,a}}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const s=Number.parseInt(n[1]??"",10),o=Number.parseInt(n[2]??"",10),l=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:l,a:i}}return null}function bn(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const l=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),a=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${l}${i}${a}${c}`}return`#${l}${i}${a}`}function Gr(e){const{r:t,g:n,b:s,a:o}=e;if(o!==0)return`rgba(${t}, ${n}, ${s}, ${o})`}function Br(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const vn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],kt=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:te.palette,children:vn.map((s,o)=>{const l=s.value===void 0,i=s.value===t,a=l?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${te.paletteButton} ${l?te.transparentPaletteButton:""} ${i?te.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:a},s.value??`undefined-${o}`)})});kt.displayName="ColorPalette";const Vr="_input_14n56_5",Ur={input:Vr},ie=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:l,integer:i,placeholder:a,width:c,height:d,config:f,onBlur:x})=>{const b=s??(f==null?void 0:f.min)??1,v=o??(f==null?void 0:f.max),j=l??(f==null?void 0:f.step)??1,y=i??(f==null?void 0:f.integer)??!1,h=a??(f==null?void 0:f.placeholder),p=c??(f==null?void 0:f.width),m=d??(f==null?void 0:f.height),w=u.useCallback(E=>{const k=E.target.value;if(k===""){t(void 0);return}let $=Number.parseFloat(k);Number.isNaN($)||(y&&($=Math.round($)),b!==void 0&&$<b&&($=b),v!==void 0&&$>v&&($=v),t($))},[t,b,v,y]),I={};return p!==void 0&&(I.width=`${p}px`),m!==void 0&&(I.height=`${m}px`,I.paddingTop=0,I.paddingBottom=0),r.jsx("input",{type:"number",className:Ur.input,style:I,value:e??"",onChange:w,onBlur:x,disabled:n,min:b,max:v,step:j,placeholder:h})};ie.displayName="NumberInput";const Pt=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:te.rgbaInputs,children:[r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"R"}),r.jsx(ie,{value:e.r,onChange:s=>t("r",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"G"}),r.jsx(ie,{value:e.g,onChange:s=>t("g",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"B"}),r.jsx(ie,{value:e.b,onChange:s=>t("b",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"A"}),r.jsx(ie,{value:Math.round(e.a*100),onChange:s=>t("a",s!==void 0?s/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});Pt.displayName="RGBAInputs";const B={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},he={BG:10,CONTENT:50,GUIDE:70,BORDER:80},At=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:l,readOnly:i=!1})=>{const a=u.useRef(null);return u.useEffect(()=>{if(!e)return;const c=d=>{a.current&&!a.current.contains(d.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:te.popover,ref:a,style:{zIndex:B.DROPDOWN},children:[r.jsx(kt,{onColorSelect:o,selectedColor:l,readOnly:i}),r.jsx(Pt,{rgba:n,onChange:s,readOnly:i})]}):null};At.displayName="ColorPickerPopover";const ze=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:l,width:i,height:a,config:c})=>{const d=o??(c==null?void 0:c.allowUndefined)??!0,f=l??(d?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=a??(c==null?void 0:c.height),[v,j]=u.useState(!1),y=u.useRef(null),[h,p]=u.useState(()=>yt(e)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const N=yt(e);N&&p(N)},[e]);const m=u.useCallback(()=>{n||j(N=>!N)},[n]),[w,I]=u.useState(e?e.replace(/^#/,""):"");u.useEffect(()=>{I(e?e.replace(/^#/,""):"")},[e]);const E=u.useCallback(N=>{const D=N.target.value;/^[0-9A-Fa-f]*$/.test(D)&&I(D)},[]),k=u.useCallback(N=>{if(N===""&&d){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):I(e?e.replace(/^#/,""):"")},[t,d,e]),$=u.useCallback(N=>{k(N.target.value)},[k]),_=u.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),k(N.currentTarget.value),N.currentTarget.blur())},[k]),T=u.useCallback(N=>{t(N)},[t]),M=u.useCallback((N,D)=>{if(D===void 0)return;const P={...h,[N]:D};p(P),t(bn(P))},[h,t]),O=e??"未設定",C={};e&&(C.background=e);const L={};return x!==void 0?L.width=`${x}px`:L.width="100%",b!==void 0&&(L.height=`${b}px`),r.jsxs("div",{className:te.container,style:L,ref:y,children:[r.jsx("button",{type:"button",className:te.colorButton,onClick:m,disabled:n,title:O,"aria-label":"カラーピッカーを開く",style:C}),s&&r.jsxs("div",{className:te.textInputWrapper,children:[r.jsx("span",{className:te.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:te.textInput,value:w,onChange:E,onKeyDown:_,onBlur:$,disabled:n,placeholder:f,maxLength:8})]}),r.jsx(At,{isOpen:v,onClose:()=>j(!1),rgba:h,onRgbaChange:M,onColorSelect:T,selectedColor:e,readOnly:n})]})};ze.displayName="ColorPicker";const Fr="_container_1n9lj_5",zr="_valueInput_1n9lj_23",Wr="_unitSelect_1n9lj_45",vt={container:Fr,valueInput:zr,unitSelect:Wr},oe=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),a=e.max??(o==null?void 0:o.max),c=e.step??(o==null?void 0:o.step)??1,d=e.placeholder??(o==null?void 0:o.placeholder),f=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),b=(t==null?void 0:t.unit)??(l==null?void 0:l[0]),v=u.useCallback(w=>{const I=w.target.value;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const k=i??1;E<k&&(E=k),a!==void 0&&E>a&&(E=a),n({value:E,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,a]),j=u.useCallback(w=>{const I=w.target.value;if(I==="")return;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const k=i??1;E<k&&(E=k,n({value:E,unit:(t==null?void 0:t.unit)??b})),a!==void 0&&E>a&&(E=a,n({value:E,unit:(t==null?void 0:t.unit)??b}))},[t,n,b,i,a]),y=u.useCallback(w=>{const I=w.target.value;n({value:(t==null?void 0:t.value)??1,unit:I})},[t,n]),h=(t==null?void 0:t.value)??"",p=(t==null?void 0:t.unit)??b??"",m={};return f!==void 0?m.width=`${f}px`:m.width="100%",x!==void 0&&(m.height=`${x}px`),r.jsxs("div",{className:vt.container,style:m,children:[r.jsx("input",{type:"number",className:vt.valueInput,value:h,onChange:v,onBlur:j,placeholder:d,min:i??1,max:a,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:vt.unitSelect,value:p,onChange:y,disabled:s||!l||l.length<=1,children:l?l.map(w=>r.jsx("option",{value:w,children:w},w)):r.jsx("option",{value:p,children:p})})]})},Yr="_container_1bfk3_6",Hr="_scrollArea_1bfk3_23",Kr="_emptyState_1bfk3_31",gt={container:Yr,scrollArea:Hr,emptyState:Kr},St=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${gt.container} ${n||""}`,children:e?r.jsx("div",{className:gt.scrollArea,children:e}):t&&r.jsx("div",{className:gt.emptyState,children:t})}),Xr="_root_qs6t8_3",qr="_list_qs6t8_11",Zr="_trigger_qs6t8_26",Jr="_content_qs6t8_71",it={root:Xr,list:qr,trigger:Zr,content:Jr},lt=u.createContext(void 0),Lt=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:l=""})=>{const[i,a]=u.useState(e),c=t??i,d=f=>{a(f),n==null||n(f)};return r.jsx(lt.Provider,{value:{value:c,onChange:d,variant:o},children:r.jsx("div",{className:`${it.root} ${l}`,"data-variant":o,children:s})})},Ot=({children:e,className:t="",width:n,height:s,style:o})=>{const l=u.useContext(lt);if(!l)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=l,a={...o};return n!==void 0&&(a.width=`${n}px`),s!==void 0&&(a.height=`${s}px`),r.jsx("div",{className:`${it.list} ${t}`,"data-variant":i,style:a,children:e})},ye=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:l,style:i})=>{const a=u.useContext(lt);if(!a)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:d,variant:f}=a,x=c===e,b={...i};return o!==void 0&&(b.width=`${o}px`),l!==void 0&&(b.height=`${l}px`),r.jsx("button",{className:`${it.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":f,onClick:()=>d(e),disabled:s,type:"button",style:b,children:t})},Ee=({value:e,children:t,className:n=""})=>{const s=u.useContext(lt);if(!s)throw new Error("TabsContent must be used within a Tabs component");const{value:o}=s;return o!==e?null:r.jsx("div",{className:`${it.content} ${n}`,children:t})},Qr="_input_9unrj_5",eo={input:Qr},Pe=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:l,rows:i,width:a,height:c,config:d,onBlur:f})=>{const x=s??(d==null?void 0:d.placeholder),b=o??(d==null?void 0:d.maxLength),v=l??(d==null?void 0:d.multiline)??!1,j=i??(d==null?void 0:d.rows)??3,y=u.useCallback(m=>{const w=m.target.value;t(w)},[t]),h={};a!==void 0?h.width=`${a}px`:h.width="100%",c!==void 0&&(h.height=`${c}px`);const p={className:eo.input,style:h,value:e??"",onChange:y,disabled:n,placeholder:x,maxLength:b};return v?r.jsx("textarea",{...p,rows:j}):r.jsx("input",{...p,type:"text",onBlur:f})};Pe.displayName="TextInput";const to=["mm","cm","fr","inch","pt","px","%"],no=["mm","cm","pt","inch","px"],ro=["mm","cm","inch"],oo=["mm","cm","fr","inch","pt","px"],gn=["px","pt","mm"],wn=["px","pt","mm"],$e=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],_n={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xe,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0}},so={...xn,..._n},yn=[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}],io={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:oe,config:{allowedUnits:wn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:we,config:{placeholder:"フォントを選択",options:yn}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:ze,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xe},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xe},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xe},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xe},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:ie,config:{min:1,max:3,step:.1}}};function lo(e){return e.reduce((t,n)=>(t[n.kind]=n,t),{})}var je=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(je||{});const ao={objectFit:{defaultValue:je.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:we,config:{options:[{label:"全体を表示",value:je.Contain},{label:"枠を埋める/切り抜き",value:je.Cover},{label:"引き伸ばす/縮小する",value:je.Fill},{label:"元のサイズ",value:je.None},{label:"縮小のみ",value:je.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Pe,config:{placeholder:"画像の説明"}}};var Ce=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Ce||{}),Me=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(Me||{});const co={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xe,config:{label:"有効にする"}},wordWrap:{defaultValue:Ce.Normal,label:"単語の折り返し",group:"設定",Component:we,config:{options:[{label:"通常",value:Ce.Normal},{label:"単語で改行",value:Ce.BreakWord},{label:"強制改行",value:Ce.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:Me.Normal,label:"空白文字の扱い",group:"設定",Component:we,config:{options:[{label:"通常",value:Me.Normal},{label:"折り返しなし",value:Me.NoWrap},{label:"そのまま表示",value:Me.Pre}]},condition:e=>e.multiline===!0}},uo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Pe,config:{placeholder:"例: テキストを入力してください"}}},ho={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}}},En=e=>{const t={};return Object.entries(e.properties).forEach(([n,s])=>{s!==!1&&typeof s=="object"&&s!==null&&"defaultValue"in s&&(t[n]=s.defaultValue)}),t};function jn(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Ne(e,t,n){const s=En(e);return{id:jn(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const mo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xe,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Pe,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ae=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(ae||{});const Nn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var de=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(de||{});const W=96;function at(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function ne(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function In(e,t,n,s){if(e<t||e>n){const o=s??"Value";throw new Error(`${o} must be between ${t} and ${n}: got ${e}`)}}function ct(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function fo(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const po=25.4,xo=2.54,bo=72,V={_assertDpi(e){at(e,"DPI"),ct(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),ne(e,"Millimeter value"),e*t/po},fromCm(e,t=W){return V._assertDpi(t),ne(e,"Centimeter value"),e*t/xo},fromInch(e,t=W){return V._assertDpi(t),ne(e,"Inch value"),e*t},fromPt(e,t=W){return V._assertDpi(t),ne(e,"Point value"),e*t/bo},fromPx(e,t=W){return V._assertDpi(t),ne(e,"Pixel value"),e*t/W},fromDim(e,t=W,n){switch(V._assertDpi(t),ne(e.value,"Dimension value"),e.unit){case"mm":return V.fromMm(e.value,t);case"cm":return V.fromCm(e.value,t);case"inch":return V.fromInch(e.value,t);case"pt":return V.fromPt(e.value,t);case"px":return V.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const s=e.unit;throw new Error(`Unsupported unit: ${s}`)}}}},ke=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===de.DASHED)return`${t*4} ${t*2}`;if(e.type===de.DOTTED)return`${t*1} ${t*2}`}};class Ae{constructor(t){this.style=t}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(t,n=W){const s=this.top;return s?{x1:0,y1:0,x2:t,y2:0,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:ke(s),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,s=W){const o=this.right;return o?{x1:t,y1:0,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:ke(o),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,s=W){const o=this.bottom;return o?{x1:0,y1:n,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:ke(o),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=W){const s=this.left;return s?{x1:0,y1:0,x2:0,y2:t,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:ke(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ce=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ce||{}),pe=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(pe||{});const Gt={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},Dn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},$n={size:Gt.A4,margin:Dn},vo={paper:$n,grid:Nn,blocks:[]};var Tn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Tn||{});const Ie=u.memo(({width:e,height:t,border:n,dpi:s=W,className:o=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:o,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,s)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,s)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,s)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,s)})]}):null);Ie.displayName="BorderRenderer";function Rn(e){const t=B.BLOCK_LAYER_MIN+e*B.BLOCK_LAYER_STEP;return t>=B.BLOCK_LAYER_MAX?B.BLOCK_LAYER_MAX:t}function We(e,t){const n=Math.min(Math.max(0,t),B.BLOCK_LAYER_STEP-1);return e+n}function go(){return Math.floor((B.BLOCK_LAYER_MAX-B.BLOCK_LAYER_MIN)/B.BLOCK_LAYER_STEP)}const Cn=u.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=he.BORDER,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(t)return new Ae(t)},[t]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(n,s),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-border",children:r.jsx(Ie,{width:e.width,height:e.height,border:a,dpi:l})})}),Mn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.BG,backgroundColor:s="transparent",className:o=""})=>{const l=We(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:l};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),kn={color:"#cccccc",width:{value:1,unit:"pt"},type:de.SOLID},ut={all:kn},Pn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.GUIDE,borderStyle:s=ut,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(t,n),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-base-border",children:r.jsx(Ie,{width:e.width,height:e.height,border:a,dpi:l})})}),wo=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,readOnly:i,mode:a,blockSizePx:c,blockZIndex:d,subZIndex:f=he.CONTENT,validationState:x,className:b=""},v)=>{const j=u.useRef(null);u.useImperativeHandle(v,()=>({focus:()=>{var w;return(w=j.current)==null?void 0:w.focus()}}),[]);const y=We(d,f),h={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},p={id:e,props:n,value:s,onChange:o??(()=>{}),onBlur:l,readOnly:i,mode:a,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},m=t.Renderer;return r.jsx("div",{className:b,style:h,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(m,{ref:j,...p})})},_o=u.forwardRef(wo),Ye=u.memo(_o);function Bt(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const Vt=u.memo(u.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:s,mode:o,value:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v="",pointerEvents:j="none"},y)=>{var m,w,I,E;const h=Bt(n,{zIndex:s,pointerEvents:j}),p=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:h,"data-block-id":e.id,className:v,children:[r.jsx(Mn,{blockSizePx:p,blockZIndex:s,backgroundColor:(m=e.style)==null?void 0:m.backgroundColor,subZIndex:f.bg}),c&&!((w=e.style)!=null&&w.border)&&r.jsx(Pn,{blockSizePx:p,blockZIndex:s,subZIndex:f.guide,borderStyle:x,dpi:b}),r.jsx(Ye,{id:e.id,ref:y,plugin:t,props:e.props,value:l,onChange:i,onBlur:a,readOnly:o===ce.EDIT?((I=e.behavior)==null?void 0:I.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:f.content}),r.jsx(Cn,{blockSizePx:p,blockZIndex:s,borderStyle:(E=e.style)==null?void 0:E.border,subZIndex:f.border,visible:d,dpi:b})]})}));Vt.displayName="BlockContainer";const He=u.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v=""})=>{const j=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:v,style:y,"data-testid":"block-layer",children:e.map((h,p)=>{const m=t[h.kind];if(!m)return null;const w=l(h),I=o.includes(h.id);let E=Rn(p);I&&(E=B.SELECT_BLOCK);const k=s[h.id]??h.initValue;return r.jsx(Vt,{ref:$=>{$?j.current.set(h.id,$):j.current.delete(h.id)},block:h,plugin:m,blockRectPx:w,blockZIndex:E,mode:n,value:k,onValueChange:i?$=>i(h.id,$):void 0,onValueBlur:$=>a==null?void 0:a(h.id,$),showGuides:c,showBorder:d,blockSubZIndex:f,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},h.id)})})});He.displayName="BlockLayer";const An=u.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:l=W,zIndex:i=B.BORDER_OVERLAY,className:a=""})=>{const c=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!c||!c.hasAnyBorder)return null;const d={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:a,style:d,"data-testid":"border-overlay",children:r.jsx(Ie,{width:e.width,height:e.height,border:c,dpi:l})})}),Sn=u.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:s=B.GRID_CANVAS,className:o})=>{const l={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:s};return r.jsx("div",{className:o,style:l,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),yo="_label_vgaic_1",Eo={label:yo},jo="_editor_6szgo_5",No="_input_6szgo_18",Io="_select_6szgo_38",Do="_button_6szgo_54",Ze={editor:jo,input:No,select:Io,button:Do};function Ln(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const s=Number(n[1]),o=n[2];if(ne(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function $o(e,t){return e.map(n=>Ln(n,t))}const To=10,Ro=25.4,Co=.352778,Mo=.264583,Y={fromCm(e){return ne(e,"Centimeter value"),e*To},fromInch(e){return ne(e,"Inch value"),e*Ro},fromPt(e){return ne(e,"Point value"),e*Co},fromPx(e){return ne(e,"Pixel value"),e*Mo},fromDim(e){switch(ne(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return Y.fromCm(e.value);case"inch":return Y.fromInch(e.value);case"pt":return Y.fromPt(e.value);case"px":return Y.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function On(e){return ne(e.value,"Dimension"),`${e.value}${e.unit}`}function ko(e){return e.map(On)}const Po=["fr","px","mm","cm","pt","inch"];function Ao(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const s=Y.fromPx(e)/10;return Math.round(s*100)/100}case"inch":{const s=Y.fromPx(e)/25.4;return Math.round(s*100)/100}case"pt":{const o=Y.fromPx(e)/25.4*72;return Math.round(o*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const Gn=u.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:l,onChange:i,onCancel:a})=>{const[c,d]=u.useState(t.value.toString()),[f,x]=u.useState(t.unit),b=u.useRef(null),v=u.useRef(null),j=e==="column"?{left:`${o+s}px`,top:`${l+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${l+s}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var m,w;(m=b.current)==null||m.focus(),(w=b.current)==null||w.select()},[]),u.useEffect(()=>{const m=w=>{v.current&&!v.current.contains(w.target)&&a()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[a]);const y=()=>{const m=Number.parseFloat(c);!Number.isNaN(m)&&m>=.1?i({unit:f,value:m}):a()},h=m=>{m.key==="Enter"?(m.preventDefault(),y()):m.key==="Escape"&&(m.preventDefault(),a())},p=m=>{const w=m.target.value;x(w);const I=Ao(n,w);d(I.toString())};return r.jsxs("div",{ref:v,className:Ze.editor,style:j,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:Ze.input,value:c,onChange:m=>d(m.target.value),onKeyDown:h,min:"0.1",step:f==="fr"?"0.1":"1"}),r.jsx("select",{className:Ze.select,value:f,onChange:p,children:Po.map(m=>r.jsx("option",{value:m,children:m},m))}),r.jsx("button",{type:"button",className:Ze.button,onClick:y,title:"確定",children:"✓"})]})});Gn.displayName="GridUnitEditor";function So(e,t,n,s){if(t==="fr"){if(n!==void 0&&s!==void 0&&s>0){const o=e/s;return Math.round(n*o*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const o=Y.fromPx(e);return Math.round(o*10)/10}case"cm":{const o=Y.fromPx(e);return Math.round(o/10*100)/100}case"inch":{const o=Y.fromPx(e);return Math.round(o/25.4*100)/100}case"pt":{const o=Y.fromPx(e);return Math.round(o/25.4*72*10)/10}default:{const o=t;throw new Error(`Unsupported unit: ${o}`)}}}const et=u.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:l,marginTopPx:i,isNearCursor:a,resizingPxSize:c,onDimensionChange:d})=>{const[f,x]=u.useState(!1);if(!a&&!f)return null;const b=e==="column"?{left:`${l+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${l-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},v=()=>{x(!0)},j=m=>{d==null||d(e,t,m),x(!1)},y=()=>{x(!1)},p=c?(()=>{const m=So(c,n.unit,n.value,o);return n.unit==="fr"?`${m}fr`:`${m}${n.unit}`})():(m=>m.unit==="fr"?`${m.value}fr`:`${m.value}${m.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Eo.label,style:b,onDoubleClick:v,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",f&&r.jsx(Gn,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:l,marginTopPx:i,onChange:j,onCancel:y})]})});et.displayName="GridDimensionLabel";function Lo(e,t,n,s){let o="";for(const l of e)o+=`M ${l} 0 L ${l} ${s} `;for(const l of t)o+=`M 0 ${l} L ${n} ${l} `;return o}const Bn=u.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:l=!0,zIndex:i=B.GRID_OVERLAY,dpi:a=W,className:c=""})=>{const d=u.useMemo(()=>Lo(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!l||!o)return null;const f=ke(o),x=V.fromDim(o.width,a),b={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d,stroke:o.color,strokeWidth:x,strokeDasharray:f,fill:"none"})})}),Oo="_handle_1mgtx_1",Go="_dragging_1mgtx_19",wt={handle:Oo,dragging:Go},tt=u.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:l,onResize:i,onResizeEnd:a})=>{const[c,d]=u.useState(!1),f=12,x=f/2,b=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${f}px`,height:`${f}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${f}px`,height:`${f}px`,cursor:"row-resize"},v=u.useCallback(j=>{j.stopPropagation(),j.preventDefault();const y=e==="column"?j.clientX:j.clientY;d(!0),l==null||l(e,t);const h=m=>{const I=(e==="column"?m.clientX:m.clientY)-y;i==null||i(e,t,I)},p=m=>{const I=(e==="column"?m.clientX:m.clientY)-y;d(!1),a==null||a(e,t,I),window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",p)},[e,t,l,i,a]);return r.jsx("div",{className:`${wt.handle} ${wt[e]} ${c?wt.dragging:""}`,style:b,onPointerDown:v,"data-testid":`grid-resize-handle-${e}-${t}`})});tt.displayName="GridResizeHandle";const Vn=u.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=B.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const l={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:s},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:o,style:l,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),dt=u.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:l="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:a="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:d=!0,showBorder:f=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:v,onDimensionChange:j,className:y="",zIndex:h={}})=>{const[p,m]=u.useState(null),[w,I]=u.useState(null),[E,k]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const N=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();k({x:P.clientX-S.left,y:P.clientY-S.top})},D=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();(P.clientX<S.left||P.clientX>S.right||P.clientY<S.top||P.clientY>S.bottom)&&k(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",D),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",D)}},[]);const _=u.useMemo(()=>{if(!E)return!1;const N=e.content.width,D=e.content.height,P=e.margin.left,S=e.margin.top;return!(E.x>=P&&E.x<=P+N&&E.y>=S&&E.y<=S+D)},[E,e]),T=u.useCallback((N,D)=>{I({direction:N,index:D})},[]),M=u.useMemo(()=>{if(!p||!w)return null;const N=w.direction==="column"?t.cols:t.rows,D=w.index,P=N[D-1],S=p.position,F=P!==void 0?S-P:0,K=p.position,X=N[D+1],g=X!==void 0?X-K:0;return{direction:w.direction,prevIndex:D-1,prevSize:F,nextIndex:D,nextSize:g}},[p,w,t]),O=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0)return;const K=S[D-1],X=S[D+1],g=10;let R=P;if(K!==void 0){const A=K+g-F;R=Math.max(R,A)}if(X!==void 0){const A=X-g-F;R=Math.min(R,A)}m({direction:N,position:F+R})},[t]),C=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0){m(null);return}const K=S[D-1],X=S[D+1],g=10;let R=P;if(K!==void 0){const A=K+g-F;R=Math.max(R,A)}if(X!==void 0){const A=X-g-F;R=Math.min(R,A)}m(null),I(null),v==null||v(N,D,R)},[t,v]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:L,children:[r.jsx(Sn,{canvasPx:e.canvas,backgroundColor:l,boxShadow:i,zIndex:(h==null?void 0:h.canvas)??B.GRID_CANVAS,className:y}),d&&r.jsx(Vn,{paperPx:e,visible:d,marginColor:a,zIndex:(h==null?void 0:h.margin)??B.MARGIN_OVERLAY,className:y}),c&&r.jsx(Bn,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(h==null?void 0:h.grid)??B.GRID_OVERLAY,dpi:W,className:y}),f&&r.jsx(An,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:f,dpi:W,zIndex:(h==null?void 0:h.border)??B.BORDER_OVERLAY,className:y}),x&&v&&r.jsxs(r.Fragment,{children:[t.cols.map((N,D)=>{if(D===0||D===t.cols.length-1)return null;const P=`col-${D}`;return r.jsx(tt,{direction:"column",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:C},P)}),t.rows.map((N,D)=>{if(D===0||D===t.rows.length-1)return null;const P=`row-${D}`;return r.jsx(tt,{direction:"row",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:C},P)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,D)=>{const P=t.cols[D],S=t.cols[D+1];if(P===void 0||S===void 0)return null;const F=(w==null?void 0:w.direction)==="column"&&(w.index===D||w.index===D+1);let K;M&&M.direction==="column"&&(M.prevIndex===D?K=M.prevSize:M.nextIndex===D&&(K=M.nextSize));const X=(P+S)/2,g=S-P,R=`col-dim-${D}`;return r.jsx(et,{direction:"column",index:D,dimension:N,position:X,currentPxSize:g,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||F,resizingPxSize:K,onDimensionChange:j},R)})," ",n.rows.map((N,D)=>{const P=t.rows[D],S=t.rows[D+1];if(P===void 0||S===void 0)return null;const F=(w==null?void 0:w.direction)==="row"&&(w.index===D||w.index===D+1),K=(P+S)/2,X=S-P,g=`row-dim-${D}`;return r.jsx(et,{direction:"row",index:D,dimension:N,position:K,currentPxSize:X,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||F,onDimensionChange:j},g)})]}),p&&r.jsx("div",{style:{position:"absolute",left:p.direction==="column"?e.margin.left+p.position:e.margin.left,top:p.direction==="row"?e.margin.top+p.position:e.margin.top,width:p.direction==="column"?"2px":e.content.width,height:p.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:B.GRID_GHOST}})]})});class Bo{constructor(){pt(this,"state",null);pt(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const Fe=new Bo;function jt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],l=o[t],i=o[t+1];return!l||!i?e:l.unit==="fr"&&i.unit==="fr"?Vo(o,t,n,s):l.unit!=="fr"&&i.unit!=="fr"?Uo(o,t,n):l.unit==="fr"&&i.unit!=="fr"?mn(o,t,n,"next",s):mn(o,t,n,"current",s)}function Vo(e,t,n,s){const o=e[t],l=e[t+1];if(!o||!l)return e;const i=e.reduce((j,y)=>y.unit==="fr"?j+y.value:j,0),a=s/i,c=o.value*a,d=l.value*a,f=Math.max(10,c+n),x=Math.max(10,d-n),b=f/a,v=x/a;return e[t]={...o,value:Math.round(b*100)/100},e[t+1]={...l,value:Math.round(v*100)/100},e}function Uo(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const l=V.fromDim(s),i=V.fromDim(o),a=Math.max(10,l+n),c=Math.max(10,i-n);return e[t]={...s,value:nt(a,s.unit)},e[t+1]={...o,value:nt(c,o.unit)},e}function mn(e,t,n,s,o){const l=e[t],i=e[t+1];if(!l||!i)return e;let a=0,c=0;for(const x of e)x.unit==="fr"?a+=x.value:c+=V.fromDim(x);const d=o-c,f=a>0?d/a:0;if(s==="next"){const x=V.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:nt(b,i.unit)};const v=b-x,j=d-v,y=l.value*f,h=Math.max(10,y+n),p=a>0?h/j*a:1;e[t]={...l,value:Math.round(p*100)/100}}else{const x=V.fromDim(l),b=Math.max(10,x+n);e[t]={...l,value:nt(b,l.unit)};const v=b-x,j=d-v,y=i.value*f,h=Math.max(10,y-n),p=a>0?h/j*a:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function nt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function Un(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){ne(s,"Pixel value");const o=s+n,l=Math.round(o);t.push(l),n=o-l}return t}const Fo=8,zo=32,Wo=64,Yo=512,fn=(e,t,n)=>Math.min(Math.max(e,t),n);function Nt(e){const t=e.length-1,n=t>=1?e[t]??0:0,s=e.length>=1?n/t:0,o=fn(Math.ceil(Math.log2(t+1)),Fo,zo),l=fn(s*2,Wo,Yo);return{step:o,windowPx:l}}function Qe(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let s=1,o=n;for(;s<=o;){const l=s+o>>>1,i=t[l];if(i===void 0){o=l-1;continue}i<=e?s=l+1:o=l-1}return s-1}function It(e,t,n){const s=e.length-1;let o=0;return l=>{if(s<=0||e[0]===void 0||l<e[0]||e[s]===void 0)return-1;if(l>=e[s])return s-1;const i=e[o],a=e[o+1];if(i===void 0||a===void 0)return-1;if(i<=l&&l<a)return o;const c=i-n,d=a+n;if(l<c||l>=d)return o=Qe(l,e),o;let f=0;const x=e[o+1];if(x!==void 0&&l>=x)for(;o+1<s;){const b=e[o+1];if(b===void 0||l<b)break;if(o++,++f>t)return o=Qe(l,e),o}else for(;o>0;){const b=e[o];if(b===void 0||l>=b)break;if(o--,++f>t)return o=Qe(l,e),o}return o}}function rt(e,t){if(e.length===0)return[];ne(t,"Content size");let n=0,s=0;const o=e.map(a=>{if(ne(a.value,"Grid dimension value"),a.unit==="fr")return n+=a.value,null;{const c=Y.fromDim(a);return s+=c,c}});if(n===0)return In(s,0,t,"Total fixed size"),o;const l=t-s;ne(l,"Content size - fixed sizes");const i=l/n;return o.map((a,c)=>{const d=e[c];if(a!=null)return a;if(!d)throw new Error(`dims[${c}] is undefined`);return d.value*i})}function ot(e,t=96){at(t,"DPI"),ct(t,"DPI");const n=e.map(o=>V.fromMm(o,t));return Un(n)}function Ho(e,t,n){if(e.length===0)return[];at(n,"DPI"),ct(n,"DPI"),ne(t,"Content size");const s=rt(e,t);return ot(s,n)}function st(e){const t={};for(const[n,s]of Object.entries(e))if(s!=null)if(typeof s=="object"&&!Array.isArray(s)&&s!==null){const o=st(s);t[n]=o}else t[n]=s;return t}function Ko(e,t){const s={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[e];return t==="landscape"?{width:s.height,height:s.width}:s}function Fn(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function zn(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function Dt(e){Fn({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var s;(s=e==null?void 0:e.onBeforePrint)==null||s.call(e)},n=()=>{var s;(s=e==null?void 0:e.onAfterPrint)==null||s.call(e),zn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function Xo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function qo(e){return e==="fr"||e==="px"||e==="%"}function pn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&qo(n.unit)}):!1}function Zo(e){if(typeof e!="object"||e===null)return!1;const t=e;return pn(t.cols)&&pn(t.rows)}function Jo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const s=n.width;if(typeof s.value!="number"||typeof s.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const o=n.height;if(typeof o.value!="number"||typeof o.unit!="string"||typeof t.margin!="object"||t.margin===null)return!1;const l=t.margin;for(const i of["top","right","bottom","left"]){const a=l[i];if(typeof a!="object"||a===null)return!1;const c=a;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function Qo(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function Wn(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!Jo(t.paper))throw new Error("Invalid paper definition");if(!Zo(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(Xo))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const s in n)if(!Qo(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function $t(e){try{const t=JSON.parse(e);return Wn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Tt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Yn(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(Yn):!1}function Hn(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!Yn(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Rt(e){try{const t=JSON.parse(e);return Hn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Ct(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Ke={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:de.SOLID}},ht={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},J={base:B.INTERACTION_LAYER_BASE,select_block:B.SELECT_BLOCK,block_ghost:B.BLOCK_GHOST,hover_outline:B.HOVER_OUTLINE,edit_block:B.EDIT_BLOCK,grid_ghost:B.GRID_GHOST,grid_handles:B.GRID_HANDLES,select_border:B.BLOCK_SELECT_BORDER,block_handles:B.BLOCK_HANDLES,rubber_band:B.RUBBER_BAND};var U=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(U||{}),H=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(H||{}),re=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(re||{}),G=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(G||{});const es="_interactionBlock_145kg_7",ts="_resizeHandle_145kg_7",Kn={interactionBlock:es,resizeHandle:ts},ns=[{id:H.NW,cursor:"nwse-resize",x:0,y:0},{id:H.N,cursor:"ns-resize",x:50,y:0},{id:H.NE,cursor:"nesw-resize",x:100,y:0},{id:H.W,cursor:"ew-resize",x:0,y:50},{id:H.E,cursor:"ew-resize",x:100,y:50},{id:H.SW,cursor:"nesw-resize",x:0,y:100},{id:H.S,cursor:"ns-resize",x:50,y:100},{id:H.SE,cursor:"nwse-resize",x:100,y:100}],Ut=u.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=ht,zIndex:s=B.BLOCK_HANDLES})=>{const o=n.size,l=o/2;return r.jsx(r.Fragment,{children:ns.map(({id:i,cursor:a,x:c,y:d})=>{const f=c===50?`calc(50% - ${l}px)`:c===100?`calc(100% - ${l}px)`:`-${l}px`,x=d===50?`calc(50% - ${l}px)`:d===100?`calc(100% - ${l}px)`:`-${l}px`,b=t===i;return r.jsx("div",{className:Kn.resizeHandle,onPointerDown:v=>{v.stopPropagation(),e(v,i)},style:{position:"absolute",left:f,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:a,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});Ut.displayName="ResizeHandles";const Xn=u.memo(({width:e,height:t,zIndex:n=B.BLOCK_SELECT_BORDER,borderStyle:s=Ke})=>{const o=u.useMemo(()=>new Ae(s),[s]),l={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:l,children:r.jsx(Ie,{width:e,height:t,border:o})})}),Se=u.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:l=Ke,handleStyle:i=ht,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{const d={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Kn.interactionBlock,style:d,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Xn,{width:t.width,height:t.height,zIndex:a,borderStyle:l}),n&&s&&r.jsx(Ut,{onResizeStart:s,activeHandle:o,handleStyle:i,zIndex:c})]})});Se.displayName="InteractionBlock";const Ft=u.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:s,currentMousePx:o,pluginKind:l,defaultSize:i,isOutside:a,selectionStyle:c,ghostZIndex:d=J.block_ghost,selectBorderZIndex:f=J.select_border,blockHandlesZIndex:x=J.block_handles})=>{const b=e[l];if(!b)return null;let v;if(a&&o){const y=Ne(b,{x:0,y:0,w:i.w,h:i.h}),h=n(y);v={left:o.x-h.width/2,top:o.y-h.height/2,width:h.width,height:h.height}}else{const y=t.cols-i.w,h=t.rows-i.h,p=Math.max(0,Math.min(s.col,y)),m=Math.max(0,Math.min(s.row,h)),w=Ne(b,{x:p,y:m,w:i.w,h:i.h});v=n(w)}const j=Ne(b,{x:0,y:0,w:i.w,h:i.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.height}px`,opacity:a?.3:.6,filter:a?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ye,{id:j.id,plugin:b,props:j.props,value:j.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:v,blockZIndex:d})}),r.jsx(Se,{block:j,rect:v,selectionStyle:c,selectBorderZIndex:f,blockHandlesZIndex:x})]})});Ft.displayName="InsertGhost";function zt(e,t,n,s,o){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const m=s-p.layout.w,w=o-p.layout.h,I=Math.max(0,Math.min(p.layout.x+t,m)),E=Math.max(0,Math.min(p.layout.y+n,w));return[{blockId:p.id,x:I,y:E}]}const l=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),a=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),d=a-l,f=c-i,x=l+t,b=i+n,v=Math.max(0,Math.min(x,s-d)),j=Math.max(0,Math.min(b,o-f)),y=v-l,h=j-i;return e.map(p=>({blockId:p.id,x:p.layout.x+y,y:p.layout.y+h}))}const Wt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:l,deltaRow:i,isOutside:a,currentMousePx:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=o.map(y=>e.find(h=>h.id===y)).filter(Boolean),j=zt(v,l,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.map(y=>{const h=e.find(I=>I.id===y);if(!h)return null;const p=t[h.kind];if(!p)return null;let m;if(a&&c){const I=s(h);m={left:c.x-I.width/2,top:c.y-I.height/2,width:I.width,height:I.height}}else{const I=j.find(k=>k.blockId===h.id);if(!I)return null;const E={...h,layout:{...h.layout,x:I.x,y:I.y}};m=s(E)}const w={...h,layout:{...h.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,opacity:a?.3:.5,filter:a?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:w.id,plugin:p,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:m,blockZIndex:f,className:"ghost-content"})}),r.jsx(Se,{block:w,rect:m,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},y)})})});Wt.displayName="MovingGhost";function Yt({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:l}){const i={...e};if(t===H.E||t===H.NE||t===H.SE){const a=o-e.x;i.w=Math.max(1,Math.min(e.w+n,a))}else if(t===H.W||t===H.NW||t===H.SW){const a=e.w-1,c=n>0?Math.min(n,a):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===H.S||t===H.SE||t===H.SW){const a=l-e.y;i.h=Math.max(1,Math.min(e.h+s,a))}else if(t===H.N||t===H.NE||t===H.NW){const a=e.h-1,c=s>0?Math.min(s,a):s;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const Ht=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:o,handle:l,deltaCol:i,deltaRow:a,isOutside:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=e.find(m=>m.id===o),j=t[(v==null?void 0:v.kind)??""];if(!v||!j)return null;const y=Yt({layout:v.layout,handle:l,deltaCol:i,deltaRow:a,gridCols:n.cols,gridRows:n.rows}),h={...v,layout:y},p=s(h);return r.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:h.id,plugin:j,props:h.props,value:h.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:p,blockZIndex:f,className:"resize-ghost-content"})}),r.jsx(Se,{block:h,rect:p,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},v.id)})});Ht.displayName="ResizeGhost";const Kt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:l=Ke,ghostZIndex:i=J.block_ghost,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{if(!s)return null;const d=s.currentGrid.col-s.startGrid.col,f=s.currentGrid.row-s.startGrid.row;switch(s.type){case re.MOVE:return r.jsx(Wt,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c});case re.RESIZE:{const x=s.blockIds[0];return!x||!s.handle?null:r.jsx(Ht,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:x,handle:s.handle,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c})}case re.INSERT:return s.defaultSize?r.jsx(Ft,{pluginRegistry:t,gridLength:n,getBlockRectPx:o,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,pluginKind:s.pluginKind||"",defaultSize:s.defaultSize,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c}):null;default:return null}});Kt.displayName="DragLayer";const rs=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,blockRectPx:i,zIndex:a=B.EDIT_BLOCK,validationState:c,className:d=""},f)=>{const x=u.useRef(null);u.useImperativeHandle(f,()=>({focus:()=>{var h;(h=x.current)==null||h.focus()}}),[]);const b=Bt(i,{zIndex:a,pointerEvents:"auto"}),v={width:i.width,height:i.height},j={id:e,props:n,value:s,onChange:o,onBlur:l,readOnly:!1,mode:ce.FORM,dimensions:{widthPx:v.width,heightPx:v.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(y,{ref:x,...j})})},os=u.forwardRef(rs),qn=u.memo(os);function Zn(e){const[t,n]=u.useState({mode:U.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=u.useCallback(o=>{n(l=>{switch(o.type){case G.SELECT:{const i=o.blockIds;return{...l,mode:U.IDLE,selectedBlockIds:i}}case G.DESELECT:return{...l,mode:U.IDLE,selectedBlockIds:[]};case G.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...l,mode:U.PRESSING,dragging:{type:re.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case G.UPDATE_DRAG:{if(!l.dragging)return l;const i=o.currentGrid.col!==l.dragging.startGrid.col||o.currentGrid.row!==l.dragging.startGrid.row;return l.mode===U.PRESSING?i?{...l,mode:U.DRAGGING,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l.mode===U.DRAGGING?{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l}case G.END_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.CANCEL_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.EDIT:return{...l,mode:U.EDITING,editingBlockId:o.blockId};case G.END_EDIT:return{...l,mode:U.IDLE,editingBlockId:null};case G.START_INSERT:return{...l,mode:U.DRAGGING,dragging:{type:re.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:o.pluginKind,defaultSize:o.defaultSize,isOutside:!1}};case G.CANCEL_INSERT:return{...l,mode:U.IDLE,dragging:void 0};case G.START_RESIZE:return{...l,mode:U.DRAGGING,dragging:{type:re.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return l}})},[]);return[t,s]}const Xt=u.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:l,selectionStyle:i=Ke,handleStyle:a=ht,selectBorderZIndex:c=J.select_border,blockHandlesZIndex:d=J.block_handles})=>{if(n&&(s==null?void 0:s.type)!==re.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const v=e.find(h=>h.id===b);if(!v)return null;const y=(s==null?void 0:s.type)===re.RESIZE&&s.blockIds.includes(b)?s==null?void 0:s.handle:null;return r.jsx(Se,{block:v,rect:o(v),showHandles:!0,onResizeStart:(h,p)=>l(h,p,b),activeHandle:y,selectionStyle:i,handleStyle:a,selectBorderZIndex:c,blockHandlesZIndex:d},v.id)})})});Xt.displayName="SelectionLayer";function Jn(e,t,n,s){const o=n-t.w,l=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,l))}}function Mt(e,t,n){const{x:s,y:o}=e;for(let l=t.length-1;l>=0;l--){const i=t[l];if(!i)continue;const a=n(i);if(s>=a.left&&s<=a.left+a.width&&o>=a.top&&o<=a.top+a.height)return i.id}return null}const qt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:l,state:i,onChange:a,onBlockChange:c,scale:d=1,className:f="",selectionStyle:x,handleStyle:b,editBlockZIndex:v=B.EDIT_BLOCK,selectBorderZIndex:j=J.select_border,blockHandlesZIndex:y=J.block_handles,dragGhostZIndex:h=J.block_ghost})=>{const p=u.useRef(null),m=u.useRef(null);u.useEffect(()=>{i.mode===U.EDITING&&i.editingBlockId&&setTimeout(()=>{var _;(_=m.current)==null||_.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const _=new Set(e.map(M=>M.id)),T=i.selectedBlockIds.filter(M=>_.has(M));T.length!==i.selectedBlockIds.length&&a({type:G.SELECT,blockIds:T,shiftKey:!1})},[e,i.selectedBlockIds,a]);const w=u.useCallback(_=>{var D;if(_.button!==0)return;const T=(D=p.current)==null?void 0:D.getBoundingClientRect();if(!T)return;const M=d??1,O={x:(_.clientX-T.left)/M,y:(_.clientY-T.top)/M},C=Mt(O,e,s);if(i.mode===U.EDITING){C!==i.editingBlockId&&(a({type:G.END_EDIT}),C||a({type:G.DESELECT}));return}const L=o(O.x),N=l(O.y);if(C){_.stopPropagation();const P=i.selectedBlockIds.includes(C);if(P&&_.shiftKey){const S=i.selectedBlockIds.filter(F=>F!==C);a({type:G.SELECT,blockIds:S,shiftKey:!0});return}else P?(_.currentTarget.setPointerCapture(_.pointerId),a({type:G.START_PRESS,blockId:C,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(_.currentTarget.setPointerCapture(_.pointerId),_.shiftKey?a({type:G.SELECT,blockIds:[...i.selectedBlockIds,C],shiftKey:!0}):(a({type:G.SELECT,blockIds:[C]}),a({type:G.START_PRESS,blockId:C,startGrid:{col:L,row:N},selectedBlockIds:[C]})))}else _.stopPropagation(),a({type:G.DESELECT})},[e,s,o,l,i.mode,i.selectedBlockIds,a,d,i.editingBlockId]),I=u.useCallback(_=>{var X;if(i.mode!==U.PRESSING&&i.mode!==U.DRAGGING||!i.dragging)return;const T=(X=p.current)==null?void 0:X.getBoundingClientRect();if(!T)return;const M=d??1,O=T.width/M,C=T.height/M,L=(_.clientX-T.left)/M,N=(_.clientY-T.top)/M,D=i.dragging.type!==re.RESIZE&&(L<0||L>O||N<0||N>C),P=Math.max(0,Math.min(L,O)),S=Math.max(0,Math.min(N,C)),F=o(P),K=l(S);a({type:G.UPDATE_DRAG,currentGrid:{col:F,row:K},currentMousePx:{x:L,y:N},isOutside:D})},[i.mode,i.dragging,o,l,a,d]),E=u.useCallback(_=>{if(i.mode===U.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===re.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.END_DRAG}),_.currentTarget.releasePointerCapture(_.pointerId);return}const T=i.dragging.currentGrid.col-i.dragging.startGrid.col,M=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===re.MOVE){if(T!==0||M!==0){const O=i.dragging.blockIds.map(N=>e.find(D=>D.id===N)).filter(Boolean);if(O.length===0){a({type:G.END_DRAG}),_.currentTarget.releasePointerCapture(_.pointerId);return}const C=zt(O,T,M,n.cols,n.rows),L=O.map(N=>{const D=C.find(P=>P.blockId===N.id);return D?{...N,layout:{...N.layout,x:D.x,y:D.y}}:N});c==null||c({type:ae.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===re.INSERT){const{pluginKind:O,currentGrid:C,defaultSize:L}=i.dragging;if(O&&L){const N=t[O];if(N){const{x:D,y:P}=Jn({x:C.col,y:C.row},{w:L.w,h:L.h},n.cols,n.rows),S=Ne(N,{x:D,y:P,w:L.w,h:L.h});c==null||c({type:ae.ADD,blockIds:[S.id],blocks:[S]})}}}else if(i.dragging.type===re.RESIZE){const O=i.dragging.blockIds[0],C=e.find(N=>N.id===O),L=i.dragging.handle;if(C&&L&&(T!==0||M!==0)){const N=Yt({layout:C.layout,handle:L,deltaCol:T,deltaRow:M,gridCols:n.cols,gridRows:n.rows});(N.x!==C.layout.x||N.y!==C.layout.y||N.w!==C.layout.w||N.h!==C.layout.h)&&(c==null||c({type:ae.RESIZE,blockIds:[C.id],blocks:[{...C,layout:N}]}))}}a({type:G.END_DRAG})}else i.mode===U.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===re.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.CANCEL_DRAG}));_.currentTarget.releasePointerCapture(_.pointerId)},[i.mode,i.dragging,e,n,t,c,a]),k=u.useCallback(_=>{var L;const T=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!T)return;const M=d??1,O={x:(_.clientX-T.left)/M,y:(_.clientY-T.top)/M},C=Mt(O,e,s);C&&(i.selectedBlockIds.includes(C)||a({type:G.SELECT,blockIds:[C]}),a({type:G.EDIT,blockId:C}))},[e,s,a,d,i.selectedBlockIds]),$=u.useCallback(_=>{var T;if((i.mode===U.PRESSING||i.mode===U.DRAGGING)&&i.dragging){const M=(T=p.current)==null?void 0:T.getBoundingClientRect();if(M){const O=d??1,C=(_.clientX-M.left)/O,L=(_.clientY-M.top)/O,N=M.width/O,D=M.height/O,P=Math.max(0,Math.min(C,N)),S=Math.max(0,Math.min(L,D));a({type:G.UPDATE_DRAG,currentGrid:{col:o(P),row:l(S)},currentMousePx:{x:C,y:L},isOutside:!0})}}},[i.mode,i.dragging,d,o,l,a]);return r.jsxs("div",{ref:p,className:f,style:{position:"absolute",inset:0,zIndex:B.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:w,onPointerMove:I,onPointerUp:E,onPointerLeave:$,onDoubleClick:k,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const _=e.find(M=>M.id===i.editingBlockId),T=_?t[_.kind]:null;return!_||!T?null:r.jsx(qn,{ref:m,id:_.id,plugin:T,props:_.props,value:_.initValue,onChange:M=>{c==null||c({type:ae.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:M}]})},onBlur:M=>{c==null||c({type:ae.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:M}]})},blockRectPx:s(_),zIndex:v})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(_,T,M)=>{var N;const O=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!O)return;i.mode===U.EDITING&&a({type:G.END_EDIT}),_.currentTarget.setPointerCapture(_.pointerId);const C=d??1,L={x:(_.clientX-O.left)/C,y:(_.clientY-O.top)/C};a({type:G.START_RESIZE,blockId:M,handle:T,startGrid:{col:o(L.x),row:l(L.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:j,blockHandlesZIndex:y}),r.jsx(Kt,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:h,selectBorderZIndex:j,blockHandlesZIndex:y})]})});qt.displayName="InteractionLayer";function mt(e,t,n=W){const s=u.useMemo(()=>Y.fromDim(e.size.width),[e.size.width]),o=u.useMemo(()=>Y.fromDim(e.size.height),[e.size.height]),l=u.useMemo(()=>Y.fromDim(e.margin.top),[e.margin.top]),i=u.useMemo(()=>Y.fromDim(e.margin.bottom),[e.margin.bottom]),a=u.useMemo(()=>Y.fromDim(e.margin.left),[e.margin.left]),c=u.useMemo(()=>Y.fromDim(e.margin.right),[e.margin.right]),d=u.useMemo(()=>s-a-c,[s,a,c]),f=u.useMemo(()=>o-l-i,[o,l,i]),x=u.useMemo(()=>rt(t.cols,d),[t.cols,d]),b=u.useMemo(()=>rt(t.rows,f),[t.rows,f]),v=u.useMemo(()=>V.fromMm(s,n),[s,n]),j=u.useMemo(()=>V.fromMm(o,n),[o,n]),y=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(a,n),[a,n]),m=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>V.fromMm(f,n),[f,n]),E=u.useMemo(()=>ot(x,n),[x,n]),k=u.useMemo(()=>ot(b,n),[b,n]),$=u.useMemo(()=>{const A=[0];for(const z of E){const me=A[A.length-1]??0;A.push(me+z)}return A},[E]),_=u.useMemo(()=>{const A=[0];for(const z of k){const me=A[A.length-1]??0;A.push(me+z)}return A},[k]),{step:T,windowPx:M}=u.useMemo(()=>Nt($),[$]),{step:O,windowPx:C}=u.useMemo(()=>Nt(_),[_]),L=u.useMemo(()=>It($,T,M),[$,T,M]),N=u.useMemo(()=>It(_,O,C),[_,O,C]),D=u.useCallback(A=>L(A-p),[L,p]),P=u.useCallback(A=>N(A-y),[N,y]),S=u.useMemo(()=>({cols:$,rows:_}),[$,_]),F=u.useMemo(()=>({width:v,height:j}),[v,j]),K=u.useMemo(()=>({top:y,bottom:h,left:p,right:m}),[y,h,p,m]),X=u.useMemo(()=>({width:w,height:I}),[w,I]),g=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),R=u.useCallback(A=>{const{x:z,y:me,w:Le,h:q}=A.layout,ue=S.cols,ve=S.rows;if(!ue.length||!ve.length)return{left:0,top:0,width:0,height:0};const Xe=Math.min(Math.max(0,z),ue.length-1),cr=Math.min(Math.max(0,z+Le),ue.length-1),cn=Math.min(Math.max(0,me),ve.length-1),ur=Math.min(Math.max(0,me+q),ve.length-1),dr=(ue[Xe]??0)+p,hr=(ve[cn]??0)+y,mr=(ue[cr]??0)-(ue[Xe]??0),fr=(ve[ur]??0)-(ve[cn]??0);return{left:dr,top:hr,width:mr,height:fr}},[S,p,y]);return{paperPx:g,gridPosPx:S,getColIndex:D,getRowIndex:P,getBlockRectPx:R}}const Zt=u.memo(({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:l})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:c}=mt(e.paper,e.grid,W),d=u.useCallback((f,x)=>{s&&s(f,x)},[s]);return r.jsxs("div",{className:l,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.EDIT,values:t,getBlockRectPx:c,onValueChange:d,showGuides:!0,showBorder:!0})]})});Zt.displayName="NoteEdit";const Jt=u.memo(({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:l})=>{const[i,a]=Zn(),c=u.useRef(null),{paperPx:d,gridPosPx:f,getBlockRectPx:x,getColIndex:b,getRowIndex:v}=mt(e.paper,e.grid,W),j=u.useCallback(E=>{if(n)switch(E.type){case ae.MOVE:case ae.RESIZE:{if(!E.blocks)return;const k=e.blocks.map($=>{var T;return((T=E.blocks)==null?void 0:T.find(M=>M.id===$.id))||$});n({...e,blocks:k});break}case ae.ADD:{if(!E.blocks)return;n({...e,blocks:[...e.blocks,...E.blocks]});break}case ae.DELETE:{const k=new Set(E.blockIds),$=e.blocks.filter(_=>!k.has(_.id));n({...e,blocks:$});break}case ae.UPDATE:{if(!E.blocks)return;const k=e.blocks.map($=>{var O;const _=(O=E.blocks)==null?void 0:O.find(C=>C.id===$.id);if(!_)return $;const T=_.style?st(_.style):_.style,M=_.props?st(_.props):_.props;return{...$,..._,style:T,props:M}});n({...e,blocks:k});break}}},[e,n]),y=u.useCallback((E,k)=>{if(!n)return;const $=e.blocks.map(_=>_.id===E?{..._,initValue:k}:_);n({...e,blocks:$})},[e,n]);u.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]),u.useEffect(()=>{const E=Fe.subscribe(k=>{var $;!k&&i.mode===U.DRAGGING&&(($=i.dragging)==null?void 0:$.type)===re.INSERT&&a({type:G.CANCEL_INSERT})});return()=>E()},[i.mode,i.dragging,a]),u.useEffect(()=>{const E=k=>{var _;if(i.selectedBlockIds.length===0)return;const $=k.target;if(c.current&&!c.current.contains($)){const T=$;if((_=T.closest)==null?void 0:_.call(T,'[data-sidebar="true"]'))return;a({type:G.DESELECT})}};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[i.selectedBlockIds,a]);const h=u.useCallback((E,k,$)=>{if(!n)return;const _=k-1;if(E==="column"){const T=jt(e.grid.cols,_,$,d.content.width);n({...e,grid:{...e.grid,cols:T}})}else{const T=jt(e.grid.rows,_,$,d.content.height);n({...e,grid:{...e.grid,rows:T}})}},[e,d,n]),p=u.useCallback((E,k,$)=>{if(n)if(E==="column"){const _=[...e.grid.cols];_[k]=$,n({...e,grid:{...e.grid,cols:_}})}else{const _=[...e.grid.rows];_[k]=$,n({...e,grid:{...e.grid,rows:_}})}},[n,e]),m=u.useMemo(()=>e.blocks.reduce((E,k)=>(E[k.id]=k.initValue,E),{}),[e.blocks]),w=u.useCallback(()=>{const E=Fe.get();E&&(i.mode===U.DRAGGING||i.dragging||a({type:G.START_INSERT,pluginKind:E.kind,defaultSize:E.defaultSize}))},[i.mode,i.dragging,a]),I=u.useCallback(()=>{},[]);return r.jsxs("div",{ref:c,className:l,onPointerEnter:w,onPointerLeave:I,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:d,gridPosPxs:f,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:h,onDimensionChange:p,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:de.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:de.SOLID}}}),r.jsx(He,{blocks:e.blocks,pluginRegistry:t,mode:ce.FORM,values:m,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:x,onValueChange:y,showGuides:!0,showBorder:!0}),r.jsx(qt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:x,getColIndex:b,getRowIndex:v,state:i,onChange:a,onBlockChange:j,scale:o})]})});Jt.displayName="NoteForm";const Qn=({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o,printMode:l=!1,printSettings:i},a)=>{const c=u.useRef(null),{paperPx:d,gridPosPx:f,getBlockRectPx:x}=mt(e.paper,e.grid,W);return u.useEffect(()=>{if(!i)return;const b=document.getElementById("dynamic-print-page-style");b&&b.remove();const v=document.createElement("style");v.id="dynamic-print-page-style";const{paperSize:j="A4",orientation:y="portrait",margin:h}=i,p=y==="landscape"?`${j} landscape`:`${j} portrait`;return v.textContent=`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
<%s key={someKey} {...props} />`,z,q,ue,q),X[q+z]=!0)}if(q=null,A!==void 0&&(n(A),q=""+A),i(C)&&(n(C.key),q=""+C.key),"key"in C){A={};for(var ve in C)ve!=="key"&&(A[ve]=C[ve])}else A=C;return q&&l(A,typeof g=="function"?g.displayName||g.name||"Unknown":g),d(g,q,A,o(),he,Oe)}function x(g){b(g)?g._store&&(g._store.validated=1):typeof g=="object"&&g!==null&&g.$$typeof===T&&(g._payload.status==="fulfilled"?b(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function b(g){return typeof g=="object"&&g!==null&&g.$$typeof===j}var v=u,j=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),I=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),R=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,N=Array.isArray,D=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(g){return g()}};var P,S={},F=v.react_stack_bottom_frame.bind(v,a)(),K=D(s(a)),X={};Be.Fragment=f,Be.jsx=function(g,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(g,C,A,!1,z?Error("react-stack-top-frame"):F,z?D(s(g)):K)},Be.jsxs=function(g,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(g,C,A,!0,z?Error("react-stack-top-frame"):F,z?D(s(g)):K)}})()),Be}var un;function yr(){return un||(un=1,process.env.NODE_ENV==="production"?Ze.exports=wr():Ze.exports=_r()),Ze.exports}var r=yr(),Te=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(Te||{}),Ce=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Ce||{});const Er="_container_1mr3i_5",jr="_select_1mr3i_11",Nr="_placeholderOverlay_1mr3i_44",xt={container:Er,select:jr,placeholderOverlay:Nr},we=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",l=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),d=u.useCallback(j=>{const y=j.target.value;if(y==="")n(void 0);else{const f=a.find(p=>String(p.value)===y);n(f?f.value:y)}},[n,a]),m=t??"",x=t!==void 0&&t!=="",b={};l!==void 0?b.width=`${l}px`:b.width="100%";const v={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:b,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:v,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:v,value:m,onChange:d,disabled:s,children:a.map(j=>r.jsx("option",{value:String(j.value),children:j.label},String(j.value)))})]})};we.displayName="Select";const fn={justifyContent:{defaultValue:Te.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:we,config:{options:[{label:"左揃え",value:Te.left},{label:"中央揃え",value:Te.center},{label:"右揃え",value:Te.right}]}},alignItems:{defaultValue:Ce.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:we,config:{options:[{label:"上揃え",value:Ce.top},{label:"中央揃え",value:Ce.center},{label:"下揃え",value:Ce.bottom}]}}},Ir="_container_1tnp6_5",Dr="_input_1tnp6_13",$r="_label_1tnp6_29",bt={container:Ir,input:Dr,label:$r},xe=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const a=s??(o==null?void 0:o.label),i=u.useCallback(l=>{t(l.target.checked)},[t]);return r.jsxs("label",{className:bt.container,children:[r.jsx("input",{type:"checkbox",className:bt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:bt.label,children:a})]})};xe.displayName="Checkbox";const Tr="_container_qbvob_5",Cr="_colorButton_qbvob_13",Rr="_textInputWrapper_qbvob_40",Mr="_textInputPrefix_qbvob_62",kr="_textInput_qbvob_40",Pr="_popover_qbvob_125",Ar="_palette_qbvob_141",Sr="_paletteButton_qbvob_148",Lr="_selected_qbvob_171",Or="_transparentPaletteButton_qbvob_177",Gr="_rgbaInputs_qbvob_183",Br="_rgbaInputGroup_qbvob_190",Vr="_rgbaLabel_qbvob_205",te={container:Tr,colorButton:Cr,textInputWrapper:Rr,textInputPrefix:Mr,textInput:kr,popover:Pr,palette:Ar,paletteButton:Sr,selected:Lr,transparentPaletteButton:Or,rgbaInputs:Gr,rgbaInputGroup:Br,rgbaLabel:Vr};function yt(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const s=t[1],o=Number.parseInt(s.slice(0,2),16),a=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),l=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:a,b:i,a:l}}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const s=Number.parseInt(n[1]??"",10),o=Number.parseInt(n[2]??"",10),a=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:a,a:i}}return null}function pn(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const a=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),l=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${a}${i}${l}${c}`}return`#${a}${i}${l}`}function Ur(e){const{r:t,g:n,b:s,a:o}=e;if(o!==0)return`rgba(${t}, ${n}, ${s}, ${o})`}function Fr(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const xn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],kt=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:te.palette,children:xn.map((s,o)=>{const a=s.value===void 0,i=s.value===t,l=a?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${te.paletteButton} ${a?te.transparentPaletteButton:""} ${i?te.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:l},s.value??`undefined-${o}`)})});kt.displayName="ColorPalette";const zr="_input_14n56_5",Wr={input:zr},ie=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:a,integer:i,placeholder:l,width:c,height:d,config:m,onBlur:x})=>{const b=s??(m==null?void 0:m.min)??1,v=o??(m==null?void 0:m.max),j=a??(m==null?void 0:m.step)??1,y=i??(m==null?void 0:m.integer)??!1,f=l??(m==null?void 0:m.placeholder),p=c??(m==null?void 0:m.width),h=d??(m==null?void 0:m.height),w=u.useCallback(E=>{const M=E.target.value;if(M===""){t(void 0);return}let $=Number.parseFloat(M);Number.isNaN($)||(y&&($=Math.round($)),b!==void 0&&$<b&&($=b),v!==void 0&&$>v&&($=v),t($))},[t,b,v,y]),I={};return p!==void 0&&(I.width=`${p}px`),h!==void 0&&(I.height=`${h}px`,I.paddingTop=0,I.paddingBottom=0),r.jsx("input",{type:"number",className:Wr.input,style:I,value:e??"",onChange:w,onBlur:x,disabled:n,min:b,max:v,step:j,placeholder:f})};ie.displayName="NumberInput";const Pt=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:te.rgbaInputs,children:[r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"R"}),r.jsx(ie,{value:e.r,onChange:s=>t("r",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"G"}),r.jsx(ie,{value:e.g,onChange:s=>t("g",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"B"}),r.jsx(ie,{value:e.b,onChange:s=>t("b",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"A"}),r.jsx(ie,{value:Math.round(e.a*100),onChange:s=>t("a",s!==void 0?s/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});Pt.displayName="RGBAInputs";const B={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},me={BG:10,CONTENT:50,GUIDE:70,BORDER:80},At=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:a,readOnly:i=!1})=>{const l=u.useRef(null);return u.useEffect(()=>{if(!e)return;const c=d=>{l.current&&!l.current.contains(d.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:te.popover,ref:l,style:{zIndex:B.DROPDOWN},children:[r.jsx(kt,{onColorSelect:o,selectedColor:a,readOnly:i}),r.jsx(Pt,{rgba:n,onChange:s,readOnly:i})]}):null};At.displayName="ColorPickerPopover";const We=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:a,width:i,height:l,config:c})=>{const d=o??(c==null?void 0:c.allowUndefined)??!0,m=a??(d?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=l??(c==null?void 0:c.height),[v,j]=u.useState(!1),y=u.useRef(null),[f,p]=u.useState(()=>yt(e)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const N=yt(e);N&&p(N)},[e]);const h=u.useCallback(()=>{n||j(N=>!N)},[n]),[w,I]=u.useState(e?e.replace(/^#/,""):"");u.useEffect(()=>{I(e?e.replace(/^#/,""):"")},[e]);const E=u.useCallback(N=>{const D=N.target.value;/^[0-9A-Fa-f]*$/.test(D)&&I(D)},[]),M=u.useCallback(N=>{if(N===""&&d){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):I(e?e.replace(/^#/,""):"")},[t,d,e]),$=u.useCallback(N=>{M(N.target.value)},[M]),_=u.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),M(N.currentTarget.value),N.currentTarget.blur())},[M]),T=u.useCallback(N=>{t(N)},[t]),k=u.useCallback((N,D)=>{if(D===void 0)return;const P={...f,[N]:D};p(P),t(pn(P))},[f,t]),O=e??"未設定",R={};e&&(R.background=e);const L={};return x!==void 0?L.width=`${x}px`:L.width="100%",b!==void 0&&(L.height=`${b}px`),r.jsxs("div",{className:te.container,style:L,ref:y,children:[r.jsx("button",{type:"button",className:te.colorButton,onClick:h,disabled:n,title:O,"aria-label":"カラーピッカーを開く",style:R}),s&&r.jsxs("div",{className:te.textInputWrapper,children:[r.jsx("span",{className:te.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:te.textInput,value:w,onChange:E,onKeyDown:_,onBlur:$,disabled:n,placeholder:m,maxLength:8})]}),r.jsx(At,{isOpen:v,onClose:()=>j(!1),rgba:f,onRgbaChange:k,onColorSelect:T,selectedColor:e,readOnly:n})]})};We.displayName="ColorPicker";const Yr="_container_1n9lj_5",Hr="_valueInput_1n9lj_23",Kr="_unitSelect_1n9lj_45",vt={container:Yr,valueInput:Hr,unitSelect:Kr},oe=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),l=e.max??(o==null?void 0:o.max),c=e.step??(o==null?void 0:o.step)??1,d=e.placeholder??(o==null?void 0:o.placeholder),m=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),b=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),v=u.useCallback(w=>{const I=w.target.value;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const M=i??1;E<M&&(E=M),l!==void 0&&E>l&&(E=l),n({value:E,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,l]),j=u.useCallback(w=>{const I=w.target.value;if(I==="")return;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const M=i??1;E<M&&(E=M,n({value:E,unit:(t==null?void 0:t.unit)??b})),l!==void 0&&E>l&&(E=l,n({value:E,unit:(t==null?void 0:t.unit)??b}))},[t,n,b,i,l]),y=u.useCallback(w=>{const I=w.target.value;n({value:(t==null?void 0:t.value)??1,unit:I})},[t,n]),f=(t==null?void 0:t.value)??"",p=(t==null?void 0:t.unit)??b??"",h={};return m!==void 0?h.width=`${m}px`:h.width="100%",x!==void 0&&(h.height=`${x}px`),r.jsxs("div",{className:vt.container,style:h,children:[r.jsx("input",{type:"number",className:vt.valueInput,value:f,onChange:v,onBlur:j,placeholder:d,min:i??1,max:l,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:vt.unitSelect,value:p,onChange:y,disabled:s||!a||a.length<=1,children:a?a.map(w=>r.jsx("option",{value:w,children:w},w)):r.jsx("option",{value:p,children:p})})]})},Xr="_container_1bfk3_6",qr="_scrollArea_1bfk3_23",Zr="_emptyState_1bfk3_31",gt={container:Xr,scrollArea:qr,emptyState:Zr},St=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${gt.container} ${n||""}`,children:e?r.jsx("div",{className:gt.scrollArea,children:e}):t&&r.jsx("div",{className:gt.emptyState,children:t})}),Jr="_root_qs6t8_3",Qr="_list_qs6t8_11",eo="_trigger_qs6t8_26",to="_content_qs6t8_71",at={root:Jr,list:Qr,trigger:eo,content:to},lt=u.createContext(void 0),Lt=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:a=""})=>{const[i,l]=u.useState(e),c=t??i,d=m=>{l(m),n==null||n(m)};return r.jsx(lt.Provider,{value:{value:c,onChange:d,variant:o},children:r.jsx("div",{className:`${at.root} ${a}`,"data-variant":o,children:s})})},Ot=({children:e,className:t="",width:n,height:s,style:o})=>{const a=u.useContext(lt);if(!a)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=a,l={...o};return n!==void 0&&(l.width=`${n}px`),s!==void 0&&(l.height=`${s}px`),r.jsx("div",{className:`${at.list} ${t}`,"data-variant":i,style:l,children:e})},ye=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:a,style:i})=>{const l=u.useContext(lt);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:d,variant:m}=l,x=c===e,b={...i};return o!==void 0&&(b.width=`${o}px`),a!==void 0&&(b.height=`${a}px`),r.jsx("button",{className:`${at.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":m,onClick:()=>d(e),disabled:s,type:"button",style:b,children:t})},Ee=({value:e,children:t,className:n=""})=>{const s=u.useContext(lt);if(!s)throw new Error("TabsContent must be used within a Tabs component");const{value:o}=s;return o!==e?null:r.jsx("div",{className:`${at.content} ${n}`,children:t})},no="_input_9unrj_5",ro={input:no},Pe=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:a,rows:i,width:l,height:c,config:d,onBlur:m})=>{const x=s??(d==null?void 0:d.placeholder),b=o??(d==null?void 0:d.maxLength),v=a??(d==null?void 0:d.multiline)??!1,j=i??(d==null?void 0:d.rows)??3,y=u.useCallback(h=>{const w=h.target.value;t(w)},[t]),f={};l!==void 0?f.width=`${l}px`:f.width="100%",c!==void 0&&(f.height=`${c}px`);const p={className:ro.input,style:f,value:e??"",onChange:y,disabled:n,placeholder:x,maxLength:b};return v?r.jsx("textarea",{...p,rows:j}):r.jsx("input",{...p,type:"text",onBlur:m})};Pe.displayName="TextInput";const oo=["mm","cm","fr","inch","pt","px","%"],so=["mm","cm","pt","inch","px"],io=["mm","cm","inch"],ao=["mm","cm","fr","inch","pt","px"],bn=["px","pt","mm"],vn=["px","pt","mm"],$e=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],gn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xe,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0}},lo={...fn,...gn},wn=[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}],co={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:oe,config:{allowedUnits:vn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:we,config:{placeholder:"フォントを選択",options:wn}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:We,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xe},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xe},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xe},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xe},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:ie,config:{min:1,max:3,step:.1}}};function uo(e){return e.reduce((t,n)=>(t[n.kind]=n,t),{})}var je=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(je||{});const mo={objectFit:{defaultValue:je.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:we,config:{options:[{label:"全体を表示",value:je.Contain},{label:"枠を埋める/切り抜き",value:je.Cover},{label:"引き伸ばす/縮小する",value:je.Fill},{label:"元のサイズ",value:je.None},{label:"縮小のみ",value:je.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Pe,config:{placeholder:"画像の説明"}}};var Re=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Re||{}),Me=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(Me||{});const ho={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xe,config:{label:"有効にする"}},wordWrap:{defaultValue:Re.Normal,label:"単語の折り返し",group:"設定",Component:we,config:{options:[{label:"通常",value:Re.Normal},{label:"単語で改行",value:Re.BreakWord},{label:"強制改行",value:Re.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:Me.Normal,label:"空白文字の扱い",group:"設定",Component:we,config:{options:[{label:"通常",value:Me.Normal},{label:"折り返しなし",value:Me.NoWrap},{label:"そのまま表示",value:Me.Pre}]},condition:e=>e.multiline===!0}},fo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Pe,config:{placeholder:"例: テキストを入力してください"}}},po={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}}},_n=e=>{const t={};return Object.entries(e.properties).forEach(([n,s])=>{s!==!1&&typeof s=="object"&&s!==null&&"defaultValue"in s&&(t[n]=s.defaultValue)}),t};function yn(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Ne(e,t,n){const s=_n(e);return{id:yn(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const xo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xe,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Pe,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ce=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(ce||{});const En={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var de=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(de||{});const W=96;function ct(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function ne(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function jn(e,t,n,s){if(e<t||e>n){const o=s??"Value";throw new Error(`${o} must be between ${t} and ${n}: got ${e}`)}}function ut(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function bo(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const vo=25.4,go=2.54,wo=72,V={_assertDpi(e){ct(e,"DPI"),ut(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),ne(e,"Millimeter value"),e*t/vo},fromCm(e,t=W){return V._assertDpi(t),ne(e,"Centimeter value"),e*t/go},fromInch(e,t=W){return V._assertDpi(t),ne(e,"Inch value"),e*t},fromPt(e,t=W){return V._assertDpi(t),ne(e,"Point value"),e*t/wo},fromPx(e,t=W){return V._assertDpi(t),ne(e,"Pixel value"),e*t/W},fromDim(e,t=W,n){switch(V._assertDpi(t),ne(e.value,"Dimension value"),e.unit){case"mm":return V.fromMm(e.value,t);case"cm":return V.fromCm(e.value,t);case"inch":return V.fromInch(e.value,t);case"pt":return V.fromPt(e.value,t);case"px":return V.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const s=e.unit;throw new Error(`Unsupported unit: ${s}`)}}}},ke=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===de.DASHED)return`${t*4} ${t*2}`;if(e.type===de.DOTTED)return`${t*1} ${t*2}`}};class Ae{constructor(t){this.style=t}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(t,n=W){const s=this.top;return s?{x1:0,y1:0,x2:t,y2:0,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:ke(s),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,s=W){const o=this.right;return o?{x1:t,y1:0,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:ke(o),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,s=W){const o=this.bottom;return o?{x1:0,y1:n,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:ke(o),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=W){const s=this.left;return s?{x1:0,y1:0,x2:0,y2:t,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:ke(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ae=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ae||{}),pe=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(pe||{});const Gt={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},Nn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},In={size:Gt.A4,margin:Nn},_o={paper:In,grid:En,blocks:[]};var Dn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Dn||{});const Ie=u.memo(({width:e,height:t,border:n,dpi:s=W,className:o=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:o,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,s)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,s)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,s)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,s)})]}):null);Ie.displayName="BorderRenderer";function $n(e){const t=B.BLOCK_LAYER_MIN+e*B.BLOCK_LAYER_STEP;return t>=B.BLOCK_LAYER_MAX?B.BLOCK_LAYER_MAX:t}function Ye(e,t){const n=Math.min(Math.max(0,t),B.BLOCK_LAYER_STEP-1);return e+n}function yo(){return Math.floor((B.BLOCK_LAYER_MAX-B.BLOCK_LAYER_MIN)/B.BLOCK_LAYER_STEP)}const Tn=u.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=me.BORDER,visible:o=!0,dpi:a=W,className:i=""})=>{const l=u.useMemo(()=>{if(t)return new Ae(t)},[t]);if(!o||!l||!l.hasAnyBorder)return null;const c=Ye(n,s),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-border",children:r.jsx(Ie,{width:e.width,height:e.height,border:l,dpi:a})})}),Cn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=me.BG,backgroundColor:s="transparent",className:o=""})=>{const a=Ye(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:a};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Rn={color:"#cccccc",width:{value:1,unit:"pt"},type:de.SOLID},dt={all:Rn},Mn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=me.GUIDE,borderStyle:s=dt,visible:o=!0,dpi:a=W,className:i=""})=>{const l=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!l||!l.hasAnyBorder)return null;const c=Ye(t,n),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-base-border",children:r.jsx(Ie,{width:e.width,height:e.height,border:l,dpi:a})})}),Eo=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,readOnly:i,mode:l,blockSizePx:c,blockZIndex:d,subZIndex:m=me.CONTENT,validationState:x,className:b=""},v)=>{const j=u.useRef(null);u.useImperativeHandle(v,()=>({focus:()=>{var w;return(w=j.current)==null?void 0:w.focus()}}),[]);const y=Ye(d,m),f={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},p={id:e,props:n,value:s,onChange:o??(()=>{}),onBlur:a,readOnly:i,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},h=t.Renderer;return r.jsx("div",{className:b,style:f,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(h,{ref:j,...p})})},jo=u.forwardRef(Eo),He=u.memo(jo);function Bt(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const Vt=u.memo(u.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:s,mode:o,value:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:m={bg:me.BG,guide:me.GUIDE,content:me.CONTENT,border:me.BORDER},defaultGuideBorder:x=dt,dpi:b=W,className:v="",pointerEvents:j="none"},y)=>{var h,w,I,E;const f=Bt(n,{zIndex:s,pointerEvents:j}),p=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:f,"data-block-id":e.id,className:v,children:[r.jsx(Cn,{blockSizePx:p,blockZIndex:s,backgroundColor:(h=e.style)==null?void 0:h.backgroundColor,subZIndex:m.bg}),c&&!((w=e.style)!=null&&w.border)&&r.jsx(Mn,{blockSizePx:p,blockZIndex:s,subZIndex:m.guide,borderStyle:x,dpi:b}),r.jsx(He,{id:e.id,ref:y,plugin:t,props:e.props,value:a,onChange:i,onBlur:l,readOnly:o===ae.EDIT?((I=e.behavior)==null?void 0:I.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:m.content}),r.jsx(Tn,{blockSizePx:p,blockZIndex:s,borderStyle:(E=e.style)==null?void 0:E.border,subZIndex:m.border,visible:d,dpi:b})]})}));Vt.displayName="BlockContainer";const Se=u.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:m={bg:me.BG,guide:me.GUIDE,content:me.CONTENT,border:me.BORDER},defaultGuideBorder:x=dt,dpi:b=W,className:v=""})=>{const j=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:v,style:y,"data-testid":"block-layer",children:e.map((f,p)=>{const h=t[f.kind];if(!h)return null;const w=a(f),I=o.includes(f.id);let E=$n(p);I&&(E=B.SELECT_BLOCK);const M=s[f.id]??f.initValue;return r.jsx(Vt,{ref:$=>{$?j.current.set(f.id,$):j.current.delete(f.id)},block:f,plugin:h,blockRectPx:w,blockZIndex:E,mode:n,value:M,onValueChange:i?$=>i(f.id,$):void 0,onValueBlur:$=>l==null?void 0:l(f.id,$),showGuides:c,showBorder:d,blockSubZIndex:m,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},f.id)})})});Se.displayName="BlockLayer";const kn=u.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:a=W,zIndex:i=B.BORDER_OVERLAY,className:l=""})=>{const c=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!c||!c.hasAnyBorder)return null;const d={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:l,style:d,"data-testid":"border-overlay",children:r.jsx(Ie,{width:e.width,height:e.height,border:c,dpi:a})})}),Pn=u.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:s=B.GRID_CANVAS,className:o})=>{const a={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:s};return r.jsx("div",{className:o,style:a,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),No="_label_vgaic_1",Io={label:No},Do="_editor_6szgo_5",$o="_input_6szgo_18",To="_select_6szgo_38",Co="_button_6szgo_54",Je={editor:Do,input:$o,select:To,button:Co};function An(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const s=Number(n[1]),o=n[2];if(ne(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function Ro(e,t){return e.map(n=>An(n,t))}const Mo=10,ko=25.4,Po=.352778,Ao=.264583,Y={fromCm(e){return ne(e,"Centimeter value"),e*Mo},fromInch(e){return ne(e,"Inch value"),e*ko},fromPt(e){return ne(e,"Point value"),e*Po},fromPx(e){return ne(e,"Pixel value"),e*Ao},fromDim(e){switch(ne(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return Y.fromCm(e.value);case"inch":return Y.fromInch(e.value);case"pt":return Y.fromPt(e.value);case"px":return Y.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function Sn(e){return ne(e.value,"Dimension"),`${e.value}${e.unit}`}function So(e){return e.map(Sn)}const Lo=["fr","px","mm","cm","pt","inch"];function Oo(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const s=Y.fromPx(e)/10;return Math.round(s*100)/100}case"inch":{const s=Y.fromPx(e)/25.4;return Math.round(s*100)/100}case"pt":{const o=Y.fromPx(e)/25.4*72;return Math.round(o*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const Ln=u.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:a,onChange:i,onCancel:l})=>{const[c,d]=u.useState(t.value.toString()),[m,x]=u.useState(t.unit),b=u.useRef(null),v=u.useRef(null),j=e==="column"?{left:`${o+s}px`,top:`${a+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${a+s}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var h,w;(h=b.current)==null||h.focus(),(w=b.current)==null||w.select()},[]),u.useEffect(()=>{const h=w=>{v.current&&!v.current.contains(w.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const y=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?i({unit:m,value:h}):l()},f=h=>{h.key==="Enter"?(h.preventDefault(),y()):h.key==="Escape"&&(h.preventDefault(),l())},p=h=>{const w=h.target.value;x(w);const I=Oo(n,w);d(I.toString())};return r.jsxs("div",{ref:v,className:Je.editor,style:j,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:Je.input,value:c,onChange:h=>d(h.target.value),onKeyDown:f,min:"0.1",step:m==="fr"?"0.1":"1"}),r.jsx("select",{className:Je.select,value:m,onChange:p,children:Lo.map(h=>r.jsx("option",{value:h,children:h},h))}),r.jsx("button",{type:"button",className:Je.button,onClick:y,title:"確定",children:"✓"})]})});Ln.displayName="GridUnitEditor";function Go(e,t,n,s){if(t==="fr"){if(n!==void 0&&s!==void 0&&s>0){const o=e/s;return Math.round(n*o*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const o=Y.fromPx(e);return Math.round(o*10)/10}case"cm":{const o=Y.fromPx(e);return Math.round(o/10*100)/100}case"inch":{const o=Y.fromPx(e);return Math.round(o/25.4*100)/100}case"pt":{const o=Y.fromPx(e);return Math.round(o/25.4*72*10)/10}default:{const o=t;throw new Error(`Unsupported unit: ${o}`)}}}const tt=u.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:a,marginTopPx:i,isNearCursor:l,resizingPxSize:c,onDimensionChange:d})=>{const[m,x]=u.useState(!1);if(!l&&!m)return null;const b=e==="column"?{left:`${a+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${a-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},v=()=>{x(!0)},j=h=>{d==null||d(e,t,h),x(!1)},y=()=>{x(!1)},p=c?(()=>{const h=Go(c,n.unit,n.value,o);return n.unit==="fr"?`${h}fr`:`${h}${n.unit}`})():(h=>h.unit==="fr"?`${h.value}fr`:`${h.value}${h.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Io.label,style:b,onDoubleClick:v,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",m&&r.jsx(Ln,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:a,marginTopPx:i,onChange:j,onCancel:y})]})});tt.displayName="GridDimensionLabel";function Bo(e,t,n,s){let o="";for(const a of e)o+=`M ${a} 0 L ${a} ${s} `;for(const a of t)o+=`M 0 ${a} L ${n} ${a} `;return o}const On=u.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:a=!0,zIndex:i=B.GRID_OVERLAY,dpi:l=W,className:c=""})=>{const d=u.useMemo(()=>Bo(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!a||!o)return null;const m=ke(o),x=V.fromDim(o.width,l),b={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d,stroke:o.color,strokeWidth:x,strokeDasharray:m,fill:"none"})})}),Vo="_handle_1mgtx_1",Uo="_dragging_1mgtx_19",wt={handle:Vo,dragging:Uo},nt=u.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:a,onResize:i,onResizeEnd:l})=>{const[c,d]=u.useState(!1),m=12,x=m/2,b=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${m}px`,height:`${m}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${m}px`,height:`${m}px`,cursor:"row-resize"},v=u.useCallback(j=>{j.stopPropagation(),j.preventDefault();const y=e==="column"?j.clientX:j.clientY;d(!0),a==null||a(e,t);const f=h=>{const I=(e==="column"?h.clientX:h.clientY)-y;i==null||i(e,t,I)},p=h=>{const I=(e==="column"?h.clientX:h.clientY)-y;d(!1),l==null||l(e,t,I),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",p)},[e,t,a,i,l]);return r.jsx("div",{className:`${wt.handle} ${wt[e]} ${c?wt.dragging:""}`,style:b,onPointerDown:v,"data-testid":`grid-resize-handle-${e}-${t}`})});nt.displayName="GridResizeHandle";const Gn=u.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=B.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const a={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:s},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:o,style:a,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),mt=u.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:a="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:d=!0,showBorder:m=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:v,onDimensionChange:j,className:y="",zIndex:f={}})=>{const[p,h]=u.useState(null),[w,I]=u.useState(null),[E,M]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const N=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();M({x:P.clientX-S.left,y:P.clientY-S.top})},D=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();(P.clientX<S.left||P.clientX>S.right||P.clientY<S.top||P.clientY>S.bottom)&&M(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",D),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",D)}},[]);const _=u.useMemo(()=>{if(!E)return!1;const N=e.content.width,D=e.content.height,P=e.margin.left,S=e.margin.top;return!(E.x>=P&&E.x<=P+N&&E.y>=S&&E.y<=S+D)},[E,e]),T=u.useCallback((N,D)=>{I({direction:N,index:D})},[]),k=u.useMemo(()=>{if(!p||!w)return null;const N=w.direction==="column"?t.cols:t.rows,D=w.index,P=N[D-1],S=p.position,F=P!==void 0?S-P:0,K=p.position,X=N[D+1],g=X!==void 0?X-K:0;return{direction:w.direction,prevIndex:D-1,prevSize:F,nextIndex:D,nextSize:g}},[p,w,t]),O=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0)return;const K=S[D-1],X=S[D+1],g=10;let C=P;if(K!==void 0){const A=K+g-F;C=Math.max(C,A)}if(X!==void 0){const A=X-g-F;C=Math.min(C,A)}h({direction:N,position:F+C})},[t]),R=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0){h(null);return}const K=S[D-1],X=S[D+1],g=10;let C=P;if(K!==void 0){const A=K+g-F;C=Math.max(C,A)}if(X!==void 0){const A=X-g-F;C=Math.min(C,A)}h(null),I(null),v==null||v(N,D,C)},[t,v]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:L,children:[r.jsx(Pn,{canvasPx:e.canvas,backgroundColor:a,boxShadow:i,zIndex:(f==null?void 0:f.canvas)??B.GRID_CANVAS,className:y}),d&&r.jsx(Gn,{paperPx:e,visible:d,marginColor:l,zIndex:(f==null?void 0:f.margin)??B.MARGIN_OVERLAY,className:y}),c&&r.jsx(On,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(f==null?void 0:f.grid)??B.GRID_OVERLAY,dpi:W,className:y}),m&&r.jsx(kn,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:m,dpi:W,zIndex:(f==null?void 0:f.border)??B.BORDER_OVERLAY,className:y}),x&&v&&r.jsxs(r.Fragment,{children:[t.cols.map((N,D)=>{if(D===0||D===t.cols.length-1)return null;const P=`col-${D}`;return r.jsx(nt,{direction:"column",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:R},P)}),t.rows.map((N,D)=>{if(D===0||D===t.rows.length-1)return null;const P=`row-${D}`;return r.jsx(nt,{direction:"row",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:R},P)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,D)=>{const P=t.cols[D],S=t.cols[D+1];if(P===void 0||S===void 0)return null;const F=(w==null?void 0:w.direction)==="column"&&(w.index===D||w.index===D+1);let K;k&&k.direction==="column"&&(k.prevIndex===D?K=k.prevSize:k.nextIndex===D&&(K=k.nextSize));const X=(P+S)/2,g=S-P,C=`col-dim-${D}`;return r.jsx(tt,{direction:"column",index:D,dimension:N,position:X,currentPxSize:g,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||F,resizingPxSize:K,onDimensionChange:j},C)})," ",n.rows.map((N,D)=>{const P=t.rows[D],S=t.rows[D+1];if(P===void 0||S===void 0)return null;const F=(w==null?void 0:w.direction)==="row"&&(w.index===D||w.index===D+1),K=(P+S)/2,X=S-P,g=`row-dim-${D}`;return r.jsx(tt,{direction:"row",index:D,dimension:N,position:K,currentPxSize:X,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||F,onDimensionChange:j},g)})]}),p&&r.jsx("div",{style:{position:"absolute",left:p.direction==="column"?e.margin.left+p.position:e.margin.left,top:p.direction==="row"?e.margin.top+p.position:e.margin.top,width:p.direction==="column"?"2px":e.content.width,height:p.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:B.GRID_GHOST}})]})});class Fo{constructor(){pt(this,"state",null);pt(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const ze=new Fo;function jt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],a=o[t],i=o[t+1];return!a||!i?e:a.unit==="fr"&&i.unit==="fr"?zo(o,t,n,s):a.unit!=="fr"&&i.unit!=="fr"?Wo(o,t,n):a.unit==="fr"&&i.unit!=="fr"?dn(o,t,n,"next",s):dn(o,t,n,"current",s)}function zo(e,t,n,s){const o=e[t],a=e[t+1];if(!o||!a)return e;const i=e.reduce((j,y)=>y.unit==="fr"?j+y.value:j,0),l=s/i,c=o.value*l,d=a.value*l,m=Math.max(10,c+n),x=Math.max(10,d-n),b=m/l,v=x/l;return e[t]={...o,value:Math.round(b*100)/100},e[t+1]={...a,value:Math.round(v*100)/100},e}function Wo(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const a=V.fromDim(s),i=V.fromDim(o),l=Math.max(10,a+n),c=Math.max(10,i-n);return e[t]={...s,value:rt(l,s.unit)},e[t+1]={...o,value:rt(c,o.unit)},e}function dn(e,t,n,s,o){const a=e[t],i=e[t+1];if(!a||!i)return e;let l=0,c=0;for(const x of e)x.unit==="fr"?l+=x.value:c+=V.fromDim(x);const d=o-c,m=l>0?d/l:0;if(s==="next"){const x=V.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:rt(b,i.unit)};const v=b-x,j=d-v,y=a.value*m,f=Math.max(10,y+n),p=l>0?f/j*l:1;e[t]={...a,value:Math.round(p*100)/100}}else{const x=V.fromDim(a),b=Math.max(10,x+n);e[t]={...a,value:rt(b,a.unit)};const v=b-x,j=d-v,y=i.value*m,f=Math.max(10,y-n),p=l>0?f/j*l:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function rt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function Bn(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){ne(s,"Pixel value");const o=s+n,a=Math.round(o);t.push(a),n=o-a}return t}const Yo=8,Ho=32,Ko=64,Xo=512,mn=(e,t,n)=>Math.min(Math.max(e,t),n);function Nt(e){const t=e.length-1,n=t>=1?e[t]??0:0,s=e.length>=1?n/t:0,o=mn(Math.ceil(Math.log2(t+1)),Yo,Ho),a=mn(s*2,Ko,Xo);return{step:o,windowPx:a}}function et(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let s=1,o=n;for(;s<=o;){const a=s+o>>>1,i=t[a];if(i===void 0){o=a-1;continue}i<=e?s=a+1:o=a-1}return s-1}function It(e,t,n){const s=e.length-1;let o=0;return a=>{if(s<=0||e[0]===void 0||a<e[0]||e[s]===void 0)return-1;if(a>=e[s])return s-1;const i=e[o],l=e[o+1];if(i===void 0||l===void 0)return-1;if(i<=a&&a<l)return o;const c=i-n,d=l+n;if(a<c||a>=d)return o=et(a,e),o;let m=0;const x=e[o+1];if(x!==void 0&&a>=x)for(;o+1<s;){const b=e[o+1];if(b===void 0||a<b)break;if(o++,++m>t)return o=et(a,e),o}else for(;o>0;){const b=e[o];if(b===void 0||a>=b)break;if(o--,++m>t)return o=et(a,e),o}return o}}function ot(e,t){if(e.length===0)return[];ne(t,"Content size");let n=0,s=0;const o=e.map(l=>{if(ne(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Y.fromDim(l);return s+=c,c}});if(n===0)return jn(s,0,t,"Total fixed size"),o;const a=t-s;ne(a,"Content size - fixed sizes");const i=a/n;return o.map((l,c)=>{const d=e[c];if(l!=null)return l;if(!d)throw new Error(`dims[${c}] is undefined`);return d.value*i})}function st(e,t=96){ct(t,"DPI"),ut(t,"DPI");const n=e.map(o=>V.fromMm(o,t));return Bn(n)}function qo(e,t,n){if(e.length===0)return[];ct(n,"DPI"),ut(n,"DPI"),ne(t,"Content size");const s=ot(e,t);return st(s,n)}function it(e){const t={};for(const[n,s]of Object.entries(e))if(s!=null)if(typeof s=="object"&&!Array.isArray(s)&&s!==null){const o=it(s);t[n]=o}else t[n]=s;return t}function Zo(e,t){const s={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[e];return t==="landscape"?{width:s.height,height:s.width}:s}function Vn(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function Un(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function Dt(e,t){var o,a;const n=document.title,s=document.createElement("style");s.id="tatamicks-print-style",s.textContent=`
|
|
23
|
+
@media print {
|
|
24
|
+
/* bodyとhtmlのマージン・パディングをリセット */
|
|
25
|
+
html, body {
|
|
26
|
+
margin: 0 !important;
|
|
27
|
+
padding: 0 !important;
|
|
28
|
+
width: 100% !important;
|
|
29
|
+
height: 100% !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* すべての要素を非表示 */
|
|
33
|
+
body * {
|
|
34
|
+
visibility: hidden !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* 印刷対象の要素とその子孫を表示 */
|
|
38
|
+
.tatamicks-print-target,
|
|
39
|
+
.tatamicks-print-target * {
|
|
40
|
+
visibility: visible !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* 印刷対象の要素を左上に固定 */
|
|
44
|
+
.tatamicks-print-target {
|
|
45
|
+
position: fixed !important;
|
|
46
|
+
left: 0 !important;
|
|
47
|
+
top: 0 !important;
|
|
48
|
+
margin: 0 !important;
|
|
49
|
+
padding: 0 !important;
|
|
50
|
+
transform: none !important;
|
|
51
|
+
/* 親要素のスタイルを完全にオーバーライド */
|
|
52
|
+
inset: 0 auto auto 0 !important;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* 背景色を印刷に含める */
|
|
56
|
+
* {
|
|
57
|
+
-webkit-print-color-adjust: exact !important;
|
|
58
|
+
print-color-adjust: exact !important;
|
|
59
|
+
color-adjust: exact !important;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;try{document.head.appendChild(s),e.classList.add("tatamicks-print-target"),t!=null&&t.title&&(document.title=t.title),(o=t==null?void 0:t.onBeforePrint)==null||o.call(t),window.print(),(a=t==null?void 0:t.onAfterPrint)==null||a.call(t)}finally{e.classList.remove("tatamicks-print-target");const i=document.getElementById("tatamicks-print-style");i&&i.remove(),document.title=n}}function Jo(e){Vn({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var s;(s=e==null?void 0:e.onBeforePrint)==null||s.call(e)},n=()=>{var s;(s=e==null?void 0:e.onAfterPrint)==null||s.call(e),Un({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function Qo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function es(e){return e==="fr"||e==="px"||e==="%"}function hn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&es(n.unit)}):!1}function ts(e){if(typeof e!="object"||e===null)return!1;const t=e;return hn(t.cols)&&hn(t.rows)}function ns(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const s=n.width;if(typeof s.value!="number"||typeof s.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const o=n.height;if(typeof o.value!="number"||typeof o.unit!="string"||typeof t.margin!="object"||t.margin===null)return!1;const a=t.margin;for(const i of["top","right","bottom","left"]){const l=a[i];if(typeof l!="object"||l===null)return!1;const c=l;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function rs(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function Fn(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!ns(t.paper))throw new Error("Invalid paper definition");if(!ts(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(Qo))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const s in n)if(!rs(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function $t(e){try{const t=JSON.parse(e);return Fn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Tt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function zn(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(zn):!1}function Wn(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!zn(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Ct(e){try{const t=JSON.parse(e);return Wn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Rt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Ke={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:de.SOLID}},ht={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},J={base:B.INTERACTION_LAYER_BASE,select_block:B.SELECT_BLOCK,block_ghost:B.BLOCK_GHOST,hover_outline:B.HOVER_OUTLINE,edit_block:B.EDIT_BLOCK,grid_ghost:B.GRID_GHOST,grid_handles:B.GRID_HANDLES,select_border:B.BLOCK_SELECT_BORDER,block_handles:B.BLOCK_HANDLES,rubber_band:B.RUBBER_BAND};var U=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(U||{}),H=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(H||{}),re=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(re||{}),G=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(G||{});const os="_interactionBlock_145kg_7",ss="_resizeHandle_145kg_7",Yn={interactionBlock:os,resizeHandle:ss},is=[{id:H.NW,cursor:"nwse-resize",x:0,y:0},{id:H.N,cursor:"ns-resize",x:50,y:0},{id:H.NE,cursor:"nesw-resize",x:100,y:0},{id:H.W,cursor:"ew-resize",x:0,y:50},{id:H.E,cursor:"ew-resize",x:100,y:50},{id:H.SW,cursor:"nesw-resize",x:0,y:100},{id:H.S,cursor:"ns-resize",x:50,y:100},{id:H.SE,cursor:"nwse-resize",x:100,y:100}],Ut=u.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=ht,zIndex:s=B.BLOCK_HANDLES})=>{const o=n.size,a=o/2;return r.jsx(r.Fragment,{children:is.map(({id:i,cursor:l,x:c,y:d})=>{const m=c===50?`calc(50% - ${a}px)`:c===100?`calc(100% - ${a}px)`:`-${a}px`,x=d===50?`calc(50% - ${a}px)`:d===100?`calc(100% - ${a}px)`:`-${a}px`,b=t===i;return r.jsx("div",{className:Yn.resizeHandle,onPointerDown:v=>{v.stopPropagation(),e(v,i)},style:{position:"absolute",left:m,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});Ut.displayName="ResizeHandles";const Hn=u.memo(({width:e,height:t,zIndex:n=B.BLOCK_SELECT_BORDER,borderStyle:s=Ke})=>{const o=u.useMemo(()=>new Ae(s),[s]),a={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:a,children:r.jsx(Ie,{width:e,height:t,border:o})})}),Le=u.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:a=Ke,handleStyle:i=ht,selectBorderZIndex:l=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{const d={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Yn.interactionBlock,style:d,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Hn,{width:t.width,height:t.height,zIndex:l,borderStyle:a}),n&&s&&r.jsx(Ut,{onResizeStart:s,activeHandle:o,handleStyle:i,zIndex:c})]})});Le.displayName="InteractionBlock";const Ft=u.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:s,currentMousePx:o,pluginKind:a,defaultSize:i,isOutside:l,selectionStyle:c,ghostZIndex:d=J.block_ghost,selectBorderZIndex:m=J.select_border,blockHandlesZIndex:x=J.block_handles})=>{const b=e[a];if(!b)return null;let v;if(l&&o){const y=Ne(b,{x:0,y:0,w:i.w,h:i.h}),f=n(y);v={left:o.x-f.width/2,top:o.y-f.height/2,width:f.width,height:f.height}}else{const y=t.cols-i.w,f=t.rows-i.h,p=Math.max(0,Math.min(s.col,y)),h=Math.max(0,Math.min(s.row,f)),w=Ne(b,{x:p,y:h,w:i.w,h:i.h});v=n(w)}const j=Ne(b,{x:0,y:0,w:i.w,h:i.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:d},children:r.jsx(He,{id:j.id,plugin:b,props:j.props,value:j.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:v,blockZIndex:d})}),r.jsx(Le,{block:j,rect:v,selectionStyle:c,selectBorderZIndex:m,blockHandlesZIndex:x})]})});Ft.displayName="InsertGhost";function zt(e,t,n,s,o){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const h=s-p.layout.w,w=o-p.layout.h,I=Math.max(0,Math.min(p.layout.x+t,h)),E=Math.max(0,Math.min(p.layout.y+n,w));return[{blockId:p.id,x:I,y:E}]}const a=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),l=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),d=l-a,m=c-i,x=a+t,b=i+n,v=Math.max(0,Math.min(x,s-d)),j=Math.max(0,Math.min(b,o-m)),y=v-a,f=j-i;return e.map(p=>({blockId:p.id,x:p.layout.x+y,y:p.layout.y+f}))}const Wt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:a,deltaRow:i,isOutside:l,currentMousePx:c,selectionStyle:d,ghostZIndex:m=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=o.map(y=>e.find(f=>f.id===y)).filter(Boolean),j=zt(v,a,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.map(y=>{const f=e.find(I=>I.id===y);if(!f)return null;const p=t[f.kind];if(!p)return null;let h;if(l&&c){const I=s(f);h={left:c.x-I.width/2,top:c.y-I.height/2,width:I.width,height:I.height}}else{const I=j.find(M=>M.blockId===f.id);if(!I)return null;const E={...f,layout:{...f.layout,x:I.x,y:I.y}};h=s(E)}const w={...f,layout:{...f.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:m},children:r.jsx(He,{id:w.id,plugin:p,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:h,blockZIndex:m,className:"ghost-content"})}),r.jsx(Le,{block:w,rect:h,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},y)})})});Wt.displayName="MovingGhost";function Yt({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:a}){const i={...e};if(t===H.E||t===H.NE||t===H.SE){const l=o-e.x;i.w=Math.max(1,Math.min(e.w+n,l))}else if(t===H.W||t===H.NW||t===H.SW){const l=e.w-1,c=n>0?Math.min(n,l):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===H.S||t===H.SE||t===H.SW){const l=a-e.y;i.h=Math.max(1,Math.min(e.h+s,l))}else if(t===H.N||t===H.NE||t===H.NW){const l=e.h-1,c=s>0?Math.min(s,l):s;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const Ht=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:o,handle:a,deltaCol:i,deltaRow:l,isOutside:c,selectionStyle:d,ghostZIndex:m=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=e.find(h=>h.id===o),j=t[(v==null?void 0:v.kind)??""];if(!v||!j)return null;const y=Yt({layout:v.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),f={...v,layout:y},p=s(f);return r.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:m},children:r.jsx(He,{id:f.id,plugin:j,props:f.props,value:f.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:p,blockZIndex:m,className:"resize-ghost-content"})}),r.jsx(Le,{block:f,rect:p,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},v.id)})});Ht.displayName="ResizeGhost";const Kt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:a=Ke,ghostZIndex:i=J.block_ghost,selectBorderZIndex:l=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{if(!s)return null;const d=s.currentGrid.col-s.startGrid.col,m=s.currentGrid.row-s.startGrid.row;switch(s.type){case re.MOVE:return r.jsx(Wt,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:d,deltaRow:m,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c});case re.RESIZE:{const x=s.blockIds[0];return!x||!s.handle?null:r.jsx(Ht,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:x,handle:s.handle,deltaCol:d,deltaRow:m,isOutside:s.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c})}case re.INSERT:return s.defaultSize?r.jsx(Ft,{pluginRegistry:t,gridLength:n,getBlockRectPx:o,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,pluginKind:s.pluginKind||"",defaultSize:s.defaultSize,isOutside:s.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});Kt.displayName="DragLayer";const as=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,blockRectPx:i,zIndex:l=B.EDIT_BLOCK,validationState:c,className:d=""},m)=>{const x=u.useRef(null);u.useImperativeHandle(m,()=>({focus:()=>{var f;(f=x.current)==null||f.focus()}}),[]);const b=Bt(i,{zIndex:l,pointerEvents:"auto"}),v={width:i.width,height:i.height},j={id:e,props:n,value:s,onChange:o,onBlur:a,readOnly:!1,mode:ae.FORM,dimensions:{widthPx:v.width,heightPx:v.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(y,{ref:x,...j})})},ls=u.forwardRef(as),Kn=u.memo(ls);function Xn(e){const[t,n]=u.useState({mode:U.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=u.useCallback(o=>{n(a=>{switch(o.type){case G.SELECT:{const i=o.blockIds;return{...a,mode:U.IDLE,selectedBlockIds:i}}case G.DESELECT:return{...a,mode:U.IDLE,selectedBlockIds:[]};case G.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...a,mode:U.PRESSING,dragging:{type:re.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case G.UPDATE_DRAG:{if(!a.dragging)return a;const i=o.currentGrid.col!==a.dragging.startGrid.col||o.currentGrid.row!==a.dragging.startGrid.row;return a.mode===U.PRESSING?i?{...a,mode:U.DRAGGING,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a.mode===U.DRAGGING?{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a}case G.END_DRAG:return{...a,mode:U.IDLE,dragging:void 0};case G.CANCEL_DRAG:return{...a,mode:U.IDLE,dragging:void 0};case G.EDIT:return{...a,mode:U.EDITING,editingBlockId:o.blockId};case G.END_EDIT:return{...a,mode:U.IDLE,editingBlockId:null};case G.START_INSERT:return{...a,mode:U.DRAGGING,dragging:{type:re.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:o.pluginKind,defaultSize:o.defaultSize,isOutside:!1}};case G.CANCEL_INSERT:return{...a,mode:U.IDLE,dragging:void 0};case G.START_RESIZE:return{...a,mode:U.DRAGGING,dragging:{type:re.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return a}})},[]);return[t,s]}const Xt=u.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:a,selectionStyle:i=Ke,handleStyle:l=ht,selectBorderZIndex:c=J.select_border,blockHandlesZIndex:d=J.block_handles})=>{if(n&&(s==null?void 0:s.type)!==re.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const v=e.find(f=>f.id===b);if(!v)return null;const y=(s==null?void 0:s.type)===re.RESIZE&&s.blockIds.includes(b)?s==null?void 0:s.handle:null;return r.jsx(Le,{block:v,rect:o(v),showHandles:!0,onResizeStart:(f,p)=>a(f,p,b),activeHandle:y,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:d},v.id)})})});Xt.displayName="SelectionLayer";function qn(e,t,n,s){const o=n-t.w,a=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,a))}}function Mt(e,t,n){const{x:s,y:o}=e;for(let a=t.length-1;a>=0;a--){const i=t[a];if(!i)continue;const l=n(i);if(s>=l.left&&s<=l.left+l.width&&o>=l.top&&o<=l.top+l.height)return i.id}return null}const qt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:a,state:i,onChange:l,onBlockChange:c,scale:d=1,className:m="",selectionStyle:x,handleStyle:b,editBlockZIndex:v=B.EDIT_BLOCK,selectBorderZIndex:j=J.select_border,blockHandlesZIndex:y=J.block_handles,dragGhostZIndex:f=J.block_ghost})=>{const p=u.useRef(null),h=u.useRef(null);u.useEffect(()=>{i.mode===U.EDITING&&i.editingBlockId&&setTimeout(()=>{var _;(_=h.current)==null||_.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const _=new Set(e.map(k=>k.id)),T=i.selectedBlockIds.filter(k=>_.has(k));T.length!==i.selectedBlockIds.length&&l({type:G.SELECT,blockIds:T,shiftKey:!1})},[e,i.selectedBlockIds,l]);const w=u.useCallback(_=>{var D;if(_.button!==0)return;const T=(D=p.current)==null?void 0:D.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(_.clientX-T.left)/k,y:(_.clientY-T.top)/k},R=Mt(O,e,s);if(i.mode===U.EDITING){R!==i.editingBlockId&&(l({type:G.END_EDIT}),R||l({type:G.DESELECT}));return}const L=o(O.x),N=a(O.y);if(R){_.stopPropagation();const P=i.selectedBlockIds.includes(R);if(P&&_.shiftKey){const S=i.selectedBlockIds.filter(F=>F!==R);l({type:G.SELECT,blockIds:S,shiftKey:!0});return}else P?(_.currentTarget.setPointerCapture(_.pointerId),l({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(_.currentTarget.setPointerCapture(_.pointerId),_.shiftKey?l({type:G.SELECT,blockIds:[...i.selectedBlockIds,R],shiftKey:!0}):(l({type:G.SELECT,blockIds:[R]}),l({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:[R]})))}else _.stopPropagation(),l({type:G.DESELECT})},[e,s,o,a,i.mode,i.selectedBlockIds,l,d,i.editingBlockId]),I=u.useCallback(_=>{var X;if(i.mode!==U.PRESSING&&i.mode!==U.DRAGGING||!i.dragging)return;const T=(X=p.current)==null?void 0:X.getBoundingClientRect();if(!T)return;const k=d??1,O=T.width/k,R=T.height/k,L=(_.clientX-T.left)/k,N=(_.clientY-T.top)/k,D=i.dragging.type!==re.RESIZE&&(L<0||L>O||N<0||N>R),P=Math.max(0,Math.min(L,O)),S=Math.max(0,Math.min(N,R)),F=o(P),K=a(S);l({type:G.UPDATE_DRAG,currentGrid:{col:F,row:K},currentMousePx:{x:L,y:N},isOutside:D})},[i.mode,i.dragging,o,a,l,d]),E=u.useCallback(_=>{if(i.mode===U.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===re.MOVE&&(c==null||c({type:ce.DELETE,blockIds:i.dragging.blockIds}),l({type:G.DESELECT})),l({type:G.END_DRAG}),_.currentTarget.releasePointerCapture(_.pointerId);return}const T=i.dragging.currentGrid.col-i.dragging.startGrid.col,k=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===re.MOVE){if(T!==0||k!==0){const O=i.dragging.blockIds.map(N=>e.find(D=>D.id===N)).filter(Boolean);if(O.length===0){l({type:G.END_DRAG}),_.currentTarget.releasePointerCapture(_.pointerId);return}const R=zt(O,T,k,n.cols,n.rows),L=O.map(N=>{const D=R.find(P=>P.blockId===N.id);return D?{...N,layout:{...N.layout,x:D.x,y:D.y}}:N});c==null||c({type:ce.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===re.INSERT){const{pluginKind:O,currentGrid:R,defaultSize:L}=i.dragging;if(O&&L){const N=t[O];if(N){const{x:D,y:P}=qn({x:R.col,y:R.row},{w:L.w,h:L.h},n.cols,n.rows),S=Ne(N,{x:D,y:P,w:L.w,h:L.h});c==null||c({type:ce.ADD,blockIds:[S.id],blocks:[S]})}}}else if(i.dragging.type===re.RESIZE){const O=i.dragging.blockIds[0],R=e.find(N=>N.id===O),L=i.dragging.handle;if(R&&L&&(T!==0||k!==0)){const N=Yt({layout:R.layout,handle:L,deltaCol:T,deltaRow:k,gridCols:n.cols,gridRows:n.rows});(N.x!==R.layout.x||N.y!==R.layout.y||N.w!==R.layout.w||N.h!==R.layout.h)&&(c==null||c({type:ce.RESIZE,blockIds:[R.id],blocks:[{...R,layout:N}]}))}}l({type:G.END_DRAG})}else i.mode===U.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===re.MOVE&&(c==null||c({type:ce.DELETE,blockIds:i.dragging.blockIds}),l({type:G.DESELECT})),l({type:G.CANCEL_DRAG}));_.currentTarget.releasePointerCapture(_.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),M=u.useCallback(_=>{var L;const T=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(_.clientX-T.left)/k,y:(_.clientY-T.top)/k},R=Mt(O,e,s);R&&(i.selectedBlockIds.includes(R)||l({type:G.SELECT,blockIds:[R]}),l({type:G.EDIT,blockId:R}))},[e,s,l,d,i.selectedBlockIds]),$=u.useCallback(_=>{var T;if((i.mode===U.PRESSING||i.mode===U.DRAGGING)&&i.dragging){const k=(T=p.current)==null?void 0:T.getBoundingClientRect();if(k){const O=d??1,R=(_.clientX-k.left)/O,L=(_.clientY-k.top)/O,N=k.width/O,D=k.height/O,P=Math.max(0,Math.min(R,N)),S=Math.max(0,Math.min(L,D));l({type:G.UPDATE_DRAG,currentGrid:{col:o(P),row:a(S)},currentMousePx:{x:R,y:L},isOutside:!0})}}},[i.mode,i.dragging,d,o,a,l]);return r.jsxs("div",{ref:p,className:m,style:{position:"absolute",inset:0,zIndex:B.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:w,onPointerMove:I,onPointerUp:E,onPointerLeave:$,onDoubleClick:M,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const _=e.find(k=>k.id===i.editingBlockId),T=_?t[_.kind]:null;return!_||!T?null:r.jsx(Kn,{ref:h,id:_.id,plugin:T,props:_.props,value:_.initValue,onChange:k=>{c==null||c({type:ce.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:k}]})},onBlur:k=>{c==null||c({type:ce.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:k}]})},blockRectPx:s(_),zIndex:v})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(_,T,k)=>{var N;const O=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!O)return;i.mode===U.EDITING&&l({type:G.END_EDIT}),_.currentTarget.setPointerCapture(_.pointerId);const R=d??1,L={x:(_.clientX-O.left)/R,y:(_.clientY-O.top)/R};l({type:G.START_RESIZE,blockId:k,handle:T,startGrid:{col:o(L.x),row:a(L.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:j,blockHandlesZIndex:y}),r.jsx(Kt,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:f,selectBorderZIndex:j,blockHandlesZIndex:y})]})});qt.displayName="InteractionLayer";function Xe(e,t,n=W){const s=u.useMemo(()=>Y.fromDim(e.size.width),[e.size.width]),o=u.useMemo(()=>Y.fromDim(e.size.height),[e.size.height]),a=u.useMemo(()=>Y.fromDim(e.margin.top),[e.margin.top]),i=u.useMemo(()=>Y.fromDim(e.margin.bottom),[e.margin.bottom]),l=u.useMemo(()=>Y.fromDim(e.margin.left),[e.margin.left]),c=u.useMemo(()=>Y.fromDim(e.margin.right),[e.margin.right]),d=u.useMemo(()=>s-l-c,[s,l,c]),m=u.useMemo(()=>o-a-i,[o,a,i]),x=u.useMemo(()=>ot(t.cols,d),[t.cols,d]),b=u.useMemo(()=>ot(t.rows,m),[t.rows,m]),v=u.useMemo(()=>V.fromMm(s,n),[s,n]),j=u.useMemo(()=>V.fromMm(o,n),[o,n]),y=u.useMemo(()=>V.fromMm(a,n),[a,n]),f=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>V.fromMm(m,n),[m,n]),E=u.useMemo(()=>st(x,n),[x,n]),M=u.useMemo(()=>st(b,n),[b,n]),$=u.useMemo(()=>{const A=[0];for(const z of E){const he=A[A.length-1]??0;A.push(he+z)}return A},[E]),_=u.useMemo(()=>{const A=[0];for(const z of M){const he=A[A.length-1]??0;A.push(he+z)}return A},[M]),{step:T,windowPx:k}=u.useMemo(()=>Nt($),[$]),{step:O,windowPx:R}=u.useMemo(()=>Nt(_),[_]),L=u.useMemo(()=>It($,T,k),[$,T,k]),N=u.useMemo(()=>It(_,O,R),[_,O,R]),D=u.useCallback(A=>L(A-p),[L,p]),P=u.useCallback(A=>N(A-y),[N,y]),S=u.useMemo(()=>({cols:$,rows:_}),[$,_]),F=u.useMemo(()=>({width:v,height:j}),[v,j]),K=u.useMemo(()=>({top:y,bottom:f,left:p,right:h}),[y,f,p,h]),X=u.useMemo(()=>({width:w,height:I}),[w,I]),g=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),C=u.useCallback(A=>{const{x:z,y:he,w:Oe,h:q}=A.layout,ue=S.cols,ve=S.rows;if(!ue.length||!ve.length)return{left:0,top:0,width:0,height:0};const qe=Math.min(Math.max(0,z),ue.length-1),mr=Math.min(Math.max(0,z+Oe),ue.length-1),an=Math.min(Math.max(0,he),ve.length-1),hr=Math.min(Math.max(0,he+q),ve.length-1),fr=(ue[qe]??0)+p,pr=(ve[an]??0)+y,xr=(ue[mr]??0)-(ue[qe]??0),br=(ve[hr]??0)-(ve[an]??0);return{left:fr,top:pr,width:xr,height:br}},[S,p,y]);return{paperPx:g,gridPosPx:S,getColIndex:D,getRowIndex:P,getBlockRectPx:C}}const Zn=({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:a})=>{const{paperPx:i,gridPosPx:l,getBlockRectPx:c}=Xe(e.paper,e.grid,W),d=u.useCallback((m,x)=>{s&&s(m,x)},[s]);return r.jsxs("div",{className:a,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(mt,{paperPx:i,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.EDIT,values:t,getBlockRectPx:c,onValueChange:d,showGuides:!0,showBorder:!0})]})};Zn.displayName="NoteEdit";const Jn=u.memo(Zn),Qn=({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:a})=>{const[i,l]=Xn(),c=u.useRef(null),{paperPx:d,gridPosPx:m,getBlockRectPx:x,getColIndex:b,getRowIndex:v}=Xe(e.paper,e.grid,W),j=u.useCallback(E=>{if(n)switch(E.type){case ce.MOVE:case ce.RESIZE:{if(!E.blocks)return;const M=e.blocks.map($=>{var T;return((T=E.blocks)==null?void 0:T.find(k=>k.id===$.id))||$});n({...e,blocks:M});break}case ce.ADD:{if(!E.blocks)return;n({...e,blocks:[...e.blocks,...E.blocks]});break}case ce.DELETE:{const M=new Set(E.blockIds),$=e.blocks.filter(_=>!M.has(_.id));n({...e,blocks:$});break}case ce.UPDATE:{if(!E.blocks)return;const M=e.blocks.map($=>{var O;const _=(O=E.blocks)==null?void 0:O.find(R=>R.id===$.id);if(!_)return $;const T=_.style?it(_.style):_.style,k=_.props?it(_.props):_.props;return{...$,..._,style:T,props:k}});n({...e,blocks:M});break}}},[e,n]),y=u.useCallback((E,M)=>{if(!n)return;const $=e.blocks.map(_=>_.id===E?{..._,initValue:M}:_);n({...e,blocks:$})},[e,n]);u.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]),u.useEffect(()=>{const E=ze.subscribe(M=>{var $;!M&&i.mode===U.DRAGGING&&(($=i.dragging)==null?void 0:$.type)===re.INSERT&&l({type:G.CANCEL_INSERT})});return()=>E()},[i.mode,i.dragging,l]),u.useEffect(()=>{const E=M=>{if(i.selectedBlockIds.length===0)return;const $=M.target;$ instanceof HTMLElement&&$.closest('[data-sidebar="true"]')||c.current&&!c.current.contains($)&&l({type:G.DESELECT})};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[i.selectedBlockIds,l]);const f=u.useCallback((E,M,$)=>{if(!n)return;const _=M-1;if(E==="column"){const T=jt(e.grid.cols,_,$,d.content.width);n({...e,grid:{...e.grid,cols:T}})}else{const T=jt(e.grid.rows,_,$,d.content.height);n({...e,grid:{...e.grid,rows:T}})}},[e,d,n]),p=u.useCallback((E,M,$)=>{if(n)if(E==="column"){const _=[...e.grid.cols];_[M]=$,n({...e,grid:{...e.grid,cols:_}})}else{const _=[...e.grid.rows];_[M]=$,n({...e,grid:{...e.grid,rows:_}})}},[n,e]),h=u.useMemo(()=>e.blocks.reduce((E,M)=>(E[M.id]=M.initValue,E),{}),[e.blocks]),w=u.useCallback(()=>{const E=ze.get();E&&(i.mode===U.DRAGGING||i.dragging||l({type:G.START_INSERT,pluginKind:E.kind,defaultSize:E.defaultSize}))},[i.mode,i.dragging,l]),I=u.useCallback(()=>{},[]);return r.jsxs("div",{ref:c,className:a,onPointerEnter:w,onPointerLeave:I,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(mt,{paperPx:d,gridPosPxs:m,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:f,onDimensionChange:p,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:de.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:de.SOLID}}}),r.jsx(Se,{blocks:e.blocks,pluginRegistry:t,mode:ae.FORM,values:h,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:x,onValueChange:y,showGuides:!0,showBorder:!0}),r.jsx(qt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:x,getColIndex:b,getRowIndex:v,state:i,onChange:l,onBlockChange:j,scale:o})]})};Qn.displayName="NoteForm";const er=u.memo(Qn),tr=({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o})=>{const{paperPx:a,gridPosPx:i,getBlockRectPx:l}=Xe(e.paper,e.grid,W);return r.jsxs("div",{className:o,style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(mt,{paperPx:a,gridPosPxs:i,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.VIEW,values:t,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};tr.displayName="NoteView";const nr=u.memo(tr),rr=({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:a,onSelectionChange:i,scale:l=1,className:c})=>{const d=u.useCallback((m,x)=>{if(a)if(x==null){const{[m]:b,...v}=t;a(v)}else a({...t,[m]:x})},[t,a]);return n===ae.FORM?r.jsx(er,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:l,className:c}):n===ae.EDIT?r.jsx(Jn,{schema:e,values:t,pluginRegistry:s,onValueChange:d,scale:l,className:c}):r.jsx(nr,{schema:e,values:t,pluginRegistry:s,scale:l,className:c})};rr.displayName="NoteEditor";const cs=u.memo(rr),or=({schema:e,values:t,pluginRegistry:n,className:s},o)=>{const a=u.useRef(null),{paperPx:i,getBlockRectPx:l}=Xe(e.paper,e.grid,W);return u.useEffect(()=>{const{size:c}=e.paper,d=Y.fromDim(c.width),m=Y.fromDim(c.height),x=document.getElementById("printable-note-page-style");x&&x.remove();const b=document.createElement("style");return b.id="printable-note-page-style",b.textContent=`
|
|
63
|
+
@media print {
|
|
64
|
+
@page {
|
|
65
|
+
size: ${d}mm ${m}mm;
|
|
66
|
+
margin: 0;
|
|
31
67
|
}
|
|
32
|
-
`,document.head.appendChild(v),()=>{const m=document.getElementById("dynamic-print-page-style");m&&m.remove()}},[i]),u.useImperativeHandle(a,()=>({print:()=>{Dt({title:"Document"})},openPrintPreview:()=>{Dt({title:"Document"})}}),[]),r.jsxs("div",{ref:c,className:o,"data-print-mode":l,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:d,gridPosPxs:f,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.VIEW,values:t,getBlockRectPx:x,showGuides:!1,showBorder:!0})]})};Qn.displayName="NoteView";const er=u.memo(u.forwardRef(Qn)),tr=u.memo(({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:l,onSelectionChange:i,scale:a=1,className:c})=>{const d=u.useCallback((f,x)=>{if(l)if(x==null){const{[f]:b,...v}=t;l(v)}else l({...t,[f]:x})},[t,l]);return n===ce.FORM?r.jsx(Jt,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:a,className:c}):n===ce.EDIT?r.jsx(Zt,{schema:e,values:t,pluginRegistry:s,onValueChange:d,scale:a,className:c}):r.jsx(er,{schema:e,values:t,pluginRegistry:s,scale:a,className:c})});tr.displayName="NoteEditor";function be(e,t){if(e.length===0)return;const n=(i,a)=>{let c=i;for(const d of a){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[d]}return c},s=t.split("."),o=n(e[0],s);return e.every(i=>n(i,s)===o)?o:void 0}const ss="_container_1tfjv_1",is="_row_1tfjv_20",ls="_inputWrapper_1tfjv_37",_t={container:ss,row:is,inputWrapper:ls},nr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(l=>{o[l.id]={style:{...l.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:_t.container,children:r.jsx("div",{className:_t.row,children:r.jsx("div",{className:_t.inputWrapper,children:r.jsx(ze,{value:be(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _e(e,t,n){const s=t.split("."),o=(l,i)=>{const a=s[i];if(i===s.length-1){if(n==null){const{[a]:f,...x}=l;return x}return{...l,[a]:n}}const c=(l==null?void 0:l[a])||{},d=o(c,i+1);if(Object.keys(d).length===0){const{[a]:f,...x}=l;return x}return{...l,[a]:d}};return o(e,0)}const rr=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,a,c)=>{const d={};e.forEach(f=>{var b,v,j;let x=_e(f.style||{},`border.${i}.${a}`,c);if(a==="type"&&c==null&&(x=_e(x,`border.${i}.width`,void 0),x=_e(x,`border.${i}.color`,void 0)),a==="type"&&c!==void 0&&c!==null){const y=(b=f.style)==null?void 0:b.border,h=y==null?void 0:y[i];h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"})),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}if(a==="color"&&c!==void 0&&c!==null){const y=(v=f.style)==null?void 0:v.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"}))}if(a==="width"&&c!==void 0&&c!==null){const y=(j=f.style)==null?void 0:j.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}d[f.id]={style:x}}),t(d)},s=u.useMemo(()=>{var f;if(e.length!==1)return null;const i=e[0];if(!((f=i==null?void 0:i.style)!=null&&f.border))return null;const a=i.style.border;if(!a)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(a[x]))?new Ae(a):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(we,{value:be(e,`style.border.${i}.type`),onChange:a=>n(i,"type",a),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:de.SOLID},{label:"破線",value:de.DASHED},{label:"点線",value:de.DOTTED}]}),r.jsx(oe,{value:be(e,`style.border.${i}.width`),onChange:a=>n(i,"width",a),placeholder:"太さ",height:24,allowedUnits:gn,min:1}),r.jsx(ze,{value:be(e,`style.border.${i}.color`),onChange:a=>n(i,"color",a),placeholder:"色",height:24,allowUndefined:!0})]}),l={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return r.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[r.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:r.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[r.jsx("title",{children:"枠線ガイド"}),r.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),r.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),s?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(Ie,{width:80,height:80,border:s})}):r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[r.jsx("title",{children:"枠線未設定"}),r.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),r.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:r.jsxs(Lt,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ot,{style:{width:"100%",display:"flex"},children:[r.jsx(ye,{value:"all",height:24,style:l,children:"共通"}),r.jsx(ye,{value:"top",height:24,style:l,children:"上"}),r.jsx(ye,{value:"bottom",height:24,style:l,children:"下"}),r.jsx(ye,{value:"left",height:24,style:l,children:"左"}),r.jsx(ye,{value:"right",height:24,style:l,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Ee,{value:"all",children:o("all")}),r.jsx(Ee,{value:"top",children:o("top")}),r.jsx(Ee,{value:"bottom",children:o("bottom")}),r.jsx(Ee,{value:"left",children:o("left")}),r.jsx(Ee,{value:"right",children:o("right")})]})]})})]})},as="_container_1daw7_1",cs="_grid_1daw7_19",us="_field_1daw7_26",ds="_label_1daw7_33",hs="_inputWrapper_1daw7_43",le={container:as,grid:cs,field:us,label:ds,inputWrapper:hs},or=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(a=>a.layout.x)):void 0,l=s?Math.min(...e.map(a=>a.layout.y)):void 0,i=(a,c)=>{if(c===void 0)return;const d={};if(s&&(a==="x"||a==="y")){const f=a==="x"?o:l;if(f===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),b=Math.max(...e.map(p=>p.layout.y+p.layout.h)),v=x-(o??0),j=b-(l??0);let y=c;a==="x"&&n?y=Math.max(0,Math.min(c,n.cols-v)):a==="y"&&n?y=Math.max(0,Math.min(c,n.rows-j)):y=Math.max(0,c);const h=y-f;e.forEach(p=>{const m=p.layout[a]+h;d[p.id]={layout:{...p.layout,[a]:m}}})}else e.forEach(f=>{let x=c;if(a==="x"&&n)x=Math.max(0,Math.min(c,n.cols-f.layout.w));else if(a==="y"&&n)x=Math.max(0,Math.min(c,n.rows-f.layout.h));else if(a==="w"&&n){const b=n.cols-f.layout.x;x=Math.max(1,Math.min(c,b))}else if(a==="h"&&n){const b=n.rows-f.layout.y;x=Math.max(1,Math.min(c,b))}else a==="w"||a==="h"?x=Math.max(1,c):x=Math.max(0,c);d[f.id]={layout:{...f.layout,[a]:x}}});t(d)};return r.jsx("div",{className:le.container,children:r.jsxs("div",{className:le.grid,children:[r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"X"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?o:be(e,"layout.x"),onChange:a=>i("x",a),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"Y"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?l:be(e,"layout.y"),onChange:a=>i("y",a),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"W"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.w"),onChange:a=>i("w",a),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"H"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.h"),onChange:a=>i("h",a),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ms="_container_1h4w8_1",fs="_row_1h4w8_10",ps="_label_1h4w8_16",xs="_inputWrapper_1h4w8_25",De={container:ms,row:fs,label:ps,inputWrapper:xs},sr=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=u.useState(""),o=e[0];u.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const l=()=>{if(!o)return;const c=o.id,d=n.trim();if(d===c||!d){s(c);return}t({[c]:{id:d}})},i=c=>{s(c??"")},a=c=>{const d={};e.forEach(f=>{d[f.id]={behavior:{...f.behavior,readOnly:!!c}}}),t(d)};return r.jsxs("div",{className:De.container,children:[e.length===1&&r.jsxs("div",{className:De.row,children:[r.jsx("span",{className:De.label,children:"ID"}),r.jsx("div",{className:De.inputWrapper,children:r.jsx(Pe,{value:n,onChange:i,onBlur:l,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:De.row,children:r.jsx("div",{className:De.inputWrapper,children:r.jsx(xe,{label:"読み取り専用",value:!!be(e,"behavior.readOnly"),onChange:a})})})]})},bs="_container_wa11y_1",vs="_scrollArea_wa11y_18",gs="_section_wa11y_26",ws="_sectionTitle_wa11y_35",_s="_subsection_wa11y_47",ys="_subsectionTitle_wa11y_51",Es="_fields_wa11y_59",js="_emptyState_wa11y_69",se={container:bs,scrollArea:vs,section:gs,sectionTitle:ws,subsection:_s,subsectionTitle:ys,fields:Es,emptyState:js},Ns="_field_qo0ef_1",Is="_label_qo0ef_7",Ds="_mixed_qo0ef_15",$s="_description_qo0ef_22",Je={field:Ns,label:Is,mixed:Ds,description:$s},ft=u.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var f;const o=t.Component;if(!o)return null;const l=be(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&l===void 0&&n.length>1,d={value:c?void 0:l!==void 0?l:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(f=t.config)==null?void 0:f.placeholder}};return r.jsxs("div",{className:Je.field,children:[t.label&&r.jsx("div",{className:Je.label,title:t.description,children:t.label}),r.jsx(o,{...d}),c&&r.jsx("span",{className:Je.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:Je.description,children:t.description})]})});ft.displayName="PropertyField";function Ts(e){return e!==!1}const Qt=u.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const l=e[0],i=l?t[l.kind]:void 0,a=u.useMemo(()=>{var x;if(e.length===0)return!1;const f=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===f)},[e]),c=u.useMemo(()=>{if(!l||!i)return{};const f={};let x;if(a)x=Object.entries(i.properties);else{const b=e.map(h=>t[h.kind]).filter(h=>h!==void 0);if(b.length===0)return{};const v=b[0];if(!v)return{};const j=new Set(Object.keys(v.properties));x=Array.from(j).filter(h=>b.every(p=>h in p.properties)).map(h=>{const p=i.properties[h];return p?[h,p]:null}).filter(h=>h!==null)}return x.forEach(([b,v])=>{if(!Ts(v)||e.length>1&&v.disableInMultiSelection||v.condition&&!v.condition(l.props))return;const j=v.group||"基本";f[j]||(f[j]=[]),v.Component&&f[j].push({key:b,definition:v})}),f},[i,t,e,l,a]),d=(f,x)=>{const b={};e.forEach(v=>{b[v.id]={props:{...v.props,[f]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.scrollArea,children:[r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"配置・サイズ"}),r.jsx(or,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"背景"}),r.jsx(nr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"枠線"}),r.jsx(rr,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:se.section,children:Object.entries(c).map(([f,x])=>r.jsxs("div",{className:se.subsection,children:[r.jsx("div",{className:se.subsectionTitle,children:f}),r.jsx("div",{className:se.fields,children:x.map(({key:b,definition:v})=>r.jsx(ft,{propertyKey:b,definition:v,selectedBlocks:e,onChange:d},b))})]},f))}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"基本設定"}),r.jsx(sr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});Qt.displayName="BlockPropertyPanel";const Rs="_panel_1h33v_1",Cs="_header_1h33v_11",Ms="_group_1h33v_18",ks="_groupTitle_1h33v_26",Ps="_groupContent_1h33v_36",Be={panel:Rs,header:Cs,group:Ms,groupTitle:ks,groupContent:Ps};function As(e){return e!==!1}const Ss=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const s=e[0],o=s?t[s.kind]:void 0,l=u.useMemo(()=>{if(!s||!o)return{};const a={};return Object.entries(o.properties).forEach(([c,d])=>{if(!As(d)||e.length>1&&d.disableInMultiSelection||d.condition&&!d.condition(s.props))return;const f=d.group||"基本";a[f]||(a[f]=[]),d.Component&&a[f].push({key:c,definition:d})}),a},[o,e.length,s]),i=(a,c)=>{const d={};e.forEach(f=>{d[f.id]={props:{...f.props,[a]:c}}}),n(d)};return!s||!o||e.length===0?null:r.jsxs("div",{className:Be.panel,children:[r.jsx("div",{className:Be.header,children:e.length>1?`${e.length}個のブロック`:o.meta.displayName}),Object.entries(l).map(([a,c])=>r.jsxs("div",{className:Be.group,children:[r.jsx("div",{className:Be.groupTitle,children:a}),r.jsx("div",{className:Be.groupContent,children:c.map(({key:d,definition:f})=>r.jsx(ft,{propertyKey:d,definition:f,selectedBlocks:e,onChange:i},d))})]},a))]})},Ls="_panel_1ekwd_6",Os="_title_1ekwd_10",Gs="_content_1ekwd_22",Bs="_description_1ekwd_29",Vs="_list_1ekwd_35",Us="_item_1ekwd_44",Fs="_dragging_1ekwd_61",zs="_dragOver_1ekwd_66",Ws="_dragHandle_1ekwd_71",Ys="_itemInfo_1ekwd_86",Hs="_itemId_1ekwd_93",Ks="_itemMeta_1ekwd_98",Xs="_itemKind_1ekwd_105",qs="_itemActions_1ekwd_113",Zs="_actionButton_1ekwd_118",Js="_empty_1ekwd_154",Q={panel:Ls,title:Os,content:Gs,description:Bs,list:Vs,item:Us,dragging:Fs,dragOver:zs,dragHandle:Ws,itemInfo:Ys,itemId:Hs,itemMeta:Ks,itemKind:Xs,itemActions:qs,actionButton:Zs,empty:Js},en=({blocks:e,onBlocksChange:t})=>{const[n,s]=u.useState(null),[o,l]=u.useState(null),i=[...e].reverse(),a=u.useCallback(h=>{const p=e.findIndex(I=>I.id===h);if(p===-1||p===e.length-1)return;const m=[...e],[w]=m.splice(p,1);w&&(m.push(w),t(m))},[e,t]),c=u.useCallback(h=>{const p=e.findIndex(I=>I.id===h);if(p===-1||p===0)return;const m=[...e],[w]=m.splice(p,1);w&&(m.unshift(w),t(m))},[e,t]),d=u.useCallback(h=>{const p=e.findIndex(E=>E.id===h);if(p===-1||p===e.length-1)return;const m=[...e],w=m[p],I=m[p+1];!w||!I||(m[p]=I,m[p+1]=w,t(m))},[e,t]),f=u.useCallback(h=>{const p=e.findIndex(E=>E.id===h);if(p===-1||p===0)return;const m=[...e],w=m[p],I=m[p-1];!w||!I||(m[p]=I,m[p-1]=w,t(m))},[e,t]),x=u.useCallback((h,p)=>{var w;s(p),h.dataTransfer.effectAllowed="move";const m=e.length-1-p;h.currentTarget&&h.dataTransfer.setData("text/plain",((w=e[m])==null?void 0:w.id)||"")},[e]),b=u.useCallback(()=>{s(null),l(null)},[]),v=u.useCallback((h,p)=>{h.preventDefault(),h.dataTransfer.dropEffect="move",!(n===null||n===p)&&l(p)},[n]),j=u.useCallback(()=>{l(null)},[]),y=u.useCallback((h,p)=>{if(h.preventDefault(),n===null||n===p){s(null),l(null);return}const m=e.length-1-n,w=e.length-1-p,I=[...e],[E]=I.splice(m,1);E&&(I.splice(w,0,E),t(I),s(null),l(null))},[e,n,t]);return r.jsxs("div",{className:Q.panel,children:[r.jsx("h3",{className:Q.title,children:"ブロック順序"}),r.jsxs("div",{className:Q.content,children:[r.jsx("p",{className:Q.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:Q.list,children:i.map((h,p)=>{const m=e.length-1-p;return r.jsxs("li",{className:`${Q.item} ${n===p?Q.dragging:""} ${o===p?Q.dragOver:""}`,onDragOver:w=>v(w,p),onDragLeave:j,onDrop:w=>y(w,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>x(w,p),onDragEnd:b,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"ドラッグハンドル"}),r.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),r.jsxs("div",{className:Q.itemInfo,children:[r.jsx("div",{className:Q.itemId,children:h.id}),r.jsx("div",{className:Q.itemMeta,children:r.jsx("span",{className:Q.itemKind,children:h.kind})})]}),r.jsxs("div",{className:Q.itemActions,children:[r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>a(h.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最前面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>d(h.id),title:"前面へ","aria-label":"前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"前面へ"}),r.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),r.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>f(h.id),title:"背面へ","aria-label":"背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"背面へ"}),r.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>c(h.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最背面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},h.id)})}),e.length===0&&r.jsx("div",{className:Q.empty,children:"ブロックがありません"})]})]})};en.displayName="BlockOrderPanel";const tn=({schema:e,onSchemaChange:t})=>{const n=u.useCallback(l=>{t({...e,paper:l})},[e,t]),s=u.useCallback(l=>{t({...e,grid:l})},[e,t]),o=u.useCallback(l=>{t({...e,blocks:l})},[e,t]);return r.jsxs(St,{children:[r.jsx(on,{paper:e.paper,onPaperChange:n}),r.jsx(rn,{paper:e.paper,onPaperChange:n}),r.jsx(nn,{grid:e.grid,onGridChange:s}),r.jsx(en,{blocks:e.blocks,onBlocksChange:o})]})};tn.displayName="CanvasPanel";const Qs="_panel_1axyd_6",ei="_title_1axyd_10",ti="_content_1axyd_22",ni="_field_1axyd_29",ri="_horizontal_1axyd_35",oi="_label_1axyd_41",si="_gridSizeRow_1axyd_52",ge={panel:Qs,title:ei,content:ti,field:ni,horizontal:ri,label:oi,gridSizeRow:si},nn=({grid:e,onGridChange:t})=>{const n=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.cols.length,i=[];if(o>l){i.push(...e.cols);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,o));t({...e,cols:i})},[e,t]),s=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.rows.length,i=[];if(o>l){i.push(...e.rows);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,o));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:ge.panel,children:[r.jsx("h3",{className:ge.title,children:"グリッドサイズ"}),r.jsx("div",{className:ge.content,children:r.jsxs("div",{className:ge.gridSizeRow,children:[r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};nn.displayName="GridSizePanel";const ii="_panel_qlcb6_6",li="_header_qlcb6_10",ai="_title_qlcb6_20",ci="_headerActions_qlcb6_29",ui="_content_qlcb6_33",di="_field_qlcb6_37",hi="_horizontal_qlcb6_43",mi="_label_qlcb6_49",fi="_marginsGrid_qlcb6_60",pi="_topMargin_qlcb6_66",xi="_bottomMargin_qlcb6_67",bi="_sideMargins_qlcb6_73",Z={panel:ii,header:li,title:ai,headerActions:ci,content:ui,field:di,horizontal:hi,label:mi,marginsGrid:fi,topMargin:pi,bottomMargin:xi,sideMargins:bi},rn=({paper:e,onPaperChange:t})=>{const[n,s]=u.useState(!1),o=u.useCallback(d=>{d!==void 0&&s(d)},[]),l=u.useCallback(d=>{if(!d)return;const f=n?{top:d,right:d,bottom:d,left:d}:{...e.margin,top:d};t({...e,margin:f})},[e,t,n]),i=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,right:d}})},[e,t]),a=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,bottom:d}})},[e,t]),c=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,left:d}})},[e,t]);return r.jsxs("div",{className:Z.panel,children:[r.jsxs("div",{className:Z.header,children:[r.jsx("h3",{className:Z.title,children:"マージン"}),r.jsx("div",{className:Z.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:Z.content,children:n?r.jsxs("div",{className:`${Z.field} ${Z.horizontal}`,children:[r.jsx("span",{className:Z.label,children:"全辺"}),r.jsx(oe,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:Z.marginsGrid,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.topMargin}`,children:r.jsx(oe,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:Z.sideMargins,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(oe,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(oe,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.bottomMargin}`,children:r.jsx(oe,{value:e.margin.bottom,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};rn.displayName="MarginPanel";const vi="_panel_16d9o_6",gi="_title_16d9o_10",wi="_content_16d9o_22",_i="_field_16d9o_29",yi="_horizontal_16d9o_35",Ei="_label_16d9o_41",ji="_dimensionsRow_16d9o_52",fe={panel:vi,title:gi,content:wi,field:_i,horizontal:yi,label:Ei,dimensionsRow:ji},on=({paper:e,onPaperChange:t})=>{const n=u.useMemo(()=>[{value:pe.A4,label:"A4 (210 × 297 mm)"},{value:pe.A3,label:"A3 (297 × 420 mm)"},{value:pe.B5,label:"B5 (182 × 257 mm)"},{value:pe.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pe.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pe.CUSTOM,label:"カスタム"}],[]),s=u.useCallback(a=>{if(!a)return;const c=Gt[a];t({...e,size:c})},[e,t]),o=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,width:a};t({...e,size:c})},[e,t]),l=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,height:a};t({...e,size:c})},[e,t]),i=e.size.preset===pe.CUSTOM;return r.jsxs("div",{className:fe.panel,children:[r.jsx("h3",{className:fe.title,children:"用紙サイズ"}),r.jsxs("div",{className:fe.content,children:[r.jsx("div",{className:fe.field,children:r.jsx(we,{value:e.size.preset,options:n,onChange:s})}),i&&r.jsxs("div",{className:fe.dimensionsRow,children:[r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"幅"}),r.jsx(oe,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:1,max:500})]}),r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"高さ"}),r.jsx(oe,{value:e.size.height,onChange:l,allowedUnits:["mm","cm","inch"],min:1,max:500})]})]})]})]})};on.displayName="PaperSizePanel";const Ni="_section_p4xnx_6",Ii="_title_p4xnx_14",Di="_content_p4xnx_26",$i="_buttonGroup_p4xnx_33",Ti="_button_p4xnx_33",Ri="_error_p4xnx_65",ee={section:Ni,title:Ii,content:Di,buttonGroup:$i,button:Ti,error:Ri},sn=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,l]=u.useState(""),i=u.useRef(null),a=u.useRef(null),c=u.useCallback(()=>{try{const m=Tt(e,!0),w=new Blob([m],{type:"application/json"}),I=URL.createObjectURL(w),E=document.createElement("a");E.href=I,E.download="schema.json",E.click(),URL.revokeObjectURL(I),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),d=u.useCallback(async()=>{try{const m=Tt(e,!0);await navigator.clipboard.writeText(m),l(""),alert("スキーマをクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),f=u.useCallback(()=>{var m;(m=i.current)==null||m.click()},[]),x=u.useCallback(m=>{var E;const w=(E=m.target.files)==null?void 0:E[0];if(!w)return;const I=new FileReader;I.onload=k=>{var $;try{const _=($=k.target)==null?void 0:$.result,T=$t(_);n(T),l(""),alert("スキーマをインポートしました")}catch(_){l(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},I.readAsText(w),m.target.value=""},[n]),b=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=$t(m);n(w),l(""),alert("スキーマをインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[n]),v=u.useCallback(()=>{try{const m=Ct(t,!0),w=new Blob([m],{type:"application/json"}),I=URL.createObjectURL(w),E=document.createElement("a");E.href=I,E.download="values.json",E.click(),URL.revokeObjectURL(I),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),j=u.useCallback(async()=>{try{const m=Ct(t,!0);await navigator.clipboard.writeText(m),l(""),alert("値をクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),y=u.useCallback(()=>{var m;(m=a.current)==null||m.click()},[]),h=u.useCallback(m=>{var E;const w=(E=m.target.files)==null?void 0:E[0];if(!w)return;const I=new FileReader;I.onload=k=>{var $;try{const _=($=k.target)==null?void 0:$.result,T=Rt(_);s(T),l(""),alert("値をインポートしました")}catch(_){l(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},I.readAsText(w),m.target.value=""},[s]),p=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=Rt(m);s(w),l(""),alert("値をインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"スキーマ"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:d,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:f,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"値"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:v,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:j,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:h})]})]}),o&&r.jsx("div",{className:ee.error,role:"alert",children:o})]})};sn.displayName="ImportExportPanel";const ln=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(St,{children:r.jsx(sn,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});ln.displayName="OtherPanel";const Ci="_container_6c3ft_3",Mi="_paletteItems_6c3ft_32",ki="_item_6c3ft_44",Pi="_itemName_6c3ft_70",Ai="_itemPreview_6c3ft_98",Ue={container:Ci,paletteItems:Mi,item:ki,itemName:Pi,itemPreview:Ai},an=({plugins:e,className:t})=>{const[n,s]=u.useState(null),o=u.useCallback((l,i)=>{s({plugin:l,mousePos:i,isOverCanvas:!1});const a=d=>{const f=document.elementFromPoint(d.clientX,d.clientY),x=!!(f!=null&&f.closest('[data-testid="interaction-layer"]'));s(b=>b?{...b,mousePos:{x:d.clientX,y:d.clientY},isOverCanvas:x}:null)},c=()=>{s(null),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Ue.container} ${t||""}`,children:r.jsx("div",{className:Ue.paletteItems,children:e.map(l=>r.jsx(ir,{plugin:l,onDragStart:o},l.kind))})}),n&&!n.isOverCanvas&&r.jsx(lr,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const ir=({plugin:e,onDragStart:t})=>{const n=u.useMemo(()=>Ne(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o=u.useCallback(l=>{l.preventDefault(),Fe.start(e.kind,e.meta.defaultSize),t(e,{x:l.clientX,y:l.clientY});const i=()=>{Fe.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("div",{className:Ue.item,children:[r.jsx("button",{type:"button",onPointerDown:o,className:Ue.itemName,"aria-label":`${e.meta.displayName}ブロックを追加`,children:e.meta.displayName}),r.jsx("div",{className:Ue.itemPreview,onPointerDown:o,"aria-hidden":"true",children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})]})};ir.displayName="PaletteItem";const lr=({plugin:e,mousePos:t})=>{const n=u.useMemo(()=>Ne(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-o.width/2}px`,top:`${t.y-o.height/2}px`,width:`${o.width}px`,height:`${o.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})};lr.displayName="DragGhost";const Si="_container_rt0ql_3",Li="_tabHeader_rt0ql_14",Oi="_tabContent_rt0ql_21",Ve={container:Si,tabHeader:Li,tabContent:Oi},ar=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:l,onSchemaChange:i,onValuesChange:a,gridSize:c,className:d})=>{const f=u.useMemo(()=>Object.values(n),[n]),x=u.useMemo(()=>e.filter(v=>t.includes(v.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${Ve.container} ${d||""}`,"data-sidebar":"true",children:r.jsxs(Lt,{defaultValue:"block",variant:"default",children:[r.jsxs(Ot,{className:Ve.tabHeader,children:[r.jsx(ye,{value:"block",children:"ブロック"}),r.jsx(ye,{value:"canvas",children:"キャンバス"}),r.jsx(ye,{value:"other",children:"その他"})]}),r.jsx(Ee,{value:"block",className:Ve.tabContent,children:b?r.jsx(Qt,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(an,{plugins:f})}),r.jsx(Ee,{value:"canvas",className:Ve.tabContent,children:r.jsx(tn,{schema:o,onSchemaChange:i})}),r.jsx(Ee,{value:"other",className:Ve.tabContent,children:r.jsx(ln,{schema:o,values:l,onSchemaChange:i,onValuesChange:a})})]})})};ar.displayName="Sidebar";exports.ACTUAL_UNITS=no;exports.ALL_UNITS=to;exports.BLOCK_SUB_INDEX=he;exports.BORDER_UNITS=gn;exports.BackgroundPanel=nr;exports.BlockBorder=Cn;exports.BlockCanvas=Mn;exports.BlockChangeType=ae;exports.BlockContainer=Vt;exports.BlockGuideBorder=Pn;exports.BlockLayer=He;exports.BlockOrderPanel=en;exports.BlockPropertyPanel=Qt;exports.BlockRenderer=Ye;exports.Border=Ae;exports.BorderOverlay=An;exports.BorderPanel=rr;exports.BorderRenderer=Ie;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xe;exports.ColorPalette=kt;exports.ColorPicker=ze;exports.ColorPickerPopover=At;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=yn;exports.DEFAULT_GRID=Nn;exports.DEFAULT_GUIDE_BORDER=ut;exports.DEFAULT_GUIDE_LINE=kn;exports.DEFAULT_PAPER=$n;exports.DEFAULT_PAPER_MARGIN=Dn;exports.DEFAULT_PAPER_SIZES=Gt;exports.DEFAULT_SCHEMA=vo;exports.DimensionInput=oe;exports.DragLayer=Kt;exports.DragType=re;exports.EditingBlock=qn;exports.FONT_UNITS=wn;exports.GRID_UNITS=oo;exports.GridCanvas=Sn;exports.GridDimensionLabel=et;exports.GridLayer=dt;exports.GridOverlay=Bn;exports.GridResizeHandle=tt;exports.GridSizePanel=nn;exports.HorizontalAlign=Te;exports.ImageObjectFit=je;exports.ImportExportPanel=sn;exports.InsertGhost=Ft;exports.InteractionBlock=Se;exports.InteractionEventType=G;exports.InteractionLayer=qt;exports.InteractionMode=U;exports.LayoutPanel=or;exports.LineType=de;exports.MarginOverlay=Vn;exports.MarginPanel=rn;exports.MetaPanel=sr;exports.MovingGhost=Wt;exports.MultilineWhiteSpace=Me;exports.MultilineWordWrap=Ce;exports.NoteEdit=Zt;exports.NoteEditor=tr;exports.NoteForm=Jt;exports.NoteMode=ce;exports.NoteView=er;exports.NumberInput=ie;exports.OtherPanel=ln;exports.PADDING_UNITS=$e;exports.PAPER_UNITS=ro;exports.PalettePanel=an;exports.PaperSizePanel=on;exports.PaperSizePreset=pe;exports.PluginPanels=Ss;exports.PropertyField=ft;exports.RESIZE_HANDLE_STYLE=ht;exports.RGBAInputs=Pt;exports.ResizeGhost=Ht;exports.ResizeHandle=H;exports.ResizeHandles=Ut;exports.SELECTION_STYLE=Ke;exports.SIZE_UNITS=Et;exports.Select=we;exports.SelectionBorder=Xn;exports.SelectionLayer=Xt;exports.Sidebar=ar;exports.TabPanel=St;exports.Tabs=Lt;exports.TabsContent=Ee;exports.TabsList=Ot;exports.TabsTrigger=ye;exports.TextInput=Pe;exports.ValidationSeverity=Tn;exports.VerticalAlign=Re;exports.Z_INDEX=B;exports.alignmentDefinition=xn;exports.assertFinite=fo;exports.assertInteger=ct;exports.assertNonNegative=ne;exports.assertPositive=at;exports.assertRange=In;exports.binarySearch=Qe;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=Jn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=zn;exports.createBlock=Ne;exports.createBlockId=jn;exports.createInitialProps=En;exports.createPluginRegistry=lo;exports.deserializeSchema=$t;exports.deserializeValues=Rt;exports.dimensionToString=On;exports.dimensionsToStrings=ko;exports.distributeRemainder=Un;exports.executePrint=Dt;exports.findBlockAtPoint=Mt;exports.findGridIndex=It;exports.fontStyleDefinition=io;exports.getBlockContainerStyle=Bt;exports.getBlockZIndex=Rn;exports.getCommonValue=be;exports.getMaxBlockCount=go;exports.getMaxStep=Nt;exports.getPaperSize=Ko;exports.getStrokeDasharray=ke;exports.getSubZIndex=We;exports.globalDragStore=Fe;exports.gridToMms=rt;exports.gridToPxs=Ho;exports.imageDefinition=ao;exports.interactionZIndexs=J;exports.isValidHex=Br;exports.mmsToPxs=ot;exports.multilineDefinition=co;exports.paddingDefinition=_n;exports.parseColor=yt;exports.placeholderDefinition=uo;exports.preparePrint=Fn;exports.removeUndefinedProps=st;exports.serializeSchema=Tt;exports.serializeValues=Ct;exports.sizeDefinition=ho;exports.stringToDimension=Ln;exports.stringsToDimensions=$o;exports.toHex=bn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Gr;exports.universalProperties=so;exports.useGridCalc=mt;exports.useInteractionState=Zn;exports.validateSchema=Wn;exports.validateValues=Hn;exports.validationDefinition=mo;
|
|
68
|
+
}
|
|
69
|
+
`,document.head.appendChild(b),()=>{const v=document.getElementById("printable-note-page-style");v&&v.remove()}},[e.paper]),u.useImperativeHandle(o,()=>({print:()=>{a.current&&Dt(a.current,{title:"Document"})},openPrintPreview:()=>{a.current&&Dt(a.current,{title:"Document"})}}),[]),r.jsx("div",{ref:a,className:s,style:{width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,backgroundColor:"#fff",paddingTop:`${i.margin.top}px`,paddingLeft:`${i.margin.left}px`,paddingRight:`${i.margin.right}px`,paddingBottom:`${i.margin.bottom}px`,boxSizing:"border-box"},children:r.jsx("div",{style:{position:"relative",width:`${i.content.width}px`,height:`${i.content.height}px`},children:r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.VIEW,values:t??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};or.displayName="NotePrint";const us=u.memo(u.forwardRef(or));function be(e,t){if(e.length===0)return;const n=(i,l)=>{let c=i;for(const d of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[d]}return c},s=t.split("."),o=n(e[0],s);return e.every(i=>n(i,s)===o)?o:void 0}const ds="_container_1tfjv_1",ms="_row_1tfjv_20",hs="_inputWrapper_1tfjv_37",_t={container:ds,row:ms,inputWrapper:hs},sr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(a=>{o[a.id]={style:{...a.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:_t.container,children:r.jsx("div",{className:_t.row,children:r.jsx("div",{className:_t.inputWrapper,children:r.jsx(We,{value:be(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _e(e,t,n){const s=t.split("."),o=(a,i)=>{const l=s[i];if(i===s.length-1){if(n==null){const{[l]:m,...x}=a;return x}return{...a,[l]:n}}const c=(a==null?void 0:a[l])||{},d=o(c,i+1);if(Object.keys(d).length===0){const{[l]:m,...x}=a;return x}return{...a,[l]:d}};return o(e,0)}const ir=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,l,c)=>{const d={};e.forEach(m=>{var b,v,j;let x=_e(m.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(x=_e(x,`border.${i}.width`,void 0),x=_e(x,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(b=m.style)==null?void 0:b.border,f=y==null?void 0:y[i];f!=null&&f.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"})),f!=null&&f.color||(x=_e(x,`border.${i}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const y=(v=m.style)==null?void 0:v.border,f=y==null?void 0:y[i];f!=null&&f.type||(x=_e(x,`border.${i}.type`,de.SOLID)),f!=null&&f.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const y=(j=m.style)==null?void 0:j.border,f=y==null?void 0:y[i];f!=null&&f.type||(x=_e(x,`border.${i}.type`,de.SOLID)),f!=null&&f.color||(x=_e(x,`border.${i}.color`,"#000000"))}d[m.id]={style:x}}),t(d)},s=u.useMemo(()=>{var m;if(e.length!==1)return null;const i=e[0];if(!((m=i==null?void 0:i.style)!=null&&m.border))return null;const l=i.style.border;if(!l)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(l[x]))?new Ae(l):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(we,{value:be(e,`style.border.${i}.type`),onChange:l=>n(i,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:de.SOLID},{label:"破線",value:de.DASHED},{label:"点線",value:de.DOTTED}]}),r.jsx(oe,{value:be(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:bn,min:1}),r.jsx(We,{value:be(e,`style.border.${i}.color`),onChange:l=>n(i,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),a={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return r.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[r.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:r.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[r.jsx("title",{children:"枠線ガイド"}),r.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),r.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),s?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(Ie,{width:80,height:80,border:s})}):r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[r.jsx("title",{children:"枠線未設定"}),r.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),r.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:r.jsxs(Lt,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ot,{style:{width:"100%",display:"flex"},children:[r.jsx(ye,{value:"all",height:24,style:a,children:"共通"}),r.jsx(ye,{value:"top",height:24,style:a,children:"上"}),r.jsx(ye,{value:"bottom",height:24,style:a,children:"下"}),r.jsx(ye,{value:"left",height:24,style:a,children:"左"}),r.jsx(ye,{value:"right",height:24,style:a,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Ee,{value:"all",children:o("all")}),r.jsx(Ee,{value:"top",children:o("top")}),r.jsx(Ee,{value:"bottom",children:o("bottom")}),r.jsx(Ee,{value:"left",children:o("left")}),r.jsx(Ee,{value:"right",children:o("right")})]})]})})]})},fs="_container_1daw7_1",ps="_grid_1daw7_19",xs="_field_1daw7_26",bs="_label_1daw7_33",vs="_inputWrapper_1daw7_43",le={container:fs,grid:ps,field:xs,label:bs,inputWrapper:vs},ar=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(l=>l.layout.x)):void 0,a=s?Math.min(...e.map(l=>l.layout.y)):void 0,i=(l,c)=>{if(c===void 0)return;const d={};if(s&&(l==="x"||l==="y")){const m=l==="x"?o:a;if(m===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),b=Math.max(...e.map(p=>p.layout.y+p.layout.h)),v=x-(o??0),j=b-(a??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-v)):l==="y"&&n?y=Math.max(0,Math.min(c,n.rows-j)):y=Math.max(0,c);const f=y-m;e.forEach(p=>{const h=p.layout[l]+f;d[p.id]={layout:{...p.layout,[l]:h}}})}else e.forEach(m=>{let x=c;if(l==="x"&&n)x=Math.max(0,Math.min(c,n.cols-m.layout.w));else if(l==="y"&&n)x=Math.max(0,Math.min(c,n.rows-m.layout.h));else if(l==="w"&&n){const b=n.cols-m.layout.x;x=Math.max(1,Math.min(c,b))}else if(l==="h"&&n){const b=n.rows-m.layout.y;x=Math.max(1,Math.min(c,b))}else l==="w"||l==="h"?x=Math.max(1,c):x=Math.max(0,c);d[m.id]={layout:{...m.layout,[l]:x}}});t(d)};return r.jsx("div",{className:le.container,children:r.jsxs("div",{className:le.grid,children:[r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"X"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?o:be(e,"layout.x"),onChange:l=>i("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"Y"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?a:be(e,"layout.y"),onChange:l=>i("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"W"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.w"),onChange:l=>i("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"H"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},gs="_container_1h4w8_1",ws="_row_1h4w8_10",_s="_label_1h4w8_16",ys="_inputWrapper_1h4w8_25",De={container:gs,row:ws,label:_s,inputWrapper:ys},lr=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=u.useState(""),o=e[0];u.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const a=()=>{if(!o)return;const c=o.id,d=n.trim();if(d===c||!d){s(c);return}t({[c]:{id:d}})},i=c=>{s(c??"")},l=c=>{const d={};e.forEach(m=>{d[m.id]={behavior:{...m.behavior,readOnly:!!c}}}),t(d)};return r.jsxs("div",{className:De.container,children:[e.length===1&&r.jsxs("div",{className:De.row,children:[r.jsx("span",{className:De.label,children:"ID"}),r.jsx("div",{className:De.inputWrapper,children:r.jsx(Pe,{value:n,onChange:i,onBlur:a,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:De.row,children:r.jsx("div",{className:De.inputWrapper,children:r.jsx(xe,{label:"読み取り専用",value:!!be(e,"behavior.readOnly"),onChange:l})})})]})},Es="_container_wa11y_1",js="_scrollArea_wa11y_18",Ns="_section_wa11y_26",Is="_sectionTitle_wa11y_35",Ds="_subsection_wa11y_47",$s="_subsectionTitle_wa11y_51",Ts="_fields_wa11y_59",Cs="_emptyState_wa11y_69",se={container:Es,scrollArea:js,section:Ns,sectionTitle:Is,subsection:Ds,subsectionTitle:$s,fields:Ts,emptyState:Cs},Rs="_field_qo0ef_1",Ms="_label_qo0ef_7",ks="_mixed_qo0ef_15",Ps="_description_qo0ef_22",Qe={field:Rs,label:Ms,mixed:ks,description:Ps},ft=u.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var m;const o=t.Component;if(!o)return null;const a=be(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&a===void 0&&n.length>1,d={value:c?void 0:a!==void 0?a:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(m=t.config)==null?void 0:m.placeholder}};return r.jsxs("div",{className:Qe.field,children:[t.label&&r.jsx("div",{className:Qe.label,title:t.description,children:t.label}),r.jsx(o,{...d}),c&&r.jsx("span",{className:Qe.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:Qe.description,children:t.description})]})});ft.displayName="PropertyField";function As(e){return e!==!1}const Zt=u.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const a=e[0],i=a?t[a.kind]:void 0,l=u.useMemo(()=>{var x;if(e.length===0)return!1;const m=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===m)},[e]),c=u.useMemo(()=>{if(!a||!i)return{};const m={};let x;if(l)x=Object.entries(i.properties);else{const b=e.map(f=>t[f.kind]).filter(f=>f!==void 0);if(b.length===0)return{};const v=b[0];if(!v)return{};const j=new Set(Object.keys(v.properties));x=Array.from(j).filter(f=>b.every(p=>f in p.properties)).map(f=>{const p=i.properties[f];return p?[f,p]:null}).filter(f=>f!==null)}return x.forEach(([b,v])=>{if(!As(v)||e.length>1&&v.disableInMultiSelection||v.condition&&!v.condition(a.props))return;const j=v.group||"基本";m[j]||(m[j]=[]),v.Component&&m[j].push({key:b,definition:v})}),m},[i,t,e,a,l]),d=(m,x)=>{const b={};e.forEach(v=>{b[v.id]={props:{...v.props,[m]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.scrollArea,children:[r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"配置・サイズ"}),r.jsx(ar,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"背景"}),r.jsx(sr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"枠線"}),r.jsx(ir,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:se.section,children:Object.entries(c).map(([m,x])=>r.jsxs("div",{className:se.subsection,children:[r.jsx("div",{className:se.subsectionTitle,children:m}),r.jsx("div",{className:se.fields,children:x.map(({key:b,definition:v})=>r.jsx(ft,{propertyKey:b,definition:v,selectedBlocks:e,onChange:d},b))})]},m))}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"基本設定"}),r.jsx(lr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});Zt.displayName="BlockPropertyPanel";const Ss="_panel_1h33v_1",Ls="_header_1h33v_11",Os="_group_1h33v_18",Gs="_groupTitle_1h33v_26",Bs="_groupContent_1h33v_36",Ve={panel:Ss,header:Ls,group:Os,groupTitle:Gs,groupContent:Bs};function Vs(e){return e!==!1}const Us=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const s=e[0],o=s?t[s.kind]:void 0,a=u.useMemo(()=>{if(!s||!o)return{};const l={};return Object.entries(o.properties).forEach(([c,d])=>{if(!Vs(d)||e.length>1&&d.disableInMultiSelection||d.condition&&!d.condition(s.props))return;const m=d.group||"基本";l[m]||(l[m]=[]),d.Component&&l[m].push({key:c,definition:d})}),l},[o,e.length,s]),i=(l,c)=>{const d={};e.forEach(m=>{d[m.id]={props:{...m.props,[l]:c}}}),n(d)};return!s||!o||e.length===0?null:r.jsxs("div",{className:Ve.panel,children:[r.jsx("div",{className:Ve.header,children:e.length>1?`${e.length}個のブロック`:o.meta.displayName}),Object.entries(a).map(([l,c])=>r.jsxs("div",{className:Ve.group,children:[r.jsx("div",{className:Ve.groupTitle,children:l}),r.jsx("div",{className:Ve.groupContent,children:c.map(({key:d,definition:m})=>r.jsx(ft,{propertyKey:d,definition:m,selectedBlocks:e,onChange:i},d))})]},l))]})},Fs="_panel_1ekwd_6",zs="_title_1ekwd_10",Ws="_content_1ekwd_22",Ys="_description_1ekwd_29",Hs="_list_1ekwd_35",Ks="_item_1ekwd_44",Xs="_dragging_1ekwd_61",qs="_dragOver_1ekwd_66",Zs="_dragHandle_1ekwd_71",Js="_itemInfo_1ekwd_86",Qs="_itemId_1ekwd_93",ei="_itemMeta_1ekwd_98",ti="_itemKind_1ekwd_105",ni="_itemActions_1ekwd_113",ri="_actionButton_1ekwd_118",oi="_empty_1ekwd_154",Q={panel:Fs,title:zs,content:Ws,description:Ys,list:Hs,item:Ks,dragging:Xs,dragOver:qs,dragHandle:Zs,itemInfo:Js,itemId:Qs,itemMeta:ei,itemKind:ti,itemActions:ni,actionButton:ri,empty:oi},Jt=({blocks:e,onBlocksChange:t})=>{const[n,s]=u.useState(null),[o,a]=u.useState(null),i=[...e].reverse(),l=u.useCallback(f=>{const p=e.findIndex(I=>I.id===f);if(p===-1||p===e.length-1)return;const h=[...e],[w]=h.splice(p,1);w&&(h.push(w),t(h))},[e,t]),c=u.useCallback(f=>{const p=e.findIndex(I=>I.id===f);if(p===-1||p===0)return;const h=[...e],[w]=h.splice(p,1);w&&(h.unshift(w),t(h))},[e,t]),d=u.useCallback(f=>{const p=e.findIndex(E=>E.id===f);if(p===-1||p===e.length-1)return;const h=[...e],w=h[p],I=h[p+1];!w||!I||(h[p]=I,h[p+1]=w,t(h))},[e,t]),m=u.useCallback(f=>{const p=e.findIndex(E=>E.id===f);if(p===-1||p===0)return;const h=[...e],w=h[p],I=h[p-1];!w||!I||(h[p]=I,h[p-1]=w,t(h))},[e,t]),x=u.useCallback((f,p)=>{var w;s(p),f.dataTransfer.effectAllowed="move";const h=e.length-1-p;f.currentTarget&&f.dataTransfer.setData("text/plain",((w=e[h])==null?void 0:w.id)||"")},[e]),b=u.useCallback(()=>{s(null),a(null)},[]),v=u.useCallback((f,p)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",!(n===null||n===p)&&a(p)},[n]),j=u.useCallback(()=>{a(null)},[]),y=u.useCallback((f,p)=>{if(f.preventDefault(),n===null||n===p){s(null),a(null);return}const h=e.length-1-n,w=e.length-1-p,I=[...e],[E]=I.splice(h,1);E&&(I.splice(w,0,E),t(I),s(null),a(null))},[e,n,t]);return r.jsxs("div",{className:Q.panel,children:[r.jsx("h3",{className:Q.title,children:"ブロック順序"}),r.jsxs("div",{className:Q.content,children:[r.jsx("p",{className:Q.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:Q.list,children:i.map((f,p)=>{const h=e.length-1-p;return r.jsxs("li",{className:`${Q.item} ${n===p?Q.dragging:""} ${o===p?Q.dragOver:""}`,onDragOver:w=>v(w,p),onDragLeave:j,onDrop:w=>y(w,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>x(w,p),onDragEnd:b,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"ドラッグハンドル"}),r.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),r.jsxs("div",{className:Q.itemInfo,children:[r.jsx("div",{className:Q.itemId,children:f.id}),r.jsx("div",{className:Q.itemMeta,children:r.jsx("span",{className:Q.itemKind,children:f.kind})})]}),r.jsxs("div",{className:Q.itemActions,children:[r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>l(f.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:h===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最前面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>d(f.id),title:"前面へ","aria-label":"前面へ移動",disabled:h===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"前面へ"}),r.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),r.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>m(f.id),title:"背面へ","aria-label":"背面へ移動",disabled:h===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"背面へ"}),r.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>c(f.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:h===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最背面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},f.id)})}),e.length===0&&r.jsx("div",{className:Q.empty,children:"ブロックがありません"})]})]})};Jt.displayName="BlockOrderPanel";const Qt=({schema:e,onSchemaChange:t})=>{const n=u.useCallback(a=>{t({...e,paper:a})},[e,t]),s=u.useCallback(a=>{t({...e,grid:a})},[e,t]),o=u.useCallback(a=>{t({...e,blocks:a})},[e,t]);return r.jsxs(St,{children:[r.jsx(nn,{paper:e.paper,onPaperChange:n}),r.jsx(tn,{paper:e.paper,onPaperChange:n}),r.jsx(en,{grid:e.grid,onGridChange:s}),r.jsx(Jt,{blocks:e.blocks,onBlocksChange:o})]})};Qt.displayName="CanvasPanel";const si="_panel_1axyd_6",ii="_title_1axyd_10",ai="_content_1axyd_22",li="_field_1axyd_29",ci="_horizontal_1axyd_35",ui="_label_1axyd_41",di="_gridSizeRow_1axyd_52",ge={panel:si,title:ii,content:ai,field:li,horizontal:ci,label:ui,gridSizeRow:di},en=({grid:e,onGridChange:t})=>{const n=u.useCallback(o=>{if(!o||o<1||o>100)return;const a=e.cols.length,i=[];if(o>a){i.push(...e.cols);for(let l=a;l<o;l++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,o));t({...e,cols:i})},[e,t]),s=u.useCallback(o=>{if(!o||o<1||o>100)return;const a=e.rows.length,i=[];if(o>a){i.push(...e.rows);for(let l=a;l<o;l++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,o));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:ge.panel,children:[r.jsx("h3",{className:ge.title,children:"グリッドサイズ"}),r.jsx("div",{className:ge.content,children:r.jsxs("div",{className:ge.gridSizeRow,children:[r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const mi="_panel_qlcb6_6",hi="_header_qlcb6_10",fi="_title_qlcb6_20",pi="_headerActions_qlcb6_29",xi="_content_qlcb6_33",bi="_field_qlcb6_37",vi="_horizontal_qlcb6_43",gi="_label_qlcb6_49",wi="_marginsGrid_qlcb6_60",_i="_topMargin_qlcb6_66",yi="_bottomMargin_qlcb6_67",Ei="_sideMargins_qlcb6_73",Z={panel:mi,header:hi,title:fi,headerActions:pi,content:xi,field:bi,horizontal:vi,label:gi,marginsGrid:wi,topMargin:_i,bottomMargin:yi,sideMargins:Ei},tn=({paper:e,onPaperChange:t})=>{const[n,s]=u.useState(!1),o=u.useCallback(d=>{d!==void 0&&s(d)},[]),a=u.useCallback(d=>{if(!d)return;const m=n?{top:d,right:d,bottom:d,left:d}:{...e.margin,top:d};t({...e,margin:m})},[e,t,n]),i=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,right:d}})},[e,t]),l=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,bottom:d}})},[e,t]),c=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,left:d}})},[e,t]);return r.jsxs("div",{className:Z.panel,children:[r.jsxs("div",{className:Z.header,children:[r.jsx("h3",{className:Z.title,children:"マージン"}),r.jsx("div",{className:Z.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:Z.content,children:n?r.jsxs("div",{className:`${Z.field} ${Z.horizontal}`,children:[r.jsx("span",{className:Z.label,children:"全辺"}),r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:Z.marginsGrid,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.topMargin}`,children:r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:Z.sideMargins,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(oe,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(oe,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.bottomMargin}`,children:r.jsx(oe,{value:e.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};tn.displayName="MarginPanel";const ji="_panel_16d9o_6",Ni="_title_16d9o_10",Ii="_content_16d9o_22",Di="_field_16d9o_29",$i="_horizontal_16d9o_35",Ti="_label_16d9o_41",Ci="_dimensionsRow_16d9o_52",fe={panel:ji,title:Ni,content:Ii,field:Di,horizontal:$i,label:Ti,dimensionsRow:Ci},nn=({paper:e,onPaperChange:t})=>{const n=u.useMemo(()=>[{value:pe.A4,label:"A4 (210 × 297 mm)"},{value:pe.A3,label:"A3 (297 × 420 mm)"},{value:pe.B5,label:"B5 (182 × 257 mm)"},{value:pe.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pe.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pe.CUSTOM,label:"カスタム"}],[]),s=u.useCallback(l=>{if(!l)return;const c=Gt[l];t({...e,size:c})},[e,t]),o=u.useCallback(l=>{if(!l)return;const c={...e.size,preset:pe.CUSTOM,width:l};t({...e,size:c})},[e,t]),a=u.useCallback(l=>{if(!l)return;const c={...e.size,preset:pe.CUSTOM,height:l};t({...e,size:c})},[e,t]),i=e.size.preset===pe.CUSTOM;return r.jsxs("div",{className:fe.panel,children:[r.jsx("h3",{className:fe.title,children:"用紙サイズ"}),r.jsxs("div",{className:fe.content,children:[r.jsx("div",{className:fe.field,children:r.jsx(we,{value:e.size.preset,options:n,onChange:s})}),i&&r.jsxs("div",{className:fe.dimensionsRow,children:[r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"幅"}),r.jsx(oe,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:e.margin.left.value+e.margin.right.value+1,max:500})]}),r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"高さ"}),r.jsx(oe,{value:e.size.height,onChange:a,allowedUnits:["mm","cm","inch"],min:e.margin.top.value+e.margin.bottom.value+1,max:500})]})]})]})]})};nn.displayName="PaperSizePanel";const Ri="_section_p4xnx_6",Mi="_title_p4xnx_14",ki="_content_p4xnx_26",Pi="_buttonGroup_p4xnx_33",Ai="_button_p4xnx_33",Si="_error_p4xnx_65",ee={section:Ri,title:Mi,content:ki,buttonGroup:Pi,button:Ai,error:Si},rn=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,a]=u.useState(""),i=u.useRef(null),l=u.useRef(null),c=u.useCallback(()=>{try{const h=Tt(e,!0),w=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(w),E=document.createElement("a");E.href=I,E.download="schema.json",E.click(),URL.revokeObjectURL(I),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),d=u.useCallback(async()=>{try{const h=Tt(e,!0);await navigator.clipboard.writeText(h),a(""),alert("スキーマをクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),m=u.useCallback(()=>{var h;(h=i.current)==null||h.click()},[]),x=u.useCallback(h=>{var E;const w=(E=h.target.files)==null?void 0:E[0];if(!w)return;const I=new FileReader;I.onload=M=>{var $;try{const _=($=M.target)==null?void 0:$.result,T=$t(_);n(T),a(""),alert("スキーマをインポートしました")}catch(_){a(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},I.readAsText(w),h.target.value=""},[n]),b=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=$t(h);n(w),a(""),alert("スキーマをインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),v=u.useCallback(()=>{try{const h=Rt(t,!0),w=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(w),E=document.createElement("a");E.href=I,E.download="values.json",E.click(),URL.revokeObjectURL(I),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),j=u.useCallback(async()=>{try{const h=Rt(t,!0);await navigator.clipboard.writeText(h),a(""),alert("値をクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),y=u.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),f=u.useCallback(h=>{var E;const w=(E=h.target.files)==null?void 0:E[0];if(!w)return;const I=new FileReader;I.onload=M=>{var $;try{const _=($=M.target)==null?void 0:$.result,T=Ct(_);s(T),a(""),alert("値をインポートしました")}catch(_){a(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},I.readAsText(w),h.target.value=""},[s]),p=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Ct(h);s(w),a(""),alert("値をインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"スキーマ"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:d,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:m,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"値"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:v,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:j,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:f})]})]}),o&&r.jsx("div",{className:ee.error,role:"alert",children:o})]})};rn.displayName="ImportExportPanel";const on=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(St,{children:r.jsx(rn,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});on.displayName="OtherPanel";const Li="_container_6c3ft_3",Oi="_paletteItems_6c3ft_32",Gi="_item_6c3ft_44",Bi="_itemName_6c3ft_70",Vi="_itemPreview_6c3ft_98",Fe={container:Li,paletteItems:Oi,item:Gi,itemName:Bi,itemPreview:Vi},sn=({plugins:e,className:t})=>{const[n,s]=u.useState(null),o=u.useCallback((a,i)=>{s({plugin:a,mousePos:i,isOverCanvas:!1});const l=d=>{const m=document.elementFromPoint(d.clientX,d.clientY),x=!!(m!=null&&m.closest('[data-testid="interaction-layer"]'));s(b=>b?{...b,mousePos:{x:d.clientX,y:d.clientY},isOverCanvas:x}:null)},c=()=>{s(null),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Fe.container} ${t||""}`,children:r.jsx("div",{className:Fe.paletteItems,children:e.map(a=>r.jsx(cr,{plugin:a,onDragStart:o},a.kind))})}),n&&!n.isOverCanvas&&r.jsx(ur,{plugin:n.plugin,mousePos:n.mousePos})]})};sn.displayName="PalettePanel";const cr=({plugin:e,onDragStart:t})=>{const n=u.useMemo(()=>Ne(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o=u.useCallback(a=>{a.preventDefault(),ze.start(e.kind,e.meta.defaultSize),t(e,{x:a.clientX,y:a.clientY});const i=()=>{ze.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("div",{className:Fe.item,children:[r.jsx("button",{type:"button",onPointerDown:o,className:Fe.itemName,"aria-label":`${e.meta.displayName}ブロックを追加`,children:e.meta.displayName}),r.jsx("div",{className:Fe.itemPreview,onPointerDown:o,"aria-hidden":"true",children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ae.FORM})})]})};cr.displayName="PaletteItem";const ur=({plugin:e,mousePos:t})=>{const n=u.useMemo(()=>Ne(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-o.width/2}px`,top:`${t.y-o.height/2}px`,width:`${o.width}px`,height:`${o.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ae.FORM})})};ur.displayName="DragGhost";const Ui="_container_rt0ql_3",Fi="_tabHeader_rt0ql_14",zi="_tabContent_rt0ql_21",Ue={container:Ui,tabHeader:Fi,tabContent:zi},dr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:a,onSchemaChange:i,onValuesChange:l,gridSize:c,className:d})=>{const m=u.useMemo(()=>Object.values(n),[n]),x=u.useMemo(()=>e.filter(v=>t.includes(v.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${Ue.container} ${d||""}`,"data-sidebar":"true",children:r.jsxs(Lt,{defaultValue:"block",variant:"default",children:[r.jsxs(Ot,{className:Ue.tabHeader,children:[r.jsx(ye,{value:"block",children:"ブロック"}),r.jsx(ye,{value:"canvas",children:"キャンバス"}),r.jsx(ye,{value:"other",children:"その他"})]}),r.jsx(Ee,{value:"block",className:Ue.tabContent,children:b?r.jsx(Zt,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(sn,{plugins:m})}),r.jsx(Ee,{value:"canvas",className:Ue.tabContent,children:r.jsx(Qt,{schema:o,onSchemaChange:i})}),r.jsx(Ee,{value:"other",className:Ue.tabContent,children:r.jsx(on,{schema:o,values:a,onSchemaChange:i,onValuesChange:l})})]})})};dr.displayName="Sidebar";exports.ACTUAL_UNITS=so;exports.ALL_UNITS=oo;exports.BLOCK_SUB_INDEX=me;exports.BORDER_UNITS=bn;exports.BackgroundPanel=sr;exports.BlockBorder=Tn;exports.BlockCanvas=Cn;exports.BlockChangeType=ce;exports.BlockContainer=Vt;exports.BlockGuideBorder=Mn;exports.BlockLayer=Se;exports.BlockOrderPanel=Jt;exports.BlockPropertyPanel=Zt;exports.BlockRenderer=He;exports.Border=Ae;exports.BorderOverlay=kn;exports.BorderPanel=ir;exports.BorderRenderer=Ie;exports.COLOR_PALETTE=xn;exports.CanvasPanel=Qt;exports.Checkbox=xe;exports.ColorPalette=kt;exports.ColorPicker=We;exports.ColorPickerPopover=At;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=wn;exports.DEFAULT_GRID=En;exports.DEFAULT_GUIDE_BORDER=dt;exports.DEFAULT_GUIDE_LINE=Rn;exports.DEFAULT_PAPER=In;exports.DEFAULT_PAPER_MARGIN=Nn;exports.DEFAULT_PAPER_SIZES=Gt;exports.DEFAULT_SCHEMA=_o;exports.DimensionInput=oe;exports.DragLayer=Kt;exports.DragType=re;exports.EditingBlock=Kn;exports.FONT_UNITS=vn;exports.GRID_UNITS=ao;exports.GridCanvas=Pn;exports.GridDimensionLabel=tt;exports.GridLayer=mt;exports.GridOverlay=On;exports.GridResizeHandle=nt;exports.GridSizePanel=en;exports.HorizontalAlign=Te;exports.ImageObjectFit=je;exports.ImportExportPanel=rn;exports.InsertGhost=Ft;exports.InteractionBlock=Le;exports.InteractionEventType=G;exports.InteractionLayer=qt;exports.InteractionMode=U;exports.LayoutPanel=ar;exports.LineType=de;exports.MarginOverlay=Gn;exports.MarginPanel=tn;exports.MetaPanel=lr;exports.MovingGhost=Wt;exports.MultilineWhiteSpace=Me;exports.MultilineWordWrap=Re;exports.NoteEdit=Jn;exports.NoteEditor=cs;exports.NoteForm=er;exports.NoteMode=ae;exports.NotePrint=us;exports.NoteView=nr;exports.NumberInput=ie;exports.OtherPanel=on;exports.PADDING_UNITS=$e;exports.PAPER_UNITS=io;exports.PalettePanel=sn;exports.PaperSizePanel=nn;exports.PaperSizePreset=pe;exports.PluginPanels=Us;exports.PropertyField=ft;exports.RESIZE_HANDLE_STYLE=ht;exports.RGBAInputs=Pt;exports.ResizeGhost=Ht;exports.ResizeHandle=H;exports.ResizeHandles=Ut;exports.SELECTION_STYLE=Ke;exports.SIZE_UNITS=Et;exports.Select=we;exports.SelectionBorder=Hn;exports.SelectionLayer=Xt;exports.Sidebar=dr;exports.TabPanel=St;exports.Tabs=Lt;exports.TabsContent=Ee;exports.TabsList=Ot;exports.TabsTrigger=ye;exports.TextInput=Pe;exports.ValidationSeverity=Dn;exports.VerticalAlign=Ce;exports.Z_INDEX=B;exports.alignmentDefinition=fn;exports.assertFinite=bo;exports.assertInteger=ut;exports.assertNonNegative=ne;exports.assertPositive=ct;exports.assertRange=jn;exports.binarySearch=et;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=qn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=Un;exports.createBlock=Ne;exports.createBlockId=yn;exports.createInitialProps=_n;exports.createPluginRegistry=uo;exports.deserializeSchema=$t;exports.deserializeValues=Ct;exports.dimensionToString=Sn;exports.dimensionsToStrings=So;exports.distributeRemainder=Bn;exports.executePrint=Jo;exports.findBlockAtPoint=Mt;exports.findGridIndex=It;exports.fontStyleDefinition=co;exports.getBlockContainerStyle=Bt;exports.getBlockZIndex=$n;exports.getCommonValue=be;exports.getMaxBlockCount=yo;exports.getMaxStep=Nt;exports.getPaperSize=Zo;exports.getStrokeDasharray=ke;exports.getSubZIndex=Ye;exports.globalDragStore=ze;exports.gridToMms=ot;exports.gridToPxs=qo;exports.imageDefinition=mo;exports.interactionZIndexs=J;exports.isValidHex=Fr;exports.mmsToPxs=st;exports.multilineDefinition=ho;exports.paddingDefinition=gn;exports.parseColor=yt;exports.placeholderDefinition=fo;exports.preparePrint=Vn;exports.printElement=Dt;exports.removeUndefinedProps=it;exports.serializeSchema=Tt;exports.serializeValues=Rt;exports.sizeDefinition=po;exports.stringToDimension=An;exports.stringsToDimensions=Ro;exports.toHex=pn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Ur;exports.universalProperties=lo;exports.useGridCalc=Xe;exports.useInteractionState=Xn;exports.validateSchema=Fn;exports.validateValues=Wn;exports.validationDefinition=xo;
|
|
33
70
|
//# sourceMappingURL=index.js.map
|