motion-surveyjs-ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +738 -699
- package/dist/index.js.map +1 -1
- package/dist/lib/MotionSurvey.d.ts.map +1 -1
- package/dist/lib/ui/Logo.d.ts +5 -0
- package/dist/lib/ui/Logo.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),re=require("survey-core"),j=require("motion/react"),Ce=require("@radix-ui/react-label"),Ee=require("@radix-ui/react-radio-group"),Pe=require("@radix-ui/react-checkbox"),Ie=require("@radix-ui/react-select");function he(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return n.default=t,Object.freeze(n)}const _e=he(Ce),H=he(Ee),me=he(Pe),F=he(Ie);var de={exports:{}},ne={};var fe;function Ae(){if(fe)return ne;fe=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(a,l,o){var c=null;if(o!==void 0&&(c=""+o),l.key!==void 0&&(c=""+l.key),"key"in l){o={};for(var m in l)m!=="key"&&(o[m]=l[m])}else o=l;return l=o.ref,{$$typeof:t,type:a,key:c,ref:l!==void 0?l:null,props:o}}return ne.Fragment=n,ne.jsx=s,ne.jsxs=s,ne}var se={};var pe;function Le(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&(function(){function t(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===J?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case b:return"Fragment";case k:return"Profiler";case v:return"StrictMode";case X:return"Suspense";case A:return"SuspenseList";case D:return"Activity"}if(typeof i=="object")switch(typeof i.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),i.$$typeof){case g:return"Portal";case M:return i.displayName||"Context";case I:return(i._context.displayName||"Context")+".Consumer";case Q:var y=i.render;return i=i.displayName,i||(i=y.displayName||y.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Y:return y=i.displayName||null,y!==null?y:t(i.type)||"Memo";case U:y=i._payload,i=i._init;try{return t(i(y))}catch{}}return null}function n(i){return""+i}function s(i){try{n(i);var y=!1}catch{y=!0}if(y){y=console;var w=y.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&i[Symbol.toStringTag]||i.constructor.name||"Object";return w.call(y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),n(i)}}function a(i){if(i===b)return"<>";if(typeof i=="object"&&i!==null&&i.$$typeof===U)return"<...>";try{var y=t(i);return y?"<"+y+">":"<...>"}catch{return"<...>"}}function l(){var i=K.A;return i===null?null:i.getOwner()}function o(){return Error("react-stack-top-frame")}function c(i){if(ie.call(i,"key")){var y=Object.getOwnPropertyDescriptor(i,"key").get;if(y&&y.isReactWarning)return!1}return i.key!==void 0}function m(i,y){function w(){V||(V=!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)",y))}w.isReactWarning=!0,Object.defineProperty(i,"key",{get:w,configurable:!0})}function d(){var i=t(this.type);return oe[i]||(oe[i]=!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.")),i=this.props.ref,i!==void 0?i:null}function u(i,y,w,E,G,q){var f=w.ref;return i={$$typeof:p,type:i,key:y,props:w,_owner:E},(f!==void 0?f:null)!==null?Object.defineProperty(i,"ref",{enumerable:!1,get:d}):Object.defineProperty(i,"ref",{enumerable:!1,value:null}),i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(i,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(i,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.defineProperty(i,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i}function r(i,y,w,E,G,q){var f=y.children;if(f!==void 0)if(E)if(le(f)){for(E=0;E<f.length;E++)x(f[E]);Object.freeze&&Object.freeze(f)}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(f);if(ie.call(y,"key")){f=t(i);var T=Object.keys(y).filter(function(L){return L!=="key"});E=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",ee[f+E]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,N,w,Y,w),z[w+N]=!0)}if(w=null,p!==void 0&&(a(p),w=""+p),c(f)&&(a(f.key),w=""+f.key),"key"in f){p={};for(var q in f)q!=="key"&&(p[q]=f[q])}else p=f;return w&&m(p,typeof s=="function"?s.displayName||s.name||"Unknown":s),u(s,w,p,l(),O,D)}function j(s){h(s)?s._store&&(s._store.validated=1):typeof s=="object"&&s!==null&&s.$$typeof===U&&(s._payload.status==="fulfilled"?h(s._payload.value)&&s._payload.value._store&&(s._payload.value._store.validated=1):s._store&&(s._store.validated=1))}function h(s){return typeof s=="object"&&s!==null&&s.$$typeof===v}var _=S,v=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),C=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),W=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,te=Array.isArray,H=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(s){return s()}};var ne,ae={},se=_.react_stack_bottom_frame.bind(_,o)(),re=H(r(o)),z={};J.Fragment=b,J.jsx=function(s,f,p){var N=1e4>W.recentlyCreatedOwnerStacks++;return i(s,f,p,!1,N?Error("react-stack-top-frame"):se,N?H(r(s)):re)},J.jsxs=function(s,f,p){var N=1e4>W.recentlyCreatedOwnerStacks++;return i(s,f,p,!0,N?Error("react-stack-top-frame"):se,N?H(r(s)):re)}})()),J}var _e;function Te(){return _e||(_e=1,process.env.NODE_ENV==="production"?ie.exports=Se():ie.exports=Re()),ie.exports}var e=Te();function T({element:n,opts:t,children:a}){const l=n instanceof Z.Question?n:null,o=t.validationSeq>0&&l&&typeof l.hasErrors=="function"?l.hasErrors():!1,c=x.useAnimationControls();S.useEffect(()=>{t.animate&&o&&c.start({x:[0,-6,6,-4,0],transition:{duration:.32,ease:"easeInOut"}})},[c,o,t.animate,t.validationSeq]);const m=n.name;return e.jsx(x.motion.div,{className:o?"msj__question msj__question--invalid":"msj__question","data-msj-element":m,"data-msj-question":l?.name,initial:t.animate?{opacity:.85,y:12}:!1,whileInView:t.animate?{opacity:1,y:0}:void 0,viewport:{amount:.25,once:!0},transition:{duration:t.duration},children:e.jsx(x.motion.div,{className:"msj__questionInner",animate:c,children:a})})}function A({errors:n,opts:t}){return n.length===0?null:e.jsx(x.AnimatePresence,{initial:!1,children:n.map(a=>e.jsx(x.motion.div,{className:"msj__error",layout:!0,initial:t.animate?{opacity:0,y:-2}:!1,animate:t.animate?{opacity:1,y:0}:void 0,exit:t.animate?{opacity:0,y:-2}:void 0,transition:{duration:t.duration*.75},children:a},a))})}function E(n,t){const a=(n.title??"")||n.name;return t.showQuestionNumbers==="off"||t.showQuestionNumbers==="on"&&t.globalQuestionIndex<0||t.showQuestionNumbers==="onPage"&&t.questionIndex<0?a:`${t.showQuestionNumbers==="on"?t.globalQuestionIndex+1:t.questionIndex+1}. ${a}`}function Ce(n){const t=n;return(typeof t.getText=="function"?t.getText():t.text)??""}function L(n){return(n.errors??[]).map(Ce).filter(Boolean)}function R(n,t){if(n instanceof Z.Question){const a=n,r=a.survey;if(r&&typeof r.setValue=="function"&&a.name){r.setValue(a.name,t);return}}Reflect.set(n,"value",t)}function Ee({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],[o,c]=S.useState(!1);return e.jsxs(T,{element:a,opts:t,children:[e.jsxs(he.Root,{className:"msj__label",htmlFor:a.id,children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(x.motion.div,{className:"msj__inputWrap",initial:!1,animate:o?{scale:1.01}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:e.jsx("input",{id:a.id,className:"msj__input",value:a.value??"",onChange:m=>R(a,m.currentTarget.value),onFocus:()=>c(!0),onBlur:()=>c(!1)})}),e.jsx(A,{errors:l,opts:t})]})}function Pe({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],[o,c]=S.useState(!1),m=String(a.value??""),d=a.maxWordCount??a.maxWords??200,i=(m.trim()?m.trim().split(/\s+/).filter(Boolean):[]).length,j=i>=d*.9;return e.jsxs(T,{element:a,opts:t,children:[e.jsxs(he.Root,{className:"msj__label",htmlFor:a.id,children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(x.motion.div,{className:"msj__textareaWrap",initial:!1,animate:o?{scale:1.005}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:[e.jsx("textarea",{id:a.id,className:"msj__textarea",value:m,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:h=>{const _=h.currentTarget.value,v=_.trim()?_.trim().split(/\s+/).filter(Boolean):[];if(v.length<=d){R(a,_);return}R(a,`${v.slice(0,d).join(" ")} `)}}),e.jsx(x.motion.div,{className:"msj__counter",initial:!1,animate:j?{scale:1.05,color:"#dc2626"}:{scale:1,color:"#64748b"},transition:{type:"spring",stiffness:400,damping:25},children:t.t("wordCount",{count:i,max:d})})]}),e.jsx(A,{errors:l,opts:t})]})}function Ie({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],o=a.labelTrue||"Yes",c=a.labelFalse||"No",m=a.valueTrue??!0,d=a.valueFalse??!1,u=a.swapOrder===!0;let i;a.value===m?i="true":a.value===d?i="false":a.value===!0?i="true":a.value===!1&&(i="false");const j=P=>{R(a,P==="true"?m:d)};let h="50%",_="-50%",v="40px";i==="true"?(v="calc(50% - 6px)",u?(h="0%",_="4px"):(h="100%",_="calc(-100% - 4px)")):i==="false"&&(v="calc(50% - 6px)",u?(h="100%",_="calc(-100% - 4px)"):(h="0%",_="4px"));const g=u?o:c,b=u?c:o,y=u?"true":"false",k=u?"false":"true";return e.jsxs(T,{element:a,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(V.Root,{className:"msj__toggleSwitch",value:i,onValueChange:j,children:[e.jsxs("div",{className:"msj__toggleTrack","aria-hidden":"true",children:[e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--left",children:g}),e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--right",children:b}),e.jsx(x.motion.div,{className:`msj__toggleHandle ${i==="true"?"msj__toggleHandle--true":i==="false"?"msj__toggleHandle--false":""}`,initial:!1,animate:{left:h,x:_,width:v},transition:{type:"spring",stiffness:500,damping:30},children:e.jsx(x.motion.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:i==="true"?o:i==="false"?c:""},i||"empty")})]}),e.jsxs("div",{className:"msj__toggleInputs",children:[e.jsx(V.Item,{value:y,className:"msj__toggleInput","aria-label":g}),e.jsx(V.Item,{value:k,className:"msj__toggleInput","aria-label":b})]})]}),e.jsx(A,{errors:l,opts:t})]})}function ge({active:n,duration:t,size:a=14}){return e.jsx(x.motion.svg,{className:"msj__checkmark",width:a,height:a,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:e.jsx(x.motion.path,{d:"M3.2 8.4 6.6 11.8 12.8 4.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",pathLength:1,initial:!1,animate:n?{pathLength:1,opacity:1}:{pathLength:0,opacity:0},transition:{duration:t}})})}function fe({question:n,isMulti:t,opts:a}){const r=n,l=E(r,a),o=a.validationSeq>0?L(r):[],c=r.visibleChoices??[];if(!t){const d=r.value==null?"":String(r.value);return e.jsxs(T,{element:r,opts:a,children:[e.jsxs("div",{className:"msj__label",children:[l,r.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(V.Root,{className:"msj__choiceList",value:d,onValueChange:u=>{const i=c.find(j=>String(j.value)===u);R(r,i?i.value:void 0)},children:c.map(u=>{const i=String(u.value),j=u.text??i,h=d===i,_=`msj-radio-bg-${r.id}`;return e.jsx(V.Item,{value:i,asChild:!0,children:e.jsxs(x.motion.button,{type:"button",className:"msj__choiceOption",layout:!0,transition:{duration:a.duration},children:[h?e.jsx(x.motion.span,{className:"msj__choiceOptionBg",layoutId:_,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsxs("span",{className:"msj__radioItem",children:[e.jsx(V.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__radioIndicator",initial:!1,animate:h?{scale:1,opacity:1}:{scale:0,opacity:0},transition:h?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,a.duration*.4)}})}),h?e.jsx(x.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,a.duration*1.4)}},`${i}-pulse`):null]}),e.jsx("span",{children:j})]})]})},i)})}),e.jsx(A,{errors:o,opts:a})]})}const m=new Set(Array.isArray(r.value)?r.value:[]);return e.jsxs(T,{element:r,opts:a,children:[e.jsxs("div",{className:"msj__label",children:[l,r.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__choiceList",children:c.map(d=>{const u=d.value,i=String(u),j=d.text??i,h=m.has(u);return e.jsxs("label",{className:"msj__choiceOption","data-state":h?"checked":"unchecked",children:[e.jsx(x.motion.span,{className:"msj__choiceOptionBg","aria-hidden":!0,animate:{opacity:h?1:0},transition:{duration:a.duration}}),e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsx(le.Root,{className:"msj__checkbox",checked:h,onCheckedChange:_=>{const v=new Set(Array.isArray(r.value)?r.value:[]);_===!0?v.add(u):v.delete(u),R(r,Array.from(v))},children:e.jsx(le.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:h?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,a.duration*.5)},children:e.jsx(ge,{active:h,duration:Math.max(.22,a.duration*1.2)})})})}),e.jsx("span",{children:j})]})]},i)})}),e.jsx(A,{errors:o,opts:a})]})}function Ae({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],o=a.visibleChoices??[],c="__msj-empty__",m=a.value==null?c:String(a.value),d=o.find(h=>String(h.value)===m),u=m===c?t.t("selectPlaceholder"):d?.text??m,[i,j]=S.useState(!1);return e.jsxs(T,{element:a,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(M.Root,{open:i,onOpenChange:j,value:m,onValueChange:h=>{if(h===c){R(a,void 0);return}const _=o.find(v=>String(v.value)===h);R(a,_?_.value:h)},children:[e.jsxs(M.Trigger,{className:"msj__selectTrigger","aria-label":r,children:[e.jsx(M.Value,{className:m===c?"msj__selectValue msj__selectValue--placeholder":"msj__selectValue",children:u}),e.jsx(M.Icon,{className:"msj__selectIcon",children:"▾"})]}),e.jsx(M.Portal,{container:t.portalContainer??void 0,children:e.jsx(x.AnimatePresence,{children:i?e.jsx(M.Content,{className:"msj__selectContent",position:"popper",asChild:!0,children:e.jsx(x.motion.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{type:"spring",stiffness:650,damping:40},children:e.jsxs(M.Viewport,{className:"msj__selectViewport",children:[e.jsx(M.Item,{value:c,className:"msj__selectItem",children:e.jsx(M.ItemText,{children:t.t("selectPlaceholder")})}),o.map(h=>{const _=String(h.value);return e.jsx(M.Item,{value:_,className:"msj__selectItem",children:e.jsx(M.ItemText,{children:h.text??_})},_)})]})})}):null})})]}),e.jsx(A,{errors:l,opts:t})]})}function Le({question:n,opts:t}){const a=n,r=a.html??"";return e.jsxs(T,{element:n,opts:t,children:[a.title?e.jsx("div",{className:"msj__label",children:E(n,t)}):null,e.jsx("div",{className:"msj__html",dangerouslySetInnerHTML:{__html:r}})]})}function Oe({question:n,opts:t}){const a=n,r=a.imageLink??"",l=a.title??a.name;return e.jsxs(T,{element:n,opts:t,children:[a.title?e.jsx("div",{className:"msj__label",children:E(n,t)}):null,r?e.jsx("img",{className:"msj__image",src:r,alt:l}):null]})}function Me({question:n,opts:t}){const a=n,r=E(n,t),l=a.displayValue??a.value;return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:r}),e.jsx("div",{className:"msj__expression",children:l==null?"":String(l)})]})}function $e({question:n,opts:t}){return null}const De=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ve=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,r)=>r?r.toUpperCase():a.toLowerCase()),pe=n=>{const t=Ve(n);return t.charAt(0).toUpperCase()+t.slice(1)},ye=(...n)=>n.filter((t,a,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===a).join(" ").trim(),Be=n=>{for(const t in n)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Fe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Qe=S.forwardRef(({color:n="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:r,className:l="",children:o,iconNode:c,...m},d)=>S.createElement("svg",{ref:d,...Fe,width:t,height:t,stroke:n,strokeWidth:r?Number(a)*24/Number(t):a,className:ye("lucide",l),...!o&&!Be(m)&&{"aria-hidden":"true"},...m},[...c.map(([u,i])=>S.createElement(u,i)),...Array.isArray(o)?o:[o]]));const $=(n,t)=>{const a=S.forwardRef(({className:r,...l},o)=>S.createElement(Qe,{ref:o,iconNode:t,className:ye(`lucide-${De(pe(n))}`,`lucide-${n}`,r),...l}));return a.displayName=pe(n),a};const Ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]],He=$("angry",Ye);const Ue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],We=$("arrow-down",Ue);const Ge=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ze=$("arrow-up",Ge);const qe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Xe=$("frown",qe);const Je=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ke=$("grip-vertical",Je);const Ze=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],et=$("laugh",Ze);const tt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],nt=$("meh",tt);const at=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],st=$("plus",at);const rt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],it=$("smile",rt);const lt=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ot=$("star",lt);const ct=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ut=$("x",ct);function dt({active:n}){return e.jsx(ot,{size:24,fill:n?"currentColor":"none",strokeWidth:2})}function mt({idx:n,total:t}){const a=t>1?n/(t-1):.5;return a<.2?e.jsx(He,{size:24}):a<.4?e.jsx(Xe,{size:24}):a<.6?e.jsx(nt,{size:24}):a<.8?e.jsx(it,{size:24}):e.jsx(et,{size:24})}function ht({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleRateValues??[],c=n.value==null?"":String(n.value),m=`msj-rating-bg-${n.id}`,d=a.rateType??"labels",u=a.scaleColorMode,i=a.minRateDescription,j=a.maxRateDescription,h=a.displayRateDescriptionsAsExtremeItems,_=o.findIndex(v=>String(v.value)===c);return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__rating","data-type":d,"data-color-mode":u,children:[i&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--min",children:i}):null,o.map((v,g)=>{const b=String(v.value);let y=v.text??b;h&&(g===0&&i&&(y=i),g===o.length-1&&j&&(y=j));const k=c===b,P=d==="stars"&&_>=0?g<=_:k;let C;return u==="colored"&&(C={"--msj-rating-color":`hsl(${o.length>1?g/(o.length-1)*120:60}, 70%, 50%)`}),e.jsxs(x.motion.button,{type:"button",className:"msj__ratingItem",onClick:()=>R(n,v.value),layout:!0,transition:{duration:t.duration},"aria-label":y,style:C,children:[k?e.jsx(x.motion.span,{className:"msj__ratingItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__ratingItemContent",children:[d==="stars"?e.jsx(dt,{active:P}):null,d==="smileys"?e.jsx(mt,{idx:g,total:o.length}):null,d==="labels"?y:null]})]},b)}),j&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--max",children:j}):null]}),e.jsx(A,{errors:l,opts:t})]})}function xt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.items??[],c=n.value??{};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__multipleText",children:o.map((m,d)=>{const u=`${n.id}-${m.name}`;return e.jsxs(x.motion.div,{className:"msj__multipleTextRow",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:d*.05,duration:t.duration},children:[e.jsx(he.Root,{className:"msj__labelInline",htmlFor:u,children:m.title??m.name}),e.jsx("input",{id:u,className:"msj__input",value:c[m.name]??"",onChange:i=>{R(n,{...c,[m.name]:i.currentTarget.value})}})]},m.name)})}),e.jsx(A,{errors:l,opts:t})]})}function jt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=!!a.multiSelect,m=new Set(c?Array.isArray(n.value)?n.value:[]:[n.value]),d={rest:{opacity:0},hover:{opacity:1}};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__imagePicker",children:o.map(u=>{const i=String(u.value),j=m.has(u.value),h=`msj-imagePicker-bg-${n.id}`;return e.jsxs(x.motion.button,{type:"button",className:j?"msj__imagePickerItem msj__imagePickerItem--active":"msj__imagePickerItem",onClick:()=>{if(!c){R(n,u.value);return}const _=new Set(Array.isArray(n.value)?n.value:[]);_.has(u.value)?_.delete(u.value):_.add(u.value),R(n,Array.from(_))},layout:!0,initial:"rest",whileHover:j?void 0:"hover",transition:{duration:t.duration},children:[j?null:e.jsx(x.motion.span,{className:"msj__imagePickerHoverBg",variants:d,transition:{type:"spring",stiffness:700,damping:45}}),j?e.jsx(x.motion.span,{className:"msj__imagePickerItemBg",layoutId:h,transition:{type:"spring",stiffness:700,damping:40}}):null,u.imageLink?e.jsx("img",{className:"msj__imagePickerImg",src:u.imageLink,alt:u.text??i}):null,u.text?e.jsx("span",{className:"msj__imagePickerLabel",children:u.text}):null]},i)})}),e.jsx(A,{errors:l,opts:t})]})}function _t({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=n.value==null?"":String(n.value),m=`msj-btnGroup-bg-${n.id}`;return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__buttonGroup",children:o.map(d=>{const u=String(d.value),i=c===u;return e.jsxs(x.motion.button,{type:"button",className:i?"msj__buttonGroupItem msj__buttonGroupItem--active":"msj__buttonGroupItem",onClick:()=>R(n,d.value),layout:!0,transition:{duration:t.duration},children:[i?e.jsx(x.motion.span,{className:"msj__buttonGroupItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsx("span",{className:"msj__buttonGroupItemContent",children:d.text??u})]},u)})}),e.jsx(A,{errors:l,opts:t})]})}function ft({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=new Set(Array.isArray(n.value)?n.value:[]);return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__tagbox",children:o.map(m=>{const d=m.value,u=String(d),i=c.has(d);return e.jsxs(x.motion.button,{type:"button",className:i?"msj__tag msj__tag--active":"msj__tag",onClick:()=>{const j=new Set(Array.isArray(n.value)?n.value:[]);j.has(d)?j.delete(d):j.add(d),R(n,Array.from(j))},initial:!1,animate:i?{scale:1.02}:{scale:1},whileHover:{scale:1.04},whileTap:{scale:.97},transition:{type:"spring",stiffness:500,damping:30},children:[i?e.jsx(x.motion.span,{className:"msj__tagBg",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{type:"spring",stiffness:500,damping:35}}):null,e.jsx("span",{className:"msj__tagContent",children:m.text??u})]},u)})}),e.jsx(A,{errors:l,opts:t})]})}const de=({value:n,text:t,index:a,total:r,onClick:l,onMoveUp:o,onMoveDown:c,isRanked:m,longTap:d,enableDrag:u=!0})=>{const i=x.useDragControls(),j=S.useRef(null),h=b=>{d&&!l?(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{i.start(b),navigator.vibrate&&navigator.vibrate(50)},500)):l||i.start(b)},_=()=>{j.current&&(clearTimeout(j.current),j.current=null)},v=b=>{l&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),l())},g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"msj__rankingLabel",style:{flex:1},children:t}),e.jsxs("span",{className:"msj__rankingControls",style:{display:"flex",alignItems:"center",gap:"8px"},children:[l&&(m?e.jsx(ut,{size:16}):e.jsx(st,{size:16})),!l&&e.jsxs(e.Fragment,{children:[o&&a!==void 0&&a>0&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),o()},"aria-label":"Move up",children:e.jsx(ze,{size:16})}),c&&a!==void 0&&r!==void 0&&a<r-1&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),c()},"aria-label":"Move down",children:e.jsx(We,{size:16})}),e.jsx("div",{className:"msj__dragHandle",onPointerDown:h,onPointerUp:_,onPointerLeave:_,style:{cursor:d?"context-menu":"grab",display:"flex",alignItems:"center",padding:"4px"},children:e.jsx(Ke,{size:16,className:"msj__muted"})})]})]})]});return u?e.jsx(x.Reorder.Item,{value:n,className:"msj__rankingItem",dragListener:!1,dragControls:i,onClick:l,onKeyDown:v,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${t}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g}):e.jsx("li",{className:"msj__rankingItem",onClick:l,onKeyDown:v,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${t}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g})};function pt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=Array.isArray(n.value)?n.value:[],m=a.selectToRankEnabled===!0,d=a.selectToRankAreasLayout||"horizontal",u=a.selectToRankEmptyRankedAreaText||"Drag items here to rank them",i=a.selectToRankEmptyUnrankedAreaText||"All items ranked",j=a.longTap===!0,h=m?c:[...new Set([...c,...o.map(y=>y.value)])],_=m?o.filter(y=>!c.includes(y.value)).map(y=>y.value):[],v=y=>{R(n,y)},g=y=>{const k=[...c,y];R(n,k)},b=y=>{const k=c.filter(P=>P!==y);R(n,k)};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),m?e.jsxs("div",{className:`msj__rankingContainer msj__rankingContainer--${d}`,children:[e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Choices"}),_.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:i}),e.jsx(x.motion.ul,{className:"msj__ranking",layout:!0,children:e.jsx(x.AnimatePresence,{initial:!1,children:_.map(y=>{const k=String(y),P=o.find(C=>C.value===y)?.text??k;return e.jsx(x.motion.div,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:e.jsx(de,{value:y,text:P,onClick:()=>g(y),isRanked:!1,longTap:j,enableDrag:!1})},k)})})})]}),e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Ranked"}),h.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:u}),e.jsx(x.Reorder.Group,{axis:"y",values:h,onReorder:v,className:"msj__ranking",children:e.jsx(x.AnimatePresence,{initial:!1,children:h.map(y=>{const k=String(y),P=o.find(C=>C.value===y)?.text??k;return e.jsx(de,{value:y,text:P,onClick:()=>b(y),isRanked:!0,longTap:j},k)})})})]})]}):e.jsx(x.Reorder.Group,{axis:"y",values:h,onReorder:v,className:"msj__ranking",children:h.map((y,k)=>{const P=String(y),C=o.find(I=>I.value===y)?.text??P,B=()=>{if(k>0){const I=[...h],F=I[k];I[k]=I[k-1],I[k-1]=F,v(I)}},G=()=>{if(k<h.length-1){const I=[...h],F=I[k];I[k]=I[k+1],I[k+1]=F,v(I)}};return e.jsx(de,{value:y,text:C,index:k,total:h.length,onMoveUp:B,onMoveDown:G,longTap:j},P)})}),e.jsx(A,{errors:l,opts:t})]})}async function vt(n){const t=await new Promise(a=>{const r=new FileReader;r.onload=()=>a(String(r.result??"")),r.readAsDataURL(n)});return{name:n.name,type:n.type,content:t}}function gt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],[o,c]=S.useState(!1),m=async d=>{const u=await Promise.all(d.map(vt));R(n,a.allowMultiple===!0?u:u[0]??void 0)};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(x.motion.div,{className:"msj__fileDropZone",initial:!1,animate:o?{scale:1.02,borderColor:"var(--msj-primary)"}:{scale:1,borderColor:"var(--msj-border)"},transition:{type:"spring",stiffness:400,damping:25},onDragOver:d=>{d.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:async d=>{d.preventDefault(),c(!1);const u=Array.from(d.dataTransfer.files);u.length>0&&await m(u)},children:[e.jsx("input",{className:"msj__fileInput",type:"file",multiple:a.allowMultiple===!0,onChange:async d=>{const u=Array.from(d.currentTarget.files??[]);await m(u)}}),e.jsx("span",{className:"msj__fileDropText",children:o?"Drop files here":"Click or drag files here"})]}),e.jsx(A,{errors:l,opts:t})]})}function yt({question:n,opts:t}){const a=E(n,t),r=t.validationSeq>0?L(n):[],l=S.useRef(null),o=S.useRef(!1),[c,m]=S.useState(0);return S.useEffect(()=>{const d=l.current;if(!d)return;let u=null;try{u=d.getContext("2d")}catch{return}if(!u)return;u.lineWidth=2,u.lineCap="round",u.strokeStyle="rgba(15, 23, 42, 0.9)";const i=v=>{const g=d.getBoundingClientRect(),b=d.width/g.width,y=d.height/g.height;return{x:(v.clientX-g.left)*b,y:(v.clientY-g.top)*y}},j=v=>{o.current=!0;try{d.setPointerCapture(v.pointerId)}catch{}const g=i(v);u.beginPath(),u.moveTo(g.x,g.y)},h=v=>{if(!o.current)return;const g=i(v);u.lineTo(g.x,g.y),u.stroke()},_=()=>{if(o.current){o.current=!1;try{R(n,d.toDataURL("image/png"))}catch{}}};return d.addEventListener("pointerdown",j),d.addEventListener("pointermove",h),window.addEventListener("pointerup",_),()=>{d.removeEventListener("pointerdown",j),d.removeEventListener("pointermove",h),window.removeEventListener("pointerup",_)}},[n,c]),e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[a,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__signaturePadWrap",children:[e.jsx(x.motion.canvas,{ref:l,className:"msj__signaturePad",width:560,height:160,initial:{opacity:0},animate:{opacity:1},transition:{duration:.2}},c),e.jsx(x.motion.button,{type:"button",className:"msj__miniButton",whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{m(d=>d+1),R(n,void 0)},children:"Clear"})]}),e.jsx(A,{errors:r,opts:t})]})}function bt({question:n,opts:t,render:a}){const r=n,l=E(n,t),o=r.panels??[];return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:l}),e.jsxs("div",{className:"msj__panelDynamic",children:[e.jsx(x.AnimatePresence,{mode:"popLayout",children:o.map((c,m)=>e.jsxs(x.motion.div,{className:"msj__panelDynamicItem",initial:{opacity:0,y:-10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},transition:{type:"spring",stiffness:500,damping:35},children:[e.jsxs("div",{className:"msj__panelDynamicHeader",children:[e.jsxs("div",{className:"msj__panelDynamicTitle",children:["Item ",m+1]}),r.removePanel?e.jsx(x.motion.button,{type:"button",className:"msj__miniButton",onClick:()=>r.removePanel?.(c),whileHover:{scale:1.05},whileTap:{scale:.95},children:"Remove"}):null]}),a(c,t)]},c.name??m))}),r.addPanel?e.jsx(x.motion.button,{type:"button",className:"msj__button",onClick:()=>r.addPanel?.(),whileHover:{scale:1.02},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:25},children:"Add item"}):null]})]})}function Nt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.rows??a.visibleRows??[],c=a.columns??a.visibleColumns??[],m=n.value??{},d=a.cellType==="checkbox";return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__matrix",style:{"--msj-matrix-cols":String(c.length)},children:[e.jsxs("div",{className:"msj__matrixHeader","aria-hidden":!0,children:[e.jsx("div",{className:"msj__matrixHeaderCell msj__matrixCorner"}),c.map(u=>{const i=String(u.value);return e.jsx("div",{className:"msj__matrixHeaderCell",children:u.text??i},i)})]}),o.map(u=>{const i=String(u.value),j=u.text??i;return e.jsxs("div",{className:"msj__matrixRow",children:[e.jsx("div",{className:"msj__matrixRowTitle",children:j}),d?e.jsx("div",{className:"msj__matrixRowChoices",children:c.map(h=>{const _=String(h.value),v=Array.isArray(m[i])?m[i]:[],g=v.includes(h.value);return e.jsx("label",{className:"msj__matrixCell","data-state":g?"checked":"unchecked",children:e.jsx(le.Root,{className:"msj__checkbox",checked:g,onCheckedChange:b=>{const y=new Set(v);b===!0?y.add(h.value):y.delete(h.value),R(n,{...m,[i]:Array.from(y)})},children:e.jsx(le.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:g?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,t.duration*.5)},children:e.jsx(ge,{active:g,duration:Math.max(.22,t.duration*1.2)})})})})},_)})}):e.jsx(V.Root,{className:"msj__matrixRowChoices",value:m[i]==null?"":String(m[i]),onValueChange:h=>{R(n,{...m,[i]:h})},children:c.map(h=>{const _=String(h.value),v=h.text??_,g=String(m[i]??"")===_;return e.jsx(V.Item,{value:_,asChild:!0,children:e.jsx("button",{type:"button",className:"msj__matrixCell","aria-label":`${j}: ${v}`,"data-state":g?"checked":"unchecked",children:e.jsxs("span",{className:"msj__radioItem","aria-hidden":!0,children:[e.jsx(V.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__radioIndicator",initial:!1,animate:g?{scale:1,opacity:1}:{scale:0,opacity:0},transition:g?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,t.duration*.4)}})}),g?e.jsx(x.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,t.duration*1.4)}}):null]})})},`${i}:${_}`)})})]},i)})]}),e.jsx(A,{errors:l,opts:t})]})}function kt({question:n,opts:t}){const a=E(n,t);return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:a}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dropdown is not yet fully supported."})]})}function wt({question:n,opts:t}){const a=E(n,t);return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:a}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dynamic is not yet fully supported."})]})}function me({element:n,opts:t,render:a}){const r=n,l=r.elements??[];return e.jsxs(T,{element:n,opts:t,children:[r.title?e.jsx("div",{className:"msj__label",children:r.title}):null,e.jsx("div",{className:"msj__panel",children:l.map((o,c)=>{const m=typeof o.getType=="function"?o.getType():"unknown",d=o.name??`${m}-${c}`;return e.jsx("div",{children:a(o,t)},d)})})]})}function K(n,t){const a=typeof n.getType=="function"?n.getType():"unknown";if(!(n instanceof Z.Question))switch(a){case"flowpanel":return e.jsx(me,{element:n,opts:t,render:K});case"page":return e.jsx(me,{element:n,opts:t,render:K});default:return e.jsx(me,{element:n,opts:t,render:K})}const r=n;switch(a){case"comment":return e.jsx(Pe,{question:r,opts:t});case"boolean":return e.jsx(Ie,{question:r,opts:t});case"radiogroup":return e.jsx(fe,{question:r,isMulti:!1,opts:t});case"checkbox":return e.jsx(fe,{question:r,isMulti:!0,opts:t});case"dropdown":return e.jsx(Ae,{question:r,opts:t});case"tagbox":return e.jsx(ft,{question:r,opts:t});case"buttongroup":return e.jsx(_t,{question:r,opts:t});case"ranking":return e.jsx(pt,{question:r,opts:t});case"imagepicker":return e.jsx(jt,{question:r,opts:t});case"file":return e.jsx(gt,{question:r,opts:t});case"signaturepad":return e.jsx(yt,{question:r,opts:t});case"paneldynamic":return e.jsx(bt,{question:r,opts:t,render:K});case"matrix":return e.jsx(Nt,{question:r,opts:t});case"matrixdropdown":return e.jsx(kt,{question:r,opts:t});case"matrixdynamic":return e.jsx(wt,{question:r,opts:t});case"html":return e.jsx(Le,{question:r,opts:t});case"image":return e.jsx(Oe,{question:r,opts:t});case"expression":return e.jsx(Me,{question:r,opts:t});case"empty":return e.jsx($e,{question:r,opts:t});case"rating":return e.jsx(ht,{question:r,opts:t});case"multipletext":return e.jsx(xt,{question:r,opts:t});case"text":default:return e.jsx(Ee,{question:r,opts:t})}}const St="Previous",Rt="Next",Tt="Complete",Ct="Thanks!",Et="Your responses have been recorded.",Pt="Select…",It="{count}/{max} words",At="Page {current} of {total}",Lt={back:St,next:Rt,complete:Tt,thanksTitle:Ct,thanksHint:Et,selectPlaceholder:Pt,wordCount:It,pageXofY:At},Ot="Previous",Mt="Next",$t="Complete",Dt="Thanks!",Vt="Your responses have been recorded.",Bt="Select…",Ft="{count}/{max} words",Qt="Page {current} of {total}",Yt={back:Ot,next:Mt,complete:$t,thanksTitle:Dt,thanksHint:Vt,selectPlaceholder:Bt,wordCount:Ft,pageXofY:Qt},ve={"en-US":Yt,"en-GB":Lt};function Ht(n){return ve[n??"en-US"]??ve["en-US"]}function Ut({locale:n,messages:t}){const r={...Ht(n),...t??{}};return(l,o)=>{let c=r[l]??l;if(o)for(const[m,d]of Object.entries(o))c=c.replaceAll(`{${m}}`,String(d));return c}}function Wt(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M10 3.5 6 8l4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Gt(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M6 3.5 10 8l-4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function zt({json:n,model:t,data:a,onComplete:r,animate:l=!0,animationDurationMs:o=180,theme:c="modern",locale:m="en-US",messages:d,className:u}){const i=S.useMemo(()=>{if(t)return t;const s=n??{},f=s.showQuestionNumbers===void 0?{...s,showQuestionNumbers:"onPage"}:s,p=new Z.Model(f);return a&&(p.data=a),p},[t,n,a]),[,j]=S.useReducer(s=>s+1,0),[h,_]=S.useReducer((s,f)=>f.type==="setPage"?{pageName:f.pageName,seq:0}:s.pageName!==f.pageName?{pageName:f.pageName,seq:1}:{pageName:s.pageName,seq:s.seq+1},{pageName:null,seq:0}),v=S.useRef(null),g=o/1e3,b=S.useMemo(()=>Ut({locale:m,messages:d}),[m,d]),[y,k]=S.useState(null),P=["msj",c?`msj--theme-${c}`:null,u].filter(Boolean).join(" ");if(S.useEffect(()=>{const s=()=>j(),f=()=>{_({type:"setPage",pageName:i.currentPage?.name??null}),s()},p=()=>{r?.(i.data,i),s()};return i.onValueChanged.add(s),i.onCurrentPageChanged.add(f),i.onComplete.add(p),()=>{i.onValueChanged.remove(s),i.onCurrentPageChanged.remove(f),i.onComplete.remove(p)}},[i,r]),S.useEffect(()=>{const s=v.current;if(!s)return;v.current=null;const f=typeof window<"u"&&window.CSS&&typeof window.CSS.escape=="function"?window.CSS.escape:O=>O.replaceAll('"','\\"'),p=document.querySelector(`[data-msj-question="${f(s)}"]`);if(!p)return;const N=p.querySelector('input, textarea, select, button, [tabindex]:not([tabindex="-1"])');try{p.scrollIntoView({behavior:"smooth",block:"center"})}catch{p.scrollIntoView()}N?.focus({preventScroll:!0})}),i.state==="completed")return e.jsx("div",{className:P,children:e.jsxs("div",{className:"msj__card",children:[e.jsx("h2",{className:"msj__title",children:b("thanksTitle")}),e.jsx("div",{className:"msj__hint",children:b("thanksHint")})]})});const C=i.currentPage,B=C?.questions??[],G=C?.elements??B,I=h.pageName===(C?.name??null)?h.seq:0,F=i.showPageTitles!==!1,U=i.showPageNumbers===!0,Q=i.showQuestionNumbers,ce=Q===!0?"on":Q===!1?"off":Q==="off"||Q==="on"||Q==="onPage"?Q:"onPage",W=i.navigationButtonsLocation??"bottom",ee=i.showNavigationButtons!==!1,te=C?.navigationButtonsVisibility??"inherit",H=te==="hide"?!1:te==="show"?!0:ee,ne=i.showPrevButton!==!1,ae=H&&ne&&!i.isFirstPage,se=H&&!i.isLastPage,re=H&&i.isLastPage,z=s=>W==="topBottom"||W===s?e.jsxs("div",{className:s==="top"?"msj__nav msj__nav--top":"msj__nav",children:[e.jsx("div",{className:"msj__navSlot msj__navSlot--left",children:e.jsx(x.AnimatePresence,{initial:!1,children:ae?e.jsxs(x.motion.button,{type:"button",className:"msj__button msj__button--nav",onClick:()=>{i.prevPage(),j()},initial:l?{opacity:0,x:-6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:-6}:void 0,transition:{duration:g},whileHover:l?{x:-2}:void 0,whileTap:l?{scale:.98}:void 0,children:[e.jsx(Wt,{}),b("back")]},"prev"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--center",children:e.jsx(x.AnimatePresence,{initial:!1,children:re?e.jsx(x.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--complete",onClick:()=>{let p=!1;try{p=i.validateCurrentPage()}catch{p=!1}if(!p){const N=B.find(O=>O.hasErrors());v.current=N?.name??null,_({type:"bump",pageName:C?.name??null}),j();return}i.tryComplete(),j()},initial:l?{opacity:0,y:6,scale:.98}:!1,animate:l?{opacity:1,y:0,scale:1}:void 0,exit:l?{opacity:0,y:6,scale:.98}:void 0,transition:{duration:g,x:{type:"tween",duration:.32,ease:"easeInOut"},rotate:{type:"tween",duration:.32,ease:"easeInOut"}},whileHover:l?{x:[0,-2,2,-2,0],rotate:[0,-1.2,1.2,-1.2,0]}:void 0,whileTap:l?{scale:.98}:void 0,children:b("complete")},"complete"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--right",children:e.jsx(x.AnimatePresence,{initial:!1,children:se?e.jsxs(x.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--navPrimary",onClick:()=>{let p=!1;try{p=i.validateCurrentPage()}catch{p=!1}if(!p){const N=B.find(O=>O.hasErrors());v.current=N?.name??null,_({type:"bump",pageName:C?.name??null}),j();return}i.nextPage(),j()},initial:l?{opacity:0,x:6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:6}:void 0,transition:{duration:g},whileHover:l?{x:2}:void 0,whileTap:l?{scale:.98}:void 0,children:[b("next"),e.jsx(Gt,{})]},"next"):null})})]}):null;return e.jsx("div",{className:P,ref:k,children:e.jsxs("div",{className:"msj__card",children:[i.title?e.jsx("h2",{className:"msj__title",children:i.title}):null,z("top"),e.jsx(x.AnimatePresence,{mode:"wait",initial:!1,children:e.jsxs(x.motion.div,{initial:l?{opacity:0,y:8}:!1,animate:l?{opacity:1,y:0}:void 0,exit:l?{opacity:0,y:-8}:void 0,transition:{duration:g},children:[F||U?e.jsxs("div",{className:"msj__pageHeader",children:[F&&C?.title?e.jsx("div",{className:"msj__pageTitle",children:C.title}):null,U?e.jsx("div",{className:"msj__pageNumber",children:b("pageXofY",{current:(i.currentPageNo??0)+1,total:i.pages?.length??0})}):null]}):null,(()=>{const s=(i.pages??[]).slice(0,i.currentPageNo??0).reduce((p,N)=>p+(N.questions??[]).length,0);return G.reduce((p,N,O)=>{const D=typeof N.getType=="function"?N.getType():"unknown",w=N instanceof Z.Question&&D!=="html"&&D!=="image"&&D!=="expression"&&D!=="empty",Y=w?p.pageQuestionIndex:-1,q=w?p.globalQuestionIndex:-1,ue=N.name??`${D}-${O}`;return{items:[...p.items,e.jsx("div",{children:K(N,{animate:l,duration:g,t:b,validationSeq:I,questionIndex:Y,globalQuestionIndex:q,showQuestionNumbers:ce,portalContainer:y})},ue)],pageQuestionIndex:w?p.pageQuestionIndex+1:p.pageQuestionIndex,globalQuestionIndex:w?p.globalQuestionIndex+1:p.globalQuestionIndex}},{items:[],pageQuestionIndex:0,globalQuestionIndex:s}).items})()]},C?.name??"page")}),z("bottom")]})})}exports.MotionSurvey=zt;
|
|
6
|
+
<%s key={someKey} {...props} />`,E,f,T,f),ee[f+E]=!0)}if(f=null,w!==void 0&&(s(w),f=""+w),c(y)&&(s(y.key),f=""+y.key),"key"in y){w={};for(var N in y)N!=="key"&&(w[N]=y[N])}else w=y;return f&&m(w,typeof i=="function"?i.displayName||i.name||"Unknown":i),u(i,f,w,l(),G,q)}function x(i){h(i)?i._store&&(i._store.validated=1):typeof i=="object"&&i!==null&&i.$$typeof===U&&(i._payload.status==="fulfilled"?h(i._payload.value)&&i._payload.value._store&&(i._payload.value._store.validated=1):i._store&&(i._store.validated=1))}function h(i){return typeof i=="object"&&i!==null&&i.$$typeof===p}var _=S,p=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),M=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),K=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie=Object.prototype.hasOwnProperty,le=Array.isArray,z=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(i){return i()}};var V,oe={},Z=_.react_stack_bottom_frame.bind(_,o)(),ce=z(a(o)),ee={};se.Fragment=b,se.jsx=function(i,y,w){var E=1e4>K.recentlyCreatedOwnerStacks++;return r(i,y,w,!1,E?Error("react-stack-top-frame"):Z,E?z(a(i)):ce)},se.jsxs=function(i,y,w){var E=1e4>K.recentlyCreatedOwnerStacks++;return r(i,y,w,!0,E?Error("react-stack-top-frame"):Z,E?z(a(i)):ce)}})()),se}var ge;function $e(){return ge||(ge=1,process.env.NODE_ENV==="production"?de.exports=Ae():de.exports=Le()),de.exports}var e=$e();function C({element:t,opts:n,children:s}){const l=t instanceof re.Question?t:null,o=n.validationSeq>0&&l&&typeof l.hasErrors=="function"?l.hasErrors():!1,c=j.useAnimationControls();S.useEffect(()=>{n.animate&&o&&c.start({x:[0,-6,6,-4,0],transition:{duration:.32,ease:"easeInOut"}})},[c,o,n.animate,n.validationSeq]);const m=t.name;return e.jsx(j.motion.div,{className:o?"msj__question msj__question--invalid":"msj__question","data-msj-element":m,"data-msj-question":l?.name,initial:n.animate?{opacity:.85,y:12}:!1,whileInView:n.animate?{opacity:1,y:0}:void 0,viewport:{amount:.25,once:!0},transition:{duration:n.duration},children:e.jsx(j.motion.div,{className:"msj__questionInner",animate:c,children:s})})}function $({errors:t,opts:n}){return t.length===0?null:e.jsx(j.AnimatePresence,{initial:!1,children:t.map(s=>e.jsx(j.motion.div,{className:"msj__error",layout:!0,initial:n.animate?{opacity:0,y:-2}:!1,animate:n.animate?{opacity:1,y:0}:void 0,exit:n.animate?{opacity:0,y:-2}:void 0,transition:{duration:n.duration*.75},children:s},s))})}function P(t,n){const s=(t.title??"")||t.name;return n.showQuestionNumbers==="off"||n.showQuestionNumbers==="on"&&n.globalQuestionIndex<0||n.showQuestionNumbers==="onPage"&&n.questionIndex<0?s:`${n.showQuestionNumbers==="on"?n.globalQuestionIndex+1:n.questionIndex+1}. ${s}`}function Me(t){const n=t;return(typeof n.getText=="function"?n.getText():n.text)??""}function O(t){return(t.errors??[]).map(Me).filter(Boolean)}function R(t,n){if(t instanceof re.Question){const s=t,a=s.survey;if(a&&typeof a.setValue=="function"&&s.name){a.setValue(s.name,n);return}}Reflect.set(t,"value",n)}function Oe({question:t,opts:n}){const s=t,a=P(s,n),l=n.validationSeq>0?O(s):[],[o,c]=S.useState(!1);return e.jsxs(C,{element:s,opts:n,children:[e.jsxs(_e.Root,{className:"msj__label",htmlFor:s.id,children:[a,s.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(j.motion.div,{className:"msj__inputWrap",initial:!1,animate:o?{scale:1.01}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:e.jsx("input",{id:s.id,className:"msj__input",value:s.value??"",onChange:m=>R(s,m.currentTarget.value),onFocus:()=>c(!0),onBlur:()=>c(!1)})}),e.jsx($,{errors:l,opts:n})]})}function De({question:t,opts:n}){const s=t,a=P(s,n),l=n.validationSeq>0?O(s):[],[o,c]=S.useState(!1),m=String(s.value??""),d=s.maxWordCount??s.maxWords??200,r=(m.trim()?m.trim().split(/\s+/).filter(Boolean):[]).length,x=r>=d*.9;return e.jsxs(C,{element:s,opts:n,children:[e.jsxs(_e.Root,{className:"msj__label",htmlFor:s.id,children:[a,s.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(j.motion.div,{className:"msj__textareaWrap",initial:!1,animate:o?{scale:1.005}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:[e.jsx("textarea",{id:s.id,className:"msj__textarea",value:m,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:h=>{const _=h.currentTarget.value,p=_.trim()?_.trim().split(/\s+/).filter(Boolean):[];if(p.length<=d){R(s,_);return}R(s,`${p.slice(0,d).join(" ")} `)}}),e.jsx(j.motion.div,{className:"msj__counter",initial:!1,animate:x?{scale:1.05,color:"#dc2626"}:{scale:1,color:"#64748b"},transition:{type:"spring",stiffness:400,damping:25},children:n.t("wordCount",{count:r,max:d})})]}),e.jsx($,{errors:l,opts:n})]})}function Fe({question:t,opts:n}){const s=t,a=P(s,n),l=n.validationSeq>0?O(s):[],o=s.labelTrue||"Yes",c=s.labelFalse||"No",m=s.valueTrue??!0,d=s.valueFalse??!1,u=s.swapOrder===!0;let r;s.value===m?r="true":s.value===d?r="false":s.value===!0?r="true":s.value===!1&&(r="false");const x=I=>{R(s,I==="true"?m:d)};let h="50%",_="-50%",p="40px";r==="true"?(p="calc(50% - 6px)",u?(h="0%",_="4px"):(h="100%",_="calc(-100% - 4px)")):r==="false"&&(p="calc(50% - 6px)",u?(h="100%",_="calc(-100% - 4px)"):(h="0%",_="4px"));const g=u?o:c,b=u?c:o,v=u?"true":"false",k=u?"false":"true";return e.jsxs(C,{element:s,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,s.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(H.Root,{className:"msj__toggleSwitch",value:r,onValueChange:x,children:[e.jsxs("div",{className:"msj__toggleTrack","aria-hidden":"true",children:[e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--left",children:g}),e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--right",children:b}),e.jsx(j.motion.div,{className:`msj__toggleHandle ${r==="true"?"msj__toggleHandle--true":r==="false"?"msj__toggleHandle--false":""}`,initial:!1,animate:{left:h,x:_,width:p},transition:{type:"spring",stiffness:500,damping:30},children:e.jsx(j.motion.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:r==="true"?o:r==="false"?c:""},r||"empty")})]}),e.jsxs("div",{className:"msj__toggleInputs",children:[e.jsx(H.Item,{value:v,className:"msj__toggleInput","aria-label":g}),e.jsx(H.Item,{value:k,className:"msj__toggleInput","aria-label":b})]})]}),e.jsx($,{errors:l,opts:n})]})}function ke({active:t,duration:n,size:s=14}){return e.jsx(j.motion.svg,{className:"msj__checkmark",width:s,height:s,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:e.jsx(j.motion.path,{d:"M3.2 8.4 6.6 11.8 12.8 4.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",pathLength:1,initial:!1,animate:t?{pathLength:1,opacity:1}:{pathLength:0,opacity:0},transition:{duration:n}})})}function ve({question:t,isMulti:n,opts:s}){const a=t,l=P(a,s),o=s.validationSeq>0?O(a):[],c=a.visibleChoices??[];if(!n){const d=a.value==null?"":String(a.value);return e.jsxs(C,{element:a,opts:s,children:[e.jsxs("div",{className:"msj__label",children:[l,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(H.Root,{className:"msj__choiceList",value:d,onValueChange:u=>{const r=c.find(x=>String(x.value)===u);R(a,r?r.value:void 0)},children:c.map(u=>{const r=String(u.value),x=u.text??r,h=d===r,_=`msj-radio-bg-${a.id}`;return e.jsx(H.Item,{value:r,asChild:!0,children:e.jsxs(j.motion.button,{type:"button",className:"msj__choiceOption",layout:!0,transition:{duration:s.duration},children:[h?e.jsx(j.motion.span,{className:"msj__choiceOptionBg",layoutId:_,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsxs("span",{className:"msj__radioItem",children:[e.jsx(H.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(j.motion.span,{className:"msj__radioIndicator",initial:!1,animate:h?{scale:1,opacity:1}:{scale:0,opacity:0},transition:h?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,s.duration*.4)}})}),h?e.jsx(j.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,s.duration*1.4)}},`${r}-pulse`):null]}),e.jsx("span",{children:x})]})]})},r)})}),e.jsx($,{errors:o,opts:s})]})}const m=new Set(Array.isArray(a.value)?a.value:[]);return e.jsxs(C,{element:a,opts:s,children:[e.jsxs("div",{className:"msj__label",children:[l,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__choiceList",children:c.map(d=>{const u=d.value,r=String(u),x=d.text??r,h=m.has(u);return e.jsxs("label",{className:"msj__choiceOption","data-state":h?"checked":"unchecked",children:[e.jsx(j.motion.span,{className:"msj__choiceOptionBg","aria-hidden":!0,animate:{opacity:h?1:0},transition:{duration:s.duration}}),e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsx(me.Root,{className:"msj__checkbox",checked:h,onCheckedChange:_=>{const p=new Set(Array.isArray(a.value)?a.value:[]);_===!0?p.add(u):p.delete(u),R(a,Array.from(p))},children:e.jsx(me.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(j.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:h?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,s.duration*.5)},children:e.jsx(ke,{active:h,duration:Math.max(.22,s.duration*1.2)})})})}),e.jsx("span",{children:x})]})]},r)})}),e.jsx($,{errors:o,opts:s})]})}function Be({question:t,opts:n}){const s=t,a=P(s,n),l=n.validationSeq>0?O(s):[],o=s.visibleChoices??[],c="__msj-empty__",m=s.value==null?c:String(s.value),d=o.find(h=>String(h.value)===m),u=m===c?n.t("selectPlaceholder"):d?.text??m,[r,x]=S.useState(!1);return e.jsxs(C,{element:s,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,s.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(F.Root,{open:r,onOpenChange:x,value:m,onValueChange:h=>{if(h===c){R(s,void 0);return}const _=o.find(p=>String(p.value)===h);R(s,_?_.value:h)},children:[e.jsxs(F.Trigger,{className:"msj__selectTrigger","aria-label":a,children:[e.jsx(F.Value,{className:m===c?"msj__selectValue msj__selectValue--placeholder":"msj__selectValue",children:u}),e.jsx(F.Icon,{className:"msj__selectIcon",children:"▾"})]}),e.jsx(F.Portal,{container:n.portalContainer??void 0,children:e.jsx(j.AnimatePresence,{children:r?e.jsx(F.Content,{className:"msj__selectContent",position:"popper",asChild:!0,children:e.jsx(j.motion.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{type:"spring",stiffness:650,damping:40},children:e.jsxs(F.Viewport,{className:"msj__selectViewport",children:[e.jsx(F.Item,{value:c,className:"msj__selectItem",children:e.jsx(F.ItemText,{children:n.t("selectPlaceholder")})}),o.map(h=>{const _=String(h.value);return e.jsx(F.Item,{value:_,className:"msj__selectItem",children:e.jsx(F.ItemText,{children:h.text??_})},_)})]})})}):null})})]}),e.jsx($,{errors:l,opts:n})]})}function Ve({question:t,opts:n}){const s=t,a=s.html??"";return e.jsxs(C,{element:t,opts:n,children:[s.title?e.jsx("div",{className:"msj__label",children:P(t,n)}):null,e.jsx("div",{className:"msj__html",dangerouslySetInnerHTML:{__html:a}})]})}function He({question:t,opts:n}){const s=t,a=s.imageLink??"",l=s.title??s.name;return e.jsxs(C,{element:t,opts:n,children:[s.title?e.jsx("div",{className:"msj__label",children:P(t,n)}):null,a?e.jsx("img",{className:"msj__image",src:a,alt:l}):null]})}function Qe({question:t,opts:n}){const s=t,a=P(t,n),l=s.displayValue??s.value;return e.jsxs(C,{element:t,opts:n,children:[e.jsx("div",{className:"msj__label",children:a}),e.jsx("div",{className:"msj__expression",children:l==null?"":String(l)})]})}function Ye({question:t,opts:n}){return null}const We=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,a)=>a?a.toUpperCase():s.toLowerCase()),ye=t=>{const n=Ue(t);return n.charAt(0).toUpperCase()+n.slice(1)},we=(...t)=>t.filter((n,s,a)=>!!n&&n.trim()!==""&&a.indexOf(n)===s).join(" ").trim(),ze=t=>{for(const n in t)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};var Ge={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const qe=S.forwardRef(({color:t="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:a,className:l="",children:o,iconNode:c,...m},d)=>S.createElement("svg",{ref:d,...Ge,width:n,height:n,stroke:t,strokeWidth:a?Number(s)*24/Number(n):s,className:we("lucide",l),...!o&&!ze(m)&&{"aria-hidden":"true"},...m},[...c.map(([u,r])=>S.createElement(u,r)),...Array.isArray(o)?o:[o]]));const B=(t,n)=>{const s=S.forwardRef(({className:a,...l},o)=>S.createElement(qe,{ref:o,iconNode:n,className:we(`lucide-${We(ye(t))}`,`lucide-${t}`,a),...l}));return s.displayName=ye(t),s};const Xe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]],Je=B("angry",Xe);const Ke=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ze=B("arrow-down",Ke);const et=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],tt=B("arrow-up",et);const nt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],st=B("frown",nt);const at=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],rt=B("grip-vertical",at);const it=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],lt=B("laugh",it);const ot=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],ct=B("meh",ot);const ut=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dt=B("plus",ut);const mt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],ht=B("smile",mt);const jt=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],xt=B("star",jt);const _t=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ft=B("x",_t);function pt({active:t}){return e.jsx(xt,{size:24,fill:t?"currentColor":"none",strokeWidth:2})}function gt({idx:t,total:n}){const s=n>1?t/(n-1):.5;return s<.2?e.jsx(Je,{size:24}):s<.4?e.jsx(st,{size:24}):s<.6?e.jsx(ct,{size:24}):s<.8?e.jsx(ht,{size:24}):e.jsx(lt,{size:24})}function vt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.visibleRateValues??[],c=t.value==null?"":String(t.value),m=`msj-rating-bg-${t.id}`,d=s.rateType??"labels",u=s.scaleColorMode,r=s.minRateDescription,x=s.maxRateDescription,h=s.displayRateDescriptionsAsExtremeItems,_=o.findIndex(p=>String(p.value)===c);return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__rating","data-type":d,"data-color-mode":u,children:[r&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--min",children:r}):null,o.map((p,g)=>{const b=String(p.value);let v=p.text??b;h&&(g===0&&r&&(v=r),g===o.length-1&&x&&(v=x));const k=c===b,I=d==="stars"&&_>=0?g<=_:k;let M;return u==="colored"&&(M={"--msj-rating-color":`hsl(${o.length>1?g/(o.length-1)*120:60}, 70%, 50%)`}),e.jsxs(j.motion.button,{type:"button",className:"msj__ratingItem",onClick:()=>R(t,p.value),layout:!0,transition:{duration:n.duration},"aria-label":v,style:M,children:[k?e.jsx(j.motion.span,{className:"msj__ratingItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__ratingItemContent",children:[d==="stars"?e.jsx(pt,{active:I}):null,d==="smileys"?e.jsx(gt,{idx:g,total:o.length}):null,d==="labels"?v:null]})]},b)}),x&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--max",children:x}):null]}),e.jsx($,{errors:l,opts:n})]})}function yt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.items??[],c=t.value??{};return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__multipleText",children:o.map((m,d)=>{const u=`${t.id}-${m.name}`;return e.jsxs(j.motion.div,{className:"msj__multipleTextRow",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:d*.05,duration:n.duration},children:[e.jsx(_e.Root,{className:"msj__labelInline",htmlFor:u,children:m.title??m.name}),e.jsx("input",{id:u,className:"msj__input",value:c[m.name]??"",onChange:r=>{R(t,{...c,[m.name]:r.currentTarget.value})}})]},m.name)})}),e.jsx($,{errors:l,opts:n})]})}function bt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.visibleChoices??[],c=!!s.multiSelect,m=new Set(c?Array.isArray(t.value)?t.value:[]:[t.value]),d={rest:{opacity:0},hover:{opacity:1}};return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__imagePicker",children:o.map(u=>{const r=String(u.value),x=m.has(u.value),h=`msj-imagePicker-bg-${t.id}`;return e.jsxs(j.motion.button,{type:"button",className:x?"msj__imagePickerItem msj__imagePickerItem--active":"msj__imagePickerItem",onClick:()=>{if(!c){R(t,u.value);return}const _=new Set(Array.isArray(t.value)?t.value:[]);_.has(u.value)?_.delete(u.value):_.add(u.value),R(t,Array.from(_))},layout:!0,initial:"rest",whileHover:x?void 0:"hover",transition:{duration:n.duration},children:[x?null:e.jsx(j.motion.span,{className:"msj__imagePickerHoverBg",variants:d,transition:{type:"spring",stiffness:700,damping:45}}),x?e.jsx(j.motion.span,{className:"msj__imagePickerItemBg",layoutId:h,transition:{type:"spring",stiffness:700,damping:40}}):null,u.imageLink?e.jsx("img",{className:"msj__imagePickerImg",src:u.imageLink,alt:u.text??r}):null,u.text?e.jsx("span",{className:"msj__imagePickerLabel",children:u.text}):null]},r)})}),e.jsx($,{errors:l,opts:n})]})}function Nt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.visibleChoices??[],c=t.value==null?"":String(t.value),m=`msj-btnGroup-bg-${t.id}`;return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__buttonGroup",children:o.map(d=>{const u=String(d.value),r=c===u;return e.jsxs(j.motion.button,{type:"button",className:r?"msj__buttonGroupItem msj__buttonGroupItem--active":"msj__buttonGroupItem",onClick:()=>R(t,d.value),layout:!0,transition:{duration:n.duration},children:[r?e.jsx(j.motion.span,{className:"msj__buttonGroupItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsx("span",{className:"msj__buttonGroupItemContent",children:d.text??u})]},u)})}),e.jsx($,{errors:l,opts:n})]})}function kt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.visibleChoices??[],c=new Set(Array.isArray(t.value)?t.value:[]);return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__tagbox",children:o.map(m=>{const d=m.value,u=String(d),r=c.has(d);return e.jsxs(j.motion.button,{type:"button",className:r?"msj__tag msj__tag--active":"msj__tag",onClick:()=>{const x=new Set(Array.isArray(t.value)?t.value:[]);x.has(d)?x.delete(d):x.add(d),R(t,Array.from(x))},initial:!1,animate:r?{scale:1.02}:{scale:1},whileHover:{scale:1.04},whileTap:{scale:.97},transition:{type:"spring",stiffness:500,damping:30},children:[r?e.jsx(j.motion.span,{className:"msj__tagBg",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{type:"spring",stiffness:500,damping:35}}):null,e.jsx("span",{className:"msj__tagContent",children:m.text??u})]},u)})}),e.jsx($,{errors:l,opts:n})]})}const je=({value:t,text:n,index:s,total:a,onClick:l,onMoveUp:o,onMoveDown:c,isRanked:m,longTap:d,enableDrag:u=!0})=>{const r=j.useDragControls(),x=S.useRef(null),h=b=>{d&&!l?(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{r.start(b),navigator.vibrate&&navigator.vibrate(50)},500)):l||r.start(b)},_=()=>{x.current&&(clearTimeout(x.current),x.current=null)},p=b=>{l&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),l())},g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"msj__rankingLabel",style:{flex:1},children:n}),e.jsxs("span",{className:"msj__rankingControls",style:{display:"flex",alignItems:"center",gap:"8px"},children:[l&&(m?e.jsx(ft,{size:16}):e.jsx(dt,{size:16})),!l&&e.jsxs(e.Fragment,{children:[o&&s!==void 0&&s>0&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),o()},"aria-label":"Move up",children:e.jsx(tt,{size:16})}),c&&s!==void 0&&a!==void 0&&s<a-1&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),c()},"aria-label":"Move down",children:e.jsx(Ze,{size:16})}),e.jsx("div",{className:"msj__dragHandle",onPointerDown:h,onPointerUp:_,onPointerLeave:_,style:{cursor:d?"context-menu":"grab",display:"flex",alignItems:"center",padding:"4px"},children:e.jsx(rt,{size:16,className:"msj__muted"})})]})]})]});return u?e.jsx(j.Reorder.Item,{value:t,className:"msj__rankingItem",dragListener:!1,dragControls:r,onClick:l,onKeyDown:p,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${n}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g}):e.jsx("li",{className:"msj__rankingItem",onClick:l,onKeyDown:p,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${n}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g})};function wt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.visibleChoices??[],c=Array.isArray(t.value)?t.value:[],m=s.selectToRankEnabled===!0,d=s.selectToRankAreasLayout||"horizontal",u=s.selectToRankEmptyRankedAreaText||"Drag items here to rank them",r=s.selectToRankEmptyUnrankedAreaText||"All items ranked",x=s.longTap===!0,h=m?c:[...new Set([...c,...o.map(v=>v.value)])],_=m?o.filter(v=>!c.includes(v.value)).map(v=>v.value):[],p=v=>{R(t,v)},g=v=>{const k=[...c,v];R(t,k)},b=v=>{const k=c.filter(I=>I!==v);R(t,k)};return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),m?e.jsxs("div",{className:`msj__rankingContainer msj__rankingContainer--${d}`,children:[e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Choices"}),_.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:r}),e.jsx(j.motion.ul,{className:"msj__ranking",layout:!0,children:e.jsx(j.AnimatePresence,{initial:!1,children:_.map(v=>{const k=String(v),I=o.find(M=>M.value===v)?.text??k;return e.jsx(j.motion.div,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:e.jsx(je,{value:v,text:I,onClick:()=>g(v),isRanked:!1,longTap:x,enableDrag:!1})},k)})})})]}),e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Ranked"}),h.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:u}),e.jsx(j.Reorder.Group,{axis:"y",values:h,onReorder:p,className:"msj__ranking",children:e.jsx(j.AnimatePresence,{initial:!1,children:h.map(v=>{const k=String(v),I=o.find(M=>M.value===v)?.text??k;return e.jsx(je,{value:v,text:I,onClick:()=>b(v),isRanked:!0,longTap:x},k)})})})]})]}):e.jsx(j.Reorder.Group,{axis:"y",values:h,onReorder:p,className:"msj__ranking",children:h.map((v,k)=>{const I=String(v),M=o.find(A=>A.value===v)?.text??I,Q=()=>{if(k>0){const A=[...h],Y=A[k];A[k]=A[k-1],A[k-1]=Y,p(A)}},X=()=>{if(k<h.length-1){const A=[...h],Y=A[k];A[k]=A[k+1],A[k+1]=Y,p(A)}};return e.jsx(je,{value:v,text:M,index:k,total:h.length,onMoveUp:Q,onMoveDown:X,longTap:x},I)})}),e.jsx($,{errors:l,opts:n})]})}async function St(t){const n=await new Promise(s=>{const a=new FileReader;a.onload=()=>s(String(a.result??"")),a.readAsDataURL(t)});return{name:t.name,type:t.type,content:n}}function Tt({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],[o,c]=S.useState(!1),m=async d=>{const u=await Promise.all(d.map(St));R(t,s.allowMultiple===!0?u:u[0]??void 0)};return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(j.motion.div,{className:"msj__fileDropZone",initial:!1,animate:o?{scale:1.02,borderColor:"var(--msj-primary)"}:{scale:1,borderColor:"var(--msj-border)"},transition:{type:"spring",stiffness:400,damping:25},onDragOver:d=>{d.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:async d=>{d.preventDefault(),c(!1);const u=Array.from(d.dataTransfer.files);u.length>0&&await m(u)},children:[e.jsx("input",{className:"msj__fileInput",type:"file",multiple:s.allowMultiple===!0,onChange:async d=>{const u=Array.from(d.currentTarget.files??[]);await m(u)}}),e.jsx("span",{className:"msj__fileDropText",children:o?"Drop files here":"Click or drag files here"})]}),e.jsx($,{errors:l,opts:n})]})}function Rt({question:t,opts:n}){const s=P(t,n),a=n.validationSeq>0?O(t):[],l=S.useRef(null),o=S.useRef(!1),[c,m]=S.useState(0);return S.useEffect(()=>{const d=l.current;if(!d)return;let u=null;try{u=d.getContext("2d")}catch{return}if(!u)return;u.lineWidth=2,u.lineCap="round",u.strokeStyle="rgba(15, 23, 42, 0.9)";const r=p=>{const g=d.getBoundingClientRect(),b=d.width/g.width,v=d.height/g.height;return{x:(p.clientX-g.left)*b,y:(p.clientY-g.top)*v}},x=p=>{o.current=!0;try{d.setPointerCapture(p.pointerId)}catch{}const g=r(p);u.beginPath(),u.moveTo(g.x,g.y)},h=p=>{if(!o.current)return;const g=r(p);u.lineTo(g.x,g.y),u.stroke()},_=()=>{if(o.current){o.current=!1;try{R(t,d.toDataURL("image/png"))}catch{}}};return d.addEventListener("pointerdown",x),d.addEventListener("pointermove",h),window.addEventListener("pointerup",_),()=>{d.removeEventListener("pointerdown",x),d.removeEventListener("pointermove",h),window.removeEventListener("pointerup",_)}},[t,c]),e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[s,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__signaturePadWrap",children:[e.jsx(j.motion.canvas,{ref:l,className:"msj__signaturePad",width:560,height:160,initial:{opacity:0},animate:{opacity:1},transition:{duration:.2}},c),e.jsx(j.motion.button,{type:"button",className:"msj__miniButton",whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{m(d=>d+1),R(t,void 0)},children:"Clear"})]}),e.jsx($,{errors:a,opts:n})]})}function Ct({question:t,opts:n,render:s}){const a=t,l=P(t,n),o=a.panels??[];return e.jsxs(C,{element:t,opts:n,children:[e.jsx("div",{className:"msj__label",children:l}),e.jsxs("div",{className:"msj__panelDynamic",children:[e.jsx(j.AnimatePresence,{mode:"popLayout",children:o.map((c,m)=>e.jsxs(j.motion.div,{className:"msj__panelDynamicItem",initial:{opacity:0,y:-10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},transition:{type:"spring",stiffness:500,damping:35},children:[e.jsxs("div",{className:"msj__panelDynamicHeader",children:[e.jsxs("div",{className:"msj__panelDynamicTitle",children:["Item ",m+1]}),a.removePanel?e.jsx(j.motion.button,{type:"button",className:"msj__miniButton",onClick:()=>a.removePanel?.(c),whileHover:{scale:1.05},whileTap:{scale:.95},children:"Remove"}):null]}),s(c,n)]},c.name??m))}),a.addPanel?e.jsx(j.motion.button,{type:"button",className:"msj__button",onClick:()=>a.addPanel?.(),whileHover:{scale:1.02},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:25},children:"Add item"}):null]})]})}function Et({question:t,opts:n}){const s=t,a=P(t,n),l=n.validationSeq>0?O(t):[],o=s.rows??s.visibleRows??[],c=s.columns??s.visibleColumns??[],m=t.value??{},d=s.cellType==="checkbox";return e.jsxs(C,{element:t,opts:n,children:[e.jsxs("div",{className:"msj__label",children:[a,t.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__matrix",style:{"--msj-matrix-cols":String(c.length)},children:[e.jsxs("div",{className:"msj__matrixHeader","aria-hidden":!0,children:[e.jsx("div",{className:"msj__matrixHeaderCell msj__matrixCorner"}),c.map(u=>{const r=String(u.value);return e.jsx("div",{className:"msj__matrixHeaderCell",children:u.text??r},r)})]}),o.map(u=>{const r=String(u.value),x=u.text??r;return e.jsxs("div",{className:"msj__matrixRow",children:[e.jsx("div",{className:"msj__matrixRowTitle",children:x}),d?e.jsx("div",{className:"msj__matrixRowChoices",children:c.map(h=>{const _=String(h.value),p=Array.isArray(m[r])?m[r]:[],g=p.includes(h.value);return e.jsx("label",{className:"msj__matrixCell","data-state":g?"checked":"unchecked",children:e.jsx(me.Root,{className:"msj__checkbox",checked:g,onCheckedChange:b=>{const v=new Set(p);b===!0?v.add(h.value):v.delete(h.value),R(t,{...m,[r]:Array.from(v)})},children:e.jsx(me.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(j.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:g?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,n.duration*.5)},children:e.jsx(ke,{active:g,duration:Math.max(.22,n.duration*1.2)})})})})},_)})}):e.jsx(H.Root,{className:"msj__matrixRowChoices",value:m[r]==null?"":String(m[r]),onValueChange:h=>{R(t,{...m,[r]:h})},children:c.map(h=>{const _=String(h.value),p=h.text??_,g=String(m[r]??"")===_;return e.jsx(H.Item,{value:_,asChild:!0,children:e.jsx("button",{type:"button",className:"msj__matrixCell","aria-label":`${x}: ${p}`,"data-state":g?"checked":"unchecked",children:e.jsxs("span",{className:"msj__radioItem","aria-hidden":!0,children:[e.jsx(H.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(j.motion.span,{className:"msj__radioIndicator",initial:!1,animate:g?{scale:1,opacity:1}:{scale:0,opacity:0},transition:g?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,n.duration*.4)}})}),g?e.jsx(j.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,n.duration*1.4)}}):null]})})},`${r}:${_}`)})})]},r)})]}),e.jsx($,{errors:l,opts:n})]})}function Pt({question:t,opts:n}){const s=P(t,n);return e.jsxs(C,{element:t,opts:n,children:[e.jsx("div",{className:"msj__label",children:s}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dropdown is not yet fully supported."})]})}function It({question:t,opts:n}){const s=P(t,n);return e.jsxs(C,{element:t,opts:n,children:[e.jsx("div",{className:"msj__label",children:s}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dynamic is not yet fully supported."})]})}function xe({element:t,opts:n,render:s}){const a=t,l=a.elements??[];return e.jsxs(C,{element:t,opts:n,children:[a.title?e.jsx("div",{className:"msj__label",children:a.title}):null,e.jsx("div",{className:"msj__panel",children:l.map((o,c)=>{const m=typeof o.getType=="function"?o.getType():"unknown",d=o.name??`${m}-${c}`;return e.jsx("div",{children:s(o,n)},d)})})]})}function ae(t,n){const s=typeof t.getType=="function"?t.getType():"unknown";if(!(t instanceof re.Question))switch(s){case"flowpanel":return e.jsx(xe,{element:t,opts:n,render:ae});case"page":return e.jsx(xe,{element:t,opts:n,render:ae});default:return e.jsx(xe,{element:t,opts:n,render:ae})}const a=t;switch(s){case"comment":return e.jsx(De,{question:a,opts:n});case"boolean":return e.jsx(Fe,{question:a,opts:n});case"radiogroup":return e.jsx(ve,{question:a,isMulti:!1,opts:n});case"checkbox":return e.jsx(ve,{question:a,isMulti:!0,opts:n});case"dropdown":return e.jsx(Be,{question:a,opts:n});case"tagbox":return e.jsx(kt,{question:a,opts:n});case"buttongroup":return e.jsx(Nt,{question:a,opts:n});case"ranking":return e.jsx(wt,{question:a,opts:n});case"imagepicker":return e.jsx(bt,{question:a,opts:n});case"file":return e.jsx(Tt,{question:a,opts:n});case"signaturepad":return e.jsx(Rt,{question:a,opts:n});case"paneldynamic":return e.jsx(Ct,{question:a,opts:n,render:ae});case"matrix":return e.jsx(Et,{question:a,opts:n});case"matrixdropdown":return e.jsx(Pt,{question:a,opts:n});case"matrixdynamic":return e.jsx(It,{question:a,opts:n});case"html":return e.jsx(Ve,{question:a,opts:n});case"image":return e.jsx(He,{question:a,opts:n});case"expression":return e.jsx(Qe,{question:a,opts:n});case"empty":return e.jsx(Ye,{question:a,opts:n});case"rating":return e.jsx(vt,{question:a,opts:n});case"multipletext":return e.jsx(yt,{question:a,opts:n});case"text":default:return e.jsx(Oe,{question:a,opts:n})}}function be({survey:t}){const n=t.logo;if(!n)return null;const s=t.logoWidth,a=t.logoHeight,l=t.logoFit??"contain",o=t.logoPosition??"left";if(o==="none")return null;const c={objectFit:l,width:s?typeof s=="number"?`${s}px`:s:void 0,height:a?typeof a=="number"?`${a}px`:a:void 0};return e.jsx("img",{src:n,alt:"Survey Logo",className:`msj__logo msj__logo--${o}`,style:c})}const At="Previous",Lt="Next",$t="Complete",Mt="Thanks!",Ot="Your responses have been recorded.",Dt="Select…",Ft="{count}/{max} words",Bt="Page {current} of {total}",Vt={back:At,next:Lt,complete:$t,thanksTitle:Mt,thanksHint:Ot,selectPlaceholder:Dt,wordCount:Ft,pageXofY:Bt},Ht="Previous",Qt="Next",Yt="Complete",Wt="Thanks!",Ut="Your responses have been recorded.",zt="Select…",Gt="{count}/{max} words",qt="Page {current} of {total}",Xt={back:Ht,next:Qt,complete:Yt,thanksTitle:Wt,thanksHint:Ut,selectPlaceholder:zt,wordCount:Gt,pageXofY:qt},Ne={"en-US":Xt,"en-GB":Vt};function Jt(t){return Ne[t??"en-US"]??Ne["en-US"]}function Kt({locale:t,messages:n}){const a={...Jt(t),...n??{}};return(l,o)=>{let c=a[l]??l;if(o)for(const[m,d]of Object.entries(o))c=c.replaceAll(`{${m}}`,String(d));return c}}function Zt(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M10 3.5 6 8l4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function en(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M6 3.5 10 8l-4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function tn({json:t,model:n,data:s,onComplete:a,animate:l=!0,animationDurationMs:o=180,theme:c="modern",locale:m="en-US",messages:d,className:u}){const r=S.useMemo(()=>{if(n)return n;const f=t??{},T=f.showQuestionNumbers===void 0?{...f,showQuestionNumbers:"onPage"}:f,N=new re.Model(T);return s&&(N.data=s),N},[n,t,s]),[,x]=S.useReducer(f=>f+1,0),[h,_]=S.useReducer((f,T)=>T.type==="setPage"?{pageName:T.pageName,seq:0}:f.pageName!==T.pageName?{pageName:T.pageName,seq:1}:{pageName:f.pageName,seq:f.seq+1},{pageName:null,seq:0}),p=S.useRef(null),g=o/1e3,b=S.useMemo(()=>Kt({locale:m,messages:d}),[m,d]),[v,k]=S.useState(null),I=["msj",c?`msj--theme-${c}`:null,u].filter(Boolean).join(" "),M=r.logoPosition??"left",Q=r.backgroundImage,X=r.backgroundImageFit??"auto",A=r.backgroundImageAttachment??"scroll",Y=r.backgroundOpacity??1,U=Q?{backgroundImage:`url(${Q})`,backgroundSize:X,backgroundAttachment:A,opacity:Y}:void 0;if(S.useEffect(()=>{const f=()=>x(),T=()=>{_({type:"setPage",pageName:r.currentPage?.name??null}),f()},N=()=>{a?.(r.data,r),f()};return r.onValueChanged.add(f),r.onCurrentPageChanged.add(T),r.onComplete.add(N),()=>{r.onValueChanged.remove(f),r.onCurrentPageChanged.remove(T),r.onComplete.remove(N)}},[r,a]),S.useEffect(()=>{const f=p.current;if(!f)return;p.current=null;const T=typeof window<"u"&&window.CSS&&typeof window.CSS.escape=="function"?window.CSS.escape:W=>W.replaceAll('"','\\"'),N=document.querySelector(`[data-msj-question="${T(f)}"]`);if(!N)return;const L=N.querySelector('input, textarea, select, button, [tabindex]:not([tabindex="-1"])');try{N.scrollIntoView({behavior:"smooth",block:"center"})}catch{N.scrollIntoView()}L?.focus({preventScroll:!0})}),r.state==="loading"){const f=r.loadingHtml;return e.jsx("div",{className:I,children:e.jsx("div",{className:"msj__card",children:f?e.jsx("div",{dangerouslySetInnerHTML:{__html:f}}):e.jsx("div",{className:"msj__hint",children:"Loading..."})})})}if(r.state==="completed"){const f=r.completedHtml,T=r.completedBeforeHtml;return e.jsx("div",{className:I,children:e.jsxs("div",{className:"msj__card",children:[T?e.jsx("div",{dangerouslySetInnerHTML:{__html:T}}):null,f?e.jsx("div",{dangerouslySetInnerHTML:{__html:f}}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"msj__title",children:b("thanksTitle")}),e.jsx("div",{className:"msj__hint",children:b("thanksHint")})]})]})})}const D=r.currentPage,J=D?.questions??[],K=D?.elements??J,ie=h.pageName===(D?.name??null)?h.seq:0,le=r.showPageTitles!==!1,z=r.showPageNumbers===!0,V=r.showQuestionNumbers,oe=V===!0?"on":V===!1?"off":V==="off"||V==="on"||V==="onPage"?V:"onPage",Z=r.navigationButtonsLocation??"bottom",ce=r.showNavigationButtons!==!1,ee=D?.navigationButtonsVisibility??"inherit",i=ee==="hide"?!1:ee==="show"?!0:ce,y=r.showPrevButton!==!1,w=i&&y&&!r.isFirstPage,E=i&&!r.isLastPage,G=i&&r.isLastPage,q=f=>Z==="topBottom"||Z===f?e.jsxs("div",{className:f==="top"?"msj__nav msj__nav--top":"msj__nav",children:[e.jsx("div",{className:"msj__navSlot msj__navSlot--left",children:e.jsx(j.AnimatePresence,{initial:!1,children:w?e.jsxs(j.motion.button,{type:"button",className:"msj__button msj__button--nav",onClick:()=>{r.prevPage(),x()},initial:l?{opacity:0,x:-6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:-6}:void 0,transition:{duration:g},whileHover:l?{x:-2}:void 0,whileTap:l?{scale:.98}:void 0,children:[e.jsx(Zt,{}),b("back")]},"prev"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--center",children:e.jsx(j.AnimatePresence,{initial:!1,children:G?e.jsx(j.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--complete",onClick:()=>{let N=!1;try{N=r.validateCurrentPage()}catch{N=!1}if(!N){const L=J.find(W=>W.hasErrors());p.current=L?.name??null,_({type:"bump",pageName:D?.name??null}),x();return}r.tryComplete(),x()},initial:l?{opacity:0,y:6,scale:.98}:!1,animate:l?{opacity:1,y:0,scale:1}:void 0,exit:l?{opacity:0,y:6,scale:.98}:void 0,transition:{duration:g,x:{type:"tween",duration:.32,ease:"easeInOut"},rotate:{type:"tween",duration:.32,ease:"easeInOut"}},whileHover:l?{x:[0,-2,2,-2,0],rotate:[0,-1.2,1.2,-1.2,0]}:void 0,whileTap:l?{scale:.98}:void 0,children:b("complete")},"complete"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--right",children:e.jsx(j.AnimatePresence,{initial:!1,children:E?e.jsxs(j.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--navPrimary",onClick:()=>{let N=!1;try{N=r.validateCurrentPage()}catch{N=!1}if(!N){const L=J.find(W=>W.hasErrors());p.current=L?.name??null,_({type:"bump",pageName:D?.name??null}),x();return}r.nextPage(),x()},initial:l?{opacity:0,x:6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:6}:void 0,transition:{duration:g},whileHover:l?{x:2}:void 0,whileTap:l?{scale:.98}:void 0,children:[b("next"),e.jsx(en,{})]},"next"):null})})]}):null;return e.jsxs("div",{className:I,ref:k,children:[U?e.jsx("div",{className:"msj__background",style:U}):null,e.jsxs("div",{className:"msj__card",children:[M!=="bottom"?e.jsx(be,{survey:r}):null,r.title?e.jsx("h2",{className:"msj__title",children:r.title}):null,q("top"),e.jsx(j.AnimatePresence,{mode:"wait",initial:!1,children:e.jsxs(j.motion.div,{initial:l?{opacity:0,y:8}:!1,animate:l?{opacity:1,y:0}:void 0,exit:l?{opacity:0,y:-8}:void 0,transition:{duration:g},children:[le||z?e.jsxs("div",{className:"msj__pageHeader",children:[le&&D?.title?e.jsx("div",{className:"msj__pageTitle",children:D.title}):null,z?e.jsx("div",{className:"msj__pageNumber",children:b("pageXofY",{current:(r.currentPageNo??0)+1,total:r.pages?.length??0})}):null]}):null,(()=>{const f=(r.pages??[]).slice(0,r.currentPageNo??0).reduce((N,L)=>N+(L.questions??[]).length,0);return K.reduce((N,L,W)=>{const te=typeof L.getType=="function"?L.getType():"unknown",ue=L instanceof re.Question&&te!=="html"&&te!=="image"&&te!=="expression"&&te!=="empty",Se=ue?N.pageQuestionIndex:-1,Te=ue?N.globalQuestionIndex:-1,Re=L.name??`${te}-${W}`;return{items:[...N.items,e.jsx("div",{children:ae(L,{animate:l,duration:g,t:b,validationSeq:ie,questionIndex:Se,globalQuestionIndex:Te,showQuestionNumbers:oe,portalContainer:v})},Re)],pageQuestionIndex:ue?N.pageQuestionIndex+1:N.pageQuestionIndex,globalQuestionIndex:ue?N.globalQuestionIndex+1:N.globalQuestionIndex}},{items:[],pageQuestionIndex:0,globalQuestionIndex:f}).items})()]},D?.name??"page")}),q("bottom"),M==="bottom"?e.jsx(be,{survey:r}):null]})]})}exports.MotionSurvey=tn;
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|