@tatamicks/core 0.2.3 → 0.2.4

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 CHANGED
@@ -1,33 +1,25 @@
1
- "use strict";require('./index.css');var wo=Object.defineProperty;var Eo=(e,t,n)=>t in e?wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Wt=(e,t,n)=>Eo(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");var xt={exports:{}},st={};/**
1
+ "use strict";require('./index.css');var br=Object.defineProperty;var vr=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pt=(e,t,n)=>vr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");var qe={exports:{}},Ge={};/**
2
2
  * @license React
3
- * react-jsx-runtime.production.min.js
3
+ * react-jsx-runtime.production.js
4
4
  *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
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 Xn;function jo(){if(Xn)return st;Xn=1;var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function i(l,c,f){var m,v={},x=null,b=null;f!==void 0&&(x=""+f),c.key!==void 0&&(x=""+c.key),c.ref!==void 0&&(b=c.ref);for(m in c)o.call(c,m)&&!a.hasOwnProperty(m)&&(v[m]=c[m]);if(l&&l.defaultProps)for(m in c=l.defaultProps,c)v[m]===void 0&&(v[m]=c[m]);return{$$typeof:t,type:l,key:x,ref:b,props:v,_owner:s.current}}return st.Fragment=n,st.jsx=i,st.jsxs=i,st}var it={};/**
9
+ */var ln;function _r(){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
  *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
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 qn;function No(){return qn||(qn=1,process.env.NODE_ENV!=="production"&&(function(){var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),I=Symbol.iterator,E="@@iterator";function g(u){if(u===null||typeof u!="object")return null;var w=I&&u[I]||u[E];return typeof w=="function"?w:null}var p=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(u){{for(var w=arguments.length,C=new Array(w>1?w-1:0),A=1;A<w;A++)C[A-1]=arguments[A];y("error",u,C)}}function y(u,w,C){{var A=p.ReactDebugCurrentFrame,z=A.getStackAddendum();z!==""&&(w+="%s",C=C.concat([z]));var H=C.map(function(U){return String(U)});H.unshift("Warning: "+w),Function.prototype.apply.call(console[u],console,H)}}var D=!1,j=!1,M=!1,$=!1,_=!1,T;T=Symbol.for("react.module.reference");function k(u){return!!(typeof u=="string"||typeof u=="function"||u===o||u===a||_||u===s||u===f||u===m||$||u===b||D||j||M||typeof u=="object"&&u!==null&&(u.$$typeof===x||u.$$typeof===v||u.$$typeof===i||u.$$typeof===l||u.$$typeof===c||u.$$typeof===T||u.getModuleId!==void 0))}function G(u,w,C){var A=u.displayName;if(A)return A;var z=w.displayName||w.name||"";return z!==""?C+"("+z+")":C}function P(u){return u.displayName||"Context"}function L(u){if(u==null)return null;if(typeof u.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case o:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case f:return"Suspense";case m:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case l:var w=u;return P(w)+".Consumer";case i:var C=u;return P(C._context)+".Provider";case c:return G(u,u.render,"ForwardRef");case v:var A=u.displayName||null;return A!==null?A:L(u.type)||"Memo";case x:{var z=u,H=z._payload,U=z._init;try{return L(U(H))}catch{return null}}}return null}var N=Object.assign,R=0,S,O,K,Q,ee,fe,ce;function X(){}X.__reactDisabledLog=!0;function ke(){{if(R===0){S=console.log,O=console.info,K=console.warn,Q=console.error,ee=console.group,fe=console.groupCollapsed,ce=console.groupEnd;var u={configurable:!0,enumerable:!0,value:X,writable:!0};Object.defineProperties(console,{info:u,log:u,warn:u,error:u,group:u,groupCollapsed:u,groupEnd:u})}R++}}function Se(){{if(R--,R===0){var u={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},u,{value:S}),info:N({},u,{value:O}),warn:N({},u,{value:K}),error:N({},u,{value:Q}),group:N({},u,{value:ee}),groupCollapsed:N({},u,{value:fe}),groupEnd:N({},u,{value:ce})})}R<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var nt=p.ReactCurrentDispatcher,rt;function Ee(u,w,C){{if(rt===void 0)try{throw Error()}catch(z){var A=z.stack.trim().match(/\n( *(at )?)/);rt=A&&A[1]||""}return`
18
- `+rt+u}}var Re=!1,Ae;{var Lt=typeof WeakMap=="function"?WeakMap:Map;Ae=new Lt}function ot(u,w){if(!u||Re)return"";{var C=Ae.get(u);if(C!==void 0)return C}var A;Re=!0;var z=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var H;H=nt.current,nt.current=null,ke();try{if(w){var U=function(){throw Error()};if(Object.defineProperty(U.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(U,[])}catch(ge){A=ge}Reflect.construct(u,[],U)}else{try{U.call()}catch(ge){A=ge}u.call(U.prototype)}}else{try{throw Error()}catch(ge){A=ge}u()}}catch(ge){if(ge&&A&&typeof ge.stack=="string"){for(var F=ge.stack.split(`
19
- `),me=A.stack.split(`
20
- `),te=F.length-1,ne=me.length-1;te>=1&&ne>=0&&F[te]!==me[ne];)ne--;for(;te>=1&&ne>=0;te--,ne--)if(F[te]!==me[ne]){if(te!==1||ne!==1)do if(te--,ne--,ne<0||F[te]!==me[ne]){var we=`
21
- `+F[te].replace(" at new "," at ");return u.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",u.displayName)),typeof u=="function"&&Ae.set(u,we),we}while(te>=1&&ne>=0);break}}}finally{Re=!1,nt.current=H,Se(),Error.prepareStackTrace=z}var We=u?u.displayName||u.name:"",Ge=We?Ee(We):"";return typeof u=="function"&&Ae.set(u,Ge),Ge}function At(u,w,C){return ot(u,!1)}function Ot(u){var w=u.prototype;return!!(w&&w.isReactComponent)}function Ve(u,w,C){if(u==null)return"";if(typeof u=="function")return ot(u,Ot(u));if(typeof u=="string")return Ee(u);switch(u){case f:return Ee("Suspense");case m:return Ee("SuspenseList")}if(typeof u=="object")switch(u.$$typeof){case c:return At(u.render);case v:return Ve(u.type,w,C);case x:{var A=u,z=A._payload,H=A._init;try{return Ve(H(z),w,C)}catch{}}}return""}var Oe=Object.prototype.hasOwnProperty,vt={},Ln=p.ReactDebugCurrentFrame;function gt(u){if(u){var w=u._owner,C=Ve(u.type,u._source,w?w.type:null);Ln.setExtraStackFrame(C)}else Ln.setExtraStackFrame(null)}function Qr(u,w,C,A,z){{var H=Function.call.bind(Oe);for(var U in u)if(H(u,U)){var F=void 0;try{if(typeof u[U]!="function"){var me=Error((A||"React class")+": "+C+" type `"+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof u[U]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw me.name="Invariant Violation",me}F=u[U](w,U,A,C,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(te){F=te}F&&!(F instanceof Error)&&(gt(z),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",A||"React class",C,U,typeof F),gt(null)),F instanceof Error&&!(F.message in vt)&&(vt[F.message]=!0,gt(z),h("Failed %s type: %s",C,F.message),gt(null))}}}var eo=Array.isArray;function Gt(u){return eo(u)}function to(u){{var w=typeof Symbol=="function"&&Symbol.toStringTag,C=w&&u[Symbol.toStringTag]||u.constructor.name||"Object";return C}}function no(u){try{return An(u),!1}catch{return!0}}function An(u){return""+u}function On(u){if(no(u))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",to(u)),An(u)}var Gn=p.ReactCurrentOwner,ro={key:!0,ref:!0,__self:!0,__source:!0},Bn,Fn;function oo(u){if(Oe.call(u,"ref")){var w=Object.getOwnPropertyDescriptor(u,"ref").get;if(w&&w.isReactWarning)return!1}return u.ref!==void 0}function so(u){if(Oe.call(u,"key")){var w=Object.getOwnPropertyDescriptor(u,"key").get;if(w&&w.isReactWarning)return!1}return u.key!==void 0}function io(u,w){typeof u.ref=="string"&&Gn.current}function ao(u,w){{var C=function(){Bn||(Bn=!0,h("%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://reactjs.org/link/special-props)",w))};C.isReactWarning=!0,Object.defineProperty(u,"key",{get:C,configurable:!0})}}function lo(u,w){{var C=function(){Fn||(Fn=!0,h("%s: `ref` 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://reactjs.org/link/special-props)",w))};C.isReactWarning=!0,Object.defineProperty(u,"ref",{get:C,configurable:!0})}}var co=function(u,w,C,A,z,H,U){var F={$$typeof:t,type:u,key:w,ref:C,props:U,_owner:H};return F._store={},Object.defineProperty(F._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(F,"_self",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.defineProperty(F,"_source",{configurable:!1,enumerable:!1,writable:!1,value:z}),Object.freeze&&(Object.freeze(F.props),Object.freeze(F)),F};function uo(u,w,C,A,z){{var H,U={},F=null,me=null;C!==void 0&&(On(C),F=""+C),so(w)&&(On(w.key),F=""+w.key),oo(w)&&(me=w.ref,io(w,z));for(H in w)Oe.call(w,H)&&!ro.hasOwnProperty(H)&&(U[H]=w[H]);if(u&&u.defaultProps){var te=u.defaultProps;for(H in te)U[H]===void 0&&(U[H]=te[H])}if(F||me){var ne=typeof u=="function"?u.displayName||u.name||"Unknown":u;F&&ao(U,ne),me&&lo(U,ne)}return co(u,F,me,z,A,Gn.current,U)}}var Bt=p.ReactCurrentOwner,Vn=p.ReactDebugCurrentFrame;function Ue(u){if(u){var w=u._owner,C=Ve(u.type,u._source,w?w.type:null);Vn.setExtraStackFrame(C)}else Vn.setExtraStackFrame(null)}var Ft;Ft=!1;function Vt(u){return typeof u=="object"&&u!==null&&u.$$typeof===t}function Un(){{if(Bt.current){var u=L(Bt.current.type);if(u)return`
22
-
23
- Check the render method of \``+u+"`."}return""}}function fo(u){return""}var Wn={};function ho(u){{var w=Un();if(!w){var C=typeof u=="string"?u:u.displayName||u.name;C&&(w=`
24
-
25
- Check the top-level render call using <`+C+">.")}return w}}function zn(u,w){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var C=ho(w);if(Wn[C])return;Wn[C]=!0;var A="";u&&u._owner&&u._owner!==Bt.current&&(A=" It was passed a child from "+L(u._owner.type)+"."),Ue(u),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',C,A),Ue(null)}}function Yn(u,w){{if(typeof u!="object")return;if(Gt(u))for(var C=0;C<u.length;C++){var A=u[C];Vt(A)&&zn(A,w)}else if(Vt(u))u._store&&(u._store.validated=!0);else if(u){var z=g(u);if(typeof z=="function"&&z!==u.entries)for(var H=z.call(u),U;!(U=H.next()).done;)Vt(U.value)&&zn(U.value,w)}}}function mo(u){{var w=u.type;if(w==null||typeof w=="string")return;var C;if(typeof w=="function")C=w.propTypes;else if(typeof w=="object"&&(w.$$typeof===c||w.$$typeof===v))C=w.propTypes;else return;if(C){var A=L(w);Qr(C,u.props,"prop",A,u)}else if(w.PropTypes!==void 0&&!Ft){Ft=!0;var z=L(w);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",z||"Unknown")}typeof w.getDefaultProps=="function"&&!w.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function po(u){{for(var w=Object.keys(u.props),C=0;C<w.length;C++){var A=w[C];if(A!=="children"&&A!=="key"){Ue(u),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",A),Ue(null);break}}u.ref!==null&&(Ue(u),h("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var Hn={};function Kn(u,w,C,A,z,H){{var U=k(u);if(!U){var F="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(F+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var me=fo();me?F+=me:F+=Un();var te;u===null?te="null":Gt(u)?te="array":u!==void 0&&u.$$typeof===t?(te="<"+(L(u.type)||"Unknown")+" />",F=" Did you accidentally export a JSX literal instead of a component?"):te=typeof u,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",te,F)}var ne=uo(u,w,C,z,H);if(ne==null)return ne;if(U){var we=w.children;if(we!==void 0)if(A)if(Gt(we)){for(var We=0;We<we.length;We++)Yn(we[We],u);Object.freeze&&Object.freeze(we)}else h("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 Yn(we,u)}if(Oe.call(w,"key")){var Ge=L(u),ge=Object.keys(w).filter(function(_o){return _o!=="key"}),Ut=ge.length>0?"{key: someKey, "+ge.join(": ..., ")+": ...}":"{key: someKey}";if(!Hn[Ge+Ut]){var yo=ge.length>0?"{"+ge.join(": ..., ")+": ...}":"{}";h(`A props object containing a "key" prop is being spread into JSX:
17
+ */var cn;function wr(){return cn||(cn=1,process.env.NODE_ENV!=="production"&&(function(){function e(v){if(v==null)return null;if(typeof v=="function")return v.$$typeof===O?null:v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){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 v=="object")switch(typeof v.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),v.$$typeof){case y:return"Portal";case I:return v.displayName||"Context";case _:return(v._context.displayName||"Context")+".Consumer";case E:var C=v.render;return v=v.displayName,v||(v=C.displayName||C.name||"",v=v!==""?"ForwardRef("+v+")":"ForwardRef"),v;case w:return C=v.displayName||null,C!==null?C:e(v.type)||"Memo";case T:C=v._payload,v=v._init;try{return e(v(C))}catch{}}return null}function t(v){return""+v}function n(v){try{t(v);var C=!1}catch{C=!0}if(C){C=console;var A=C.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&v[Symbol.toStringTag]||v.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(v)}}function s(v){if(v===f)return"<>";if(typeof v=="object"&&v!==null&&v.$$typeof===T)return"<...>";try{var C=e(v);return C?"<"+C+">":"<...>"}catch{return"<...>"}}function o(){var v=R.A;return v===null?null:v.getOwner()}function a(){return Error("react-stack-top-frame")}function i(v){if(L.call(v,"key")){var C=Object.getOwnPropertyDescriptor(v,"key").get;if(C&&C.isReactWarning)return!1}return v.key!==void 0}function l(v,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(v,"key",{get:A,configurable:!0})}function c(){var v=e(this.type);return S[v]||(S[v]=!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.")),v=this.props.ref,v!==void 0?v:null}function d(v,C,A,z,he,Oe){var Z=A.ref;return v={$$typeof:j,type:v,key:C,props:A,_owner:z},(Z!==void 0?Z:null)!==null?Object.defineProperty(v,"ref",{enumerable:!1,get:c}):Object.defineProperty(v,"ref",{enumerable:!1,value:null}),v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(v,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(v,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:he}),Object.defineProperty(v,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Oe}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v}function m(v,C,A,z,he,Oe){var Z=C.children;if(Z!==void 0)if(z)if(N(Z)){for(z=0;z<Z.length;z++)x(Z[z]);Object.freeze&&Object.freeze(Z)}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(Z);if(L.call(C,"key")){Z=e(v);var ue=Object.keys(C).filter(function(Ze){return Ze!=="key"});z=0<ue.length?"{key: someKey, "+ue.join(": ..., ")+": ...}":"{key: someKey}",X[Z+z]||(ue=0<ue.length?"{"+ue.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
26
18
  let props = %s;
27
19
  <%s {...props} />
28
20
  React keys must be passed directly to JSX without using spread:
29
21
  let props = %s;
30
- <%s key={someKey} {...props} />`,Ut,Ge,yo,Ge),Hn[Ge+Ut]=!0}}return u===o?po(ne):mo(ne),ne}}function vo(u,w,C){return Kn(u,w,C,!0)}function go(u,w,C){return Kn(u,w,C,!1)}var xo=go,bo=vo;it.Fragment=o,it.jsx=xo,it.jsxs=bo})()),it}var Zn;function Io(){return Zn||(Zn=1,process.env.NODE_ENV==="production"?xt.exports=jo():xt.exports=No()),xt.exports}var r=Io(),He=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(He||{}),Ke=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Ke||{});const Do="_container_gerw7_9",Ro="_select_gerw7_21",Co="_placeholderOverlay_gerw7_87",zt={container:Do,select:Ro,placeholderOverlay:Co},$e=e=>{const{value:t,onChange:n,readOnly:o=!1,config:s}=e,a=e.options??(s==null?void 0:s.options)??[],i=e.placeholder??(s==null?void 0:s.placeholder)??"選択してください",l=e.width??(s==null?void 0:s.width),c=e.height??(s==null?void 0:s.height),f=d.useCallback(I=>{const E=I.target.value;if(E==="")n(void 0);else{const g=a.find(p=>String(p.value)===E);n(g?g.value:E)}},[n,a]),m=t??"",v=t!==void 0&&t!=="",x={};l!==void 0?x.width=`${l}px`:x.width="100%";const b={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:zt.container,style:x,children:[!v&&r.jsx("input",{className:zt.placeholderOverlay,style:b,readOnly:!0,placeholder:i}),r.jsx("select",{className:zt.select,style:b,value:m,onChange:f,disabled:o,children:a.map(I=>r.jsx("option",{value:String(I.value),children:I.label},String(I.value)))})]})};$e.displayName="Select";const tr={justifyContent:{defaultValue:He.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:$e,config:{options:[{label:"左揃え",value:He.left},{label:"中央揃え",value:He.center},{label:"右揃え",value:He.right}]}},alignItems:{defaultValue:Ke.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:$e,config:{options:[{label:"上揃え",value:Ke.top},{label:"中央揃え",value:Ke.center},{label:"下揃え",value:Ke.bottom}]}}},$o="_container_6u83k_9",To="_input_6u83k_25",Po="_label_6u83k_57",Yt={container:$o,input:To,label:Po},Ie=({value:e,onChange:t,readOnly:n=!1,label:o,config:s})=>{const a=o??(s==null?void 0:s.label),i=d.useCallback(l=>{t(l.target.checked)},[t]);return r.jsxs("label",{className:Yt.container,children:[r.jsx("input",{type:"checkbox",className:Yt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:Yt.label,children:a})]})};Ie.displayName="Checkbox";const Mo="_container_1gj1n_9",ko="_colorButton_1gj1n_25",So="_textInputWrapper_1gj1n_79",Lo="_textInputPrefix_1gj1n_123",Ao="_textInput_1gj1n_79",Oo="_popover_1gj1n_249",Go="_palette_1gj1n_281",Bo="_paletteButton_1gj1n_295",Fo="_selected_1gj1n_341",Vo="_transparentPaletteButton_1gj1n_353",Uo="_rgbaInputs_1gj1n_365",Wo="_rgbaInputGroup_1gj1n_379",zo="_rgbaLabel_1gj1n_409",ae={container:Mo,colorButton:ko,textInputWrapper:So,textInputPrefix:Lo,textInput:Ao,popover:Oo,palette:Go,paletteButton:Bo,selected:Fo,transparentPaletteButton:Vo,rgbaInputs:Uo,rgbaInputGroup:Wo,rgbaLabel:zo};function Zt(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 o=t[1],s=Number.parseInt(o.slice(0,2),16),a=Number.parseInt(o.slice(2,4),16),i=Number.parseInt(o.slice(4,6),16),l=o.length===8?Number.parseInt(o.slice(6,8),16)/255:1;return{r:s,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 o=Number.parseInt(n[1]??"",10),s=Number.parseInt(n[2]??"",10),a=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:o,g:s,b:a,a:i}}return null}function nr(e){const{r:t,g:n,b:o,a:s}=e;if(s===0)return;const a=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),l=o.toString(16).padStart(2,"0");if(s<1){const c=Math.round(s*255).toString(16).padStart(2,"0");return`#${a}${i}${l}${c}`}return`#${a}${i}${l}`}function Yo(e){const{r:t,g:n,b:o,a:s}=e;if(s!==0)return`rgba(${t}, ${n}, ${o}, ${s})`}function Ho(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const rr=[{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"}],cn=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:ae.palette,children:rr.map((o,s)=>{const a=o.value===void 0,i=o.value===t,l=a?{}:{backgroundColor:o.value};return r.jsx("button",{type:"button",className:`${ae.paletteButton} ${a?ae.transparentPaletteButton:""} ${i?ae.selected:""}`,onClick:()=>e(o.value),disabled:n,title:o.label,"aria-label":o.label,style:l},o.value??`undefined-${s}`)})});cn.displayName="ColorPalette";const Ko="_input_me6tq_9",Xo={input:Ko},pe=({value:e,onChange:t,readOnly:n=!1,min:o,max:s,step:a,integer:i,placeholder:l,width:c,height:f,config:m,onBlur:v})=>{const x=o??(m==null?void 0:m.min)??1,b=s??(m==null?void 0:m.max),I=a??(m==null?void 0:m.step)??1,E=i??(m==null?void 0:m.integer)??!1,g=l??(m==null?void 0:m.placeholder),p=c??(m==null?void 0:m.width),h=f??(m==null?void 0:m.height),y=d.useCallback(j=>{const M=j.target.value;if(M===""){t(void 0);return}let $=Number.parseFloat(M);Number.isNaN($)||(E&&($=Math.round($)),x!==void 0&&$<x&&($=x),b!==void 0&&$>b&&($=b),t($))},[t,x,b,E]),D={};return p!==void 0&&(D.width=`${p}px`),h!==void 0&&(D.height=`${h}px`,D.paddingTop=0,D.paddingBottom=0),r.jsx("input",{type:"number",className:Xo.input,style:D,value:e??"",onChange:y,onBlur:v,disabled:n,min:x,max:b,step:I,placeholder:g})};pe.displayName="NumberInput";const un=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:ae.rgbaInputs,children:[r.jsxs("div",{className:ae.rgbaInputGroup,children:[r.jsx("span",{className:ae.rgbaLabel,children:"R"}),r.jsx(pe,{value:e.r,onChange:o=>t("r",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ae.rgbaInputGroup,children:[r.jsx("span",{className:ae.rgbaLabel,children:"G"}),r.jsx(pe,{value:e.g,onChange:o=>t("g",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ae.rgbaInputGroup,children:[r.jsx("span",{className:ae.rgbaLabel,children:"B"}),r.jsx(pe,{value:e.b,onChange:o=>t("b",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ae.rgbaInputGroup,children:[r.jsx("span",{className:ae.rgbaLabel,children:"A"}),r.jsx(pe,{value:Math.round(e.a*100),onChange:o=>t("a",o!==void 0?o/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});un.displayName="RGBAInputs";const V={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},_e={BG:10,CONTENT:50,GUIDE:70,BORDER:80},dn=({isOpen:e,onClose:t,rgba:n,onRgbaChange:o,onColorSelect:s,selectedColor:a,readOnly:i=!1})=>{const l=d.useRef(null);return d.useEffect(()=>{if(!e)return;const c=f=>{l.current&&!l.current.contains(f.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:ae.popover,ref:l,style:{zIndex:V.DROPDOWN},children:[r.jsx(cn,{onColorSelect:s,selectedColor:a,readOnly:i}),r.jsx(un,{rgba:n,onChange:o,readOnly:i})]}):null};dn.displayName="ColorPickerPopover";const dt=({value:e,onChange:t,readOnly:n=!1,showTextInput:o=!0,allowUndefined:s,placeholder:a,width:i,height:l,config:c})=>{const f=s??(c==null?void 0:c.allowUndefined)??!0,m=a??(f?"未設定":"#000000"),v=i??(c==null?void 0:c.width),x=l??(c==null?void 0:c.height),[b,I]=d.useState(!1),E=d.useRef(null),[g,p]=d.useState(()=>Zt(e)??{r:0,g:0,b:0,a:1});d.useEffect(()=>{const N=Zt(e);N&&p(N)},[e]);const h=d.useCallback(()=>{n||I(N=>!N)},[n]),[y,D]=d.useState(e?e.replace(/^#/,""):"");d.useEffect(()=>{D(e?e.replace(/^#/,""):"")},[e]);const j=d.useCallback(N=>{const R=N.target.value;/^[0-9A-Fa-f]*$/.test(R)&&D(R)},[]),M=d.useCallback(N=>{if(N===""&&f){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):D(e?e.replace(/^#/,""):"")},[t,f,e]),$=d.useCallback(N=>{M(N.target.value)},[M]),_=d.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),M(N.currentTarget.value),N.currentTarget.blur())},[M]),T=d.useCallback(N=>{t(N)},[t]),k=d.useCallback((N,R)=>{if(R===void 0)return;const S={...g,[N]:R};p(S),t(nr(S))},[g,t]),G=e??"未設定",P={};e&&(P.background=e);const L={};return v!==void 0?L.width=`${v}px`:L.width="100%",x!==void 0&&(L.height=`${x}px`),r.jsxs("div",{className:ae.container,style:L,ref:E,children:[r.jsx("button",{type:"button",className:ae.colorButton,onClick:h,disabled:n,title:G,"aria-label":"カラーピッカーを開く",style:P}),o&&r.jsxs("div",{className:ae.textInputWrapper,children:[r.jsx("span",{className:ae.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:ae.textInput,value:y,onChange:j,onKeyDown:_,onBlur:$,disabled:n,placeholder:m,maxLength:8})]}),r.jsx(dn,{isOpen:b,onClose:()=>I(!1),rgba:g,onRgbaChange:k,onColorSelect:T,selectedColor:e,readOnly:n})]})};dt.displayName="ColorPicker";const qo="_container_3qavu_9",Zo="_valueInput_3qavu_45",Jo="_unitSelect_3qavu_89",Ht={container:qo,valueInput:Zo,unitSelect:Jo},de=e=>{const{value:t,onChange:n,readOnly:o=!1,config:s}=e,a=e.allowedUnits??(s==null?void 0:s.allowedUnits),i=e.min??(s==null?void 0:s.min),l=e.max??(s==null?void 0:s.max),c=e.step??(s==null?void 0:s.step)??1,f=e.placeholder??(s==null?void 0:s.placeholder),m=e.width??(s==null?void 0:s.width),v=e.height??(s==null?void 0:s.height),x=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),b=d.useCallback(y=>{const D=y.target.value;let j=Number.parseFloat(D);if(Number.isNaN(j))return;const M=i??1;j<M&&(j=M),l!==void 0&&j>l&&(j=l),n({value:j,unit:(t==null?void 0:t.unit)??x})},[t,n,x,i,l]),I=d.useCallback(y=>{const D=y.target.value;if(D==="")return;let j=Number.parseFloat(D);if(Number.isNaN(j))return;const M=i??1;j<M&&(j=M,n({value:j,unit:(t==null?void 0:t.unit)??x})),l!==void 0&&j>l&&(j=l,n({value:j,unit:(t==null?void 0:t.unit)??x}))},[t,n,x,i,l]),E=d.useCallback(y=>{const D=y.target.value;n({value:(t==null?void 0:t.value)??1,unit:D})},[t,n]),g=(t==null?void 0:t.value)??"",p=(t==null?void 0:t.unit)??x??"",h={};return m!==void 0?h.width=`${m}px`:h.width="100%",v!==void 0&&(h.height=`${v}px`),r.jsxs("div",{className:Ht.container,style:h,children:[r.jsx("input",{type:"number",className:Ht.valueInput,value:g,onChange:b,onBlur:I,placeholder:f,min:i??1,max:l,step:c,readOnly:o,disabled:o}),r.jsx("select",{className:Ht.unitSelect,value:p,onChange:E,disabled:o||!a||a.length<=1,children:a?a.map(y=>r.jsx("option",{value:y,children:y},y)):r.jsx("option",{value:p,children:p})})]})},Qo="_container_1sn14_11",es="_scrollArea_1sn14_45",ts="_emptyState_1sn14_61",Kt={container:Qo,scrollArea:es,emptyState:ts},fn=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${Kt.container} ${n||""}`,children:e?r.jsx("div",{className:Kt.scrollArea,children:e}):t&&r.jsx("div",{className:Kt.emptyState,children:t})}),ns="_root_kb3dm_5",rs="_list_kb3dm_21",os="_trigger_kb3dm_51",ss="_content_kb3dm_141",Rt={root:ns,list:rs,trigger:os,content:ss},Ct=d.createContext(void 0),hn=({defaultValue:e,value:t,onValueChange:n,children:o,variant:s="default",className:a=""})=>{const[i,l]=d.useState(e),c=t??i,f=m=>{l(m),n==null||n(m)};return r.jsx(Ct.Provider,{value:{value:c,onChange:f,variant:s},children:r.jsx("div",{className:`${Rt.root} ${a}`,"data-variant":s,children:o})})},mn=({children:e,className:t="",width:n,height:o,style:s})=>{const a=d.useContext(Ct);if(!a)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=a,l={...s};return n!==void 0&&(l.width=`${n}px`),o!==void 0&&(l.height=`${o}px`),r.jsx("div",{className:`${Rt.list} ${t}`,"data-variant":i,style:l,children:e})},Pe=({value:e,children:t,className:n="",disabled:o=!1,width:s,height:a,style:i})=>{const l=d.useContext(Ct);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:f,variant:m}=l,v=c===e,x={...i};return s!==void 0&&(x.width=`${s}px`),a!==void 0&&(x.height=`${a}px`),r.jsx("button",{className:`${Rt.trigger} ${n}`,"data-state":v?"active":"inactive","data-variant":m,onClick:()=>f(e),disabled:o,type:"button",style:x,children:t})},Me=({value:e,children:t,className:n=""})=>{const o=d.useContext(Ct);if(!o)throw new Error("TabsContent must be used within a Tabs component");const{value:s}=o;return s!==e?null:r.jsx("div",{className:`${Rt.content} ${n}`,children:t})},is="_input_hr2wj_9",as={input:is},Je=({value:e,onChange:t,readOnly:n=!1,placeholder:o,maxLength:s,multiline:a,rows:i,width:l,height:c,config:f,onBlur:m})=>{const v=o??(f==null?void 0:f.placeholder),x=s??(f==null?void 0:f.maxLength),b=a??(f==null?void 0:f.multiline)??!1,I=i??(f==null?void 0:f.rows)??3,E=d.useCallback(h=>{const y=h.target.value;t(y)},[t]),g={};l!==void 0?g.width=`${l}px`:g.width="100%",c!==void 0&&(g.height=`${c}px`);const p={className:as.input,style:g,value:e??"",onChange:E,disabled:n,placeholder:v,maxLength:x};return b?r.jsx("textarea",{...p,rows:I}):r.jsx("input",{...p,type:"text",onBlur:m})};Je.displayName="TextInput";const ls=["mm","cm","fr","inch","pt","px","%"],cs=["mm","cm","pt","inch","px"],us=["mm","cm","inch"],ds=["mm","cm","fr","inch","pt","px"],or=["px","pt","mm"],sr=["px","pt","mm"],Ye=["mm","pt","px","%"],Jt=["mm","cm","inch","pt","px","%"],ir={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:Ie,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:de,config:{allowedUnits:Ye,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:de,config:{allowedUnits:Ye,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:de,config:{allowedUnits:Ye,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:de,config:{allowedUnits:Ye,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:de,config:{allowedUnits:Ye,min:0},condition:e=>e.isIndividual===!0}},fs={...tr,...ir},ar=[{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"}],hs={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:de,config:{allowedUnits:sr,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:$e,config:{placeholder:"フォントを選択",options:ar}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:dt,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:Ie},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:Ie},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:Ie},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:Ie},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:pe,config:{min:1,max:3,step:.1}}};function ms(e){return e.reduce((t,n)=>(t[n.kind]=n,t),{})}var Le=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(Le||{});const ps={objectFit:{defaultValue:Le.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:$e,config:{options:[{label:"全体を表示",value:Le.Contain},{label:"枠を埋める/切り抜き",value:Le.Cover},{label:"引き伸ばす/縮小する",value:Le.Fill},{label:"元のサイズ",value:Le.None},{label:"縮小のみ",value:Le.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Je,config:{placeholder:"画像の説明"}}};var Xe=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Xe||{}),qe=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(qe||{});const vs={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:Ie,config:{label:"有効にする"}},wordWrap:{defaultValue:Xe.Normal,label:"単語の折り返し",group:"設定",Component:$e,config:{options:[{label:"通常",value:Xe.Normal},{label:"単語で改行",value:Xe.BreakWord},{label:"強制改行",value:Xe.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:qe.Normal,label:"空白文字の扱い",group:"設定",Component:$e,config:{options:[{label:"通常",value:qe.Normal},{label:"折り返しなし",value:qe.NoWrap},{label:"そのまま表示",value:qe.Pre}]},condition:e=>e.multiline===!0}},gs={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Je,config:{placeholder:"例: テキストを入力してください"}}},xs={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:de,config:{min:0,allowedUnits:Jt,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:de,config:{min:0,allowedUnits:Jt,placeholder:"auto"}}},lr=e=>{const t={};return Object.entries(e.properties).forEach(([n,o])=>{o!==!1&&typeof o=="object"&&o!==null&&"defaultValue"in o&&(t[n]=o.defaultValue)}),t};function cr(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Be(e,t,n){const o=lr(e);return{id:cr(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...o,...n}}}const bs={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:Ie,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Je,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var be=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(be||{});const ur={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var ye=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(ye||{});const q=96;function $t(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function le(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function dr(e,t,n,o){if(e<t||e>n){const s=o??"Value";throw new Error(`${s} must be between ${t} and ${n}: got ${e}`)}}function Tt(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function ys(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const _s=25.4,ws=2.54,Es=72,W={_assertDpi(e){$t(e,"DPI"),Tt(e,"DPI")},fromMm(e,t=q){return W._assertDpi(t),le(e,"Millimeter value"),e*t/_s},fromCm(e,t=q){return W._assertDpi(t),le(e,"Centimeter value"),e*t/ws},fromInch(e,t=q){return W._assertDpi(t),le(e,"Inch value"),e*t},fromPt(e,t=q){return W._assertDpi(t),le(e,"Point value"),e*t/Es},fromPx(e,t=q){return W._assertDpi(t),le(e,"Pixel value"),e*t/q},fromDim(e,t=q,n){switch(W._assertDpi(t),le(e.value,"Dimension value"),e.unit){case"mm":return W.fromMm(e.value,t);case"cm":return W.fromCm(e.value,t);case"inch":return W.fromInch(e.value,t);case"pt":return W.fromPt(e.value,t);case"px":return W.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 o=e.unit;throw new Error(`Unsupported unit: ${o}`)}}}},Ze=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===ye.DASHED)return`${t*4} ${t*2}`;if(e.type===ye.DOTTED)return`${t*1} ${t*2}`}};class Qe{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=q){const o=this.top;return o?{x1:0,y1:0,x2:t,y2:0,stroke:o.color,strokeWidth:W.fromDim(o.width,n),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,o=q){const s=this.right;return s?{x1:t,y1:0,x2:t,y2:n,stroke:s.color,strokeWidth:W.fromDim(s.width,o),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,o=q){const s=this.bottom;return s?{x1:0,y1:n,x2:t,y2:n,stroke:s.color,strokeWidth:W.fromDim(s.width,o),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=q){const o=this.left;return o?{x1:0,y1:0,x2:0,y2:t,stroke:o.color,strokeWidth:W.fromDim(o.width,n),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ve=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ve||{}),Ne=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(Ne||{});const pn={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"}}},fr={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},hr={size:pn.A4,margin:fr},js={paper:hr,grid:ur,blocks:[]};var mr=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(mr||{});const Fe=d.memo(({width:e,height:t,border:n,dpi:o=q,className:s=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:s,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,o)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,o)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,o)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,o)})]}):null);Fe.displayName="BorderRenderer";function pr(e){const t=V.BLOCK_LAYER_MIN+e*V.BLOCK_LAYER_STEP;return t>=V.BLOCK_LAYER_MAX?V.BLOCK_LAYER_MAX:t}function ft(e,t){const n=Math.min(Math.max(0,t),V.BLOCK_LAYER_STEP-1);return e+n}function Ns(){return Math.floor((V.BLOCK_LAYER_MAX-V.BLOCK_LAYER_MIN)/V.BLOCK_LAYER_STEP)}const vr=d.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:o=_e.BORDER,visible:s=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(t)return new Qe(t)},[t]);if(!s||!l||!l.hasAnyBorder)return null;const c=ft(n,o),f={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:f,"data-testid":"block-border",children:r.jsx(Fe,{width:e.width,height:e.height,border:l,dpi:a})})}),gr=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=_e.BG,backgroundColor:o="transparent",className:s=""})=>{const a=ft(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:o,pointerEvents:"none",zIndex:a};return r.jsx("div",{className:s,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),xr={color:"#cccccc",width:{value:1,unit:"pt"},type:ye.SOLID},Pt={all:xr},br=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=_e.GUIDE,borderStyle:o=Pt,visible:s=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(o)return new Qe(o)},[o]);if(!s||!l||!l.hasAnyBorder)return null;const c=ft(t,n),f={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:f,"data-testid":"block-base-border",children:r.jsx(Fe,{width:e.width,height:e.height,border:l,dpi:a})})}),Is=({id:e,plugin:t,props:n,value:o,onChange:s,onBlur:a,readOnly:i,mode:l,blockSizePx:c,blockZIndex:f,subZIndex:m=_e.CONTENT,validationState:v,className:x=""},b)=>{const I=d.useRef(null);d.useImperativeHandle(b,()=>({focus:()=>{var y;return(y=I.current)==null?void 0:y.focus()}}),[]);const E=ft(f,m),g={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:E,pointerEvents:"auto"},p={id:e,props:n,value:o,onChange:s??(()=>{}),onBlur:a,readOnly:i,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:v},h=t.Renderer;return r.jsx("div",{className:x,style:g,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(h,{ref:I,...p})})},Ds=d.forwardRef(Is),ht=d.memo(Ds);function vn(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 gn=d.memo(d.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:o,mode:s,value:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:f=!0,blockSubZIndex:m={bg:_e.BG,guide:_e.GUIDE,content:_e.CONTENT,border:_e.BORDER},defaultGuideBorder:v=Pt,dpi:x=q,className:b="",pointerEvents:I="none"},E)=>{var h,y,D,j;const g=vn(n,{zIndex:o,pointerEvents:I}),p=d.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:g,"data-block-id":e.id,className:b,children:[r.jsx(gr,{blockSizePx:p,blockZIndex:o,backgroundColor:(h=e.style)==null?void 0:h.backgroundColor,subZIndex:m.bg}),c&&!((y=e.style)!=null&&y.border)&&r.jsx(br,{blockSizePx:p,blockZIndex:o,subZIndex:m.guide,borderStyle:v,dpi:x}),r.jsx(ht,{id:e.id,ref:E,plugin:t,props:e.props,value:a,onChange:i,onBlur:l,readOnly:s===ve.EDIT?((D=e.behavior)==null?void 0:D.readOnly)??!1:!0,mode:s,blockSizePx:p,blockZIndex:o,subZIndex:m.content}),r.jsx(vr,{blockSizePx:p,blockZIndex:o,borderStyle:(j=e.style)==null?void 0:j.border,subZIndex:m.border,visible:f,dpi:x})]})}));gn.displayName="BlockContainer";const et=d.memo(({blocks:e,pluginRegistry:t,mode:n,values:o,selectedBlockIds:s=[],getBlockRectPx:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:f=!0,blockSubZIndex:m={bg:_e.BG,guide:_e.GUIDE,content:_e.CONTENT,border:_e.BORDER},defaultGuideBorder:v=Pt,dpi:x=q,className:b=""})=>{const I=d.useRef(new Map),E={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:b,style:E,"data-testid":"block-layer",children:e.map((g,p)=>{const h=t[g.kind];if(!h)return null;const y=a(g),D=s.includes(g.id);let j=pr(p);D&&(j=V.SELECT_BLOCK);const M=o[g.id]??g.initValue;return r.jsx(gn,{ref:$=>{$?I.current.set(g.id,$):I.current.delete(g.id)},block:g,plugin:h,blockRectPx:y,blockZIndex:j,mode:n,value:M,onValueChange:i?$=>i(g.id,$):void 0,onValueBlur:$=>l==null?void 0:l(g.id,$),showGuides:c,showBorder:f,blockSubZIndex:m,defaultGuideBorder:v,dpi:x,pointerEvents:"none"},g.id)})})});et.displayName="BlockLayer";const yr=d.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:o,visible:s=!0,dpi:a=q,zIndex:i=V.BORDER_OVERLAY,className:l=""})=>{const c=d.useMemo(()=>{if(o)return new Qe(o)},[o]);if(!s||!c||!c.hasAnyBorder)return null;const f={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:f,"data-testid":"border-overlay",children:r.jsx(Fe,{width:e.width,height:e.height,border:c,dpi:a})})}),_r=d.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:o=V.GRID_CANVAS,className:s})=>{const a={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:o};return r.jsx("div",{className:s,style:a,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),Rs="_label_fluf5_1",Cs={label:Rs},$s="_editor_1aiew_9",Ts="_input_1aiew_35",Ps="_select_1aiew_75",Ms="_button_1aiew_107",bt={editor:$s,input:Ts,select:Ps,button:Ms};function wr(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const o=Number(n[1]),s=n[2];if(le(o,"Dimension value"),!t.includes(s))throw new Error(`Unit not allowed: ${s}`);return{value:o,unit:s}}function ks(e,t){return e.map(n=>wr(n,t))}const Ss=10,Ls=25.4,As=.352778,Os=.264583,Z={fromCm(e){return le(e,"Centimeter value"),e*Ss},fromInch(e){return le(e,"Inch value"),e*Ls},fromPt(e){return le(e,"Point value"),e*As},fromPx(e){return le(e,"Pixel value"),e*Os},fromDim(e){switch(le(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return Z.fromCm(e.value);case"inch":return Z.fromInch(e.value);case"pt":return Z.fromPt(e.value);case"px":return Z.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 Er(e){return le(e.value,"Dimension"),`${e.value}${e.unit}`}function Gs(e){return e.map(Er)}const Bs=["fr","px","mm","cm","pt","inch"];function Fs(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=Z.fromPx(e);return Math.round(n*10)/10}case"cm":{const o=Z.fromPx(e)/10;return Math.round(o*100)/100}case"inch":{const o=Z.fromPx(e)/25.4;return Math.round(o*100)/100}case"pt":{const s=Z.fromPx(e)/25.4*72;return Math.round(s*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const jr=d.memo(({direction:e,dimension:t,currentPxSize:n,position:o,marginLeftPx:s,marginTopPx:a,onChange:i,onCancel:l})=>{const[c,f]=d.useState(t.value.toString()),[m,v]=d.useState(t.unit),x=d.useRef(null),b=d.useRef(null),I=e==="column"?{left:`${s+o}px`,top:`${a+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${a+o}px`,transform:"translateY(-50%)"};d.useEffect(()=>{var h,y;(h=x.current)==null||h.focus(),(y=x.current)==null||y.select()},[]),d.useEffect(()=>{const h=y=>{b.current&&!b.current.contains(y.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const E=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?i({unit:m,value:h}):l()},g=h=>{h.key==="Enter"?(h.preventDefault(),E()):h.key==="Escape"&&(h.preventDefault(),l())},p=h=>{const y=h.target.value;v(y);const D=Fs(n,y);f(D.toString())};return r.jsxs("div",{ref:b,className:bt.editor,style:I,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:x,type:"number",className:bt.input,value:c,onChange:h=>f(h.target.value),onKeyDown:g,min:"0.1",step:m==="fr"?"0.1":"1"}),r.jsx("select",{className:bt.select,value:m,onChange:p,children:Bs.map(h=>r.jsx("option",{value:h,children:h},h))}),r.jsx("button",{type:"button",className:bt.button,onClick:E,title:"確定",children:"✓"})]})});jr.displayName="GridUnitEditor";function Vs(e,t,n,o){if(t==="fr"){if(n!==void 0&&o!==void 0&&o>0){const s=e/o;return Math.round(n*s*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const s=Z.fromPx(e);return Math.round(s*10)/10}case"cm":{const s=Z.fromPx(e);return Math.round(s/10*100)/100}case"inch":{const s=Z.fromPx(e);return Math.round(s/25.4*100)/100}case"pt":{const s=Z.fromPx(e);return Math.round(s/25.4*72*10)/10}default:{const s=t;throw new Error(`Unsupported unit: ${s}`)}}}const wt=d.memo(({direction:e,index:t,dimension:n,position:o,currentPxSize:s,marginLeftPx:a,marginTopPx:i,isNearCursor:l,resizingPxSize:c,onDimensionChange:f})=>{const[m,v]=d.useState(!1);if(!l&&!m)return null;const x=e==="column"?{left:`${a+o}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${a-20}px`,top:`${i+o}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},b=()=>{v(!0)},I=h=>{f==null||f(e,t,h),v(!1)},E=()=>{v(!1)},p=c?(()=>{const h=Vs(c,n.unit,n.value,s);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:Cs.label,style:x,onDoubleClick:b,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",m&&r.jsx(jr,{direction:e,dimension:n,currentPxSize:s,position:o,marginLeftPx:a,marginTopPx:i,onChange:I,onCancel:E})]})});wt.displayName="GridDimensionLabel";function Us(e,t,n,o){let s="";for(const a of e)s+=`M ${a} 0 L ${a} ${o} `;for(const a of t)s+=`M 0 ${a} L ${n} ${a} `;return s}const Nr=d.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:o,lineStyle:s,visible:a=!0,zIndex:i=V.GRID_OVERLAY,dpi:l=q,className:c=""})=>{const f=d.useMemo(()=>Us(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!a||!s)return null;const m=Ze(s),v=W.fromDim(s.width,l),x={position:"absolute",left:`${n}px`,top:`${o}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:x,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:f,stroke:s.color,strokeWidth:v,strokeDasharray:m,fill:"none"})})}),Ws="_handle_c4kku_1",zs="_dragging_c4kku_37",Xt={handle:Ws,dragging:zs},Et=d.memo(({direction:e,index:t,position:n,marginLeftPx:o,marginTopPx:s,onResizeStart:a,onResize:i,onResizeEnd:l})=>{const[c,f]=d.useState(!1),m=12,v=m/2,x=e==="column"?{left:`${o+n-v}px`,top:`${s-v}px`,width:`${m}px`,height:`${m}px`,cursor:"col-resize"}:{left:`${o-v}px`,top:`${s+n-v}px`,width:`${m}px`,height:`${m}px`,cursor:"row-resize"},b=d.useCallback(I=>{I.stopPropagation(),I.preventDefault();const E=e==="column"?I.clientX:I.clientY;f(!0),a==null||a(e,t);const g=h=>{const D=(e==="column"?h.clientX:h.clientY)-E;i==null||i(e,t,D)},p=h=>{const D=(e==="column"?h.clientX:h.clientY)-E;f(!1),l==null||l(e,t,D),window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",p)},[e,t,a,i,l]);return r.jsx("div",{className:`${Xt.handle} ${Xt[e]} ${c?Xt.dragging:""}`,style:x,onPointerDown:b,"data-testid":`grid-resize-handle-${e}-${t}`})});Et.displayName="GridResizeHandle";const Ir=d.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:o=V.MARGIN_OVERLAY,className:s=""})=>{if(!t)return null;const a={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:o},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:s,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=d.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:o,borderStyle:s,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:f=!0,showBorder:m=!0,showResizeHandles:v=!1,showDimensionLabels:x=!1,onGridResize:b,onDimensionChange:I,className:E="",zIndex:g={}})=>{const[p,h]=d.useState(null),[y,D]=d.useState(null),[j,M]=d.useState(null),$=d.useRef(null);d.useEffect(()=>{const N=S=>{if(!$.current)return;const O=$.current.getBoundingClientRect();M({x:S.clientX-O.left,y:S.clientY-O.top})},R=S=>{if(!$.current)return;const O=$.current.getBoundingClientRect();(S.clientX<O.left||S.clientX>O.right||S.clientY<O.top||S.clientY>O.bottom)&&M(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",R),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",R)}},[]);const _=d.useMemo(()=>{if(!j)return!1;const N=e.content.width,R=e.content.height,S=e.margin.left,O=e.margin.top;return!(j.x>=S&&j.x<=S+N&&j.y>=O&&j.y<=O+R)},[j,e]),T=d.useCallback((N,R)=>{D({direction:N,index:R})},[]),k=d.useMemo(()=>{if(!p||!y)return null;const N=y.direction==="column"?t.cols:t.rows,R=y.index,S=N[R-1],O=p.position,K=S!==void 0?O-S:0,Q=p.position,ee=N[R+1],fe=ee!==void 0?ee-Q:0;return{direction:y.direction,prevIndex:R-1,prevSize:K,nextIndex:R,nextSize:fe}},[p,y,t]),G=d.useCallback((N,R,S)=>{const O=N==="column"?t.cols:t.rows,K=O[R];if(K===void 0)return;const Q=O[R-1],ee=O[R+1],fe=10;let ce=S;if(Q!==void 0){const X=Q+fe-K;ce=Math.max(ce,X)}if(ee!==void 0){const X=ee-fe-K;ce=Math.min(ce,X)}h({direction:N,position:K+ce})},[t]),P=d.useCallback((N,R,S)=>{const O=N==="column"?t.cols:t.rows,K=O[R];if(K===void 0){h(null);return}const Q=O[R-1],ee=O[R+1],fe=10;let ce=S;if(Q!==void 0){const X=Q+fe-K;ce=Math.max(ce,X)}if(ee!==void 0){const X=ee-fe-K;ce=Math.min(ce,X)}h(null),D(null),b==null||b(N,R,ce)},[t,b]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:E,style:L,children:[r.jsx(_r,{canvasPx:e.canvas,backgroundColor:a,boxShadow:i,zIndex:(g==null?void 0:g.canvas)??V.GRID_CANVAS,className:E}),f&&r.jsx(Ir,{paperPx:e,visible:f,marginColor:l,zIndex:(g==null?void 0:g.margin)??V.MARGIN_OVERLAY,className:E}),c&&r.jsx(Nr,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:o,visible:c,zIndex:(g==null?void 0:g.grid)??V.GRID_OVERLAY,dpi:q,className:E}),m&&r.jsx(yr,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:s,visible:m,dpi:q,zIndex:(g==null?void 0:g.border)??V.BORDER_OVERLAY,className:E}),v&&b&&r.jsxs(r.Fragment,{children:[t.cols.map((N,R)=>{if(R===0||R===t.cols.length-1)return null;const S=`col-${R}`;return r.jsx(Et,{direction:"column",index:R,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:G,onResizeEnd:P},S)}),t.rows.map((N,R)=>{if(R===0||R===t.rows.length-1)return null;const S=`row-${R}`;return r.jsx(Et,{direction:"row",index:R,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:G,onResizeEnd:P},S)})]}),x&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,R)=>{const S=t.cols[R],O=t.cols[R+1];if(S===void 0||O===void 0)return null;const K=(y==null?void 0:y.direction)==="column"&&(y.index===R||y.index===R+1);let Q;k&&k.direction==="column"&&(k.prevIndex===R?Q=k.prevSize:k.nextIndex===R&&(Q=k.nextSize));const ee=(S+O)/2,fe=O-S,ce=`col-dim-${R}`;return r.jsx(wt,{direction:"column",index:R,dimension:N,position:ee,currentPxSize:fe,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||K,resizingPxSize:Q,onDimensionChange:I},ce)})," ",n.rows.map((N,R)=>{const S=t.rows[R],O=t.rows[R+1];if(S===void 0||O===void 0)return null;const K=(y==null?void 0:y.direction)==="row"&&(y.index===R||y.index===R+1),Q=(S+O)/2,ee=O-S,fe=`row-dim-${R}`;return r.jsx(wt,{direction:"row",index:R,dimension:N,position:Q,currentPxSize:ee,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:_||K,onDimensionChange:I},fe)})]}),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:V.GRID_GHOST}})]})});class Ys{constructor(){Wt(this,"state",null);Wt(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 ut=new Ys;function Qt(e,t,n,o){if(t<0||t>=e.length)return e;const s=[...e],a=s[t],i=s[t+1];return!a||!i?e:a.unit==="fr"&&i.unit==="fr"?Hs(s,t,n,o):a.unit!=="fr"&&i.unit!=="fr"?Ks(s,t,n):a.unit==="fr"&&i.unit!=="fr"?Jn(s,t,n,"next",o):Jn(s,t,n,"current",o)}function Hs(e,t,n,o){const s=e[t],a=e[t+1];if(!s||!a)return e;const i=e.reduce((I,E)=>E.unit==="fr"?I+E.value:I,0),l=o/i,c=s.value*l,f=a.value*l,m=Math.max(10,c+n),v=Math.max(10,f-n),x=m/l,b=v/l;return e[t]={...s,value:Math.round(x*100)/100},e[t+1]={...a,value:Math.round(b*100)/100},e}function Ks(e,t,n){const o=e[t],s=e[t+1];if(!o||!s)return e;const a=W.fromDim(o),i=W.fromDim(s),l=Math.max(10,a+n),c=Math.max(10,i-n);return e[t]={...o,value:jt(l,o.unit)},e[t+1]={...s,value:jt(c,s.unit)},e}function Jn(e,t,n,o,s){const a=e[t],i=e[t+1];if(!a||!i)return e;let l=0,c=0;for(const v of e)v.unit==="fr"?l+=v.value:c+=W.fromDim(v);const f=s-c,m=l>0?f/l:0;if(o==="next"){const v=W.fromDim(i),x=Math.max(10,v-n);e[t+1]={...i,value:jt(x,i.unit)};const b=x-v,I=f-b,E=a.value*m,g=Math.max(10,E+n),p=l>0?g/I*l:1;e[t]={...a,value:Math.round(p*100)/100}}else{const v=W.fromDim(a),x=Math.max(10,v+n);e[t]={...a,value:jt(x,a.unit)};const b=x-v,I=f-b,E=i.value*m,g=Math.max(10,E-n),p=l>0?g/I*l:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function jt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=Z.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=Z.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=Z.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=Z.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 Dr(e){if(e.length===0)return[];const t=[];let n=0;for(const o of e){le(o,"Pixel value");const s=o+n,a=Math.round(s);t.push(a),n=s-a}return t}const Xs=8,qs=32,Zs=64,Js=512,Qn=(e,t,n)=>Math.min(Math.max(e,t),n);function en(e){const t=e.length-1,n=t>=1?e[t]??0:0,o=e.length>=1?n/t:0,s=Qn(Math.ceil(Math.log2(t+1)),Xs,qs),a=Qn(o*2,Zs,Js);return{step:s,windowPx:a}}function _t(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 o=1,s=n;for(;o<=s;){const a=o+s>>>1,i=t[a];if(i===void 0){s=a-1;continue}i<=e?o=a+1:s=a-1}return o-1}function tn(e,t,n){const o=e.length-1;let s=0;return a=>{if(o<=0||e[0]===void 0||a<e[0]||e[o]===void 0)return-1;if(a>=e[o])return o-1;const i=e[s],l=e[s+1];if(i===void 0||l===void 0)return-1;if(i<=a&&a<l)return s;const c=i-n,f=l+n;if(a<c||a>=f)return s=_t(a,e),s;let m=0;const v=e[s+1];if(v!==void 0&&a>=v)for(;s+1<o;){const x=e[s+1];if(x===void 0||a<x)break;if(s++,++m>t)return s=_t(a,e),s}else for(;s>0;){const x=e[s];if(x===void 0||a>=x)break;if(s--,++m>t)return s=_t(a,e),s}return s}}function Nt(e,t){if(e.length===0)return[];le(t,"Content size");let n=0,o=0;const s=e.map(l=>{if(le(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Z.fromDim(l);return o+=c,c}});if(n===0)return dr(o,0,t,"Total fixed size"),s;const a=t-o;le(a,"Content size - fixed sizes");const i=a/n;return s.map((l,c)=>{const f=e[c];if(l!=null)return l;if(!f)throw new Error(`dims[${c}] is undefined`);return f.value*i})}function It(e,t=96){$t(t,"DPI"),Tt(t,"DPI");const n=e.map(s=>W.fromMm(s,t));return Dr(n)}function Qs(e,t,n){if(e.length===0)return[];$t(n,"DPI"),Tt(n,"DPI"),le(t,"Content size");const o=Nt(e,t);return It(o,n)}function Dt(e){const t={};for(const[n,o]of Object.entries(e))if(o!=null)if(typeof o=="object"&&!Array.isArray(o)&&o!==null){const s=Dt(o);t[n]=s}else t[n]=o;return t}function ei(e,t){const o={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:o.height,height:o.width}:o}function Rr(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function Cr(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function nn(e,t){var s,a;const n=document.title,o=document.createElement("style");o.id="tatamicks-print-style",o.textContent=`
22
+ <%s key={someKey} {...props} />`,z,Z,ue,Z),X[Z+z]=!0)}if(Z=null,A!==void 0&&(n(A),Z=""+A),i(C)&&(n(C.key),Z=""+C.key),"key"in C){A={};for(var be in C)be!=="key"&&(A[be]=C[be])}else A=C;return Z&&l(A,typeof v=="function"?v.displayName||v.name||"Unknown":v),d(v,Z,A,o(),he,Oe)}function x(v){g(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===T&&(v._payload.status==="fulfilled"?g(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function g(v){return typeof v=="object"&&v!==null&&v.$$typeof===j}var b=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"),_=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"),w=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),R=b.__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};b={react_stack_bottom_frame:function(v){return v()}};var P,S={},F=b.react_stack_bottom_frame.bind(b,a)(),K=D(s(a)),X={};Be.Fragment=f,Be.jsx=function(v,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(v,C,A,!1,z?Error("react-stack-top-frame"):F,z?D(s(v)):K)},Be.jsxs=function(v,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(v,C,A,!0,z?Error("react-stack-top-frame"):F,z?D(s(v)):K)}})()),Be}var un;function yr(){return un||(un=1,process.env.NODE_ENV==="production"?qe.exports=_r():qe.exports=wr()),qe.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_gerw7_9",jr="_select_gerw7_21",Nr="_placeholderOverlay_gerw7_87",xt={container:Er,select:jr,placeholderOverlay:Nr},_e=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!=="",g={};l!==void 0?g.width=`${l}px`:g.width="100%";const b={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:g,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:b,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:b,value:m,onChange:d,disabled:s,children:a.map(j=>r.jsx("option",{value:String(j.value),children:j.label},String(j.value)))})]})};_e.displayName="Select";const fn={justifyContent:{defaultValue:Te.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:_e,config:{options:[{label:"左揃え",value:Te.left},{label:"中央揃え",value:Te.center},{label:"右揃え",value:Te.right}]}},alignItems:{defaultValue:Ce.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:_e,config:{options:[{label:"上揃え",value:Ce.top},{label:"中央揃え",value:Ce.center},{label:"下揃え",value:Ce.bottom}]}}},Ir="_container_6u83k_9",Dr="_input_6u83k_25",$r="_label_6u83k_57",gt={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:gt.container,children:[r.jsx("input",{type:"checkbox",className:gt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:gt.label,children:a})]})};xe.displayName="Checkbox";const Tr="_container_1gj1n_9",Cr="_colorButton_1gj1n_25",Rr="_textInputWrapper_1gj1n_79",Mr="_textInputPrefix_1gj1n_123",kr="_textInput_1gj1n_79",Pr="_popover_1gj1n_249",Ar="_palette_1gj1n_281",Sr="_paletteButton_1gj1n_295",Lr="_selected_1gj1n_341",Or="_transparentPaletteButton_1gj1n_353",Gr="_rgbaInputs_1gj1n_365",Br="_rgbaInputGroup_1gj1n_379",Vr="_rgbaLabel_1gj1n_409",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_me6tq_9",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 g=s??(m==null?void 0:m.min)??1,b=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),_=u.useCallback(E=>{const M=E.target.value;if(M===""){t(void 0);return}let $=Number.parseFloat(M);Number.isNaN($)||(y&&($=Math.round($)),g!==void 0&&$<g&&($=g),b!==void 0&&$>b&&($=b),t($))},[t,g,b,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:_,onBlur:x,disabled:n,min:g,max:b,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),g=l??(c==null?void 0:c.height),[b,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]),[_,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]),w=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%",g!==void 0&&(L.height=`${g}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:_,onChange:E,onKeyDown:w,onBlur:$,disabled:n,placeholder:m,maxLength:8})]}),r.jsx(At,{isOpen:b,onClose:()=>j(!1),rgba:f,onRgbaChange:k,onColorSelect:T,selectedColor:e,readOnly:n})]})};We.displayName="ColorPicker";const Yr="_container_3qavu_9",Hr="_valueInput_3qavu_45",Kr="_unitSelect_3qavu_89",bt={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),g=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),b=u.useCallback(_=>{const I=_.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)??g})},[t,n,g,i,l]),j=u.useCallback(_=>{const I=_.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)??g})),l!==void 0&&E>l&&(E=l,n({value:E,unit:(t==null?void 0:t.unit)??g}))},[t,n,g,i,l]),y=u.useCallback(_=>{const I=_.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)??g??"",h={};return m!==void 0?h.width=`${m}px`:h.width="100%",x!==void 0&&(h.height=`${x}px`),r.jsxs("div",{className:bt.container,style:h,children:[r.jsx("input",{type:"number",className:bt.valueInput,value:f,onChange:b,onBlur:j,placeholder:d,min:i??1,max:l,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:bt.unitSelect,value:p,onChange:y,disabled:s||!a||a.length<=1,children:a?a.map(_=>r.jsx("option",{value:_,children:_},_)):r.jsx("option",{value:p,children:p})})]})},Xr="_container_1sn14_11",Zr="_scrollArea_1sn14_45",qr="_emptyState_1sn14_61",vt={container:Xr,scrollArea:Zr,emptyState:qr},St=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${vt.container} ${n||""}`,children:e?r.jsx("div",{className:vt.scrollArea,children:e}):t&&r.jsx("div",{className:vt.emptyState,children:t})}),Jr="_root_kb3dm_5",Qr="_list_kb3dm_21",eo="_trigger_kb3dm_51",to="_content_kb3dm_141",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,g={...i};return o!==void 0&&(g.width=`${o}px`),a!==void 0&&(g.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:g,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_hr2wj_9",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),g=o??(d==null?void 0:d.maxLength),b=a??(d==null?void 0:d.multiline)??!1,j=i??(d==null?void 0:d.rows)??3,y=u.useCallback(h=>{const _=h.target.value;t(_)},[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:g};return b?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"],gn=["px","pt","mm"],bn=["px","pt","mm"],$e=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],vn={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,...vn},_n=[{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:bn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:_e,config:{placeholder:"フォントを選択",options:_n}},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:_e,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:_e,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:_e,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"}}},wn=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=wn(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 go(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const bo=25.4,vo=2.54,_o=72,V={_assertDpi(e){ct(e,"DPI"),ut(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),ne(e,"Millimeter value"),e*t/bo},fromCm(e,t=W){return V._assertDpi(t),ne(e,"Centimeter value"),e*t/vo},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/_o},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},wo={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:g=""},b)=>{const j=u.useRef(null);u.useImperativeHandle(b,()=>({focus:()=>{var _;return(_=j.current)==null?void 0:_.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:g,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:g=W,className:b="",pointerEvents:j="none"},y)=>{var h,_,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:b,children:[r.jsx(Cn,{blockSizePx:p,blockZIndex:s,backgroundColor:(h=e.style)==null?void 0:h.backgroundColor,subZIndex:m.bg}),c&&!((_=e.style)!=null&&_.border)&&r.jsx(Mn,{blockSizePx:p,blockZIndex:s,subZIndex:m.guide,borderStyle:x,dpi:g}),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:g})]})}));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:g=W,className:b=""})=>{const j=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:b,style:y,"data-testid":"block-layer",children:e.map((f,p)=>{const h=t[f.kind];if(!h)return null;const _=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:_,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:g,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_fluf5_1",Io={label:No},Do="_editor_1aiew_9",$o="_input_1aiew_35",To="_select_1aiew_75",Co="_button_1aiew_107",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),g=u.useRef(null),b=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,_;(h=g.current)==null||h.focus(),(_=g.current)==null||_.select()},[]),u.useEffect(()=>{const h=_=>{b.current&&!b.current.contains(_.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 _=h.target.value;x(_);const I=Oo(n,_);d(I.toString())};return r.jsxs("div",{ref:b,className:Je.editor,style:j,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:g,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 g=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"},b=()=>{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:g,onDoubleClick:b,"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),g={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:g,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_c4kku_1",Uo="_dragging_c4kku_37",_t={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,g=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"},b=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:`${_t.handle} ${_t[e]} ${c?_t.dragging:""}`,style:g,onPointerDown:b,"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:g=!1,onGridResize:b,onDimensionChange:j,className:y="",zIndex:f={}})=>{const[p,h]=u.useState(null),[_,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 w=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||!_)return null;const N=_.direction==="column"?t.cols:t.rows,D=_.index,P=N[D-1],S=p.position,F=P!==void 0?S-P:0,K=p.position,X=N[D+1],v=X!==void 0?X-K:0;return{direction:_.direction,prevIndex:D-1,prevSize:F,nextIndex:D,nextSize:v}},[p,_,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],v=10;let C=P;if(K!==void 0){const A=K+v-F;C=Math.max(C,A)}if(X!==void 0){const A=X-v-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],v=10;let C=P;if(K!==void 0){const A=K+v-F;C=Math.max(C,A)}if(X!==void 0){const A=X-v-F;C=Math.min(C,A)}h(null),I(null),b==null||b(N,D,C)},[t,b]),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&&b&&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)})]}),g&&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=(_==null?void 0:_.direction)==="column"&&(_.index===D||_.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,v=S-P,C=`col-dim-${D}`;return r.jsx(tt,{direction:"column",index:D,dimension:N,position:X,currentPxSize:v,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:w||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=(_==null?void 0:_.direction)==="row"&&(_.index===D||_.index===D+1),K=(P+S)/2,X=S-P,v=`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:w||F,onDimensionChange:j},v)})]}),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),g=m/l,b=x/l;return e[t]={...o,value:Math.round(g*100)/100},e[t+1]={...a,value:Math.round(b*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),g=Math.max(10,x-n);e[t+1]={...i,value:rt(g,i.unit)};const b=g-x,j=d-b,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),g=Math.max(10,x+n);e[t]={...a,value:rt(g,a.unit)};const b=g-x,j=d-b,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 g=e[o+1];if(g===void 0||a<g)break;if(o++,++m>t)return o=et(a,e),o}else for(;o>0;){const g=e[o];if(g===void 0||a>=g)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 Zo(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 qo(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=`
31
23
  @media print {
32
24
  /* bodyとhtmlのマージン・パディングをリセット */
33
25
  html, body {
@@ -67,12 +59,12 @@ React keys must be passed directly to JSX without using spread:
67
59
  color-adjust: exact !important;
68
60
  }
69
61
  }
70
- `;try{document.head.appendChild(o),e.classList.add("tatamicks-print-target"),t!=null&&t.title&&(document.title=t.title),(s=t==null?void 0:t.onBeforePrint)==null||s.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 ti(e){Rr({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var o;(o=e==null?void 0:e.onBeforePrint)==null||o.call(e)},n=()=>{var o;(o=e==null?void 0:e.onAfterPrint)==null||o.call(e),Cr({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function ni(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 ri(e){return e==="fr"||e==="px"||e==="%"}function er(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&ri(n.unit)}):!1}function oi(e){if(typeof e!="object"||e===null)return!1;const t=e;return er(t.cols)&&er(t.rows)}function si(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 o=n.width;if(typeof o.value!="number"||typeof o.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const s=n.height;if(typeof s.value!="number"||typeof s.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 ii(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function $r(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!si(t.paper))throw new Error("Invalid paper definition");if(!oi(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(ni))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 o in n)if(!ii(n[o]))throw new Error(`Invalid value in metaData.${o}`)}return t}function rn(e){try{const t=JSON.parse(e);return $r(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function on(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 Tr(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(Tr):!1}function Pr(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(!Tr(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function sn(e){try{const t=JSON.parse(e);return Pr(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function an(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 mt={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:ye.SOLID}},kt={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},oe={base:V.INTERACTION_LAYER_BASE,select_block:V.SELECT_BLOCK,block_ghost:V.BLOCK_GHOST,hover_outline:V.HOVER_OUTLINE,edit_block:V.EDIT_BLOCK,grid_ghost:V.GRID_GHOST,grid_handles:V.GRID_HANDLES,select_border:V.BLOCK_SELECT_BORDER,block_handles:V.BLOCK_HANDLES,rubber_band:V.RUBBER_BAND};var Y=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(Y||{}),J=(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))(J||{}),ue=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(ue||{}),B=(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))(B||{});const ai="_interactionBlock_7lg72_13",li="_resizeHandle_7lg72_13",Mr={interactionBlock:ai,resizeHandle:li},ci=[{id:J.NW,cursor:"nwse-resize",x:0,y:0},{id:J.N,cursor:"ns-resize",x:50,y:0},{id:J.NE,cursor:"nesw-resize",x:100,y:0},{id:J.W,cursor:"ew-resize",x:0,y:50},{id:J.E,cursor:"ew-resize",x:100,y:50},{id:J.SW,cursor:"nesw-resize",x:0,y:100},{id:J.S,cursor:"ns-resize",x:50,y:100},{id:J.SE,cursor:"nwse-resize",x:100,y:100}],xn=d.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=kt,zIndex:o=V.BLOCK_HANDLES})=>{const s=n.size,a=s/2;return r.jsx(r.Fragment,{children:ci.map(({id:i,cursor:l,x:c,y:f})=>{const m=c===50?`calc(50% - ${a}px)`:c===100?`calc(100% - ${a}px)`:`-${a}px`,v=f===50?`calc(50% - ${a}px)`:f===100?`calc(100% - ${a}px)`:`-${a}px`,x=t===i;return r.jsx("div",{className:Mr.resizeHandle,onPointerDown:b=>{b.stopPropagation(),e(b,i)},style:{position:"absolute",left:m,top:v,width:`${s}px`,height:`${s}px`,backgroundColor:x?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",opacity:x?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:x?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});xn.displayName="ResizeHandles";const kr=d.memo(({width:e,height:t,zIndex:n=V.BLOCK_SELECT_BORDER,borderStyle:o=mt})=>{const s=d.useMemo(()=>new Qe(o),[o]),a={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:a,children:r.jsx(Fe,{width:e,height:t,border:s})})}),tt=d.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:o,activeHandle:s,selectionStyle:a=mt,handleStyle:i=kt,selectBorderZIndex:l=oe.select_border,blockHandlesZIndex:c=oe.block_handles})=>{const f={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:Mr.interactionBlock,style:f,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(kr,{width:t.width,height:t.height,zIndex:l,borderStyle:a}),n&&o&&r.jsx(xn,{onResizeStart:o,activeHandle:s,handleStyle:i,zIndex:c})]})});tt.displayName="InteractionBlock";const bn=d.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:o,currentMousePx:s,pluginKind:a,defaultSize:i,isOutside:l,selectionStyle:c,ghostZIndex:f=oe.block_ghost,selectBorderZIndex:m=oe.select_border,blockHandlesZIndex:v=oe.block_handles})=>{const x=e[a];if(!x)return null;let b;if(l&&s){const E=Be(x,{x:0,y:0,w:i.w,h:i.h}),g=n(E);b={left:s.x-g.width/2,top:s.y-g.height/2,width:g.width,height:g.height}}else{const E=t.cols-i.w,g=t.rows-i.h,p=Math.max(0,Math.min(o.col,E)),h=Math.max(0,Math.min(o.row,g)),y=Be(x,{x:p,y:h,w:i.w,h:i.h});b=n(y)}const I=Be(x,{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:`${b.left}px`,top:`${b.top}px`,width:`${b.width}px`,height:`${b.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:f},children:r.jsx(ht,{id:I.id,plugin:x,props:I.props,value:I.initValue,onChange:()=>{},readOnly:!0,mode:ve.EDIT,blockSizePx:b,blockZIndex:f})}),r.jsx(tt,{block:I,rect:b,selectionStyle:c,selectBorderZIndex:m,blockHandlesZIndex:v})]})});bn.displayName="InsertGhost";function yn(e,t,n,o,s){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const h=o-p.layout.w,y=s-p.layout.h,D=Math.max(0,Math.min(p.layout.x+t,h)),j=Math.max(0,Math.min(p.layout.y+n,y));return[{blockId:p.id,x:D,y:j}]}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)),f=l-a,m=c-i,v=a+t,x=i+n,b=Math.max(0,Math.min(v,o-f)),I=Math.max(0,Math.min(x,s-m)),E=b-a,g=I-i;return e.map(p=>({blockId:p.id,x:p.layout.x+E,y:p.layout.y+g}))}const _n=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s,deltaCol:a,deltaRow:i,isOutside:l,currentMousePx:c,selectionStyle:f,ghostZIndex:m=oe.block_ghost,selectBorderZIndex:v=oe.select_border,blockHandlesZIndex:x=oe.block_handles})=>{const b=s.map(E=>e.find(g=>g.id===E)).filter(Boolean),I=yn(b,a,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(E=>{const g=e.find(D=>D.id===E);if(!g)return null;const p=t[g.kind];if(!p)return null;let h;if(l&&c){const D=o(g);h={left:c.x-D.width/2,top:c.y-D.height/2,width:D.width,height:D.height}}else{const D=I.find(M=>M.blockId===g.id);if(!D)return null;const j={...g,layout:{...g.layout,x:D.x,y:D.y}};h=o(j)}const y={...g,layout:{...g.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(ht,{id:y.id,plugin:p,props:y.props,value:y.initValue,onChange:()=>{},readOnly:!0,mode:ve.EDIT,blockSizePx:h,blockZIndex:m,className:"ghost-content"})}),r.jsx(tt,{block:y,rect:h,selectionStyle:f,selectBorderZIndex:v,blockHandlesZIndex:x})]},E)})})});_n.displayName="MovingGhost";function wn({layout:e,handle:t,deltaCol:n,deltaRow:o,gridCols:s,gridRows:a}){const i={...e};if(t===J.E||t===J.NE||t===J.SE){const l=s-e.x;i.w=Math.max(1,Math.min(e.w+n,l))}else if(t===J.W||t===J.NW||t===J.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===J.S||t===J.SE||t===J.SW){const l=a-e.y;i.h=Math.max(1,Math.min(e.h+o,l))}else if(t===J.N||t===J.NE||t===J.NW){const l=e.h-1,c=o>0?Math.min(o,l):o;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 En=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:s,handle:a,deltaCol:i,deltaRow:l,isOutside:c,selectionStyle:f,ghostZIndex:m=oe.block_ghost,selectBorderZIndex:v=oe.select_border,blockHandlesZIndex:x=oe.block_handles})=>{const b=e.find(h=>h.id===s),I=t[(b==null?void 0:b.kind)??""];if(!b||!I)return null;const E=wn({layout:b.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),g={...b,layout:E},p=o(g);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(ht,{id:g.id,plugin:I,props:g.props,value:g.initValue,onChange:()=>{},readOnly:!0,mode:ve.EDIT,blockSizePx:p,blockZIndex:m,className:"resize-ghost-content"})}),r.jsx(tt,{block:g,rect:p,selectionStyle:f,selectBorderZIndex:v,blockHandlesZIndex:x})]},b.id)})});En.displayName="ResizeGhost";const jn=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:o,getBlockRectPx:s,selectionStyle:a=mt,ghostZIndex:i=oe.block_ghost,selectBorderZIndex:l=oe.select_border,blockHandlesZIndex:c=oe.block_handles})=>{if(!o)return null;const f=o.currentGrid.col-o.startGrid.col,m=o.currentGrid.row-o.startGrid.row;switch(o.type){case ue.MOVE:return r.jsx(_n,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o.blockIds,deltaCol:f,deltaRow:m,isOutside:o.isOutside??!1,currentMousePx:o.currentMousePx,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c});case ue.RESIZE:{const v=o.blockIds[0];return!v||!o.handle?null:r.jsx(En,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:v,handle:o.handle,deltaCol:f,deltaRow:m,isOutside:o.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c})}case ue.INSERT:return o.defaultSize?r.jsx(bn,{pluginRegistry:t,gridLength:n,getBlockRectPx:s,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,pluginKind:o.pluginKind||"",defaultSize:o.defaultSize,isOutside:o.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});jn.displayName="DragLayer";const ui=({id:e,plugin:t,props:n,value:o,onChange:s,onBlur:a,blockRectPx:i,zIndex:l=V.EDIT_BLOCK,validationState:c,className:f=""},m)=>{const v=d.useRef(null);d.useImperativeHandle(m,()=>({focus:()=>{var g;(g=v.current)==null||g.focus()}}),[]);const x=vn(i,{zIndex:l,pointerEvents:"auto"}),b={width:i.width,height:i.height},I={id:e,props:n,value:o,onChange:s,onBlur:a,readOnly:!1,mode:ve.FORM,dimensions:{widthPx:b.width,heightPx:b.height},validationState:c},E=t.Renderer;return r.jsx("div",{className:f,style:x,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(E,{ref:v,...I})})},di=d.forwardRef(ui),Sr=d.memo(di);function Lr(e){const[t,n]=d.useState({mode:Y.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),o=d.useCallback(s=>{n(a=>{switch(s.type){case B.SELECT:{const i=s.blockIds;return{...a,mode:Y.IDLE,selectedBlockIds:i}}case B.DESELECT:return{...a,mode:Y.IDLE,selectedBlockIds:[]};case B.START_PRESS:{const i=s.selectedBlockIds||[s.blockId];return{...a,mode:Y.PRESSING,dragging:{type:ue.MOVE,blockIds:i,startGrid:s.startGrid,currentGrid:s.startGrid,isOutside:!1}}}case B.UPDATE_DRAG:{if(!a.dragging)return a;const i=s.currentGrid.col!==a.dragging.startGrid.col||s.currentGrid.row!==a.dragging.startGrid.row;return a.mode===Y.PRESSING?i?{...a,mode:Y.DRAGGING,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:{...a,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:a.mode===Y.DRAGGING?{...a,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:a}case B.END_DRAG:return{...a,mode:Y.IDLE,dragging:void 0};case B.CANCEL_DRAG:return{...a,mode:Y.IDLE,dragging:void 0};case B.EDIT:return{...a,mode:Y.EDITING,editingBlockId:s.blockId};case B.END_EDIT:return{...a,mode:Y.IDLE,editingBlockId:null};case B.START_INSERT:return{...a,mode:Y.DRAGGING,dragging:{type:ue.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:s.pluginKind,defaultSize:s.defaultSize,isOutside:!1}};case B.CANCEL_INSERT:return{...a,mode:Y.IDLE,dragging:void 0};case B.START_RESIZE:return{...a,mode:Y.DRAGGING,dragging:{type:ue.RESIZE,blockIds:[s.blockId],startGrid:s.startGrid,currentGrid:s.startGrid,handle:s.handle,isOutside:!1}};default:return a}})},[]);return[t,o]}const Nn=d.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:o,getBlockRectPx:s,onResizeStart:a,selectionStyle:i=mt,handleStyle:l=kt,selectBorderZIndex:c=oe.select_border,blockHandlesZIndex:f=oe.block_handles})=>{if(n&&(o==null?void 0:o.type)!==ue.RESIZE)return null;const v=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:v.map(x=>{const b=e.find(g=>g.id===x);if(!b)return null;const E=(o==null?void 0:o.type)===ue.RESIZE&&o.blockIds.includes(x)?o==null?void 0:o.handle:null;return r.jsx(tt,{block:b,rect:s(b),showHandles:!0,onResizeStart:(g,p)=>a(g,p,x),activeHandle:E,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:f},b.id)})})});Nn.displayName="SelectionLayer";function Ar(e,t,n,o){const s=n-t.w,a=o-t.h;return{x:Math.max(0,Math.min(e.x,s)),y:Math.max(0,Math.min(e.y,a))}}function ln(e,t,n){const{x:o,y:s}=e;for(let a=t.length-1;a>=0;a--){const i=t[a];if(!i)continue;const l=n(i);if(o>=l.left&&o<=l.left+l.width&&s>=l.top&&s<=l.top+l.height)return i.id}return null}const In=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,getColIndex:s,getRowIndex:a,state:i,onChange:l,onBlockChange:c,scale:f=1,className:m="",selectionStyle:v,handleStyle:x,editBlockZIndex:b=V.EDIT_BLOCK,selectBorderZIndex:I=oe.select_border,blockHandlesZIndex:E=oe.block_handles,dragGhostZIndex:g=oe.block_ghost})=>{const p=d.useRef(null),h=d.useRef(null);d.useEffect(()=>{i.mode===Y.EDITING&&i.editingBlockId&&setTimeout(()=>{var _;(_=h.current)==null||_.focus()},0)},[i.mode,i.editingBlockId]),d.useEffect(()=>{const _=new Set(e.map(k=>k.id)),T=i.selectedBlockIds.filter(k=>_.has(k));T.length!==i.selectedBlockIds.length&&l({type:B.SELECT,blockIds:T,shiftKey:!1})},[e,i.selectedBlockIds,l]);const y=d.useCallback(_=>{var R;if(_.button!==0)return;const T=(R=p.current)==null?void 0:R.getBoundingClientRect();if(!T)return;const k=f??1,G={x:(_.clientX-T.left)/k,y:(_.clientY-T.top)/k},P=ln(G,e,o);if(i.mode===Y.EDITING){P!==i.editingBlockId&&(l({type:B.END_EDIT}),P||l({type:B.DESELECT}));return}const L=s(G.x),N=a(G.y);if(P){_.stopPropagation();const S=i.selectedBlockIds.includes(P);if(S&&_.shiftKey){const O=i.selectedBlockIds.filter(K=>K!==P);l({type:B.SELECT,blockIds:O,shiftKey:!0});return}else S?(_.currentTarget.setPointerCapture(_.pointerId),l({type:B.START_PRESS,blockId:P,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(_.currentTarget.setPointerCapture(_.pointerId),_.shiftKey?l({type:B.SELECT,blockIds:[...i.selectedBlockIds,P],shiftKey:!0}):(l({type:B.SELECT,blockIds:[P]}),l({type:B.START_PRESS,blockId:P,startGrid:{col:L,row:N},selectedBlockIds:[P]})))}else _.stopPropagation(),l({type:B.DESELECT})},[e,o,s,a,i.mode,i.selectedBlockIds,l,f,i.editingBlockId]),D=d.useCallback(_=>{var ee;if(i.mode!==Y.PRESSING&&i.mode!==Y.DRAGGING||!i.dragging)return;const T=(ee=p.current)==null?void 0:ee.getBoundingClientRect();if(!T)return;const k=f??1,G=T.width/k,P=T.height/k,L=(_.clientX-T.left)/k,N=(_.clientY-T.top)/k,R=i.dragging.type!==ue.RESIZE&&(L<0||L>G||N<0||N>P),S=Math.max(0,Math.min(L,G)),O=Math.max(0,Math.min(N,P)),K=s(S),Q=a(O);l({type:B.UPDATE_DRAG,currentGrid:{col:K,row:Q},currentMousePx:{x:L,y:N},isOutside:R})},[i.mode,i.dragging,s,a,l,f]),j=d.useCallback(_=>{if(i.mode===Y.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===ue.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:B.DESELECT})),l({type:B.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===ue.MOVE){if(T!==0||k!==0){const G=i.dragging.blockIds.map(N=>e.find(R=>R.id===N)).filter(Boolean);if(G.length===0){l({type:B.END_DRAG}),_.currentTarget.releasePointerCapture(_.pointerId);return}const P=yn(G,T,k,n.cols,n.rows),L=G.map(N=>{const R=P.find(S=>S.blockId===N.id);return R?{...N,layout:{...N.layout,x:R.x,y:R.y}}:N});c==null||c({type:be.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===ue.INSERT){const{pluginKind:G,currentGrid:P,defaultSize:L}=i.dragging;if(G&&L){const N=t[G];if(N){const{x:R,y:S}=Ar({x:P.col,y:P.row},{w:L.w,h:L.h},n.cols,n.rows),O=Be(N,{x:R,y:S,w:L.w,h:L.h});c==null||c({type:be.ADD,blockIds:[O.id],blocks:[O]})}}}else if(i.dragging.type===ue.RESIZE){const G=i.dragging.blockIds[0],P=e.find(N=>N.id===G),L=i.dragging.handle;if(P&&L&&(T!==0||k!==0)){const N=wn({layout:P.layout,handle:L,deltaCol:T,deltaRow:k,gridCols:n.cols,gridRows:n.rows});(N.x!==P.layout.x||N.y!==P.layout.y||N.w!==P.layout.w||N.h!==P.layout.h)&&(c==null||c({type:be.RESIZE,blockIds:[P.id],blocks:[{...P,layout:N}]}))}}l({type:B.END_DRAG})}else i.mode===Y.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===ue.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:B.DESELECT})),l({type:B.CANCEL_DRAG}));_.currentTarget.releasePointerCapture(_.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),M=d.useCallback(_=>{var L;const T=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!T)return;const k=f??1,G={x:(_.clientX-T.left)/k,y:(_.clientY-T.top)/k},P=ln(G,e,o);P&&(i.selectedBlockIds.includes(P)||l({type:B.SELECT,blockIds:[P]}),l({type:B.EDIT,blockId:P}))},[e,o,l,f,i.selectedBlockIds]),$=d.useCallback(_=>{var T;if((i.mode===Y.PRESSING||i.mode===Y.DRAGGING)&&i.dragging){const k=(T=p.current)==null?void 0:T.getBoundingClientRect();if(k){const G=f??1,P=(_.clientX-k.left)/G,L=(_.clientY-k.top)/G,N=k.width/G,R=k.height/G,S=Math.max(0,Math.min(P,N)),O=Math.max(0,Math.min(L,R));l({type:B.UPDATE_DRAG,currentGrid:{col:s(S),row:a(O)},currentMousePx:{x:P,y:L},isOutside:!0})}}},[i.mode,i.dragging,f,s,a,l]);return r.jsxs("div",{ref:p,className:m,style:{position:"absolute",inset:0,zIndex:V.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:y,onPointerMove:D,onPointerUp:j,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(Sr,{ref:h,id:_.id,plugin:T,props:_.props,value:_.initValue,onChange:k=>{c==null||c({type:be.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:k}]})},onBlur:k=>{c==null||c({type:be.UPDATE,blockIds:[_.id],blocks:[{..._,initValue:k}]})},blockRectPx:o(_),zIndex:b})})(),r.jsx(Nn,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===Y.DRAGGING,draggingState:i.dragging,getBlockRectPx:o,onResizeStart:(_,T,k)=>{var N;const G=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!G)return;i.mode===Y.EDITING&&l({type:B.END_EDIT}),_.currentTarget.setPointerCapture(_.pointerId);const P=f??1,L={x:(_.clientX-G.left)/P,y:(_.clientY-G.top)/P};l({type:B.START_RESIZE,blockId:k,handle:T,startGrid:{col:s(L.x),row:a(L.y)}})},selectionStyle:v,handleStyle:x,selectBorderZIndex:I,blockHandlesZIndex:E}),r.jsx(jn,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:o,selectionStyle:v,ghostZIndex:g,selectBorderZIndex:I,blockHandlesZIndex:E})]})});In.displayName="InteractionLayer";function pt(e,t,n=q){const o=d.useMemo(()=>Z.fromDim(e.size.width),[e.size.width]),s=d.useMemo(()=>Z.fromDim(e.size.height),[e.size.height]),a=d.useMemo(()=>Z.fromDim(e.margin.top),[e.margin.top]),i=d.useMemo(()=>Z.fromDim(e.margin.bottom),[e.margin.bottom]),l=d.useMemo(()=>Z.fromDim(e.margin.left),[e.margin.left]),c=d.useMemo(()=>Z.fromDim(e.margin.right),[e.margin.right]),f=d.useMemo(()=>o-l-c,[o,l,c]),m=d.useMemo(()=>s-a-i,[s,a,i]),v=d.useMemo(()=>Nt(t.cols,f),[t.cols,f]),x=d.useMemo(()=>Nt(t.rows,m),[t.rows,m]),b=d.useMemo(()=>W.fromMm(o,n),[o,n]),I=d.useMemo(()=>W.fromMm(s,n),[s,n]),E=d.useMemo(()=>W.fromMm(a,n),[a,n]),g=d.useMemo(()=>W.fromMm(i,n),[i,n]),p=d.useMemo(()=>W.fromMm(l,n),[l,n]),h=d.useMemo(()=>W.fromMm(c,n),[c,n]),y=d.useMemo(()=>W.fromMm(f,n),[f,n]),D=d.useMemo(()=>W.fromMm(m,n),[m,n]),j=d.useMemo(()=>It(v,n),[v,n]),M=d.useMemo(()=>It(x,n),[x,n]),$=d.useMemo(()=>{const X=[0];for(const ke of j){const Se=X[X.length-1]??0;X.push(Se+ke)}return X},[j]),_=d.useMemo(()=>{const X=[0];for(const ke of M){const Se=X[X.length-1]??0;X.push(Se+ke)}return X},[M]),{step:T,windowPx:k}=d.useMemo(()=>en($),[$]),{step:G,windowPx:P}=d.useMemo(()=>en(_),[_]),L=d.useMemo(()=>tn($,T,k),[$,T,k]),N=d.useMemo(()=>tn(_,G,P),[_,G,P]),R=d.useCallback(X=>L(X-p),[L,p]),S=d.useCallback(X=>N(X-E),[N,E]),O=d.useMemo(()=>({cols:$,rows:_}),[$,_]),K=d.useMemo(()=>({width:b,height:I}),[b,I]),Q=d.useMemo(()=>({top:E,bottom:g,left:p,right:h}),[E,g,p,h]),ee=d.useMemo(()=>({width:y,height:D}),[y,D]),fe=d.useMemo(()=>({canvas:K,margin:Q,content:ee}),[K,Q,ee]),ce=d.useCallback(X=>{const{x:ke,y:Se,w:nt,h:rt}=X.layout,Ee=O.cols,Re=O.rows;if(!Ee.length||!Re.length)return{left:0,top:0,width:0,height:0};const Ae=Math.min(Math.max(0,ke),Ee.length-1),Lt=Math.min(Math.max(0,ke+nt),Ee.length-1),ot=Math.min(Math.max(0,Se),Re.length-1),At=Math.min(Math.max(0,Se+rt),Re.length-1),Ot=(Ee[Ae]??0)+p,Ve=(Re[ot]??0)+E,Oe=(Ee[Lt]??0)-(Ee[Ae]??0),vt=(Re[At]??0)-(Re[ot]??0);return{left:Ot,top:Ve,width:Oe,height:vt}},[O,p,E]);return{paperPx:fe,gridPosPx:O,getColIndex:R,getRowIndex:S,getBlockRectPx:ce}}const Or=({schema:e,values:t,pluginRegistry:n,onValueChange:o,scale:s=1,className:a})=>{const{paperPx:i,gridPosPx:l,getBlockRectPx:c}=pt(e.paper,e.grid,q),f=d.useCallback((m,v)=>{o&&o(m,v)},[o]);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:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(Mt,{paperPx:i,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(et,{blocks:e.blocks,pluginRegistry:n,mode:ve.EDIT,values:t,getBlockRectPx:c,onValueChange:f,showGuides:!0,showBorder:!0})]})};Or.displayName="NoteEdit";const Gr=d.memo(Or),Br=({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:o,scale:s=1,className:a})=>{const[i,l]=Lr(),c=d.useRef(null),{paperPx:f,gridPosPx:m,getBlockRectPx:v,getColIndex:x,getRowIndex:b}=pt(e.paper,e.grid,q),I=d.useCallback(j=>{if(n)switch(j.type){case be.MOVE:case be.RESIZE:{if(!j.blocks)return;const M=e.blocks.map($=>{var T;return((T=j.blocks)==null?void 0:T.find(k=>k.id===$.id))||$});n({...e,blocks:M});break}case be.ADD:{if(!j.blocks)return;n({...e,blocks:[...e.blocks,...j.blocks]});break}case be.DELETE:{const M=new Set(j.blockIds),$=e.blocks.filter(_=>!M.has(_.id));n({...e,blocks:$});break}case be.UPDATE:{if(!j.blocks)return;const M=e.blocks.map($=>{var G;const _=(G=j.blocks)==null?void 0:G.find(P=>P.id===$.id);if(!_)return $;const T=_.style?Dt(_.style):_.style,k=_.props?Dt(_.props):_.props;return{...$,..._,style:T,props:k}});n({...e,blocks:M});break}}},[e,n]),E=d.useCallback((j,M)=>{if(!n)return;const $=e.blocks.map(_=>_.id===j?{..._,initValue:M}:_);n({...e,blocks:$})},[e,n]);d.useEffect(()=>{o&&o(i.selectedBlockIds)},[i.selectedBlockIds,o]),d.useEffect(()=>{const j=ut.subscribe(M=>{var $;!M&&i.mode===Y.DRAGGING&&(($=i.dragging)==null?void 0:$.type)===ue.INSERT&&l({type:B.CANCEL_INSERT})});return()=>j()},[i.mode,i.dragging,l]),d.useEffect(()=>{const j=M=>{if(i.selectedBlockIds.length===0)return;const $=M.target;$ instanceof HTMLElement&&$.closest('[data-sidebar="true"]')||c.current&&!c.current.contains($)&&l({type:B.DESELECT})};return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[i.selectedBlockIds,l]);const g=d.useCallback((j,M,$)=>{if(!n)return;const _=M-1;if(j==="column"){const T=Qt(e.grid.cols,_,$,f.content.width);n({...e,grid:{...e.grid,cols:T}})}else{const T=Qt(e.grid.rows,_,$,f.content.height);n({...e,grid:{...e.grid,rows:T}})}},[e,f,n]),p=d.useCallback((j,M,$)=>{if(n)if(j==="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=d.useMemo(()=>e.blocks.reduce((j,M)=>(j[M.id]=M.initValue,j),{}),[e.blocks]),y=d.useCallback(()=>{const j=ut.get();j&&(i.mode===Y.DRAGGING||i.dragging||l({type:B.START_INSERT,pluginKind:j.kind,defaultSize:j.defaultSize}))},[i.mode,i.dragging,l]),D=d.useCallback(()=>{},[]);return r.jsxs("div",{ref:c,className:a,onPointerEnter:y,onPointerLeave:D,style:{position:"relative",width:`${f.canvas.width}px`,height:`${f.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:f,gridPosPxs:m,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:g,onDimensionChange:p,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:ye.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:ye.SOLID}}}),r.jsx(et,{blocks:e.blocks,pluginRegistry:t,mode:ve.FORM,values:h,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:v,onValueChange:E,showGuides:!0,showBorder:!0}),r.jsx(In,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:v,getColIndex:x,getRowIndex:b,state:i,onChange:l,onBlockChange:I,scale:s})]})};Br.displayName="NoteForm";const Fr=d.memo(Br),Vr=({schema:e,values:t,pluginRegistry:n,scale:o=1,className:s})=>{const{paperPx:a,gridPosPx:i,getBlockRectPx:l}=pt(e.paper,e.grid,q);return r.jsxs("div",{className:s,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:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(Mt,{paperPx:a,gridPosPxs:i,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(et,{blocks:e.blocks,pluginRegistry:n,mode:ve.VIEW,values:t,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};Vr.displayName="NoteView";const Ur=d.memo(Vr),Wr=({schema:e,values:t,mode:n,pluginRegistry:o,onSchemaChange:s,onValuesChange:a,onSelectionChange:i,scale:l=1,className:c})=>{const f=d.useCallback((m,v)=>{if(a)if(v==null){const{[m]:x,...b}=t;a(b)}else a({...t,[m]:v})},[t,a]);return n===ve.FORM?r.jsx(Fr,{schema:e,pluginRegistry:o,onSchemaChange:s,onSelectionChange:i,scale:l,className:c}):n===ve.EDIT?r.jsx(Gr,{schema:e,values:t,pluginRegistry:o,onValueChange:f,scale:l,className:c}):r.jsx(Ur,{schema:e,values:t,pluginRegistry:o,scale:l,className:c})};Wr.displayName="NoteEditor";const fi=d.memo(Wr),zr=({schema:e,values:t,pluginRegistry:n,className:o},s)=>{const a=d.useRef(null),{paperPx:i,getBlockRectPx:l}=pt(e.paper,e.grid,q);return d.useEffect(()=>{const{size:c}=e.paper,f=Z.fromDim(c.width),m=Z.fromDim(c.height),v=document.getElementById("printable-note-page-style");v&&v.remove();const x=document.createElement("style");return x.id="printable-note-page-style",x.textContent=`
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_7lg72_13",ss="_resizeHandle_7lg72_13",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`,g=t===i;return r.jsx("div",{className:Yn.resizeHandle,onPointerDown:b=>{b.stopPropagation(),e(b,i)},style:{position:"absolute",left:m,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:g?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:g?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:g?"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 g=e[a];if(!g)return null;let b;if(l&&o){const y=Ne(g,{x:0,y:0,w:i.w,h:i.h}),f=n(y);b={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)),_=Ne(g,{x:p,y:h,w:i.w,h:i.h});b=n(_)}const j=Ne(g,{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:`${b.left}px`,top:`${b.top}px`,width:`${b.width}px`,height:`${b.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:d},children:r.jsx(He,{id:j.id,plugin:g,props:j.props,value:j.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:b,blockZIndex:d})}),r.jsx(Le,{block:j,rect:b,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,_=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,_));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,g=i+n,b=Math.max(0,Math.min(x,s-d)),j=Math.max(0,Math.min(g,o-m)),y=b-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:g=J.block_handles})=>{const b=o.map(y=>e.find(f=>f.id===y)).filter(Boolean),j=zt(b,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 _={...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:_.id,plugin:p,props:_.props,value:_.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:h,blockZIndex:m,className:"ghost-content"})}),r.jsx(Le,{block:_,rect:h,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:g})]},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:g=J.block_handles})=>{const b=e.find(h=>h.id===o),j=t[(b==null?void 0:b.kind)??""];if(!b||!j)return null;const y=Yt({layout:b.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),f={...b,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:g})]},b.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 g=Bt(i,{zIndex:l,pointerEvents:"auto"}),b={width:i.width,height:i.height},j={id:e,props:n,value:s,onChange:o,onBlur:a,readOnly:!1,mode:ae.FORM,dimensions:{widthPx:b.width,heightPx:b.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:g,"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(g=>{const b=e.find(f=>f.id===g);if(!b)return null;const y=(s==null?void 0:s.type)===re.RESIZE&&s.blockIds.includes(g)?s==null?void 0:s.handle:null;return r.jsx(Le,{block:b,rect:o(b),showHandles:!0,onResizeStart:(f,p)=>a(f,p,g),activeHandle:y,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:d},b.id)})})});Xt.displayName="SelectionLayer";function Zn(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 Zt=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:g,editBlockZIndex:b=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 w;(w=h.current)==null||w.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const w=new Set(e.map(k=>k.id)),T=i.selectedBlockIds.filter(k=>w.has(k));T.length!==i.selectedBlockIds.length&&l({type:G.SELECT,blockIds:T,shiftKey:!1})},[e,i.selectedBlockIds,l]);const _=u.useCallback(w=>{var D;if(w.button!==0)return;const T=(D=p.current)==null?void 0:D.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(w.clientX-T.left)/k,y:(w.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){w.stopPropagation();const P=i.selectedBlockIds.includes(R);if(P&&w.shiftKey){const S=i.selectedBlockIds.filter(F=>F!==R);l({type:G.SELECT,blockIds:S,shiftKey:!0});return}else P?(w.currentTarget.setPointerCapture(w.pointerId),l({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(w.currentTarget.setPointerCapture(w.pointerId),w.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 w.stopPropagation(),l({type:G.DESELECT})},[e,s,o,a,i.mode,i.selectedBlockIds,l,d,i.editingBlockId]),I=u.useCallback(w=>{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=(w.clientX-T.left)/k,N=(w.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(w=>{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}),w.currentTarget.releasePointerCapture(w.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}),w.currentTarget.releasePointerCapture(w.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}=Zn({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}));w.currentTarget.releasePointerCapture(w.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),M=u.useCallback(w=>{var L;const T=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(w.clientX-T.left)/k,y:(w.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(w=>{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=(w.clientX-k.left)/O,L=(w.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:_,onPointerMove:I,onPointerUp:E,onPointerLeave:$,onDoubleClick:M,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const w=e.find(k=>k.id===i.editingBlockId),T=w?t[w.kind]:null;return!w||!T?null:r.jsx(Kn,{ref:h,id:w.id,plugin:T,props:w.props,value:w.initValue,onChange:k=>{c==null||c({type:ce.UPDATE,blockIds:[w.id],blocks:[{...w,initValue:k}]})},onBlur:k=>{c==null||c({type:ce.UPDATE,blockIds:[w.id],blocks:[{...w,initValue:k}]})},blockRectPx:s(w),zIndex:b})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(w,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}),w.currentTarget.setPointerCapture(w.pointerId);const R=d??1,L={x:(w.clientX-O.left)/R,y:(w.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:g,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})]})});Zt.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]),g=u.useMemo(()=>ot(t.rows,m),[t.rows,m]),b=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]),_=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(g,n),[g,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]),w=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(w),[w]),L=u.useMemo(()=>It($,T,k),[$,T,k]),N=u.useMemo(()=>It(w,O,R),[w,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:w}),[$,w]),F=u.useMemo(()=>({width:b,height:j}),[b,j]),K=u.useMemo(()=>({top:y,bottom:f,left:p,right:h}),[y,f,p,h]),X=u.useMemo(()=>({width:_,height:I}),[_,I]),v=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),C=u.useCallback(A=>{const{x:z,y:he,w:Oe,h:Z}=A.layout,ue=S.cols,be=S.rows;if(!ue.length||!be.length)return{left:0,top:0,width:0,height:0};const Ze=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),be.length-1),hr=Math.min(Math.max(0,he+Z),be.length-1),fr=(ue[Ze]??0)+p,pr=(be[an]??0)+y,xr=(ue[mr]??0)-(ue[Ze]??0),gr=(be[hr]??0)-(be[an]??0);return{left:fr,top:pr,width:xr,height:gr}},[S,p,y]);return{paperPx:v,gridPosPx:S,getColIndex:D,getRowIndex:P,getBlockRectPx:C}}const qn=({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})]})};qn.displayName="NoteEdit";const Jn=u.memo(qn),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:g,getRowIndex:b}=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(w=>!M.has(w.id));n({...e,blocks:$});break}case ce.UPDATE:{if(!E.blocks)return;const M=e.blocks.map($=>{var O;const w=(O=E.blocks)==null?void 0:O.find(R=>R.id===$.id);if(!w)return $;const T=w.style?it(w.style):w.style,k=w.props?it(w.props):w.props;return{...$,...w,style:T,props:k}});n({...e,blocks:M});break}}},[e,n]),y=u.useCallback((E,M)=>{if(!n)return;const $=e.blocks.map(w=>w.id===E?{...w,initValue:M}:w);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 w=M-1;if(E==="column"){const T=jt(e.grid.cols,w,$,d.content.width);n({...e,grid:{...e.grid,cols:T}})}else{const T=jt(e.grid.rows,w,$,d.content.height);n({...e,grid:{...e.grid,rows:T}})}},[e,d,n]),p=u.useCallback((E,M,$)=>{if(n)if(E==="column"){const w=[...e.grid.cols];w[M]=$,n({...e,grid:{...e.grid,cols:w}})}else{const w=[...e.grid.rows];w[M]=$,n({...e,grid:{...e.grid,rows:w}})}},[n,e]),h=u.useMemo(()=>e.blocks.reduce((E,M)=>(E[M.id]=M.initValue,E),{}),[e.blocks]),_=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:_,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(Zt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:x,getColIndex:g,getRowIndex:b,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]:g,...b}=t;a(b)}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 g=document.createElement("style");return g.id="printable-note-page-style",g.textContent=`
71
63
  @media print {
72
64
  @page {
73
- size: ${f}mm ${m}mm;
65
+ size: ${d}mm ${m}mm;
74
66
  margin: 0;
75
67
  }
76
68
  }
77
- `,document.head.appendChild(x),()=>{const b=document.getElementById("printable-note-page-style");b&&b.remove()}},[e.paper]),d.useImperativeHandle(s,()=>({print:()=>{a.current&&nn(a.current,{title:"Document"})},openPrintPreview:()=>{a.current&&nn(a.current,{title:"Document"})}}),[]),r.jsx("div",{ref:a,className:o,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(et,{blocks:e.blocks,pluginRegistry:n,mode:ve.VIEW,values:t??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};zr.displayName="NotePrint";const hi=d.memo(d.forwardRef(zr));function De(e,t){if(e.length===0)return;const n=(i,l)=>{let c=i;for(const f of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[f]}return c},o=t.split("."),s=n(e[0],o);return e.every(i=>n(i,o)===s)?s:void 0}const mi="_container_1nwxd_1",pi="_row_1nwxd_39",vi="_inputWrapper_1nwxd_73",qt={container:mi,row:pi,inputWrapper:vi},Yr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=o=>{const s={};e.forEach(a=>{s[a.id]={style:{...a.style,backgroundColor:o}}}),t(s)};return r.jsx("div",{className:qt.container,children:r.jsx("div",{className:qt.row,children:r.jsx("div",{className:qt.inputWrapper,children:r.jsx(dt,{value:De(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function Te(e,t,n){const o=t.split("."),s=(a,i)=>{const l=o[i];if(i===o.length-1){if(n==null){const{[l]:m,...v}=a;return v}return{...a,[l]:n}}const c=(a==null?void 0:a[l])||{},f=s(c,i+1);if(Object.keys(f).length===0){const{[l]:m,...v}=a;return v}return{...a,[l]:f}};return s(e,0)}const Hr=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,l,c)=>{const f={};e.forEach(m=>{var x,b,I;let v=Te(m.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(v=Te(v,`border.${i}.width`,void 0),v=Te(v,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const E=(x=m.style)==null?void 0:x.border,g=E==null?void 0:E[i];g!=null&&g.width||(v=Te(v,`border.${i}.width`,{value:1,unit:"px"})),g!=null&&g.color||(v=Te(v,`border.${i}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const E=(b=m.style)==null?void 0:b.border,g=E==null?void 0:E[i];g!=null&&g.type||(v=Te(v,`border.${i}.type`,ye.SOLID)),g!=null&&g.width||(v=Te(v,`border.${i}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const E=(I=m.style)==null?void 0:I.border,g=E==null?void 0:E[i];g!=null&&g.type||(v=Te(v,`border.${i}.type`,ye.SOLID)),g!=null&&g.color||(v=Te(v,`border.${i}.color`,"#000000"))}f[m.id]={style:v}}),t(f)},o=d.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=v=>v?!(v.type&&!v.width):!0;return["all","top","right","bottom","left"].every(v=>c(l[v]))?new Qe(l):null},[e]),s=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx($e,{value:De(e,`style.border.${i}.type`),onChange:l=>n(i,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:ye.SOLID},{label:"破線",value:ye.DASHED},{label:"点線",value:ye.DOTTED}]}),r.jsx(de,{value:De(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:or,min:1}),r.jsx(dt,{value:De(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"})]}),o?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(Fe,{width:80,height:80,border:o})}):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(hn,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(mn,{style:{width:"100%",display:"flex"},children:[r.jsx(Pe,{value:"all",height:24,style:a,children:"共通"}),r.jsx(Pe,{value:"top",height:24,style:a,children:"上"}),r.jsx(Pe,{value:"bottom",height:24,style:a,children:"下"}),r.jsx(Pe,{value:"left",height:24,style:a,children:"左"}),r.jsx(Pe,{value:"right",height:24,style:a,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Me,{value:"all",children:s("all")}),r.jsx(Me,{value:"top",children:s("top")}),r.jsx(Me,{value:"bottom",children:s("bottom")}),r.jsx(Me,{value:"left",children:s("left")}),r.jsx(Me,{value:"right",children:s("right")})]})]})})]})},gi="_container_2914u_1",xi="_grid_2914u_37",bi="_field_2914u_51",yi="_label_2914u_65",_i="_inputWrapper_2914u_85",xe={container:gi,grid:xi,field:bi,label:yi,inputWrapper:_i},Kr=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const o=e.length>1,s=o?Math.min(...e.map(l=>l.layout.x)):void 0,a=o?Math.min(...e.map(l=>l.layout.y)):void 0,i=(l,c)=>{if(c===void 0)return;const f={};if(o&&(l==="x"||l==="y")){const m=l==="x"?s:a;if(m===void 0)return;const v=Math.max(...e.map(p=>p.layout.x+p.layout.w)),x=Math.max(...e.map(p=>p.layout.y+p.layout.h)),b=v-(s??0),I=x-(a??0);let E=c;l==="x"&&n?E=Math.max(0,Math.min(c,n.cols-b)):l==="y"&&n?E=Math.max(0,Math.min(c,n.rows-I)):E=Math.max(0,c);const g=E-m;e.forEach(p=>{const h=p.layout[l]+g;f[p.id]={layout:{...p.layout,[l]:h}}})}else e.forEach(m=>{let v=c;if(l==="x"&&n)v=Math.max(0,Math.min(c,n.cols-m.layout.w));else if(l==="y"&&n)v=Math.max(0,Math.min(c,n.rows-m.layout.h));else if(l==="w"&&n){const x=n.cols-m.layout.x;v=Math.max(1,Math.min(c,x))}else if(l==="h"&&n){const x=n.rows-m.layout.y;v=Math.max(1,Math.min(c,x))}else l==="w"||l==="h"?v=Math.max(1,c):v=Math.max(0,c);f[m.id]={layout:{...m.layout,[l]:v}}});t(f)};return r.jsx("div",{className:xe.container,children:r.jsxs("div",{className:xe.grid,children:[r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"X"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:o?s:De(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:xe.field,children:[r.jsx("span",{className:xe.label,children:"Y"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:o?a:De(e,"layout.y"),onChange:l=>i("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"W"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:De(e,"layout.w"),onChange:l=>i("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"H"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:De(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},wi="_container_razoq_1",Ei="_row_razoq_19",ji="_label_razoq_31",Ni="_inputWrapper_razoq_49",ze={container:wi,row:Ei,label:ji,inputWrapper:Ni},Xr=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,o]=d.useState(""),s=e[0];d.useEffect(()=>{e.length===1&&s&&o(s.id)},[e,s]);const a=()=>{if(!s)return;const c=s.id,f=n.trim();if(f===c||!f){o(c);return}t({[c]:{id:f}})},i=c=>{o(c??"")},l=c=>{const f={};e.forEach(m=>{f[m.id]={behavior:{...m.behavior,readOnly:!!c}}}),t(f)};return r.jsxs("div",{className:ze.container,children:[e.length===1&&r.jsxs("div",{className:ze.row,children:[r.jsx("span",{className:ze.label,children:"ID"}),r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Je,{value:n,onChange:i,onBlur:a,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:ze.row,children:r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Ie,{label:"読み取り専用",value:!!De(e,"behavior.readOnly"),onChange:l})})})]})},Ii="_container_1axrl_1",Di="_scrollArea_1axrl_35",Ri="_section_1axrl_51",Ci="_sectionTitle_1axrl_69",$i="_subsection_1axrl_93",Ti="_subsectionTitle_1axrl_101",Pi="_fields_1axrl_117",Mi="_emptyState_1axrl_137",he={container:Ii,scrollArea:Di,section:Ri,sectionTitle:Ci,subsection:$i,subsectionTitle:Ti,fields:Pi,emptyState:Mi},ki="_field_1f6zx_1",Si="_label_1f6zx_13",Li="_mixed_1f6zx_29",Ai="_description_1f6zx_43",yt={field:ki,label:Si,mixed:Li,description:Ai},St=d.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:o})=>{var m;const s=t.Component;if(!s)return null;const a=De(n,`props.${e}`),c=!n.map(v=>v.props[e]).every(v=>v===void 0)&&a===void 0&&n.length>1,f={value:c?void 0:a!==void 0?a:t.defaultValue,onChange:v=>o(e,v),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(m=t.config)==null?void 0:m.placeholder}};return r.jsxs("div",{className:yt.field,children:[t.label&&r.jsx("div",{className:yt.label,title:t.description,children:t.label}),r.jsx(s,{...f}),c&&r.jsx("span",{className:yt.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:yt.description,children:t.description})]})});St.displayName="PropertyField";function Oi(e){return e!==!1}const Dn=d.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:o,className:s=""})=>{const a=e[0],i=a?t[a.kind]:void 0,l=d.useMemo(()=>{var v;if(e.length===0)return!1;const m=(v=e[0])==null?void 0:v.kind;return e.every(x=>x.kind===m)},[e]),c=d.useMemo(()=>{if(!a||!i)return{};const m={};let v;if(l)v=Object.entries(i.properties);else{const x=e.map(g=>t[g.kind]).filter(g=>g!==void 0);if(x.length===0)return{};const b=x[0];if(!b)return{};const I=new Set(Object.keys(b.properties));v=Array.from(I).filter(g=>x.every(p=>g in p.properties)).map(g=>{const p=i.properties[g];return p?[g,p]:null}).filter(g=>g!==null)}return v.forEach(([x,b])=>{if(!Oi(b)||e.length>1&&b.disableInMultiSelection||b.condition&&!b.condition(a.props))return;const I=b.group||"基本";m[I]||(m[I]=[]),b.Component&&m[I].push({key:x,definition:b})}),m},[i,t,e,a,l]),f=(m,v)=>{const x={};e.forEach(b=>{x[b.id]={props:{...b.props,[m]:v}}}),n(x)};return e.length===0?r.jsx("div",{className:`${he.container} ${s}`,children:r.jsxs("div",{className:he.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${he.container} ${s}`,children:r.jsxs("div",{className:he.scrollArea,children:[r.jsxs("div",{className:he.section,children:[r.jsx("div",{className:he.sectionTitle,children:"配置・サイズ"}),r.jsx(Kr,{selectedBlocks:e,onUpdateBlocks:n,gridSize:o})]}),r.jsxs("div",{className:he.section,children:[r.jsx("div",{className:he.sectionTitle,children:"背景"}),r.jsx(Yr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:he.section,children:[r.jsx("div",{className:he.sectionTitle,children:"枠線"}),r.jsx(Hr,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:he.section,children:Object.entries(c).map(([m,v])=>r.jsxs("div",{className:he.subsection,children:[r.jsx("div",{className:he.subsectionTitle,children:m}),r.jsx("div",{className:he.fields,children:v.map(({key:x,definition:b})=>r.jsx(St,{propertyKey:x,definition:b,selectedBlocks:e,onChange:f},x))})]},m))}),r.jsxs("div",{className:he.section,children:[r.jsx("div",{className:he.sectionTitle,children:"基本設定"}),r.jsx(Xr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});Dn.displayName="BlockPropertyPanel";const Gi="_panel_4e5h0_1",Bi="_header_4e5h0_21",Fi="_group_4e5h0_35",Vi="_groupTitle_4e5h0_51",Ui="_groupContent_4e5h0_71",at={panel:Gi,header:Bi,group:Fi,groupTitle:Vi,groupContent:Ui};function Wi(e){return e!==!1}const zi=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const o=e[0],s=o?t[o.kind]:void 0,a=d.useMemo(()=>{if(!o||!s)return{};const l={};return Object.entries(s.properties).forEach(([c,f])=>{if(!Wi(f)||e.length>1&&f.disableInMultiSelection||f.condition&&!f.condition(o.props))return;const m=f.group||"基本";l[m]||(l[m]=[]),f.Component&&l[m].push({key:c,definition:f})}),l},[s,e.length,o]),i=(l,c)=>{const f={};e.forEach(m=>{f[m.id]={props:{...m.props,[l]:c}}}),n(f)};return!o||!s||e.length===0?null:r.jsxs("div",{className:at.panel,children:[r.jsx("div",{className:at.header,children:e.length>1?`${e.length}個のブロック`:s.meta.displayName}),Object.entries(a).map(([l,c])=>r.jsxs("div",{className:at.group,children:[r.jsx("div",{className:at.groupTitle,children:l}),r.jsx("div",{className:at.groupContent,children:c.map(({key:f,definition:m})=>r.jsx(St,{propertyKey:f,definition:m,selectedBlocks:e,onChange:i},f))})]},l))]})},Yi="_panel_1p81n_11",Hi="_title_1p81n_19",Ki="_content_1p81n_43",Xi="_description_1p81n_57",qi="_list_1p81n_69",Zi="_item_1p81n_87",Ji="_dragging_1p81n_121",Qi="_dragOver_1p81n_131",ea="_dragHandle_1p81n_141",ta="_itemInfo_1p81n_171",na="_itemId_1p81n_185",ra="_itemMeta_1p81n_195",oa="_itemKind_1p81n_209",sa="_itemActions_1p81n_225",ia="_actionButton_1p81n_235",aa="_empty_1p81n_307",se={panel:Yi,title:Hi,content:Ki,description:Xi,list:qi,item:Zi,dragging:Ji,dragOver:Qi,dragHandle:ea,itemInfo:ta,itemId:na,itemMeta:ra,itemKind:oa,itemActions:sa,actionButton:ia,empty:aa},Rn=({blocks:e,onBlocksChange:t})=>{const[n,o]=d.useState(null),[s,a]=d.useState(null),i=[...e].reverse(),l=d.useCallback(g=>{const p=e.findIndex(D=>D.id===g);if(p===-1||p===e.length-1)return;const h=[...e],[y]=h.splice(p,1);y&&(h.push(y),t(h))},[e,t]),c=d.useCallback(g=>{const p=e.findIndex(D=>D.id===g);if(p===-1||p===0)return;const h=[...e],[y]=h.splice(p,1);y&&(h.unshift(y),t(h))},[e,t]),f=d.useCallback(g=>{const p=e.findIndex(j=>j.id===g);if(p===-1||p===e.length-1)return;const h=[...e],y=h[p],D=h[p+1];!y||!D||(h[p]=D,h[p+1]=y,t(h))},[e,t]),m=d.useCallback(g=>{const p=e.findIndex(j=>j.id===g);if(p===-1||p===0)return;const h=[...e],y=h[p],D=h[p-1];!y||!D||(h[p]=D,h[p-1]=y,t(h))},[e,t]),v=d.useCallback((g,p)=>{var y;o(p),g.dataTransfer.effectAllowed="move";const h=e.length-1-p;g.currentTarget&&g.dataTransfer.setData("text/plain",((y=e[h])==null?void 0:y.id)||"")},[e]),x=d.useCallback(()=>{o(null),a(null)},[]),b=d.useCallback((g,p)=>{g.preventDefault(),g.dataTransfer.dropEffect="move",!(n===null||n===p)&&a(p)},[n]),I=d.useCallback(()=>{a(null)},[]),E=d.useCallback((g,p)=>{if(g.preventDefault(),n===null||n===p){o(null),a(null);return}const h=e.length-1-n,y=e.length-1-p,D=[...e],[j]=D.splice(h,1);j&&(D.splice(y,0,j),t(D),o(null),a(null))},[e,n,t]);return r.jsxs("div",{className:se.panel,children:[r.jsx("h3",{className:se.title,children:"ブロック順序"}),r.jsxs("div",{className:se.content,children:[r.jsx("p",{className:se.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:se.list,children:i.map((g,p)=>{const h=e.length-1-p;return r.jsxs("li",{className:`${se.item} ${n===p?se.dragging:""} ${s===p?se.dragOver:""}`,onDragOver:y=>b(y,p),onDragLeave:I,onDrop:y=>E(y,p),children:[r.jsx("button",{type:"button",className:se.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:y=>v(y,p),onDragEnd:x,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:se.itemInfo,children:[r.jsx("div",{className:se.itemId,children:g.id}),r.jsx("div",{className:se.itemMeta,children:r.jsx("span",{className:se.itemKind,children:g.kind})})]}),r.jsxs("div",{className:se.itemActions,children:[r.jsx("button",{type:"button",className:se.actionButton,onClick:()=>l(g.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:se.actionButton,onClick:()=>f(g.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:se.actionButton,onClick:()=>m(g.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:se.actionButton,onClick:()=>c(g.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"})]})})]})]},g.id)})}),e.length===0&&r.jsx("div",{className:se.empty,children:"ブロックがありません"})]})]})};Rn.displayName="BlockOrderPanel";const Cn=({schema:e,onSchemaChange:t})=>{const n=d.useCallback(a=>{t({...e,paper:a})},[e,t]),o=d.useCallback(a=>{t({...e,grid:a})},[e,t]),s=d.useCallback(a=>{t({...e,blocks:a})},[e,t]);return r.jsxs(fn,{children:[r.jsx(Pn,{paper:e.paper,onPaperChange:n}),r.jsx(Tn,{paper:e.paper,onPaperChange:n}),r.jsx($n,{grid:e.grid,onGridChange:o}),r.jsx(Rn,{blocks:e.blocks,onBlocksChange:s})]})};Cn.displayName="CanvasPanel";const la="_panel_98kh0_11",ca="_title_98kh0_19",ua="_content_98kh0_43",da="_field_98kh0_57",fa="_horizontal_98kh0_69",ha="_label_98kh0_81",ma="_gridSizeRow_98kh0_103",Ce={panel:la,title:ca,content:ua,field:da,horizontal:fa,label:ha,gridSizeRow:ma},$n=({grid:e,onGridChange:t})=>{const n=d.useCallback(s=>{if(!s||s<1||s>100)return;const a=e.cols.length,i=[];if(s>a){i.push(...e.cols);for(let l=a;l<s;l++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,s));t({...e,cols:i})},[e,t]),o=d.useCallback(s=>{if(!s||s<1||s>100)return;const a=e.rows.length,i=[];if(s>a){i.push(...e.rows);for(let l=a;l<s;l++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,s));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:Ce.panel,children:[r.jsx("h3",{className:Ce.title,children:"グリッドサイズ"}),r.jsx("div",{className:Ce.content,children:r.jsxs("div",{className:Ce.gridSizeRow,children:[r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"列数"}),r.jsx(pe,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"行数"}),r.jsx(pe,{value:e.rows.length,onChange:o,min:1,max:100,step:1})]})]})})]})};$n.displayName="GridSizePanel";const pa="_panel_7447e_11",va="_header_7447e_19",ga="_title_7447e_39",xa="_headerActions_7447e_57",ba="_content_7447e_65",ya="_field_7447e_73",_a="_horizontal_7447e_85",wa="_label_7447e_97",Ea="_marginsGrid_7447e_119",ja="_topMargin_7447e_131",Na="_bottomMargin_7447e_133",Ia="_sideMargins_7447e_145",re={panel:pa,header:va,title:ga,headerActions:xa,content:ba,field:ya,horizontal:_a,label:wa,marginsGrid:Ea,topMargin:ja,bottomMargin:Na,sideMargins:Ia},Tn=({paper:e,onPaperChange:t})=>{const[n,o]=d.useState(!1),s=d.useCallback(f=>{f!==void 0&&o(f)},[]),a=d.useCallback(f=>{if(!f)return;const m=n?{top:f,right:f,bottom:f,left:f}:{...e.margin,top:f};t({...e,margin:m})},[e,t,n]),i=d.useCallback(f=>{f&&t({...e,margin:{...e.margin,right:f}})},[e,t]),l=d.useCallback(f=>{f&&t({...e,margin:{...e.margin,bottom:f}})},[e,t]),c=d.useCallback(f=>{f&&t({...e,margin:{...e.margin,left:f}})},[e,t]);return r.jsxs("div",{className:re.panel,children:[r.jsxs("div",{className:re.header,children:[r.jsx("h3",{className:re.title,children:"マージン"}),r.jsx("div",{className:re.headerActions,children:r.jsx(Ie,{value:n,onChange:s,label:"全辺を一括設定"})})]}),r.jsx("div",{className:re.content,children:n?r.jsxs("div",{className:`${re.field} ${re.horizontal}`,children:[r.jsx("span",{className:re.label,children:"全辺"}),r.jsx(de,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:re.marginsGrid,children:[r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.topMargin}`,children:r.jsx(de,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:re.sideMargins,children:[r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(de,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(de,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.bottomMargin}`,children:r.jsx(de,{value:e.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};Tn.displayName="MarginPanel";const Da="_panel_18o68_11",Ra="_title_18o68_19",Ca="_content_18o68_43",$a="_field_18o68_57",Ta="_horizontal_18o68_69",Pa="_label_18o68_81",Ma="_dimensionsRow_18o68_103",je={panel:Da,title:Ra,content:Ca,field:$a,horizontal:Ta,label:Pa,dimensionsRow:Ma},Pn=({paper:e,onPaperChange:t})=>{const n=d.useMemo(()=>[{value:Ne.A4,label:"A4 (210 × 297 mm)"},{value:Ne.A3,label:"A3 (297 × 420 mm)"},{value:Ne.B5,label:"B5 (182 × 257 mm)"},{value:Ne.LETTER,label:"Letter (8.5 × 11 inch)"},{value:Ne.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:Ne.CUSTOM,label:"カスタム"}],[]),o=d.useCallback(l=>{if(!l)return;const c=pn[l];t({...e,size:c})},[e,t]),s=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,width:l};t({...e,size:c})},[e,t]),a=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,height:l};t({...e,size:c})},[e,t]),i=e.size.preset===Ne.CUSTOM;return r.jsxs("div",{className:je.panel,children:[r.jsx("h3",{className:je.title,children:"用紙サイズ"}),r.jsxs("div",{className:je.content,children:[r.jsx("div",{className:je.field,children:r.jsx($e,{value:e.size.preset,options:n,onChange:o})}),i&&r.jsxs("div",{className:je.dimensionsRow,children:[r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"幅"}),r.jsx(de,{value:e.size.width,onChange:s,allowedUnits:["mm","cm","inch"],min:e.margin.left.value+e.margin.right.value+1,max:500})]}),r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"高さ"}),r.jsx(de,{value:e.size.height,onChange:a,allowedUnits:["mm","cm","inch"],min:e.margin.top.value+e.margin.bottom.value+1,max:500})]})]})]})]})};Pn.displayName="PaperSizePanel";const ka="_section_1o2ff_11",Sa="_title_1o2ff_27",La="_content_1o2ff_51",Aa="_buttonGroup_1o2ff_65",Oa="_button_1o2ff_65",Ga="_error_1o2ff_129",ie={section:ka,title:Sa,content:La,buttonGroup:Aa,button:Oa,error:Ga},Mn=({schema:e,values:t,onSchemaChange:n,onValuesChange:o})=>{const[s,a]=d.useState(""),i=d.useRef(null),l=d.useRef(null),c=d.useCallback(()=>{try{const h=on(e,!0),y=new Blob([h],{type:"application/json"}),D=URL.createObjectURL(y),j=document.createElement("a");j.href=D,j.download="schema.json",j.click(),URL.revokeObjectURL(D),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),f=d.useCallback(async()=>{try{const h=on(e,!0);await navigator.clipboard.writeText(h),a(""),alert("スキーマをクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),m=d.useCallback(()=>{var h;(h=i.current)==null||h.click()},[]),v=d.useCallback(h=>{var j;const y=(j=h.target.files)==null?void 0:j[0];if(!y)return;const D=new FileReader;D.onload=M=>{var $;try{const _=($=M.target)==null?void 0:$.result,T=rn(_);n(T),a(""),alert("スキーマをインポートしました")}catch(_){a(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},D.readAsText(y),h.target.value=""},[n]),x=d.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),y=rn(h);n(y),a(""),alert("スキーマをインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),b=d.useCallback(()=>{try{const h=an(t,!0),y=new Blob([h],{type:"application/json"}),D=URL.createObjectURL(y),j=document.createElement("a");j.href=D,j.download="values.json",j.click(),URL.revokeObjectURL(D),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),I=d.useCallback(async()=>{try{const h=an(t,!0);await navigator.clipboard.writeText(h),a(""),alert("値をクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),E=d.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),g=d.useCallback(h=>{var j;const y=(j=h.target.files)==null?void 0:j[0];if(!y)return;const D=new FileReader;D.onload=M=>{var $;try{const _=($=M.target)==null?void 0:$.result,T=sn(_);o(T),a(""),alert("値をインポートしました")}catch(_){a(`インポートエラー: ${_ instanceof Error?_.message:String(_)}`)}},D.readAsText(y),h.target.value=""},[o]),p=d.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),y=sn(h);o(y),a(""),alert("値をインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ie.section,children:[r.jsx("h3",{className:ie.title,children:"スキーマ"}),r.jsxs("div",{className:ie.content,children:[r.jsxs("div",{className:ie.buttonGroup,children:[r.jsx("button",{type:"button",className:ie.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ie.button,onClick:f,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ie.buttonGroup,children:[r.jsx("button",{type:"button",className:ie.button,onClick:m,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ie.button,onClick:x,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:v})]})]}),r.jsxs("div",{className:ie.section,children:[r.jsx("h3",{className:ie.title,children:"値"}),r.jsxs("div",{className:ie.content,children:[r.jsxs("div",{className:ie.buttonGroup,children:[r.jsx("button",{type:"button",className:ie.button,onClick:b,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ie.button,onClick:I,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ie.buttonGroup,children:[r.jsx("button",{type:"button",className:ie.button,onClick:E,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ie.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:g})]})]}),s&&r.jsx("div",{className:ie.error,role:"alert",children:s})]})};Mn.displayName="ImportExportPanel";const kn=({schema:e,values:t,onSchemaChange:n,onValuesChange:o})=>r.jsx(fn,{children:r.jsx(Mn,{schema:e,values:t,onSchemaChange:n,onValuesChange:o})});kn.displayName="OtherPanel";const Ba="_container_11zea_5",Fa="_paletteItems_11zea_63",Va="_item_11zea_87",Ua="_itemName_11zea_139",Wa="_itemPreview_11zea_195",ct={container:Ba,paletteItems:Fa,item:Va,itemName:Ua,itemPreview:Wa},Sn=({plugins:e,className:t})=>{const[n,o]=d.useState(null),s=d.useCallback((a,i)=>{o({plugin:a,mousePos:i,isOverCanvas:!1});const l=f=>{const m=document.elementFromPoint(f.clientX,f.clientY),v=!!(m!=null&&m.closest('[data-testid="interaction-layer"]'));o(x=>x?{...x,mousePos:{x:f.clientX,y:f.clientY},isOverCanvas:v}:null)},c=()=>{o(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:`${ct.container} ${t||""}`,children:r.jsx("div",{className:ct.paletteItems,children:e.map(a=>r.jsx(qr,{plugin:a,onDragStart:s},a.kind))})}),n&&!n.isOverCanvas&&r.jsx(Zr,{plugin:n.plugin,mousePos:n.mousePos})]})};Sn.displayName="PalettePanel";const qr=({plugin:e,onDragStart:t})=>{const n=d.useMemo(()=>Be(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),o=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),s=d.useCallback(a=>{a.preventDefault(),ut.start(e.kind,e.meta.defaultSize),t(e,{x:a.clientX,y:a.clientY});const i=()=>{ut.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("div",{className:ct.item,children:[r.jsx("button",{type:"button",onPointerDown:s,className:ct.itemName,"aria-label":`${e.meta.displayName}ブロックを追加`,children:e.meta.displayName}),r.jsx("div",{className:ct.itemPreview,onPointerDown:s,"aria-hidden":"true",children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:ve.FORM})})]})};qr.displayName="PaletteItem";const Zr=({plugin:e,mousePos:t})=>{const n=d.useMemo(()=>Be(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),o=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),s={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-s.width/2}px`,top:`${t.y-s.height/2}px`,width:`${s.width}px`,height:`${s.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:o,onChange:()=>{},readOnly:!0,mode:ve.FORM})})};Zr.displayName="DragGhost";const za="_container_k3psy_5",Ya="_tabHeader_k3psy_27",Ha="_tabContent_k3psy_41",lt={container:za,tabHeader:Ya,tabContent:Ha},Jr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:o,schema:s,values:a,onSchemaChange:i,onValuesChange:l,gridSize:c,className:f})=>{const m=d.useMemo(()=>Object.values(n),[n]),v=d.useMemo(()=>e.filter(b=>t.includes(b.id)),[e,t]),x=t.length>0;return r.jsx("div",{className:`${lt.container} ${f||""}`,"data-sidebar":"true",children:r.jsxs(hn,{defaultValue:"block",variant:"default",children:[r.jsxs(mn,{className:lt.tabHeader,children:[r.jsx(Pe,{value:"block",children:"ブロック"}),r.jsx(Pe,{value:"canvas",children:"キャンバス"}),r.jsx(Pe,{value:"other",children:"その他"})]}),r.jsx(Me,{value:"block",className:lt.tabContent,children:x?r.jsx(Dn,{selectedBlocks:v,pluginRegistry:n,onUpdateBlocks:o,gridSize:c}):r.jsx(Sn,{plugins:m})}),r.jsx(Me,{value:"canvas",className:lt.tabContent,children:r.jsx(Cn,{schema:s,onSchemaChange:i})}),r.jsx(Me,{value:"other",className:lt.tabContent,children:r.jsx(kn,{schema:s,values:a,onSchemaChange:i,onValuesChange:l})})]})})};Jr.displayName="Sidebar";exports.ACTUAL_UNITS=cs;exports.ALL_UNITS=ls;exports.BLOCK_SUB_INDEX=_e;exports.BORDER_UNITS=or;exports.BackgroundPanel=Yr;exports.BlockBorder=vr;exports.BlockCanvas=gr;exports.BlockChangeType=be;exports.BlockContainer=gn;exports.BlockGuideBorder=br;exports.BlockLayer=et;exports.BlockOrderPanel=Rn;exports.BlockPropertyPanel=Dn;exports.BlockRenderer=ht;exports.Border=Qe;exports.BorderOverlay=yr;exports.BorderPanel=Hr;exports.BorderRenderer=Fe;exports.COLOR_PALETTE=rr;exports.CanvasPanel=Cn;exports.Checkbox=Ie;exports.ColorPalette=cn;exports.ColorPicker=dt;exports.ColorPickerPopover=dn;exports.DEFAULT_DPI=q;exports.DEFAULT_FONT_FAMILY=ar;exports.DEFAULT_GRID=ur;exports.DEFAULT_GUIDE_BORDER=Pt;exports.DEFAULT_GUIDE_LINE=xr;exports.DEFAULT_PAPER=hr;exports.DEFAULT_PAPER_MARGIN=fr;exports.DEFAULT_PAPER_SIZES=pn;exports.DEFAULT_SCHEMA=js;exports.DimensionInput=de;exports.DragLayer=jn;exports.DragType=ue;exports.EditingBlock=Sr;exports.FONT_UNITS=sr;exports.GRID_UNITS=ds;exports.GridCanvas=_r;exports.GridDimensionLabel=wt;exports.GridLayer=Mt;exports.GridOverlay=Nr;exports.GridResizeHandle=Et;exports.GridSizePanel=$n;exports.HorizontalAlign=He;exports.ImageObjectFit=Le;exports.ImportExportPanel=Mn;exports.InsertGhost=bn;exports.InteractionBlock=tt;exports.InteractionEventType=B;exports.InteractionLayer=In;exports.InteractionMode=Y;exports.LayoutPanel=Kr;exports.LineType=ye;exports.MarginOverlay=Ir;exports.MarginPanel=Tn;exports.MetaPanel=Xr;exports.MovingGhost=_n;exports.MultilineWhiteSpace=qe;exports.MultilineWordWrap=Xe;exports.NoteEdit=Gr;exports.NoteEditor=fi;exports.NoteForm=Fr;exports.NoteMode=ve;exports.NotePrint=hi;exports.NoteView=Ur;exports.NumberInput=pe;exports.OtherPanel=kn;exports.PADDING_UNITS=Ye;exports.PAPER_UNITS=us;exports.PalettePanel=Sn;exports.PaperSizePanel=Pn;exports.PaperSizePreset=Ne;exports.PluginPanels=zi;exports.PropertyField=St;exports.RESIZE_HANDLE_STYLE=kt;exports.RGBAInputs=un;exports.ResizeGhost=En;exports.ResizeHandle=J;exports.ResizeHandles=xn;exports.SELECTION_STYLE=mt;exports.SIZE_UNITS=Jt;exports.Select=$e;exports.SelectionBorder=kr;exports.SelectionLayer=Nn;exports.Sidebar=Jr;exports.TabPanel=fn;exports.Tabs=hn;exports.TabsContent=Me;exports.TabsList=mn;exports.TabsTrigger=Pe;exports.TextInput=Je;exports.ValidationSeverity=mr;exports.VerticalAlign=Ke;exports.Z_INDEX=V;exports.alignmentDefinition=tr;exports.assertFinite=ys;exports.assertInteger=Tt;exports.assertNonNegative=le;exports.assertPositive=$t;exports.assertRange=dr;exports.binarySearch=_t;exports.calculateGridResize=Qt;exports.calculateResizedLayout=wn;exports.clampBlockToGrid=Ar;exports.clampMultipleBlocks=yn;exports.cleanupPrint=Cr;exports.createBlock=Be;exports.createBlockId=cr;exports.createInitialProps=lr;exports.createPluginRegistry=ms;exports.deserializeSchema=rn;exports.deserializeValues=sn;exports.dimensionToString=Er;exports.dimensionsToStrings=Gs;exports.distributeRemainder=Dr;exports.executePrint=ti;exports.findBlockAtPoint=ln;exports.findGridIndex=tn;exports.fontStyleDefinition=hs;exports.getBlockContainerStyle=vn;exports.getBlockZIndex=pr;exports.getCommonValue=De;exports.getMaxBlockCount=Ns;exports.getMaxStep=en;exports.getPaperSize=ei;exports.getStrokeDasharray=Ze;exports.getSubZIndex=ft;exports.globalDragStore=ut;exports.gridToMms=Nt;exports.gridToPxs=Qs;exports.imageDefinition=ps;exports.interactionZIndexs=oe;exports.isValidHex=Ho;exports.mmsToPxs=It;exports.multilineDefinition=vs;exports.paddingDefinition=ir;exports.parseColor=Zt;exports.placeholderDefinition=gs;exports.preparePrint=Rr;exports.printElement=nn;exports.removeUndefinedProps=Dt;exports.serializeSchema=on;exports.serializeValues=an;exports.sizeDefinition=xs;exports.stringToDimension=wr;exports.stringsToDimensions=ks;exports.toHex=nr;exports.toMm=Z;exports.toPx=W;exports.toRgbaString=Yo;exports.universalProperties=fs;exports.useGridCalc=pt;exports.useInteractionState=Lr;exports.validateSchema=$r;exports.validateValues=Pr;exports.validationDefinition=bs;
69
+ `,document.head.appendChild(g),()=>{const b=document.getElementById("printable-note-page-style");b&&b.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 ge(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_1nwxd_1",ms="_row_1nwxd_39",hs="_inputWrapper_1nwxd_73",wt={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:wt.container,children:r.jsx("div",{className:wt.row,children:r.jsx("div",{className:wt.inputWrapper,children:r.jsx(We,{value:ge(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function we(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 g,b,j;let x=we(m.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(x=we(x,`border.${i}.width`,void 0),x=we(x,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(g=m.style)==null?void 0:g.border,f=y==null?void 0:y[i];f!=null&&f.width||(x=we(x,`border.${i}.width`,{value:1,unit:"px"})),f!=null&&f.color||(x=we(x,`border.${i}.color`,"#000000"))}if(l==="color"&&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.type||(x=we(x,`border.${i}.type`,de.SOLID)),f!=null&&f.width||(x=we(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=we(x,`border.${i}.type`,de.SOLID)),f!=null&&f.color||(x=we(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(_e,{value:ge(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:ge(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:gn,min:1}),r.jsx(We,{value:ge(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_2914u_1",ps="_grid_2914u_37",xs="_field_2914u_51",gs="_label_2914u_65",bs="_inputWrapper_2914u_85",le={container:fs,grid:ps,field:xs,label:gs,inputWrapper:bs},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)),g=Math.max(...e.map(p=>p.layout.y+p.layout.h)),b=x-(o??0),j=g-(a??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-b)):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 g=n.cols-m.layout.x;x=Math.max(1,Math.min(c,g))}else if(l==="h"&&n){const g=n.rows-m.layout.y;x=Math.max(1,Math.min(c,g))}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:ge(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:ge(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:ge(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:ge(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},vs="_container_razoq_1",_s="_row_razoq_19",ws="_label_razoq_31",ys="_inputWrapper_razoq_49",De={container:vs,row:_s,label:ws,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:!!ge(e,"behavior.readOnly"),onChange:l})})})]})},Es="_container_1axrl_1",js="_scrollArea_1axrl_35",Ns="_section_1axrl_51",Is="_sectionTitle_1axrl_69",Ds="_subsection_1axrl_93",$s="_subsectionTitle_1axrl_101",Ts="_fields_1axrl_117",Cs="_emptyState_1axrl_137",se={container:Es,scrollArea:js,section:Ns,sectionTitle:Is,subsection:Ds,subsectionTitle:$s,fields:Ts,emptyState:Cs},Rs="_field_1f6zx_1",Ms="_label_1f6zx_13",ks="_mixed_1f6zx_29",Ps="_description_1f6zx_43",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=ge(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 qt=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(g=>g.kind===m)},[e]),c=u.useMemo(()=>{if(!a||!i)return{};const m={};let x;if(l)x=Object.entries(i.properties);else{const g=e.map(f=>t[f.kind]).filter(f=>f!==void 0);if(g.length===0)return{};const b=g[0];if(!b)return{};const j=new Set(Object.keys(b.properties));x=Array.from(j).filter(f=>g.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(([g,b])=>{if(!As(b)||e.length>1&&b.disableInMultiSelection||b.condition&&!b.condition(a.props))return;const j=b.group||"基本";m[j]||(m[j]=[]),b.Component&&m[j].push({key:g,definition:b})}),m},[i,t,e,a,l]),d=(m,x)=>{const g={};e.forEach(b=>{g[b.id]={props:{...b.props,[m]:x}}}),n(g)};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:g,definition:b})=>r.jsx(ft,{propertyKey:g,definition:b,selectedBlocks:e,onChange:d},g))})]},m))}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"基本設定"}),r.jsx(lr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});qt.displayName="BlockPropertyPanel";const Ss="_panel_4e5h0_1",Ls="_header_4e5h0_21",Os="_group_4e5h0_35",Gs="_groupTitle_4e5h0_51",Bs="_groupContent_4e5h0_71",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_1p81n_11",zs="_title_1p81n_19",Ws="_content_1p81n_43",Ys="_description_1p81n_57",Hs="_list_1p81n_69",Ks="_item_1p81n_87",Xs="_dragging_1p81n_121",Zs="_dragOver_1p81n_131",qs="_dragHandle_1p81n_141",Js="_itemInfo_1p81n_171",Qs="_itemId_1p81n_185",ei="_itemMeta_1p81n_195",ti="_itemKind_1p81n_209",ni="_itemActions_1p81n_225",ri="_actionButton_1p81n_235",oi="_empty_1p81n_307",Q={panel:Fs,title:zs,content:Ws,description:Ys,list:Hs,item:Ks,dragging:Xs,dragOver:Zs,dragHandle:qs,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],[_]=h.splice(p,1);_&&(h.push(_),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],[_]=h.splice(p,1);_&&(h.unshift(_),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],_=h[p],I=h[p+1];!_||!I||(h[p]=I,h[p+1]=_,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],_=h[p],I=h[p-1];!_||!I||(h[p]=I,h[p-1]=_,t(h))},[e,t]),x=u.useCallback((f,p)=>{var _;s(p),f.dataTransfer.effectAllowed="move";const h=e.length-1-p;f.currentTarget&&f.dataTransfer.setData("text/plain",((_=e[h])==null?void 0:_.id)||"")},[e]),g=u.useCallback(()=>{s(null),a(null)},[]),b=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,_=e.length-1-p,I=[...e],[E]=I.splice(h,1);E&&(I.splice(_,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:_=>b(_,p),onDragLeave:j,onDrop:_=>y(_,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:_=>x(_,p),onDragEnd:g,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_98kh0_11",ii="_title_98kh0_19",ai="_content_98kh0_43",li="_field_98kh0_57",ci="_horizontal_98kh0_69",ui="_label_98kh0_81",di="_gridSizeRow_98kh0_103",ve={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:ve.panel,children:[r.jsx("h3",{className:ve.title,children:"グリッドサイズ"}),r.jsx("div",{className:ve.content,children:r.jsxs("div",{className:ve.gridSizeRow,children:[r.jsxs("div",{className:`${ve.field} ${ve.horizontal}`,children:[r.jsx("span",{className:ve.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ve.field} ${ve.horizontal}`,children:[r.jsx("span",{className:ve.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const mi="_panel_7447e_11",hi="_header_7447e_19",fi="_title_7447e_39",pi="_headerActions_7447e_57",xi="_content_7447e_65",gi="_field_7447e_73",bi="_horizontal_7447e_85",vi="_label_7447e_97",_i="_marginsGrid_7447e_119",wi="_topMargin_7447e_131",yi="_bottomMargin_7447e_133",Ei="_sideMargins_7447e_145",q={panel:mi,header:hi,title:fi,headerActions:pi,content:xi,field:gi,horizontal:bi,label:vi,marginsGrid:_i,topMargin:wi,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:q.panel,children:[r.jsxs("div",{className:q.header,children:[r.jsx("h3",{className:q.title,children:"マージン"}),r.jsx("div",{className:q.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:q.content,children:n?r.jsxs("div",{className:`${q.field} ${q.horizontal}`,children:[r.jsx("span",{className:q.label,children:"全辺"}),r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:q.marginsGrid,children:[r.jsx("div",{className:`${q.field} ${q.horizontal} ${q.topMargin}`,children:r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:q.sideMargins,children:[r.jsx("div",{className:`${q.field} ${q.horizontal}`,children:r.jsx(oe,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${q.field} ${q.horizontal}`,children:r.jsx(oe,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${q.field} ${q.horizontal} ${q.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_18o68_11",Ni="_title_18o68_19",Ii="_content_18o68_43",Di="_field_18o68_57",$i="_horizontal_18o68_69",Ti="_label_18o68_81",Ci="_dimensionsRow_18o68_103",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(_e,{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_1o2ff_11",Mi="_title_1o2ff_27",ki="_content_1o2ff_51",Pi="_buttonGroup_1o2ff_65",Ai="_button_1o2ff_65",Si="_error_1o2ff_129",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),_=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(_),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 _=(E=h.target.files)==null?void 0:E[0];if(!_)return;const I=new FileReader;I.onload=M=>{var $;try{const w=($=M.target)==null?void 0:$.result,T=$t(w);n(T),a(""),alert("スキーマをインポートしました")}catch(w){a(`インポートエラー: ${w instanceof Error?w.message:String(w)}`)}},I.readAsText(_),h.target.value=""},[n]),g=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),_=$t(h);n(_),a(""),alert("スキーマをインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),b=u.useCallback(()=>{try{const h=Rt(t,!0),_=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(_),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 _=(E=h.target.files)==null?void 0:E[0];if(!_)return;const I=new FileReader;I.onload=M=>{var $;try{const w=($=M.target)==null?void 0:$.result,T=Ct(w);s(T),a(""),alert("値をインポートしました")}catch(w){a(`インポートエラー: ${w instanceof Error?w.message:String(w)}`)}},I.readAsText(_),h.target.value=""},[s]),p=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),_=Ct(h);s(_),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:g,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:b,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_11zea_5",Oi="_paletteItems_11zea_63",Gi="_item_11zea_87",Bi="_itemName_11zea_139",Vi="_itemPreview_11zea_195",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(g=>g?{...g,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_k3psy_5",Fi="_tabHeader_k3psy_27",zi="_tabContent_k3psy_41",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(b=>t.includes(b.id)),[e,t]),g=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:g?r.jsx(qt,{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=gn;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=qt;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=_n;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=wo;exports.DimensionInput=oe;exports.DragLayer=Kt;exports.DragType=re;exports.EditingBlock=Kn;exports.FONT_UNITS=bn;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=Zt;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=_e;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=go;exports.assertInteger=ut;exports.assertNonNegative=ne;exports.assertPositive=ct;exports.assertRange=jn;exports.binarySearch=et;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=Un;exports.createBlock=Ne;exports.createBlockId=yn;exports.createInitialProps=wn;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=ge;exports.getMaxBlockCount=yo;exports.getMaxStep=Nt;exports.getPaperSize=qo;exports.getStrokeDasharray=ke;exports.getSubZIndex=Ye;exports.globalDragStore=ze;exports.gridToMms=ot;exports.gridToPxs=Zo;exports.imageDefinition=mo;exports.interactionZIndexs=J;exports.isValidHex=Fr;exports.mmsToPxs=st;exports.multilineDefinition=ho;exports.paddingDefinition=vn;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;
78
70
  //# sourceMappingURL=index.js.map