{"version":3,"file":"NextSfaEmbeddedForm.an5ldw9D.mjs","names":["React.useState","React.useId","formElement"],"sources":["https:/framerusercontent.com/modules/VUnmSijcuFEJeMn93MLG/PvPGsljNUI00AGzr8g3T/NextSfaEmbeddedForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const DEFAULT_SCRIPT_URL=\"https://geo-code-cloud.s3-ap-northeast-1.amazonaws.com/next-sfa/js/gc.nsfa.form.min.js\";function loadNextSfaScript(scriptUrl){if(typeof window===\"undefined\"||typeof document===\"undefined\"){return Promise.resolve();}if(window.__nextSfaFormScriptLoaded||typeof window.openForm===\"function\"){return Promise.resolve();}if(window.__nextSfaFormScriptPromise)return window.__nextSfaFormScriptPromise;const existingScript=document.querySelector(`script[src=\"${scriptUrl}\"]`);window.__nextSfaFormScriptPromise=new Promise((resolve,reject)=>{if(existingScript){if(existingScript.dataset.loaded===\"true\"){window.__nextSfaFormScriptLoaded=true;resolve();return;}existingScript.addEventListener(\"load\",()=>{existingScript.dataset.loaded=\"true\";window.__nextSfaFormScriptLoaded=true;resolve();},{once:true});existingScript.addEventListener(\"error\",()=>reject(new Error(\"Failed to load nextSFA form script\")),{once:true});return;}const script=document.createElement(\"script\");script.src=scriptUrl;script.async=false;script.dataset.nextSfaForm=\"true\";script.onload=()=>{script.dataset.loaded=\"true\";window.__nextSfaFormScriptLoaded=true;resolve();};script.onerror=()=>reject(new Error(\"Failed to load nextSFA form script\"));document.body.appendChild(script);});return window.__nextSfaFormScriptPromise;}function waitForOpenForm(timeout=6e3){const startedAt=Date.now();return new Promise((resolve,reject)=>{const check=()=>{if(typeof window.openForm===\"function\"){resolve();return;}if(Date.now()-startedAt>timeout){reject(new Error(\"nextSFA openForm was not available\"));return;}window.setTimeout(check,100);};check();});}/**\n * nextSFA Embedded Form\n *\n * Renders the official nextSFA form directly in the Framer page so the published page URL is used as the referrer.\n *\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 560\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function NextSfaEmbeddedForm(props){const{token,formId,formWidth,scriptUrl,minHeight,padding,borderRadius,background,loadingText,style}=props;const htmlFormId=`sfaForm_${formId}`;const[status,setStatus]=React.useState(\"loading\");const mountKey=React.useId().replace(/:/g,\"\");React.useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;let cancelled=false;const formElement=document.getElementById(htmlFormId);if(formElement)formElement.innerHTML=\"\";setStatus(\"loading\");const initialize=()=>{if(cancelled||typeof window.openForm!==\"function\")return;const formElement=document.getElementById(htmlFormId);if(!formElement)return;formElement.innerHTML=\"\";window.__nextSfaFormInitialized=window.__nextSfaFormInitialized||{};window.__nextSfaFormInitialized[mountKey]=Date.now();try{window.openForm(token,formWidth,formId);setStatus(\"ready\");}catch(error){console.error(\"nextSFA openForm failed\",error);setStatus(\"error\");}};loadNextSfaScript(scriptUrl).then(()=>waitForOpenForm()).then(()=>{if(document.readyState===\"complete\"){window.setTimeout(initialize,50);}else{window.addEventListener(\"load\",()=>window.setTimeout(initialize,50),{once:true});}}).catch(()=>{if(!cancelled)setStatus(\"error\");});return()=>{cancelled=true;};},[htmlFormId,token,formWidth,formId,scriptUrl,mountKey]);const innerMinHeight=Math.max(minHeight-padding*2,320);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",height:\"100%\",minHeight,background,borderRadius,boxSizing:\"border-box\",padding,overflowX:\"hidden\",overflowY:\"auto\",WebkitOverflowScrolling:\"touch\"},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                #${htmlFormId}, #${htmlFormId} * {\n                    box-sizing: border-box;\n                    max-width: 100%;\n                }\n                #${htmlFormId} {\n                    width: 100% !important;\n                    min-height: ${innerMinHeight}px;\n                    margin: 0 !important;\n                    overflow-x: hidden;\n                    overflow-wrap: break-word;\n                }\n                #${htmlFormId} table,\n                #${htmlFormId} iframe {\n                    width: 100% !important;\n                    max-width: 100% !important;\n                }\n                #${htmlFormId} input,\n                #${htmlFormId} select,\n                #${htmlFormId} textarea,\n                #${htmlFormId} button {\n                    max-width: 100% !important;\n                }\n                #${htmlFormId} img {\n                    max-width: 100% !important;\n                    height: auto !important;\n                }\n            `}),/*#__PURE__*/_jsx(\"form\",{id:htmlFormId,style:{width:\"100%\",margin:0}}),status!==\"ready\"&&/*#__PURE__*/_jsx(\"div\",{\"aria-live\":\"polite\",style:{width:\"100%\",minHeight:160,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:status===\"error\"?\"#B42318\":\"#5A6B82\",fontFamily:\"Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif\",fontSize:14,lineHeight:1.6,textAlign:\"center\"},children:status===\"error\"?\"フォームを読み込めませんでした。時間をおいて再度お試しください。\":loadingText})]});}addPropertyControls(NextSfaEmbeddedForm,{token:{type:ControlType.String,title:\"Token\",defaultValue:\"NA7QkhxT3CvCQCOcXLguVln6BsRU9FEw\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"23\"},formWidth:{type:ControlType.String,title:\"Form Width\",defaultValue:\"500\"},scriptUrl:{type:ControlType.String,title:\"Script URL\",defaultValue:DEFAULT_SCRIPT_URL},minHeight:{type:ControlType.Number,title:\"Min Height\",defaultValue:520,min:320,max:900,step:10,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:0,min:0,max:48,step:1,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:18,min:0,max:32,step:1,unit:\"px\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},loadingText:{type:ControlType.String,title:\"Loading Text\",defaultValue:\"フォームを読み込んでいます...\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NextSfaEmbeddedForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"560\",\"framerContractVersion\":\"1\",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